Skip to content

Conversation

@sonhv0212
Copy link
Contributor

PRs:

ethereum/go-ethereum#30078
ethereum/go-ethereum#31089

Description

This PR implements EIP-7702: "Set EOA account code".
Specification: https://eips.ethereum.org/EIPS/eip-7702

Add a new transaction type that adds a list of [chain_id, address, nonce, y_parity, r, s] authorization tuples. For each tuple, write a
delegation designator (0xef0100 ++ address) to the signing account’s
code. All code reading operations must load the code pointed to by the
designator.

huyngopt1994 and others added 30 commits November 21, 2024 11:35
* core,trie,eth,cmd: rework preimage store

* ci: trigger unittest path-base-implementing
…liary tool to capture all deleted node wwhich can't be captured by trie.Committer. The deleted nodes (#552)

can be removed from the disk later. Implement traverse and rework init Trie
* cmd, core/state, light, trie, eth: add trie owner notion

* all: refactor

* tests: fix goimports

* core/state/snapshot: fix ineffasigns

Co-authored-by: rjl493456442 <[email protected]>
Co-authored-by: Martin Holst Swende <[email protected]>
* core, trie: rework trie commiter

changed the commit procedure, introduce new struct called nodeSet for
returning including all dirty nodes of a trie. Multiple nodeset will be
merged to MergedNodeSet struct. then be submitted to in-memory database
from block to block

