Skip to content

core/vm: added JumpDests type to abstract jumpdest analysis caching #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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

lmittmann
Copy link
Contributor

resolves #32137

This PR replaces jumpDests map[common.Hash]bitvec with jumpDests JumpDests in the EVM. The JumpDests allows custom jumpdest analysis caches.

I did not update the signature of vm.NewEVM to keep the diff smaller. Instead I added EVM.SetJumpDests which can be used directly after construction to set a custom JumpDests implementation. If SetJumpDests is not called a mapJumpDests is set lazily within the EVM.
Additionally I exported bitvec, now BitVec. This is necessary to support third-party JumpDests implementations.

lmittmann added 2 commits July 3, 2025 14:13
- renamed `bitvec` to `BitVec`
- `BitVec` needs to be exported to support thirdparty `JumpDests` implementations
@lmittmann lmittmann requested a review from rjl493456442 as a code owner July 3, 2025 12:23
core/vm/evm.go Outdated
@@ -138,7 +137,7 @@ func NewEVM(blockCtx BlockContext, statedb StateDB, chainConfig *params.ChainCon
Config: config,
chainConfig: chainConfig,
chainRules: chainConfig.Rules(blockCtx.BlockNumber, blockCtx.Random != nil, blockCtx.Time),
jumpDests: make(map[common.Hash]bitvec),
jumpDests: nil,
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, updated the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

core/vm: codeBitmap is consuming ~20% of CPU time in simulation heavy workloads
2 participants