You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This performs another deep copy of the same state object,
This deep copy is performed for each user-provided hex key until an error is encountered
As a result, the RPC expends significant resources on invalid requests, which could be cheaply shortcut
So a correct request will result in N+1 deep copies of the state object (1 before the loop, and N within the loop). It will perform deep copies even if the input is malformatted (invalid hex), repeatedly until it encounters the invalid input.
Implementation
Do you have ideas regarding the implementation of this feature?
Suggestions:
Greedily validate input to prevent deep copying when input is invalid
Perform all hex deserialization first at the start of the function, rather than within the for loop [as currently written].
shortcut if any hex deser fails
this prevents resource expenditure on bad caller input
…mplementation (#27310)
Deserialize hex keys early to shortcut on invalid input, and re-use the account storageTrie for each proof for each proof in the account, preventing repeated deep-copying of the trie.
Closes#27308
--------
Co-authored-by: Martin Holst Swende <[email protected]>
Co-authored-by: Marius van der Wijden <[email protected]>
devopsbo3
pushed a commit
to HorizenOfficial/go-ethereum
that referenced
this issue
Nov 10, 2023
…mplementation (ethereum#27310)
Deserialize hex keys early to shortcut on invalid input, and re-use the account storageTrie for each proof for each proof in the account, preventing repeated deep-copying of the trie.
Closesethereum#27308
--------
Co-authored-by: Martin Holst Swende <[email protected]>
Co-authored-by: Marius van der Wijden <[email protected]>
Encountered while writing #27306
Rationale
eth_getProof
is significantly more resource-intensive than it should beeth_getProof
implementations performs N+1 deep copies, when only 1 is necessaryeth_getProof
implementations performs these expensive deep copies before performing cheap hex deserializationGetStorageProof
So a correct request will result in N+1 deep copies of the state object (1 before the loop, and N within the loop). It will perform deep copies even if the input is malformatted (invalid hex), repeatedly until it encounters the invalid input.
Implementation
Do you have ideas regarding the implementation of this feature?
Suggestions:
for
loop [as currently written].storageTrie
reference from outside the loop to generate the storage proofN
deep copies of the state objectAre you willing to implement this feature?
Yes
The text was updated successfully, but these errors were encountered: