refactor: remove eq_outputs from validator receipts#1529
refactor: remove eq_outputs from validator receipts#1529cristiam86 wants to merge 3 commits intomainfrom
Conversation
Validators never generate eq_outputs, so they always produced empty dicts.
This change:
- Makes Receipt.eq_outputs optional (dict[int, str] | None = None)
- Only populates eq_outputs for leader receipts
- Omits eq_outputs from serialization for validator receipts
- Removes eq_outputs={} from all validator receipt constructors
- Handles None eq_outputs when decoding leader receipt for validator execution
All 579 backend unit tests, 60 DB tests, and 112 frontend tests pass.
Fixes DXP-36
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe PR makes Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@backend/node/types.py`:
- Around line 257-261: The deserialization uses a truthiness check that treats
an empty dict as falsy, causing eq_outputs to become None; update the condition
around raw_eq in the eq_outputs assignment (the comprehension that currently
uses "if (raw_eq := input.get('eq_outputs'))") to explicitly check for None
(e.g., "if (raw_eq := input.get('eq_outputs')) is not None") so empty dicts
deserialize back to {} while still mapping keys via the existing comprehension
that converts keys to int.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 7e051cb8-5e10-42a3-9cbd-0a70eaa2bb92
📒 Files selected for processing (7)
backend/consensus/base.pybackend/node/base.pybackend/node/types.pytests/unit/consensus/test_helpers.pytests/unit/consensus/test_validator_exec_timeout.pytests/unit/test_leader_llm_recovery.pytests/unit/test_set_vote.py
💤 Files with no reviewable changes (2)
- backend/consensus/base.py
- tests/unit/consensus/test_validator_exec_timeout.py
Empty dict {} is falsy in Python, so the truthiness check would
incorrectly convert a leader's empty eq_outputs to None on
deserialization. Use `is not None` to preserve the round-trip.
What
Made
Receipt.eq_outputsoptional since validators never generate it. Changes:eq_outputsoptional (dict[int, str] | None = None) in Receipteq_outputsfor leader receipts; validators getNoneeq_outputsfrom JSON serialization for validator receiptseq_outputs={}from all validator receipt constructors in testsWhy
Validators always produced empty
eq_outputsdicts with no actual data. Making it optional reduces unnecessary storage and clearer semantics in the data model.Testing done
Decisions made
eq_outputs(always set to dict, even if empty)eq_outputs = None(omitted from JSON)Nonewhen decoding leader receipt for validator executionFixes DXP-36
Summary by CodeRabbit
Bug Fixes
Tests