Skip to content

genesis: ValidatorManager schema accepts a validator public key of any length; the chain requires 32 bytes #413

Description

@JspIIV

Summary

scripts/genesis/ValidatorManager.ts types a validator publicKey as schemaHex — any 0x plus an even number of hex digits — while the chain only accepts 32-byte keys:

// contracts/src/validator-manager/ValidatorRegistry.sol
require(publicKey.length == ED25519_PUBLIC_KEY_LENGTH, InvalidPublicKeyFormat());

The 32-byte rule exists in the genesis tooling only as a throw new Error('Public key must be 32 bytes') inside buildValidatorManagerGenesisAllocs. genesis.ts parses the whole config with schemaGenesisConfig.parse first (line 161) and builds later (line 188), so a 31-byte key passes validation, passes the public-key uniqueness check, and only fails afterwards with an error that names no path.

Steps to reproduce

import { schemaValidatorManager } from './scripts/genesis/ValidatorManager'
schemaValidatorManager.safeParse({ ...validConfig, validators: [{ publicKey: `0x${'11'.repeat(31)}`, votingPower: 20n, controllers: [...] }] })
// => success: true   (expected: false, path validators.0.publicKey)

Expected behavior

The schema rejects any publicKey that is not exactly 32 bytes, with a path, the same way #359 moved the consensus-timeout and base-fee range checks into the schema. schemaBytes32 already exists in scripts/genesis/types.ts and is exactly {32} bytes.

Every key in assets/*/genesis.config.ts is already 64 hex characters, so no shipped config changes.

Related

#346, #359 (same class: genesis schema aligned with a runtime check). Does not overlap #374, which normalizes hex casing and leaves the field type alone.

I have a fix ready in #401 and would like to be assigned.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions