Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ethereum Execution Tests failing only when run inside the guest #52

Closed
Wollac opened this issue Nov 2, 2023 · 6 comments
Closed

Ethereum Execution Tests failing only when run inside the guest #52

Wollac opened this issue Nov 2, 2023 · 6 comments
Assignees

Comments

@Wollac
Copy link
Contributor

Wollac commented Nov 2, 2023

Currently, zeth is tested against the GeneralStateTests of ethereum/tests. However, while each of these tests is tested for correct execution on the host, only a handful of them are actually executed on the guest by default.

If you manually run all of them in the guest, some of them will fail due to a SlotNotFound panic. This happens when the EVM inside the guest tries to access storage slots that are not part of the guest's input.

Steps to reproduce

For example, the following test fails because of this issue: returndatacopy_initial_big_sum.json. To run this exact test, change the following line

#[files("testdata/BlockchainTests/GeneralStateTests/**/*Call1024BalanceTooLow.json")]

to

#[files("testdata/BlockchainTests/GeneralStateTests/stReturnDataTest/returndatacopy_initial_big_sum.json")]

This returns

[INFO  zeth_lib::execution::ethereum] Block no. 1
[INFO  zeth_lib::execution::ethereum]   EVM spec ID: MERGE
[INFO  zeth_lib::execution::ethereum]   Timestamp: 1970-01-01 00:16:40 UTC
[INFO  zeth_lib::execution::ethereum]   Transactions: 1
[INFO  zeth_lib::execution::ethereum]   Withdrawals: 0
[INFO  zeth_lib::execution::ethereum]   Fee Recipient: 0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba
[INFO  zeth_lib::execution::ethereum]   Gas limit: 111669149696
[INFO  zeth_lib::execution::ethereum]   Base fee per gas: 10
[INFO  zeth_lib::execution::ethereum]   Extra data: Bytes(0x00)
[DEBUG zeth_lib::execution::ethereum] Tx no. 0 (hash: 0xa46fe628a24d18f063fe6276ef8bca32fa7e68cd93e4b694557cebf82d027936)
[DEBUG zeth_lib::execution::ethereum]   Type: 0
[DEBUG zeth_lib::execution::ethereum]   Fr: 0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b
[DEBUG zeth_lib::execution::ethereum]   To: 0x0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6
[DEBUG zeth_lib::execution::ethereum]   Ok: Halt { reason: OutOfGas(BasicOutOfGas), gas_used: 42949672960 }
[DEBUG zeth_lib::execution::ethereum]   State 0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba (is_selfdestructed=false, is_loaded_as_not_existing=false, is_created=false, is_empty=true)
[DEBUG zeth_lib::execution::ethereum]      After balance: 0 (Nonce: 0)
[DEBUG zeth_lib::execution::ethereum]   State 0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b (is_selfdestructed=false, is_loaded_as_not_existing=false, is_created=false, is_empty=false)
[DEBUG zeth_lib::execution::ethereum]      After balance: 0 (Nonce: 1)
[INFO  zeth_lib::host] The partial state trie consists of 3 nodes
[INFO  zeth_lib::host] The partial storage tries consist of 0 nodes
[DEBUG risc0_binfmt::image] root_page_addr: 0x0d6b5800, root_addr: 0x0d6b5ac0
[INFO  risc0_zkvm::host::server::session] segment[0]> reads: 340, writes: 53, exit_code: SystemSplit, split_insn: Some(1383200), po2: 21, cycles: 1666168
thread '<unnamed>' panicked at 'Failed to build the resulting block: Error at transaction 0: Database(SlotNotFound(0x0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6, 0x0_U256))', src/main.rs:29:10

This indicates, that for this artificial case, when revm is run on the host it does not access storage slot 0x0 of account 0x0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6. However, when running in the guest, it does.

@dyxushuai
Copy link
Contributor

@Wollac I want to try this issue, May I claim this?

@Wollac
Copy link
Contributor Author

Wollac commented Dec 21, 2023

@dyxushuai Sorry for the late reply. This is a pretty tricky issue, but feel free to check it out!

@Wollac
Copy link
Contributor Author

Wollac commented Jan 16, 2024

Will be fixed when revm is updated to include bluealloy/revm#978

@dyxushuai
Copy link
Contributor

This issue was fixed by #76, I think it's time to close it.

@dyxushuai
Copy link
Contributor

This issue was fixed by #76, I think it's time to close it.

cc @Wollac

@Wollac
Copy link
Contributor Author

Wollac commented Jan 29, 2024

Yes thanks!

@Wollac Wollac closed this as completed Jan 29, 2024
johntaiko pushed a commit to johntaiko/zeth that referenced this issue Mar 19, 2024
Sp1 stuff + re-enable risc0 + invalid tx support
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants