test(invariant): make protocol-fee conservation independent of on-chain state - #210
Merged
Merged
Conversation
…in state The protocol-fee conservation invariant mirrored the on-chain balance delta into its own tracker, so it compared the escrow balance against an echo of itself and could never catch a miscredit. The handler now accumulates the independently computed charge and quoted transfer fee, and a new invariant asserts those tracked inflows equal the on-chain protocol fees. Dead insurance-draw scaffolding, its recorded-log parsing, and stale insurance wording are removed to match the protocol-fee model.
Contributor
CI Summary
Labelssmartcontracts, type: test, type: docs, scope: pop |
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.
Description
The protocol-fee conservation invariant used to read the on-chain protocol-fee balance before and after each action and fold the difference into its own tracker. Because both sides came from the same source, the check compared the balance against an echo of itself and would pass even if a caller had been charged the wrong amount. The handler now accumulates the fee it independently expects, the charge on a cross-paid registration and the quoted fee on a payable transfer, so the invariant proves the escrow credited exactly what the caller was asked to pay. A second invariant asserts that the tracked inflows sum to the on-chain protocol-fee balance, which holds because protocol fees only ever accrue.
Type
Scope
Related Issues
Stacked on #208.
Fixes
Checklist
Code
forge buildpassesforge testpassesTesting
Security
selfdestructordelegatecallDocumentation
Breaking Changes
Breaking changes:
How to test
forge test --mc DotnsNameEscrowInvariantTestNotes