diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 1cdac54530e5..fd362750145e 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -15,7 +15,7 @@ jobs: - name: Set up Go 1.x uses: actions/setup-go@v2 with: - go-version: ^1.13 + go-version: ^1.19 id: go - name: Check out code into the Go module directory diff --git a/core/state_processor.go b/core/state_processor.go index 7705365899cb..629086d18266 100644 --- a/core/state_processor.go +++ b/core/state_processor.go @@ -142,7 +142,7 @@ func applyTransaction(msg *Message, config *params.ChainConfig, gp *GasPool, sta return receipt, err } -func applyTransactionWithResult(msg types.Message, config *params.ChainConfig, bc ChainContext, author *common.Address, gp *GasPool, statedb *state.StateDB, header *types.Header, tx *types.Transaction, usedGas *uint64, evm *vm.EVM) (*types.Receipt, *ExecutionResult, error) { +func applyTransactionWithResult(msg *Message, config *params.ChainConfig, gp *GasPool, statedb *state.StateDB, blockNumber *big.Int, blockHash common.Hash, tx *types.Transaction, usedGas *uint64, evm *vm.EVM) (*types.Receipt, *ExecutionResult, error) { // Create a new context to be used in the EVM environment. txContext := NewEVMTxContext(msg) evm.Reset(txContext, statedb) @@ -155,10 +155,10 @@ func applyTransactionWithResult(msg types.Message, config *params.ChainConfig, b // Update the state with pending changes. var root []byte - if config.IsByzantium(header.Number) { + if config.IsByzantium(blockNumber) { statedb.Finalise(true) } else { - root = statedb.IntermediateRoot(config.IsEIP158(header.Number)).Bytes() + root = statedb.IntermediateRoot(config.IsEIP158(blockNumber)).Bytes() } *usedGas += result.UsedGas @@ -174,15 +174,15 @@ func applyTransactionWithResult(msg types.Message, config *params.ChainConfig, b receipt.GasUsed = result.UsedGas // If the transaction created a contract, store the creation address in the receipt. - if msg.To() == nil { + if msg.To == nil { receipt.ContractAddress = crypto.CreateAddress(evm.TxContext.Origin, tx.Nonce()) } // Set the receipt logs and create the bloom filter. - receipt.Logs = statedb.GetLogs(tx.Hash(), header.Hash()) + receipt.Logs = statedb.GetLogs(tx.Hash(), blockNumber.Uint64(), blockHash) receipt.Bloom = types.CreateBloom(types.Receipts{receipt}) - receipt.BlockHash = header.Hash() - receipt.BlockNumber = header.Number + receipt.BlockHash = blockHash + receipt.BlockNumber = blockNumber receipt.TransactionIndex = uint(statedb.TxIndex()) return receipt, result, err } @@ -203,12 +203,12 @@ func ApplyTransaction(config *params.ChainConfig, bc ChainContext, author *commo } func ApplyTransactionWithResult(config *params.ChainConfig, bc ChainContext, author *common.Address, gp *GasPool, statedb *state.StateDB, header *types.Header, tx *types.Transaction, usedGas *uint64, cfg vm.Config) (*types.Receipt, *ExecutionResult, error) { - msg, err := tx.AsMessage(types.MakeSigner(config, header.Number), header.BaseFee) + msg, err := TransactionToMessage(tx, types.MakeSigner(config, header.Number), header.BaseFee) if err != nil { return nil, nil, err } // Create a new context to be used in the EVM environment blockContext := NewEVMBlockContext(header, bc, author) vmenv := vm.NewEVM(blockContext, vm.TxContext{}, statedb, config, cfg) - return applyTransactionWithResult(msg, config, bc, author, gp, statedb, header, tx, usedGas, vmenv) + return applyTransactionWithResult(msg, config, gp, statedb, header.Number, header.Hash(), tx, usedGas, vmenv) } diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 9b3742138f4b..5b6f1cc613e2 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -2227,7 +2227,7 @@ func (s *BundleAPI) CallBundle(ctx context.Context, args CallBundleArgs) (map[st } coinbaseBalanceBeforeTx := state.GetBalance(coinbase) - state.Prepare(tx.Hash(), i) + state.SetTxContext(tx.Hash(), i) receipt, result, err := core.ApplyTransactionWithResult(s.b.ChainConfig(), s.chain, &coinbase, gp, state, header, tx, &header.GasUsed, vmconfig) if err != nil { @@ -2382,7 +2382,7 @@ func (s *BundleAPI) EstimateGasBundle(ctx context.Context, args EstimateGasBundl rand.Read(randomHash[:]) // New random hash since its a call - statedb.Prepare(randomHash, i) + statedb.SetTxContext(randomHash, i) // Convert tx args to msg to apply state transition msg, err := txArgs.ToMessage(globalGasCap, header.BaseFee)