diff --git a/internal/ethapi/api_test.go b/internal/ethapi/api_test.go index f7a12fa38..2ee60a0ce 100644 --- a/internal/ethapi/api_test.go +++ b/internal/ethapi/api_test.go @@ -1029,6 +1029,10 @@ func TestSimulateV1(t *testing.T) { } sha256Address = common.BytesToAddress([]byte{0x02}) ) + + // Enable Venoki hardfork to enable basefee + genesis.Config.VenokiBlock = big.NewInt(0) + api := NewPublicBlockChainAPI(newTestBackend(t, genBlocks, genesis, ethash.NewFaker(), func(i int, b *core.BlockGen) { b.SetCoinbase(common.HexToAddress(coinbase)) // Transfer from account[0] to account[1] @@ -1091,6 +1095,7 @@ func TestSimulateV1(t *testing.T) { validation *bool expectErr error want []blockRes + skip bool }{ // State build-up over calls: // First value transfer OK after state @@ -1570,12 +1575,12 @@ func TestSimulateV1(t *testing.T) { want: []blockRes{{ Number: "0xb", GasLimit: "0x47e7c4", - GasUsed: "0x77dc", + GasUsed: "0xd984", Miner: coinbase, BaseFeePerGas: "0x0", Calls: []callRes{{ ReturnValue: "0x", - GasUsed: "0x77dc", + GasUsed: "0xd984", Logs: []log{{ Address: transferAddress, Topics: []common.Hash{ @@ -1618,7 +1623,7 @@ func TestSimulateV1(t *testing.T) { // if gt(balance(cac), 0) { // revert(0, 0) // } - // if gt(extcodesize(cac), 0) { + // if eq(extcodesize(cac), 0) { // After EIP-6780, code not be deleted // revert(0, 0) // } // if eq(balance(dad), 0) { @@ -1626,18 +1631,18 @@ func TestSimulateV1(t *testing.T) { // } // } // } - Input: hex2Bytes("610cac610dad600082311115601357600080fd5b6000823b1115602157600080fd5b6000813103602e57600080fd5b5050"), + Input: hex2Bytes("610cac610dad905f8131116025575f903b146021575f903114601d57005b5f80fd5b5f80fd5b5f80fd"), }}, }, { Calls: []TransactionArgs{{ From: &accounts[0].addr, - Input: hex2Bytes("610cac610dad600082311115601357600080fd5b6000823b1115602157600080fd5b6000813103602e57600080fd5b5050"), + Input: hex2Bytes("610cac610dad905f8131116025575f903b146021575f903114601d57005b5f80fd5b5f80fd5b5f80fd"), }}, }}, want: []blockRes{{ Number: "0xb", GasLimit: "0x47e7c4", - GasUsed: "0x1b83f", + GasUsed: "0x1b7ee", Miner: coinbase, BaseFeePerGas: "0x0", Calls: []callRes{{ @@ -1647,19 +1652,19 @@ func TestSimulateV1(t *testing.T) { Status: "0x1", }, { ReturnValue: "0x", - GasUsed: "0xe6d9", + GasUsed: "0xe688", Logs: []log{}, Status: "0x1", }}, }, { Number: "0xc", GasLimit: "0x47e7c4", - GasUsed: "0xe6d9", + GasUsed: "0xe688", Miner: coinbase, BaseFeePerGas: "0x0", Calls: []callRes{{ ReturnValue: "0x", - GasUsed: "0xe6d9", + GasUsed: "0xe688", Logs: []log{}, Status: "0x1", }}, @@ -1671,9 +1676,10 @@ func TestSimulateV1(t *testing.T) { tag: latest, blocks: []simBlock{{ Calls: []TransactionArgs{{ - From: &accounts[2].addr, - To: &cac, - Nonce: newUint64(2), + From: &accounts[2].addr, + To: &cac, + Nonce: newUint64(2), + MaxFeePerGas: newInt(1000000000), }}, }}, validation: &validation, @@ -1684,10 +1690,11 @@ func TestSimulateV1(t *testing.T) { { name: "validation-checks-from-contract", tag: latest, + skip: true, // This require eip-7702 enabled to pass blocks: []simBlock{{ StateOverrides: &StateOverride{ randomAccounts[2].addr: OverrideAccount{ - Balance: newRPCBalance(big.NewInt(2098640803896784)), + Balance: newRPCBalance(big.NewInt(4712388000000000)), Code: hex2Bytes("00"), Nonce: newUint64(1), }, @@ -1696,7 +1703,7 @@ func TestSimulateV1(t *testing.T) { From: &randomAccounts[2].addr, To: &cac, Nonce: newUint64(1), - MaxFeePerGas: newInt(233138868), + MaxFeePerGas: newInt(1000000000), MaxPriorityFeePerGas: newInt(1), }}, }}, @@ -1706,7 +1713,7 @@ func TestSimulateV1(t *testing.T) { GasLimit: "0x47e7c4", GasUsed: "0xd166", Miner: coinbase, - BaseFeePerGas: "0xde56ab3", + BaseFeePerGas: "0x3b9aca00", Calls: []callRes{{ ReturnValue: "0x", GasUsed: "0xd166", @@ -2071,7 +2078,7 @@ func TestSimulateV1(t *testing.T) { Calls: []TransactionArgs{{ From: &accounts[0].addr, To: &randomAccounts[2].addr, - MaxFeePerGas: newInt(233138868), + MaxFeePerGas: newInt(1000000000), MaxPriorityFeePerGas: newInt(1), }}, }}, @@ -2081,9 +2088,9 @@ func TestSimulateV1(t *testing.T) { GasLimit: "0x47e7c4", GasUsed: "0x5227", Miner: coinbase, - BaseFeePerGas: "0xde56ab3", + BaseFeePerGas: "0x3b9aca00", Calls: []callRes{{ - ReturnValue: "0x000000000000000000000000000000000000000000000000000000000de56ab4000000000000000000000000000000000000000000000000000000000de56ab3", + ReturnValue: "0x000000000000000000000000000000000000000000000000000000003b9aca00000000000000000000000000000000000000000000000000000000003b9aca00", GasUsed: "0x5227", Logs: []log{}, Status: "0x1", @@ -2093,6 +2100,10 @@ func TestSimulateV1(t *testing.T) { } for _, tc := range testSuite { + if tc.skip { + continue + } + t.Run(tc.name, func(t *testing.T) { opts := simOpts{BlockStateCalls: tc.blocks} if tc.includeTransfers != nil && *tc.includeTransfers { diff --git a/internal/ethapi/simulate.go b/internal/ethapi/simulate.go index f7918e276..3f27b2401 100644 --- a/internal/ethapi/simulate.go +++ b/internal/ethapi/simulate.go @@ -304,6 +304,7 @@ func (sim *simulator) processBlock(ctx context.Context, block *simBlock, header, sim.state.SetTxContext(txHash, i) // EoA check is always skipped, even in validation mode. msg, err := call.ToMessage(sim.base.GasLimit, header.BaseFee) + msg.SkipAccountChecks = !sim.validate if err != nil { return nil, nil, nil, err } diff --git a/internal/ethapi/transaction_args.go b/internal/ethapi/transaction_args.go index 7f3d2aba9..2ea187f64 100644 --- a/internal/ethapi/transaction_args.go +++ b/internal/ethapi/transaction_args.go @@ -294,7 +294,25 @@ func (args *TransactionArgs) ToMessage(globalGasCap uint64, baseFee *big.Int) (* if args.BlobHashes != nil && args.BlobFeeCap == nil { args.BlobFeeCap = new(hexutil.Big) } - msg := core.NewMessage(addr, args.To, 0, value, gas, gasPrice, gasFeeCap, gasTipCap, data, accessList, true, (*big.Int)(args.BlobFeeCap), args.BlobHashes) + var nonce uint64 + if args.Nonce != nil { + nonce = uint64(*args.Nonce) + } + msg := core.NewMessage( + addr, + args.To, + nonce, + value, + gas, + gasPrice, + gasFeeCap, + gasTipCap, + data, + accessList, + true, + (*big.Int)(args.BlobFeeCap), + args.BlobHashes, + ) return msg, nil }