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

[evm] Add methods for StatedbAdapter #3964

Merged
merged 3 commits into from
Nov 11, 2023

Conversation

envestcc
Copy link
Member

@envestcc envestcc commented Nov 8, 2023

Description

In the Shanghai upgrade of EVM, there have been changes to the StateDB Interface, therefore the StatedbAdapter also needs to be modified accordingly.

The modified parts of the new StateDB Interface are as follows:

PrepareAccessList(sender common.Address, dest *common.Address, precompiles []common.Address, txAccesses types.AccessList)

=>

GetTransientState(addr common.Address, key common.Hash) common.Hash
SetTransientState(addr common.Address, key, value common.Hash)

Prepare(rules params.Rules, sender, coinbase common.Address, dest *common.Address, precompiles []common.Address, txAccesses types.AccessList)

Among them, GetTransientState and SetTransientState are prepared for EIP-1153, but this EIP is not activated in Shanghai, so it will not be supported in this PR for now.

The implementation of the Prepare method refers to the implementation in Ethereum.

Type of change

Please delete options that are not relevant.

  • [] Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • [] Code refactor or improvement
  • [] Breaking change (fix or feature that would cause a new or changed behavior of existing functionality)
  • [] This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • make test
  • [] fullsync
  • [] Other test (please specify)

Test Configuration:

  • Firmware version:
  • Hardware:
  • Toolchain:
  • SDK:

Checklist:

  • [] My code follows the style guidelines of this project
  • [] I have performed a self-review of my code
  • [] I have commented my code, particularly in hard-to-understand areas
  • [] I have made corresponding changes to the documentation
  • [] My changes generate no new warnings
  • [] I have added tests that prove my fix is effective or that my feature works
  • [] New and existing unit tests pass locally with my changes
  • [] Any dependent changes have been merged and published in downstream modules

@envestcc envestcc marked this pull request as ready for review November 8, 2023 13:54
Copy link

codecov bot commented Nov 8, 2023

Codecov Report

Merging #3964 (992a293) into master (e1f0636) will increase coverage by 0.75%.
Report is 99 commits behind head on master.
The diff coverage is 77.81%.

❗ Current head 992a293 differs from pull request most recent head 6d16569. Consider uploading reports for the commit 6d16569 to get more accurate results

@@            Coverage Diff             @@
##           master    #3964      +/-   ##
==========================================
+ Coverage   75.38%   76.13%   +0.75%     
==========================================
  Files         303      329      +26     
  Lines       25923    28045    +2122     
==========================================
+ Hits        19541    21353    +1812     
- Misses       5360     5595     +235     
- Partials     1022     1097      +75     
Files Coverage Δ
action/candidate_register.go 90.00% <100.00%> (ø)
action/candidate_update.go 89.01% <100.00%> (+0.12%) ⬆️
action/claimreward.go 90.62% <100.00%> (-0.42%) ⬇️
action/depositreward.go 87.50% <100.00%> (-0.56%) ⬇️
action/protocol/context.go 67.66% <100.00%> (+0.49%) ⬆️
action/protocol/execution/protocol.go 42.10% <100.00%> (ø)
action/protocol/rewarding/protocol.go 80.08% <ø> (+0.67%) ⬆️
action/protocol/rewarding/reward.go 90.07% <100.00%> (+0.60%) ⬆️
...tion/protocol/staking/candidate_buckets_indexer.go 89.31% <100.00%> (-0.47%) ⬇️
...col/staking/ethabi/stake_composite_bucketscount.go 100.00% <100.00%> (ø)
... and 70 more

... and 4 files with indirect coverage changes

📣 Codecov offers a browser extension for seamless coverage viewing on GitHub. Try it in Chrome or Firefox today!

// - Add coinbase to access list (EIP-3651)
// - Reset transient storage (EIP-1153)
func (stateDB *StateDBAdapter) Prepare(rules params.Rules, sender, coinbase common.Address, dst *common.Address, precompiles []common.Address, list types.AccessList) {
if rules.IsBerlin {
Copy link
Collaborator

Choose a reason for hiding this comment

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

early return:

    if !rules.IsBerlin {
      return
    }

Copy link

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
7.1% 7.1% Duplication

idea Catch issues before they fail your Quality Gate with our IDE extension sonarlint SonarLint

@CoderZhi CoderZhi merged commit eafbb04 into iotexproject:master Nov 11, 2023
2 of 3 checks passed
@envestcc envestcc linked an issue Nov 17, 2023 that may be closed by this pull request
6 tasks
@envestcc envestcc removed a link to an issue Nov 24, 2023
6 tasks
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.

3 participants