Skip to content

Conversation

@gakonst
Copy link
Contributor

@gakonst gakonst commented Feb 6, 2026

Summary

Add new invariant test handlers to improve Rust precompile code coverage, identified through instrument-coverage benchmarking of tempo-foundry PR #245.

Changes

TIP20.t.sol — 2 new handlers:

  • mintWithMemo(tokenSeed, recipientSeed, amount, memoSeed) — exercises tip20::mint_with_memo path
  • burnWithMemo(tokenSeed, amount, memoSeed) — exercises tip20::burn_with_memo + internal _burn path
  • Both maintain existing supply conservation invariants (TEMPO-TIP6/7/8)

ValidatorConfig.t.sol — 1 new handler:

  • changeValidatorStatusByIndex(indexSeed, newStatus) — exercises validator_config::change_validator_status_by_index T1+ dispatch path
  • Verifies TEMPO-VAL5/VAL6 status toggle invariants

Coverage Impact

Benchmarked with -Cinstrument-coverage on the fuzz profile binary (10 runs × 1000 depth, seed=42):

Metric Before After Delta
TIP20 precompile LOC 1555/5370 1567/5370 +12
ValidatorConfig precompile LOC 1167/5370 1193/5370 +26
Total precompile LOC (all tests) 12,994 13,029 +35
Feature diversity 182 194 +12 (+6.6%)

Not addressed (future work)

  • TIP403Registry compound policies — gated behind T2 (is_t2() check), not testable on current T1 hardfork
  • Protocol-internal functions (Nonce check_and_mark_expiring_nonce, AccountKeychain authorize_transfer, TIP20 transfer_fee_pre/post_tx, FeeAMM execute_fee_swap) — ~620 uncovered LOC not reachable from Solidity invariant tests
  • Rust storage layer (vec.rs, array.rs, hashmap.rs) — internal implementation with Rust proptests

Related: tempoxyz/tempo-foundry#245

…StatusByIndex handlers

Add new invariant test handlers to improve Rust precompile code coverage:

TIP20.t.sol:
- mintWithMemo: exercises tip20/mod.rs mint_with_memo path (~18 LOC)
- burnWithMemo: exercises tip20/mod.rs burn_with_memo + _burn paths (~22 LOC)
  Both maintain existing supply conservation invariants (TEMPO-TIP6/7/8)

ValidatorConfig.t.sol:
- changeValidatorStatusByIndex: exercises validator_config/mod.rs
  change_validator_status_by_index T1+ dispatch path (~18 LOC)
  Verifies TEMPO-VAL5/VAL6 status toggle invariants

Coverage benchmark results (10 runs, 1000 depth, seed=42):
- TIP20: +12 precompile LOC hit
- ValidatorConfig: +26 precompile LOC hit
- Total: +35 LOC across all tests (+0.3%)
- Feature diversity: +12 features (+6.6%)

Amp-Thread-ID: https://ampcode.com/threads/T-019c32ac-ea85-752e-a124-01029df9c9d6
Co-authored-by: Amp <[email protected]>
@grandizzy grandizzy marked this pull request as ready for review February 6, 2026 19:34
@github-actions
Copy link

github-actions bot commented Feb 6, 2026

📊 Tempo Precompiles Coverage

precompiles

Coverage: 16582/17521 lines (94.64%)

File details
File Lines Coverage
src/account_keychain/dispatch.rs 36/41 87.80%
src/account_keychain/mod.rs 636/656 96.95%
src/error.rs 78/97 80.41%
src/lib.rs 277/292 94.86%
src/nonce/dispatch.rs 19/23 82.61%
src/nonce/mod.rs 236/247 95.55%
src/stablecoin_dex/dispatch.rs 349/353 98.87%
src/stablecoin_dex/error.rs 51/51 100.00%
src/stablecoin_dex/mod.rs 2674/2768 96.60%
src/stablecoin_dex/order.rs 362/362 100.00%
src/stablecoin_dex/orderbook.rs 621/660 94.09%
src/storage/evm.rs 321/344 93.31%
src/storage/hashmap.rs 118/133 88.72%
src/storage/mod.rs 5/5 100.00%
src/storage/packing.rs 526/552 95.29%
src/storage/thread_local.rs 135/188 71.81%
src/storage/types/array.rs 211/262 80.53%
src/storage/types/bytes_like.rs 323/338 95.56%
src/storage/types/mapping.rs 131/150 87.33%
src/storage/types/mod.rs 61/85 71.76%
src/storage/types/primitives.rs 564/567 99.47%
src/storage/types/slot.rs 282/296 95.27%
src/storage/types/vec.rs 1072/1095 97.90%
src/test_util.rs 194/231 83.98%
src/tip20/dispatch.rs 534/563 94.85%
src/tip20/mod.rs 1338/1405 95.23%
src/tip20/rewards.rs 444/487 91.17%
src/tip20/roles.rs 187/206 90.78%
src/tip20_factory/dispatch.rs 26/29 89.66%
src/tip20_factory/mod.rs 488/500 97.60%
src/tip403_registry/dispatch.rs 406/443 91.65%
src/tip403_registry/mod.rs 1247/1333 93.55%
src/tip_fee_manager/amm.rs 1111/1147 96.86%
src/tip_fee_manager/dispatch.rs 278/289 96.19%
src/tip_fee_manager/mod.rs 478/497 96.18%
src/validator_config/dispatch.rs 210/221 95.02%
src/validator_config/mod.rs 553/605 91.40%

contracts

Coverage: 164/329 lines (49.85%)

File details
File Lines Coverage
src/lib.rs 1/71 1.41%
src/precompiles/account_keychain.rs 24/30 80.00%
src/precompiles/nonce.rs 9/18 50.00%
src/precompiles/stablecoin_dex.rs 33/48 68.75%
src/precompiles/tip20.rs 46/64 71.88%
src/precompiles/tip20_factory.rs 6/12 50.00%
src/precompiles/tip403_registry.rs 12/15 80.00%
src/precompiles/tip_fee_manager.rs 21/45 46.67%
src/precompiles/validator_config.rs 12/26 46.15%

Total: 16746/17850 lines (93.82%)

📦 Download full HTML report

Add tests to catch mutations missed by cargo-mutants:
- get_key: verify correct signature type for Secp256k1/P256/WebAuthn (catches match arm deletion)
- get_key: verify revoked key returns zero fields (catches || vs && mutation)
- get_key: verify nonexistent key returns zero fields
- update_spending_limit: verify rejection on expired key (catches >= boundary)
- update_spending_limit: verify enforce_limits gets enabled (catches ! deletion)
- spending_limit_key: verify deterministic output and arg-order sensitivity

Amp-Thread-ID: https://ampcode.com/threads/T-019c34b4-a27f-72da-994d-4c242b3d6605
Co-authored-by: Amp <[email protected]>
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