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

chore(pevm): Post-processing lazy evaluation: assert that the evaluated nonce matches the transaction's #355

Merged
merged 3 commits into from
Sep 16, 2024

Conversation

tsnewnami
Copy link
Contributor

This PR addresses #310

@tsnewnami
Copy link
Contributor Author

Hey @hai-rise, I've tried to have a crack at this one. And I'm not sure if I've identified a bug or not (thinking possibly yes as the other MemoryValue::Basic checks pass).

The mainnet_blocks_from_disk is failing. I'd love to try and debug this more to better understand the stack, but I may need some pointers if that's okay 🙏 .

Just for my understanding of what's going on here: this is essentially validating the incarnation (tx) that resulted in the particular state mutation of an account, which is encoded in the write_history. Where the write_history holds all particular state updates for a given memory location from the resulting incarnations?

Here is the particular tx_env where this check fails:

TX TxEnv {
    caller: 0xa9cefd4474086c52f15abc0e604284440768da57,
    gas_limit: 23100,
    gas_price: 54641531805,
    transact_to: Call(
        0xcff0b829fd9bd7a58ca8d62eef8105506f859592,
    ),
    value: 500000000000000,
    data: 0x,
    nonce: Some(
        18,
    ),
    chain_id: Some(
        1,
    ),
    access_list: [],
    gas_priority_fee: Some(
        3358468195,
    ),
    blob_hashes: [],
    max_fee_per_blob_gas: None,
    authorization_list: None,
}

Tyvm.

Copy link
Contributor

@hai-rise hai-rise left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, tx.nonce only applies to the sender, while we can have the recipient (or more addresses in the future) in MemoryValue::Basic and other arms.

I think we can add this line below the match memory_entry:

debug_assert!(tx.caller != address || tx.nonce.map_or(true, |n| n + 1 == nonce));

src/pevm.rs Outdated Show resolved Hide resolved
@tsnewnami tsnewnami marked this pull request as ready for review September 16, 2024 02:28
@tsnewnami
Copy link
Contributor Author

Thank you for the feedback @hai-rise. That makes sense. Was way off the mark with that bug... Thank you for the learning here.

Copy link
Contributor

@hai-rise hai-rise left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@hai-rise hai-rise merged commit 20b6ba6 into risechain:main Sep 16, 2024
1 check passed
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

Successfully merging this pull request may close these issues.

2 participants