Skip to content

feat: declare validators in Config - #81

Draft
redshiftzero wants to merge 12 commits into
mainfrom
73-admin-validator
Draft

feat: declare validators in Config#81
redshiftzero wants to merge 12 commits into
mainfrom
73-admin-validator

Conversation

@redshiftzero

@redshiftzero redshiftzero commented Jan 27, 2026

Copy link
Copy Markdown
Contributor

Closes #73, I've tested block production but haven't tried adding another validator yet.

I'm also scoping out updating power for existing validators. We currently have equal weights for all validators, we could change this. For now, it's the declared power in the config or 0, which might be worth hardcoding to 1 or 0, or we can leave it flexible as is.

@redshiftzero
redshiftzero changed the base branch from spike-038 to main January 27, 2026 22:59

#[serde_as]
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
pub struct Validator {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now the Config takes a vec of these Validator entries

@conorsch

Copy link
Copy Markdown
Contributor

Stacked PR on #64 since the relevant logic needs to happen in EndBlock (0.34) or FinalizeBlock (0.38), so I'm doing this on top of the 0.38 changes

Word, I merged #64 and tagged the 0.38 cometbft bump as v0.3.0, so you're free to rebase on top of latest main if you haven't yet.

@conorsch conorsch mentioned this pull request Feb 20, 2026
@conorsch
conorsch force-pushed the 73-admin-validator branch 5 times, most recently from b55a388 to 015f813 Compare March 16, 2026 05:18
@conorsch
conorsch force-pushed the 73-admin-validator branch from 015f813 to ca42a77 Compare March 23, 2026 21:09
@conorsch
conorsch force-pushed the 73-admin-validator branch from ca42a77 to 0788db2 Compare April 2, 2026 19:13
@conorsch

conorsch commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

Rebased on top of latest main to include #130 ; still need to update the integration tests here to use that join logic, though.

@conorsch
conorsch force-pushed the 73-admin-validator branch from 0788db2 to e77e0bd Compare April 5, 2026 22:02
@conorsch

conorsch commented Apr 5, 2026

Copy link
Copy Markdown
Contributor

still need to update the integration tests here to use that join logic

I've removed the validator-specific integration tests from this PR, and will submit them as a separate PR, as with #135.

redshiftzero and others added 11 commits April 6, 2026 12:29
This needs more testing (integration tests TK), but the rationale is
that sync_validators_from_config sets removed validators to power=0 in
the store, but active_validators() filters out power=0 entries. CometBFT
requires an explicit power=0 update to remove a validator from the active
set. So we should return the changes from sync_validators_from_config
and merge them into validator_updates in FinalizeBlock.

This is super relevant for the recent 0.38 changes.
The validator set in the config is technically optional; if it's
missing, no changes should be made to the validator set, otherwise
all validators will be removed from consensus, which is a chain halt.

This is a judgment call: it's better to drop changes silently than apply
unintended changes and break the chain.
Comet doesn't want the full set, just changes to it. Let's compute the
changes in the app code and pass only the changes over the ABCI boundary
to comet.
@conorsch
conorsch force-pushed the 73-admin-validator branch from e77e0bd to c507d89 Compare April 6, 2026 19:29
@conorsch

conorsch commented Apr 6, 2026

Copy link
Copy Markdown
Contributor

Rebased on top of latest main, i.e. 1a6baa0

@redshiftzero redshiftzero changed the title wip: declare validators in Config feat: declare validators in Config Apr 8, 2026
@redshiftzero

Copy link
Copy Markdown
Contributor Author

i've reviewed the changes not added by @conorsch as of c507d89, and all LGTM - but keeping this as draft until we're ready to merge in all validator-related changes.

pub struct Validator {
#[serde_as(as = "Hex")]
pub public_key: Bytes,
pub power: u64,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forgot this - @conorsch apparently we do track power in Validator entries in the Config, which I will change in #135

Add new integration tests exercising the validator lifecycle changes
that can be triggered by admin config updates. Uses the join_network
logic from #130. The tests include:

* onboarding/offboarding: seed genesis validators into config, add a
  4th validator, remove it, and verify chain liveness at each phase

* setting num_vals to zero is impossible: regression test ensuring
  an empty validators field in a Config submission doesn't wipe the
  active set, which would be a catastrophic liveness failure

* end-to-end joined-node promotion: a real node joins via join_network,
  syncs, is promoted to validator via admin reconfig, and both nodes
  converge on identical state

Also adds a few helpers to make working with the tests more ergonomic.
Notably there's a change from using cometbft's `broadcast_tx_commit`
to `broadcast_tx_sync`, which requires polling for tx inclusion,
but avoids a common timeout condition where the HTTP timeout on the
`tx_commit` call was being reached, causing the tests to fail.
This failure occurred sporadically, mostly under load.
);
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The check_config function doesn't ensure that the public keys used for validator identifies are valid. If a config.json contains malformed or outright junk data in a pubkey field, it's possible to vote that config into passing, at which point it'll halt the chain.

Such a failure would require multiple admins to vote it in, but still, the app logic should prevent invalid state from being approved for inclusion by the chain. If a validatory pubkey is tombstoned, the reconfigure request should be explicitly rejected, rather than merely logging a warning.

There are surely other places in the codebase where we're handling consensus-critical values as bytes or strings, when we should in fact be parsing as strong types. I'm not yet certain whether we should just tackle all those updates as part of review here, slotting the changes in via a separate PR, or try to be comprehensive about the change. My bias is toward a comprehensive solution now, while we're thinking about it.

Encountered this logic bug while reviewing #135, so I'm writing here.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

allow admins to update validator set

2 participants