eth, internal/web3ext: implement storageRangeAt#3407
Conversation
|
@obscuren, thanks for your PR! By analyzing the history of the files in this pull request, we identified @Arachnid, @tgerring and @Gustav-Simonsson to be potential reviewers. |
95f570e to
9c7a7c1
Compare
var h = eth.getBlock(eth.blockNumber-2).hash;
var a = "0xFA7B9770Ca4cb04296Cac84F37736d4041251CDF";
var s = "0x0000000000000000000000000000000000000000000000000000000000000001";
var e = "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff";
debug.storageRangeAt(h, 0, a, s, e, 100)returns: |
|
Please rename to storageRangeAt. You also need to rebase because the environment PR is merged. |
bf4b982 to
9373fb8
Compare
StorageAt is currently limited and requires needless iterations due to the limitation of the trie iterator. At present we can't start iterating from any given key, thus we need to loop over any key that's not inclusive in the range of start and end.
|
@obscuren this should work in the light client odr as well right? |
| } | ||
| stateDb.DeleteSuicides() | ||
| continue | ||
| } |
There was a problem hiding this comment.
Please extract this code into its own function. This basically recomputes the state up to a certain transaction
and is duplicated in the tracing code just above.
| trie := stateObject.GetTrie(api.eth.ChainDb()) | ||
| it := trie.Iterator() | ||
|
|
||
| for it.Next() && len(result.Storage) < maxResult { |
There was a problem hiding this comment.
would be better to use ForEachStorage here instead of exposing the trie
|
I've done the updates myself. The current version is pretty useless because it keeps the first n keys hit by the random iteration order. It'd be better to keep a sorted buffer so the function always returns the n lowest keys instead. I'll add that next. |
I'm taking over the PR because @obscuren is sick.
|
Postponed to 1.5.6 |
7c101dc to
cff315d
Compare
|
@obscuren Please review this. The API has changed and is now correct in cases where pre-images of storage keys are missing. In your initial implementation, such keys would override the entry for 0x0000..00. I have discussed this change with @chriseth and @yann300. The other bug that I fixed is the one mentioned above: your implementation kept the first N matching keys found during random iteration. This caused random gaps in the result, making the API pretty useless for actually syncing storage to the client. The new implementation returns the first N keys from the starting key out of all keys in storage. Clients can use this to download full storage incrementally by requesting from 0x00 with limit 100, then using the last key + 1 as the start key for the next call. Example (on ropsten): |
|
Now that I think about it, the API still isn't right. It works reasonably well when key pre-images are available. When they're not, all @chriseth @yann300 please comment. This API is for remix so the result should make sense for whatever remix is doing. |
|
Concerning |
|
@gumb0 could you please adjust the implementation in cpp-ethereum to the new specification? |
|
@fjl Is still still slated for 1.5.6 or do we push it out to 1.5.7? I'd like to finish the release merges today. |
|
@fjl instead of returning an array for the storage, |
|
Yes |
|
@fjl is the return value is sorted by hashed keys? |
|
This is now #14350 |
StorageAt is currently limited and requires needless iterations due to
the limitation of the trie iterator. At present we can't start
iterating from any given key, thus we need to loop over any key
that's not inclusive in the range of start and end.