Skip to content

base_supply > max_supply is accepted at token contract creation, permanently blocking mints #3850

Description

@thephez

Problem

A token contract can be created with base_supply greater than its own max_supply. There is no creation-time guard comparing the two — the create validator only rejects base_supply > i64::MAX.

The result is an inconsistent token that is unrecoverable:

  • It is created with total supply equal to base_supply, already over the cap.
  • base_supply is immutable on contract update, so the over-cap state cannot be corrected from that side.
  • Every mint is then permanently rejected with TokenMintPastMaxSupplyError, since current supply already exceeds max_supply.
  • Lowering max_supply to match is also blocked (TokenSettingMaxSupplyToLessThanCurrentSupplyError); the only escape is raising max_supply to >= current supply, assuming the max-supply change rules allow it.

Example: base_supply = 100_000, max_supply = Some(50_000) → contract is created with supply 100_000 and can never mint.

Where

  • packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_create/basic_structure/v0/mod.rs — the per-token checks reject base_supply > i64::MAX but do not compare base_supply against max_supply.

Expected

Reject contract creation when base_supply > max_supply (where max_supply is set), with a graceful consensus error, alongside the existing base_supply > i64::MAX check.

Test

Documented by the #[ignore]d test test_data_contract_creation_with_base_supply_over_max_supply_should_cause_error added in #3849, which runs a real DataContractCreateTransition and asserts the intended rejection. It currently fails (creation succeeds with an over-cap supply); remove #[ignore] once the guard is added.

Related: #3848 (minting past i64::MAX on an uncapped token returns InternalError).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions