Skip to content

test(invariant): make protocol-fee conservation independent of on-chain state - #210

Merged
sphamjoli merged 1 commit into
spha/scarcity-pricingfrom
spha/scarcity-pricing-audit
Aug 7, 2026
Merged

test(invariant): make protocol-fee conservation independent of on-chain state#210
sphamjoli merged 1 commit into
spha/scarcity-pricingfrom
spha/scarcity-pricing-audit

Conversation

@sphamjoli

@sphamjoli sphamjoli commented Aug 7, 2026

Copy link
Copy Markdown
Member

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

  • Bug fix
  • Feature
  • Breaking change
  • Documentation
  • Chore
  • Refactor
  • Security

Scope

  • Registration
  • Resolver
  • Store
  • Proof of Personhood
  • Deployment scripts
  • Tests

Related Issues

Stacked on #208.

Fixes

Checklist

Code

  • Follows project style
  • forge build passes
  • forge test passes
  • No new compiler warnings

Testing

  • New tests added for changed behavior
  • Fuzz tests added where applicable
  • Invariant tests verified

Security

  • No new selfdestruct or delegatecall
  • Access control reviewed
  • No storage layout conflicts (for upgradeable contracts)

Documentation

  • NatSpec updated on changed interfaces
  • README updated if needed

Breaking Changes

  • No breaking changes
  • Breaking changes documented below

Breaking changes:

How to test

forge test --mc DotnsNameEscrowInvariantTest

Notes

…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.
@sphamjoli
sphamjoli requested a review from waytwotall as a code owner August 7, 2026 14:53
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

CI Summary

Check Result
Format & Lint Passed - Code formatted correctly
PR Title PR Title Valid
Labels Unknown

Labels

smartcontracts, type: test, type: docs, scope: pop

@github-actions github-actions Bot added smartcontracts Any issue relating to smart contracts type: test type: docs scope: pop labels Aug 7, 2026
@sphamjoli
sphamjoli merged commit 57fa214 into spha/scarcity-pricing Aug 7, 2026
8 checks passed
@sphamjoli
sphamjoli deleted the spha/scarcity-pricing-audit branch August 7, 2026 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: pop smartcontracts Any issue relating to smart contracts type: docs type: test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant