Skip to content

Minting past i64::MAX on an uncapped token returns InternalError instead of a consensus error #3848

Description

@thephez

Problem

When a token has max_supply == None, mint state validation skips its supply-bound check entirely. A mint that would push total supply past i64::MAX (the GroveDB sum-item ceiling) is caught only by the low-level Drive checked_add, surfacing as an InternalError rather than a graceful consensus rejection.

Supply is not corrupted (the write is prevented), but the failure class is wrong.

Observed result:

InternalError("storage: drive: corrupted code execution error: trying to add an amount that would overflow total supply")

Where

  • token_mint_transition_action/state_v0/mod.rs — the supply check is wrapped in if let Some(max_supply) = token_configuration.max_supply(), so the None case has no validation-layer guard.
  • Guard that actually fires: add_to_token_total_supply/v0/mod.rs (checked_add).

Expected

Reject at the validation layer with a graceful consensus error (treat i64::MAX as an implicit hard ceiling when max_supply is None).

Test

Current behavior is pinned by the characterization test test_token_mint_with_max_i64_base_supply_then_overflow_returns_internal_error_without_mutating_supply (batch/tests/token/mint/mod.rs). Adding the guard should break it — that is the signal to update it to expect the graceful rejection.

Related, distinct gap: base_supply > max_supply accepted at creation, documented by the #[ignore]d test_data_contract_creation_with_base_supply_over_max_supply_should_cause_error.

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