-
Notifications
You must be signed in to change notification settings - Fork 767
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Vote account parsing does not consider optional value + new account data #2013
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for pushing, here. This situation is not great and I appreciate you taking a stab!
return new OptionLayout<T>(layout, property) | ||
} | ||
|
||
class OptionLayout<T> extends BufferLayout.Layout<T | null> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should also be possible to decode options with tagged unions, right? The discriminator in this case is the 0
or the 1
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry, I haven't got this. Can you please point me to some example?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah! It's like this case:
…but where 0
means its None
and where 1
means it's Some
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could also be helpful:
@steveluscher awesome, thanks for your feedback and points 👍 I haven't got to this earlier but finally I have an update. I changed to use the version parsing as you suggested. While I fight with the buffer layout a bit so not sure if it's how you like this to be. Let me know in comment if/what should be changed. Thanks again. |
50e63ff
to
c6f1595
Compare
Because there has been no activity on this PR for 14 days since it was merged, it has been automatically locked. Please open a new issue if it requires a follow up. |
I troubled with an issue with the
fromAccountData
methodsolana-web3.js/packages/library-legacy/src/vote-account.ts
Line 180 in 24d71d6
I want to deserialize data from
AccountInfo
.as the deserialization was failing I needed to start checking the Solana code and I found a new version of the account is different from an "old" one.
Difference at Solana code at
Adding new account buffer was not enough as the current processing has an issue that does not consider the
rootSlot
as being optional (https://github.com/solana-labs/solana/blob/v1.17.15/sdk/program/src/vote/state/vote_state_1_14_11.rs#L22) and it requires it being defined all the time (https://github.com/solana-labs/solana-web3.js/blob/v1.88.0/packages/library-legacy/src/vote-account.ts#L90-L91). That's a wrong wrong deserialization processing.I don't know what's the exactly ways around this code (it's under
legacy
) and I haven't tried to put into any tests.First I would like to know if it's desirable to have the code here. Then I would like to get some feedback on the code and (if it's considered fine) then if you can share what's needed to finish the PR to be merge-able. Thanks.