mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 10:22:23 +00:00
Renaming, Adding tstore/tload support
This commit is contained in:
parent
9bb4fb0328
commit
fb55ee2446
9 changed files with 166 additions and 158 deletions
|
|
@ -136,7 +136,7 @@ func handleRip7560Transactions(transactions []*types.Transaction, index int, sta
|
|||
// todo: move to a suitable interface, whatever that is
|
||||
// todo 2: maybe handle the "shared gas pool" situation instead of just overriding it completely?
|
||||
func BuyGasRip7560Transaction(st *types.Rip7560AccountAbstractionTx, state vm.StateDB) error {
|
||||
gasLimit := st.Gas + st.ValidationGas + st.PaymasterGas + st.PostOpGas
|
||||
gasLimit := st.Gas + st.ValidationGasLimit + st.PaymasterValidationGasLimit + st.PostOpGas
|
||||
mgval := new(uint256.Int).SetUint64(gasLimit)
|
||||
gasFeeCap, _ := uint256.FromBig(st.GasFeeCap)
|
||||
mgval = mgval.Mul(mgval, gasFeeCap)
|
||||
|
|
@ -358,7 +358,7 @@ func prepareDeployerMessage(baseTx *types.Transaction, config *params.ChainConfi
|
|||
From: config.DeployerCallerAddress,
|
||||
To: tx.Deployer,
|
||||
Value: big.NewInt(0),
|
||||
GasLimit: tx.ValidationGas,
|
||||
GasLimit: tx.ValidationGasLimit,
|
||||
GasPrice: tx.GasFeeCap,
|
||||
GasFeeCap: tx.GasFeeCap,
|
||||
GasTipCap: tx.GasTipCap,
|
||||
|
|
@ -385,7 +385,7 @@ func prepareAccountValidationMessage(baseTx *types.Transaction, chainConfig *par
|
|||
From: chainConfig.EntryPointAddress,
|
||||
To: tx.Sender,
|
||||
Value: big.NewInt(0),
|
||||
GasLimit: tx.ValidationGas - deploymentUsedGas,
|
||||
GasLimit: tx.ValidationGasLimit - deploymentUsedGas,
|
||||
GasPrice: tx.GasFeeCap,
|
||||
GasFeeCap: tx.GasFeeCap,
|
||||
GasTipCap: tx.GasTipCap,
|
||||
|
|
@ -416,7 +416,7 @@ func preparePaymasterValidationMessage(baseTx *types.Transaction, config *params
|
|||
From: config.EntryPointAddress,
|
||||
To: tx.Paymaster,
|
||||
Value: big.NewInt(0),
|
||||
GasLimit: tx.PaymasterGas,
|
||||
GasLimit: tx.PaymasterValidationGasLimit,
|
||||
GasPrice: tx.GasFeeCap,
|
||||
GasFeeCap: tx.GasFeeCap,
|
||||
GasTipCap: tx.GasTipCap,
|
||||
|
|
@ -465,7 +465,7 @@ func preparePostOpMessage(vpr *ValidationPhaseResult, chainConfig *params.ChainC
|
|||
From: chainConfig.EntryPointAddress,
|
||||
To: tx.Paymaster,
|
||||
Value: big.NewInt(0),
|
||||
GasLimit: tx.PaymasterGas - executionResult.UsedGas,
|
||||
GasLimit: tx.PaymasterValidationGasLimit - executionResult.UsedGas,
|
||||
GasPrice: tx.GasFeeCap,
|
||||
GasFeeCap: tx.GasFeeCap,
|
||||
GasTipCap: tx.GasTipCap,
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ func (s rip7560Signer) Hash(tx *Transaction) common.Hash {
|
|||
aatx.PaymasterData,
|
||||
aatx.DeployerData,
|
||||
aatx.BuilderFee,
|
||||
aatx.ValidationGas,
|
||||
aatx.PaymasterGas,
|
||||
aatx.ValidationGasLimit,
|
||||
aatx.PaymasterValidationGasLimit,
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,8 +42,8 @@ type Rip7560AccountAbstractionTx struct {
|
|||
Deployer *common.Address `rlp:"nil"`
|
||||
DeployerData []byte
|
||||
BuilderFee *big.Int
|
||||
ValidationGas uint64
|
||||
PaymasterGas uint64
|
||||
ValidationGasLimit uint64
|
||||
PaymasterValidationGasLimit uint64
|
||||
PostOpGas uint64
|
||||
|
||||
// removed fields
|
||||
|
|
@ -73,8 +73,8 @@ func (tx *Rip7560AccountAbstractionTx) copy() TxData {
|
|||
Deployer: copyAddressPtr(tx.Deployer),
|
||||
DeployerData: common.CopyBytes(tx.DeployerData),
|
||||
BuilderFee: new(big.Int),
|
||||
ValidationGas: tx.ValidationGas,
|
||||
PaymasterGas: tx.PaymasterGas,
|
||||
ValidationGasLimit: tx.ValidationGasLimit,
|
||||
PaymasterValidationGasLimit: tx.PaymasterValidationGasLimit,
|
||||
PostOpGas: tx.PostOpGas,
|
||||
}
|
||||
copy(cpy.AccessList, tx.AccessList)
|
||||
|
|
@ -143,7 +143,7 @@ type Rip7560Transaction struct {
|
|||
Sender common.Address
|
||||
Nonce *big.Int
|
||||
ValidationGasLimit *big.Int
|
||||
PaymasterGasLimit *big.Int
|
||||
PaymasterValidationGasLimit *big.Int
|
||||
PostOpGasLimit *big.Int
|
||||
CallGasLimit *big.Int
|
||||
MaxFeePerGas *big.Int
|
||||
|
|
@ -162,7 +162,7 @@ func (tx *Rip7560AccountAbstractionTx) AbiEncode() ([]byte, error) {
|
|||
{Name: "sender", Type: "address"},
|
||||
{Name: "nonce", Type: "uint256"},
|
||||
{Name: "validationGasLimit", Type: "uint256"},
|
||||
{Name: "paymasterGasLimit", Type: "uint256"},
|
||||
{Name: "paymasterValidationGasLimit", Type: "uint256"},
|
||||
{Name: "callGasLimit", Type: "uint256"},
|
||||
{Name: "maxFeePerGas", Type: "uint256"},
|
||||
{Name: "maxPriorityFeePerGas", Type: "uint256"},
|
||||
|
|
@ -179,8 +179,8 @@ func (tx *Rip7560AccountAbstractionTx) AbiEncode() ([]byte, error) {
|
|||
record := &Rip7560Transaction{
|
||||
Sender: *tx.Sender,
|
||||
Nonce: big.NewInt(int64(tx.Nonce)),
|
||||
ValidationGasLimit: big.NewInt(int64(tx.ValidationGas)),
|
||||
PaymasterGasLimit: big.NewInt(int64(tx.PaymasterGas)),
|
||||
ValidationGasLimit: big.NewInt(int64(tx.ValidationGasLimit)),
|
||||
PaymasterValidationGasLimit: big.NewInt(int64(tx.PaymasterValidationGasLimit)),
|
||||
CallGasLimit: big.NewInt(int64(tx.Gas)),
|
||||
MaxFeePerGas: tx.GasFeeCap,
|
||||
MaxPriorityFeePerGas: tx.GasTipCap,
|
||||
|
|
|
|||
|
|
@ -35,6 +35,8 @@ type contractSizeVal struct {
|
|||
type access struct {
|
||||
Reads map[string]string `json:"reads"`
|
||||
Writes map[string]uint64 `json:"writes"`
|
||||
TransientReads map[string]uint64 `json:"transientReads"`
|
||||
TransientWrites map[string]uint64 `json:"transientWrites"`
|
||||
}
|
||||
|
||||
// note - this means an individual 'frame' in 7560 (validate, execute, postOp)
|
||||
|
|
@ -251,7 +253,7 @@ func (b *rip7560ValidationTracer) OnOpcode(pc uint64, op byte, gas, cost uint64,
|
|||
}
|
||||
b.lastOp = opcode
|
||||
|
||||
if opcode == "SLOAD" || opcode == "SSTORE" {
|
||||
if opcode == "SLOAD" || opcode == "SSTORE" || opcode == "TLOAD" || opcode == "TSTORE" {
|
||||
slot := common.BytesToHash(StackBack(scope.StackData(), 0).Bytes())
|
||||
slotHex := slot.Hex()
|
||||
addr := scope.Address()
|
||||
|
|
@ -259,6 +261,8 @@ func (b *rip7560ValidationTracer) OnOpcode(pc uint64, op byte, gas, cost uint64,
|
|||
b.CurrentLevel.Access[addr] = &access{
|
||||
Reads: map[string]string{},
|
||||
Writes: map[string]uint64{},
|
||||
TransientReads: map[string]uint64{},
|
||||
TransientWrites: map[string]uint64{},
|
||||
}
|
||||
}
|
||||
access := *b.CurrentLevel.Access[addr]
|
||||
|
|
@ -271,8 +275,12 @@ func (b *rip7560ValidationTracer) OnOpcode(pc uint64, op byte, gas, cost uint64,
|
|||
if !rOk && !wOk {
|
||||
access.Reads[slotHex] = b.env.StateDB.GetState(addr, slot).Hex()
|
||||
}
|
||||
} else {
|
||||
} else if opcode == "STORE" {
|
||||
b.incrementCount(access.Writes, slotHex)
|
||||
} else if opcode == "TLOAD" {
|
||||
b.incrementCount(access.TransientReads, slotHex)
|
||||
} else if opcode == "TSTORE" {
|
||||
b.incrementCount(access.TransientWrites, slotHex)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -507,8 +507,8 @@ func (args *TransactionArgs) ToTransaction() *types.Transaction {
|
|||
Deployer: args.Deployer,
|
||||
DeployerData: *args.DeployerData,
|
||||
BuilderFee: (*big.Int)(args.BuilderFee),
|
||||
ValidationGas: uint64(*args.ValidationGas),
|
||||
PaymasterGas: uint64(*args.PaymasterGas),
|
||||
ValidationGasLimit: uint64(*args.ValidationGas),
|
||||
PaymasterValidationGasLimit: uint64(*args.PaymasterGas),
|
||||
PostOpGas: uint64(*args.PostOpGas),
|
||||
}
|
||||
data = &aatx
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ func TestValidationFailure_deployerRevert(t *testing.T) {
|
|||
withCode(DEPLOYER.Hex(), revertWithData([]byte{}), 0),
|
||||
types.Rip7560AccountAbstractionTx{
|
||||
Deployer: &DEPLOYER,
|
||||
ValidationGas: 1000000000,
|
||||
ValidationGasLimit: 1000000000,
|
||||
GasFeeCap: big.NewInt(1000000000),
|
||||
}, "account deployment failed: execution reverted")
|
||||
}
|
||||
|
|
@ -26,7 +26,7 @@ func TestValidationFailure_deployerOOG(t *testing.T) {
|
|||
withCode(DEPLOYER.Hex(), revertWithData([]byte{}), 0),
|
||||
types.Rip7560AccountAbstractionTx{
|
||||
Deployer: &DEPLOYER,
|
||||
ValidationGas: 1,
|
||||
ValidationGasLimit: 1,
|
||||
GasFeeCap: big.NewInt(1000000000),
|
||||
}, "account deployment failed: out of gas")
|
||||
}
|
||||
|
|
@ -37,7 +37,7 @@ func TestValidationFailure_senderNotDeployed(t *testing.T) {
|
|||
withCode(DEPLOYER.Hex(), returnWithData([]byte{}), 0),
|
||||
types.Rip7560AccountAbstractionTx{
|
||||
Deployer: &DEPLOYER,
|
||||
ValidationGas: 1000000000,
|
||||
ValidationGasLimit: 1000000000,
|
||||
GasFeeCap: big.NewInt(1000000000),
|
||||
}, "account deployment failed: sender not deployed")
|
||||
}
|
||||
|
|
@ -52,7 +52,7 @@ func TestValidationFailure_senderAlreadyDeployed(t *testing.T) {
|
|||
types.Rip7560AccountAbstractionTx{
|
||||
Sender: &sender,
|
||||
Deployer: &DEPLOYER,
|
||||
ValidationGas: 1000000000,
|
||||
ValidationGasLimit: 1000000000,
|
||||
GasFeeCap: big.NewInt(1000000000),
|
||||
}, "account deployment failed: sender already deployed")
|
||||
}
|
||||
|
|
@ -67,7 +67,7 @@ func TestValidationFailure_senderReverts(t *testing.T) {
|
|||
types.Rip7560AccountAbstractionTx{
|
||||
Sender: &sender,
|
||||
Deployer: &DEPLOYER,
|
||||
ValidationGas: 1000000000,
|
||||
ValidationGasLimit: 1000000000,
|
||||
GasFeeCap: big.NewInt(1000000000),
|
||||
}, "execution reverted")
|
||||
}
|
||||
|
|
@ -82,7 +82,7 @@ func TestValidation_deployer_ok(t *testing.T) {
|
|||
types.Rip7560AccountAbstractionTx{
|
||||
Sender: &sender,
|
||||
Deployer: &DEPLOYER,
|
||||
ValidationGas: 1000000000,
|
||||
ValidationGasLimit: 1000000000,
|
||||
GasFeeCap: big.NewInt(1000000000),
|
||||
}, "ok")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ func TestPaymasterValidationFailure_nobalance(t *testing.T) {
|
|||
|
||||
handleTransaction(newTestContextBuilder(t).withCode(DEFAULT_SENDER, createAccountCode(), 0).
|
||||
withCode(DEFAULT_PAYMASTER.String(), createCode(vm.PUSH0, vm.DUP1, vm.REVERT), 1), types.Rip7560AccountAbstractionTx{
|
||||
ValidationGas: 1000000000,
|
||||
ValidationGasLimit: 1000000000,
|
||||
GasFeeCap: big.NewInt(1000000000),
|
||||
Paymaster: &DEFAULT_PAYMASTER,
|
||||
}, "insufficient funds for gas * price + value: address 0xaaAaaAAAAAbBbbbbBbBBCCCCcCCCcCdddDDDdddd have 1 want 1000000000000000000")
|
||||
|
|
@ -25,7 +25,7 @@ func TestPaymasterValidationFailure_oog(t *testing.T) {
|
|||
|
||||
handleTransaction(newTestContextBuilder(t).withCode(DEFAULT_SENDER, createAccountCode(), 0).
|
||||
withCode(DEFAULT_PAYMASTER.String(), createCode(vm.PUSH0, vm.DUP1, vm.REVERT), DEFAULT_BALANCE), types.Rip7560AccountAbstractionTx{
|
||||
ValidationGas: 1000000000,
|
||||
ValidationGasLimit: 1000000000,
|
||||
GasFeeCap: big.NewInt(1000000000),
|
||||
Paymaster: &DEFAULT_PAYMASTER,
|
||||
}, "out of gas")
|
||||
|
|
@ -34,10 +34,10 @@ func TestPaymasterValidationFailure_revert(t *testing.T) {
|
|||
|
||||
handleTransaction(newTestContextBuilder(t).withCode(DEFAULT_SENDER, createAccountCode(), 0).
|
||||
withCode(DEFAULT_PAYMASTER.String(), createCode(vm.PUSH0, vm.DUP1, vm.REVERT), DEFAULT_BALANCE), types.Rip7560AccountAbstractionTx{
|
||||
ValidationGas: uint64(1000000000),
|
||||
ValidationGasLimit: uint64(1000000000),
|
||||
GasFeeCap: big.NewInt(1000000000),
|
||||
Paymaster: &DEFAULT_PAYMASTER,
|
||||
PaymasterGas: 1000000000,
|
||||
PaymasterValidationGasLimit: 1000000000,
|
||||
}, "execution reverted")
|
||||
}
|
||||
|
||||
|
|
@ -45,8 +45,8 @@ func TestPaymasterValidationFailure_unparseable_return_value(t *testing.T) {
|
|||
|
||||
handleTransaction(newTestContextBuilder(t).withCode(DEFAULT_SENDER, createAccountCode(), 0).
|
||||
withCode(DEFAULT_PAYMASTER.String(), createAccountCode(), DEFAULT_BALANCE), types.Rip7560AccountAbstractionTx{
|
||||
ValidationGas: 1000000000,
|
||||
PaymasterGas: 1000000000,
|
||||
ValidationGasLimit: 1000000000,
|
||||
PaymasterValidationGasLimit: 1000000000,
|
||||
GasFeeCap: big.NewInt(1000000000),
|
||||
Paymaster: &DEFAULT_PAYMASTER,
|
||||
}, "paymaster return data: too short")
|
||||
|
|
@ -55,8 +55,8 @@ func TestPaymasterValidationFailure_unparseable_return_value(t *testing.T) {
|
|||
func TestPaymasterValidationFailure_wrong_magic(t *testing.T) {
|
||||
handleTransaction(newTestContextBuilder(t).withCode(DEFAULT_SENDER, createAccountCode(), 0).
|
||||
withCode(DEFAULT_PAYMASTER.String(), returnWithData(paymasterReturnValue(1, 2, 3, []byte{})), DEFAULT_BALANCE), types.Rip7560AccountAbstractionTx{
|
||||
ValidationGas: 1000000000,
|
||||
PaymasterGas: 1000000000,
|
||||
ValidationGasLimit: 1000000000,
|
||||
PaymasterValidationGasLimit: 1000000000,
|
||||
GasFeeCap: big.NewInt(1000000000),
|
||||
Paymaster: &DEFAULT_PAYMASTER,
|
||||
}, "paymaster did not return correct MAGIC_VALUE")
|
||||
|
|
@ -77,8 +77,8 @@ func TestPaymasterValidationFailure_contextTooLarge(t *testing.T) {
|
|||
|
||||
handleTransaction(newTestContextBuilder(t).withCode(DEFAULT_SENDER, createAccountCode(), 0).
|
||||
withCode(DEFAULT_PAYMASTER.String(), pmCode, DEFAULT_BALANCE), types.Rip7560AccountAbstractionTx{
|
||||
ValidationGas: 1000000000,
|
||||
PaymasterGas: 1000000000,
|
||||
ValidationGasLimit: 1000000000,
|
||||
PaymasterValidationGasLimit: 1000000000,
|
||||
GasFeeCap: big.NewInt(1000000000),
|
||||
Paymaster: &DEFAULT_PAYMASTER,
|
||||
}, "paymaster return data: context too large")
|
||||
|
|
@ -87,8 +87,8 @@ func TestPaymasterValidationFailure_contextTooLarge(t *testing.T) {
|
|||
func TestPaymasterValidationFailure_validAfter(t *testing.T) {
|
||||
handleTransaction(newTestContextBuilder(t).withCode(DEFAULT_SENDER, createAccountCode(), 0).
|
||||
withCode(DEFAULT_PAYMASTER.String(), returnWithData(paymasterReturnValue(core.MAGIC_VALUE_PAYMASTER, 300, 200, []byte{})), DEFAULT_BALANCE), types.Rip7560AccountAbstractionTx{
|
||||
ValidationGas: 1000000000,
|
||||
PaymasterGas: 1000000000,
|
||||
ValidationGasLimit: 1000000000,
|
||||
PaymasterValidationGasLimit: 1000000000,
|
||||
GasFeeCap: big.NewInt(1000000000),
|
||||
Paymaster: &DEFAULT_PAYMASTER,
|
||||
}, "RIP-7560 transaction validity not reached yet")
|
||||
|
|
@ -97,8 +97,8 @@ func TestPaymasterValidationFailure_validAfter(t *testing.T) {
|
|||
func TestPaymasterValidationFailure_validUntil(t *testing.T) {
|
||||
handleTransaction(newTestContextBuilder(t).withCode(DEFAULT_SENDER, createAccountCode(), 0).
|
||||
withCode(DEFAULT_PAYMASTER.String(), returnWithData(paymasterReturnValue(core.MAGIC_VALUE_PAYMASTER, 1, 0, []byte{})), DEFAULT_BALANCE), types.Rip7560AccountAbstractionTx{
|
||||
ValidationGas: 1000000000,
|
||||
PaymasterGas: 1000000000,
|
||||
ValidationGasLimit: 1000000000,
|
||||
PaymasterValidationGasLimit: 1000000000,
|
||||
GasFeeCap: big.NewInt(1000000000),
|
||||
Paymaster: &DEFAULT_PAYMASTER,
|
||||
}, "RIP-7560 transaction validity expired")
|
||||
|
|
@ -107,8 +107,8 @@ func TestPaymasterValidationFailure_validUntil(t *testing.T) {
|
|||
func TestPaymasterValidation_ok(t *testing.T) {
|
||||
handleTransaction(newTestContextBuilder(t).withCode(DEFAULT_SENDER, createAccountCode(), 0).
|
||||
withCode(DEFAULT_PAYMASTER.String(), returnWithData(paymasterReturnValue(core.MAGIC_VALUE_PAYMASTER, 0, 0, []byte{})), DEFAULT_BALANCE), types.Rip7560AccountAbstractionTx{
|
||||
ValidationGas: 1000000000,
|
||||
PaymasterGas: 1000000000,
|
||||
ValidationGasLimit: 1000000000,
|
||||
PaymasterValidationGasLimit: 1000000000,
|
||||
GasFeeCap: big.NewInt(1000000000),
|
||||
Paymaster: &DEFAULT_PAYMASTER,
|
||||
}, "ok")
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ func TestProcess1(t *testing.T) {
|
|||
build(), []*types.Rip7560AccountAbstractionTx{
|
||||
{
|
||||
Sender: &Sender,
|
||||
ValidationGas: uint64(1000000000),
|
||||
ValidationGasLimit: uint64(1000000000),
|
||||
GasFeeCap: big.NewInt(1000000000),
|
||||
Data: []byte{1, 2, 3},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ func TestUnpackValidationData(t *testing.T) {
|
|||
func TestValidationFailure_OOG(t *testing.T) {
|
||||
|
||||
handleTransaction(newTestContextBuilder(t).withCode(DEFAULT_SENDER, createAccountCode(), DEFAULT_BALANCE), types.Rip7560AccountAbstractionTx{
|
||||
ValidationGas: uint64(1),
|
||||
ValidationGasLimit: uint64(1),
|
||||
GasFeeCap: big.NewInt(1000000000),
|
||||
}, "out of gas")
|
||||
}
|
||||
|
|
@ -38,14 +38,14 @@ func TestValidationFailure_OOG(t *testing.T) {
|
|||
func TestValidationFailure_no_balance(t *testing.T) {
|
||||
|
||||
handleTransaction(newTestContextBuilder(t).withCode(DEFAULT_SENDER, createAccountCode(), 1), types.Rip7560AccountAbstractionTx{
|
||||
ValidationGas: uint64(1),
|
||||
ValidationGasLimit: uint64(1),
|
||||
GasFeeCap: big.NewInt(1000000000),
|
||||
}, "insufficient funds for gas * price + value: address 0x1111111111222222222233333333334444444444 have 1 want 1000000000")
|
||||
}
|
||||
|
||||
func TestValidationFailure_sigerror(t *testing.T) {
|
||||
handleTransaction(newTestContextBuilder(t).withCode(DEFAULT_SENDER, returnWithData(core.PackValidationData(core.MAGIC_VALUE_SIGFAIL, 0, 0)), DEFAULT_BALANCE), types.Rip7560AccountAbstractionTx{
|
||||
ValidationGas: uint64(1000000000),
|
||||
ValidationGasLimit: uint64(1000000000),
|
||||
GasFeeCap: big.NewInt(1000000000),
|
||||
}, "account signature error")
|
||||
}
|
||||
|
|
@ -54,7 +54,7 @@ func TestValidationFailure_validAfter(t *testing.T) {
|
|||
|
||||
handleTransaction(newTestContextBuilder(t).withCode(DEFAULT_SENDER,
|
||||
returnWithData(core.PackValidationData(core.MAGIC_VALUE_SENDER, 300, 200)), DEFAULT_BALANCE), types.Rip7560AccountAbstractionTx{
|
||||
ValidationGas: uint64(1000000000),
|
||||
ValidationGasLimit: uint64(1000000000),
|
||||
GasFeeCap: big.NewInt(1000000000),
|
||||
}, "RIP-7560 transaction validity not reached yet")
|
||||
}
|
||||
|
|
@ -63,7 +63,7 @@ func TestValidationFailure_validUntil(t *testing.T) {
|
|||
|
||||
handleTransaction(newTestContextBuilder(t).withCode(DEFAULT_SENDER,
|
||||
returnWithData(core.PackValidationData(core.MAGIC_VALUE_SENDER, 1, 0)), DEFAULT_BALANCE), types.Rip7560AccountAbstractionTx{
|
||||
ValidationGas: uint64(1000000000),
|
||||
ValidationGasLimit: uint64(1000000000),
|
||||
GasFeeCap: big.NewInt(1000000000),
|
||||
}, "RIP-7560 transaction validity expired")
|
||||
}
|
||||
|
|
@ -71,7 +71,7 @@ func TestValidationFailure_validUntil(t *testing.T) {
|
|||
func TestValidation_ok(t *testing.T) {
|
||||
|
||||
handleTransaction(newTestContextBuilder(t).withCode(DEFAULT_SENDER, createAccountCode(), DEFAULT_BALANCE), types.Rip7560AccountAbstractionTx{
|
||||
ValidationGas: uint64(1000000000),
|
||||
ValidationGasLimit: uint64(1000000000),
|
||||
GasFeeCap: big.NewInt(1000000000),
|
||||
}, "ok")
|
||||
}
|
||||
|
|
@ -79,20 +79,20 @@ func TestValidation_ok(t *testing.T) {
|
|||
func TestValidation_ok_paid(t *testing.T) {
|
||||
|
||||
aatx := types.Rip7560AccountAbstractionTx{
|
||||
ValidationGas: uint64(1000000000),
|
||||
ValidationGasLimit: uint64(1000000000),
|
||||
GasFeeCap: big.NewInt(1000000000),
|
||||
}
|
||||
tb := newTestContextBuilder(t).withCode(DEFAULT_SENDER, createAccountCode(), DEFAULT_BALANCE)
|
||||
handleTransaction(tb, aatx, "ok")
|
||||
|
||||
maxCost := new(big.Int).SetUint64(aatx.ValidationGas + aatx.PaymasterGas + aatx.Gas)
|
||||
maxCost := new(big.Int).SetUint64(aatx.ValidationGasLimit + aatx.PaymasterValidationGasLimit + aatx.Gas)
|
||||
maxCost.Mul(maxCost, aatx.GasFeeCap)
|
||||
}
|
||||
|
||||
func TestValidationFailure_account_nonce(t *testing.T) {
|
||||
handleTransaction(newTestContextBuilder(t).withCode(DEFAULT_SENDER, createAccountCode(), DEFAULT_BALANCE), types.Rip7560AccountAbstractionTx{
|
||||
Nonce: 1234,
|
||||
ValidationGas: uint64(1000000000),
|
||||
ValidationGasLimit: uint64(1000000000),
|
||||
GasFeeCap: big.NewInt(1000000000),
|
||||
}, "nonce too high: address 0x1111111111222222222233333333334444444444, tx: 1234 state: 0")
|
||||
}
|
||||
|
|
@ -100,7 +100,7 @@ func TestValidationFailure_account_nonce(t *testing.T) {
|
|||
func TestValidationFailure_account_revert(t *testing.T) {
|
||||
handleTransaction(newTestContextBuilder(t).withCode(DEFAULT_SENDER,
|
||||
createCode(vm.PUSH0, vm.DUP1, vm.REVERT), DEFAULT_BALANCE), types.Rip7560AccountAbstractionTx{
|
||||
ValidationGas: uint64(1000000000),
|
||||
ValidationGasLimit: uint64(1000000000),
|
||||
GasFeeCap: big.NewInt(1000000000),
|
||||
}, "execution reverted")
|
||||
}
|
||||
|
|
@ -110,7 +110,7 @@ func TestValidationFailure_account_revert_with_reason(t *testing.T) {
|
|||
reason := hexutils.HexToBytes("0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000568656c6c6f000000000000000000000000000000000000000000000000000000")
|
||||
handleTransaction(newTestContextBuilder(t).withCode(DEFAULT_SENDER,
|
||||
revertWithData(reason), DEFAULT_BALANCE), types.Rip7560AccountAbstractionTx{
|
||||
ValidationGas: uint64(1000000000),
|
||||
ValidationGasLimit: uint64(1000000000),
|
||||
GasFeeCap: big.NewInt(1000000000),
|
||||
}, "execution reverted")
|
||||
}
|
||||
|
|
@ -118,7 +118,7 @@ func TestValidationFailure_account_revert_with_reason(t *testing.T) {
|
|||
func TestValidationFailure_account_wrong_return_length(t *testing.T) {
|
||||
handleTransaction(newTestContextBuilder(t).withCode(DEFAULT_SENDER,
|
||||
returnWithData([]byte{1, 2, 3}), DEFAULT_BALANCE), types.Rip7560AccountAbstractionTx{
|
||||
ValidationGas: uint64(1000000000),
|
||||
ValidationGasLimit: uint64(1000000000),
|
||||
GasFeeCap: big.NewInt(1000000000),
|
||||
}, "invalid account return data length")
|
||||
}
|
||||
|
|
@ -126,7 +126,7 @@ func TestValidationFailure_account_wrong_return_length(t *testing.T) {
|
|||
func TestValidationFailure_account_no_return_value(t *testing.T) {
|
||||
handleTransaction(newTestContextBuilder(t).withCode(DEFAULT_SENDER,
|
||||
returnWithData([]byte{}), DEFAULT_BALANCE), types.Rip7560AccountAbstractionTx{
|
||||
ValidationGas: uint64(1000000000),
|
||||
ValidationGasLimit: uint64(1000000000),
|
||||
GasFeeCap: big.NewInt(1000000000),
|
||||
}, "invalid account return data length")
|
||||
}
|
||||
|
|
@ -136,7 +136,7 @@ func TestValidationFailure_account_wrong_return_value(t *testing.T) {
|
|||
handleTransaction(newTestContextBuilder(t).withCode(DEFAULT_SENDER,
|
||||
returnWithData(make([]byte, 32)),
|
||||
DEFAULT_BALANCE), types.Rip7560AccountAbstractionTx{
|
||||
ValidationGas: uint64(1000000000),
|
||||
ValidationGasLimit: uint64(1000000000),
|
||||
GasFeeCap: big.NewInt(1000000000),
|
||||
}, "account did not return correct MAGIC_VALUE")
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue