Skip to content

bug(ValidatorRegistry): _nextRegistrationId starts at 0, first validator gets ID=0 which cannot be assigned a controller #484

Description

@forumevi

Description

In contracts/src/validator-manager/ValidatorRegistry.sol, _nextRegistrationId is never initialized and defaults to 0. The first registerValidator call therefore returns registrationId = 0.

However, Controller.sol explicitly rejects ID=0:

require(registrationId != 0, RegistrationIdIsZero());
This means the first registered validator can never be assigned a controller, and therefore can never be activated, removed, or have its voting power updated.

The storage comment says "starting from 1" but the code never sets the initial value to 1.

The existing test suite works around this silently by force-writing _nextRegistrationId = 1 via vm.store in TestUtils.sol, confirming the team is aware the default of 0 is incorrect.

Expected behaviour
_nextRegistrationId should be initialized to 1 so the first validator receives ID=1.

Suggested fix
Initialize _nextRegistrationId = 1 in the genesis setup or in the storage initializer.
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