Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validator key hot swap #11536

Merged
merged 62 commits into from
Jun 24, 2024
Merged

Validator key hot swap #11536

merged 62 commits into from
Jun 24, 2024

Conversation

staffik
Copy link
Contributor

@staffik staffik commented Jun 10, 2024

Issue: #11264

This PR build on:

and contains actual changes and test for validator key hot swap.

Summary

  • Extend UpdateableConfig with validator key.
  • Update client's mutable validator key when we detect it changed in the updateable config.
  • Advertise our new validator key through advertise_tier1_proxies().
  • Add integration test for the new behaviour:
    • We start with 2 validating nodes (node0, node1) and 1 non-validating node (node2). It is important that the non-validating node tracks all shards, because we do not know which shard it will track when we switch validator keys.
    • We copy validator key from node0 to node2.
    • We stop node0, then we trigger validator key reload for node2.
    • Now node2 is a validator, but it figures out as node0 because it copied validator key from node0.
    • We wait for a couple of epochs and we require that both remaining nodes progress the chain. Both nodes should be synchronised after a few epochs.

Test with:

cargo build -pneard --features test_features,rosetta_rpc &&
cargo build -pgenesis-populate -prestaked -pnear-test-contracts &&
python3 pytest/tests/sanity/validator_switch_key_quick.py

Extra changes:

  • Use MutableValidatorSigner alias instead of MutableConfigValue<Option<Arc<ValidatorSigner>>>
  • Return ConfigUpdaterResult from config updater.
  • Remove (de)serialization derives for UpdateableConfigs.

chain/client/src/config_updater.rs Show resolved Hide resolved
chain/client/src/client_actor.rs Outdated Show resolved Hide resolved
github-merge-queue bot pushed a commit that referenced this pull request Jun 21, 2024
Issue: #11264

This is follow-up to #11372.
The actual changes (+test) for
#11264 will be done in a third,
final PR: #11536.

### Summary
This PR should mostly be no-op. It focuses on propagating
`MutableConfigValue` for `validator_signer` everywhere.
All instances of mutable `validator_signer` are synchronized.
In case validator_id only is needed, we propagate `validator_signer`
anyway as it contains the current validator info.

### Extra changes
- Remove signer as a field and pass to methods instead: `Doomslug`,
`InfoHelper`, `ChunkValidator`.
- Make some public methods internal where they do not need to be public.
- Split `process_ready_orphan_witnesses_and_clean_old` into two
functions.
- Removed `block_production_started` from `ClientActorInner`.
- Add `FrozenValidatorConfig` to make it possible to return a snapshot
of `ValidatorConfig`.

---------

Co-authored-by: Your Name <you@example.com>
Base automatically changed from validator-key-hot-swap to master June 21, 2024 08:54
Copy link
Contributor

@wacban wacban left a comment

Choose a reason for hiding this comment

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

LGTM

nearcore/src/dyn_config.rs Outdated Show resolved Hide resolved
pytest/tests/sanity/validator_switch_key_quick.py Outdated Show resolved Hide resolved
@staffik staffik enabled auto-merge June 24, 2024 12:16
@staffik staffik added this pull request to the merge queue Jun 24, 2024
Merged via the queue into master with commit 21ab1ca Jun 24, 2024
27 of 30 checks passed
@staffik staffik deleted the actual-validator-key-hot-swap branch June 24, 2024 15:15
staffik added a commit that referenced this pull request Jun 25, 2024
Issue: #11264

This is follow-up to #11372.
The actual changes (+test) for
#11264 will be done in a third,
final PR: #11536.
This PR should mostly be no-op. It focuses on propagating
`MutableConfigValue` for `validator_signer` everywhere.
All instances of mutable `validator_signer` are synchronized.
In case validator_id only is needed, we propagate `validator_signer`
anyway as it contains the current validator info.
- Remove signer as a field and pass to methods instead: `Doomslug`,
`InfoHelper`, `ChunkValidator`.
- Make some public methods internal where they do not need to be public.
- Split `process_ready_orphan_witnesses_and_clean_old` into two
functions.
- Removed `block_production_started` from `ClientActorInner`.
- Add `FrozenValidatorConfig` to make it possible to return a snapshot
of `ValidatorConfig`.

---------

Co-authored-by: Your Name <you@example.com>
staffik added a commit that referenced this pull request Jun 25, 2024
Issue: #11264

This PR build on:
* #11372
* #11400

and contains actual changes and test for validator key hot swap.

### Summary
- Extend `UpdateableConfig` with validator key.
- Update client's mutable validator key when we detect it changed in the
updateable config.
- Advertise our new validator key through `advertise_tier1_proxies()`.
- Add integration test for the new behaviour:
- We start with 2 validating nodes (`node0`, `node1`) and 1
non-validating node (`node2`). It is important that the non-validating
node tracks all shards, because we do not know which shard it will track
when we switch validator keys.
  - We copy validator key from `node0` to `node2`.
  - We stop `node0`, then we trigger validator key reload for `node2`.
- Now `node2` is a validator, but it figures out as `node0` because it
copied validator key from `node0`.
- We wait for a couple of epochs and we require that both remaining
nodes progress the chain. Both nodes should be synchronised after a few
epochs.


Test with:
```
cargo build -pneard --features test_features,rosetta_rpc &&
cargo build -pgenesis-populate -prestaked -pnear-test-contracts &&
python3 pytest/tests/sanity/validator_switch_key_quick.py
```

#### Extra changes:
- Use `MutableValidatorSigner` alias instead of
`MutableConfigValue<Option<Arc<ValidatorSigner>>>`
- Return `ConfigUpdaterResult` from config updater.
- Remove (de)serialization derives for `UpdateableConfigs`.
-

---------

Co-authored-by: Your Name <you@example.com>
@staffik staffik added the A-stateless-validation Area: stateless validation label Jul 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-stateless-validation Area: stateless validation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants