Fix/combined rebuild quality - #469
Open
Hallab7 wants to merge 6 commits into
Open
Conversation
Closes TevaLabs#394 Closes TevaLabs#385 Closes TevaLabs#389 Closes TevaLabs#384
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Combined Quality & Rebuild Fixes
Summary
This PR consolidates four critical quality improvements and feature rebuilds into a single, tested integration:
Access Control Error Variants (Quality: add missing AccessDenied (and related) error variants #384): Added missing
AccessDeniedand related error codes toContractError, ensuring proper error handling and binding parity across the contract and TypeScript bindings.Dispute Window Lifecycle Rebuild (Rebuild: dispute window void_round + finalize_round end-to-end #389): Rebuilt the complete dispute window implementation including
void_round(permissionless refunds during window) andfinalize_round(settlement after window), with configurable ledger windows, full stake conservation, and comprehensive event coverage.Security Test Deduplication (Quality: deduplicate quadrupled security.rs test suite #385): Removed ~5,400 lines of quadrupled test code from
security.rs, reducing CI time while maintaining full coverage of oracle freshness, nonce replay, domain binding, and network validation.Precision Commit-Reveal Hardening (Rebuild: Precision commit-reveal with forfeiture and grinding defenses #394): Hardened commit-reveal flow with unrevealed position forfeiture, weak salt protection, and grinding defense mechanisms, including comprehensive E2E tests and event emissions.
Why? These changes address critical gaps in error handling, dispute resolution workflows, test maintainability, and Precision mode security—all essential for production readiness.
Linked issues
Docs reference
PROTOCOL_SPEC.md— invariants (I1–I13) updated if affecteddocs/EVENT_SCHEMA.md— event schema updated if new/changed eventsdispute_void,dispute_finalized)commit_received,reveal_matched,forfeit_unrevealed)MIGRATION.md— breaking changes documented with migration pathCOMPATIBILITY_POLICY.md— MAJOR/MINOR/PATCH classification notedSECURITY_REVIEW.md— open findings referenced if affectedcontracts/BENCHMARKS.md— benchmark evidence included if hot paths changedValidation
cargo test --workspace— All tests pass including new dispute window and commit-reveal E2E testscargo clippy --workspace --all-targets -- -D warnings— No warningscargo fmt --all -- --check— Formatting verifiedcd bindings && npm ci && npm run build— Bindings regenerated with new error codesGovernance checklist
CONTRIBUTING.mdfor workflow expectationsCODEOWNERSimpact for touched pathscontracts/src/,bindings/,docs/SUPPORT.mddisclosure guidance for any security-sensitive changeLabels
protocol— Dispute window settlement logicsecurity— Commit-reveal forfeiture and grinding defensesbug— Missing error variants, incomplete dispute APIsenhancement— Test suite cleanuptesting— New E2E coverage for dispute and commit-revealcontract— Core Rust contract changesRust— Primary languagepriority: high— Production-blocking quality and security gapsSmart-Contract Security Checklist
1. Authentication & Access Control
require_auth()or appropriate admin/oracle checks.void_roundis permissionless (by design, during dispute window)finalize_roundis permissionless (after window expires)AccessDeniedvariants2. Safe Arithmetic & Overflow Protection
checked_add,checked_sub,checked_mul, etc.) are used for all state changes.void_rounduse safe arithmeticpayout_add/payout_mul) where applicable.3. Lifecycle & State Transitions
void_roundonly callable during dispute window (beforedispute_ledgers_after_resolution)finalize_roundonly callable after window expires4. Event Emission & Observability
dispute_voidevent on void_round with refund detailsdispute_finalizedevent on finalize_roundcommit_received,reveal_matched,forfeit_unrevealedevents for Precision flowEVENT_SCHEMA.md5. Tests & Verification
AccessDeniederrorsCritical Path Changes
Details:
Details:
Snapshot policy
contracts/test_snapshots/changed, I reviewed the diff and confirmed every change is intentionalFile Change Summary
15 files changed | +749 insertions | -5,579 deletions
Key Changes:
access_control.rs: AddedAccessDeniedmappingerrors.rs: New error variants (AccessDenied, NotOracleRole, etc.)settlement.rs: Complete dispute window implementationbetting.rs: Commit-reveal forfeiture logicdispute_window.rs: New 128-line test suitecommit_reveal_e2e.rs: Hardened with grind scenariossecurity.rs: Reduced by 5,448 lines (deduplicated)EVENT_SCHEMA.md: 86 lines updated with new events