Skip to content

Conversation

@ziogaschr
Copy link
Contributor

@ziogaschr ziogaschr commented Mar 12, 2025

This PR merges the live tracing with hooks in order we can use this feature for further developments.
In order to achieve this we used branch_v1.0.16a as the base. This means that in order to merge this PR in master and make a release, we will also need the branch_v.0.16a to be merged as well.

The statedb, state_object and trie_prefetcher has been merged, being more close to go-ethereum implementation, later before the release if we have time, or on the next merge we can make it more aligned to bsc client, based on our preference. Though, bsc is coming closer to go-ethereum at their latest releases.

  • cmd/evm will have to merge more stuff for tracing.hooks at another PR. Except if you raise a warning that we use evm command in our workflows and we need this one now.

@ziogaschr ziogaschr changed the base branch from master to branch_v1.0.16 March 12, 2025 20:03
common.BytesToAddress([]byte{16}): &bls12381Pairing{},
common.BytesToAddress([]byte{17}): &bls12381MapG1{},
common.BytesToAddress([]byte{18}): &bls12381MapG2{},
common.BytesToAddress([]byte{0xa}): &bls12381G1Add{},
Copy link
Contributor Author

@ziogaschr ziogaschr Mar 13, 2025

Choose a reason for hiding this comment

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

0xa has a collision at Prague. Also at Ethereum, they have different addresses for BLS contracts

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let's skip this for now, as it will be fixed once we merge upstream changes for fully supporting Prague hard fork.

defer func() {
ite := vmenv.Interpreter()
vm.EVMInterpreterPool.Put(ite)
vm.EvmPool.Put(vmenv)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The EvmPool is not needed, it has been reasoned at commit 29ccc8f description.

After the rework done at ethereum/go-ethereum#30745 we had to remove the EvmPool as the PR aims on using a single EVM for the whole block execution.
The EvmPool was creating a race condition on miner tests

Coinbase *common.Address `json:"coinbase,omitempty"`
Random *common.Hash `json:"random,omitempty"`
BaseFee *hexutil.Big `json:"baseFee,omitempty"`
Coinbase *common.Address `json:"feeRecipient,omitempty"`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jackcrypto9527 @ggcore0 I think we prefer keeping this fields using the old names.

AaronChen0 and others added 25 commits March 28, 2025 09:53
…ion (#29563)

This change removes an unnecessary preallocation and fixes a flaw with no-op copies of some parts of the statedb
# Conflicts:
#	core/state/statedb.go
* core/state, tests: remove account reset operation

* core/state, core/vm: implement createcontract journal event

* core/state: make createcontract not emit dirtied account, unskip tests

* core/state: add createcontract to journal fuzzing

* core/state: fix journal

* core/state: address comments

* core/state: remove useless code

---------

Co-authored-by: Gary Rong <[email protected]>
# Conflicts:
#	core/state/state_object.go
#	core/state/state_test.go
#	core/state/statedb.go
#	core/state/statedb_test.go
#	core/vm/evm.go
…519)

* core/state: trie prefetcher change: calling trie() doesn't stop the associated subfetcher

Co-authored-by: Martin HS <[email protected]>
Co-authored-by: Péter Szilágyi <[email protected]>

* core/state: improve prefetcher

* core/state: restore async prefetcher stask scheduling

* core/state: finish prefetching async and process storage updates async

* core/state: don't use the prefetcher for missing snapshot items

* core/state: remove update concurrency for Verkle tries

* core/state: add some termination checks to prefetcher async shutdowns

* core/state: differentiate db tries and prefetched tries

* core/state: teh teh teh

---------

Co-authored-by: Jared Wasinger <[email protected]>
Co-authored-by: Martin HS <[email protected]>
Co-authored-by: Gary Rong <[email protected]>
# Conflicts:
#	core/blockchain.go
#	core/state/state_object.go
#	core/state/statedb.go
#	core/state/trie_prefetcher.go
#	core/state/trie_prefetcher_test.go

# Conflicts:
#	core/state/statedb.go
…29731)

* core/state: remove slot dirtiness if it's set back to origin value

* core/state: suggestion from martin
# Conflicts:
#	core/state/journal.go
#	core/state/state_object.go
This is a follow-up to #29520, and a preparatory PR to a more thorough
change in the journalling system.

### API methods instead of `append` operations

This PR hides the journal-implementation details away, so that the
statedb invokes methods like `JournalCreate`, instead of explicitly
appending journal-events in a list. This means that it's up to the
journal whether to implement it as a sequence of events or
aggregate/merge events.

### Snapshot-management inside the journal

This PR also makes it so that management of valid snapshots is moved
inside the journal, exposed via the methods `Snapshot() int` and
`RevertToSnapshot(revid int, s *StateDB)`.

### SetCode

