diff --git a/accounts/abi/bind/backends/blockchain.go b/accounts/abi/bind/backends/blockchain.go index d8890ba5e..6786dd838 100644 --- a/accounts/abi/bind/backends/blockchain.go +++ b/accounts/abi/bind/backends/blockchain.go @@ -156,13 +156,13 @@ func (b *BlockchainContractBackend) callContract(call kaia.CallMsg, block *types if call.AccessList != nil { accessList = *call.AccessList } - intrinsicGas, err := types.IntrinsicGas(call.Data, accessList, nil, call.To == nil, b.bc.Config().Rules(block.Number())) + intrinsicGas, tokens, err := types.IntrinsicGas(call.Data, accessList, nil, call.To == nil, b.bc.Config().Rules(block.Number())) if err != nil { return nil, err } msg := types.NewMessage(call.From, call.To, 0, call.Value, call.Gas, gasPrice, nil, nil, call.Data, - false, intrinsicGas, accessList, nil) + false, intrinsicGas, tokens, accessList, nil) txContext := blockchain.NewEVMTxContext(msg, block.Header(), b.bc.Config()) blockContext := blockchain.NewEVMBlockContext(block.Header(), b.bc, nil) diff --git a/accounts/abi/bind/backends/simulated.go b/accounts/abi/bind/backends/simulated.go index 58ab5b7e1..7181ed9a1 100644 --- a/accounts/abi/bind/backends/simulated.go +++ b/accounts/abi/bind/backends/simulated.go @@ -500,8 +500,8 @@ func (b *SimulatedBackend) callContract(_ context.Context, call kaia.CallMsg, bl if call.AccessList != nil { accessList = *call.AccessList } - intrinsicGas, _ := types.IntrinsicGas(call.Data, accessList, nil, call.To == nil, b.config.Rules(block.Number())) - msg := types.NewMessage(call.From, call.To, nonce, call.Value, call.Gas, gasPrice, nil, nil, call.Data, true, intrinsicGas, accessList, nil) + intrinsicGas, dataTokens, _ := types.IntrinsicGas(call.Data, accessList, nil, call.To == nil, b.config.Rules(block.Number())) + msg := types.NewMessage(call.From, call.To, nonce, call.Value, call.Gas, gasPrice, nil, nil, call.Data, true, intrinsicGas, dataTokens, accessList, nil) txContext := blockchain.NewEVMTxContext(msg, block.Header(), b.config) blockContext := blockchain.NewEVMBlockContext(block.Header(), b.blockchain, nil) diff --git a/api/api_ethereum.go b/api/api_ethereum.go index e6c87a3e5..5b893bfb9 100644 --- a/api/api_ethereum.go +++ b/api/api_ethereum.go @@ -1413,11 +1413,11 @@ func EthDoCall(ctx context.Context, b Backend, args EthTransactionArgs, blockNrO } else { baseFee = new(big.Int).SetUint64(params.ZeroBaseFee) } - intrinsicGas, err := types.IntrinsicGas(args.data(), args.GetAccessList(), nil, args.To == nil, b.ChainConfig().Rules(header.Number)) + intrinsicGas, dataTokens, err := types.IntrinsicGas(args.data(), args.GetAccessList(), nil, args.To == nil, b.ChainConfig().Rules(header.Number)) if err != nil { return nil, err } - msg, err := args.ToMessage(globalGasCap, baseFee, intrinsicGas) + msg, err := args.ToMessage(globalGasCap, baseFee, intrinsicGas, dataTokens) if err != nil { return nil, err } @@ -1570,11 +1570,11 @@ func AccessList(ctx context.Context, b Backend, blockNrOrHash rpc.BlockNumberOrH precompiles := vm.ActivePrecompiles(rules) toMsg := func() (*types.Transaction, error) { - intrinsicGas, err := types.IntrinsicGas(args.data(), nil, nil, args.To == nil, rules) + intrinsicGas, dataTokens, err := types.IntrinsicGas(args.data(), nil, nil, args.To == nil, rules) if err != nil { return nil, err } - return args.ToMessage(gasCap, header.BaseFee, intrinsicGas) + return args.ToMessage(gasCap, header.BaseFee, intrinsicGas, dataTokens) } if args.Gas == nil { diff --git a/api/api_public_blockchain.go b/api/api_public_blockchain.go index 463c75cf0..b01730126 100644 --- a/api/api_public_blockchain.go +++ b/api/api_public_blockchain.go @@ -327,7 +327,7 @@ func DoCall(ctx context.Context, b Backend, args CallArgs, blockNrOrHash rpc.Blo // this makes sure resources are cleaned up. defer cancel() - intrinsicGas, err := types.IntrinsicGas(args.InputData(), args.GetAccessList(), nil, args.To == nil, b.ChainConfig().Rules(header.Number)) + intrinsicGas, dataTokens, err := types.IntrinsicGas(args.InputData(), args.GetAccessList(), nil, args.To == nil, b.ChainConfig().Rules(header.Number)) if err != nil { return nil, 0, err } @@ -339,7 +339,7 @@ func DoCall(ctx context.Context, b Backend, args CallArgs, blockNrOrHash rpc.Blo } else { baseFee = new(big.Int).SetUint64(params.ZeroBaseFee) } - msg, err := args.ToMessage(globalGasCap.Uint64(), baseFee, intrinsicGas) + msg, err := args.ToMessage(globalGasCap.Uint64(), baseFee, intrinsicGas, dataTokens) if err != nil { return nil, 0, err } @@ -689,7 +689,7 @@ func newRPCTransactionFromBlockHash(b *types.Block, hash common.Hash, config *pa return nil } -func (args *CallArgs) ToMessage(globalGasCap uint64, baseFee *big.Int, intrinsicGas uint64) (*types.Transaction, error) { +func (args *CallArgs) ToMessage(globalGasCap uint64, baseFee *big.Int, intrinsicGas uint64, dataTokens uint64) (*types.Transaction, error) { if args.GasPrice != nil && (args.MaxFeePerGas != nil || args.MaxPriorityFeePerGas != nil) { return nil, errors.New("both gasPrice and (maxFeePerGas or maxPriorityFeePerGas) specified") } else if args.MaxFeePerGas != nil && args.MaxPriorityFeePerGas != nil { @@ -737,5 +737,5 @@ func (args *CallArgs) ToMessage(globalGasCap uint64, baseFee *big.Int, intrinsic if args.AccessList != nil { accessList = *args.AccessList } - return types.NewMessage(addr, args.To, 0, value, gas, gasPrice, nil, nil, args.InputData(), false, intrinsicGas, accessList, nil), nil + return types.NewMessage(addr, args.To, 0, value, gas, gasPrice, nil, nil, args.InputData(), false, intrinsicGas, dataTokens, accessList, nil), nil } diff --git a/api/tx_args.go b/api/tx_args.go index 915b23590..0af5dafbe 100644 --- a/api/tx_args.go +++ b/api/tx_args.go @@ -729,7 +729,7 @@ func (args *EthTransactionArgs) setDefaults(ctx context.Context, b Backend) erro } // ToMessage change EthTransactionArgs to types.Transaction in Kaia. -func (args *EthTransactionArgs) ToMessage(globalGasCap uint64, baseFee *big.Int, intrinsicGas uint64) (*types.Transaction, error) { +func (args *EthTransactionArgs) ToMessage(globalGasCap uint64, baseFee *big.Int, intrinsicGas uint64, dataTokens uint64) (*types.Transaction, error) { // Reject invalid combinations of pre- and post-1559 fee styles if args.GasPrice != nil && (args.MaxFeePerGas != nil || args.MaxPriorityFeePerGas != nil) { return nil, errors.New("both gasPrice and (maxFeePerGas or maxPriorityFeePerGas) specified") @@ -780,7 +780,7 @@ func (args *EthTransactionArgs) ToMessage(globalGasCap uint64, baseFee *big.Int, if args.AccessList != nil { accessList = *args.AccessList } - return types.NewMessage(addr, args.To, 0, value, gas, gasPrice, nil, nil, data, false, intrinsicGas, accessList, nil), nil + return types.NewMessage(addr, args.To, 0, value, gas, gasPrice, nil, nil, data, false, intrinsicGas, dataTokens, accessList, nil), nil } // toTransaction converts the arguments to a transaction. diff --git a/blockchain/bench_test.go b/blockchain/bench_test.go index a61b76f85..e26ed0bae 100644 --- a/blockchain/bench_test.go +++ b/blockchain/bench_test.go @@ -111,7 +111,7 @@ func genValueTx(nbytes int) func(int, *BlockGen) { return func(i int, gen *BlockGen) { toaddr := common.Address{} data := make([]byte, nbytes) - gas, _ := types.IntrinsicGas(data, nil, nil, false, params.TestChainConfig.Rules(big.NewInt(0))) + gas, _, _ := types.IntrinsicGas(data, nil, nil, false, params.TestChainConfig.Rules(big.NewInt(0))) signer := types.LatestSignerForChainID(params.TestChainConfig.ChainID) tx, _ := types.SignTx(types.NewTransaction(gen.TxNonce(benchRootAddr), toaddr, big.NewInt(1), gas, nil, data), signer, benchRootKey) gen.AddTx(tx) diff --git a/blockchain/blockchain_test.go b/blockchain/blockchain_test.go index 0d73bef51..1cd0f4064 100644 --- a/blockchain/blockchain_test.go +++ b/blockchain/blockchain_test.go @@ -1461,8 +1461,8 @@ func TestAccessListTx(t *testing.T) { b.SetRewardbase(common.Address{1}) // One transaction to 0xAAAA - intrinsicGas, _ := types.IntrinsicGas([]byte{}, list, nil, false, gspec.Config.Rules(block.Number())) - tx, _ := types.SignTx(types.NewMessage(senderAddr, &contractAddr, senderNonce, big.NewInt(0), 30000, big.NewInt(1), nil, nil, []byte{}, false, intrinsicGas, list, nil), signer, senderKey) + intrinsicGas, dataTokens, _ := types.IntrinsicGas([]byte{}, list, nil, false, gspec.Config.Rules(block.Number())) + tx, _ := types.SignTx(types.NewMessage(senderAddr, &contractAddr, senderNonce, big.NewInt(0), 30000, big.NewInt(1), nil, nil, []byte{}, false, intrinsicGas, dataTokens, list, nil), signer, senderKey) b.AddTx(tx) }) if n, err := chain.InsertChain(blocks); err != nil { @@ -2345,13 +2345,13 @@ func TestEIP7702(t *testing.T) { b.SetRewardbase(common.Address{1}) authorizationList := []types.Authorization{*auth1, *auth2} - intrinsicGas, err := types.IntrinsicGas(nil, nil, authorizationList, false, params.TestRules) + intrinsicGas, dataTokens, err := types.IntrinsicGas(nil, nil, authorizationList, false, params.TestRules) if err != nil { t.Fatalf("failed to run intrinsic gas: %v", err) } tx, err := types.SignTx(types.NewMessage(addr1, &addr1, uint64(0), nil, 500000, nil, newGkei(50), - big.NewInt(20), nil, false, intrinsicGas, nil, authorizationList), signer, key1) + big.NewInt(20), nil, false, intrinsicGas, dataTokens, nil, authorizationList), signer, key1) if err != nil { t.Fatalf("failed to sign tx: %v", err) } @@ -2426,13 +2426,13 @@ func TestEIP7702(t *testing.T) { }, key1) authorizationList := []types.Authorization{*authForEmpty} - intrinsicGas, err := types.IntrinsicGas(nil, nil, authorizationList, false, params.TestRules) + intrinsicGas, dataTokens, err := types.IntrinsicGas(nil, nil, authorizationList, false, params.TestRules) if err != nil { t.Fatalf("failed to run intrinsic gas: %v", err) } tx, err := types.SignTx(types.NewMessage(addr1, &addr1, state.GetNonce(addr1), nil, 500000, nil, newGkei(50), - big.NewInt(20), nil, false, intrinsicGas, nil, authorizationList), signer, key1) + big.NewInt(20), nil, false, intrinsicGas, dataTokens, nil, authorizationList), signer, key1) if err != nil { t.Fatalf("failed to sign tx: %v", err) } diff --git a/blockchain/error.go b/blockchain/error.go index 3a9dc2288..75a1a2d94 100644 --- a/blockchain/error.go +++ b/blockchain/error.go @@ -86,6 +86,10 @@ var ( // than required to start the invocation. ErrIntrinsicGas = errors.New("intrinsic gas too low") + // ErrDataFloorGas is returned if the transaction is specified to use less gas + // than required for the data floor cost. + ErrDataFloorGas = errors.New("insufficient gas for data floor cost") + // ErrGasLimit is returned if a transaction's requested gas limit exceeds the // maximum allowance of the current block. ErrGasLimit = errors.New("exceeds block gas limit") diff --git a/blockchain/state_processor.go b/blockchain/state_processor.go index f9ad52581..5ed7259d9 100644 --- a/blockchain/state_processor.go +++ b/blockchain/state_processor.go @@ -112,7 +112,7 @@ func ProcessParentBlockHash(header *types.Header, vmenv *vm.EVM, statedb vm.Stat gasLimit = uint64(30_000_000) ) - intrinsicGas, err := types.IntrinsicGas(data, nil, nil, false, rules) + intrinsicGas, dataTokens, err := types.IntrinsicGas(data, nil, nil, false, rules) if err != nil { return err } @@ -129,6 +129,7 @@ func ProcessParentBlockHash(header *types.Header, vmenv *vm.EVM, statedb vm.Stat data, false, intrinsicGas, + dataTokens, nil, nil, ) diff --git a/blockchain/state_transition.go b/blockchain/state_transition.go index b3eb82e38..d7f5242ee 100644 --- a/blockchain/state_transition.go +++ b/blockchain/state_transition.go @@ -25,6 +25,7 @@ package blockchain import ( "errors" "fmt" + "math" "math/big" "github.com/kaiachain/kaia/blockchain/types" @@ -83,7 +84,7 @@ type Message interface { // ValidatedIntrinsicGas returns the intrinsic gas of the transaction. // The returned intrinsic gas should be derived by calling AsMessageAccountKeyPicker(). - ValidatedIntrinsicGas() uint64 + ValidatedIntrinsicGas() *types.ValidatedIntrinsicGas // FeeRatio returns a ratio of tx fee paid by the fee payer in percentage. // For example, if it is 30, 30% of tx fee will be paid by the fee payer. @@ -111,7 +112,7 @@ type Message interface { // IntrinsicGas returns `intrinsic gas` based on the tx type. // This value is used to differentiate tx fee based on the tx type. - IntrinsicGas(currentBlockNumber uint64) (uint64, error) + IntrinsicGas(currentBlockNumber uint64) (uint64, uint64, error) // Type returns the transaction type of the message. Type() types.TxType @@ -345,11 +346,20 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) { } // Check clauses 4-5, subtract intrinsic gas if everything is correct - amount := msg.ValidatedIntrinsicGas() - if st.gas < amount { + validatedGas := msg.ValidatedIntrinsicGas() + if st.gas < validatedGas.Gas { return nil, ErrIntrinsicGas } - st.gas -= amount + if st.evm.ChainConfig().Rules(st.evm.Context.BlockNumber).IsPrague { + floorGas, err := FloorDataGas(validatedGas.Tokens) + if err != nil { + return nil, err + } + if st.gas < floorGas { + return nil, fmt.Errorf("%w: have %d, want %d", ErrDataFloorGas, st.gas, floorGas) + } + } + st.gas -= validatedGas.Gas // Check clause 6 if msg.Value().Sign() > 0 && !st.evm.Context.CanTransfer(st.state, msg.ValidatedSender(), msg.Value()) { @@ -408,6 +418,15 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) { return nil, vm.ErrTotalTimeLimitReached } + if st.evm.ChainConfig().Rules(st.evm.Context.BlockNumber).IsPrague { + // After EIP-7623: Data-heavy transactions pay the floor gas. + // Overflow error has already been checked and can be ignored here. + floorGas, _ := FloorDataGas(validatedGas.Tokens) + if st.gasUsed() < floorGas { + st.gas = st.initialGas - floorGas + } + } + if rules.IsKore { // After EIP-3529: refunds are capped to gasUsed / 5 st.refundGas(params.RefundQuotientEIP3529) @@ -582,3 +601,13 @@ func (st *StateTransition) processAuthorizationList(authList types.Authorization } } } + +// FloorDataGas calculates the minimum gas required for a transaction +// based on its data tokens (EIP-7623). +func FloorDataGas(tokens uint64) (uint64, error) { + // Check for overflow + if (math.MaxUint64-params.TxGas)/params.CostFloorPerToken7623 < tokens { + return 0, types.ErrGasUintOverflow + } + return params.TxGas + tokens*params.CostFloorPerToken7623, nil +} diff --git a/blockchain/system/multicall.go b/blockchain/system/multicall.go index 05c4a3ed2..bceeee162 100644 --- a/blockchain/system/multicall.go +++ b/blockchain/system/multicall.go @@ -49,6 +49,7 @@ func (caller *ContractCallerForMultiCall) CallContract(ctx context.Context, call gasPrice := big.NewInt(0) // execute call regardless of the balance of the sender gasLimit := uint64(1e8) // enough gas limit to execute multicall contract functions intrinsicGas := uint64(0) // read operation doesn't require intrinsicGas + dataTokens := uint64(0) // read operation has no calldata // call.From: zero address will be assigned if nothing is specified // call.To: the target contract address will be assigned by `BoundContract` @@ -63,7 +64,7 @@ func (caller *ContractCallerForMultiCall) CallContract(ctx context.Context, call } msg := types.NewMessage(call.From, call.To, caller.state.GetNonce(call.From), - call.Value, gasLimit, gasPrice, nil, nil, call.Data, false, intrinsicGas, nil, nil) + call.Value, gasLimit, gasPrice, nil, nil, call.Data, false, intrinsicGas, dataTokens, nil, nil) blockContext := blockchain.NewEVMBlockContext(caller.header, caller.chain, nil) txContext := blockchain.NewEVMTxContext(msg, caller.header, caller.chain.Config()) diff --git a/blockchain/system/rebalance.go b/blockchain/system/rebalance.go index 0800bec07..f52669d88 100644 --- a/blockchain/system/rebalance.go +++ b/blockchain/system/rebalance.go @@ -108,6 +108,7 @@ func (caller *Kip103ContractCaller) CallContract(ctx context.Context, call kaia. gasPrice := big.NewInt(0) // execute call regardless of the balance of the sender gasLimit := uint64(1e8) // enough gas limit to execute kip103 contract functions intrinsicGas := uint64(0) // read operation doesn't require intrinsicGas + dataTokens := uint64(0) // read operation has no calldata // call.From: zero address will be assigned if nothing is specified // call.To: the target contract address will be assigned by `BoundContract` @@ -122,7 +123,7 @@ func (caller *Kip103ContractCaller) CallContract(ctx context.Context, call kaia. // return nil, err //} msg := types.NewMessage(call.From, call.To, caller.state.GetNonce(call.From), - call.Value, gasLimit, gasPrice, nil, nil, call.Data, false, intrinsicGas, nil, nil) + call.Value, gasLimit, gasPrice, nil, nil, call.Data, false, intrinsicGas, dataTokens, nil, nil) blockContext := blockchain.NewEVMBlockContext(caller.header, caller.chain, nil) txContext := blockchain.NewEVMTxContext(msg, caller.header, caller.chain.Config()) diff --git a/blockchain/tx_pool.go b/blockchain/tx_pool.go index 2778d66ff..7c3d748fc 100644 --- a/blockchain/tx_pool.go +++ b/blockchain/tx_pool.go @@ -836,7 +836,7 @@ func (pool *TxPool) validateTx(tx *types.Transaction) error { } } - intrGas, err := tx.IntrinsicGas(pool.currentBlockNumber) + intrGas, dataTokens, err := tx.IntrinsicGas(pool.currentBlockNumber) intrGas += gasFrom + gasFeePayer if err != nil { return err @@ -844,6 +844,16 @@ func (pool *TxPool) validateTx(tx *types.Transaction) error { if tx.Gas() < intrGas { return ErrIntrinsicGas } + // Ensure the transaction can cover floor data gas. + if pool.rules.IsPrague { + floorGas, err := FloorDataGas(dataTokens) + if err != nil { + return err + } + if tx.Gas() < floorGas { + return fmt.Errorf("%w: gas %v, minimum needed %v", ErrDataFloorGas, tx.Gas(), floorGas) + } + } // "tx.Validate()" conducts additional validation for each new txType. // Validate humanReadable address when this tx has "true" in the humanReadable field. diff --git a/blockchain/types/transaction.go b/blockchain/types/transaction.go index c00e7b30e..9eb1b4bdd 100644 --- a/blockchain/types/transaction.go +++ b/blockchain/types/transaction.go @@ -72,6 +72,11 @@ func ErrFeePayer(err error) error { return fmt.Errorf("invalid fee payer: %s", err) } +type ValidatedIntrinsicGas struct { + Gas uint64 + Tokens uint64 +} + type Transaction struct { data TxInternalData time time.Time @@ -90,7 +95,7 @@ type Transaction struct { validatedFeePayer common.Address // validatedIntrinsicGas represents intrinsic gas of the transaction to be used for ApplyTransaction(). // This value is set in AsMessageWithAccountKeyPicker(). - validatedIntrinsicGas uint64 + validatedIntrinsicGas *ValidatedIntrinsicGas // The account's nonce is checked only if `checkNonce` is true. checkNonce bool // This value is set when the tx is invalidated in block tx validation, and is used to remove pending tx in txPool. @@ -385,7 +390,7 @@ func (tx *Transaction) ValidatedFeePayer() common.Address { return tx.validatedFeePayer } -func (tx *Transaction) ValidatedIntrinsicGas() uint64 { +func (tx *Transaction) ValidatedIntrinsicGas() *ValidatedIntrinsicGas { tx.mu.RLock() defer tx.mu.RUnlock() return tx.validatedIntrinsicGas @@ -393,7 +398,7 @@ func (tx *Transaction) ValidatedIntrinsicGas() uint64 { func (tx *Transaction) MakeRPCOutput() map[string]interface{} { return tx.data.MakeRPCOutput() } func (tx *Transaction) GetTxInternalData() TxInternalData { return tx.data } -func (tx *Transaction) IntrinsicGas(currentBlockNumber uint64) (uint64, error) { +func (tx *Transaction) IntrinsicGas(currentBlockNumber uint64) (uint64, uint64, error) { return tx.data.IntrinsicGas(currentBlockNumber) } @@ -584,7 +589,7 @@ func (tx *Transaction) Execute(vm VM, stateDB StateDB, currentBlockNumber uint64 // XXX Rename message to something less arbitrary? // TODO-Kaia: Message is removed and this function will return *Transaction. func (tx *Transaction) AsMessageWithAccountKeyPicker(s Signer, picker AccountKeyPicker, currentBlockNumber uint64) (*Transaction, error) { - intrinsicGas, err := tx.IntrinsicGas(currentBlockNumber) + intrinsicGas, dataTokens, err := tx.IntrinsicGas(currentBlockNumber) if err != nil { return nil, err } @@ -607,7 +612,7 @@ func (tx *Transaction) AsMessageWithAccountKeyPicker(s Signer, picker AccountKey } tx.mu.Lock() - tx.validatedIntrinsicGas = intrinsicGas + gasFrom + gasFeePayer + tx.validatedIntrinsicGas = &ValidatedIntrinsicGas{Gas: intrinsicGas + gasFrom + gasFeePayer, Tokens: dataTokens} tx.mu.Unlock() return tx, err @@ -1079,9 +1084,9 @@ func (t *TransactionsByPriceAndNonce) Clear() { } // NewMessage returns a `*Transaction` object with the given arguments. -func NewMessage(from common.Address, to *common.Address, nonce uint64, amount *big.Int, gasLimit uint64, gasPrice, gasFeeCap, gasTipCap *big.Int, data []byte, checkNonce bool, intrinsicGas uint64, list AccessList, auth AuthorizationList) *Transaction { +func NewMessage(from common.Address, to *common.Address, nonce uint64, amount *big.Int, gasLimit uint64, gasPrice, gasFeeCap, gasTipCap *big.Int, data []byte, checkNonce bool, intrinsicGas uint64, dataTokens uint64, list AccessList, auth AuthorizationList) *Transaction { transaction := &Transaction{ - validatedIntrinsicGas: intrinsicGas, + validatedIntrinsicGas: &ValidatedIntrinsicGas{Gas: intrinsicGas, Tokens: dataTokens}, validatedFeePayer: from, validatedSender: from, checkNonce: checkNonce, diff --git a/blockchain/types/transaction_test.go b/blockchain/types/transaction_test.go index b2403f6e3..fcb350c9b 100644 --- a/blockchain/types/transaction_test.go +++ b/blockchain/types/transaction_test.go @@ -627,27 +627,28 @@ func TestIntrinsicGas(t *testing.T) { data, err = hex.DecodeString(tc.inputString) // decode input string to hex data assert.Equal(t, nil, err) - gas, err = IntrinsicGas(data, nil, nil, false, params.Rules{IsIstanbul: false}) + // TODO-Kaia: Add test for EIP-7623 + gas, _, err = IntrinsicGas(data, nil, nil, false, params.Rules{IsIstanbul: false}) assert.Equal(t, tc.expectGas1, gas) assert.Equal(t, nil, err) - gas, err = IntrinsicGas(data, nil, nil, false, params.Rules{IsIstanbul: true}) + gas, _, err = IntrinsicGas(data, nil, nil, false, params.Rules{IsIstanbul: true}) assert.Equal(t, tc.expectGas2, gas) assert.Equal(t, nil, err) - gas, err = IntrinsicGas(data, nil, nil, false, params.Rules{IsIstanbul: true, IsShanghai: true, IsPrague: true}) + gas, _, err = IntrinsicGas(data, nil, nil, false, params.Rules{IsIstanbul: true, IsShanghai: true, IsPrague: true}) assert.Equal(t, tc.expectGas3, gas) assert.Equal(t, nil, err) - gas, err = IntrinsicGas(data, nil, nil, true, params.Rules{IsIstanbul: false}) + gas, _, err = IntrinsicGas(data, nil, nil, true, params.Rules{IsIstanbul: false}) assert.Equal(t, tc.expectGas4, gas) assert.Equal(t, nil, err) - gas, err = IntrinsicGas(data, nil, nil, true, params.Rules{IsIstanbul: true}) + gas, _, err = IntrinsicGas(data, nil, nil, true, params.Rules{IsIstanbul: true}) assert.Equal(t, tc.expectGas5, gas) assert.Equal(t, nil, err) - gas, err = IntrinsicGas(data, nil, nil, true, params.Rules{IsIstanbul: true, IsShanghai: true, IsPrague: true}) + gas, _, err = IntrinsicGas(data, nil, nil, true, params.Rules{IsIstanbul: true, IsShanghai: true, IsPrague: true}) assert.Equal(t, tc.expectGas6, gas) assert.Equal(t, nil, err) } diff --git a/blockchain/types/tx_internal_data.go b/blockchain/types/tx_internal_data.go index d81b5d5da..ff4963f8b 100644 --- a/blockchain/types/tx_internal_data.go +++ b/blockchain/types/tx_internal_data.go @@ -326,7 +326,7 @@ type TxInternalData interface { Equal(t TxInternalData) bool // IntrinsicGas computes additional 'intrinsic gas' based on tx types. - IntrinsicGas(currentBlockNumber uint64) (uint64, error) + IntrinsicGas(currentBlockNumber uint64) (uint64, uint64, error) // SerializeForSign returns a slice containing attributes to make its tx signature. SerializeForSign() []interface{} @@ -572,7 +572,8 @@ func toWordSize(size uint64) uint64 { } // Klaytn-TxTypes since genesis, and EthTxTypes since istanbul use this. -func IntrinsicGasPayload(gas uint64, data []byte, isContractCreation bool, rules params.Rules) (uint64, error) { +func IntrinsicGasPayload(gas uint64, data []byte, isContractCreation bool, rules params.Rules) (uint64, uint64, error) { + var tokens uint64 // Bump the required gas by the amount of transactional data length := uint64(len(data)) if length > 0 { @@ -583,6 +584,10 @@ func IntrinsicGasPayload(gas uint64, data []byte, isContractCreation bool, rules nz++ } } + + z := length - nz + tokens = nz*params.TokenPerNonZeroByte7623 + z + // Since the genesis block, a flat 100 gas is paid // regardless of whether the value is zero or non-zero. nonZeroGas, zeroGas := params.TxDataGas, params.TxDataGas @@ -592,13 +597,12 @@ func IntrinsicGasPayload(gas uint64, data []byte, isContractCreation bool, rules } // Make sure we don't exceed uint64 for all data combinations if (math.MaxUint64-gas)/nonZeroGas < nz { - return 0, ErrGasUintOverflow + return 0, tokens, ErrGasUintOverflow } gas += nz * nonZeroGas - z := uint64(len(data)) - nz if (math.MaxUint64-gas)/zeroGas < z { - return 0, ErrGasUintOverflow + return 0, tokens, ErrGasUintOverflow } gas += z * zeroGas } @@ -606,17 +610,18 @@ func IntrinsicGasPayload(gas uint64, data []byte, isContractCreation bool, rules if isContractCreation && rules.IsShanghai { lenWords := toWordSize(length) if (math.MaxUint64-gas)/params.InitCodeWordGas < lenWords { - return 0, ErrGasUintOverflow + return 0, tokens, ErrGasUintOverflow } gas += lenWords * params.InitCodeWordGas } - return gas, nil + return gas, tokens, nil } // Eth-TxTypes before istanbul use this. Only 0 tx type exists before Istanbul (No dynamic and access list types correspond to) // Calculate gas cost for type 0 transactions: // 68 gas for each non-zero byte and 16 gas for each zero byte in the data field. -func IntrinsicGasPayloadLegacy(gas uint64, data []byte) (uint64, error) { +func IntrinsicGasPayloadLegacy(gas uint64, data []byte) (uint64, uint64, error) { + var tokens uint64 length := uint64(len(data)) if length > 0 { // Zero and non-zero bytes are priced differently @@ -626,26 +631,33 @@ func IntrinsicGasPayloadLegacy(gas uint64, data []byte) (uint64, error) { nz++ } } + z := length - nz + tokens = nz*params.TokenPerNonZeroByte7623 + z + // Make sure we don't exceed uint64 for all data combinations if (math.MaxUint64-gas)/params.TxDataNonZeroGasFrontier < nz { - return 0, ErrGasUintOverflow + return 0, tokens, ErrGasUintOverflow } gas += nz * params.TxDataNonZeroGasFrontier - z := uint64(len(data)) - nz if (math.MaxUint64-gas)/params.TxDataZeroGas < z { - return 0, ErrGasUintOverflow + return 0, tokens, ErrGasUintOverflow } gas += z * params.TxDataZeroGas } - return gas, nil + return gas, tokens, nil } -// IntrinsicGas computes the 'intrinsic gas' for a message with the given data. -func IntrinsicGas(data []byte, accessList AccessList, authorizationList AuthorizationList, contractCreation bool, r params.Rules) (uint64, error) { +// IntrinsicGas computes the 'intrinsic gas' and the number of tokens for EIP-7623 +// for a message with the given data. +func IntrinsicGas(data []byte, accessList AccessList, authorizationList AuthorizationList, contractCreation bool, r params.Rules) (uint64, uint64, error) { // Set the starting gas for the raw transaction - var gas uint64 + var ( + gas uint64 + tokens uint64 + ) + if contractCreation { gas = params.TxGasContractCreation } else { @@ -657,14 +669,14 @@ func IntrinsicGas(data []byte, accessList AccessList, authorizationList Authoriz if r.IsIstanbul { // tx types 1,2 only exist after istanbul; so they take this path. // tx types 8+ take this path as well. - gasPayloadWithGas, err = IntrinsicGasPayload(gas, data, contractCreation, r) + gasPayloadWithGas, tokens, err = IntrinsicGasPayload(gas, data, contractCreation, r) } else { // only for tx type 0 before istanbul. - gasPayloadWithGas, err = IntrinsicGasPayloadLegacy(gas, data) + gasPayloadWithGas, tokens, err = IntrinsicGasPayloadLegacy(gas, data) } if err != nil { - return 0, err + return 0, tokens, err } // We charge additional gas for the accessList: @@ -682,7 +694,7 @@ func IntrinsicGas(data []byte, accessList AccessList, authorizationList Authoriz gasPayloadWithGas += uint64(len(authorizationList)) * params.CallNewAccountGas } - return gasPayloadWithGas, nil + return gasPayloadWithGas, tokens, nil } // CalcFeeWithRatio returns feePayer's fee and sender's fee based on feeRatio. diff --git a/blockchain/types/tx_internal_data_account_creation.go b/blockchain/types/tx_internal_data_account_creation.go index 919bbd56a..c7ca9efb0 100644 --- a/blockchain/types/tx_internal_data_account_creation.go +++ b/blockchain/types/tx_internal_data_account_creation.go @@ -364,10 +364,10 @@ func (t *TxInternalDataAccountCreation) SetSignature(s TxSignatures) { t.TxSignatures = s } -func (t *TxInternalDataAccountCreation) IntrinsicGas(currentBlockNumber uint64) (uint64, error) { +func (t *TxInternalDataAccountCreation) IntrinsicGas(currentBlockNumber uint64) (uint64, uint64, error) { gasKey, err := t.Key.AccountCreationGas(currentBlockNumber) if err != nil { - return 0, err + return 0, 0, err } gas := params.TxGasAccountCreation + gasKey @@ -375,7 +375,7 @@ func (t *TxInternalDataAccountCreation) IntrinsicGas(currentBlockNumber uint64) gas += params.TxGasHumanReadable } - return gas, nil + return gas, 0, nil } func (t *TxInternalDataAccountCreation) SerializeForSignToBytes() []byte { diff --git a/blockchain/types/tx_internal_data_account_update.go b/blockchain/types/tx_internal_data_account_update.go index 86821828a..f1ab0be7e 100644 --- a/blockchain/types/tx_internal_data_account_update.go +++ b/blockchain/types/tx_internal_data_account_update.go @@ -305,13 +305,13 @@ func (t *TxInternalDataAccountUpdate) SetSignature(s TxSignatures) { t.TxSignatures = s } -func (t *TxInternalDataAccountUpdate) IntrinsicGas(currentBlockNumber uint64) (uint64, error) { +func (t *TxInternalDataAccountUpdate) IntrinsicGas(currentBlockNumber uint64) (uint64, uint64, error) { gasKey, err := t.Key.AccountCreationGas(currentBlockNumber) if err != nil { - return 0, err + return 0, 0, err } - return params.TxGasAccountUpdate + gasKey, nil + return params.TxGasAccountUpdate + gasKey, 0, nil } func (t *TxInternalDataAccountUpdate) SerializeForSignToBytes() []byte { diff --git a/blockchain/types/tx_internal_data_cancel.go b/blockchain/types/tx_internal_data_cancel.go index 9cec98d90..deaed77c5 100644 --- a/blockchain/types/tx_internal_data_cancel.go +++ b/blockchain/types/tx_internal_data_cancel.go @@ -191,8 +191,8 @@ func (t *TxInternalDataCancel) SetSignature(s TxSignatures) { t.TxSignatures = s } -func (t *TxInternalDataCancel) IntrinsicGas(currentBlockNumber uint64) (uint64, error) { - return params.TxGasCancel, nil +func (t *TxInternalDataCancel) IntrinsicGas(currentBlockNumber uint64) (uint64, uint64, error) { + return params.TxGasCancel, 0, nil } func (t *TxInternalDataCancel) SerializeForSignToBytes() []byte { diff --git a/blockchain/types/tx_internal_data_chain_data_anchoring.go b/blockchain/types/tx_internal_data_chain_data_anchoring.go index 9aafd1dea..dd2cd9407 100644 --- a/blockchain/types/tx_internal_data_chain_data_anchoring.go +++ b/blockchain/types/tx_internal_data_chain_data_anchoring.go @@ -260,17 +260,17 @@ func (t *TxInternalDataChainDataAnchoring) SetSignature(s TxSignatures) { t.TxSignatures = s } -func (t *TxInternalDataChainDataAnchoring) IntrinsicGas(currentBlockNumber uint64) (uint64, error) { +func (t *TxInternalDataChainDataAnchoring) IntrinsicGas(currentBlockNumber uint64) (uint64, uint64, error) { gas := params.TxChainDataAnchoringGas // ChainDataAnchoring does not have Recipient, but it is not contract deployment transaction type. // So, isContractCreation is explicitly set as false. - gasPayloadWithGas, err := IntrinsicGasPayload(gas, t.Payload, false, *fork.Rules(big.NewInt(int64(currentBlockNumber)))) + gasPayloadWithGas, tokens, err := IntrinsicGasPayload(gas, t.Payload, false, *fork.Rules(big.NewInt(int64(currentBlockNumber)))) if err != nil { - return 0, err + return 0, tokens, err } - return gasPayloadWithGas, nil + return gasPayloadWithGas, tokens, nil } func (t *TxInternalDataChainDataAnchoring) Validate(stateDB StateDB, currentBlockNumber uint64) error { diff --git a/blockchain/types/tx_internal_data_ethereum_access_list.go b/blockchain/types/tx_internal_data_ethereum_access_list.go index 9539922d8..bdaaa4a58 100644 --- a/blockchain/types/tx_internal_data_ethereum_access_list.go +++ b/blockchain/types/tx_internal_data_ethereum_access_list.go @@ -293,7 +293,7 @@ func (t *TxInternalDataEthereumAccessList) RecoverPubkey(txhash common.Hash, hom return []*ecdsa.PublicKey{pk}, nil } -func (t *TxInternalDataEthereumAccessList) IntrinsicGas(currentBlockNumber uint64) (uint64, error) { +func (t *TxInternalDataEthereumAccessList) IntrinsicGas(currentBlockNumber uint64) (uint64, uint64, error) { return IntrinsicGas(t.Payload, t.AccessList, nil, t.Recipient == nil, *fork.Rules(big.NewInt(int64(currentBlockNumber)))) } diff --git a/blockchain/types/tx_internal_data_ethereum_dynamic_fee.go b/blockchain/types/tx_internal_data_ethereum_dynamic_fee.go index 111234ed8..64230e2b4 100644 --- a/blockchain/types/tx_internal_data_ethereum_dynamic_fee.go +++ b/blockchain/types/tx_internal_data_ethereum_dynamic_fee.go @@ -288,7 +288,7 @@ func (t *TxInternalDataEthereumDynamicFee) RecoverPubkey(txhash common.Hash, hom return []*ecdsa.PublicKey{pk}, nil } -func (t *TxInternalDataEthereumDynamicFee) IntrinsicGas(currentBlockNumber uint64) (uint64, error) { +func (t *TxInternalDataEthereumDynamicFee) IntrinsicGas(currentBlockNumber uint64) (uint64, uint64, error) { return IntrinsicGas(t.Payload, t.AccessList, nil, t.Recipient == nil, *fork.Rules(big.NewInt(int64(currentBlockNumber)))) } diff --git a/blockchain/types/tx_internal_data_ethereum_set_code.go b/blockchain/types/tx_internal_data_ethereum_set_code.go index 118716c58..2e5b9922f 100644 --- a/blockchain/types/tx_internal_data_ethereum_set_code.go +++ b/blockchain/types/tx_internal_data_ethereum_set_code.go @@ -347,7 +347,7 @@ func (t *TxInternalDataEthereumSetCode) Equal(a TxInternalData) bool { t.S.Cmp(ta.S) == 0 } -func (t *TxInternalDataEthereumSetCode) IntrinsicGas(currentBlockNumber uint64) (uint64, error) { +func (t *TxInternalDataEthereumSetCode) IntrinsicGas(currentBlockNumber uint64) (uint64, uint64, error) { return IntrinsicGas(t.Payload, t.AccessList, t.AuthorizationList, false, *fork.Rules(big.NewInt(int64(currentBlockNumber)))) } diff --git a/blockchain/types/tx_internal_data_fee_delegated_account_update.go b/blockchain/types/tx_internal_data_fee_delegated_account_update.go index 29fe97a30..955cd24f0 100644 --- a/blockchain/types/tx_internal_data_fee_delegated_account_update.go +++ b/blockchain/types/tx_internal_data_fee_delegated_account_update.go @@ -351,13 +351,13 @@ func (t *TxInternalDataFeeDelegatedAccountUpdate) RecoverFeePayerPubkey(txhash c return t.FeePayerSignatures.RecoverPubkey(txhash, homestead, vfunc) } -func (t *TxInternalDataFeeDelegatedAccountUpdate) IntrinsicGas(currentBlockNumber uint64) (uint64, error) { +func (t *TxInternalDataFeeDelegatedAccountUpdate) IntrinsicGas(currentBlockNumber uint64) (uint64, uint64, error) { gasKey, err := t.Key.AccountCreationGas(currentBlockNumber) if err != nil { - return 0, err + return 0, 0, err } - return params.TxGasAccountUpdate + gasKey + params.TxGasFeeDelegated, nil + return params.TxGasAccountUpdate + gasKey + params.TxGasFeeDelegated, 0, nil } func (t *TxInternalDataFeeDelegatedAccountUpdate) SerializeForSignToBytes() []byte { diff --git a/blockchain/types/tx_internal_data_fee_delegated_account_update_with_ratio.go b/blockchain/types/tx_internal_data_fee_delegated_account_update_with_ratio.go index ef905a6b8..a3d64a78a 100644 --- a/blockchain/types/tx_internal_data_fee_delegated_account_update_with_ratio.go +++ b/blockchain/types/tx_internal_data_fee_delegated_account_update_with_ratio.go @@ -376,13 +376,13 @@ func (t *TxInternalDataFeeDelegatedAccountUpdateWithRatio) RecoverFeePayerPubkey return t.FeePayerSignatures.RecoverPubkey(txhash, homestead, vfunc) } -func (t *TxInternalDataFeeDelegatedAccountUpdateWithRatio) IntrinsicGas(currentBlockNumber uint64) (uint64, error) { +func (t *TxInternalDataFeeDelegatedAccountUpdateWithRatio) IntrinsicGas(currentBlockNumber uint64) (uint64, uint64, error) { gasKey, err := t.Key.AccountCreationGas(currentBlockNumber) if err != nil { - return 0, err + return 0, 0, err } - return params.TxGasAccountUpdate + gasKey + params.TxGasFeeDelegatedWithRatio, nil + return params.TxGasAccountUpdate + gasKey + params.TxGasFeeDelegatedWithRatio, 0, nil } func (t *TxInternalDataFeeDelegatedAccountUpdateWithRatio) SerializeForSignToBytes() []byte { diff --git a/blockchain/types/tx_internal_data_fee_delegated_cancel.go b/blockchain/types/tx_internal_data_fee_delegated_cancel.go index 9fd717f54..ada9770b9 100644 --- a/blockchain/types/tx_internal_data_fee_delegated_cancel.go +++ b/blockchain/types/tx_internal_data_fee_delegated_cancel.go @@ -226,8 +226,8 @@ func (t *TxInternalDataFeeDelegatedCancel) SetSignature(s TxSignatures) { t.TxSignatures = s } -func (t *TxInternalDataFeeDelegatedCancel) IntrinsicGas(currentBlockNumber uint64) (uint64, error) { - return params.TxGasCancel + params.TxGasFeeDelegated, nil +func (t *TxInternalDataFeeDelegatedCancel) IntrinsicGas(currentBlockNumber uint64) (uint64, uint64, error) { + return params.TxGasCancel + params.TxGasFeeDelegated, 0, nil } func (t *TxInternalDataFeeDelegatedCancel) SerializeForSignToBytes() []byte { diff --git a/blockchain/types/tx_internal_data_fee_delegated_cancel_with_ratio.go b/blockchain/types/tx_internal_data_fee_delegated_cancel_with_ratio.go index 629998401..d22dbc5e8 100644 --- a/blockchain/types/tx_internal_data_fee_delegated_cancel_with_ratio.go +++ b/blockchain/types/tx_internal_data_fee_delegated_cancel_with_ratio.go @@ -246,8 +246,8 @@ func (t *TxInternalDataFeeDelegatedCancelWithRatio) SetSignature(s TxSignatures) t.TxSignatures = s } -func (t *TxInternalDataFeeDelegatedCancelWithRatio) IntrinsicGas(currentBlockNumber uint64) (uint64, error) { - return params.TxGasCancel + params.TxGasFeeDelegatedWithRatio, nil +func (t *TxInternalDataFeeDelegatedCancelWithRatio) IntrinsicGas(currentBlockNumber uint64) (uint64, uint64, error) { + return params.TxGasCancel + params.TxGasFeeDelegatedWithRatio, 0, nil } func (t *TxInternalDataFeeDelegatedCancelWithRatio) SerializeForSignToBytes() []byte { diff --git a/blockchain/types/tx_internal_data_fee_delegated_chain_data_anchoring.go b/blockchain/types/tx_internal_data_fee_delegated_chain_data_anchoring.go index ba168b1d6..caa437c9a 100644 --- a/blockchain/types/tx_internal_data_fee_delegated_chain_data_anchoring.go +++ b/blockchain/types/tx_internal_data_fee_delegated_chain_data_anchoring.go @@ -295,17 +295,17 @@ func (t *TxInternalDataFeeDelegatedChainDataAnchoring) RecoverFeePayerPubkey(txh return t.FeePayerSignatures.RecoverPubkey(txhash, homestead, vfunc) } -func (t *TxInternalDataFeeDelegatedChainDataAnchoring) IntrinsicGas(currentBlockNumber uint64) (uint64, error) { +func (t *TxInternalDataFeeDelegatedChainDataAnchoring) IntrinsicGas(currentBlockNumber uint64) (uint64, uint64, error) { gas := params.TxChainDataAnchoringGas + params.TxGasFeeDelegated // ChainDataAnchoring does not have Recipient, but it is not contract deployment transaction type. // So, isContractCreation is explicitly set as false. - gasPayloadWithGas, err := IntrinsicGasPayload(gas, t.Payload, false, *fork.Rules(big.NewInt(int64(currentBlockNumber)))) + gasPayloadWithGas, tokens, err := IntrinsicGasPayload(gas, t.Payload, false, *fork.Rules(big.NewInt(int64(currentBlockNumber)))) if err != nil { - return 0, err + return 0, tokens, err } - return gasPayloadWithGas, nil + return gasPayloadWithGas, tokens, nil } func (t *TxInternalDataFeeDelegatedChainDataAnchoring) Validate(stateDB StateDB, currentBlockNumber uint64) error { diff --git a/blockchain/types/tx_internal_data_fee_delegated_chain_data_anchoring_with_ratio.go b/blockchain/types/tx_internal_data_fee_delegated_chain_data_anchoring_with_ratio.go index befc615d9..12d65c4fa 100644 --- a/blockchain/types/tx_internal_data_fee_delegated_chain_data_anchoring_with_ratio.go +++ b/blockchain/types/tx_internal_data_fee_delegated_chain_data_anchoring_with_ratio.go @@ -319,17 +319,17 @@ func (t *TxInternalDataFeeDelegatedChainDataAnchoringWithRatio) RecoverFeePayerP return t.FeePayerSignatures.RecoverPubkey(txhash, homestead, vfunc) } -func (t *TxInternalDataFeeDelegatedChainDataAnchoringWithRatio) IntrinsicGas(currentBlockNumber uint64) (uint64, error) { +func (t *TxInternalDataFeeDelegatedChainDataAnchoringWithRatio) IntrinsicGas(currentBlockNumber uint64) (uint64, uint64, error) { gas := params.TxChainDataAnchoringGas + params.TxGasFeeDelegatedWithRatio // ChainDataAnchoring does not have Recipient, but it is not contract deployment transaction type. // So, isContractCreation is explicitly set as false. - gasPayloadWithGas, err := IntrinsicGasPayload(gas, t.Payload, false, *fork.Rules(big.NewInt(int64(currentBlockNumber)))) + gasPayloadWithGas, tokens, err := IntrinsicGasPayload(gas, t.Payload, false, *fork.Rules(big.NewInt(int64(currentBlockNumber)))) if err != nil { - return 0, err + return 0, tokens, err } - return gasPayloadWithGas, nil + return gasPayloadWithGas, tokens, nil } func (t *TxInternalDataFeeDelegatedChainDataAnchoringWithRatio) Validate(stateDB StateDB, currentBlockNumber uint64) error { diff --git a/blockchain/types/tx_internal_data_fee_delegated_smart_contract_deploy.go b/blockchain/types/tx_internal_data_fee_delegated_smart_contract_deploy.go index 0e1c8582e..3e16bbb0d 100644 --- a/blockchain/types/tx_internal_data_fee_delegated_smart_contract_deploy.go +++ b/blockchain/types/tx_internal_data_fee_delegated_smart_contract_deploy.go @@ -303,19 +303,19 @@ func (t *TxInternalDataFeeDelegatedSmartContractDeploy) String() string { enc) } -func (t *TxInternalDataFeeDelegatedSmartContractDeploy) IntrinsicGas(currentBlockNumber uint64) (uint64, error) { +func (t *TxInternalDataFeeDelegatedSmartContractDeploy) IntrinsicGas(currentBlockNumber uint64) (uint64, uint64, error) { gas := params.TxGasContractCreation + params.TxGasFeeDelegated if t.HumanReadable { gas += params.TxGasHumanReadable } - gasPayloadWithGas, err := IntrinsicGasPayload(gas, t.Payload, true, *fork.Rules(big.NewInt(int64(currentBlockNumber)))) + gasPayloadWithGas, tokens, err := IntrinsicGasPayload(gas, t.Payload, true, *fork.Rules(big.NewInt(int64(currentBlockNumber)))) if err != nil { - return 0, err + return 0, tokens, err } - return gasPayloadWithGas, nil + return gasPayloadWithGas, tokens, nil } func (t *TxInternalDataFeeDelegatedSmartContractDeploy) SerializeForSignToBytes() []byte { diff --git a/blockchain/types/tx_internal_data_fee_delegated_smart_contract_deploy_with_ratio.go b/blockchain/types/tx_internal_data_fee_delegated_smart_contract_deploy_with_ratio.go index f37090943..b5104fbe7 100644 --- a/blockchain/types/tx_internal_data_fee_delegated_smart_contract_deploy_with_ratio.go +++ b/blockchain/types/tx_internal_data_fee_delegated_smart_contract_deploy_with_ratio.go @@ -323,19 +323,19 @@ func (t *TxInternalDataFeeDelegatedSmartContractDeployWithRatio) String() string enc) } -func (t *TxInternalDataFeeDelegatedSmartContractDeployWithRatio) IntrinsicGas(currentBlockNumber uint64) (uint64, error) { +func (t *TxInternalDataFeeDelegatedSmartContractDeployWithRatio) IntrinsicGas(currentBlockNumber uint64) (uint64, uint64, error) { gas := params.TxGasContractCreation + params.TxGasFeeDelegatedWithRatio if t.HumanReadable { gas += params.TxGasHumanReadable } - gasPayloadWithGas, err := IntrinsicGasPayload(gas, t.Payload, true, *fork.Rules(big.NewInt(int64(currentBlockNumber)))) + gasPayloadWithGas, tokens, err := IntrinsicGasPayload(gas, t.Payload, true, *fork.Rules(big.NewInt(int64(currentBlockNumber)))) if err != nil { - return 0, err + return 0, tokens, err } - return gasPayloadWithGas, nil + return gasPayloadWithGas, tokens, nil } func (t *TxInternalDataFeeDelegatedSmartContractDeployWithRatio) SerializeForSignToBytes() []byte { diff --git a/blockchain/types/tx_internal_data_fee_delegated_smart_contract_execution.go b/blockchain/types/tx_internal_data_fee_delegated_smart_contract_execution.go index d1b544271..d48eced42 100644 --- a/blockchain/types/tx_internal_data_fee_delegated_smart_contract_execution.go +++ b/blockchain/types/tx_internal_data_fee_delegated_smart_contract_execution.go @@ -273,15 +273,15 @@ func (t *TxInternalDataFeeDelegatedSmartContractExecution) String() string { enc) } -func (t *TxInternalDataFeeDelegatedSmartContractExecution) IntrinsicGas(currentBlockNumber uint64) (uint64, error) { +func (t *TxInternalDataFeeDelegatedSmartContractExecution) IntrinsicGas(currentBlockNumber uint64) (uint64, uint64, error) { gas := params.TxGasContractExecution + params.TxGasFeeDelegated - gasPayloadWithGas, err := IntrinsicGasPayload(gas, t.Payload, false, *fork.Rules(big.NewInt(int64(currentBlockNumber)))) + gasPayloadWithGas, tokens, err := IntrinsicGasPayload(gas, t.Payload, false, *fork.Rules(big.NewInt(int64(currentBlockNumber)))) if err != nil { - return 0, err + return 0, tokens, err } - return gasPayloadWithGas, nil + return gasPayloadWithGas, tokens, nil } func (t *TxInternalDataFeeDelegatedSmartContractExecution) SerializeForSignToBytes() []byte { diff --git a/blockchain/types/tx_internal_data_fee_delegated_smart_contract_execution_with_ratio.go b/blockchain/types/tx_internal_data_fee_delegated_smart_contract_execution_with_ratio.go index db4c4f468..49595d542 100644 --- a/blockchain/types/tx_internal_data_fee_delegated_smart_contract_execution_with_ratio.go +++ b/blockchain/types/tx_internal_data_fee_delegated_smart_contract_execution_with_ratio.go @@ -293,15 +293,15 @@ func (t *TxInternalDataFeeDelegatedSmartContractExecutionWithRatio) String() str enc) } -func (t *TxInternalDataFeeDelegatedSmartContractExecutionWithRatio) IntrinsicGas(currentBlockNumber uint64) (uint64, error) { +func (t *TxInternalDataFeeDelegatedSmartContractExecutionWithRatio) IntrinsicGas(currentBlockNumber uint64) (uint64, uint64, error) { gas := params.TxGasContractExecution + params.TxGasFeeDelegatedWithRatio - gasPayloadWithGas, err := IntrinsicGasPayload(gas, t.Payload, false, *fork.Rules(big.NewInt(int64(currentBlockNumber)))) + gasPayloadWithGas, tokens, err := IntrinsicGasPayload(gas, t.Payload, false, *fork.Rules(big.NewInt(int64(currentBlockNumber)))) if err != nil { - return 0, err + return 0, tokens, err } - return gasPayloadWithGas, nil + return gasPayloadWithGas, tokens, nil } func (t *TxInternalDataFeeDelegatedSmartContractExecutionWithRatio) SerializeForSignToBytes() []byte { diff --git a/blockchain/types/tx_internal_data_fee_delegated_value_transfer.go b/blockchain/types/tx_internal_data_fee_delegated_value_transfer.go index 4e24db28f..617e22437 100644 --- a/blockchain/types/tx_internal_data_fee_delegated_value_transfer.go +++ b/blockchain/types/tx_internal_data_fee_delegated_value_transfer.go @@ -257,8 +257,8 @@ func (t *TxInternalDataFeeDelegatedValueTransfer) String() string { enc) } -func (t *TxInternalDataFeeDelegatedValueTransfer) IntrinsicGas(currentBlockNumber uint64) (uint64, error) { - return params.TxGasValueTransfer + params.TxGasFeeDelegated, nil +func (t *TxInternalDataFeeDelegatedValueTransfer) IntrinsicGas(currentBlockNumber uint64) (uint64, uint64, error) { + return params.TxGasValueTransfer + params.TxGasFeeDelegated, 0, nil } func (t *TxInternalDataFeeDelegatedValueTransfer) SerializeForSignToBytes() []byte { diff --git a/blockchain/types/tx_internal_data_fee_delegated_value_transfer_memo.go b/blockchain/types/tx_internal_data_fee_delegated_value_transfer_memo.go index 7f714cb60..0341c4696 100644 --- a/blockchain/types/tx_internal_data_fee_delegated_value_transfer_memo.go +++ b/blockchain/types/tx_internal_data_fee_delegated_value_transfer_memo.go @@ -274,14 +274,14 @@ func (t *TxInternalDataFeeDelegatedValueTransferMemo) RecoverFeePayerPubkey(txha return t.FeePayerSignatures.RecoverPubkey(txhash, homestead, vfunc) } -func (t *TxInternalDataFeeDelegatedValueTransferMemo) IntrinsicGas(currentBlockNumber uint64) (uint64, error) { +func (t *TxInternalDataFeeDelegatedValueTransferMemo) IntrinsicGas(currentBlockNumber uint64) (uint64, uint64, error) { gas := params.TxGasValueTransfer + params.TxGasFeeDelegated - gasPayloadWithGas, err := IntrinsicGasPayload(gas, t.Payload, false, *fork.Rules(big.NewInt(int64(currentBlockNumber)))) + gasPayloadWithGas, tokens, err := IntrinsicGasPayload(gas, t.Payload, false, *fork.Rules(big.NewInt(int64(currentBlockNumber)))) if err != nil { - return 0, err + return 0, tokens, err } - return gasPayloadWithGas, nil + return gasPayloadWithGas, tokens, nil } func (t *TxInternalDataFeeDelegatedValueTransferMemo) SerializeForSignToBytes() []byte { diff --git a/blockchain/types/tx_internal_data_fee_delegated_value_transfer_memo_with_ratio.go b/blockchain/types/tx_internal_data_fee_delegated_value_transfer_memo_with_ratio.go index 2e65e3517..98073dca7 100644 --- a/blockchain/types/tx_internal_data_fee_delegated_value_transfer_memo_with_ratio.go +++ b/blockchain/types/tx_internal_data_fee_delegated_value_transfer_memo_with_ratio.go @@ -294,14 +294,14 @@ func (t *TxInternalDataFeeDelegatedValueTransferMemoWithRatio) RecoverFeePayerPu return t.FeePayerSignatures.RecoverPubkey(txhash, homestead, vfunc) } -func (t *TxInternalDataFeeDelegatedValueTransferMemoWithRatio) IntrinsicGas(currentBlockNumber uint64) (uint64, error) { +func (t *TxInternalDataFeeDelegatedValueTransferMemoWithRatio) IntrinsicGas(currentBlockNumber uint64) (uint64, uint64, error) { gas := params.TxGasValueTransfer + params.TxGasFeeDelegatedWithRatio - gasPayloadWithGas, err := IntrinsicGasPayload(gas, t.Payload, false, *fork.Rules(big.NewInt(int64(currentBlockNumber)))) + gasPayloadWithGas, tokens, err := IntrinsicGasPayload(gas, t.Payload, false, *fork.Rules(big.NewInt(int64(currentBlockNumber)))) if err != nil { - return 0, err + return 0, tokens, err } - return gasPayloadWithGas, nil + return gasPayloadWithGas, tokens, nil } func (t *TxInternalDataFeeDelegatedValueTransferMemoWithRatio) SerializeForSignToBytes() []byte { diff --git a/blockchain/types/tx_internal_data_fee_delegated_value_transfer_with_ratio.go b/blockchain/types/tx_internal_data_fee_delegated_value_transfer_with_ratio.go index 4b5f302b5..d5e342d95 100644 --- a/blockchain/types/tx_internal_data_fee_delegated_value_transfer_with_ratio.go +++ b/blockchain/types/tx_internal_data_fee_delegated_value_transfer_with_ratio.go @@ -275,8 +275,8 @@ func (t *TxInternalDataFeeDelegatedValueTransferWithRatio) String() string { enc) } -func (t *TxInternalDataFeeDelegatedValueTransferWithRatio) IntrinsicGas(currentBlockNumber uint64) (uint64, error) { - return params.TxGasValueTransfer + params.TxGasFeeDelegatedWithRatio, nil +func (t *TxInternalDataFeeDelegatedValueTransferWithRatio) IntrinsicGas(currentBlockNumber uint64) (uint64, uint64, error) { + return params.TxGasValueTransfer + params.TxGasFeeDelegatedWithRatio, 0, nil } func (t *TxInternalDataFeeDelegatedValueTransferWithRatio) SerializeForSignToBytes() []byte { diff --git a/blockchain/types/tx_internal_data_legacy.go b/blockchain/types/tx_internal_data_legacy.go index 84f0a4d00..0dd5d68a7 100644 --- a/blockchain/types/tx_internal_data_legacy.go +++ b/blockchain/types/tx_internal_data_legacy.go @@ -235,7 +235,7 @@ func (t *TxInternalDataLegacy) RecoverPubkey(txhash common.Hash, homestead bool, return []*ecdsa.PublicKey{pk}, nil } -func (t *TxInternalDataLegacy) IntrinsicGas(currentBlockNumber uint64) (uint64, error) { +func (t *TxInternalDataLegacy) IntrinsicGas(currentBlockNumber uint64) (uint64, uint64, error) { return IntrinsicGas(t.Payload, nil, nil, t.Recipient == nil, *fork.Rules(big.NewInt(int64(currentBlockNumber)))) } diff --git a/blockchain/types/tx_internal_data_smart_contract_deploy.go b/blockchain/types/tx_internal_data_smart_contract_deploy.go index 73c7effde..ef8b79cd9 100644 --- a/blockchain/types/tx_internal_data_smart_contract_deploy.go +++ b/blockchain/types/tx_internal_data_smart_contract_deploy.go @@ -268,19 +268,19 @@ func (t *TxInternalDataSmartContractDeploy) String() string { enc) } -func (t *TxInternalDataSmartContractDeploy) IntrinsicGas(currentBlockNumber uint64) (uint64, error) { +func (t *TxInternalDataSmartContractDeploy) IntrinsicGas(currentBlockNumber uint64) (uint64, uint64, error) { gas := params.TxGasContractCreation if t.HumanReadable { gas += params.TxGasHumanReadable } - gasPayloadWithGas, err := IntrinsicGasPayload(gas, t.Payload, true, *fork.Rules(big.NewInt(int64(currentBlockNumber)))) + gasPayloadWithGas, tokens, err := IntrinsicGasPayload(gas, t.Payload, true, *fork.Rules(big.NewInt(int64(currentBlockNumber)))) if err != nil { - return 0, err + return 0, tokens, err } - return gasPayloadWithGas, nil + return gasPayloadWithGas, tokens, nil } func (t *TxInternalDataSmartContractDeploy) SerializeForSignToBytes() []byte { diff --git a/blockchain/types/tx_internal_data_smart_contract_execution.go b/blockchain/types/tx_internal_data_smart_contract_execution.go index 791ce9972..a5c0eaeb1 100644 --- a/blockchain/types/tx_internal_data_smart_contract_execution.go +++ b/blockchain/types/tx_internal_data_smart_contract_execution.go @@ -238,15 +238,15 @@ func (t *TxInternalDataSmartContractExecution) String() string { enc) } -func (t *TxInternalDataSmartContractExecution) IntrinsicGas(currentBlockNumber uint64) (uint64, error) { +func (t *TxInternalDataSmartContractExecution) IntrinsicGas(currentBlockNumber uint64) (uint64, uint64, error) { gas := params.TxGasContractExecution - gasPayloadWithGas, err := IntrinsicGasPayload(gas, t.Payload, false, *fork.Rules(big.NewInt(int64(currentBlockNumber)))) + gasPayloadWithGas, tokens, err := IntrinsicGasPayload(gas, t.Payload, false, *fork.Rules(big.NewInt(int64(currentBlockNumber)))) if err != nil { - return 0, err + return 0, tokens, err } - return gasPayloadWithGas, nil + return gasPayloadWithGas, tokens, nil } func (t *TxInternalDataSmartContractExecution) SerializeForSignToBytes() []byte { diff --git a/blockchain/types/tx_internal_data_value_transfer.go b/blockchain/types/tx_internal_data_value_transfer.go index 5b81efe59..60d44d514 100644 --- a/blockchain/types/tx_internal_data_value_transfer.go +++ b/blockchain/types/tx_internal_data_value_transfer.go @@ -222,11 +222,11 @@ func (t *TxInternalDataValueTransfer) SetSignature(s TxSignatures) { t.TxSignatures = s } -func (t *TxInternalDataValueTransfer) IntrinsicGas(currentBlockNumber uint64) (uint64, error) { +func (t *TxInternalDataValueTransfer) IntrinsicGas(currentBlockNumber uint64) (uint64, uint64, error) { // TxInternalDataValueTransfer does not have payload, and it // is not account creation. Hence, its intrinsic gas is determined by // params.TxGas. Refer to types.IntrinsicGas(). - return params.TxGasValueTransfer, nil + return params.TxGasValueTransfer, 0, nil } func (t *TxInternalDataValueTransfer) SerializeForSignToBytes() []byte { diff --git a/blockchain/types/tx_internal_data_value_transfer_memo.go b/blockchain/types/tx_internal_data_value_transfer_memo.go index 56193618c..71e6f3452 100644 --- a/blockchain/types/tx_internal_data_value_transfer_memo.go +++ b/blockchain/types/tx_internal_data_value_transfer_memo.go @@ -239,14 +239,14 @@ func (t *TxInternalDataValueTransferMemo) SetSignature(s TxSignatures) { t.TxSignatures = s } -func (t *TxInternalDataValueTransferMemo) IntrinsicGas(currentBlockNumber uint64) (uint64, error) { +func (t *TxInternalDataValueTransferMemo) IntrinsicGas(currentBlockNumber uint64) (uint64, uint64, error) { gas := params.TxGasValueTransfer - gasPayloadWithGas, err := IntrinsicGasPayload(gas, t.Payload, false, *fork.Rules(big.NewInt(int64(currentBlockNumber)))) + gasPayloadWithGas, tokens, err := IntrinsicGasPayload(gas, t.Payload, false, *fork.Rules(big.NewInt(int64(currentBlockNumber)))) if err != nil { - return 0, err + return 0, tokens, err } - return gasPayloadWithGas, nil + return gasPayloadWithGas, tokens, nil } func (t *TxInternalDataValueTransferMemo) SerializeForSignToBytes() []byte { diff --git a/node/cn/tracers/api.go b/node/cn/tracers/api.go index dd3678f45..54e2abdd1 100644 --- a/node/cn/tracers/api.go +++ b/node/cn/tracers/api.go @@ -895,7 +895,7 @@ func (api *CommonAPI) TraceCall(ctx context.Context, args kaiaapi.CallArgs, bloc defer release() // Execute the trace - intrinsicGas, err := types.IntrinsicGas(args.InputData(), args.GetAccessList(), nil, args.To == nil, api.backend.ChainConfig().Rules(block.Number())) + intrinsicGas, dataTokens, err := types.IntrinsicGas(args.InputData(), args.GetAccessList(), nil, args.To == nil, api.backend.ChainConfig().Rules(block.Number())) if err != nil { return nil, err } @@ -907,7 +907,7 @@ func (api *CommonAPI) TraceCall(ctx context.Context, args kaiaapi.CallArgs, bloc if rpcGasCap := api.backend.RPCGasCap(); rpcGasCap != nil { gasCap = rpcGasCap.Uint64() } - msg, err := args.ToMessage(gasCap, basefee, intrinsicGas) + msg, err := args.ToMessage(gasCap, basefee, intrinsicGas, dataTokens) if err != nil { return nil, err } diff --git a/params/protocol_params.go b/params/protocol_params.go index 9e832f0d3..86b9e1d48 100644 --- a/params/protocol_params.go +++ b/params/protocol_params.go @@ -35,21 +35,23 @@ var TargetGasLimit = GenesisGasLimit // The artificial target const ( // Fee schedule parameters - CallValueTransferGas uint64 = 9000 // Paid for CALL when the value transfer is non-zero. // G_callvalue - CallNewAccountGas uint64 = 25000 // Paid for CALL when the destination address didn't exist prior. // G_newaccount - TxGas uint64 = 21000 // Per transaction not creating a contract. NOTE: Not payable on data of calls between transactions. // G_transaction - TxGasContractCreation uint64 = 53000 // Per transaction that creates a contract. NOTE: Not payable on data of calls between transactions. // G_transaction + G_create - TxDataZeroGas uint64 = 4 // Per byte of data attached to a transaction that equals zero. NOTE: Not payable on data of calls between transactions. // G_txdatazero - QuadCoeffDiv uint64 = 512 // Divisor for the quadratic particle of the memory cost equation. - SstoreSetGas uint64 = 20000 // Once per SLOAD operation. // G_sset - LogDataGas uint64 = 8 // Per byte in a LOG* operation's data. // G_logdata - CallStipend uint64 = 2300 // Free gas given at beginning of call. // G_callstipend - Sha3Gas uint64 = 30 // Once per SHA3 operation. // G_sha3 - Sha3WordGas uint64 = 6 // Once per word of the SHA3 operation's data. // G_sha3word - InitCodeWordGas uint64 = 2 // Once per word of the init code when creating a contract. // G_InitCodeWord - SstoreResetGas uint64 = 5000 // Once per SSTORE operation if the zeroness changes from zero. // G_sreset - SstoreClearGas uint64 = 5000 // Once per SSTORE operation if the zeroness doesn't change. // G_sreset - SstoreRefundGas uint64 = 15000 // Once per SSTORE operation if the zeroness changes to zero. // R_sclear + CallValueTransferGas uint64 = 9000 // Paid for CALL when the value transfer is non-zero. // G_callvalue + CallNewAccountGas uint64 = 25000 // Paid for CALL when the destination address didn't exist prior. // G_newaccount + TxGas uint64 = 21000 // Per transaction not creating a contract. NOTE: Not payable on data of calls between transactions. // G_transaction + TxGasContractCreation uint64 = 53000 // Per transaction that creates a contract. NOTE: Not payable on data of calls between transactions. // G_transaction + G_create + TxDataZeroGas uint64 = 4 // Per byte of data attached to a transaction that equals zero. NOTE: Not payable on data of calls between transactions. // G_txdatazero + TokenPerNonZeroByte7623 uint64 = 4 // Token cost per non-zero byte as specified by EIP-7623. + CostFloorPerToken7623 uint64 = 10 // Cost floor per byte of data as specified by EIP-7623. + QuadCoeffDiv uint64 = 512 // Divisor for the quadratic particle of the memory cost equation. + SstoreSetGas uint64 = 20000 // Once per SLOAD operation. // G_sset + LogDataGas uint64 = 8 // Per byte in a LOG* operation's data. // G_logdata + CallStipend uint64 = 2300 // Free gas given at beginning of call. // G_callstipend + Sha3Gas uint64 = 30 // Once per SHA3 operation. // G_sha3 + Sha3WordGas uint64 = 6 // Once per word of the SHA3 operation's data. // G_sha3word + InitCodeWordGas uint64 = 2 // Once per word of the init code when creating a contract. // G_InitCodeWord + SstoreResetGas uint64 = 5000 // Once per SSTORE operation if the zeroness changes from zero. // G_sreset + SstoreClearGas uint64 = 5000 // Once per SSTORE operation if the zeroness doesn't change. // G_sreset + SstoreRefundGas uint64 = 15000 // Once per SSTORE operation if the zeroness changes to zero. // R_sclear // gasSStoreEIP2200 SstoreSentryGasEIP2200 uint64 = 2300 // Minimum gas required to be present for an SSTORE call, not consumed diff --git a/tests/kaia_test_account_map_test.go b/tests/kaia_test_account_map_test.go index b59bee2ca..9be775fdb 100644 --- a/tests/kaia_test_account_map_test.go +++ b/tests/kaia_test_account_map_test.go @@ -137,7 +137,7 @@ func (a *AccountMap) Update(txs types.Transactions, signer types.Signer, picker // TODO-Kaia: This gas fee calculation is correct only if the transaction is a value transfer transaction. // Calculate the correct transaction fee by checking the corresponding receipt. - intrinsicGas, err := tx.IntrinsicGas(currentBlockNumber) + intrinsicGas, _, err := tx.IntrinsicGas(currentBlockNumber) if err != nil { return err } diff --git a/tests/state_test_util.go b/tests/state_test_util.go index 10fcd5ac6..460076e13 100644 --- a/tests/state_test_util.go +++ b/tests/state_test_util.go @@ -434,17 +434,18 @@ func (tx *stTransaction) toMessage(ps stPostState, r params.Rules, isTestExecuti } var intrinsicGas uint64 + var dataTokens uint64 if isTestExecutionSpecState { - intrinsicGas, err = useEthIntrinsicGas(data, accessList, authorizationList, to == nil, r) + intrinsicGas, dataTokens, err = useEthIntrinsicGas(data, accessList, authorizationList, to == nil, r) } else { - intrinsicGas, err = types.IntrinsicGas(data, nil, nil, to == nil, r) + intrinsicGas, dataTokens, err = types.IntrinsicGas(data, nil, nil, to == nil, r) } if err != nil { return nil, err } - msg := types.NewMessage(from, to, tx.Nonce, value, gasLimit, tx.GasPrice, tx.MaxFeePerGas, tx.MaxPriorityFeePerGas, data, true, intrinsicGas, accessList, authorizationList) + msg := types.NewMessage(from, to, tx.Nonce, value, gasLimit, tx.GasPrice, tx.MaxFeePerGas, tx.MaxPriorityFeePerGas, data, true, intrinsicGas, dataTokens, accessList, authorizationList) return msg, nil } @@ -496,7 +497,7 @@ func useEthOpCodeGas(r params.Rules, evm *vm.EVM) { } } -func useEthIntrinsicGas(data []byte, accessList types.AccessList, authorizationList types.AuthorizationList, contractCreation bool, r params.Rules) (uint64, error) { +func useEthIntrinsicGas(data []byte, accessList types.AccessList, authorizationList types.AuthorizationList, contractCreation bool, r params.Rules) (uint64, uint64, error) { if r.IsIstanbul { r.IsPrague = true } diff --git a/tests/tx_gas_calculation_test.go b/tests/tx_gas_calculation_test.go index 35371c310..5b14681dc 100644 --- a/tests/tx_gas_calculation_test.go +++ b/tests/tx_gas_calculation_test.go @@ -846,7 +846,8 @@ func genMapForDeploy(from TestAccount, to TestAccount, gasPrice *big.Int, txType intrinsicGas := getIntrinsicGas(txType) intrinsicGas += uint64(0x175fd) - gasPayloadWithGas, err := types.IntrinsicGasPayload(intrinsicGas, common.FromHex(code), true, params.Rules{IsIstanbul: true, IsShanghai: true}) + // TODO-Kaia: Add test for EIP-7623 + gasPayloadWithGas, _, err := types.IntrinsicGasPayload(intrinsicGas, common.FromHex(code), true, params.Rules{IsIstanbul: true, IsShanghai: true}) if err != nil { return nil, 0 } @@ -881,7 +882,8 @@ func genMapForExecution(from TestAccount, to TestAccount, gasPrice *big.Int, txT intrinsicGas := getIntrinsicGas(txType) intrinsicGas += uint64(0x9ec4) - gasPayloadWithGas, err := types.IntrinsicGasPayload(intrinsicGas, data, false, params.Rules{IsShanghai: false}) + // TODO-Kaia: Add test for EIP-7623 + gasPayloadWithGas, _, err := types.IntrinsicGasPayload(intrinsicGas, data, false, params.Rules{IsShanghai: false}) if err != nil { return nil, 0 } diff --git a/tests/tx_validation_test.go b/tests/tx_validation_test.go index c1ae1d810..b6e151ecc 100644 --- a/tests/tx_validation_test.go +++ b/tests/tx_validation_test.go @@ -452,7 +452,7 @@ func TestValidationPoolInsertPrague(t *testing.T) { authorizationList := types.AuthorizationList{*auth} tx := types.NewMessage(reservoir.Addr, &eoaWithCode.Addr, reservoir.GetNonce(), nil, gasLimit, - nil, big.NewInt(25*params.Gkei), big.NewInt(25*params.Gkei), nil, false, uint64(0), nil, authorizationList) + nil, big.NewInt(25*params.Gkei), big.NewInt(25*params.Gkei), nil, false, uint64(0), uint64(0), nil, authorizationList) tx.ChainId().Set(bcdata.bc.Config().ChainID) err = tx.SignWithKeys(signer, reservoir.Keys) assert.Equal(t, nil, err)