update core/types/tx_delegate.go to catch up with changes in core/types/tx_access_list.go

This commit is contained in:
Hadrien Croubois 2024-02-15 16:41:58 +01:00
parent 50dfc024f7
commit a2065c7ad6
No known key found for this signature in database
GPG key ID: B53810561A746A06

View file

@ -17,26 +17,23 @@
package types package types
import ( import (
"bytes"
"math/big" "math/big"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/rlp"
) )
// DelegateTx represents an EIP-5806 transaction. // DelegateTx represents an EIP-5806 transaction.
type DelegateTx struct { type DelegateTx struct {
ChainID *big.Int ChainID *big.Int // destination chain ID
Nonce uint64 Nonce uint64 // nonce of sender account
GasTipCap *big.Int // a.k.a. maxPriorityFeePerGas GasPrice *big.Int // wei per gas
GasFeeCap *big.Int // a.k.a. maxFeePerGas Gas uint64 // gas limit
Gas uint64
To *common.Address `rlp:"nil"` // nil means contract creation To *common.Address `rlp:"nil"` // nil means contract creation
Data []byte Data []byte // contract invocation input data
AccessList AccessList AccessList AccessList // EIP-2930 access list
V, R, S *big.Int // signature values
// Signature values
V *big.Int `json:"v" gencodec:"required"`
R *big.Int `json:"r" gencodec:"required"`
S *big.Int `json:"s" gencodec:"required"`
} }
// copy creates a deep copy of the transaction data and initializes all fields. // 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. // These are copied below.
AccessList: make(AccessList, len(tx.AccessList)), AccessList: make(AccessList, len(tx.AccessList)),
ChainID: new(big.Int), ChainID: new(big.Int),
GasTipCap: new(big.Int), GasPrice: new(big.Int),
GasFeeCap: new(big.Int),
V: new(big.Int), V: new(big.Int),
R: new(big.Int), R: new(big.Int),
S: new(big.Int), S: new(big.Int),
@ -59,11 +55,8 @@ func (tx *DelegateTx) copy() TxData {
if tx.ChainID != nil { if tx.ChainID != nil {
cpy.ChainID.Set(tx.ChainID) cpy.ChainID.Set(tx.ChainID)
} }
if tx.GasTipCap != nil { if tx.GasPrice != nil {
cpy.GasTipCap.Set(tx.GasTipCap) cpy.GasPrice.Set(tx.GasPrice)
}
if tx.GasFeeCap != nil {
cpy.GasFeeCap.Set(tx.GasFeeCap)
} }
if tx.V != nil { if tx.V != nil {
cpy.V.Set(tx.V) 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) accessList() AccessList { return tx.AccessList }
func (tx *DelegateTx) data() []byte { return tx.Data } func (tx *DelegateTx) data() []byte { return tx.Data }
func (tx *DelegateTx) gas() uint64 { return tx.Gas } func (tx *DelegateTx) gas() uint64 { return tx.Gas }
func (tx *DelegateTx) gasFeeCap() *big.Int { return tx.GasFeeCap } func (tx *DelegateTx) gasPrice() *big.Int { return tx.GasPrice }
func (tx *DelegateTx) gasTipCap() *big.Int { return tx.GasTipCap } func (tx *DelegateTx) gasTipCap() *big.Int { return tx.GasPrice }
func (tx *DelegateTx) gasPrice() *big.Int { return tx.GasFeeCap } func (tx *DelegateTx) gasFeeCap() *big.Int { return tx.GasPrice }
func (tx *DelegateTx) value() *big.Int { return big.NewInt(0) } func (tx *DelegateTx) value() *big.Int { return big.NewInt(0) }
func (tx *DelegateTx) nonce() uint64 { return tx.Nonce } func (tx *DelegateTx) nonce() uint64 { return tx.Nonce }
func (tx *DelegateTx) to() *common.Address { return tx.To } 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 { func (tx *DelegateTx) effectiveGasPrice(dst *big.Int, baseFee *big.Int) *big.Int {
if baseFee == nil { return dst.Set(tx.GasPrice)
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)
} }
func (tx *DelegateTx) rawSignatureValues() (v, r, s *big.Int) { 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) { func (tx *DelegateTx) setSignatureValues(chainID, v, r, s *big.Int) {
tx.ChainID, tx.V, tx.R, tx.S = chainID, v, r, s 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)
}