Commit graph

497 commits

Author SHA1 Message Date
Matthieu Vachon
e51cbb0c95 Merge branch 'extended-tracer' into firehose-fh3.0
# Conflicts:
#	go.mod
#	go.sum
2023-11-29 13:50:08 -05:00
Sina Mahmoodi
56600e911b fix VMError.Unwrap 2023-11-24 18:17:57 +03:30
Sina Mahmoodi
9c00b1290b fix merge conflict 2023-11-24 16:09:47 +03:30
Martin Holst Swende
2391fbc676
tests/fuzzers: move fuzzers into native packages (#28467)
This PR moves our fuzzers from tests/fuzzers into whatever their respective 'native' package is.

The historical reason why they were placed in an external location, is that when they were based on go-fuzz, they could not be "hidden" via the _test.go prefix. So in order to shove them away from the go-ethereum "production code", they were put aside.

But now we've rewritten them to be based on golang testing, and thus can be brought back. I've left (in tests/) the ones that are not production (bls128381), require non-standard imports (secp requires btcec, bn256 requires gnark/google/cloudflare deps).

This PR also adds a fuzzer for precompiled contracts, because why not.

This PR utilizes a newly rewritten replacement for go-118-fuzz-build, namely gofuzz-shim, which utilises the inputs from the fuzzing engine better.
2023-11-14 14:34:29 +01:00
Sina Mahmoodi
e803ef09ad
eth/tracers/js: fix isPush for push0 (#28520)
Fixes so that `push0` opcode is correctly reported as `true` by the `IsPush` function

---------

Co-authored-by: Martin Holst Swende <martin@swende.se>
2023-11-14 13:14:38 +01:00
Sina Mahmoodi
0d268b796c fix TxStart for traceCall 2023-11-08 19:28:42 +03:00
Péter Szilágyi
470dba8fc1
core/vm: set basefee to 0 internally on eth_call (#28470)
* core/vm: set basefee to 0 internally on eth_call

* core: nicer 0-basefee, make it work for blob fees too

* internal/ethapi: make tests a bit more complex

* core: fix blob fee checker

* core: make code a bit more readable

* core: fix some test error strings

* core/vm: Get rid of weird comment

* core: dict wrong typo
2023-11-08 11:22:08 +02:00
Sina Mahmoodi
429dcc99ca fix merge conflict 2023-11-02 15:58:17 +01:00
lmittmann
a3be38127c
core/vm: performance tweak of OpCode.String() (#28453)
make `opCodeToString` a `[256]string` array

Co-authored-by: lmittmann <lmittmann@users.noreply.github.com>
2023-11-02 08:54:28 +02:00
Matthieu Vachon
1914bc6ed0
error code for VM failures (#18)
* Experimental: EVMLogger fixed error code

* First pass of review

* Move error to `core/vm/errors.go`, ensure also we strictly implement `rpc.Error` (without depending on it)
2023-10-27 17:49:52 +02:00
kevaundray
a6a0ae45b6
crypto/kzg4844: use the new trusted setup file and format (#28383)
Changes the trusted_setup to the one created during the kzg-ceremony. The trusted setup file can be found in the consensus specs: https://github.com/ethereum/consensus-specs/blob/dev/presets/mainnet/trusted_setups/trusted_setup_4096.json
---------

Co-authored-by: Marius van der Wijden <m.vanderwijden@live.de>
2023-10-22 16:05:04 +02:00
0xbstn
fa6107c85e
core: fix typos (#28255)
fixes various typos in core
2023-10-10 10:22:03 +02:00
Marius van der Wijden
c39cbc1a78
core: implement BLOBBASEFEE opcode (0x4a) (#28098)
Implements "EIP-7516: BLOBBASEFEE opcode" for cancun, as per spec: https://eips.ethereum.org/EIPS/eip-7516
2023-10-02 05:49:29 -04:00
hzysvilla
4de89e92e4
core/vm: minor code formatting (#28199)
Adding a space beween function opOrigin() and opcCaller() in instruciton.go.
Adding a space beween function opkeccak256()  and opAddress() in instruciton.go.
2023-09-26 11:58:01 +03:00
Sina Mahmoodi
6ee4fb8eac resolve merge conflicts 2023-09-13 16:17:36 +02:00
Matthieu Vachon
8af369e181 Merge branch 'extended-tracer' into feature/firehose-extended-tracer
# Conflicts:
#	core/state_transition.go
#	core/vm/contract.go
#	core/vm/evm.go
#	core/vm/instructions.go
#	core/vm/interpreter.go
#	core/vm/logger.go
2023-09-12 14:07:11 -04:00
Matthieu Vachon
ff3c15ff90
Full OnGasConsumed loop and added GasChangeReason (#16) 2023-09-12 17:19:15 +02:00
Matthieu Vachon
90adcd0a1e Merge branch 'feature/gas-full-cycle-and-reason' into feature/firehose-extended-tracer
# Conflicts:
#	core/vm/evm.go
2023-09-11 12:53:03 -04:00
Matthieu Vachon
469ccbe765 Do not record GasChangeCallLeftOverReturned gas change if there is no gas to return 2023-09-11 12:43:38 -04:00
Matthieu Vachon
2ff2423e28 Fixed some missing gas change to wrap around full call 2023-09-11 12:32:11 -04:00
Matthieu Vachon
9c502aa6f8 Fixed some missing gas change to wrap around full call 2023-09-11 12:32:00 -04:00
Matthieu Vachon
3abff91f34 Merge branch 'feature/gas-full-cycle-and-reason' into feature/firehose-extended-tracer 2023-09-11 11:22:00 -04:00
Matthieu Vachon
06badab596 Inverted GasChangeCallLeftOverRefunded and GasChangeCallLeftOverReturned 2023-09-11 11:21:45 -04:00
Matthieu Vachon
31f1a01ec5 Merge branch 'feature/gas-full-cycle-and-reason' into feature/firehose-extended-tracer
# Conflicts:
#	core/blockchain.go
#	core/state_transition.go
#	core/vm/contracts.go
#	core/vm/evm.go
#	core/vm/instructions.go
#	core/vm/interpreter.go
#	core/vm/logger.go
#	core/vm/operations_acl.go
#	eth/backend.go
#	eth/tracers/logger/access_list_tracer.go
#	eth/tracers/logger/logger.go
#	eth/tracers/logger/logger_json.go
2023-09-11 10:27:01 -04:00
Matthieu Vachon
8f17c19c63 Fixed wrong split of trx and call 2023-09-06 17:05:02 -04:00
Matthieu Vachon
da14392fc6 Merge remote-tracking branch 's1na/extended-tracer' into feature/gas-full-cycle-and-reason 2023-09-06 11:40:01 -04:00
Sina Mahmoodi
651c438621 fix runtime tests 2023-09-04 17:55:01 +02:00
Matthieu Vachon
aad080db33 Normalized GasChange constats, emit Refund/BuyBack only if doing something, updated comments 2023-09-01 09:32:19 -04:00
Matthieu Vachon
d0dbbaf6a5 Change OnGasConsumed(gas, cost uint64, reason) to OnGasChange(old, new uint64, reason)
This way, we avoid having a `cost` that is negative which does not make sense for a `uint64`. Having the `old, new` also yields correct value and the delta can then be negative and be holded in a `int64`.

# Conflicts:
#	core/vm/evm.go
2023-08-28 19:20:01 -04:00
Matthieu Vachon
01ccd7126e Change OnGasConsumed(gas, cost uint64, reason) to OnGasChange(old, new uint64, reason)
This way, we avoid having a `cost` that is negative which does not make sense for a `uint64`. Having the `old, new` also yields correct value and the delta can then be negative and be holded in a `int64`.
2023-08-28 15:30:10 -04:00
Matthieu Vachon
e0af166ffa Full OnGasConsumed loop and added GasChangeReason
With this change, the full gas loop of a transaction can be tracked going from initial balance (`gasLimit`) back down to 0.

I validated on my regression test suite that those conditions applied to all transactions I have:
- First `OnGasConsumed` is always going from 0 -> `trx.gasLimit`
- Last `OnGasConsumed` "new value" is always 0
- trx.gasLimit - last balance of last `OnGasConsumed` is equal to `trx.gasUsed`

The addition of `reason` make it possible for a logger to filter out unwanted signal, for example one could want to drop all OpCode related gas change and only cares about "transaction" level. The reason is also a good thing for visibility and for creating powerful debug tools for Ethereum transaction execution.

Also, I would like that we change the `OnGasConsumed` logic from `OnGasConsumed(actual, cost uint64, reason)` to `OnGasConsumed(old, new uint64, reason)`. With the new tracing I've done, we now have negative `cost` that needs to be passed around but the `cost` is `uint64` so it creates overflow. Everything works fine if you record the new/old value `gas-cost` as the final value goes back to a valid range. But it's weird for consumer that would log `cost` that it's `18127127187219...`. An alternative would be to accept a `int64` for the cost which is also valid, not full coverage theorically but I don't see why an operation would cost more than i64 max value. Maybe it make more sense than to have signature `OnGasConsumed(gas uint64, cost int64, reason)`, I'm fine with it also, I leave the decision to you.
2023-08-28 15:30:10 -04:00
Guido Vranken
0ba2d3cfa4
core/vm/runtime: Add Random field to config (#28001) 2023-08-25 04:05:33 -04:00
Martin Holst Swende
e13fa32cea
core/vm: update 4844 - point evaluation precompile address (#27874) 2023-08-08 15:54:19 +03:00
Darioush Jalali
57cdbaef30
all: remove trailing whitespace (#27741) 2023-08-05 00:24:32 +02:00
Matthieu Vachon
09df0e0c95 Merge branch 'extended-tracer' into feature/firehose-extended-tracer
# Conflicts:
#	core/vm/evm.go
2023-08-02 09:49:36 -04:00
Matthieu Vachon
32c14945da Full OnGasConsumed loop and added GasChangeReason
With this change, the full gas loop of a transaction can be tracked going from initial balance (`gasLimit`) back down to 0.

I validated on my regression test suite that those conditions applied to all transactions I have:
- First `OnGasConsumed` is always going from 0 -> `trx.gasLimit`
- Last `OnGasConsumed` "new value" is always 0
- trx.gasLimit - last balance of last `OnGasConsumed` is equal to `trx.gasUsed`

The addition of `reason` make it possible for a logger to filter out unwanted signal, for example one could want to drop all OpCode related gas change and only cares about "transaction" level. The reason is also a good thing for visibility and for creating powerful debug tools for Ethereum transaction execution.
2023-08-02 09:16:45 -04:00
Matthieu Vachon
d723124530 Added IsPrecompileAddr on EVM to let tracer easily determine if an address is a precompiled address 2023-07-28 17:03:59 -04:00
Matthieu Vachon
5952799988 Fixed wrong EVM call tracing code 2023-07-27 16:32:03 -04:00
Sina Mahmoodi
f9f377d64f capture call validation errors 2023-07-27 21:57:40 +02:00
Matthieu Vachon
9af0334dff Use leftOverGas instead of gas as it's sure to respect Go rules for defer to have latest returned value 2023-07-27 15:37:09 -04:00
Matthieu Vachon
4e834c10d0 Merge remote-tracking branch 's1na/extended-tracer' into feature/firehose-extended-tracer
# Conflicts:
#	core/state/state_object.go
#	core/state/statedb_test.go
#	core/state_transition.go
#	core/txpool/legacypool/legacypool_test.go
#	core/vm/evm.go
#	core/vm/instructions.go
#	eth/api_debug_test.go
#	eth/tracers/js/tracer_test.go
#	go.sum
2023-07-27 11:47:40 -04:00
Péter Szilágyi
57268f7e6c
all: rename dataGas to blobGas (#27789) 2023-07-27 16:53:28 +03:00
Sina Mahmoodi
b2b32e6ff6 fix merge conflict 2023-07-27 14:41:47 +02:00
Sina Mahmoodi
2faf3dbfd6 emit err on tx validation failure 2023-07-26 20:07:13 +02:00
Matthieu Vachon
5466fa3133
Capture balance reason (#12) 2023-07-26 10:49:04 +02:00
Matthieu Vachon
dd86f19df4 Move up CaptureStart/CaptureEnd as well as CaptureEnter/CaptureExit higher directly when function starts 2023-07-25 14:35:59 -04:00
Matthieu Vachon
75e8c96f4e WIP 2023-07-25 10:40:30 -04:00
jwasinger
988d84aa7c
core/state, core/vm: implement EIP 6780 (#27189)
EIP-6780: SELFDESTRUCT only in same transaction

>     SELFDESTRUCT will recover all funds to the caller but not delete the account, except when called in the same transaction as creation

---------

Co-authored-by: Martin Holst Swende <martin@swende.se>
2023-07-17 13:02:18 -04:00
Martin Holst Swende
b058cf454b
core, tests: EIP-4844 transaction processing logic (#27721)
This updates the reference tests to the latest version and also adds logic
to process EIP-4844 blob transactions into the state transition. We are now
passing most Cancun fork tests.

Co-authored-by: Marius van der Wijden <m.vanderwijden@live.de>
Co-authored-by: Felix Lange <fjl@twurst.com>
2023-07-15 23:27:36 +02:00
ucwong
99e000cb13
core/vm: use types.EmptyCodeHash (#27729) 2023-07-15 17:45:57 +02:00