Skip to content

fix(usdfc): keep MockUSDFC distribution within the 1M supply - #241

Closed
OzzyHelper wants to merge 1 commit into
FilOzone:mainfrom
OzzyHelper:koan/fix-mockusdfc-supply-budget
Closed

OzzyHelper wants to merge 1 commit into
FilOzone:mainfrom
OzzyHelper:koan/fix-mockusdfc-supply-budget

Conversation

@OzzyHelper

@OzzyHelper OzzyHelper commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

What

Keep the MockUSDFC startup distribution within the token's 1,000,000-token initial supply.

Why

Funding granted 100k tokens to each of 3 users and 200k to every active PDP SP. With 4 or 5 active SPs (MAX_PDP_SP_COUNT is 5) the schedule tried to move up to 1.3M tokens from a 1M balance, so the final transfers failed with an insufficient balance. The default two-SP topology happened to fit (700k), which hid the bug.

How

  • Users keep their fixed 100k grant. SPs share the remaining supply evenly, capped at the nominal 200k: 2–3 SPs keep 200k, 4 get 175k, 5 get 140k. Every supported topology now fits, and the default config is unchanged.
  • One distribution_plan() drives balance checks, transfers, and post-transfer verification, so the three previously-duplicated schedules cannot drift apart.
  • Removed the duplicate supply constant in usdfc_deploy_step; deployments now pass INITIAL_SUPPLY explicitly to the forge script from constants::MOCK_USDFC_INITIAL_SUPPLY, so the Rust allocation budget and the deployed token agree by construction.
  • Config::validate() now rejects topologies that cannot fund users/SPs from the supply.

Testing

  • cargo test --all-targets --all-features -- --skip test_print_running_status --skip test_print_uptime: 63 passed.
  • The two skipped tests are pre-existing failures in this environment because docker is not installed; verified they fail identically on unmodified main.
  • cargo clippy --all-targets --all-features -- -D warnings and ./scripts/lint.sh (FIX=0) pass.

Quality Report

Changes: 6 files changed, 272 insertions(+), 60 deletions(-)

Code scan: clean

Tests: skipped

Branch hygiene: 1 issue(s)

  • Branch is not pushed to remote

Startup funding granted 100k tokens to each of the three users and 200k to
every active PDP SP. With four or more SPs the schedule asked the deployer
to transfer up to 1.3M tokens from a 1M supply, so the last transfers failed
with an insufficient balance.

Derive the per-SP grant from the remaining supply instead: three users keep
their 100k each, SPs share what is left up to the nominal 200k. The default
two-SP topology is unchanged; four SPs get 175k and the maximum five get
140k, so the plan always fits.

Also:
- plan balance checks, transfers, and verification from one function so they
  cannot drift apart
- drop the duplicated supply constant from usdfc_deploy_step and pass
  INITIAL_SUPPLY explicitly to the forge script from the shared constant
- reject configurations in Config::validate that cannot fund the allocations
@FilOzzy FilOzzy added this to FOC Nov 19, 2026
@github-project-automation github-project-automation Bot moved this to 📌 Triage in FOC Nov 19, 2026
@Kubuxu

Kubuxu commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

Not important enough for this.

@Kubuxu Kubuxu closed this Nov 19, 2026
@github-project-automation github-project-automation Bot moved this from 📌 Triage to 🎉 Done in FOC Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🎉 Done

Development

Successfully merging this pull request may close these issues.

2 participants