JournalSetCode journals the setting of code: it is implicit that the
previous values were "no code" and emptyCodeHash. Therefore, we can
simplify the setCode journal.

### Selfdestruct

The self-destruct journalling is a bit strange: we allow the
selfdestruct operation to be journalled several times. This makes it so
that we also are forced to store whether the account was already
destructed.

What we can do instead, is to only journal the first destruction, and
after that only journal balance-changes, but not journal the
selfdestruct itself.

This simplifies the journalling, so that internals about state
management does not leak into the journal-API.

### Preimages

Preimages were, for some reason, integrated into the journal management,
despite not being a consensus-critical data structure. This PR undoes
that.

---------

Co-authored-by: Gary Rong <[email protected]>
# Conflicts:
#	core/state/state_object.go
#	core/state/statedb.go
As SELF-DESTRUCT opcode is disabled in the cancun fork(unless the
account is created within the same transaction, nothing to delete
in this case). The account will only be deleted in the following
cases:

- The account is created within the same transaction. In this case
the original storage was empty.

- The account is empty(zero nonce, zero balance, zero code) and
is touched within the transaction. Fortunately this kind of accounts
are not-existent on ethereum-mainnet.

All in all, after cancun, we are pretty sure there is no large contract
deletion and we don't need this mechanism for oom protection.
# Conflicts:
#	core/state/statedb.go
#	triedb/pathdb/database.go
#	triedb/pathdb/journal.go
* core/state: introduce stateUpate structure

* core/state: remove outdated function description

* core/state: address comments
# Conflicts:
#	core/state/state_object.go
#	core/state/statedb.go
#	core/state/statedb_fuzz_test.go
# Conflicts:
#	core/blockchain.go
#	core/state/statedb.go
#	miner/worker.go
we include the .cursorignore, so as the developers can fine tune what to be ignored.
Content of .gitignore are ignored automatically
This pull request fixes the broken feature where the entire storage set is overridden.

Originally, the storage set override was achieved by marking the associated account
as deleted, preventing access to the storage slot on disk. However, since #29520, this
flag is also checked when accessing the account, rendering the account unreachable.

A fix has been applied in this pull request, which re-creates a new state object with all
account metadata inherited.
buddh0 and others added 23 commits March 28, 2025 10:00
Fix the error comparison in tracer to prevent dropping revert reason data

---------

Co-authored-by: Martin <[email protected]>
Co-authored-by: rjl493456442 <[email protected]>
Removes duplicate code in the interpreter loop.
Here we add some more changes for live tracing API v1.1:

- Hook `OnSystemCallStartV2` was introduced with `VMContext` as parameter.
- Hook `OnBlockHashRead` was introduced.
- `GetCodeHash` was added to the state interface
- The new `WrapWithJournal` construction helps with tracking EVM reverts in the tracer.

---------

Co-authored-by: Felix Lange <[email protected]>
# Conflicts:
#	core/state_transition.go
#	core/tracing/CHANGELOG.md
#	core/tracing/hooks.go
#	core/txpool/blobpool/blobpool_test.go
#	core/txpool/legacypool/legacypool_test.go
#	core/verkle_witness_test.go
#	core/vm/instructions.go
#	internal/ethapi/override/override.go
…consensus/ethash,consensus/satoshi,core,core/state,core/state/pruner,core/state,core,core/txpool/legacypool,core/vm,core/vm/runtime,eth,eth/tracers,internal/ethapi,miner,trie,triedb/pathdb: resolve changes from tracer commit cherry-picks
This change fixes is a rare bug in test generator: If the run is very unlucky it
can use `modifyAccountOp` / `deleteAccountOp` without creating any
account, leading to have a trie root same as the parent.

This change makes the first operation always be a creation.
Passing `*tracing.Hooks` makes the intent clearer and ensure the `applyTransaction`
controls the creationg of the `vm.Config`.
This pull request replaces the field pointer in journal entry with the
field itself, specifically the address of mutated account.

While it will introduce the extra allocation cost, but it's easier for
code reading. Let's measure the overhead overall to see if the change is
acceptable or not.
# Conflicts:
#	core/state/journal.go
After the rework done at ethereum/go-ethereum#30745 we had to remove the EvmPool as the PR aims on using a single EVM for the whole block execution.

The EvmPool was creating a race condition on miner tests
@ziogaschr ziogaschr changed the base branch from branch_v1.0.16 to branch_v1.0.16a May 2, 2025 07:39
@ziogaschr ziogaschr marked this pull request as ready for review May 19, 2025 15:02
@ziogaschr ziogaschr merged commit 15574eb into branch_v1.0.16 May 20, 2025
@ziogaschr ziogaschr mentioned this pull request May 20, 2025
@ziogaschr ziogaschr mentioned this pull request Jun 6, 2025
@charles2023wood charles2023wood deleted the hooks/tracer branch October 11, 2025 07:24
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.