Cherry-pick https://github.com/ethereum/go-ethereum/pull/24017.
* core/vm: Define 0xfe opcode as INVALID
* core/vm: Remove opInvalid as opUndefined handles it
Co-authored-by: Alex Beregszaszi <alex@rtfs.hu>
Co-authored-by: Andrei Maiboroda <andrei@ethereum.org>
Co-authored-by: Alex Beregszaszi <alex@rtfs.hu>
Works around a flaw in the upgrade logic of the system contracts. Since
they are updated directly, without first being self-destructed and then
re-created, the usual incarnation logic does not get activated, and all
historical records of the code of these contracts are retrieved as the
most recent version. This problem will not exist in erigon3, but until
then, a workaround will be used to access code of such contracts through
a special structure, `SystemContractCodeLookup`
Fixes https://github.com/ledgerwatch/erigon/issues/5865
Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local>
So there is an issue with tracing certain blocks/transactions on
Polygon, for example:
```
> '{"method": "trace_transaction","params":["0xb198d93f640343a98f90d93aa2b74b4fc5c64f3a649f1608d2bfd1004f9dee0e"],"id":1,"jsonrpc":"2.0"}'
```
gives the error `first run for txIndex 1 error: insufficient funds for
gas * price + value: address 0x10AD27A96CDBffC90ab3b83bF695911426A69f5E
have 16927727762862809 want 17594166808296934`
The reason is that this transaction is from the author of the block,
which doesn't have enough ETH to pay for the gas fee + tx value if he's
not the block author receiving transactions fees.
The issue is that currently the APIs are using `ethash.NewFaker()`
Engine for running traces, etc. which doesn't know how to get the author
for a specific block (which is consensus dependant); as it was noting in
several TODO comments.
The fix is to pass the Engine to the BaseAPI, which can then be used to
create the right Block Context. I chose to split the current Engine
interface in 2, with Reader and Writer, so that the BaseAPI only
receives the Reader one, which might be safer (even though it's only
used for getting the block Author).
* Consensus tests update 11
* Add GrayGlacier fork
* Wire currentRandom from tests into PREVRANDAO
* Serenity engine
* Support insertion of PoS blocks in MockSentry
* Introduce marshallTypedTransactionsAsRlpStrings arg into (*Block) RawBody()
* Revert "Introduce marshallTypedTransactionsAsRlpStrings arg into (*Block) RawBody()"
This reverts commit 903fca572be03c7de33318ce177a03a4be34927b.
* Post-merge fix
* Don't wait for Beacon Chain in tests
* Skip powToPosBlockRejection transition test
* ForkChoice in insertPoSBlocks
* Add withPosDownloader arg to MockWithEverything in order to fix TestPoSDownloader
* evm t8n tool to use ExecuteBlockEphemerally api (#4512)
* fix to set V, R, S in legacy transaction
* fix to dump post-execution alloc for evm t8n
* close tx in evm t8n
* populate current difficulty and gas used in output result
- update the ExecutionResult to include corresponding info (like
Difficulty/GasUsed)
* initial attempt at migrating 'evm t8n' to use ExecuteBlockEphemerally
* using ExecutionResult in ExecuteBlockEphemerally
* bypass validations and integrate with EphemeralExecResult
* fixing output of 'evm t8n'
- remaining bits are "stateRoot" in results.txt and "balance" field for one account in
alloc.txt (for testdata=1)
* get ExecuteBlockEphemerally to accept getTracer lambda
* fix build failure
* test cases for evm t8n
* more test cases for evm t8n
* fix stateRoot computation in evm t8n
* remove reward argument, as EBE itself takes care of it
* final cleanups for migration to using ExecuteBlockEphemerally
* change EBEforBSC to match EBE
* fix linter issues
* manually revert an unwanted diff
* avoid calculating ReceiptHash twice
* linter check
* minor correction
* remove unnecessary logic in EBEforBsc
* fix integration tests
* fix build
* Revert "evm t8n tool to use ExecuteBlockEphemerally api (#4512)"
This reverts commit db93d2ea37.
* Fix compilation
Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro.local>
* fix to set V, R, S in legacy transaction
* fix to dump post-execution alloc for evm t8n
* close tx in evm t8n
* populate current difficulty and gas used in output result
- update the ExecutionResult to include corresponding info (like
Difficulty/GasUsed)
* initial attempt at migrating 'evm t8n' to use ExecuteBlockEphemerally
* using ExecutionResult in ExecuteBlockEphemerally
* bypass validations and integrate with EphemeralExecResult
* fixing output of 'evm t8n'
- remaining bits are "stateRoot" in results.txt and "balance" field for one account in
alloc.txt (for testdata=1)
* get ExecuteBlockEphemerally to accept getTracer lambda
* fix build failure
* test cases for evm t8n
* more test cases for evm t8n
* fix stateRoot computation in evm t8n
* remove reward argument, as EBE itself takes care of it
* final cleanups for migration to using ExecuteBlockEphemerally
* change EBEforBSC to match EBE
* fix linter issues
* manually revert an unwanted diff
* avoid calculating ReceiptHash twice
* linter check
* minor correction
* remove unnecessary logic in EBEforBsc
* adding eth_getLogs functionality for contract events for the devnet tool
* Made changes to fix double hashing
* Fixed lint errors
* Changed strings.Replace to strings.ReplaceAll for replacing strings
* Cleaned up print statements across files
* Fixed logs not being populated in result typee.go
Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local>
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* save
* handle chain flag in integration
* handle chain flag in integration
* handle chain flag in integration
* save
* save
* merge devel
* save
* noopWriter - one is enough
* chain spec parser
* chain spec parser
* embed
* embed
* embed
* embed
* embed
* embed
* embed
* clean
* clean
* correct alloc after reset state
* correct alloc after reset state
* correct alloc after reset state
* integration reset state now does re-apply genesis and chainConfig
* eips summary
* eips summary
* eips summary
* Where I am at
* Refactoring of transaction types
* More refactoring
* Use Homested signer in rpc daemon
* Unified signer
* Continue unified signer
* A bit more
* Fixes and down the rabbit hole...
* More tx pool fixes
* More refactoring fixes
* More fixes'
* more fixes
* More fixes
* More compile fixes
* More RLP hand-writing
* Finish RLP encoding/decoding of transactions
* Fixes to header encoding, start on protocol packets
* Transaction decoding
* Use DecodeTransaction function
* Decoding BlockBodyPacket
* Encode and decode for pool txs
* Start fixing tests
* Introduce SigningHash
* Fixes to SignHash
* RLP encoding fixes
* Fixes for encoding/decoding
* More test fixes
* Fix more tests
* More test fixes
* More test fixes
* Fix core tests
* More fixes for signer
* Fix for tx
* Fixes to string encoding/size
* Fix eip2930 test
* Fix rest of ./tests
* More fixes
* Fix compilation
* More test fixes
* More test fixes
* Test fixes
* More fixes
* Reuse EncodingSize in EncodeRLP for accessList
* Rearrange things in dynamic fee tx
* Add MarshalBinary
* More fixes
* Make V,R,S non-pointers
* More NPE fixes
* More fixes
* Receipt fixes
* Fix core/types
* Fix ./eth
* More compile fixes for tests
* More test fixes
* More test fixes
* Try to see lint errors better
* Try to see lint errors better
* Fix lint
* Debugging eip1559 test
* Fix TestEIP1559Transition test
* Fix NewBlockPacket encoding/decoding
* Fix calculation of TxHash
* Fix perf problem with senders
* Update aleut config values
* Try adding static peers
* Add staticpeers to defaul flags
* Change aleut networkID
* Fix test
Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro.local>
Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local>
This adds support for EIP-2718 typed transactions as well as EIP-2930
access list transactions (tx type 1). These EIPs are scheduled for the
Berlin fork.
There very few changes to existing APIs in core/types, and several new APIs
to deal with access list transactions. In particular, there are two new
constructor functions for transactions: types.NewTx and types.SignNewTx.
Since the canonical encoding of typed transactions is not RLP-compatible,
Transaction now has new methods for encoding and decoding: MarshalBinary
and UnmarshalBinary.
The existing EIP-155 signer does not support the new transaction types.
All code dealing with transaction signatures should be updated to use the
newer EIP-2930 signer. To make this easier for future updates, we have
added new constructor functions for types.Signer: types.LatestSigner and
types.LatestSignerForChainID.
This change also adds support for the YoloV3 testnet.
Co-authored-by: Martin Holst Swende <martin@swende.se>
Co-authored-by: Felix Lange <fjl@twurst.com>
Co-authored-by: Ryan Schneider <ryanleeschneider@gmail.com>
# Conflicts:
# accounts/abi/bind/backends/simulated.go
# cmd/evm/internal/t8ntool/execution.go
# cmd/evm/internal/t8ntool/transition.go
# cmd/geth/main.go
# cmd/geth/usage.go
# core/bench_test.go
# core/state/statedb.go
# core/state_prefetcher.go
# core/state_processor.go
# core/state_transition.go
# core/tx_pool.go
# core/types/block.go
# core/types/derive_sha.go
# core/types/gen_tx_json.go
# core/types/receipt.go
# core/types/receipt_test.go
# core/types/transaction.go
# core/types/transaction_signing.go
# core/types/transaction_test.go
# ethclient/ethclient.go
# ethclient/signer.go
# graphql/graphql.go
# internal/ethapi/api.go
# internal/guide/guide_test.go
# les/benchmark.go
# les/odr_test.go
# light/odr_test.go
# light/txpool.go
# miner/worker.go
# miner/worker_test.go
# signer/core/api.go
# tests/state_test_util.go
# trie/stacktrie_test.go
# turbo/stages/blockchain_test.go
There was a dormant error with structured inputs that failed unpacking.
This commit fixes the error by switching casting to the better abi.ConvertType function.
It also adds a test for calling a view function that returns a struct
This commit enables users to specify which signer they want to use while creating their transactOpts.
Previously all contract interactions used the homestead signer. Now a user can specify whether they
want to sign with homestead or EIP155 and specify the chainID which adds another layer of security.
Closes#16484
# Conflicts:
# accounts/abi/bind/auth.go
# accounts/abi/bind/backends/simulated.go
# accounts/abi/bind/bind_test.go
# les/sync_test.go
# les/test_helper.go
# mobile/bind.go
A lot of times when we hit 'core' errors, example: invalid tx, the information provided is
insufficient. We miss several pieces of information: what account has nonce too high,
and what transaction in that block was offending?
This PR adds that information, using the new type of wrapped errors.
It also adds a testcase which (partly) verifies the output from the errors.
The first commit changes all usage of direct equality-checks on core errors, into
using errors.Is. The second commit adds contextual information. This wraps most
of the core errors with more information, and also wraps it one more time in
stateprocessor, to further provide tx index and tx hash, if such a tx is encoutered in
a block. The third commit uses the chainmaker to try to generate chains with such
errors in them, thus triggering the errors and checking that the generated string meets
expectations.
# Conflicts:
# core/state_processor.go
# core/state_transition.go
# core/tx_pool_test.go
# light/lightchain_test.go
# turbo/stages/blockchain_test.go
* trace_call initial
* Fix tests
* More tracing
* Add more fields to the action
* Completed first example query
* Add initial bench11 to compare trace_call with OpenEthereum
* Exclude precompile calls from call traces
* Add self-destruct, call types, more comparison in rpctest
* Support for execution errors
* Stack underflow error and delegatecall value
* Fix lint
* Fix suicide traceAddress, Bad instruction error
* Fix lint
Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local>
* Cleanup and rpcdaemon unit tests
* Fix
* Fix
* Fix lint
* Test for debug_traceTransaction
* Add NoRefunds option
* Compile fix, test for no refunds
* Fix compile
* Add poly contract, fix compile errors
* No refunds now work
* Fix NPE in rpcdaemon
Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local>
* State cache init
* More code
* Fix lint
* More tests
* More tests
* More tests
* Fix test
* Transformations
* remove writeQueue, before fixing the tests
* Fix tests
* Add more tests, incarnation to the code items
* Fix lint
* Fix lint
* Remove shards prototype, add incarnation to the state reader code
* Clean up and replace cache in call_traces stage
* fix flaky test
* Save changes
* Readers to use addrHash, writes - addresses
* Fix lint
* Fix lint
* More accurate tracking of size
* Optimise for smaller write batches
* Attempt to integrate state cache into Execution stage
* cacheSize to default flags
* Print correct cache sizes and batch sizes
* cacheSize in the integration
* Fix tests
* Fix lint
* Remove print
* Fix exec stage
* Fix test
* Refresh sequence on write
* No double increment
* heap.Remove
* Try to fix alignment
* Refactoring, adding hashItems
* More changes
* Fix compile errors
* Fix lint
* Wrapping cached reader
* Wrap writer into cached writer
* Turn state cache off by default
* Fix plain state writer
* Fix for code/storage mixup
* Fix tests
* Fix clique test
* Better fix for the tests
* Add test and fix some more
* Fix compile error|
* More functions
* Fixes
* Fix for the tests
* sepatate DeletedFlag and AbsentFlag
* Minor fixes
* Test refactoring
* More changes
* Fix some tests
* More test fixes
* More test fixes
* Fix lint
* Move blockchain_test to be able to use stagedsync
* More fixes
* Fixes and cleanup
* Fix tests in turbo/stages
* Fix lint
* Fix lint
* Intemediate
* Fix tests
* Intemediate
* More fixes
* Compilation fixes
* More fixes
* Fix compile errors
* More test fixes
* More fixes
* More test fixes
* Fix compile error
* Fixes
* Fix
* Fix
* More fixes
* Fixes
* More fixes and cleanup
* Further fix
* Check gas used and bloom with header
Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local>
* ReadBlockByNumber and ReadChainConfig return error
* Let's make rawdb package to return error. But by small steps.
High-level methods need to move first:
ReadBlockByNumber
ReadChainConfig
ReadBlockByHash
ReadHeaderByHash
WriteChainConfig
WriteDatabaseVersion
WriteBlock
DeleteTd
WriteTd
ReadTd
* Initial commit for CallTraces index
* Fix compilation
* fix lint, add comment
* Fix integration
* Add Close function to ethdb.Cursor, fix some compile errors
* Try to stop cursor leak in Get
* Fix compile errors in RPC daemon
* Fix compile errors
* fixing another way
* Some fixes
* More fixes
* More fixes
* More fixes
* Fixes to core/state
* Fix lint
* Fix lint
* Fixes
* Stage caching for call trace stage
* Add mem stats
* Try to stop the leak
* Turn off debug
* Chunks for 10k blocks
* Print
* Revert "Print"
This reverts commit 5ffada4828d61e00e5dad1ca12c98258dfbbad00.
* Revert "Chunks for 10k blocks"
This reverts commit cfb9d498e782e5583d41c30abf0e2137da27383e.
* Trying to fix the leak
* Don't compute receipts in re-tracing
* Not compose block
* Print speed, fix receipts, bigger caches
* Fix lint
* Utilise changeset info
* Counters
* Use NoReceipts and ReadOnly
* ReadOnly is incompatible with caching
* Skip test leaking transactions
* Fix block test
* Change disable message for call-traces stage
* Use block option for call traces integration
* Fix retracing due to incarnation