State Transition Rules and Invariants
State Transition Rules and Invariants
Initialization:
A single path from Uninitialized → Initialized is allowed on the first batch (
prevBatchHash == 0).currentForkIdset to 1, marking the genesis commit’s creation.
Batch Submission:
Only unpaused state allows new batches.
Must build on the last commit hash (unless genesis).
commitHashmust be unique or revert withDuplicateCommit.
Fork Management:
A new fork increments
currentForkId.Ties old forks above
targetForkIdas abandoned; can restore older forks if they become canonical again.The first commit in a new fork references the chosen parent’s commit.
Access Control:
DEFAULT_ADMIN_ROLEcan assign or remove roles.APPENDER_ROLEneeded to submit a batch.FORKER_ROLErequired for forking.PAUSER_ROLE/UNPAUSER_ROLEfor toggling pause.
Pause Control:
Paused or unpaused are the two states.
Mutating operations revert if paused.
The unpauser can resume normal operations.
Commit Registry:
_usedCommits[commitHash]tracks usage.Once set, a commit can never be reused or deleted.
This ensures global uniqueness across all forks.
Invariants (must always hold true):
Fork Integrity:
currentForkIdmonotonically increases. Fork ancestry must remain traceable.Commit Integrity: Each commit has a valid parent (except genesis) and a strictly higher height than its parent.
Canonical Batches: Must lie on the chain that leads from the current fork tip to genesis without encountering any fork that branches lower.
Access Control: Roles are strictly enforced for each operation.
Pausable: If
paused, no new commits or forks can be created.
Last updated
Was this helpful?