Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 29 additions & 18 deletions internal/ethapi/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -1618,26 +1623,26 @@ 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) {
// revert(0, 0)
// }
// }
// }
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{{
Expand All @@ -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",
}},
Expand All @@ -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,
Expand All @@ -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),
},
Expand All @@ -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),
}},
}},
Expand All @@ -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",
Expand Down Expand Up @@ -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),
}},
}},
Expand All @@ -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",
Expand All @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions internal/ethapi/simulate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
20 changes: 19 additions & 1 deletion internal/ethapi/transaction_args.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down