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

refactor: Make validator_signer mutable #11400

Merged
merged 42 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
4c23cfa
Refactor Signer, ValidatorSigner
staffik May 21, 2024
47d9d26
Refactor continued
staffik May 24, 2024
5ca2fd3
refactor
staffik May 26, 2024
b60dde1
formatting
staffik May 26, 2024
edc3486
Pytest
staffik May 15, 2024
3a8b7fd
sighup
May 15, 2024
8d887a5
Dynamic updateable validator key
May 16, 2024
d82dc0b
hotswap
staffik May 26, 2024
6657b3f
Dynamic validator key everywhere
staffik Jun 3, 2024
a335707
Dynamic validator_id for shards_manager_actor
staffik Jun 7, 2024
760f8b3
Advertise Tier1 proxies
staffik Jun 10, 2024
78fe1a8
Adjust ViewClientActorInner
staffik Jun 10, 2024
07ec14a
Adjust StateSyncDumper
staffik Jun 10, 2024
718942a
formatting
staffik Jun 10, 2024
ca88247
clippy
staffik Jun 10, 2024
96bef88
Merge remote-tracking branch 'origin/master' into refactor-signer
staffik Jun 10, 2024
960ca21
clippy
staffik Jun 10, 2024
bc47972
Merge branch 'refactor-signer' into validator-key-hot-swap
staffik Jun 10, 2024
a1ee361
update tests
staffik Jun 10, 2024
f0e444d
add comments
staffik Jun 10, 2024
0b77278
Merge branch 'refactor-signer' into validator-key-hot-swap
staffik Jun 10, 2024
22b1af1
compiler errors
staffik Jun 10, 2024
ff4d55d
style fix
staffik Jun 10, 2024
1866a90
fix
staffik Jun 10, 2024
c3ce95d
nit
staffik Jun 10, 2024
637d384
Merge remote-tracking branch 'origin/master' into validator-key-hot-swap
staffik Jun 10, 2024
a153c73
Turn back into noop
staffik Jun 10, 2024
9ed6095
Fix partial witness actor
staffik Jun 11, 2024
d31ff34
Refactor shards_manager_actor
staffik Jun 11, 2024
485da1c
fix
staffik Jun 11, 2024
054c742
fix
staffik Jun 11, 2024
70cc0ed
Merge remote-tracking branch 'origin/master' into validator-key-hot-swap
staffik Jun 11, 2024
044e772
Refactor client validator_signer
staffik Jun 19, 2024
10c1699
Merge remote-tracking branch 'origin/master' into validator-key-hot-swap
staffik Jun 19, 2024
dc264e8
cargo fmt
staffik Jun 19, 2024
909e03d
FrozenValidatorConfig
staffik Jun 20, 2024
b2646ba
comments
staffik Jun 20, 2024
b053500
Reduce me.as_ref() and prefer &Arc<ValidatorSigner>
staffik Jun 20, 2024
2b04477
Enrich NotAValidator error
staffik Jun 20, 2024
a465905
comment
staffik Jun 20, 2024
9b6e83c
enrich error
staffik Jun 21, 2024
18b9705
Merge remote-tracking branch 'origin/master' into validator-key-hot-swap
staffik Jun 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 16 additions & 7 deletions chain/chain/src/doomslug.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::doomslug::trackable::TrackableBlockHeightValue;
use crate::metrics;
use near_async::time::{Clock, Duration, Instant, Utc};
use near_chain_configs::MutableConfigValue;
use near_client_primitives::debug::{ApprovalAtHeightStatus, ApprovalHistoryEntry};
use near_crypto::Signature;
use near_primitives::block::{Approval, ApprovalInner};
Expand Down Expand Up @@ -138,7 +139,7 @@ pub struct Doomslug {
endorsement_pending: bool,
/// Information to track the timer (see `start_timer` routine in the paper)
timer: DoomslugTimer,
signer: Option<Arc<ValidatorSigner>>,
signer: MutableConfigValue<Option<Arc<ValidatorSigner>>>,
staffik marked this conversation as resolved.
Show resolved Hide resolved
/// How many approvals to have before producing a block. In production should be always `HalfStake`,
/// but for many tests we use `NoApprovals` to invoke more forkfulness
threshold_mode: DoomslugThresholdMode,
Expand Down Expand Up @@ -362,7 +363,7 @@ impl Doomslug {
min_delay: Duration,
delay_step: Duration,
max_delay: Duration,
signer: Option<Arc<ValidatorSigner>>,
signer: MutableConfigValue<Option<Arc<ValidatorSigner>>>,
threshold_mode: DoomslugThresholdMode,
) -> Self {
Doomslug {
Expand Down Expand Up @@ -542,8 +543,8 @@ impl Doomslug {
}

fn create_approval(&self, target_height: BlockHeight) -> Option<Approval> {
self.signer.as_ref().map(|signer| {
Approval::new(self.tip.block_hash, self.tip.height, target_height, &**signer)
self.signer.get().map(|signer| {
Approval::new(self.tip.block_hash, self.tip.height, target_height, &*signer)
})
}

Expand Down Expand Up @@ -777,6 +778,7 @@ mod tests {
};
use crate::Doomslug;
use near_async::time::{Duration, FakeClock, Utc};
use near_chain_configs::MutableConfigValue;
use near_crypto::{KeyType, SecretKey};
use near_primitives::block::{Approval, ApprovalInner};
use near_primitives::hash::hash;
Expand All @@ -787,14 +789,18 @@ mod tests {
#[test]
fn test_endorsements_and_skips_basic() {
let clock = FakeClock::new(Utc::UNIX_EPOCH);
let validator = MutableConfigValue::new(
Some(Arc::new(create_test_signer("test").into())),
"validator_signer",
);
let mut ds = Doomslug::new(
clock.clock(),
0,
Duration::milliseconds(400),
Duration::milliseconds(1000),
Duration::milliseconds(100),
Duration::milliseconds(3000),
Some(Arc::new(create_test_signer("test"))),
validator,
DoomslugThresholdMode::TwoThirds,
);

Expand Down Expand Up @@ -942,7 +948,10 @@ mod tests {
.map(|(account_id, _, _)| create_test_signer(account_id))
.collect::<Vec<_>>();

let signer = Arc::new(create_test_signer("test"));
let signer = MutableConfigValue::new(
Some(Arc::new(create_test_signer("test").into())),
"validator_signer",
);
let clock = FakeClock::new(Utc::UNIX_EPOCH);
let mut ds = Doomslug::new(
clock.clock(),
Expand All @@ -951,7 +960,7 @@ mod tests {
Duration::milliseconds(1000),
Duration::milliseconds(100),
Duration::milliseconds(3000),
Some(signer),
signer,
DoomslugThresholdMode::TwoThirds,
);

Expand Down
10 changes: 8 additions & 2 deletions chain/chain/src/tests/doomslug.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::{Doomslug, DoomslugThresholdMode};
use near_async::time::{Duration, FakeClock, Instant, Utc};
use near_chain_configs::MutableConfigValue;
use near_crypto::{KeyType, SecretKey};
use near_primitives::block::Approval;
use near_primitives::hash::{hash, CryptoHash};
Expand Down Expand Up @@ -47,7 +48,12 @@ fn one_iter(
.collect::<Vec<_>>();
let signers = account_ids
.iter()
.map(|account_id| Arc::new(create_test_signer(account_id)))
.map(|account_id| {
MutableConfigValue::new(
Some(Arc::new(create_test_signer(account_id))),
"validator_signer",
)
})
.collect::<Vec<_>>();
let clock = FakeClock::new(Utc::UNIX_EPOCH);
let mut doomslugs = signers
Expand All @@ -60,7 +66,7 @@ fn one_iter(
Duration::milliseconds(1000),
Duration::milliseconds(100),
delta * 20, // some arbitrary number larger than delta * 6
Some(signer.clone()),
signer.clone(),
DoomslugThresholdMode::TwoThirds,
)
})
Expand Down
Loading
Loading