* trie,core: fix comments
* core: store genesis allocation and recommit them if necessary (#24460)

* core: store genesis allocation and recommit them if necessary

* core: recover predefined genesis allocation if possible

* all: cleanup the APIs for initializing genesis (#25473)

* all: polish tests

* core: apply feedback from Guillaume

* core: fix comment

---------

Co-authored-by: rjl493456442 <[email protected]>
core, eth, les, trie: rework snap sync

Co-authored-by: rjl493456442 <[email protected]>
… ethdb, can be used independently of the chain database, reference by commit 1941c5e6c99689be2e27b3e537bd591688b717de (#571)
* cmd, core, ethdb, node: rework ancient store folder reference by ethereum/go-ethereum@e44d655
* all: move genesis initialization to blockchain

* all: fix test
* core: add blockchain test for failing create/destroy-case

* core,state: some refactors

* core/rawdb: refactor db inspector for extending multiple ancient store
* core,eth,tests,trie: abstract node scheme, and contruct database
interface instead of keyvalue for supporting storing diff reverse data
in ancient

* stacktrie,core,eth: port the changes in stacktries, track the path prefix of nodes when commits,  use ethdb.Database for constructing trie.Database, it's not necessary right now, but it's required for path-based used to open reverse diff freezer

* core,trie: add scheme and resolvepath logic
* trie: track deleted nodes

* core: track deleted nodes
* all: prep for path-based trie storage

* all: use rawdb.HasLegacyNode() to check for node existance instead of check for length
* trie: implement NodeBlob API for trie iterator

This functionality is needed in new path-based storage scheme, but
can be implemented in a seperate PR though.

When an account is deleted, then all the storage slots should be
nuked out from the disk as well. In hash-based storage scheme they
are still left in the disk but in new scheme, they will be iterated
and marked as deleted.

But why the NodeBlob API is needed in this scenario? Because when
the node is marked deleted, the previous value is also required to
be recorded to construct the reverse diff.

* fuzzers/stacktrie: enable test

---------

Co-authored-by: Gary Rong <[email protected]>
* trie: refactor tracer

* fix: add description
* trie: add wrapper for database

* trie: refactor trie node

* all: fix test

* rawdb, trie: fix comment

trie: change name WithPrev => NodeWithPrev
rawdb: add schema_test
* trie: triestate/Set to track changes

* core/state: track state changes

journal.go: in resetObjectChange
- add account in resetObjectChange (ref ethereum/go-ethereum#27339)
- add prevAccount and prevStorage (ref ethereum/go-ethereum#27376)
- add prevAccountOrigin and prevStorageOrigin to track changes
state_object.go: add origin for tracking the original StateAccount before change
statedb.go:
- add accountsOrigin and storagesOrigin, same functions as above
- stateObjectsDestruct now track the previous state before destruct
- add functions for handle destructing old states

* all: apply changes to tests
* core/state: clean up: db already exist in stateObject

* core, trie: statedb also commit the block number
* all: clean up overall structure, preparing for path-based (#594)

* trie/triedb/pathdb: init pathdb components

* core, trie: track state change with address instead of hash

Reference: ethereum/go-ethereum@817553c

* trie: refactor

* rawdb: implement freezer resettable & state freezer  (#596)

* rawdb: implement freezer resettable

* rawdb: implement state freezer

* rawdb: update description

* trie: path based scheme implementing (#598)

* core/state: move account definition to core/types

Reference: ethereum/go-ethereum#27323

* trie: add path base utils

* triedb: implement history and adding some test utils

* trie/triedb/pathdb: implement difflayer and disklayer

* Fix some issues related to history, and add logic checking maxbyte when is zero for retrieving ancient ranges with maxbyte is zero

* trie/triedb/pathdb: implement database.go

* freezer: Add unit test and docs for support freezer reading with no limit size

* trie/triedb/pathdb: add database and difflayer tests

* triedb/pathdb: implement journal and add more comments

---------

Co-authored-by: Huy Ngo <[email protected]>

---------

Co-authored-by: Francesco4203 <[email protected]>
… when inserting in stack trie reference by 86fe359 (#604)
* trie: enable pathdb: add path config and enable tests

* core/rawdb: now also inspect the state freezer in pathdb; rename

* cmd: working on cmd ronin

* core: refactor; add pathbase config; fix tests

- all: fix and enable tests for pathbase
- blockchain: open triedb explicitly in blockchain functions and close right after use, since diskLayer inside pathdb is a skeleton
- blockchain: when writeBlockWithState, pathbase will skip the explicit garbage collector, which is only needed for hashbase
- genesis.go: nit: change check genesis state, ref ethereum/go-ethereum@08bf8a6

* tests: enable path tests

* eth: enable path scheme

- all: fix tests, enable path scheme tests
- state_accessor: split function to retrieve statedb from block to hash scheme and path scheme

* light, miner, les, ethclient: clean up tests

* trie: refactor triereader, return err when state reader won't be created in hash and path

* trie: fix failed test in iterator and sync test tie

* trie,core: improve trie reader and add checking config nil when initing
database

* trie: statedb instance is committed, then it's not usable, a new instance must be created based on new root updated database, reference by commit 6d2aeb4

* cmd,les,eth: fixed unittest and adding flag Parrallel correctly

* core, eth: fix tests

* core: refactor and fix sync_test logic

* tmp: disable pathbase for TestIsPeriodBlock, TestIsTrippEffective

---------

Co-authored-by: Huy Ngo <[email protected]>
…me object when passing parents in cosortium v1 (#608)

* cmd,eth: fix wrong compare logic when data dir is empty and moving checking error correctly

* docker: passing state.scheme when initing the genesis data

* rawdb: add missing freezer in collections

* v1/consortium:  create a copy to keep parents content

In snapshot function, the list parents is popped out gradually for getting its contents, so when calling apply, the parents list is empty. Simply create a copy at the beginning to fix it.
This has been fixed in consortium v2. For a full sync scenario, however, the first blocks are still processed with consortium v1, which causes our node to panic.

---------

Co-authored-by: Francesco4203 <[email protected]>
* eth/downloader: prevent pivot moves after state commit (#28126)

* core, eth/downloader: fix genesis state missing due to state sync (#28124)

* core: fix chain repair corner case in path-based scheme

* eth/downloader: disable trie database whenever state sync is launched

---------

Co-authored-by: Péter Szilágyi <[email protected]>
Co-authored-by: rjl493456442 <[email protected]>
commit ethereum/go-ethereum@65ed1a6.

This change speeds up trie hashing and all other activities that require
RLP encoding of trie nodes by approximately 20%. The speedup is achieved by
avoiding reflection overhead during node encoding.

The interface type trie.node now contains a method 'encode' that works with
rlp.EncoderBuffer. Management of EncoderBuffers is left to calling code.
trie.hasher, which is pooled to avoid allocations, now maintains an
EncoderBuffer. This means memory resources related to trie node encoding
are tied to the hasher pool.

This also refactors some functions in rlp package.

goos: linux
goarch: amd64
cpu: 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
                          │   old.txt    │               new.txt                │
                          │    sec/op    │    sec/op     vs base                │
DeriveSha200/std_trie-8     725.1µ ± 31%   613.8µ ± 37%        ~ (p=0.481 n=10)
DeriveSha200/stack_trie-8   572.3µ ± 10%   493.1µ ± 13%  -13.85% (p=0.005 n=10)
geomean                     644.2µ         550.1µ        -14.61%

                          │   old.txt    │               new.txt                │
                          │     B/op     │     B/op      vs base                │
DeriveSha200/std_trie-8     287.4Ki ± 0%   283.0Ki ± 0%   -1.53% (p=0.000 n=10)
DeriveSha200/stack_trie-8   56.34Ki ± 0%   42.43Ki ± 0%  -24.69% (p=0.000 n=10)
geomean                     127.2Ki        109.6Ki       -13.88%

                          │   old.txt   │               new.txt               │
                          │  allocs/op  │  allocs/op   vs base                │
DeriveSha200/std_trie-8     2.931k ± 0%   2.917k ± 0%   -0.46% (p=0.000 n=10)
DeriveSha200/stack_trie-8   1.462k ± 0%   1.246k ± 0%  -14.77% (p=0.000 n=10)
geomean                     2.070k        1.907k        -7.90%

                         │   old.txt    │               new.txt                │
                         │    sec/op    │    sec/op     vs base                │
Prove-8                    664.0µ ± 21%   450.2µ ± 27%  -32.20% (p=0.000 n=10)
VerifyProof-8              8.643µ ± 18%   9.009µ ± 33%        ~ (p=0.684 n=10)
VerifyRangeProof10-8       99.18µ ± 25%   67.60µ ± 67%        ~ (p=0.089 n=10)
VerifyRangeProof100-8      496.3µ ± 20%   487.0µ ± 33%        ~ (p=0.739 n=10)
VerifyRangeProof1000-8     5.149m ± 32%   4.095m ± 49%        ~ (p=0.971 n=10)
VerifyRangeProof5000-8     19.79m ± 60%   19.16m ± 28%        ~ (p=0.631 n=10)
VerifyRangeNoProof10-8     499.0µ ± 15%   422.8µ ± 29%  -15.25% (p=0.035 n=10)
VerifyRangeNoProof500-8    1.747m ± 30%   1.417m ± 24%  -18.91% (p=0.023 n=10)
VerifyRangeNoProof1000-8   3.025m ± 29%   2.239m ± 33%  -25.98% (p=0.009 n=10)
geomean                    750.9µ         622.6µ        -17.09%

                     │    old.txt    │               new.txt                │
                     │    sec/op     │    sec/op     vs base                │
HashFixedSize/10-8      60.30µ ± 19%   44.84µ ± 17%  -25.64% (p=0.000 n=10)
HashFixedSize/100-8     205.9µ ± 32%   145.2µ ± 19%  -29.48% (p=0.000 n=10)
HashFixedSize/1K-8     1326.5µ ± 23%   939.2µ ± 25%  -29.20% (p=0.002 n=10)
HashFixedSize/10K-8     14.77m ± 25%   12.74m ± 19%        ~ (p=0.075 n=10)
HashFixedSize/100K-8    135.2m ± 19%   104.1m ± 18%  -23.03% (p=0.003 n=10)
geomean                 2.011m         1.520m        -24.43%

                     │    old.txt    │               new.txt                │
                     │     B/op      │     B/op      vs base                │
HashFixedSize/10-8     11.729Ki ± 0%   9.752Ki ± 0%  -16.85% (p=0.000 n=10)
HashFixedSize/100-8     58.56Ki ± 0%   49.23Ki ± 0%  -15.93% (p=0.000 n=10)
HashFixedSize/1K-8      578.1Ki ± 0%   481.5Ki ± 0%  -16.72% (p=0.000 n=10)
HashFixedSize/10K-8     6.019Mi ± 0%   4.985Mi ± 0%  -17.18% (p=0.000 n=10)
HashFixedSize/100K-8    59.53Mi ± 0%   49.29Mi ± 0%  -17.20% (p=0.000 n=10)
geomean                 683.5Ki        568.8Ki       -16.78%

                     │   old.txt   │              new.txt               │
                     │  allocs/op  │  allocs/op   vs base               │
HashFixedSize/10-8      149.0 ± 0%    142.0 ± 0%  -4.70% (p=0.000 n=10)
HashFixedSize/100-8     772.0 ± 0%    739.0 ± 0%  -4.27% (p=0.000 n=10)
HashFixedSize/1K-8     7.443k ± 0%   7.099k ± 0%  -4.62% (p=0.000 n=10)
HashFixedSize/10K-8    77.09k ± 0%   73.32k ± 0%  -4.89% (p=0.000 n=10)
HashFixedSize/100K-8   767.8k ± 0%   730.5k ± 0%  -4.86% (p=0.000 n=10)
geomean                8.729k        8.321k       -4.67%

Co-authored-by: Qian Bin <[email protected]>
Co-authored-by: Felix Lange <[email protected]>
huyngopt1994 and others added 17 commits February 25, 2025 13:43
…ull sync

before we apply the change for commit 73f5bcb from ethereum/go-ethereum#28171, which adding more checking state for avoiding head state missing in path mode, but seem we miss the this change line when cherry-pick to path base implementing
While investigating #22374, I noticed that the Sync operation of the
freezer does not take the table lock. It also doesn't call sync for all files
if there is an error with one of them. I doubt this will fix anything, but
didn't want to drop the fix on the floor either.
This PR does a few things.
It fixes a shutdown-order flaw in the chainfreezer. Previously, the chain-freezer would shutdown the freezer backend first, and then signal for the loop to exit. This can lead to a scenario where the freezer tries to fsync closed files, which is an error-conditon that could lead to exit via log.Crit.

It also makes the printout more detailed when truncating 'dangling' items, by showing the exact number instead of approximate MB.

This PR also adds calls to fsync files before closing them, and also makes the `db inspect` command slightly more robust.

Remove logic try fsync related Access denined error on Windows
… (#691)

* core/txpool, core/state_processor, vm/evm: Skip check for blacklisted after Venoki
* core/vm, core/txpool: Skip check for contract deployer after Venoki
The new blst version fixes this build issue with go1.24.

../../go/pkg/mod/github.com/supranational/[email protected]/bindings/go/blst.go:207:11: cannot define new methods on non-local type SecretKey
../../go/pkg/mod/github.com/supranational/[email protected]/bindings/go/blst.go:310:15: cannot define new methods on non-local type SecretKey
../../go/pkg/mod/github.com/supranational/[email protected]/bindings/go/blst.go:430:11: cannot define new methods on non-local type Fp12
../../go/pkg/mod/github.com/supranational/[email protected]/bindings/go/blst.go:434:11: cannot define new methods on non-local type Fp12
../../go/pkg/mod/github.com/supranational/[email protected]/bindings/go/blst.go:438:11: cannot define new methods on non-local type Fp12
../../go/pkg/mod/github.com/supranational/[email protected]/bindings/go/blst.go:442:11: cannot define new methods on non-local type Fp12
../../go/pkg/mod/github.com/supranational/[email protected]/bindings/go/blst.go:448:12: cannot define new methods on non-local type Fp12
../../go/pkg/mod/github.com/supranational/[email protected]/bindings/go/blst.go:460:11: cannot define new methods on non-local type P1Affine
../../go/pkg/mod/github.com/supranational/[email protected]/bindings/go/blst.go:465:11: cannot define new methods on non-local type P1Affine
../../go/pkg/mod/github.com/supranational/[email protected]/bindings/go/blst.go:474:12: cannot define new methods on non-local type P2Affine

Reference:
- blst commit: supranational/blst@df47c4c
- go-ethereum commit: ethereum/go-ethereum@24ed0b5
…ain#17)

* params/version: release Ronin v1.0.0

* genesis: Pre-config hardfork node

* genesis: set testnet Venoki harkfork block

* genesis: set mainnet Venoki harkfork block

* params: config harkfork blocks
…n-chain#20)

* core/state_transition: avoid comparing basefee and feecap for system transaction when enabling basefee

* eth/tracers: change using basefee instead of gas price is 0, and add more checking after and before enabling venoki for debug_traceInternalsAndAccounts unittest

* eth/tracers/tracetest: support run all tests with hash and path scheme

* core/state_transition: skip full logic check gasFeecap with system txs
System transaction is not affected by basefee rule in normal flow, the tip from
system transaction is always 0. This commit makes the tracing flow consistent
with this behavior.
The returned reward of system transaction is negative. This is because system
transaction does not follow basefee rule. This commit fixes the issue by
setting the returned reward of system transaction to 0.
…onin-chain#24)

As the system transaction does not follow the basefee rule, make this behavior
consistent in tracing path. This commit also refactors the code the skip the
whole transaction's epilogue for system transaction in tracing.
…nin-chain#28)

* genesis,params: config hardfork block, treasury address

* version: update ronin to v1.0.2

* params: add Treasury address mainnet
@sonhv0212 sonhv0212 changed the base branch from main to eip-7702 March 7, 2025 06:30
if err != nil {
return common.Address{}, err
}
if len(pub) == 0 || pub[0] != 4 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Just curious here, what is the check pub[0] != 4?

Copy link
Contributor

Choose a reason for hiding this comment

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

I've found out about this. This is used to check if the public key is in uncompressed format.

@minh-bq
Copy link
Contributor

minh-bq commented Mar 11, 2025

I'm not sure if this is in scope of this PR but in the EIP
https://github.com/ethereum/EIPs/blob/master/EIPS/eip-7702.md#transaction-origination
"Modify the restriction put in place by EIP-3607 to allow EOAs whose code is a valid delegation designation, i.e., 0xef0100 || address, to continue to originate transactions. Accounts with any other code values may not originate transactions."

So do we need to change this place?
https://github.com/sonhv0212/ronin/blob/9a27a61a8413cc61c97f17df7faab06928efe261/core/state_transition.go#L318-L321

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.

9 participants