Skip to content

Commit a1d196b

Browse files
authored
caps/snap.md: add limit parameter in range requests (#190)
In discussion of ethereum/go-ethereum#23536, it was found that the snap specification did not include the limit parameter for account/storage range requests.
1 parent cfd36d7 commit a1d196b

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

caps/snap.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ the network.
151151

152152
### GetAccountRange (0x00)
153153

154-
`[reqID: P, rootHash: B_32, startingHash: B_32, responseBytes: P]`
154+
`[reqID: P, rootHash: B_32, startingHash: B_32, limitHash: B_32, responseBytes: P]`
155155

156156
Requests an unknown number of accounts from a given account trie, starting at the
157157
specified account hash and capped by the maximum allowed response size in bytes. The
@@ -161,6 +161,7 @@ remote node and reconstruct a state subtrie locally.
161161
- `reqID`: Request ID to match up responses with
162162
- `rootHash`: Root hash of the account trie to serve
163163
- `startingHash`: Account hash of the first to retrieve
164+
- `limitHash`: Account hash after which to stop serving data
164165
- `responseBytes`: Soft limit at which to stop returning data
165166

166167
Notes:
@@ -170,8 +171,8 @@ Notes:
170171
an empty reply. It is the responsibility of the caller to query an state not older than
171172
128 blocks.
172173
- The responding node is allowed to return **less** data than requested (own QoS limits),
173-
but the node **must** return at least one account, unless no account exists in the
174-
requested range.
174+
but the node **must** return at least one account. If no accounts exist between `startingHash` and `limitHash`, then
175+
the first (if any) account **after** `limitHash` must be provided.
175176
- The responding node **must** Merkle prove the starting hash (even if it does not exist)
176177
and the last returned account (if any exists after the starting hash).
177178

@@ -188,7 +189,7 @@ Rationale:
188189
Caveats:
189190

190191
- When requesting accounts from a starting hash, malicious nodes may skip ahead and return
191-
a gaped reply. Such a reply would cause sync to finish early with a lot of missing data.
192+
a gapped reply. Such a reply would cause sync to finish early with a lot of missing data.
192193
Proof of non-existence for the starting hash prevents this attack, completely covering
193194
the range from start to end.
194195
- No special signaling is needed if there are no more accounts after the last returned
@@ -219,7 +220,7 @@ Notes:
219220

220221
### GetStorageRanges (0x02)
221222

222-
`[reqID: P, rootHash: B_32, accountHashes: [B_32], startingHash: B, responseBytes: P]`
223+
`[reqID: P, rootHash: B_32, accountHashes: [B_32], startingHash: B, limitHash: B, responseBytes: P]`
223224

224225
Requests the storage slots of multiple accounts' storage tries. Since certain contracts
225226
have huge state, the method can also request storage slots from a single account, starting
@@ -231,6 +232,7 @@ locally.
231232
- `rootHash`: Root hash of the account trie to serve
232233
- `accountHashes`: Account hashes of the storage tries to serve
233234
- `startingHash`: Storage slot hash of the first to retrieve
235+
- `limitHash`: Storage slot hash after which to stop serving
234236
- `responseBytes`: Soft limit at which to stop returning data
235237

236238
Notes:

0 commit comments

Comments
 (0)