Commit Graph

232 Commits

Author SHA1 Message Date
Delweng
a1093d98eb
eth/tracers: flatCallTracer error compatible with parity (#30497)
Compatible error message in the flat call tracer with parity-style endpoints.

Signed-off-by: jsvisa <delweng@gmail.com>
2024-11-01 09:51:06 +01:00
Delweng
98056e1ef2
eth/tracers: add disableCode/Storage options for prestateTracer (#30648)
When using the prestateTracer, in some cases users are only concerned
with balances or nonce information, and are not interested in the lengthy
contract code or storage data.

Therefore, this PR introduces two new configuration options in the
`prestateTracerConfig` structure:
- `disableCode`
- `disableStorage`

These options allow users to control whether the tracer returns contract
code and storage data during execution tracing. By setting these
options, users can more flexibly customize their needs and focus on
obtaining information that is more critical and relevant to their
specific use cases.

These options work with the default mode as well as `diffMode: true`.

---------

Signed-off-by: jsvisa <delweng@gmail.com>
Co-authored-by: Sina M <1591639+s1na@users.noreply.github.com>
2024-10-29 07:35:06 +01:00
Shude Li
f8f5609b8e
eth/tracers/internal/tracertest: add missing Random to call context (#30652)
Fixes a configuration issue in a test-helper, so that we can do call tracing-tests post-merge
2024-10-23 08:33:14 +02:00
jwasinger
478012ab23
all: remove TerminalTotalDifficultyPassed (#30609)
rebased https://github.com/ethereum/go-ethereum/pull/29766 . The
downstream branch appears to have been deleted and I don't have perms to
push to that fork.

`TerminalTotalDifficultyPassed` is removed. `TerminalTotalDifficulty`
must now be non-nil, and it is expected that networks are already
merged: we can only import PoW/Clique chains, not produce blocks on
them.

---------

Co-authored-by: stevemilk <wangpeculiar@gmail.com>
2024-10-23 08:26:18 +02:00
Martin HS
459bb4a647
core/state: move state log mechanism to a separate layer (#30569)
This PR moves the logging/tracing-facilities out of `*state.StateDB`,
in to a wrapping struct which implements `vm.StateDB` instead.

In most places, it is a pretty straight-forward change: 
- First, hoisting the invocations from state objects up to the statedb. 
- Then making the mutation-methods simply return the previous value, so
that the external logging layer could log everything.

Some internal code uses the direct object-accessors to mutate the state,
particularly in testing and in setting up state overrides, which means
that these changes are unobservable for the hooked layer. Thus, configuring
the overrides are not necessarily part of the API we want to publish.

The trickiest part about the layering is that when the selfdestructs are
finally deleted during `Finalise`, there's the possibility that someone
sent some ether to it, which is burnt at that point, and thus needs to
be logged. The hooked layer reaches into the inner layer to figure out
these events.

In package `vm`, the conversion from `state.StateDB + hooks` into a
hooked `vm.StateDB` is performed where needed.

---------

Co-authored-by: Gary Rong <garyrong0905@gmail.com>
2024-10-23 08:03:36 +02:00
Martin HS
e4dbd5f685
eth/tracers/js: avoid compiling js bigint when not needed (#30640)
While looking at some mem profiles from `evm` runs, I noticed that
`goja` compilation of the bigint library was present. The bigint library
compilation happens in a package `init`, whenever the package
`eth/tracers/js` is loaded. This PR changes it to load lazily when
needed.

It becomes slightly faster with this change, and slightly less alloc:y. 

Non-scientific benchmark with 100 executions: 
```
time for i in {1..100}; do ./evm --code 6040 run; done;
 ```

current `master`:

```
real    0m6.634s
user    0m5.213s
sys     0m2.277s
```
Without compiling bigint
```
real    0m5.802s
user    0m4.191s
sys     0m1.965s
```
2024-10-20 19:36:51 +03:00
Sina M
978ca5fc5e
eth/tracers: various fixes (#30540)
Breaking changes:

- The ChainConfig was exposed to tracers via VMContext passed in
`OnTxStart`. This is unnecessary specially looking through the lens of
live tracers as chain config remains the same throughout the lifetime of
the program. It was there so that native API-invoked tracers could
access it. So instead we moved it to the constructor of API tracers.

Non-breaking:

- Change the default config of the tracers to be `{}` instead of nil.
This way an extra nil check can be avoided.

Refactoring:

- Rename `supply` struct to `supplyTracer`.
- Un-export some hook definitions.
2024-10-17 06:51:47 +02:00
Martin HS
5adc314817
build: update to golangci-lint 1.61.0 (#30587)
Changelog: https://golangci-lint.run/product/changelog/#1610 

Removes `exportloopref` (no longer needed), replaces it with
`copyloopvar` which is basically the opposite.

Also adds: 
- `durationcheck`
- `gocheckcompilerdirectives`
- `reassign`
- `mirror`
- `tenv`

---------

Co-authored-by: Marius van der Wijden <m.vanderwijden@live.de>
2024-10-14 19:25:22 +02:00
Felix Lange
3a5313f3f3
all: implement EIP-7002 & EIP-7251 (#30571)
This is a redo of #29052 based on newer specs. Here we implement EIPs
scheduled for the Prague fork:

- EIP-7002: Execution layer triggerable withdrawals
- EIP-7251: Increase the MAX_EFFECTIVE_BALANCE

Co-authored-by: lightclient <lightclient@protonmail.com>
2024-10-11 21:36:13 +02:00
easyfold
7942a6b5ad
eth/tracers: do system contract processing prior to parallel-tracing (#30520)
This fixes `debug_traceBlock` methods for JS tracers in that it correctly
applies the beacon block root processing to the state.
2024-10-09 14:45:14 +02:00
Sina M
40fd887df6
internal/ethapi: remove td field from block (#30386)
implement https://github.com/ethereum/execution-apis/pull/570
2024-10-01 11:36:56 +02:00
Sina M
8f4fac7b86
internal/ethapi: eth_multicall (#27720)
This is a successor PR to #25743. This PR is based on a new iteration of
the spec: https://github.com/ethereum/execution-apis/pull/484.

`eth_multicall` takes in a list of blocks, each optionally overriding
fields like number, timestamp, etc. of a base block. Each block can
include calls. At each block users can override the state. There are
extra features, such as:

- Include ether transfers as part of the logs
- Overriding precompile codes with evm bytecode
- Redirecting accounts to another address

## Breaking changes

This PR includes the following breaking changes:

- Block override fields of eth_call and debug_traceCall have had the
following fields renamed
  - `coinbase` -> `feeRecipient`
  - `random` -> `prevRandao`
  - `baseFee` -> `baseFeePerGas`

---------

Co-authored-by: Gary Rong <garyrong0905@gmail.com>
Co-authored-by: Martin Holst Swende <martin@swende.se>
2024-09-06 11:31:00 +02:00
Marius van der Wijden
b0b67be0a2
all: remove forkchoicer and reorgNeeded (#29179)
This PR changes how sidechains are handled. 

Before the merge, it was possible to import a chain with lower td and not set it as canonical. After the merge, we expect every chain that we get via InsertChain to be canonical. Non-canonical blocks can still be inserted
with InsertBlockWIthoutSetHead.

If during the InsertChain, the existing chain is not canonical anymore, we mark it as a sidechain and send the SideChainEvents normally.
2024-09-04 15:03:06 +02:00
lightclient
dfd33c7792
all: implement EIP-6110, execution layer triggered deposits (#29431)
This PR implements EIP-6110: Supply validator deposits on chain. It also sketches
out the base for Prague in the engine API types.
2024-09-04 14:33:51 +02:00
Karl Bartel
36a7134367
Include tracerConfig in created tracing test (#30364)
Fixes the tracer test filler for when there is tracerConfig.
2024-09-02 10:30:33 +02:00
Sina M
a223efcf39
core: implement EIP-2935 (#29465)
https://eips.ethereum.org/EIPS/eip-2935

---------

Co-authored-by: Guillaume Ballet <gballet@gmail.com>
Co-authored-by: Ignacio Hagopian <jsign.uy@gmail.com>
Co-authored-by: Martin HS <martin@swende.se>
2024-08-26 10:39:35 +02:00
Martin HS
30824faf90
eth/tracers: avoid panic in state test runner (#30332)
Make tracers more robust by handling `nil` receipt as input. 
Also pass in a receipt with gas used in the state test runner.
Closes https://github.com/ethereum/go-ethereum/issues/30117.

---------

Co-authored-by: Sina Mahmoodi <itz.s1na@gmail.com>
2024-08-21 15:16:08 +02:00
Dylan Vassallo
7a149a159a
eth/tracers/js: add coinbase addr to ctx (#30231)
Add coinbase address to javascript tracer context.

This PR adds the `coinbase` address to `jsTracer.ctx`, allowing access
to the coinbase address (fee receipient) in custom JavaScript tracers.

Example usage:

```javascript
result: function(ctx) {
  return toAddress(ctx.coinbase);
}
```

This change enables custom tracers to access coinbase address,
previously unavailable, enhancing their capabilities to match built-in
tracers.
2024-08-15 16:36:35 +02:00
caseylove
ac0f220040
eth/tracers, internal/ethapi: remove unnecessary map pointer in state override (#30094) 2024-07-25 01:01:59 +02:00
Halimao
269e80b07e
eth/tracers,trie: remove unnecessary check (#30071) 2024-06-27 11:29:50 +02:00
Hteev Oli
e85e21c932
core/state, eth/tracers: fix typos (#29932) 2024-06-05 11:07:37 +02:00
Chris Ziogas
c9e0b3105b
Supply delta live tracer (#29347)
Introduces the first built-in live tracer. The supply tracer tracks ETH supply changes across blocks
and writes the output to disk. This will need to be enabled through CLI using the `--vmtrace supply` flag.

Co-authored-by: Sina Mahmoodi <itz.s1na@gmail.com>
2024-06-03 12:30:27 +02:00
trillo
2f0e63e5ac
eth/downloader, eth/tracer: fix typos in comments (#29707) 2024-05-29 14:43:07 +02:00
Sina M
ea6c16007c
eth/tracers: clear error for non-reverting pre-homestead fail (#29824) 2024-05-28 13:12:46 +02:00
Sina M
fa581766f5
eth/tracers: fix json logger for evm blocktest (#29795) 2024-05-23 10:55:54 +02:00
Martin HS
7fd7c1f7dd
eth/tracers: fix basefee context for traceBlock (#29811)
This fixes an issue for `debug_traceBlock*` methods where the BASEFEE opcode was returning always 0. This caused the method return invalid results.

Co-authored-by: Sina Mahmoodi <itz.s1na@gmail.com>
2024-05-21 18:27:36 +02:00
Dragan Milic
7c7e3a77fc
eth/tracers/native: fix flatCallTracer Stop() bug (#29623)
Co-authored-by: Sina Mahmoodi <itz.s1na@gmail.com>
2024-04-30 14:33:22 +02:00
Matthieu Vachon
ade7515c81
eth, eth/tracers: process beacon root before transactions (#29402)
The beacon root when applied in `state_processor.go` is performed right before executing transaction. That means that contract reliying on this value would query the same value found in the block header.

In that spirit, it means that any tracing/operation relying on state data which touches transaction must have updated the beacon root before any transaction processing.
2024-04-24 07:58:05 +02:00
Martin HS
7aafad2233
core/vm: better error-info for vm errors (#29354) 2024-04-06 12:22:55 +02:00
Aaron Chen
ccb76c01d7
eth/tracers: use slices.Contains (#29461) 2024-04-06 12:16:25 +02:00
Delweng
8c5576b1ac
eth/tracers: fix base fee and set blob fee in tests (#29376)
Signed-off-by: jsvisa <delweng@gmail.com>
Co-authored-by: Sina Mahmoodi <itz.s1na@gmail.com>
2024-04-01 14:53:56 +02:00
Brandon Liu
a3829178af
eth/tracers/js: consistent name for method receivers (#29375) 2024-03-28 17:35:40 +01:00
cui
0183c7ad82
eth/tracers/logger: using maps.Equal (#29384)
Co-authored-by: Felix Lange <fjl@twurst.com>
2024-03-28 14:09:21 +01:00
Sina M
767b00b0b5
t8ntool: add optional call frames to json logger (#29353)
Adds a flag `--trace.callframes` to t8n which will log info when entering or exiting a call frame in addition to the execution steps.

---------

Co-authored-by: Mario Vega <marioevz@gmail.com>
2024-03-27 16:12:57 +01:00
Aaron Chen
723b1e36ad
all: fix mismatched names in comments (#29348)
* all: fix mismatched names in comments

* metrics: fix mismatched name in UpdateIfGt
2024-03-26 21:01:28 +01: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
Sina M
eff424cc30
eth/tracers: fix concurrency issue for JS-tracing a block (#29238)
This change fixes a concurrency-issue where JS-tracers were accessing the block-ctx GetHash function in a in parallel, which is not safe.
2024-03-13 07:40:02 +01:00
Delweng
6e379b6fc7
eth/tracers: prestate tracer add blob fee (#29168)
* eth/tracers: prestate balance add blob fee

Signed-off-by: jsvisa <delweng@gmail.com>

* eth/tracers: prestate test support blob tx

Signed-off-by: jsvisa <delweng@gmail.com>

* eth/tracers: add prestate blob tx test

Signed-off-by: jsvisa <delweng@gmail.com>

---------

Signed-off-by: jsvisa <delweng@gmail.com>
2024-03-06 14:36:12 +02:00
Undefinedor
a6d6e8ac41
rpc: remove deprecated method "Notifier.Closed" (#29162) 2024-03-05 14:44:23 +01:00
Andrei Silviu Dragnea
19607d1a10
eth/tracers: Fix prestateTracer pre nonce on contract creation (#29099)
The prestateTracer was reporting an inaccurate nonce for the contract being created in
post EIP-158 transactions. Correct nonce is 0, due to the issue nonce was being reported as 1.
2024-03-04 20:21:43 +01:00
Andrei Silviu Dragnea
5a0f468f8c
eth/tracers: Fix callTracer logs on onlyTopCall == true (#29068) 2024-02-27 10:29:12 +01:00
ArtificialPB
e47a7c22c4
internal/ethapi: use overriden baseFee for gasPrice (#29051)
eth_call and debug_traceCall allow users to override various block fields, among them base fee. However the overriden base fee was not considered for computing the effective gas price of that message, and instead base fee of the base block was used. This has been fixed in this commit.
2024-02-22 14:39:22 +01:00
Sina Mahmoodi
95741b1844
core: move genesis alloc types to core/types (#29003)
We want to use these types in public user-facing APIs, so they shouldn't be in core.

Co-authored-by: Felix Lange <fjl@twurst.com>
2024-02-16 19:05:33 +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
Dimitris Apostolou
8fd43c8013
all: fix typos in comments (#28881) 2024-02-05 22:16:32 +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
rjl493456442
78a3c32ef4
core, core/rawdb, eth/sync: no tx indexing during snap sync (#28703)
This change simplifies the logic for indexing transactions and enhances the UX when transaction is not found by returning more information to users.

Transaction indexing is now considered as a part of the initial sync, and `eth.syncing` will thus be `true` if transaction indexing is not yet finished. API consumers can use the syncing status to determine if the node is ready to serve users.
2024-01-22 21:05:18 +01:00
Paul Lange
c66ca8bf7a
tracer: use proper base fee in tests (#28775)
In the tracing tests, the base fee was generally set to nil. This commit changes this to pass the proper base instead, and fixes the few tests which become broken by the change.
2024-01-16 12:20:26 +01:00
Martin Holst Swende
3dc071e036
eth/tracers/logger: make structlog/json-log stack hex again (#28628)
* common/hexutil: define hex wrappers for uint256.Int

* eth/tracers/logger: make structlog/json-log stack hex again

* common/hexutil: goimports
2023-12-05 09:37:48 +01:00