diff --git a/core/state_processor_rip7560.go b/core/state_processor_rip7560.go index a80f696fa67d..568a3e00d548 100644 --- a/core/state_processor_rip7560.go +++ b/core/state_processor_rip7560.go @@ -599,7 +599,7 @@ func applyPaymasterValidationFrame(st *stateTransition, epc *EntryPointCall, tx if err != nil { return nil, 0, 0, 0, wrapError(err) } - if len(apd.Context) > 0 && aatx.PostOpGas == 0 { + if len(apd.Context) > 0 && aatx.PostOpGasLimit == 0 { return nil, 0, 0, 0, wrapError( fmt.Errorf( "paymaster returned a context of size %d but the paymasterPostOpGasLimit is 0", @@ -613,7 +613,7 @@ func applyPaymasterValidationFrame(st *stateTransition, epc *EntryPointCall, tx func applyPaymasterPostOpFrame(st *stateTransition, aatx *types.Rip7560AccountAbstractionTx, vpr *ValidationPhaseResult, success bool, gasUsed uint64) *ExecutionResult { var paymasterPostOpResult *ExecutionResult paymasterPostOpMsg := preparePostOpMessage(vpr, success, gasUsed) - paymasterPostOpResult = CallFrame(st, &AA_ENTRY_POINT, aatx.Paymaster, paymasterPostOpMsg, aatx.PostOpGas) + paymasterPostOpResult = CallFrame(st, &AA_ENTRY_POINT, aatx.Paymaster, paymasterPostOpMsg, aatx.PostOpGasLimit) return paymasterPostOpResult } @@ -685,7 +685,7 @@ func ApplyRip7560ExecutionPhase( } executionStatus = ExecutionStatusPostOpFailure } - postOpGasPenalty := (aatx.PostOpGas - postOpGasUsed) * AA_GAS_PENALTY_PCT / 100 + postOpGasPenalty := (aatx.PostOpGasLimit - postOpGasUsed) * AA_GAS_PENALTY_PCT / 100 postOpGasUsed += postOpGasPenalty gasUsed += postOpGasUsed } diff --git a/core/types/transaction_signing_rip7560.go b/core/types/transaction_signing_rip7560.go index e3fbd7d00006..97d69b9d18f7 100644 --- a/core/types/transaction_signing_rip7560.go +++ b/core/types/transaction_signing_rip7560.go @@ -42,10 +42,10 @@ func (s rip7560Signer) Hash(tx *Transaction) common.Hash { tx.GasFeeCap(), aatx.ValidationGasLimit, aatx.PaymasterValidationGasLimit, - aatx.PostOpGas, + aatx.PostOpGasLimit, tx.Gas(), tx.AccessList(), - // no AuthorizationData here - this is hashing "for signing" + // no SenderValidationData here - this is hashing "for signing" }) } diff --git a/core/types/tx_rip7560.go b/core/types/tx_rip7560.go index 8ca88b4c556a..aa97fb603943 100644 --- a/core/types/tx_rip7560.go +++ b/core/types/tx_rip7560.go @@ -19,38 +19,37 @@ package types import ( "bytes" "fmt" + "math/big" + "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/rlp" - "math/big" ) // Rip7560AccountAbstractionTx represents an RIP-7560 transaction. type Rip7560AccountAbstractionTx struct { // overlapping fields - ChainID *big.Int - Nonce uint64 - GasTipCap *big.Int // a.k.a. maxPriorityFeePerGas - GasFeeCap *big.Int // a.k.a. maxFeePerGas - Gas uint64 - AccessList AccessList - - // extra fields + ChainID *big.Int + // RIP-7712 two-dimensional nonce + NonceKey *big.Int + Nonce uint64 Sender *common.Address - AuthorizationData []byte - ExecutionData []byte + SenderValidationData []byte Paymaster *common.Address `rlp:"nil"` PaymasterData []byte Deployer *common.Address `rlp:"nil"` DeployerData []byte + ExecutionData []byte BuilderFee *big.Int + GasTipCap *big.Int // a.k.a. maxPriorityFeePerGas + GasFeeCap *big.Int // a.k.a. maxFeePerGas ValidationGasLimit uint64 PaymasterValidationGasLimit uint64 - PostOpGas uint64 - - // RIP-7712 two-dimensional nonce (optional), 192 bits - NonceKey *big.Int + PostOpGasLimit uint64 + Gas uint64 + AccessList AccessList + AuthList []SetCodeAuthorization } // copy creates a deep copy of the transaction data and initializes all fields. @@ -69,7 +68,7 @@ func (tx *Rip7560AccountAbstractionTx) copy() TxData { GasFeeCap: new(big.Int), Sender: copyAddressPtr(tx.Sender), - AuthorizationData: common.CopyBytes(tx.AuthorizationData), + SenderValidationData: common.CopyBytes(tx.SenderValidationData), Paymaster: copyAddressPtr(tx.Paymaster), PaymasterData: common.CopyBytes(tx.PaymasterData), Deployer: copyAddressPtr(tx.Deployer), @@ -77,7 +76,7 @@ func (tx *Rip7560AccountAbstractionTx) copy() TxData { BuilderFee: new(big.Int), ValidationGasLimit: tx.ValidationGasLimit, PaymasterValidationGasLimit: tx.PaymasterValidationGasLimit, - PostOpGas: tx.PostOpGas, + PostOpGasLimit: tx.PostOpGasLimit, } copy(cpy.AccessList, tx.AccessList) if tx.ChainID != nil { @@ -152,7 +151,7 @@ func (tx *Rip7560AccountAbstractionTx) PreTransactionGasCost() (uint64, error) { func (tx *Rip7560AccountAbstractionTx) callDataGasCost() (uint64, error) { return SumGas( - callDataCost(tx.AuthorizationData), + callDataCost(tx.SenderValidationData), callDataCost(tx.DeployerData), callDataCost(tx.ExecutionData), callDataCost(tx.PaymasterData), @@ -177,7 +176,7 @@ func (tx *Rip7560AccountAbstractionTx) eip7702CodeInsertionsGasCost() uint64 { func (tx *Rip7560AccountAbstractionTx) TotalGasLimit() (uint64, error) { return SumGas( params.Rip7560TxGas, - tx.Gas, tx.ValidationGasLimit, tx.PaymasterValidationGasLimit, tx.PostOpGas, + tx.Gas, tx.ValidationGasLimit, tx.PaymasterValidationGasLimit, tx.PostOpGasLimit, ) } @@ -230,41 +229,43 @@ func (tx *Rip7560AccountAbstractionTx) decode(input []byte) error { // Rip7560Transaction an equivalent of a solidity struct only used to encode the 'transaction' parameter type Rip7560Transaction struct { Sender common.Address + Paymaster common.Address + Deployer common.Address NonceKey *big.Int Nonce *big.Int + BuilderFee *big.Int + MaxFeePerGas *big.Int + MaxPriorityFeePerGas *big.Int ValidationGasLimit *big.Int PaymasterValidationGasLimit *big.Int PostOpGasLimit *big.Int CallGasLimit *big.Int - MaxFeePerGas *big.Int - MaxPriorityFeePerGas *big.Int - BuilderFee *big.Int - Paymaster common.Address + SenderValidationData []byte PaymasterData []byte - Deployer common.Address DeployerData []byte ExecutionData []byte - AuthorizationData []byte + AuthorizationList []common.Address + AuthorizationListStatus []bool } func (tx *Rip7560AccountAbstractionTx) AbiEncode() ([]byte, error) { structThing, _ := abi.NewType("tuple", "struct thing", []abi.ArgumentMarshaling{ {Name: "sender", Type: "address"}, + {Name: "paymaster", Type: "address"}, + {Name: "deployer", Type: "address"}, {Name: "nonceKey", Type: "uint256"}, {Name: "nonce", Type: "uint256"}, + {Name: "builderFee", Type: "uint256"}, + {Name: "maxFeePerGas", Type: "uint256"}, + {Name: "maxPriorityFeePerGas", Type: "uint256"}, {Name: "validationGasLimit", Type: "uint256"}, {Name: "paymasterValidationGasLimit", Type: "uint256"}, {Name: "postOpGasLimit", Type: "uint256"}, {Name: "callGasLimit", Type: "uint256"}, - {Name: "maxFeePerGas", Type: "uint256"}, - {Name: "maxPriorityFeePerGas", Type: "uint256"}, - {Name: "builderFee", Type: "uint256"}, - {Name: "paymaster", Type: "address"}, + {Name: "senderData", Type: "bytes"}, {Name: "paymasterData", Type: "bytes"}, - {Name: "deployer", Type: "address"}, {Name: "deployerData", Type: "bytes"}, {Name: "executionData", Type: "bytes"}, - {Name: "authorizationData", Type: "bytes"}, }) args := abi.Arguments{ @@ -282,21 +283,23 @@ func (tx *Rip7560AccountAbstractionTx) AbiEncode() ([]byte, error) { record := &Rip7560Transaction{ Sender: *tx.Sender, + Paymaster: *paymaster, + Deployer: *deployer, NonceKey: tx.NonceKey, Nonce: big.NewInt(int64(tx.Nonce)), + BuilderFee: tx.BuilderFee, + MaxFeePerGas: tx.GasFeeCap, + MaxPriorityFeePerGas: tx.GasTipCap, ValidationGasLimit: big.NewInt(int64(tx.ValidationGasLimit)), PaymasterValidationGasLimit: big.NewInt(int64(tx.PaymasterValidationGasLimit)), - PostOpGasLimit: big.NewInt(int64(tx.PostOpGas)), + PostOpGasLimit: big.NewInt(int64(tx.PostOpGasLimit)), CallGasLimit: big.NewInt(int64(tx.Gas)), - MaxFeePerGas: tx.GasFeeCap, - MaxPriorityFeePerGas: tx.GasTipCap, - BuilderFee: tx.BuilderFee, - Paymaster: *paymaster, + SenderValidationData: tx.SenderValidationData, PaymasterData: tx.PaymasterData, - Deployer: *deployer, DeployerData: tx.DeployerData, ExecutionData: tx.ExecutionData, - AuthorizationData: tx.AuthorizationData, + AuthorizationList: make([]common.Address, 0), + AuthorizationListStatus: make([]bool, 0), } packed, err := args.Pack(&record) return packed, err diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 10a9bff44536..e9327d657e10 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -939,7 +939,7 @@ func RPCMarshalBlock(block *types.Block, inclTx bool, fullTx bool, config *param type RPCTransaction struct { BlockHash *common.Hash `json:"blockHash"` BlockNumber *hexutil.Big `json:"blockNumber"` - From common.Address `json:"from,omitempty"` + From common.Address `json:"from,omitempty"` Gas hexutil.Uint64 `json:"gas"` GasPrice *hexutil.Big `json:"gasPrice"` GasFeeCap *hexutil.Big `json:"maxFeePerGas,omitempty"` @@ -948,7 +948,7 @@ type RPCTransaction struct { Hash common.Hash `json:"hash"` Input hexutil.Bytes `json:"input"` Nonce hexutil.Uint64 `json:"nonce"` - To *common.Address `json:"to,omitempty"` + To *common.Address `json:"to,omitempty"` TransactionIndex *hexutil.Uint64 `json:"transactionIndex"` Value *hexutil.Big `json:"value"` Type hexutil.Uint64 `json:"type"` @@ -956,9 +956,9 @@ type RPCTransaction struct { ChainID *hexutil.Big `json:"chainId,omitempty"` BlobVersionedHashes []common.Hash `json:"blobVersionedHashes,omitempty"` AuthorizationList []types.SetCodeAuthorization `json:"authorizationList,omitempty"` - V *hexutil.Big `json:"v,omitempty"` - R *hexutil.Big `json:"r,omitempty"` - S *hexutil.Big `json:"s,omitempty"` + V *hexutil.Big `json:"v,omitempty"` + R *hexutil.Big `json:"r,omitempty"` + S *hexutil.Big `json:"s,omitempty"` YParity *hexutil.Uint64 `json:"yParity,omitempty"` // Introduced by RIP-7560 Transaction @@ -1058,7 +1058,7 @@ func newRPCTransaction(tx *types.Transaction, blockHash common.Hash, blockNumber result.NonceKey = (*hexutil.Big)(rip7560Tx.NonceKey) result.Input = make(hexutil.Bytes, 0) result.Sender = rip7560Tx.Sender - result.AuthorizationData = toBytes(rip7560Tx.AuthorizationData) + result.AuthorizationData = toBytes(rip7560Tx.SenderValidationData) result.ExecutionData = toBytes(rip7560Tx.ExecutionData) result.Gas = hexutil.Uint64(tx.Gas()) result.Paymaster = rip7560Tx.Paymaster @@ -1068,7 +1068,7 @@ func newRPCTransaction(tx *types.Transaction, blockHash common.Hash, blockNumber result.BuilderFee = (*hexutil.Big)(rip7560Tx.BuilderFee) result.ValidationGas = (*hexutil.Uint64)(&rip7560Tx.ValidationGasLimit) result.PaymasterValidationGasLimit = conditional_uint64(rip7560Tx.PaymasterValidationGasLimit, rip7560Tx.Paymaster) - result.PostOpGas = conditional_uint64(rip7560Tx.PostOpGas, rip7560Tx.Paymaster) + result.PostOpGas = conditional_uint64(rip7560Tx.PostOpGasLimit, rip7560Tx.Paymaster) //shared fields with DynamicFeeTxType result.ChainID = (*hexutil.Big)(tx.ChainId()) diff --git a/internal/ethapi/transaction_args.go b/internal/ethapi/transaction_args.go index e359650e974a..ccfe11d6ea8e 100644 --- a/internal/ethapi/transaction_args.go +++ b/internal/ethapi/transaction_args.go @@ -557,7 +557,7 @@ func (args *TransactionArgs) ToTransaction(defaultType int) *types.Transaction { AccessList: al, // RIP-7560 parameters Sender: args.Sender, - AuthorizationData: *args.AuthorizationData, + SenderValidationData: *args.AuthorizationData, Paymaster: args.Paymaster, PaymasterData: *args.PaymasterData, Deployer: args.Deployer, @@ -565,7 +565,7 @@ func (args *TransactionArgs) ToTransaction(defaultType int) *types.Transaction { BuilderFee: (*big.Int)(args.BuilderFee), ValidationGasLimit: toUint64(args.ValidationGas), PaymasterValidationGasLimit: toUint64(args.PaymasterGas), - PostOpGas: toUint64(args.PostOpGas), + PostOpGasLimit: toUint64(args.PostOpGas), } zeroAddress := common.Address{}