Skip to content

feat: INativeDoge token-duality interface + Foundry test shim - #40

Closed
dghelm wants to merge 1 commit into
dogeos-v0.3.0-developfrom
experiment/duality-test-shim
Closed

dghelm wants to merge 1 commit into
dogeos-v0.3.0-developfrom
experiment/duality-test-shim

Conversation

@dghelm

@dghelm dghelm commented Jun 11, 2026

Copy link
Copy Markdown

Summary

Groundwork for using Celo-style token duality (an ERC20-shaped token whose balances are native account balances) in DogeOS contracts — specifically so the upcoming payment/intent-ledger work can be developed and tested against duality semantics now, before the protocol pieces exist.

True duality cannot be implemented in pure EVM: moving another account's native balance requires a protocol-level native-transfer precompile (Celo's CELO/GoldToken model). Enabling it for real on DogeOS needs, tracked separately:

  1. a native-transfer precompile in l2geth/revm (callable only by the duality token contract), with prover/stateless-verifier support;
  2. a predeploy token contract at a canonical DogeOSPredeploy address calling that precompile;
  3. genesis integration.

What this PR ships

  • src/dogeos/INativeDoge.sol — the interface contracts should code against, with production semantics specified: balanceOf(a) == a.balance (no storage balances), transfers move native value without executing recipient code (no receive()/fallback() hooks — matching Celo's precompile behavior), storage allowances.
  • src/test/mocks/DualityDogeShim.sol — TEST-ONLY functional shim implementing the interface in Foundry via vm.deal (the in-test stand-in for the future precompile). Semantically faithful, including the no-recipient-hooks property; explicitly not valid for gas measurement. Placed under src/test/mocks/ so hardhat never compiles it (it imports forge-std) and slither/coverage exclude it.
  • src/test/dogeos/DualityDogeShim.t.sol — 11 tests: native-balance mirroring, transfer/transferFrom/allowance semantics (incl. infinite-allowance no-decrement), insufficient balance/allowance reverts with exact errors, reverting-receive() cannot block a transfer, conservation fuzz.

Test plan

  • forge test --evm-version cancun — 432 tests pass (11 new)
  • npx hardhat compile — clean (interface compiles; shim correctly excluded)

Relation to other work

🤖 Generated with Claude Code

Celo-style "token duality" - an ERC20-shaped token whose balances ARE
native account balances (balanceOf == address.balance, transfers move
native value without executing recipient code) - cannot be implemented
in pure EVM: moving another account's native balance requires a
protocol-level native-transfer precompile, plus a predeploy token and
prover support. That protocol work does not exist on DogeOS yet.

This PR ships what contracts development needs in the meantime:

- src/dogeos/INativeDoge.sol: the interface payment/intent contracts
  should code against, with the production semantics specified (native
  balances, no recipient-code execution on transfer, storage allowances)
  and the protocol prerequisites documented.
- src/test/mocks/DualityDogeShim.sol: TEST-ONLY functional shim
  implementing the interface inside Foundry via vm.deal (the in-test
  stand-in for the future precompile). Faithful to production semantics
  including the no-recipient-hooks property; explicitly NOT faithful for
  gas. Lives under src/test/mocks so hardhat (which cannot resolve
  forge-std) never compiles it and slither/coverage exclude it.
- src/test/dogeos/DualityDogeShim.t.sol: 11 tests covering native
  balance mirroring, transfer/transferFrom/allowance semantics
  (incl. infinite-allowance no-decrement), insufficient balance and
  allowance reverts, the reverting-receive()-cannot-block-transfer
  property, and a conservation fuzz.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@dghelm
dghelm force-pushed the experiment/duality-test-shim branch from 216989d to 2da450c Compare July 7, 2026 04:43
@dghelm
dghelm marked this pull request as ready for review July 7, 2026 04:49
@dghelm

dghelm commented Jul 8, 2026

Copy link
Copy Markdown
Author

Superseded by #51

@dghelm dghelm closed this Jul 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant