mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
Fix issue: charging 'from' address (EntryPoint) for inner frames gas
This commit is contained in:
parent
c6fc74b5f8
commit
28a79ec98d
3 changed files with 20 additions and 14 deletions
|
|
@ -68,7 +68,10 @@ 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, isEIP3860 bool) (uint64, error) {
|
||||
func IntrinsicGas(data []byte, accessList types.AccessList, isContractCreation bool, isHomestead, isEIP2028, isEIP3860 bool, isRIP7560InnerFrame ...bool) (uint64, error) {
|
||||
if isRIP7560InnerFrame != nil && len(isRIP7560InnerFrame) > 0 && isRIP7560InnerFrame[0] {
|
||||
return 0, nil
|
||||
}
|
||||
// Set the starting gas for the raw transaction
|
||||
var gas uint64
|
||||
if isContractCreation && isHomestead {
|
||||
|
|
@ -358,6 +361,15 @@ func (st *StateTransition) preCheck() error {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// no need to "buy gus" for individual frames
|
||||
// there is a single shared gas pre-charge
|
||||
if st.rip7560Frame {
|
||||
st.gasRemaining += st.msg.GasLimit
|
||||
st.initialGas = st.msg.GasLimit
|
||||
return nil
|
||||
}
|
||||
|
||||
return st.buyGas()
|
||||
}
|
||||
|
||||
|
|
@ -395,7 +407,7 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) {
|
|||
)
|
||||
|
||||
// Check clauses 4-5, subtract intrinsic gas if everything is correct
|
||||
gas, err := IntrinsicGas(msg.Data, msg.AccessList, contractCreation, rules.IsHomestead, rules.IsIstanbul, rules.IsShanghai)
|
||||
gas, err := IntrinsicGas(msg.Data, msg.AccessList, contractCreation, rules.IsHomestead, rules.IsIstanbul, rules.IsShanghai, msg.IsRip7560Frame)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,11 +24,8 @@ import (
|
|||
"math/big"
|
||||
)
|
||||
|
||||
const ScaTransactionSubtype = 0x01
|
||||
|
||||
// Rip7560AccountAbstractionTx represents an RIP-7560 transaction.
|
||||
type Rip7560AccountAbstractionTx struct {
|
||||
Subtype byte
|
||||
// overlapping fields
|
||||
ChainID *big.Int
|
||||
GasTipCap *big.Int // a.k.a. maxPriorityFeePerGas
|
||||
|
|
@ -56,7 +53,6 @@ type Rip7560AccountAbstractionTx struct {
|
|||
// copy creates a deep copy of the transaction data and initializes all fields.
|
||||
func (tx *Rip7560AccountAbstractionTx) copy() TxData {
|
||||
cpy := &Rip7560AccountAbstractionTx{
|
||||
Subtype: tx.Subtype,
|
||||
To: copyAddressPtr(tx.To),
|
||||
Data: common.CopyBytes(tx.Data),
|
||||
Gas: tx.Gas,
|
||||
|
|
@ -128,14 +124,12 @@ func (tx *Rip7560AccountAbstractionTx) setSignatureValues(chainID, v, r, s *big.
|
|||
|
||||
// encode the subtype byte and the payload-bearing bytes of the RIP-7560 transaction
|
||||
func (tx *Rip7560AccountAbstractionTx) encode(b *bytes.Buffer) error {
|
||||
b.WriteByte(ScaTransactionSubtype)
|
||||
return rlp.Encode(b, tx)
|
||||
}
|
||||
|
||||
// decode the payload-bearing bytes of the encoded RIP-7560 transaction payload
|
||||
func (tx *Rip7560AccountAbstractionTx) decode(input []byte) error {
|
||||
tx.Subtype = ScaTransactionSubtype
|
||||
return rlp.DecodeBytes(input[1:], tx)
|
||||
return rlp.DecodeBytes(input, tx)
|
||||
}
|
||||
|
||||
// Rip7560Transaction an equivalent of a solidity struct only used to encode the 'transaction' parameter
|
||||
|
|
|
|||
|
|
@ -76,7 +76,6 @@ type TransactionArgs struct {
|
|||
blobSidecarAllowed bool
|
||||
|
||||
// Introduced by RIP-7560 Transaction
|
||||
Subtype *hexutil.Uint64
|
||||
Sender *common.Address `json:"sender"`
|
||||
Signature *hexutil.Bytes
|
||||
PaymasterData *hexutil.Bytes `json:"paymasterData"`
|
||||
|
|
@ -84,6 +83,7 @@ type TransactionArgs struct {
|
|||
BuilderFee *hexutil.Big
|
||||
ValidationGas *hexutil.Uint64
|
||||
PaymasterGas *hexutil.Uint64
|
||||
PostOpGas *hexutil.Uint64
|
||||
}
|
||||
|
||||
// from retrieves the transaction sender address.
|
||||
|
|
@ -488,7 +488,6 @@ func (args *TransactionArgs) ToTransaction() *types.Transaction {
|
|||
al = *args.AccessList
|
||||
}
|
||||
aatx := types.Rip7560AccountAbstractionTx{
|
||||
Subtype: byte(*args.Subtype),
|
||||
To: &common.Address{},
|
||||
ChainID: (*big.Int)(args.ChainID),
|
||||
Gas: uint64(*args.Gas),
|
||||
|
|
@ -505,6 +504,7 @@ func (args *TransactionArgs) ToTransaction() *types.Transaction {
|
|||
BuilderFee: (*big.Int)(args.BuilderFee),
|
||||
ValidationGas: uint64(*args.ValidationGas),
|
||||
PaymasterGas: uint64(*args.PaymasterGas),
|
||||
PostOpGas: uint64(*args.PostOpGas),
|
||||
}
|
||||
data = &aatx
|
||||
hash := types.NewTx(data).Hash()
|
||||
|
|
|
|||
Loading…
Reference in a new issue