Skip to content

repository: enforce valid epoch status transitions#759

Merged
vfusco merged 2 commits intonext/2.0from
feature/enforce-epoch-status-transition
Mar 16, 2026
Merged

repository: enforce valid epoch status transitions#759
vfusco merged 2 commits intonext/2.0from
feature/enforce-epoch-status-transition

Conversation

@vfusco
Copy link
Collaborator

@vfusco vfusco commented Mar 14, 2026

No description provided.

@vfusco vfusco added this to the 2.0.0 milestone Mar 14, 2026
@vfusco vfusco requested a review from Copilot March 14, 2026 19:18
@vfusco vfusco self-assigned this Mar 14, 2026
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

Adds database-level enforcement for epoch status state-machine transitions and updates repository logic/tests to respect the new constraints, improving crash-recovery safety and data integrity across epoch processing.

Changes:

  • Introduce a Postgres trigger (enforce_epoch_status_transition) to validate epoch status transitions and require proof fields when entering CLAIM_COMPUTED.
  • Make CreateEpochsAndInputs upserts preserve non-OPEN epochs (crash-recovery guard) and tighten StoreClaimAndProofs to only advance epochs from INPUTS_PROCESSED.
  • Update integration/repository tests with a helper to advance epochs through valid transitions.

Reviewed changes

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

Show a summary per file
File Description
test/validator/validator_test.go Adjusts validator integration tests to move epochs through CLOSED -> INPUTS_PROCESSED before storing claims.
internal/repository/repotest/epoch_test_cases.go Adds new test coverage for upsert guarding and DB-trigger transition enforcement.
internal/repository/repotest/claimer_test_cases.go Switches tests to use AdvanceEpochStatus helper for valid transitions.
internal/repository/repotest/bulk_test_cases.go Updates bulk-operation tests to satisfy new preconditions for StoreClaimAndProofs.
internal/repository/repotest/builders.go Introduces AdvanceEpochStatus helper and dummy-proof setup for tests.
internal/repository/postgres/schema/migrations/000001_create_initial_schema.up.sql Adds epoch-status transition trigger and required-proof-field checks.
internal/repository/postgres/schema/migrations/000001_create_initial_schema.down.sql Adds rollback steps for the new trigger/function.
internal/repository/postgres/epoch.go Adds guarded upsert behavior (only mutate epoch fields when existing row is OPEN).
internal/repository/postgres/bulk.go Enforces INPUTS_PROCESSED precondition when updating epoch claim/status to CLAIM_COMPUTED.
internal/evmreader/output.go Adds explanatory comments around marking apps inoperable on output mismatch.
internal/evmreader/input.go Adds explanatory comments around marking apps inoperable on invalid epoch length.

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

You can also share your feedback on Copilot code review. Take the survey.

@vfusco vfusco force-pushed the feature/enforce-epoch-status-transition branch from 6f39291 to 0485be3 Compare March 15, 2026 15:29
@vfusco vfusco marked this pull request as ready for review March 15, 2026 15:31
@vfusco vfusco requested review from mpolitzer and renatomaia March 15, 2026 15:32
@vfusco vfusco force-pushed the feature/enforce-epoch-status-transition branch from 0485be3 to f5a9d87 Compare March 16, 2026 08:45
mpolitzer
mpolitzer previously approved these changes Mar 16, 2026
@github-project-automation github-project-automation bot moved this from Todo to Waiting Merge in Rollups SDK Mar 16, 2026
Base automatically changed from feature/evmreader-review to next/2.0 March 16, 2026 12:50
@vfusco vfusco dismissed mpolitzer’s stale review March 16, 2026 12:50

The base branch was changed.

@vfusco vfusco merged commit f5a9d87 into next/2.0 Mar 16, 2026
8 checks passed
@vfusco vfusco deleted the feature/enforce-epoch-status-transition branch March 16, 2026 12:59
@github-project-automation github-project-automation bot moved this from Waiting Merge to Done in Rollups SDK Mar 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants