Skip to content

Cleanup and improvements for ControlledValidatorIndices#8896

Merged
tdimitrov merged 6 commits intomasterfrom
tsv-controlled-ind-impr
Jul 2, 2025
Merged

Cleanup and improvements for ControlledValidatorIndices#8896
tdimitrov merged 6 commits intomasterfrom
tsv-controlled-ind-impr

Conversation

@tdimitrov
Copy link
Copy Markdown
Contributor

@tdimitrov tdimitrov commented Jun 18, 2025

Improvements for ControlledValidatorIndices from #8837:
- remove unneeded dependency
- more readable implementations for get and find_controlled_validator_indices

@tdimitrov tdimitrov added T0-node This PR/Issue is related to the topic “node”. T8-polkadot This PR/Issue is related to/affects the Polkadot network. labels Jun 18, 2025
@tdimitrov tdimitrov requested a review from Sajjon June 18, 2025 10:50
Copy link
Copy Markdown
Contributor

@Sajjon Sajjon left a comment

Choose a reason for hiding this comment

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

Lgtm :)

}

controlled
validators
Copy link
Copy Markdown
Contributor

@alexggh alexggh Jun 18, 2025

Choose a reason for hiding this comment

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

bikeshedding/unpopular opinion :D, this is not more readable to me :D.


/// Find indices controlled by this validator.
///
/// That is all `ValidatorIndex`es we have private keys for. Usually this will only be one.
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.

I doubt our code would work if the validator controlled multiple validator keys. We have many subsystems which terminate the search once they find the first one (pvf-checker, statement-distribution, collator-protocol (all which use signing_key_and_index helper fn.
We could modify that to log a warn if it finds multiple keys

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.

signing_key_and_index returns an Option so if we stick to it we don't need to check if more than one index is returned.

We should update dispute-coordinator to use Option for the controlled validator index instead of a HashSet here but I prefer to do this in a separate PR.

Copy link
Copy Markdown
Contributor

@alindima alindima Jun 20, 2025

Choose a reason for hiding this comment

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

I think we should actually modify the inner workings of signing_key_and_index to log an error if it finds multiple validator keys. Maybe we should even fail to start the validator if we detect this (but still log on this function since the keystore probably can change at runtime). But of course, it can be a follow-up.

Copy link
Copy Markdown
Member

@eskimor eskimor Jun 20, 2025

Choose a reason for hiding this comment

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

What about session changes and key rotations? In this case (especially relevant for disputes), we might indeed have two still relevant keys available at a given point in time: One for the old and one for the most recent/current session. For a single session, I would also not see a reason why there should be more than one key.

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.

What about session changes and key rotations? In this case (especially relevant for disputes), we might indeed have two still relevant keys available at a given point in time: One for the old and one for the most recent/current session.

So this is the reason to keep more than one key in dispute-coordinator.

I think we should revert all optimizations and simplifications and just keep this:
https://github.com/paritytech/polkadot-sdk/pull/8896/files#diff-40d27ae9fcbe1c9f5075913a3b52571f075eddb0bd79807b34b34501bda881d1L35

Before we break something :)

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.

all of this key iteration is done per-session. we couldn't have more than one key per session

Copy link
Copy Markdown
Contributor Author

@tdimitrov tdimitrov Jun 20, 2025

Choose a reason for hiding this comment

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

I think @eskimor was referring to my comment about dispute-coordinator:

We should update dispute-coordinator to use Option for the controlled validator index instead of a HashSet here but I prefer to do this in a separate PR.

On second thought, CandiateEnvironment is also per session:

pub struct CandidateEnvironment<'a> {

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.

As discussed offline with @eskimor, this is per session so it is okay.

@tdimitrov tdimitrov enabled auto-merge July 2, 2025 06:26
@tdimitrov tdimitrov added this pull request to the merge queue Jul 2, 2025
Merged via the queue into master with commit 6e3f912 Jul 2, 2025
242 checks passed
@tdimitrov tdimitrov deleted the tsv-controlled-ind-impr branch July 2, 2025 09:37
ordian added a commit that referenced this pull request Jul 24, 2025
* master: (91 commits)
  Add extra information to the harmless error logs during validate_transaction (#9047)
  `sp-tracing`: Remove `test-utils` feature (#9063)
  add try-state check for staking roles -- staker cannot be nominator a… (#9034)
  net/discovery: File persistence for `AddrCache` (#8839)
  dispute-coordinator: handle race with offchain disabling (#9050)
  Align parameters for `EventEmitter::emit_sent_event` (#9057)
  Fetch parent block `api_version` (#9059)
  [XCM Precompile] Rename functions and improve docs in the Solidity interface (#9023)
  Cleanup and improvements for `ControlledValidatorIndices` (#8896)
  reenable 0001-parachains-pvf (#9046)
  Add optional auto-rebag within on-idle (#8684)
  Fix flaxy 0003-block-building-warp-sync test - one more approach (#8974)
  [Staking] [AHM] Fixes insufficient slashing of nominators (and some other small issues). (#8937)
  chore: Bump bounded-collections dep (#9004)
  XCMP and DMP improvements (#8860)
  EPMB/unsigned: fixed multi-page winner computation (#8987)
  Always send full parent header, not only hash, part of collation response (#8939)
  revive: Precompiles should return dummy code when queried (#9001)
  Fix confusing log messages in network protocol behaviour (#8819)
  Fix pallet_migrations benchmark when FailedMigrationHandler emits events (#8694)
  ...
alvicsam pushed a commit that referenced this pull request Oct 17, 2025
Improvements for `ControlledValidatorIndices` from
#8837:
      - remove unneeded dependency
- more readable implementations for `get` and
`find_controlled_validator_indices`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T0-node This PR/Issue is related to the topic “node”. T8-polkadot This PR/Issue is related to/affects the Polkadot network.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants