-
Notifications
You must be signed in to change notification settings - Fork 21.6k
core/vm: add configurable jumpdest analysis cache #32143
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
Conversation
- renamed `bitvec` to `BitVec` - `BitVec` needs to be exported to support thirdparty `JumpDests` implementations
core/vm/evm.go
Outdated
| chainConfig: chainConfig, | ||
| chainRules: chainConfig.Rules(blockCtx.BlockNumber, blockCtx.Random != nil, blockCtx.Time), | ||
| jumpDests: make(map[common.Hash]bitvec), | ||
| jumpDests: nil, |
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.
Please put this back, i.e. put make(mapJumpDests) here and remove the lazy init. Yes, there will be an extra allocation in case it's not used, but I feel it's preferable to having to init everywhere.
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.
Okay, updated the PR.
JumpDests type to abstract jumpdest analysis cachingThis adds a method on vm.EVM to set the jumpdest cache implementation. It can be used to maintain an analysis cache across VM invocations, to improve performance by skipping the analysis for already known contracts. --------- Co-authored-by: lmittmann <lmittmann@users.noreply.github.com> Co-authored-by: Felix Lange <fjl@twurst.com>
This adds a method on vm.EVM to set the jumpdest cache implementation. It can be used to maintain an analysis cache across VM invocations, to improve performance by skipping the analysis for already known contracts. --------- Co-authored-by: lmittmann <lmittmann@users.noreply.github.com> Co-authored-by: Felix Lange <fjl@twurst.com>
resolves #32137
This PR replaces
jumpDests map[common.Hash]bitvecwithjumpDests JumpDestsin theEVM. TheJumpDestsallows custom jumpdest analysis caches.I did not update the signature of
vm.NewEVMto keep the diff smaller. Instead I addedEVM.SetJumpDestswhich can be used directly after construction to set a customJumpDestsimplementation. IfSetJumpDestsis not called amapJumpDestsis set lazily within theEVM.Additionally I exported
bitvec, nowBitVec. This is necessary to support third-partyJumpDestsimplementations.