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

Fix trie output when debugging final root mismatch #86

Merged
merged 8 commits into from
Mar 7, 2024
Merged

Conversation

Nashtare
Copy link
Collaborator

@Nashtare Nashtare commented Mar 6, 2024

Upon Kernel failure when comparing resulting tries post txn execution, we recompute the tries that plonky2 internally calculated (if log::Level::Debug or deeper is enabled) for debugging.
However it currently fails when the receipts contain more than 1 log because of a missing offset increment. This wasn't caught when failures were encountered among the integration tests here because none of them have actual logs.

This can be tested against the log_opcode tests by adding a PANIC say before the final %jump(halt), and calling:

RUST_LOG=debug cargo test --release --test log_opcode test_log_opcodes -- --ignored

which will result in an "Computed receipts trie: Err(IntegerTooLarge)" issue.

The PR also:

  • adapts the logic so that it can be used within the CPU simulation
  • adds 3 trie specific labels during the final checks, so that the logs are more meaningful upon failure (before we would just know one root check failed, now we will know exactly which trie).

@Nashtare Nashtare added the bug Something isn't working label Mar 6, 2024
@Nashtare Nashtare requested a review from BGluth March 6, 2024 04:26
@Nashtare Nashtare self-assigned this Mar 6, 2024
@Nashtare
Copy link
Collaborator Author

Nashtare commented Mar 6, 2024

@BGluth I ended up adding some labels for the final trie checks, as we always do this locally when debugging anyway

@Nashtare Nashtare added the crate: evm_arithmetization Anything related to the evm_arithmetization crate. label Mar 6, 2024
Copy link
Contributor

@BGluth BGluth left a comment

Choose a reason for hiding this comment

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

Yeah LGTM!

Comment on lines +94 to +99
PUSH 1 // initial trie data length
global check_state_trie:
%mpt_hash_state_trie %mload_global_metadata(@GLOBAL_METADATA_STATE_TRIE_DIGEST_AFTER) %assert_eq
global check_txn_trie:
%mpt_hash_txn_trie %mload_global_metadata(@GLOBAL_METADATA_TXN_TRIE_DIGEST_AFTER) %assert_eq
global check_receipt_trie:
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah I guess we have been adding these in locally for so long that maybe it makes more sense just to get this into main. 🙃

}

// Retrieve previous PC (before jumping to KernelPanic), to see if we reached
// `hash_final_tries`. We will output debugging information on the final
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I think you changed hash_final_tries --> perform_final_checks (which is a much better name).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oops, yes I did, thanks!

@Nashtare Nashtare merged commit 5de86aa into main Mar 7, 2024
5 checks passed
@Nashtare Nashtare deleted the fix_trie_output branch March 7, 2024 00:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working crate: evm_arithmetization Anything related to the evm_arithmetization crate.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants