Skip to content

Conversation

@bamrith
Copy link
Contributor

@bamrith bamrith commented Nov 15, 2025

No description provided.

@bamrith bamrith force-pushed the bharath/block_policy_errors branch from 2dc9149 to 769a1f1 Compare November 15, 2025 19:26
@bamrith bamrith changed the title Add logging for block policy errors Update logging for block policy errors Nov 15, 2025
@bamrith bamrith force-pushed the bharath/block_validation_errors branch 2 times, most recently from 09aa093 to a854d26 Compare November 17, 2025 02:13
@bamrith bamrith force-pushed the bharath/block_policy_errors branch 2 times, most recently from 9cfb165 to 32a5e2f Compare November 17, 2025 02:24
@bamrith bamrith force-pushed the bharath/block_validation_errors branch 3 times, most recently from ea50b59 to b3f2732 Compare November 17, 2025 22:58
@bamrith bamrith force-pushed the bharath/block_policy_errors branch from 32a5e2f to a34c8b7 Compare November 17, 2025 23:02
Base automatically changed from bharath/block_validation_errors to master November 18, 2025 02:32
Copilot AI review requested due to automatic review settings November 18, 2025 04:17
@michael-yxchen michael-yxchen force-pushed the bharath/block_policy_errors branch from a34c8b7 to 235067c Compare November 18, 2025 04:17
Copilot finished reviewing on behalf of michael-yxchen November 18, 2025 04:22
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors error handling and logging for block policy validation by introducing specific error types (EthBlockPolicyError and EthBlockPolicyBlockValidatorError) to replace the generic BlockPolicyError, improves error logging with additional context, and adds metrics tracking for specific error conditions.

Key changes:

  • Introduces a dedicated error module (monad-eth-block-policy/src/error.rs) with specific error types for Ethereum block policy validation
  • Enhances error logging by changing many trace! calls to debug! and adding contextual information (block seq_num, round, transaction details)
  • Adds metrics tracking for execution lagging, bad state root, and base fee errors directly in the block policy layer
  • Removes unnecessary chain_config parameters from update_committed_block and reset methods in the BlockPolicy trait
  • Updates SystemTransactionError and SystemTransactionValidationError to derive PartialEq, Eq for better error handling

Reviewed Changes

Copilot reviewed 13 out of 14 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
monad-eth-block-policy/src/error.rs New error module defining EthBlockPolicyError and EthBlockPolicyBlockValidatorError with appropriate From trait implementations
monad-eth-block-policy/src/lib.rs Major refactoring: replaces BlockPolicyError with EthBlockPolicyError, updates logging from trace to debug with enhanced context, adds metrics tracking, removes phantom data field from validator
monad-consensus-types/src/block.rs Removes generic BlockPolicyError types, adds associated BlockPolicyError type to BlockPolicy trait, simplifies method signatures, introduces PassthruBlockPolicyError
monad-system-calls/src/validator.rs Adds PartialEq, Eq derives to error enums and includes transaction in debug logging
monad-state/src/lib.rs Updates block_policy.reset() call to remove unnecessary chain_config parameter
monad-eth-txpool/src/pool/mod.rs Updates error type references and removes ? from non-fallible validator constructor
monad-eth-txpool/tests/pool.rs Removes unnecessary chain_config parameter from test code
monad-eth-txpool-executor/src/lib.rs Updates block policy method calls to remove chain_config parameter
monad-updaters/src/txpool.rs Updates block policy method calls to use simplified signatures
monad-consensus-state/src/lib.rs Simplifies update_committed_block call by removing chain_config parameter
monad-blocktree/src/blocktree.rs Simplifies error handling and adds debug logging for coherency check failures
monad-eth-block-validator/tests/coherency_test.rs Adds Metrics::default() parameter to test to match updated trait signature
monad-blocktree/Cargo.toml Adds tracing dependency for new debug logging
Cargo.lock Reflects new tracing dependency for monad-blocktree

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

let Some(account_balance) = maybe_account_balance else {
warn!(
debug!(
seq_num =?self.block_seq_num,
Copy link

Copilot AI Nov 18, 2025

Choose a reason for hiding this comment

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

Inconsistent formatting in debug macro. The format should be seq_num =? self.block_seq_num (with space after =?) to match the pattern used elsewhere in this file (e.g., lines 406, 422, 443, 461, 476). The same issue appears on lines 525, 541, 567, 582, and 598.

Copilot uses AI. Check for mistakes.
?is_emptying_transaction,
"Non-emptying txn can not be accepted insufficient reserve balance"
is_emptying_transaction,
"Non-emptying txn can not be accepted. insufficient reserve balance"
Copy link

Copilot AI Nov 18, 2025

Choose a reason for hiding this comment

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

Grammatical error: "can not" should be "cannot" (one word).

Suggested change
"Non-emptying txn can not be accepted. insufficient reserve balance"
"Non-emptying txn cannot be accepted. insufficient reserve balance"

Copilot uses AI. Check for mistakes.
?is_emptying_transaction,
"Non-emptying txn can not be accepted insufficient reserve balance"
is_emptying_transaction,
"Non-emptying txn can not be accepted. insufficient reserve balance"
Copy link

Copilot AI Nov 18, 2025

Choose a reason for hiding this comment

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

Error message lacks proper capitalization and punctuation: "insufficient reserve balance" should be "Insufficient reserve balance." or rephrase to "Txn validation failed: Non-emptying txn cannot be accepted due to insufficient reserve balance"

Suggested change
"Non-emptying txn can not be accepted. insufficient reserve balance"
"Txn validation failed: Non-emptying txn cannot be accepted due to insufficient reserve balance."

Copilot uses AI. Check for mistakes.
?is_emptying_transaction,
"Emptying txn can not be accepted insufficient reserve balance"
is_emptying_transaction,
"Txn validation failed: Emptying txn can not be accepted insufficient reserve balance"
Copy link

Copilot AI Nov 18, 2025

Choose a reason for hiding this comment

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

Error message is misleading. It says "insufficient reserve balance" but the check is account_balance.balance < txn_max_gas (regular balance) and returns InsufficientBalance. The message should be: "Txn validation failed: Emptying txn cannot be accepted due to insufficient balance" (also fix "can not" → "cannot").

Suggested change
"Txn validation failed: Emptying txn can not be accepted insufficient reserve balance"
"Txn validation failed: Emptying txn cannot be accepted due to insufficient balance"

Copilot uses AI. Check for mistakes.

let Some(account_balance) = maybe_account_balance else {
warn!(
debug!(
Copy link
Contributor

Choose a reason for hiding this comment

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

i think this should be a warn - if this happens, it's likely there is a bug in our code (i.e. account balances for tx signers should always be populated)

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.

3 participants