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

Prepare codebase for merging hooking tracers from upstream #53

Draft
wants to merge 23 commits into
base: branch_v1.0.16
Choose a base branch
from

Conversation

ziogaschr
Copy link
Contributor

This PR, brings in upstream changes mostly in StateDb and Trie in order we can bring in the live hooking tracers from upstream.
This PR will not be merged at its own, but a followup PR will follow, though it's being created in order to help the team review the changes happening.

  • Fix some tests

AaronChen0 and others added 23 commits February 27, 2025 10:47
…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
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.

6 participants