diff --git a/cmd/evm/internal/t8ntool/execution.go b/cmd/evm/internal/t8ntool/execution.go index 59c43693a2..a2de58ad46 100644 --- a/cmd/evm/internal/t8ntool/execution.go +++ b/cmd/evm/internal/t8ntool/execution.go @@ -270,7 +270,7 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig, continue } } - statedb.SetTxContext(tx.Hash(), len(receipts), uint16(len(receipts)+1)) + statedb.SetTxContext(tx.Hash(), len(receipts), uint32(len(receipts)+1)) var ( snapshot = statedb.Snapshot() gp = gaspool.Snapshot() @@ -336,7 +336,7 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig, for _, receipt := range receipts { allLogs = append(allLogs, receipt.Logs...) } - requests, err := core.PostExecution(context.Background(), chainConfig, vmContext.BlockNumber, vmContext.Time, allLogs, evm, uint16(len(receipts)+1)) + requests, err := core.PostExecution(context.Background(), chainConfig, vmContext.BlockNumber, vmContext.Time, allLogs, evm, uint32(len(receipts)+1)) if err != nil { return nil, nil, nil, NewError(ErrorEVM, fmt.Errorf("failed to process post-execution: %v", err)) } diff --git a/core/chain_makers.go b/core/chain_makers.go index da6881e050..cfd6302794 100644 --- a/core/chain_makers.go +++ b/core/chain_makers.go @@ -117,7 +117,7 @@ func (b *BlockGen) addTx(bc *BlockChain, vmConfig vm.Config, tx *types.Transacti blockContext = NewEVMBlockContext(b.header, bc, &b.header.Coinbase) evm = vm.NewEVM(blockContext, b.statedb, b.cm.config, vmConfig) ) - b.statedb.SetTxContext(tx.Hash(), len(b.txs), uint16(len(b.txs)+1)) + b.statedb.SetTxContext(tx.Hash(), len(b.txs), uint32(len(b.txs)+1)) receipt, err := ApplyTransaction(evm, b.gasPool, b.statedb, b.header, tx) if err != nil { panic(err) @@ -323,7 +323,7 @@ func (b *BlockGen) collectRequests(readonly bool) (requests [][]byte) { blockContext := NewEVMBlockContext(b.header, b.cm, &b.header.Coinbase) evm := vm.NewEVM(blockContext, statedb, b.cm.config, vm.Config{}) - requests, err := PostExecution(context.Background(), b.cm.config, b.header.Number, b.header.Time, blockLogs, evm, uint16(len(b.txs)+1)) + requests, err := PostExecution(context.Background(), b.cm.config, b.header.Number, b.header.Time, blockLogs, evm, uint32(len(b.txs)+1)) if err != nil { panic(fmt.Sprintf("failed to run post-execution: %v", err)) } diff --git a/core/state/statedb.go b/core/state/statedb.go index 339211b95a..1c49d46020 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -132,7 +132,7 @@ type StateDB struct { stateAccessList *bal.ConstructionBlockAccessList // Block access index (0 for pre-execution, 1..n for transactions, n+1 for post-execution) - blockAccessIndex uint16 + blockAccessIndex uint32 // Transient storage transientStorage transientStorage @@ -1097,7 +1097,7 @@ func (s *StateDB) IntermediateRoot(deleteEmptyObjects bool) common.Hash { // SetTxContext sets the current transaction hash and index which are // used when the EVM emits new state logs. It should be invoked before // transaction execution. -func (s *StateDB) SetTxContext(thash common.Hash, ti int, blockAccessIndex uint16) { +func (s *StateDB) SetTxContext(thash common.Hash, ti int, blockAccessIndex uint32) { s.thash = thash s.txIndex = ti s.blockAccessIndex = blockAccessIndex diff --git a/core/state/statedb_hooked.go b/core/state/statedb_hooked.go index 5e1ad5afbd..98d01343a4 100644 --- a/core/state/statedb_hooked.go +++ b/core/state/statedb_hooked.go @@ -289,6 +289,6 @@ func (s *hookedStateDB) Finalise(deleteEmptyObjects bool) *bal.ConstructionBlock return s.inner.Finalise(deleteEmptyObjects) } -func (s *hookedStateDB) SetTxContext(thash common.Hash, ti int, blockAccessIndex uint16) { +func (s *hookedStateDB) SetTxContext(thash common.Hash, ti int, blockAccessIndex uint32) { s.inner.SetTxContext(thash, ti, blockAccessIndex) } diff --git a/core/state_prefetcher.go b/core/state_prefetcher.go index 11a0f282d2..d99611ff2c 100644 --- a/core/state_prefetcher.go +++ b/core/state_prefetcher.go @@ -104,7 +104,7 @@ func (p *statePrefetcher) Prefetch(block *types.Block, statedb *state.StateDB, c // Disable the nonce check msg.SkipNonceChecks = true - stateCpy.SetTxContext(tx.Hash(), i, uint16(i+1)) + stateCpy.SetTxContext(tx.Hash(), i, uint32(i+1)) // We attempt to apply a transaction. The goal is not to execute // the transaction successfully, rather to warm up touched data slots. diff --git a/core/state_processor.go b/core/state_processor.go index 0e57d32410..13466b7815 100644 --- a/core/state_processor.go +++ b/core/state_processor.go @@ -94,7 +94,7 @@ func (p *StateProcessor) Process(ctx context.Context, block *types.Block, stated if err != nil { return nil, fmt.Errorf("could not apply tx %d [%v]: %w", i, tx.Hash().Hex(), err) } - statedb.SetTxContext(tx.Hash(), i, uint16(i+1)) + statedb.SetTxContext(tx.Hash(), i, uint32(i+1)) _, _, spanEnd := telemetry.StartSpan(ctx, "core.ApplyTransactionWithEVM", telemetry.StringAttribute("tx.hash", tx.Hash().Hex()), telemetry.Int64Attribute("tx.index", int64(i)), @@ -109,7 +109,7 @@ func (p *StateProcessor) Process(ctx context.Context, block *types.Block, stated allLogs = append(allLogs, receipt.Logs...) spanEnd(nil) } - requests, err := PostExecution(ctx, config, block.Number(), block.Time(), allLogs, evm, uint16(len(block.Transactions())+1)) + requests, err := PostExecution(ctx, config, block.Number(), block.Time(), allLogs, evm, uint32(len(block.Transactions())+1)) if err != nil { return nil, err } @@ -142,7 +142,7 @@ func PreExecution(ctx context.Context, beaconRoot *common.Hash, parent common.Ha // PostExecution processes post-execution system calls when Prague is enabled. // If Prague is not activated, it returns null requests to differentiate from // empty requests. -func PostExecution(ctx context.Context, config *params.ChainConfig, number *big.Int, time uint64, allLogs []*types.Log, evm *vm.EVM, blockAccessIndex uint16) (requests [][]byte, err error) { +func PostExecution(ctx context.Context, config *params.ChainConfig, number *big.Int, time uint64, allLogs []*types.Log, evm *vm.EVM, blockAccessIndex uint32) (requests [][]byte, err error) { _, _, spanEnd := telemetry.StartSpan(ctx, "core.postExecution") defer spanEnd(&err) @@ -309,17 +309,17 @@ func ProcessParentBlockHash(prevHash common.Hash, evm *vm.EVM) { // ProcessWithdrawalQueue calls the EIP-7002 withdrawal queue contract. // It returns the opaque request data returned by the contract. -func ProcessWithdrawalQueue(requests *[][]byte, evm *vm.EVM, blockAccessIndex uint16) error { +func ProcessWithdrawalQueue(requests *[][]byte, evm *vm.EVM, blockAccessIndex uint32) error { return processRequestsSystemCall(requests, evm, 0x01, params.WithdrawalQueueAddress, blockAccessIndex) } // ProcessConsolidationQueue calls the EIP-7251 consolidation queue contract. // It returns the opaque request data returned by the contract. -func ProcessConsolidationQueue(requests *[][]byte, evm *vm.EVM, blockAccessIndex uint16) error { +func ProcessConsolidationQueue(requests *[][]byte, evm *vm.EVM, blockAccessIndex uint32) error { return processRequestsSystemCall(requests, evm, 0x02, params.ConsolidationQueueAddress, blockAccessIndex) } -func processRequestsSystemCall(requests *[][]byte, evm *vm.EVM, requestType byte, addr common.Address, blockAccessIndex uint16) error { +func processRequestsSystemCall(requests *[][]byte, evm *vm.EVM, requestType byte, addr common.Address, blockAccessIndex uint32) error { if tracer := evm.Config.Tracer; tracer != nil { onSystemCallStart(tracer, evm.GetVMContext()) if tracer.OnSystemCallEnd != nil { diff --git a/core/vm/interface.go b/core/vm/interface.go index 6d197d06f6..a9938c2a28 100644 --- a/core/vm/interface.go +++ b/core/vm/interface.go @@ -99,5 +99,5 @@ type StateDB interface { // Finalise must be invoked at the end of a transaction Finalise(bool) *bal.ConstructionBlockAccessList - SetTxContext(thash common.Hash, ti int, blockAccessIndex uint16) + SetTxContext(thash common.Hash, ti int, blockAccessIndex uint32) } diff --git a/eth/state_accessor.go b/eth/state_accessor.go index fd2f879616..284ddf4305 100644 --- a/eth/state_accessor.go +++ b/eth/state_accessor.go @@ -265,7 +265,7 @@ func (eth *Ethereum) stateAtTransaction(ctx context.Context, block *types.Block, msg, _ := core.TransactionToMessage(tx, signer, block.BaseFee()) // Not yet the searched for transaction, execute on top of the current state - statedb.SetTxContext(tx.Hash(), idx, uint16(idx+1)) + statedb.SetTxContext(tx.Hash(), idx, uint32(idx+1)) if _, err := core.ApplyMessage(evm, msg, nil); err != nil { return nil, vm.BlockContext{}, nil, nil, fmt.Errorf("transaction %#x failed: %v", tx.Hash(), err) } diff --git a/eth/tracers/api.go b/eth/tracers/api.go index 822f38ea5b..57f9ebc0d7 100644 --- a/eth/tracers/api.go +++ b/eth/tracers/api.go @@ -530,7 +530,7 @@ func (api *API) IntermediateRoots(ctx context.Context, hash common.Hash, config return nil, err } msg, _ := core.TransactionToMessage(tx, signer, block.BaseFee()) - statedb.SetTxContext(tx.Hash(), i, uint16(i+1)) + statedb.SetTxContext(tx.Hash(), i, uint32(i+1)) if _, err := core.ApplyMessage(evm, msg, nil); err != nil { log.Warn("Tracing intermediate roots did not complete", "txindex", i, "txhash", tx.Hash(), "err", err) // We intentionally don't return the error here: if we do, then the RPC server will not @@ -681,7 +681,7 @@ txloop: // Generate the next state snapshot fast without tracing msg, _ := core.TransactionToMessage(tx, signer, block.BaseFee()) - statedb.SetTxContext(tx.Hash(), i, uint16(i+1)) + statedb.SetTxContext(tx.Hash(), i, uint32(i+1)) if _, err := core.ApplyMessage(evm, msg, nil); err != nil { failed = err break txloop @@ -793,7 +793,7 @@ func (api *API) standardTraceBlockToFile(ctx context.Context, block *types.Block }) ) // Execute the transaction and flush any traces to disk - statedb.SetTxContext(tx.Hash(), i, uint16(i+1)) + statedb.SetTxContext(tx.Hash(), i, uint32(i+1)) if tracer.OnTxStart != nil { tracer.OnTxStart(evm.GetVMContext(), tx, msg.From) } @@ -1016,7 +1016,7 @@ func (api *API) traceTx(ctx context.Context, tx *types.Transaction, message *cor defer cancel() // Call Prepare to clear out the statedb access list - statedb.SetTxContext(txctx.TxHash, txctx.TxIndex, uint16(txctx.TxIndex)) + statedb.SetTxContext(txctx.TxHash, txctx.TxIndex, uint32(txctx.TxIndex)) _, err = core.ApplyTransactionWithEVM(message, core.NewGasPool(message.GasLimit), statedb, vmctx.BlockNumber, txctx.BlockHash, vmctx.Time, tx, evm) if err != nil { diff --git a/internal/ethapi/simulate.go b/internal/ethapi/simulate.go index 9c3fb6a52e..ad69cdf0a0 100644 --- a/internal/ethapi/simulate.go +++ b/internal/ethapi/simulate.go @@ -340,7 +340,7 @@ func (sim *simulator) processBlock(ctx context.Context, block *simBlock, header, tracer.reset(txHash, uint(i)) // EoA check is always skipped, even in validation mode. - sim.state.SetTxContext(txHash, i, uint16(i+1)) + sim.state.SetTxContext(txHash, i, uint32(i+1)) msg := call.ToMessage(header.BaseFee, !sim.validate) result, err := applyMessageWithEVM(ctx, evm, msg, timeout, gp) if err != nil { @@ -390,8 +390,8 @@ func (sim *simulator) processBlock(ctx context.Context, block *simBlock, header, header.BlobGasUsed = &blobGasUsed } - // Run post-execution system calls - requests, err := core.PostExecution(ctx, sim.chainConfig, header.Number, header.Time, allLogs, evm, uint16(len(block.Calls)+1)) + // Process EIP-7685 requests + requests, err := core.PostExecution(ctx, sim.chainConfig, header.Number, header.Time, allLogs, evm, uint32(len(block.Calls)+1)) if err != nil { return nil, nil, nil, err } diff --git a/miner/worker.go b/miner/worker.go index 08acdf3339..026bafc4e5 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -167,7 +167,7 @@ func (miner *Miner) generateWork(ctx context.Context, genParam *generateParams, // otherwise, fill the block with the current transactions from the txpool if genParam.forceOverrides && len(genParam.overrideTxs) > 0 { for _, tx := range genParam.overrideTxs { - work.state.SetTxContext(tx.Hash(), work.tcount, uint16(work.tcount+1)) + work.state.SetTxContext(tx.Hash(), work.tcount, uint32(work.tcount+1)) if err := miner.commitTransaction(ctx, work, tx); err != nil { // all passed transactions HAVE to be valid at this point return &newPayloadResult{err: err} @@ -208,7 +208,7 @@ func (miner *Miner) generateWork(ctx context.Context, genParam *generateParams, } // Collect consensus-layer requests if Prague is enabled. - requests, err := core.PostExecution(ctx, miner.chainConfig, work.header.Number, work.header.Time, allLogs, work.evm, uint16(work.tcount+1)) + requests, err := core.PostExecution(ctx, miner.chainConfig, work.header.Number, work.header.Time, allLogs, work.evm, uint32(work.tcount+1)) if err != nil { return &newPayloadResult{err: err} } @@ -502,7 +502,7 @@ func (miner *Miner) commitTransactions(ctx context.Context, env *environment, pl continue } // Start executing the transaction - env.state.SetTxContext(tx.Hash(), env.tcount, uint16(env.tcount+1)) + env.state.SetTxContext(tx.Hash(), env.tcount, uint32(env.tcount+1)) err := miner.commitTransaction(ctx, env, tx) switch {