Skip to content

Refactor ErrorCode to include NodePtr and drop ValidationErr#1348

Open
cameroncooper wants to merge 1 commit intomainfrom
refactor-error-code
Open

Refactor ErrorCode to include NodePtr and drop ValidationErr#1348
cameroncooper wants to merge 1 commit intomainfrom
refactor-error-code

Conversation

@cameroncooper
Copy link
Copy Markdown

@cameroncooper cameroncooper commented Feb 6, 2026

Note

Medium Risk
Wide, cross-cutting change to error types and propagation across consensus-critical parsing/validation code; behavior should be equivalent but regressions could surface via mismatched error construction or lost node context.

Overview
Refactors validation errors to eliminate ValidationErr and make ErrorCode carry location context. A new error_code module defines ErrorCode variants that embed NodePtr (or Option<NodePtr>) and provides CLVM list helpers (first/rest/next/atom/check_nil) plus u32 mapping and EvalErr/io conversions.

All consensus/mempool paths (condition parsing/validation, generator execution, spendbundle validation, additions/removals, message parsing, timelock checks, fingerprinting, sanitizers) are updated to return Result<_, ErrorCode> and construct errors via the new variants/closures; tests and fuzz targets are adjusted to compare by numeric code or pattern-match variants. Error::Validation now wraps ErrorCode directly (with From<ErrorCode>), and lib.rs exports error_code instead of validation_error.

Written by Cursor Bugbot for commit 71f388e. This will update automatically on new commits. Configure here.

@cameroncooper cameroncooper requested a review from arvidn February 6, 2026 20:05
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

let code1 = u32::from(msg1);
let code2 = u32::from(msg2);
if code1 != code2 {
assert!(discrepancy_errors.contains(&code1) || discrepancy_errors.contains(&code2));
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Fuzz test drops node-data comparison weakening assertion

Low Severity

The old error comparison checked both error code equality AND node data equality (node_to_bytes). The new code only compares u32 error codes via u32::from, completely dropping the node-data check. If two runs fail with the same error type but at different CLVM nodes (indicating a meaningful behavioral difference), the fuzz test will no longer detect it.

Fix in Cursor Fix in Web

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.

1 participant