Conversation
The chain only accepts 32-byte keys -- ValidatorRegistry.registerValidator reverts with InvalidPublicKeyFormat on anything else -- but the genesis schema typed publicKey as schemaHex, which is any even-length hex. The 32-byte rule lived only as a throw inside buildValidatorManagerGenesisAllocs, so a 31-byte key passed schemaGenesisConfig.parse and the uniqueness check, and failed later with an Error that names no path. Use schemaBytes32, which already exists and is exactly 32 bytes, and drop the runtime throw it makes unreachable: the builder re-parses the schema on entry, so nothing gets past it. The rejection now carries a path, validators.<i>.publicKey, like the other genesis invariants. Tests: a 31-byte and a 33-byte key are rejected at the schema with the path set, a 32-byte key is accepted. Both rejections fail on main.
JspIIV
requested review from
ZhiyuCircle,
ancazamfir,
romac and
sergio-mena
as code owners
September 13, 2026 10:30
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes: #413
Summary
Same shape as #359, one field over: the genesis schema for
ValidatorManageraccepts a validatorpublicKeyof any even hex length, while the chain only accepts 32 bytes.ValidatorRegistry.registerValidatorenforces the real rule:and the alloc builder knows it too — but only as a
throw new Error('Public key must be 32 bytes')insidebuildValidatorManagerGenesisAllocs, afterschemaGenesisConfig.parsehas already accepted the config (genesis.ts:161parses,:188builds). So a 31-byte key passes validation, passes the uniqueness check, and then fails later with a message that carries no path to the offending entry.Change
publicKey: schemaBytes32— the schema already exists intypes.tsand is exactly{32}bytes.The error moves to where the other genesis invariants live, with a path (
validators.0.publicKey) instead of a bare string.Tests
tests/unit/validator-manager-genesis-validation.test.ts: a 31-byte and a 33-byte key are rejected at the schema with the path set, a 32-byte key is accepted. Both rejections fail onmain(the schema accepts them; only the builder would object). Run withmocha -r ts-node/registerdirectly, sinceforgeis not available here and the hardhat-foundry plugin refuses to start without it;make genesiswas not run for the same reason. Every key inassets/*/genesis.config.tsis already 64 hex characters, so no shipped config changes behaviour.Does not overlap #374, which normalizes hex casing and leaves the field type alone.
Related: #346, #359