From a2065c7ad6533cb2a9fa4b35c8ed874aaf6dd8c6 Mon Sep 17 00:00:00 2001 From: Hadrien Croubois Date: Thu, 15 Feb 2024 16:41:58 +0100 Subject: [PATCH] update core/types/tx_delegate.go to catch up with changes in core/types/tx_access_list.go --- core/types/tx_delegate.go | 57 +++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 33 deletions(-) diff --git a/core/types/tx_delegate.go b/core/types/tx_delegate.go index 079c710334..c900d10a83 100644 --- a/core/types/tx_delegate.go +++ b/core/types/tx_delegate.go @@ -17,26 +17,23 @@ package types import ( + "bytes" "math/big" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/rlp" ) // DelegateTx represents an EIP-5806 transaction. type DelegateTx struct { - ChainID *big.Int - Nonce uint64 - GasTipCap *big.Int // a.k.a. maxPriorityFeePerGas - GasFeeCap *big.Int // a.k.a. maxFeePerGas - Gas uint64 + ChainID *big.Int // destination chain ID + Nonce uint64 // nonce of sender account + GasPrice *big.Int // wei per gas + Gas uint64 // gas limit To *common.Address `rlp:"nil"` // nil means contract creation - Data []byte - AccessList AccessList - - // Signature values - V *big.Int `json:"v" gencodec:"required"` - R *big.Int `json:"r" gencodec:"required"` - S *big.Int `json:"s" gencodec:"required"` + Data []byte // contract invocation input data + AccessList AccessList // EIP-2930 access list + V, R, S *big.Int // signature values } // copy creates a deep copy of the transaction data and initializes all fields. @@ -49,8 +46,7 @@ func (tx *DelegateTx) copy() TxData { // These are copied below. AccessList: make(AccessList, len(tx.AccessList)), ChainID: new(big.Int), - GasTipCap: new(big.Int), - GasFeeCap: new(big.Int), + GasPrice: new(big.Int), V: new(big.Int), R: new(big.Int), S: new(big.Int), @@ -59,11 +55,8 @@ func (tx *DelegateTx) copy() TxData { if tx.ChainID != nil { cpy.ChainID.Set(tx.ChainID) } - if tx.GasTipCap != nil { - cpy.GasTipCap.Set(tx.GasTipCap) - } - if tx.GasFeeCap != nil { - cpy.GasFeeCap.Set(tx.GasFeeCap) + if tx.GasPrice != nil { + cpy.GasPrice.Set(tx.GasPrice) } if tx.V != nil { cpy.V.Set(tx.V) @@ -83,25 +76,15 @@ func (tx *DelegateTx) chainID() *big.Int { return tx.ChainID } func (tx *DelegateTx) accessList() AccessList { return tx.AccessList } func (tx *DelegateTx) data() []byte { return tx.Data } func (tx *DelegateTx) gas() uint64 { return tx.Gas } -func (tx *DelegateTx) gasFeeCap() *big.Int { return tx.GasFeeCap } -func (tx *DelegateTx) gasTipCap() *big.Int { return tx.GasTipCap } -func (tx *DelegateTx) gasPrice() *big.Int { return tx.GasFeeCap } +func (tx *DelegateTx) gasPrice() *big.Int { return tx.GasPrice } +func (tx *DelegateTx) gasTipCap() *big.Int { return tx.GasPrice } +func (tx *DelegateTx) gasFeeCap() *big.Int { return tx.GasPrice } func (tx *DelegateTx) value() *big.Int { return big.NewInt(0) } func (tx *DelegateTx) nonce() uint64 { return tx.Nonce } func (tx *DelegateTx) to() *common.Address { return tx.To } -func (tx *DelegateTx) blobGas() uint64 { return 0 } -func (tx *DelegateTx) blobGasFeeCap() *big.Int { return nil } -func (tx *DelegateTx) blobHashes() []common.Hash { return nil } func (tx *DelegateTx) effectiveGasPrice(dst *big.Int, baseFee *big.Int) *big.Int { - if baseFee == nil { - return dst.Set(tx.GasFeeCap) - } - tip := dst.Sub(tx.GasFeeCap, baseFee) - if tip.Cmp(tx.GasTipCap) > 0 { - tip.Set(tx.GasTipCap) - } - return tip.Add(tip, baseFee) + return dst.Set(tx.GasPrice) } func (tx *DelegateTx) rawSignatureValues() (v, r, s *big.Int) { @@ -111,3 +94,11 @@ func (tx *DelegateTx) rawSignatureValues() (v, r, s *big.Int) { func (tx *DelegateTx) setSignatureValues(chainID, v, r, s *big.Int) { tx.ChainID, tx.V, tx.R, tx.S = chainID, v, r, s } + +func (tx *DelegateTx) encode(b *bytes.Buffer) error { + return rlp.Encode(b, tx) +} + +func (tx *DelegateTx) decode(input []byte) error { + return rlp.DecodeBytes(input, tx) +}