-
Notifications
You must be signed in to change notification settings - Fork 20.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
internal/ethapi: prevent unnecessary resource usage in eth_getProof implementation #27310
internal/ethapi: prevent unnecessary resource usage in eth_getProof implementation #27310
Conversation
// GetProof returns the Merkle-proof for a given account and optionally some storage keys. | ||
func (s *BlockChainAPI) GetProof(ctx context.Context, address common.Address, storageKeys []string, blockNrOrHash rpc.BlockNumberOrHash) (*AccountResult, error) { | ||
var ( | ||
keys = make([]common.Hash, len(storageKeys)) | ||
storageProof = make([]StorageResult, len(storageKeys)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe storageProofs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SGTM
Co-authored-by: Marius van der Wijden <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks for the cleanup 🙏 |
…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. Closes ethereum#27308 -------- Co-authored-by: Martin Holst Swende <[email protected]> Co-authored-by: Marius van der Wijden <[email protected]>
…tProof implementation (ethereum#27310)" This reverts commit 4fb4311.
…tProof implementation (ethereum#27310)" This reverts commit 4fb4311.
closes #27308
storageTrie
for each proof for each proof in the account, preventing repeated deep-copying of the trieCode smell:
I duplicated the
proofList
type rather than making it public. Making it public seemed like the wrong choice, as it would result in panics on misuse. There is probably a better way to do this but I'm not sufficiently familiar with the codebase