Skip to content

chore: fix generateUint256Column precision to numeric(78,0) for true uint256 coverage #600

@Mautjee

Description

@Mautjee

Background

The helper `generateUint256Column` in `services/explorer-api/src/svcs/database/schema/utils.ts` is defined as:

```ts
export const generateUint256Column = (name: string) =>
numeric(name, { precision: 77, scale: 0 });
```

`numeric(77, 0)` can hold values up to 10⁷⁷ − 1, which is sufficient to cover Aztec's BN254 Fr field (max ~2.19×10⁷⁶). However, a true uint256 max is ~1.16×10⁷⁷, which requires 78 digits (`numeric(78, 0)`).

The helper name implies uint256 coverage but the precision is one digit short.

What needs to change

  • Update `generateUint256Column` in `schema/utils.ts` from `numeric(77, 0)` → `numeric(78, 0)`
  • Regenerate a new Drizzle migration (the `ALTER COLUMN ... SET DATA TYPE` for all columns using this helper: `total_fees`, `total_mana_used`, `balance`, `stake`)
  • Update the Drizzle snapshot accordingly

Context

Tracked from PR #599, which fixed a bigint overflow in `total_fees`/`total_mana_used` by switching to `generateUint256Column`. The migration in that PR uses `numeric(77, 0)` (matching the helper as-is). This issue tracks the follow-up to make the helper truly cover uint256.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    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