Skip to content
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

feat: EVM execution opcode level optimization #77

Merged
merged 7 commits into from
Apr 9, 2024

Conversation

sunny2022da
Copy link
Collaborator

@sunny2022da sunny2022da commented Mar 28, 2024

several optimizations included:

  • opcode fusion
  • jumpdest calculation optimization
  • SHA caching in interpreter

we observed ~1.2-1.5x speedup in execution time of opbnb mainnet when syncing block at hight ~11m

Description

This PR introduce several optimizations in EVM execution engine, mainly 3 points:
opcode fusion: Combine several hottest opcodes into one super instruction to reduce strength
jumpdest calculation optimizations: reduce the unnecessary jumpdest calculation every time a call happened by leverage caching.
SHA cacheing in interpreter: optimized the SHA opcode to use hash cache that already implemented in geth.

Rationale

To speed up the execution time of contracts and hence enhance the performance.

Example

N/A

Changes

Notable changes:

  • opcode fusion
  • jumpdest calculation optimization
  • SHA caching in interpreter

several optimizations included:
- opcode fusion
- jumpdest calculation optimization
- SHA caching in interpreter

Co-authored-by: redhdx <lredhdx@gmail.com>
@sunny2022da
Copy link
Collaborator Author

UT test fails has been fixed. The current 2 failed cases seems not related with this PR.

  • TestPrecompiledPointEvaluation: seems related with ZK
  • TestExecutionSpec: seems related with gas but it fails too without this PR.

FYI

Switch interpreter jump table at runtime to avoid mismatch of optimized
opcode and the spec.
core/vm/evm.go Outdated Show resolved Hide resolved
core/vm/errors.go Outdated Show resolved Hide resolved
core/vm/instructions.go Outdated Show resolved Hide resolved
crypto/crypto.go Outdated Show resolved Hide resolved
@owen-reorg
Copy link
Collaborator

Please do refactor a little bit to avoid unnecessary changes, including format, new lines, changes with no effect, comments, etc. It will reduce potential overhead to resolve conflicts in further merge.

cmd/utils/flags.go Outdated Show resolved Hide resolved
cmd/utils/flags.go Outdated Show resolved Hide resolved
core/vm/contract.go Outdated Show resolved Hide resolved
core/vm/analysis.go Show resolved Hide resolved
core/vm/evm.go Outdated Show resolved Hide resolved
core/vm/evm.go Outdated Show resolved Hide resolved
core/vm/evm.go Outdated Show resolved Hide resolved
core/vm/evm.go Outdated Show resolved Hide resolved
@owen-reorg owen-reorg merged commit d5ba7d9 into bnb-chain:develop Apr 9, 2024
1 check passed
owen-reorg pushed a commit to owen-reorg/op-geth that referenced this pull request Apr 25, 2024
…imate

implement more accurate & predicable priority fee suggestion algorithm for chains like Optimism
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.

4 participants