Repository navigation
fix(security): emit LockedAmountMonitoringEnabled on deploy and document balance conservation invariant (FINDING-002) - #26
Open
mertcano wants to merge 1 commit into
Conversation
…ent balance conservation invariant (FINDING-002)
### Summary of Changes
Addresses **FINDING-002** (Medium Severity) regarding locked amount accounting assumptions and event consistency:
- **Observability in Token Deployment:**
- Added emission of `LockedAmountMonitoringEnabled { l1_token, amount: 0 }` inside `handle_token_deployment`.
- Ensures external monitoring bots, indexers, and security guardians receive immediate notification that locked-amount conservation is active from token genesis.
- **Invariant & Operational Documentation:**
- Documented core balance conservation invariant `locked_amount == L1_locked_balance` in `LockedAmount` struct.
- Added operational runbook guidance in `enable_locked_amount_monitoring`: governance must verify that no in-flight deposit or withdrawal messages exist when utilizing the `total_supply()` fallback to prevent desynchronization.
- **Unit Test Coverage:**
- Added `test_failed_withdraw_exceeds_locked_amount` to confirm that withdrawals exceeding the monitored L1 locked pool are rejected.
### Affected Files
- `packages/bridge/src/token_bridge.cairo`
### Verification
```bash
scarb --release build
snforge test test_failed_withdraw_exceeds_locked_amount
snforge test
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.
Summary of Changes
Addresses FINDING-002 (Medium Severity) regarding locked amount accounting assumptions and event consistency:
LockedAmountMonitoringEnabled { l1_token, amount: 0 }insidehandle_token_deployment.locked_amount == L1_locked_balanceinLockedAmountstruct.enable_locked_amount_monitoring: governance must verify that no in-flight deposit or withdrawal messages exist when utilizing thetotal_supply()fallback to prevent desynchronization.test_failed_withdraw_exceeds_locked_amountto confirm that withdrawals exceeding the monitored L1 locked pool are rejected.Affected Files
packages/bridge/src/token_bridge.cairoVerification