From 7a22d848c851b1dcc89344049e5be9833fde1e97 Mon Sep 17 00:00:00 2001 From: "lightclient@protonmail.com" Date: Fri, 13 Nov 2020 07:35:37 -0700 Subject: [PATCH] core/tx_pool: remove 2718 fork info from intrinsic gas --- core/bench_test.go | 2 +- core/state_transition.go | 7 +++---- core/tx_pool.go | 2 +- light/txpool.go | 2 +- tests/transaction_test_util.go | 21 ++++++++++----------- 5 files changed, 16 insertions(+), 18 deletions(-) diff --git a/core/bench_test.go b/core/bench_test.go index 0347bc44318c..85653ea5dbe6 100644 --- a/core/bench_test.go +++ b/core/bench_test.go @@ -85,7 +85,7 @@ func genValueTx(nbytes int) func(int, *BlockGen) { return func(i int, gen *BlockGen) { toaddr := common.Address{} data := make([]byte, nbytes) - gas, _ := IntrinsicGas(data, nil, false, false, false, false) + gas, _ := IntrinsicGas(data, nil, false, false, false) tx, _ := types.SignTx(types.NewTransaction(gen.TxNonce(benchRootAddr), toaddr, big.NewInt(1), gas, nil, data), types.HomesteadSigner{}, benchRootKey) gen.AddTx(tx) } diff --git a/core/state_transition.go b/core/state_transition.go index 2e83a15d9858..2ebd97dc08c6 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -106,7 +106,7 @@ func (result *ExecutionResult) Revert() []byte { } // IntrinsicGas computes the 'intrinsic gas' for a message with the given data. -func IntrinsicGas(data []byte, accessList *types.AccessList, isContractCreation bool, isHomestead, isEIP2028, isEIP2718 bool) (uint64, error) { +func IntrinsicGas(data []byte, accessList *types.AccessList, isContractCreation bool, isHomestead, isEIP2028 bool) (uint64, error) { // Set the starting gas for the raw transaction var gas uint64 if isContractCreation && isHomestead { @@ -139,7 +139,7 @@ func IntrinsicGas(data []byte, accessList *types.AccessList, isContractCreation } gas += z * params.TxDataZeroGas } - if isEIP2718 && accessList != nil { + if accessList != nil { gas += uint64(accessList.Addresses()) * params.TxAccessListAddressGas gas += uint64(accessList.StorageKeys()) * params.TxAccessListStorageKeyGas } @@ -238,11 +238,10 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) { sender := vm.AccountRef(msg.From()) homestead := st.evm.ChainConfig().IsHomestead(st.evm.Context.BlockNumber) istanbul := st.evm.ChainConfig().IsIstanbul(st.evm.Context.BlockNumber) - yoloV2 := st.evm.ChainConfig().IsYoloV2(st.evm.Context.BlockNumber) contractCreation := msg.To() == nil // Check clauses 4-5, subtract intrinsic gas if everything is correct - gas, err := IntrinsicGas(st.data, st.msg.AccessList(), contractCreation, homestead, istanbul, yoloV2) + gas, err := IntrinsicGas(st.data, st.msg.AccessList(), contractCreation, homestead, istanbul) if err != nil { return nil, err } diff --git a/core/tx_pool.go b/core/tx_pool.go index 5242b410bc62..4279f84aeffb 100644 --- a/core/tx_pool.go +++ b/core/tx_pool.go @@ -562,7 +562,7 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error { return ErrInsufficientFunds } // Ensure the transaction has more gas than the basic tx fee. - intrGas, err := IntrinsicGas(tx.Data(), tx.AccessList(), tx.To() == nil, true, pool.istanbul, pool.yoloV2) + intrGas, err := IntrinsicGas(tx.Data(), tx.AccessList(), tx.To() == nil, true, pool.istanbul) if err != nil { return err } diff --git a/light/txpool.go b/light/txpool.go index 7525b13ce8f8..a6acce4f6a49 100644 --- a/light/txpool.go +++ b/light/txpool.go @@ -383,7 +383,7 @@ func (pool *TxPool) validateTx(ctx context.Context, tx *types.Transaction) error } // Should supply enough intrinsic gas - gas, err := core.IntrinsicGas(tx.Data(), tx.AccessList(), tx.To() == nil, true, pool.istanbul, pool.yoloV2) + gas, err := core.IntrinsicGas(tx.Data(), tx.AccessList(), tx.To() == nil, true, pool.istanbul) if err != nil { return err } diff --git a/tests/transaction_test_util.go b/tests/transaction_test_util.go index fd4adfb97678..82ee01de15c8 100644 --- a/tests/transaction_test_util.go +++ b/tests/transaction_test_util.go @@ -45,7 +45,7 @@ type ttFork struct { } func (tt *TransactionTest) Run(config *params.ChainConfig) error { - validateTx := func(rlpData hexutil.Bytes, signer types.Signer, isHomestead bool, isIstanbul bool, isYoloV2 bool) (*common.Address, *common.Hash, error) { + validateTx := func(rlpData hexutil.Bytes, signer types.Signer, isHomestead bool, isIstanbul bool) (*common.Address, *common.Hash, error) { tx := new(types.Transaction) if err := rlp.DecodeBytes(rlpData, tx); err != nil { return nil, nil, err @@ -55,7 +55,7 @@ func (tt *TransactionTest) Run(config *params.ChainConfig) error { return nil, nil, err } // Intrinsic gas - requiredGas, err := core.IntrinsicGas(tx.Data(), tx.AccessList(), tx.To() == nil, isHomestead, isIstanbul, isYoloV2) + requiredGas, err := core.IntrinsicGas(tx.Data(), tx.AccessList(), tx.To() == nil, isHomestead, isIstanbul) if err != nil { return nil, nil, err } @@ -72,17 +72,16 @@ func (tt *TransactionTest) Run(config *params.ChainConfig) error { fork ttFork isHomestead bool isIstanbul bool - isYoloV2 bool }{ - {"Frontier", types.FrontierSigner{}, tt.Frontier, false, false, false}, - {"Homestead", types.HomesteadSigner{}, tt.Homestead, true, false, false}, - {"EIP150", types.HomesteadSigner{}, tt.EIP150, true, false, false}, - {"EIP158", types.NewEIP155Signer(config.ChainID), tt.EIP158, true, false, false}, - {"Byzantium", types.NewEIP155Signer(config.ChainID), tt.Byzantium, true, false, false}, - {"Constantinople", types.NewEIP155Signer(config.ChainID), tt.Constantinople, true, false, false}, - {"Istanbul", types.NewEIP155Signer(config.ChainID), tt.Istanbul, true, true, false}, + {"Frontier", types.FrontierSigner{}, tt.Frontier, false, false}, + {"Homestead", types.HomesteadSigner{}, tt.Homestead, true, false}, + {"EIP150", types.HomesteadSigner{}, tt.EIP150, true, false}, + {"EIP158", types.NewEIP155Signer(config.ChainID), tt.EIP158, true, false}, + {"Byzantium", types.NewEIP155Signer(config.ChainID), tt.Byzantium, true, false}, + {"Constantinople", types.NewEIP155Signer(config.ChainID), tt.Constantinople, true, false}, + {"Istanbul", types.NewEIP155Signer(config.ChainID), tt.Istanbul, true, true}, } { - sender, txhash, err := validateTx(tt.RLP, testcase.signer, testcase.isHomestead, testcase.isIstanbul, testcase.isYoloV2) + sender, txhash, err := validateTx(tt.RLP, testcase.signer, testcase.isHomestead, testcase.isIstanbul) if testcase.fork.Sender == (common.UnprefixedAddress{}) { if err == nil {