Commit graph

488 commits

Author SHA1 Message Date
Matthieu Vachon
2cfff4e562 Added two new test cases and fixed double suicide withdraw
The StateDB SelftDestruct6780 must not record a balance change since the `opSelfdestruct6780` instruction implementation already calls `StateDB.SubBalance` to deduce the suicide refund.

The second test case show case a new account creations in 2.3 but that doesn't appear when running in backward compatibility mode using 3.0 version of the tracer.
2025-02-08 12:29:54 -05:00
Matthieu Vachon
d1f03614a4 Merge tag 'v1.14.12' into firehose-fh3.0
# Conflicts:
#	cmd/geth/misccmd.go
#	core/state/statedb.go
#	core/state_processor.go
#	go.mod
2024-12-17 16:01:41 -05:00
Matthieu Vachon
a64a69dbfc Merge remote-tracking branch 'origin/master' into firehose-fh3.0
# Conflicts:
#	go.mod
2024-04-23 15:40:14 -04:00
haoran
b2b0e1da8c
all: fix various typos (#29600)
* core: fix typo

* rpc: fix typo

* snap: fix typo

* trie: fix typo

* main: fix typo

* abi: fix typo

* main: fix field comment for basicOp
2024-04-23 13:09:42 +03:00
Aaron Chen
1e9bf2a09e
core/state: fix bug in statedb.Copy and remove unnecessary preallocation (#29563)
This change removes an unnecessary preallocation and fixes a flaw with no-op copies of some parts of the statedb
2024-04-17 13:55:31 +02:00
rjl493456442
d3c4466edd
core, eth/protocols/snap, trie: fix cause for snap-sync corruption, implement gentrie (#29313)
This pull request defines a gentrie for snap sync purpose.

The stackTrie is used to generate the merkle tree nodes upon receiving a state batch. Several additional options have been added into stackTrie to handle incomplete states (either missing states before or after).

In this pull request, these options have been relocated from stackTrie to genTrie, which serves as a wrapper for stackTrie specifically for snap sync purposes.

Further, the logic for managing incomplete state has been enhanced in this change. Originally, there are two cases handled:

-    boundary node filtering
-    internal (covered by extension node) node clearing

This changes adds one more:
 
- Clearing leftover nodes on the boundaries.

This feature is necessary if there are leftover trie nodes in database, otherwise node inconsistency may break the state healing.
2024-04-16 09:05:36 +02:00
Abirdcfly
b179b7b8e7
all: remove duplicate word in comments (#29531)
This change removes some duplicate words in in comments
2024-04-15 08:34:31 +02:00
cui
ab6419ccd8
core/state: use maps.Clone (#29365)
core: using maps.Clone
2024-04-02 15:56:12 +03:00
cui
7481398a24
core/state: using slices.Clone (#29366) 2024-03-28 12:13:41 +01:00
Guillaume Ballet
da7469e5c4
core: add an end-to-end verkle test (#29262)
core: add a simple verkle test

triedb, core: skip hash comparison in verkle

core: remove legacy daoFork logic in verkle chain maker

fix: nil pointer in tests

triedb/pathdb: add blob hex

core: less defensive

Co-authored-by: Ignacio Hagopian <jsign.uy@gmail.com>
Co-authored-by: Martin HS <martin@swende.se>
Co-authored-by: Gary Rong <garyrong0905@gmail.com>
2024-03-26 21:25:41 +01:00
jwasinger
58a3e2f180
core/state: perform updates before deletions when mutating tries (#29201)
This addresses an edge-case (detailed in the code comment) where the computation of the intermediate trie root would force the unnecessary resolution of a hash node. The change makes it so that when we process changes from a block, we first process trie-updates and afterwards process trie-deletions.
2024-03-26 15:21:39 +01:00
Matthieu Vachon
4105834d36 Reverting more changes that were on firehose-fh3.0 but not on origin/master 2024-03-25 14:51:24 -04:00
Matthieu Vachon
262c3117f6 Merge remote-tracking branch 'origin/master' into firehose-fh3.0
# Conflicts:
#	cmd/evm/internal/t8ntool/execution.go
#	cmd/evm/internal/t8ntool/transition.go
#	cmd/utils/flags.go
#	consensus/beacon/consensus.go
#	core/blockchain.go
#	core/state_processor.go
#	core/tracing/hooks.go
#	core/vm/runtime/runtime.go
#	eth/backend.go
#	eth/tracers/api.go
#	eth/tracers/dir.go
#	eth/tracers/directory/tracers.go
#	eth/tracers/internal/tracetest/calltrace_test.go
#	eth/tracers/internal/tracetest/flat_calltrace_test.go
#	eth/tracers/js/goja.go
#	eth/tracers/js/tracer_test.go
#	eth/tracers/live/noop.go
#	eth/tracers/logger/logger.go
#	eth/tracers/native/4byte.go
#	eth/tracers/native/call.go
#	eth/tracers/native/call_flat.go
#	eth/tracers/native/mux.go
#	eth/tracers/native/noop.go
#	eth/tracers/native/prestate.go
#	eth/tracers/tracers.go
#	go.mod
2024-03-25 14:45:08 -04:00
Martin HS
14cc967d19
all: remove dependency on golang.org/exp (#29314)
This change includes a leftovers from https://github.com/ethereum/go-ethereum/pull/29307
- using the [new `slices` package](https://go.dev/doc/go1.21#slices) and
- using the [new `cmp.Ordered`](https://go.dev/doc/go1.21#cmp) instead of exp `constraints.Ordered`
2024-03-25 07:50:18 +01:00
Sina M
064f37d6f6
eth/tracers: live chain tracing with hooks (#29189)
Here we add a Go API for running tracing plugins within the main block import process. 

As an advanced user of geth, you can now create a Go file in eth/tracers/live/, and within
that file register your custom tracer implementation. Then recompile geth and select your tracer
on the command line. Hooks defined in the tracer will run whenever a block is processed.

The hook system is defined in package core/tracing. It uses a struct with callbacks, instead of 
requiring an interface, for several reasons:

- We plan to keep this API stable long-term. The core/tracing hook API does not depend on
  on deep geth internals.
- There are a lot of hooks, and tracers will only need some of them. Using a struct allows you
   to implement only the hooks you want to actually use.

All existing tracers in eth/tracers/native have been rewritten to use the new hook system.

This change breaks compatibility with the vm.EVMLogger interface that we used to have.
If you are a user of vm.EVMLogger, please migrate to core/tracing, and sorry for breaking
your stuff. But we just couldn't have both the old and new tracing APIs coexist in the EVM.

---------

Co-authored-by: Matthieu Vachon <matthieu.o.vachon@gmail.com>
Co-authored-by: Delweng <delweng@gmail.com>
Co-authored-by: Martin HS <martin@swende.se>
2024-03-22 18:53:53 +01:00
Matthieu Vachon
7b77261b7c Added back OnNewAccount which is Firehose concept so I left it out of the merge commit just before this one 2024-03-13 16:24:14 -04:00
Matthieu Vachon
f47d2fc315 Merge branch 'extended-tracer-struct' into firehose-fh3.0
# Conflicts:
#	core/blockchain.go
#	core/state/statedb.go
#	eth/backend.go
#	eth/tracers/live/printer.go
#	go.mod
#	go.sum
2024-03-13 16:23:13 -04:00
Sina Mahmoodi
73ca96b97e resolve merge conflict 2024-03-12 17:55:17 +01:00
Péter Szilágyi
b393ad8d29
cmd, core, metrics: always report expensive metrics (#29191)
* cmd, core, metrics: always report expensive metrics

* core, metrics: report block processing metrics as resetting timer

* metrics: update reporter tests
2024-03-11 10:06:57 +02:00
rjl493456442
7b81cf6362
core/state, trie/triedb/pathdb: remove storage incomplete flag (#28940)
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.
2024-03-05 14:31:55 +01:00
Sina Mahmoodi
a2829c6f49 rename LiveLogger to hooks 2024-02-28 19:38:04 +01:00
Sina Mahmoodi
7d8db9b503 move logger interface to core/tracing 2024-02-28 19:34:49 +01:00
Sina Mahmoodi
8cc747f439 moaar fixes 2024-02-28 19:20:17 +01:00
Sina Mahmoodi
fc35780124 full struct-based tracing infra 2024-02-21 18:47:59 +01:00
buddho
bba3fa9af9
core,eth,internal: fix typo (#29024) 2024-02-20 19:42:48 +08:00
Sina Mahmoodi
50095906e2 use struct for tracing events 2024-02-16 11:20:56 +01:00
Sina Mahmoodi
35291e6a8c resolve merge conflict 2024-02-15 10:22:56 +01:00
Martin HS
8321fe2fda
tests: fix goroutine leak related to state snapshot generation (#28974)
---------

Co-authored-by: Felix Lange <fjl@twurst.com>
2024-02-14 17:02:56 +01:00
Sina Mahmoodi
4cd7cb3637 resolve merge conflict 2024-02-14 15:40:27 +01:00
rjl493456442
fe91d476ba
all: remove the dependency from trie to triedb (#28824)
This change removes the dependency from trie package to triedb package.
2024-02-13 14:49:53 +01:00
Sina Mahmoodi
27f662d96c fix merge conflict 2024-02-08 19:07:00 +01:00
Sina Mahmoodi
57cd0c30df rm OnNewAccount 2024-02-08 16:30:14 +01:00
lmittmann
199e0c9ff5
core/state, core/vm: minor uint256 related perf improvements (#28944) 2024-02-07 17:01:38 +01:00
Dimitris Apostolou
8fd43c8013
all: fix typos in comments (#28881) 2024-02-05 22:16:32 +01:00
Sina Mahmoodi
188cd4182e remove precompile check for newAccount 2024-02-05 18:37:57 +01:00
Sina Mahmoodi
6c44a594f4 fix self destruct burn condition 2024-02-05 18:29:53 +01:00
Matthieu Vachon
a46903cf0c Reduce amount of changes to Geth Live Tracer to keep Firehose backward compatibility
We removed the `precompile` check on `OnNewAccount` and moved it to the Firehose tracer directly. This way, we can remove our custom logic that toggle the check at the tracing code level and we can instead move the logic of backward compatibility back `FirehoseTracer`.

Refactored a bit also how precompiles are check. We moved the precompiles checker up to the block level now that `chainConfig` is available on `OnBlockStart` meaning we can extract the list of active precompiles. However, to make it work, we had to modify `OnGenesisBlock` to also receive `chainConfig` parameter, I've ask to add it to the geth codebase directly.
2024-02-05 12:01:21 -05:00
Matthieu Vachon
8767058368 Merge branch 'extended-tracer' into firehose-fh3.0
# Conflicts:
#	cmd/evm/internal/t8ntool/execution.go
#	consensus/beacon/consensus.go
#	consensus/ethash/consensus.go
#	consensus/misc/dao.go
#	core/genesis.go
#	core/state/statedb.go
#	core/state/statedb_test.go
#	core/state_transition.go
#	core/txpool/blobpool/blobpool_test.go
#	core/txpool/legacypool/legacypool2_test.go
#	core/txpool/legacypool/legacypool_test.go
#	core/vm/evm.go
#	core/vm/interface.go
#	tests/state_test_util.go
2024-02-02 15:08:47 -05:00
Sina Mahmoodi
56862cf07f emit onNewAccount when reseting account 2024-01-30 16:36:14 +01:00
Sina Mahmoodi
4c1d675041 resolve merge conflict 2024-01-29 20:00:43 +01:00
Marius van der Wijden
c89a3da7d9
core/state/snapshot: use AddHash/ContainHash instead of Hasher interface (#28849)
This change switches from using the `Hasher` interface to add/query the bloomfilter to implementing it as methods.
This significantly reduces the allocations for Search and Rebloom.
2024-01-23 15:15:48 +01:00
Martin HS
a5a4fa7032
all: use uint256 in state (#28598)
This change makes use of uin256 to represent balance in state. It touches primarily upon statedb, stateobject and state processing, trying to avoid changes in transaction pools, core types, rpc and tracers.
2024-01-23 14:51:58 +01:00
Arun Dhyani
eae09aabda create account deleted corner case fix 2024-01-17 18:43:33 +08:00
Arun Dhyani
0b70fbd76a account creation fixes 2024-01-17 10:46:52 +08:00
Sina Mahmoodi
d07264afe0 no balance change reason on 0 balance selfdestruct 2024-01-16 21:03:16 +03:30
Matthieu Vachon
8545daf9f9 Fixed some small stuff while merging extended-tracer in 2024-01-15 14:03:07 -05:00
Sina Mahmoodi
626fee4fed fix withdraw balance change name 2024-01-15 19:40:55 +03:30
Darioush Jalali
29b73555ae
core/state: unexport GetOrNewStateObject (#28804) 2024-01-14 12:32:23 +01:00
Sina Mahmoodi
aa0db68d3a resolve merge conflict 2024-01-12 17:58:24 +03:30
Sina Mahmoodi
f241a76f4a fix comment' 2024-01-12 16:24:42 +03:30