Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

feat: support stateful precompiled contracts #1650

Closed
wants to merge 45 commits into from
Closed

Conversation

mmsqe
Copy link
Contributor

@mmsqe mmsqe commented Feb 1, 2023

Updates: #1116

Description


For contributor use:

  • Targeted PR against correct branch (see CONTRIBUTING.md)
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Code follows the module structure standards.
  • Wrote unit and integration tests
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/)
  • Added relevant godoc comments.
  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • Re-reviewed Files changed in the Github PR explorer

For admin use:

  • Added appropriate labels to PR (ex. WIP, R4R, docs, etc)
  • Reviewers assigned
  • Squashed all commits, uses message "Merge pull request #XYZ: [title]" (coding standards)

yihuang and others added 3 commits February 1, 2023 08:53
temp

temp

fix build

temp

fix build

support mint method

mint and query balance
Comment on lines 371 to 373
for addr, creator := range k.customPrecompiles {
contracts[addr] = creator(ctx, stateDB, caller, msg.Value(), false)
}

Check failure

Code scanning / gosec

the value in the range statement should be _ unless copying a map: want: for key := range m

the value in the range statement should be _ unless copying a map: want: for key := range m

func init() {
addressType, _ := abi.NewType("address", "", nil)
uint256Type, _ := abi.NewType("uint256", "", nil)

Check warning

Code scanning / gosec

Returned error is not propagated up the stack.

Returned error is not propagated up the stack.
)

func init() {
addressType, _ := abi.NewType("address", "", nil)

Check warning

Code scanning / gosec

Returned error is not propagated up the stack.

Returned error is not propagated up the stack.
x/evm/keeper/state_transition.go Fixed Show fixed Hide fixed
x/evm/keeper/precompiles/bank.go Fixed Show fixed Hide fixed
x/evm/keeper/precompiles/bank.go Fixed Show fixed Hide fixed
Comment on lines 69 to 71
for addr, c := range contracts {
precompiles[addr] = c
}

Check warning

Code scanning / CodeQL

Iteration over map

Iteration over map may be a possible source of non-determinism
Comment on lines 371 to 373
for addr, creator := range k.customPrecompiles {
contracts[addr] = creator(ctx, stateDB, caller, msg.Value(), false)
}

Check warning

Code scanning / CodeQL

Iteration over map

Iteration over map may be a possible source of non-determinism
x/evm/keeper/state_transition.go Fixed Show fixed Hide fixed
x/evm/keeper/state_transition.go Fixed Show fixed Hide fixed
x/evm/keeper/state_transition.go Fixed Show fixed Hide fixed
x/evm/keeper/precompiles/bank.go Fixed Show fixed Hide fixed
x/evm/keeper/state_transition.go Fixed Show fixed Hide fixed
x/evm/keeper/precompiles/bank.go Fixed Show fixed Hide fixed
x/evm/keeper/state_transition.go Fixed Show fixed Hide fixed
x/evm/keeper/state_transition.go Fixed Show fixed Hide fixed
x/evm/keeper/state_transition.go Fixed Show fixed Hide fixed
x/evm/keeper/state_transition.go Fixed Show fixed Hide fixed
x/evm/keeper/precompiles/transfer.go Fixed Show fixed Hide fixed
x/evm/keeper/precompiles/transfer.go Fixed Show fixed Hide fixed
store/cachemulti/store.go Fixed Show fixed Hide fixed
store/cachemulti/store.go Fixed Show fixed Hide fixed
store/cachemulti/store.go Fixed Show fixed Hide fixed
store/cachemulti/store.go Fixed Show fixed Hide fixed
store/cachemulti/store.go Fixed Show fixed Hide fixed
store/cachemulti/store.go Fixed Show fixed Hide fixed
store/cachemulti/store.go Fixed Show fixed Hide fixed
store/cachemulti/store.go Fixed Show fixed Hide fixed
store/cachemulti/store.go Fixed Show fixed Hide fixed
store/cachemulti/store.go Fixed Show fixed Hide fixed
store/cachemulti/store.go Fixed Show fixed Hide fixed
@github-actions
Copy link

github-actions bot commented Apr 8, 2023

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days-before-close if no further activity occurs.

// Keeper returns the underlying `Keeper`
func (s *StateDB) Keeper() Keeper {
return s.keeper
}

// AppendJournalEntry allow external module to append journal entry,
// to support snapshot revert for external states.
func (s *StateDB) AppendJournalEntry(entry JournalEntry) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this method used anywhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, can clean up some interface now

@codecov
Copy link

codecov bot commented Apr 13, 2023

Codecov Report

Merging #1650 (5377940) into main (382a6ae) will decrease coverage by 0.18%.
The diff coverage is 54.66%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1650      +/-   ##
==========================================
- Coverage   68.89%   68.72%   -0.18%     
==========================================
  Files         117      119       +2     
  Lines       10681    10726      +45     
==========================================
+ Hits         7359     7371      +12     
- Misses       2900     2931      +31     
- Partials      422      424       +2     
Impacted Files Coverage Δ
client/bank.go 0.00% <0.00%> (ø)
x/evm/statedb/native.go 0.00% <0.00%> (ø)
x/evm/types/tracer.go 7.14% <0.00%> (ø)
x/evm/statedb/statedb.go 91.30% <8.33%> (-7.91%) ⬇️
app/ante/eth.go 80.00% <100.00%> (-0.18%) ⬇️
app/app.go 85.04% <100.00%> (-0.03%) ⬇️
x/evm/keeper/keeper.go 87.13% <100.00%> (-0.15%) ⬇️
x/evm/keeper/state_transition.go 79.63% <100.00%> (+1.25%) ⬆️

@mmsqe mmsqe marked this pull request as ready for review April 13, 2023 14:46
@mmsqe mmsqe requested a review from a team as a code owner April 13, 2023 14:46
@mmsqe mmsqe requested review from facs95 and MalteHerrmann and removed request for a team April 13, 2023 14:46
replace transfer with raw
func init() {
addressType, _ := abi.NewType("address", "", nil)
uint256Type, _ := abi.NewType("uint256", "", nil)
bytesType, _ := abi.NewType("bytes", "", nil)

Check warning

Code scanning / gosec

Returned error is not propagated up the stack.

Returned error is not propagated up the stack.

func init() {
addressType, _ := abi.NewType("address", "", nil)
uint256Type, _ := abi.NewType("uint256", "", nil)

Check warning

Code scanning / gosec

Returned error is not propagated up the stack.

Returned error is not propagated up the stack.
)

func init() {
addressType, _ := abi.NewType("address", "", nil)

Check warning

Code scanning / gosec

Returned error is not propagated up the stack.

Returned error is not propagated up the stack.
@github-actions
Copy link

github-actions bot commented Jun 2, 2023

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days-before-close if no further activity occurs.

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

Successfully merging this pull request may close these issues.

3 participants