Commit ee36f0c
committed
fix(ws): pubsub parity
Cross-checked every response and request shape in rpc/ws against
agave/pubsub-client (anza-xyz/agave) and filled the gaps. Method-level
parity was already complete, but option sets, response fields, and the
BlockSubscribe/ParsedBlockSubscribe split had drifted in ways that
produced the "unable to decode client response" error on jsonParsed
block notifications (issue #291) and left several subscriptions without
the options Agave exposes.
BlockSubscribe unification (closes #291)
----------------------------------------
BlockSubscribe now accepts every UiTransactionEncoding the RPC
supports — base58, base64, base64+zstd, jsonParsed — through a single
method, matching Agave's shape. Go can't express
#[serde(untagged)] the way Rust's EncodedTransaction does, so
BlockResult.Value is a Go-style union: BlockResultValue carries both
Block (*rpc.GetBlockResult) and ParsedBlock (*rpc.GetParsedBlockResult).
Exactly one is populated per frame, chosen by the Encoding captured at
subscribe time and routed inside decodeBlockNotification(isParsed).
base58 / base64 / base64+zstd -> Block
jsonParsed -> ParsedBlock
ParsedBlockSubscribe is marked Deprecated but continues to return
*ParsedBlockResult so nothing breaks for existing callers.
Request / config parity
-----------------------
- AccountSubscribeConfig: new struct mirroring RpcAccountInfoConfig
(commitment, encoding, dataSlice, minContextSlot). The existing
AccountSubscribe / AccountSubscribeWithOpts are preserved as thin
wrappers; AccountSubscribeWithConfig exposes the full surface.
- ProgramSubscribeConfig: new struct mirroring RpcProgramAccountsConfig
(commitment, encoding, dataSlice, filters, minContextSlot,
withContext, sortResults).
- SignatureSubscribeConfig: new struct mirroring
RpcSignatureSubscribeConfig, adds enableReceivedNotification.
- Each Config has an unexported (c *Config).params() helper that
matches Agave's serde(skip_serializing_if="Option::is_none") behavior.
Response parity
---------------
- SignatureResult.Value now models the untagged
ProcessedSignature | ReceivedSignature union via
SignatureResultValue{IsReceived, Processed}. Custom UnmarshalJSON
handles the object form ({"err":...}), the string form
"receivedSignature", and null. The old Value.Err path is replaced
by Value.Processed.Err.
- VoteResult gains VotePubkey and Signature to match RpcVote.
- SlotsUpdatesResult adds Err (Dead variant), documents which fields
are populated per discriminator.
- All Context fields across the subscription result types moved from
anonymous struct{Slot uint64} to a shared RPCResponseContext
(slot + apiVersion), matching RpcResponseContext.
Consumer adaptation
-------------------
sendAndConfirmTransaction.WaitForConfirmation adapted to the new
SignatureResult shape and loops on IsReceived until a processed
notification arrives — previously retried only once, so a second
consecutive received-only frame would have passed a nil Processed
through and wrongly reported (confirmed=true, err=nil).
Examples
--------
- rpc/ws/examples/blockSubscribe: demonstrates the Block/ParsedBlock
union via a switch on which field is populated.
- rpc/ws/examples/parsedBlockSubscribe: removed (redundant now).
Tests (new subscriptions_test.go + parsedBlockSubscribe_test.go)
----------------------------------------------------------------
Fixture JSON mirrors the wire format produced by Agave's
rpc_subscriptions.rs integration tests:
- accountNotification: base64 and jsonParsed payloads
- programNotification, logsNotification, voteNotification,
slotNotification, rootNotification
- signatureNotification: processed (null err), processed (with err),
and the "receivedSignature" string variant
- slotsUpdatesNotification: all seven SlotUpdate variants
- blockNotification: separate ParsedRoute / BinaryRoute tests that
exercise decodeBlockNotification for both branches; the binary
fixture includes a real [blob, "base64"] 2-array transaction +
meta so drift between the two shapes would fail the test
- TestConfigParams_Wire verifies per-field emission and omit behavior
on every *SubscribeConfig.1 parent 828ac78 commit ee36f0c
12 files changed
Lines changed: 1028 additions & 124 deletions
File tree
- rpc
- sendAndConfirmTransaction
- ws
- examples/blockSubscribe
Lines changed: 16 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
130 | 135 | | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
135 | 143 | | |
136 | | - | |
137 | 144 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
29 | 61 | | |
30 | 62 | | |
31 | 63 | | |
32 | | - | |
| 64 | + | |
33 | 65 | | |
34 | 66 | | |
35 | 67 | | |
36 | 68 | | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
| 69 | + | |
42 | 70 | | |
43 | 71 | | |
44 | | - | |
45 | | - | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
46 | 77 | | |
47 | 78 | | |
48 | 79 | | |
49 | 80 | | |
50 | 81 | | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
51 | 87 | | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
63 | 94 | | |
64 | | - | |
65 | | - | |
| 95 | + | |
| 96 | + | |
66 | 97 | | |
67 | 98 | | |
68 | 99 | | |
| |||
74 | 105 | | |
75 | 106 | | |
76 | 107 | | |
77 | | - | |
78 | | - | |
79 | | - | |
| 108 | + | |
80 | 109 | | |
81 | 110 | | |
82 | 111 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
25 | 28 | | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
34 | 53 | | |
35 | 54 | | |
36 | 55 | | |
| |||
76 | 95 | | |
77 | 96 | | |
78 | 97 | | |
79 | | - | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
80 | 103 | | |
81 | 104 | | |
82 | 105 | | |
| |||
85 | 108 | | |
86 | 109 | | |
87 | 110 | | |
| 111 | + | |
| 112 | + | |
88 | 113 | | |
89 | 114 | | |
90 | 115 | | |
| |||
94 | 119 | | |
95 | 120 | | |
96 | 121 | | |
| 122 | + | |
97 | 123 | | |
98 | 124 | | |
99 | 125 | | |
| |||
102 | 128 | | |
103 | 129 | | |
104 | 130 | | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | 131 | | |
109 | 132 | | |
110 | 133 | | |
| 134 | + | |
111 | 135 | | |
112 | 136 | | |
113 | 137 | | |
| |||
126 | 150 | | |
127 | 151 | | |
128 | 152 | | |
| 153 | + | |
129 | 154 | | |
130 | 155 | | |
131 | 156 | | |
132 | 157 | | |
133 | 158 | | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
| 159 | + | |
139 | 160 | | |
140 | 161 | | |
141 | 162 | | |
| |||
145 | 166 | | |
146 | 167 | | |
147 | 168 | | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
148 | 205 | | |
149 | 206 | | |
150 | 207 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
| 25 | + | |
| 26 | + | |
29 | 27 | | |
30 | 28 | | |
31 | 29 | | |
| |||
0 commit comments