fix(ws): use spec "showRewards" key in blockSubscribe params#430
Open
ozpool wants to merge 1 commit into
Open
Conversation
The blockSubscribe / parsedBlockSubscribe params object was emitting `rewards` for the rewards-toggle field, but the Solana spec uses `showRewards`. The validator silently ignored the unknown `rewards` key, which meant Rewards=false (or true) had no effect — rewards were always populated. Change both BlockSubscribe and ParsedBlockSubscribe to emit `showRewards`, matching the spec at: https://solana.com/docs/rpc/websocket/blocksubscribe Note: the HTTP getBlock RPC continues to use `rewards` — that name is correct per its own spec, only the websocket variant differs. Closes solana-foundation#208.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #208.
Bug
BlockSubscribeandParsedBlockSubscribebuild the params object with the wrong field name:The Solana websocket spec for
blockSubscribecalls this fieldshowRewards, notrewards. The validator silently ignores the unknownrewardskey, which means settingBlockSubscribeOpts.Rewards = &falsehas no effect today — rewards are always populated on the wire. The original report in #208 (open since 2024-05) cites the spec and notes there is no workaround.Note: this is not the same as the HTTP
getBlockRPC, whererewardsis the correct field name per its own spec — only the websocket variant differs.rpc/getBlock.gois left untouched.Fix
rpc/ws/blockSubscribe.go: emitshowRewardsinstead ofrewards.rpc/ws/parsedBlockSubscribe.go: same fix in the parsed variant (PR Subscribe block #203 copied the buggy name).Tests
rpc/ws/blockSubscribe_rewards_test.go(new), using the in-treemockWSServerto intercept the subscribe request and assert the params shape:TestBlockSubscribeUsesShowRewardsField— pins thatBlockSubscribeemitsshowRewards: false(and neverrewards) whenRewards = &false.TestParsedBlockSubscribeUsesShowRewardsField— same for the parsed path withRewards = &true.Diff size