From 2feec322fe4b20861956f2a4a438a18ae0464fd7 Mon Sep 17 00:00:00 2001 From: Shreyan Gupta Date: Tue, 30 Apr 2024 16:29:27 -0700 Subject: [PATCH] [stateless_validation] Rename StateWitnessActor to PartialWitnessActor (#11191) Better organization of partial witness actor and actions. Renaming and pushing to a new module. Only refactoring changes. --- chain/client/src/client.rs | 10 ++--- chain/client/src/client_actions.rs | 2 +- chain/client/src/client_actor.rs | 6 +-- chain/client/src/lib.rs | 8 ++-- chain/client/src/stateless_validation/mod.rs | 4 +- .../partial_witness/mod.rs | 3 ++ .../partial_witness_actions.rs} | 12 ++--- .../partial_witness_actor.rs} | 26 +++++------ .../partial_witness_tracker.rs | 6 +-- .../state_witness_producer.rs | 5 ++- ...ter.rs => mock_partial_witness_adapter.rs} | 8 ++-- chain/client/src/test_utils/mod.rs | 2 +- chain/client/src/test_utils/setup.rs | 14 +++--- chain/client/src/test_utils/test_env.rs | 22 ++++----- .../client/src/test_utils/test_env_builder.rs | 12 ++--- chain/client/src/test_utils/test_loop.rs | 21 ++++----- .../test_loop/partial_witness_actions.rs | 32 +++++++++++++ .../test_loop/state_witness_actions.rs | 27 ----------- chain/network/src/peer/peer_actor.rs | 6 +-- chain/network/src/peer/testonly.rs | 8 ++-- .../src/peer_manager/network_state/mod.rs | 8 ++-- .../src/peer_manager/peer_manager_actor.rs | 6 +-- chain/network/src/peer_manager/testonly.rs | 10 ++--- chain/network/src/state_witness.rs | 2 +- .../features/multinode_test_loop_example.rs | 45 ++++++++++--------- .../features/orphan_chunk_state_witness.rs | 6 +-- integration-tests/src/tests/network/runner.rs | 6 +-- nearcore/src/lib.rs | 24 +++++----- 28 files changed, 175 insertions(+), 166 deletions(-) create mode 100644 chain/client/src/stateless_validation/partial_witness/mod.rs rename chain/client/src/stateless_validation/{state_witness_actions.rs => partial_witness/partial_witness_actions.rs} (97%) rename chain/client/src/stateless_validation/{state_witness_actor.rs => partial_witness/partial_witness_actor.rs} (87%) rename chain/client/src/stateless_validation/{ => partial_witness}/partial_witness_tracker.rs (98%) rename chain/client/src/test_utils/{mock_state_witness_adapter.rs => mock_partial_witness_adapter.rs} (66%) create mode 100644 chain/client/src/test_utils/test_loop/partial_witness_actions.rs delete mode 100644 chain/client/src/test_utils/test_loop/state_witness_actions.rs diff --git a/chain/client/src/client.rs b/chain/client/src/client.rs index f0b903690b0..8c2edaa0818 100644 --- a/chain/client/src/client.rs +++ b/chain/client/src/client.rs @@ -7,7 +7,7 @@ use crate::debug::BlockProductionTracker; use crate::debug::PRODUCTION_TIMES_CACHE_SIZE; use crate::stateless_validation::chunk_endorsement_tracker::ChunkEndorsementTracker; use crate::stateless_validation::chunk_validator::ChunkValidator; -use crate::stateless_validation::state_witness_actor::StateWitnessSenderForClient; +use crate::stateless_validation::partial_witness::partial_witness_actor::PartialWitnessSenderForClient; use crate::sync::adapter::SyncShardInfo; use crate::sync::block::BlockSync; use crate::sync::epoch::EpochSync; @@ -186,8 +186,8 @@ pub struct Client { pub chunk_inclusion_tracker: ChunkInclusionTracker, /// Tracks chunk endorsements received from chunk validators. Used to filter out chunks ready for inclusion pub chunk_endorsement_tracker: Arc, - /// Adapter to send request to state_witness_actor to distribute state witness. - pub state_witness_adapter: StateWitnessSenderForClient, + /// Adapter to send request to partial_witness_actor to distribute state witness. + pub partial_witness_adapter: PartialWitnessSenderForClient, // Optional value used for the Chunk Distribution Network Feature. chunk_distribution_network: Option, } @@ -249,7 +249,7 @@ impl Client { rng_seed: RngSeed, snapshot_callbacks: Option, async_computation_spawner: Arc, - state_witness_adapter: StateWitnessSenderForClient, + partial_witness_adapter: PartialWitnessSenderForClient, ) -> Result { let doomslug_threshold_mode = if enable_doomslug { DoomslugThresholdMode::TwoThirds @@ -404,7 +404,7 @@ impl Client { chunk_validator, chunk_inclusion_tracker: ChunkInclusionTracker::new(), chunk_endorsement_tracker, - state_witness_adapter, + partial_witness_adapter, chunk_distribution_network, }) } diff --git a/chain/client/src/client_actions.rs b/chain/client/src/client_actions.rs index a095be0ab21..a37604ca458 100644 --- a/chain/client/src/client_actions.rs +++ b/chain/client/src/client_actions.rs @@ -96,7 +96,7 @@ pub struct SyncJobsSenderForClient { #[derive(Clone, MultiSend, MultiSenderFrom, MultiSendMessage)] #[multi_send_message_derive(Debug)] -pub struct ClientSenderForStateWitness { +pub struct ClientSenderForPartialWitness { pub receive_chunk_state_witness: Sender, } diff --git a/chain/client/src/client_actor.rs b/chain/client/src/client_actor.rs index c5cfd3236da..8bffa280c20 100644 --- a/chain/client/src/client_actor.rs +++ b/chain/client/src/client_actor.rs @@ -35,7 +35,7 @@ use tokio::sync::broadcast; use crate::client_actions::{ClientActionHandler, ClientActions, ClientSenderForClient}; use crate::gc_actor::GCActor; use crate::start_gc_actor; -use crate::stateless_validation::state_witness_actor::StateWitnessSenderForClient; +use crate::stateless_validation::partial_witness::partial_witness_actor::PartialWitnessSenderForClient; use crate::sync_jobs_actions::SyncJobsActions; use crate::sync_jobs_actor::SyncJobsActor; use crate::{metrics, Client, ConfigUpdater, SyncAdapter}; @@ -206,7 +206,7 @@ pub fn start_client( sender: Option>, adv: crate::adversarial::Controls, config_updater: Option, - state_witness_adapter: StateWitnessSenderForClient, + partial_witness_adapter: PartialWitnessSenderForClient, ) -> StartClientResult { let client_arbiter = Arbiter::new(); let client_arbiter_handle = client_arbiter.handle(); @@ -228,7 +228,7 @@ pub fn start_client( random_seed_from_thread(), snapshot_callbacks, Arc::new(RayonAsyncComputationSpawner), - state_witness_adapter, + partial_witness_adapter, ) .unwrap(); let resharding_handle = client.chain.resharding_handle.clone(); diff --git a/chain/client/src/lib.rs b/chain/client/src/lib.rs index 628664ed36b..f72adaebc9c 100644 --- a/chain/client/src/lib.rs +++ b/chain/client/src/lib.rs @@ -21,11 +21,11 @@ pub use near_client_primitives::debug::DebugStatus; pub use near_network::client::{ BlockApproval, BlockResponse, ProcessTxRequest, ProcessTxResponse, SetNetworkInfo, }; -pub use stateless_validation::processing_tracker::{ProcessingDoneTracker, ProcessingDoneWaiter}; -pub use stateless_validation::state_witness_actions::StateWitnessActions; -pub use stateless_validation::state_witness_actor::{ - DistributeStateWitnessRequest, StateWitnessActor, StateWitnessSenderForClientMessage, +pub use stateless_validation::partial_witness::partial_witness_actions::PartialWitnessActions; +pub use stateless_validation::partial_witness::partial_witness_actor::{ + DistributeStateWitnessRequest, PartialWitnessActor, PartialWitnessSenderForClientMessage, }; +pub use stateless_validation::processing_tracker::{ProcessingDoneTracker, ProcessingDoneWaiter}; pub mod adapter; pub mod adversarial; diff --git a/chain/client/src/stateless_validation/mod.rs b/chain/client/src/stateless_validation/mod.rs index b889b761955..55798f17716 100644 --- a/chain/client/src/stateless_validation/mod.rs +++ b/chain/client/src/stateless_validation/mod.rs @@ -1,9 +1,7 @@ pub mod chunk_endorsement_tracker; pub mod chunk_validator; -mod partial_witness_tracker; +pub mod partial_witness; pub mod processing_tracker; mod shadow_validate; -pub mod state_witness_actions; -pub mod state_witness_actor; mod state_witness_producer; pub mod state_witness_tracker; diff --git a/chain/client/src/stateless_validation/partial_witness/mod.rs b/chain/client/src/stateless_validation/partial_witness/mod.rs new file mode 100644 index 00000000000..5c5e5e3271d --- /dev/null +++ b/chain/client/src/stateless_validation/partial_witness/mod.rs @@ -0,0 +1,3 @@ +pub mod partial_witness_actions; +pub mod partial_witness_actor; +mod partial_witness_tracker; diff --git a/chain/client/src/stateless_validation/state_witness_actions.rs b/chain/client/src/stateless_validation/partial_witness/partial_witness_actions.rs similarity index 97% rename from chain/client/src/stateless_validation/state_witness_actions.rs rename to chain/client/src/stateless_validation/partial_witness/partial_witness_actions.rs index 40fdaa3f344..df2ca0b7131 100644 --- a/chain/client/src/stateless_validation/state_witness_actions.rs +++ b/chain/client/src/stateless_validation/partial_witness/partial_witness_actions.rs @@ -16,14 +16,14 @@ use near_primitives::stateless_validation::{ use near_primitives::types::{AccountId, EpochId}; use near_primitives::validator_signer::ValidatorSigner; -use crate::client_actions::ClientSenderForStateWitness; +use crate::client_actions::ClientSenderForPartialWitness; use crate::metrics; +use crate::stateless_validation::state_witness_tracker::ChunkStateWitnessTracker; +use super::partial_witness_actor::DistributeStateWitnessRequest; use super::partial_witness_tracker::{PartialEncodedStateWitnessTracker, RsMap}; -use super::state_witness_actor::DistributeStateWitnessRequest; -use super::state_witness_tracker::ChunkStateWitnessTracker; -pub struct StateWitnessActions { +pub struct PartialWitnessActions { /// Adapter to send messages to the network. network_adapter: PeerManagerAdapter, /// Validator signer to sign the state witness. @@ -39,11 +39,11 @@ pub struct StateWitnessActions { rs_map: RsMap, } -impl StateWitnessActions { +impl PartialWitnessActions { pub fn new( clock: Clock, network_adapter: PeerManagerAdapter, - client_sender: ClientSenderForStateWitness, + client_sender: ClientSenderForPartialWitness, my_signer: Arc, epoch_manager: Arc, ) -> Self { diff --git a/chain/client/src/stateless_validation/state_witness_actor.rs b/chain/client/src/stateless_validation/partial_witness/partial_witness_actor.rs similarity index 87% rename from chain/client/src/stateless_validation/state_witness_actor.rs rename to chain/client/src/stateless_validation/partial_witness/partial_witness_actor.rs index 074851c0406..7e07a62666f 100644 --- a/chain/client/src/stateless_validation/state_witness_actor.rs +++ b/chain/client/src/stateless_validation/partial_witness/partial_witness_actor.rs @@ -17,25 +17,25 @@ use near_primitives::stateless_validation::ChunkStateWitness; use near_primitives::types::EpochId; use near_primitives::validator_signer::ValidatorSigner; -use crate::client_actions::ClientSenderForStateWitness; +use crate::client_actions::ClientSenderForPartialWitness; -use super::state_witness_actions::StateWitnessActions; +use super::partial_witness_actions::PartialWitnessActions; -pub struct StateWitnessActor { - pub actions: StateWitnessActions, +pub struct PartialWitnessActor { + pub actions: PartialWitnessActions, } -impl StateWitnessActor { +impl PartialWitnessActor { pub fn spawn( clock: Clock, network_adapter: PeerManagerAdapter, - client_sender: ClientSenderForStateWitness, + client_sender: ClientSenderForPartialWitness, my_signer: Arc, epoch_manager: Arc, ) -> (actix::Addr, actix::ArbiterHandle) { let arbiter = actix::Arbiter::new().handle(); let addr = Self::start_in_arbiter(&arbiter, |_ctx| Self { - actions: StateWitnessActions::new( + actions: PartialWitnessActions::new( clock, network_adapter, client_sender, @@ -47,7 +47,7 @@ impl StateWitnessActor { } } -impl actix::Actor for StateWitnessActor { +impl actix::Actor for PartialWitnessActor { type Context = actix::Context; } @@ -61,11 +61,11 @@ pub struct DistributeStateWitnessRequest { #[derive(Clone, MultiSend, MultiSenderFrom, MultiSendMessage)] #[multi_send_message_derive(Debug)] -pub struct StateWitnessSenderForClient { +pub struct PartialWitnessSenderForClient { pub distribute_chunk_state_witness: Sender, } -impl actix::Handler> for StateWitnessActor { +impl actix::Handler> for PartialWitnessActor { type Result = (); #[perf] @@ -81,7 +81,7 @@ impl actix::Handler> for StateWit } } -impl actix::Handler> for StateWitnessActor { +impl actix::Handler> for PartialWitnessActor { type Result = (); fn handle( @@ -94,7 +94,7 @@ impl actix::Handler> for StateWitne } } -impl actix::Handler> for StateWitnessActor { +impl actix::Handler> for PartialWitnessActor { type Result = (); fn handle( @@ -110,7 +110,7 @@ impl actix::Handler> for Stat } impl actix::Handler> - for StateWitnessActor + for PartialWitnessActor { type Result = (); diff --git a/chain/client/src/stateless_validation/partial_witness_tracker.rs b/chain/client/src/stateless_validation/partial_witness/partial_witness_tracker.rs similarity index 98% rename from chain/client/src/stateless_validation/partial_witness_tracker.rs rename to chain/client/src/stateless_validation/partial_witness/partial_witness_tracker.rs index e53bb2ffd4b..0313d10f28b 100644 --- a/chain/client/src/stateless_validation/partial_witness_tracker.rs +++ b/chain/client/src/stateless_validation/partial_witness/partial_witness_tracker.rs @@ -11,7 +11,7 @@ use near_primitives::stateless_validation::{EncodedChunkStateWitness, PartialEnc use near_primitives::types::{BlockHeight, ShardId}; use reed_solomon_erasure::galois_8::ReedSolomon; -use crate::client_actions::ClientSenderForStateWitness; +use crate::client_actions::ClientSenderForPartialWitness; /// Max number of chunks to keep in the witness tracker cache. We reach here only after validation /// of the partial_witness so the LRU cache size need not be too large. @@ -142,7 +142,7 @@ impl CacheEntry { /// recreate the full state witness. pub struct PartialEncodedStateWitnessTracker { /// Sender to send the encoded state witness to the client actor. - client_sender: ClientSenderForStateWitness, + client_sender: ClientSenderForPartialWitness, /// Epoch manager to get the set of chunk validators epoch_manager: Arc, /// Keeps track of state witness parts received from chunk producers. @@ -153,7 +153,7 @@ pub struct PartialEncodedStateWitnessTracker { impl PartialEncodedStateWitnessTracker { pub fn new( - client_sender: ClientSenderForStateWitness, + client_sender: ClientSenderForPartialWitness, epoch_manager: Arc, ) -> Self { Self { diff --git a/chain/client/src/stateless_validation/state_witness_producer.rs b/chain/client/src/stateless_validation/state_witness_producer.rs index 8023ef6f492..9ba32b25ef0 100644 --- a/chain/client/src/stateless_validation/state_witness_producer.rs +++ b/chain/client/src/stateless_validation/state_witness_producer.rs @@ -15,9 +15,10 @@ use near_primitives::stateless_validation::{ use near_primitives::types::{AccountId, EpochId}; use crate::stateless_validation::chunk_validator::send_chunk_endorsement_to_block_producers; -use crate::stateless_validation::state_witness_actor::DistributeStateWitnessRequest; use crate::Client; +use super::partial_witness::partial_witness_actor::DistributeStateWitnessRequest; + impl Client { /// Distributes the chunk state witness to chunk validators that are /// selected to validate this chunk. @@ -65,7 +66,7 @@ impl Client { ); } - self.state_witness_adapter.send(DistributeStateWitnessRequest { + self.partial_witness_adapter.send(DistributeStateWitnessRequest { epoch_id: epoch_id.clone(), chunk_header, state_witness, diff --git a/chain/client/src/test_utils/mock_state_witness_adapter.rs b/chain/client/src/test_utils/mock_partial_witness_adapter.rs similarity index 66% rename from chain/client/src/test_utils/mock_state_witness_adapter.rs rename to chain/client/src/test_utils/mock_partial_witness_adapter.rs index fcdeee084ac..e006f0ad479 100644 --- a/chain/client/src/test_utils/mock_state_witness_adapter.rs +++ b/chain/client/src/test_utils/mock_partial_witness_adapter.rs @@ -3,20 +3,20 @@ use std::sync::{Arc, RwLock}; use near_async::messaging::CanSend; -use crate::stateless_validation::state_witness_actor::DistributeStateWitnessRequest; +use crate::stateless_validation::partial_witness::partial_witness_actor::DistributeStateWitnessRequest; #[derive(Clone, Default)] -pub struct MockStateWitnessAdapter { +pub struct MockPartialWitnessAdapter { distribution_request: Arc>>, } -impl CanSend for MockStateWitnessAdapter { +impl CanSend for MockPartialWitnessAdapter { fn send(&self, msg: DistributeStateWitnessRequest) { self.distribution_request.write().unwrap().push_back(msg); } } -impl MockStateWitnessAdapter { +impl MockPartialWitnessAdapter { pub fn pop_distribution_request(&self) -> Option { self.distribution_request.write().unwrap().pop_front() } diff --git a/chain/client/src/test_utils/mod.rs b/chain/client/src/test_utils/mod.rs index 9ee619953bc..1e986bc23bb 100644 --- a/chain/client/src/test_utils/mod.rs +++ b/chain/client/src/test_utils/mod.rs @@ -1,6 +1,6 @@ pub mod block_stats; pub mod client; -mod mock_state_witness_adapter; +mod mock_partial_witness_adapter; pub mod peer_manager_mock; pub mod setup; pub mod test_env; diff --git a/chain/client/src/test_utils/setup.rs b/chain/client/src/test_utils/setup.rs index 3665c66e2fc..9826203a3a9 100644 --- a/chain/client/src/test_utils/setup.rs +++ b/chain/client/src/test_utils/setup.rs @@ -4,8 +4,8 @@ use super::block_stats::BlockStats; use super::peer_manager_mock::PeerManagerMock; -use crate::stateless_validation::state_witness_actor::{ - StateWitnessActor, StateWitnessSenderForClient, +use crate::stateless_validation::partial_witness::partial_witness_actor::{ + PartialWitnessActor, PartialWitnessSenderForClient, }; use crate::{start_view_client, Client, ClientActor, SyncAdapter, SyncStatus, ViewClientActor}; use actix::{Actor, Addr, AsyncContext, Context}; @@ -177,14 +177,14 @@ pub fn setup( SyncAdapter::actix_actor_maker(), ))); - let (state_witness_addr, _) = StateWitnessActor::spawn( + let (partial_witness_addr, _) = PartialWitnessActor::spawn( clock.clone(), network_adapter.clone(), noop().into_multi_sender(), signer.clone(), epoch_manager.clone(), ); - let state_witness_adapter = state_witness_addr.with_auto_span_context(); + let partial_witness_adapter = partial_witness_addr.with_auto_span_context(); let client = Client::new( clock.clone(), config.clone(), @@ -200,7 +200,7 @@ pub fn setup( TEST_SEED, None, Arc::new(RayonAsyncComputationSpawner), - state_witness_adapter.into_multi_sender(), + partial_witness_adapter.into_multi_sender(), ) .unwrap(); let client_actor = ClientActor::new( @@ -974,7 +974,7 @@ pub fn setup_client_with_runtime( archive: bool, save_trie_changes: bool, snapshot_callbacks: Option, - state_witness_adapter: StateWitnessSenderForClient, + partial_witness_adapter: PartialWitnessSenderForClient, validator_signer: Arc, ) -> Client { let mut config = ClientConfig::test( @@ -1008,7 +1008,7 @@ pub fn setup_client_with_runtime( rng_seed, snapshot_callbacks, Arc::new(RayonAsyncComputationSpawner), - state_witness_adapter, + partial_witness_adapter, ) .unwrap(); client.sync_status = SyncStatus::NoSync; diff --git a/chain/client/src/test_utils/test_env.rs b/chain/client/src/test_utils/test_env.rs index 730ec43d18a..0a015dcc298 100644 --- a/chain/client/src/test_utils/test_env.rs +++ b/chain/client/src/test_utils/test_env.rs @@ -42,7 +42,7 @@ use once_cell::sync::OnceCell; use std::collections::{HashMap, HashSet}; use std::sync::{Arc, Mutex}; -use super::mock_state_witness_adapter::MockStateWitnessAdapter; +use super::mock_partial_witness_adapter::MockPartialWitnessAdapter; use super::setup::setup_client_with_runtime; use super::test_env_builder::TestEnvBuilder; use super::TEST_SEED; @@ -58,7 +58,7 @@ pub struct TestEnv { pub validators: Vec, pub network_adapters: Vec>, pub client_adapters: Vec>, - pub state_witness_adapters: Vec, + pub partial_witness_adapters: Vec, pub shards_manager_adapters: Vec, pub clients: Vec, pub(crate) account_indices: AccountIndices, @@ -346,16 +346,16 @@ impl TestEnv { }; let mut witness_processing_done_waiters: Vec = Vec::new(); - // Here we are completely bypassing the state_witness_actor and directly distributing the state witness to the + // Here we are completely bypassing the partial_witness_actor and directly distributing the state witness to the // clients. Ideally the route should have been the following: - // [client] ----(DistributeStateWitnessRequest)----> [state_witness_actor] - // [state_witness_actor] ----(PartialEncodedStateWitness + Forward)----> [state_witness_actor] - // [state_witness_actor] ----(ProcessChunkStateWitnessMessage)----> [client] + // [client] ----(DistributeStateWitnessRequest)----> [partial_witness_actor] + // [partial_witness_actor] ----(PartialEncodedStateWitness + Forward)----> [partial_witness_actor] + // [partial_witness_actor] ----(ProcessChunkStateWitnessMessage)----> [client] // But we go directly from processing DistributeStateWitnessRequest to sending it to all the chunk validators. - // Validation of state witness is done in the state_witness_actor which should be tested by test_loop. - let state_witness_adapters = self.state_witness_adapters.clone(); - for (client_idx, state_witness_adapter) in state_witness_adapters.iter().enumerate() { - while let Some(request) = state_witness_adapter.pop_distribution_request() { + // Validation of state witness is done in the partial_witness_actor which should be tested by test_loop. + let partial_witness_adapters = self.partial_witness_adapters.clone(); + for (client_idx, partial_witness_adapter) in partial_witness_adapters.iter().enumerate() { + while let Some(request) = partial_witness_adapter.pop_distribution_request() { let DistributeStateWitnessRequest { epoch_id, chunk_header, state_witness } = request; let (encoded_witness, _) = @@ -625,7 +625,7 @@ impl TestEnv { self.archive, self.save_trie_changes, None, - self.clients[idx].state_witness_adapter.clone(), + self.clients[idx].partial_witness_adapter.clone(), self.clients[idx].validator_signer.clone().unwrap(), ) } diff --git a/chain/client/src/test_utils/test_env_builder.rs b/chain/client/src/test_utils/test_env_builder.rs index 13157c16694..5c8497fa328 100644 --- a/chain/client/src/test_utils/test_env_builder.rs +++ b/chain/client/src/test_utils/test_env_builder.rs @@ -1,4 +1,4 @@ -use super::mock_state_witness_adapter::MockStateWitnessAdapter; +use super::mock_partial_witness_adapter::MockPartialWitnessAdapter; use super::setup::{setup_client_with_runtime, setup_synchronous_shards_manager}; use super::test_env::TestEnv; use super::{AccountIndices, TEST_SEED}; @@ -511,8 +511,8 @@ impl TestEnvBuilder { let client_adapters = (0..num_clients) .map(|_| Arc::new(MockClientAdapterForShardsManager::default())) .collect_vec(); - let state_witness_adapters = - (0..num_clients).map(|_| MockStateWitnessAdapter::default()).collect_vec(); + let partial_witness_adapters = + (0..num_clients).map(|_| MockPartialWitnessAdapter::default()).collect_vec(); let shards_manager_adapters = (0..num_clients) .map(|i| { let clock = clock.clone(); @@ -537,7 +537,7 @@ impl TestEnvBuilder { .map(|i| { let account_id = clients[i].clone(); let network_adapter = network_adapters[i].clone(); - let state_witness_adapter = state_witness_adapters[i].clone(); + let partial_witness_adapter = partial_witness_adapters[i].clone(); let shards_manager_adapter = shards_manager_adapters[i].clone(); let epoch_manager = epoch_managers[i].clone(); let shard_tracker = shard_trackers[i].clone(); @@ -576,7 +576,7 @@ impl TestEnvBuilder { self.archive, self.save_trie_changes, Some(snapshot_callbacks), - state_witness_adapter.into_multi_sender(), + partial_witness_adapter.into_multi_sender(), validator_signer, ) }) @@ -588,7 +588,7 @@ impl TestEnvBuilder { validators, network_adapters, client_adapters, - state_witness_adapters, + partial_witness_adapters, shards_manager_adapters, clients, account_indices: AccountIndices( diff --git a/chain/client/src/test_utils/test_loop.rs b/chain/client/src/test_utils/test_loop.rs index 187ddd7d11f..5f4376315f8 100644 --- a/chain/client/src/test_utils/test_loop.rs +++ b/chain/client/src/test_utils/test_loop.rs @@ -1,10 +1,11 @@ pub mod client_actions; -pub mod state_witness_actions; +pub mod partial_witness_actions; pub mod sync_actor; pub mod sync_jobs_actions; -use crate::client_actions::ClientSenderForStateWitnessMessage; -use crate::client_actions::{ClientActionHandler, ClientActions}; +use crate::client_actions::{ + ClientActionHandler, ClientActions, ClientSenderForPartialWitnessMessage, +}; use near_async::messaging::{CanSend, SendAsync}; use near_async::test_loop::delay_sender::DelaySender; use near_async::test_loop::event_handler::{LoopEventHandler, TryIntoOrSelf}; @@ -18,8 +19,8 @@ use near_network::client::{ }; use near_network::state_witness::{ ChunkStateWitnessAckMessage, PartialEncodedStateWitnessForwardMessage, - PartialEncodedStateWitnessMessage, StateWitnessSenderForNetwork, - StateWitnessSenderForNetworkMessage, + PartialEncodedStateWitnessMessage, PartialWitnessSenderForNetwork, + PartialWitnessSenderForNetworkMessage, }; use near_network::test_loop::SupportsRoutingLookup; use near_network::types::{NetworkRequests, PeerManagerMessageRequest}; @@ -89,7 +90,7 @@ pub fn route_network_messages_to_client< Event: TryIntoOrSelf + From + From - + From, + + From, >( sender: DelaySender<(usize, Event)>, network_delay: Duration, @@ -117,7 +118,7 @@ pub fn route_network_messages_to_client< sender .with_additional_delay(network_delay) .for_index(idx) - .into_wrapped_multi_sender::() + .into_wrapped_multi_sender::() }) .collect::>(); @@ -350,10 +351,10 @@ impl + AsRef> ClientQueries for Vec { } } -pub fn forward_messages_from_state_witness_actor_to_client( -) -> LoopEventHandler { +pub fn forward_messages_from_partial_witness_actor_to_client( +) -> LoopEventHandler { LoopEventHandler::new_simple(|msg, client_actions: &mut ClientActions| match msg { - ClientSenderForStateWitnessMessage::_receive_chunk_state_witness(msg) => { + ClientSenderForPartialWitnessMessage::_receive_chunk_state_witness(msg) => { client_actions.handle(msg) } }) diff --git a/chain/client/src/test_utils/test_loop/partial_witness_actions.rs b/chain/client/src/test_utils/test_loop/partial_witness_actions.rs new file mode 100644 index 00000000000..aab8470ab8b --- /dev/null +++ b/chain/client/src/test_utils/test_loop/partial_witness_actions.rs @@ -0,0 +1,32 @@ +use crate::{PartialWitnessActions, PartialWitnessSenderForClientMessage}; +use near_async::test_loop::event_handler::LoopEventHandler; +use near_network::state_witness::PartialWitnessSenderForNetworkMessage; + +pub fn forward_messages_from_network_to_partial_witness_actor( +) -> LoopEventHandler { + LoopEventHandler::new_simple(|msg, partial_witness_actions: &mut PartialWitnessActions| { + match msg { + PartialWitnessSenderForNetworkMessage::_chunk_state_witness_ack(msg) => { + partial_witness_actions.handle_chunk_state_witness_ack(msg.0); + } + PartialWitnessSenderForNetworkMessage::_partial_encoded_state_witness(msg) => { + partial_witness_actions.handle_partial_encoded_state_witness(msg.0).unwrap(); + } + PartialWitnessSenderForNetworkMessage::_partial_encoded_state_witness_forward(msg) => { + partial_witness_actions + .handle_partial_encoded_state_witness_forward(msg.0) + .unwrap(); + } + } + }) +} + +pub fn forward_messages_from_client_to_partial_witness_actor( +) -> LoopEventHandler { + LoopEventHandler::new_simple(|msg, state_partial_actions: &mut PartialWitnessActions| match msg + { + PartialWitnessSenderForClientMessage::_distribute_chunk_state_witness(msg) => { + state_partial_actions.handle_distribute_state_witness_request(msg).unwrap(); + } + }) +} diff --git a/chain/client/src/test_utils/test_loop/state_witness_actions.rs b/chain/client/src/test_utils/test_loop/state_witness_actions.rs deleted file mode 100644 index 2083e46ae67..00000000000 --- a/chain/client/src/test_utils/test_loop/state_witness_actions.rs +++ /dev/null @@ -1,27 +0,0 @@ -use crate::{StateWitnessActions, StateWitnessSenderForClientMessage}; -use near_async::test_loop::event_handler::LoopEventHandler; -use near_network::state_witness::StateWitnessSenderForNetworkMessage; - -pub fn forward_messages_from_network_to_state_witness_actor( -) -> LoopEventHandler { - LoopEventHandler::new_simple(|msg, state_witness_actions: &mut StateWitnessActions| match msg { - StateWitnessSenderForNetworkMessage::_chunk_state_witness_ack(msg) => { - state_witness_actions.handle_chunk_state_witness_ack(msg.0); - } - StateWitnessSenderForNetworkMessage::_partial_encoded_state_witness(msg) => { - state_witness_actions.handle_partial_encoded_state_witness(msg.0).unwrap(); - } - StateWitnessSenderForNetworkMessage::_partial_encoded_state_witness_forward(msg) => { - state_witness_actions.handle_partial_encoded_state_witness_forward(msg.0).unwrap(); - } - }) -} - -pub fn forward_messages_from_client_to_state_witness_actor( -) -> LoopEventHandler { - LoopEventHandler::new_simple(|msg, state_witness_actions: &mut StateWitnessActions| match msg { - StateWitnessSenderForClientMessage::_distribute_chunk_state_witness(msg) => { - state_witness_actions.handle_distribute_state_witness_request(msg).unwrap(); - } - }) -} diff --git a/chain/network/src/peer/peer_actor.rs b/chain/network/src/peer/peer_actor.rs index 315f70facc9..b41499c8172 100644 --- a/chain/network/src/peer/peer_actor.rs +++ b/chain/network/src/peer/peer_actor.rs @@ -1021,7 +1021,7 @@ impl PeerActor { None } RoutedMessageBody::ChunkStateWitnessAck(ack) => { - network_state.state_witness_adapter.send(ChunkStateWitnessAckMessage(ack)); + network_state.partial_witness_adapter.send(ChunkStateWitnessAckMessage(ack)); None } RoutedMessageBody::ChunkEndorsement(endorsement) => { @@ -1030,13 +1030,13 @@ impl PeerActor { } RoutedMessageBody::PartialEncodedStateWitness(witness) => { network_state - .state_witness_adapter + .partial_witness_adapter .send(PartialEncodedStateWitnessMessage(witness)); None } RoutedMessageBody::PartialEncodedStateWitnessForward(witness) => { network_state - .state_witness_adapter + .partial_witness_adapter .send(PartialEncodedStateWitnessForwardMessage(witness)); None } diff --git a/chain/network/src/peer/testonly.rs b/chain/network/src/peer/testonly.rs index b3bbaae6855..21436cd213f 100644 --- a/chain/network/src/peer/testonly.rs +++ b/chain/network/src/peer/testonly.rs @@ -13,7 +13,7 @@ use crate::peer_manager::peer_store; use crate::private_actix::SendMessage; use crate::shards_manager::ShardsManagerRequestFromNetwork; use crate::state_witness::{ - StateWitnessSenderForNetworkInput, StateWitnessSenderForNetworkMessage, + PartialWitnessSenderForNetworkInput, PartialWitnessSenderForNetworkMessage, }; use crate::store; use crate::tcp; @@ -46,7 +46,7 @@ pub(crate) enum Event { ShardsManager(ShardsManagerRequestFromNetwork), Client(ClientSenderForNetworkInput), Network(peer_manager_actor::Event), - StateWitness(StateWitnessSenderForNetworkInput), + PartialWitness(PartialWitnessSenderForNetworkInput), } pub(crate) struct PeerHandle { @@ -125,8 +125,8 @@ impl PeerHandle { }); let state_witness_sender = Sender::from_fn({ let send = send.clone(); - move |event: StateWitnessSenderForNetworkMessage| { - send.send(Event::StateWitness(event.into_input())); + move |event: PartialWitnessSenderForNetworkMessage| { + send.send(Event::PartialWitness(event.into_input())); } }); let network_state = Arc::new(NetworkState::new( diff --git a/chain/network/src/peer_manager/network_state/mod.rs b/chain/network/src/peer_manager/network_state/mod.rs index a0fd81d3745..d66b8208120 100644 --- a/chain/network/src/peer_manager/network_state/mod.rs +++ b/chain/network/src/peer_manager/network_state/mod.rs @@ -18,7 +18,7 @@ use crate::routing::route_back_cache::RouteBackCache; use crate::routing::NetworkTopologyChange; use crate::shards_manager::ShardsManagerRequestFromNetwork; use crate::snapshot_hosts::{SnapshotHostInfoError, SnapshotHostsCache}; -use crate::state_witness::StateWitnessSenderForNetwork; +use crate::state_witness::PartialWitnessSenderForNetwork; use crate::stats::metrics; use crate::store; use crate::tcp; @@ -96,7 +96,7 @@ pub(crate) struct NetworkState { pub genesis_id: GenesisId, pub client: ClientSenderForNetwork, pub shards_manager_adapter: Sender, - pub state_witness_adapter: StateWitnessSenderForNetwork, + pub partial_witness_adapter: PartialWitnessSenderForNetwork, /// Network-related info about the chain. pub chain_info: ArcSwap>, @@ -165,7 +165,7 @@ impl NetworkState { genesis_id: GenesisId, client: ClientSenderForNetwork, shards_manager_adapter: Sender, - state_witness_adapter: StateWitnessSenderForNetwork, + partial_witness_adapter: PartialWitnessSenderForNetwork, whitelist_nodes: Vec, ) -> Self { Self { @@ -182,7 +182,7 @@ impl NetworkState { genesis_id, client, shards_manager_adapter, - state_witness_adapter, + partial_witness_adapter, chain_info: Default::default(), tier2: connection::Pool::new(config.node_id()), tier1: connection::Pool::new(config.node_id()), diff --git a/chain/network/src/peer_manager/peer_manager_actor.rs b/chain/network/src/peer_manager/peer_manager_actor.rs index cdd4eaf4814..21aa76d2853 100644 --- a/chain/network/src/peer_manager/peer_manager_actor.rs +++ b/chain/network/src/peer_manager/peer_manager_actor.rs @@ -11,7 +11,7 @@ use crate::peer_manager::connection; use crate::peer_manager::network_state::{NetworkState, WhitelistNode}; use crate::peer_manager::peer_store; use crate::shards_manager::ShardsManagerRequestFromNetwork; -use crate::state_witness::StateWitnessSenderForNetwork; +use crate::state_witness::PartialWitnessSenderForNetwork; use crate::stats::metrics; use crate::store; use crate::tcp; @@ -208,7 +208,7 @@ impl PeerManagerActor { config: config::NetworkConfig, client: ClientSenderForNetwork, shards_manager_adapter: Sender, - state_witness_adapter: StateWitnessSenderForNetwork, + partial_witness_adapter: PartialWitnessSenderForNetwork, genesis_id: GenesisId, ) -> anyhow::Result> { let config = config.verify().context("config")?; @@ -239,7 +239,7 @@ impl PeerManagerActor { genesis_id, client, shards_manager_adapter, - state_witness_adapter, + partial_witness_adapter, whitelist_nodes, )); arbiter.spawn({ diff --git a/chain/network/src/peer_manager/testonly.rs b/chain/network/src/peer_manager/testonly.rs index 17a0e26cb86..282e3f9575a 100644 --- a/chain/network/src/peer_manager/testonly.rs +++ b/chain/network/src/peer_manager/testonly.rs @@ -19,8 +19,8 @@ use crate::peer_manager::network_state::NetworkState; use crate::peer_manager::peer_manager_actor::Event as PME; use crate::shards_manager::ShardsManagerRequestFromNetwork; use crate::snapshot_hosts::SnapshotHostsCache; -use crate::state_witness::StateWitnessSenderForNetworkInput; -use crate::state_witness::StateWitnessSenderForNetworkMessage; +use crate::state_witness::PartialWitnessSenderForNetworkInput; +use crate::state_witness::PartialWitnessSenderForNetworkMessage; use crate::tcp; use crate::test_utils; use crate::testonly::actix::ActixSystem; @@ -73,7 +73,7 @@ pub enum Event { ShardsManager(ShardsManagerRequestFromNetwork), Client(ClientSenderForNetworkInput), PeerManager(PME), - StateWitness(StateWitnessSenderForNetworkInput), + PartialWitness(PartialWitnessSenderForNetworkInput), } pub(crate) struct ActorHandler { @@ -627,8 +627,8 @@ pub(crate) async fn start( }); let state_witness_sender = Sender::from_fn({ let send = send.clone(); - move |event: StateWitnessSenderForNetworkMessage| { - send.send(Event::StateWitness(event.into_input())); + move |event: PartialWitnessSenderForNetworkMessage| { + send.send(Event::PartialWitness(event.into_input())); } }); PeerManagerActor::spawn( diff --git a/chain/network/src/state_witness.rs b/chain/network/src/state_witness.rs index 8f5b73fd340..35677d8818d 100644 --- a/chain/network/src/state_witness.rs +++ b/chain/network/src/state_witness.rs @@ -17,7 +17,7 @@ pub struct PartialEncodedStateWitnessForwardMessage(pub PartialEncodedStateWitne #[derive(Clone, MultiSend, MultiSenderFrom, MultiSendMessage)] #[multi_send_message_derive(Debug)] #[multi_send_input_derive(Debug, Clone, PartialEq, Eq)] -pub struct StateWitnessSenderForNetwork { +pub struct PartialWitnessSenderForNetwork { pub chunk_state_witness_ack: Sender, pub partial_encoded_state_witness: Sender, pub partial_encoded_state_witness_forward: Sender, diff --git a/integration-tests/src/tests/client/features/multinode_test_loop_example.rs b/integration-tests/src/tests/client/features/multinode_test_loop_example.rs index b6804b68070..538a7bdef3f 100644 --- a/integration-tests/src/tests/client/features/multinode_test_loop_example.rs +++ b/integration-tests/src/tests/client/features/multinode_test_loop_example.rs @@ -33,7 +33,7 @@ use near_chunks::test_loop::{ }; use near_chunks::ShardsManager; use near_client::client_actions::{ - ClientActions, ClientSenderForClientMessage, ClientSenderForStateWitnessMessage, + ClientActions, ClientSenderForClientMessage, ClientSenderForPartialWitnessMessage, SyncJobsSenderForClientMessage, }; use near_client::sync::sync_actor::SyncActor; @@ -46,9 +46,9 @@ use near_client::test_utils::test_loop::client_actions::{ forward_client_messages_from_shards_manager, forward_client_messages_from_sync_adapter, forward_client_messages_from_sync_jobs_to_client_actions, }; -use near_client::test_utils::test_loop::state_witness_actions::{ - forward_messages_from_client_to_state_witness_actor, - forward_messages_from_network_to_state_witness_actor, +use near_client::test_utils::test_loop::partial_witness_actions::{ + forward_messages_from_client_to_partial_witness_actor, + forward_messages_from_network_to_partial_witness_actor, }; use near_client::test_utils::test_loop::sync_actor::{ forward_sync_actor_messages_from_client, forward_sync_actor_messages_from_network, @@ -59,11 +59,12 @@ use near_client::test_utils::test_loop::sync_jobs_actions::{ forward_sync_jobs_messages_from_sync_jobs_to_sync_jobs_actions, }; use near_client::test_utils::test_loop::{ - forward_messages_from_state_witness_actor_to_client, print_basic_client_info_before_each_event, + forward_messages_from_partial_witness_actor_to_client, + print_basic_client_info_before_each_event, }; use near_client::test_utils::test_loop::{route_network_messages_to_client, ClientQueries}; use near_client::{ - Client, StateWitnessActions, StateWitnessSenderForClientMessage, SyncAdapter, SyncMessage, + Client, PartialWitnessActions, PartialWitnessSenderForClientMessage, SyncAdapter, SyncMessage, }; use near_epoch_manager::shard_tracker::{ShardTracker, TrackedConfig}; use near_epoch_manager::EpochManager; @@ -72,7 +73,7 @@ use near_network::client::{ }; use near_network::shards_manager::ShardsManagerRequestFromNetwork; use near_network::state_sync::StateSyncResponse; -use near_network::state_witness::StateWitnessSenderForNetworkMessage; +use near_network::state_witness::PartialWitnessSenderForNetworkMessage; use near_network::types::{PeerManagerMessageRequest, PeerManagerMessageResponse, SetChainInfo}; use near_primitives::network::PeerId; use near_primitives::shard_layout::{ShardLayout, ShardUId}; @@ -101,7 +102,7 @@ struct TestData { pub client: ClientActions, pub sync_jobs: SyncJobsActions, pub shards_manager: ShardsManager, - pub state_witness: StateWitnessActions, + pub partial_witness: PartialWitnessActions, pub sync_actors: TestSyncActors, pub state_sync_dumper: StateSyncDumper, pub state_snapshot: StateSnapshotActions, @@ -173,12 +174,12 @@ enum TestEvent { ), /// Calls to the network component to set chain info. SetChainInfo(SetChainInfo), - /// Message from Client to StateWitnessActor. - StateWitnessSenderForClient(StateWitnessSenderForClientMessage), - /// Message from Network to StateWitnessActor. - StateWitnessSenderForNetwork(StateWitnessSenderForNetworkMessage), - /// Message from StateWitnessActor to Client. - ClientSenderForStateWitness(ClientSenderForStateWitnessMessage), + /// Message from Client to PartialWitnessActor. + PartialWitnessSenderForClient(PartialWitnessSenderForClientMessage), + /// Message from Network to PartialWitnessActor. + PArtialWitnessSenderForNetwork(PartialWitnessSenderForNetworkMessage), + /// Message from PartialWitnessActor to Client. + PartialSenderForStateWitness(ClientSenderForPartialWitnessMessage), } const ONE_NEAR: u128 = 1_000_000_000_000_000_000_000_000; @@ -363,7 +364,7 @@ fn test_client_with_multi_test_loop() { builder .sender() .for_index(idx) - .into_wrapped_multi_sender::(), + .into_wrapped_multi_sender::(), ) .unwrap(); @@ -402,13 +403,13 @@ fn test_client_with_multi_test_loop() { ) .unwrap(); - let state_witness_actions = StateWitnessActions::new( + let partial_witness_actions = PartialWitnessActions::new( builder.clock(), builder.sender().for_index(idx).into_multi_sender(), builder .sender() .for_index(idx) - .into_wrapped_multi_sender::(), + .into_wrapped_multi_sender::(), validator_signer, epoch_manager.clone(), ); @@ -435,7 +436,7 @@ fn test_client_with_multi_test_loop() { client: client_actions, sync_jobs: sync_jobs_actions, shards_manager, - state_witness: state_witness_actions, + partial_witness: partial_witness_actions, sync_actors, state_sync_dumper, state_snapshot, @@ -469,7 +470,7 @@ fn test_client_with_multi_test_loop() { ); test.register_handler(forward_client_messages_from_shards_manager().widen().for_index(idx)); test.register_handler( - forward_messages_from_state_witness_actor_to_client().widen().for_index(idx), + forward_messages_from_partial_witness_actor_to_client().widen().for_index(idx), ); test.register_handler(forward_client_messages_from_sync_adapter().widen().for_index(idx)); @@ -506,12 +507,12 @@ fn test_client_with_multi_test_loop() { // Messages to the network layer; multi-node messages are handled below. test.register_handler(ignore_events::().widen().for_index(idx)); - // Messages to StateWitnessActor. + // Messages to PartialWitnessActor. test.register_handler( - forward_messages_from_client_to_state_witness_actor().widen().for_index(idx), + forward_messages_from_client_to_partial_witness_actor().widen().for_index(idx), ); test.register_handler( - forward_messages_from_network_to_state_witness_actor().widen().for_index(idx), + forward_messages_from_network_to_partial_witness_actor().widen().for_index(idx), ); } // Handles network routing. Outgoing messages are handled by emitting incoming messages to the diff --git a/integration-tests/src/tests/client/features/orphan_chunk_state_witness.rs b/integration-tests/src/tests/client/features/orphan_chunk_state_witness.rs index 76cd44a8df6..c22e41d1258 100644 --- a/integration-tests/src/tests/client/features/orphan_chunk_state_witness.rs +++ b/integration-tests/src/tests/client/features/orphan_chunk_state_witness.rs @@ -128,9 +128,9 @@ fn setup_orphan_witness_test() -> OrphanWitnessTestEnv { // The witness isn't processed on `excluded_validator` to give users of // `setup_orphan_witness_test()` full control over the events. let mut encoded_witness_opt = None; - let state_witness_adapter = - env.state_witness_adapters[env.get_client_index(&block2_chunk_producer)].clone(); - while let Some(request) = state_witness_adapter.pop_distribution_request() { + let partial_witness_adapter = + env.partial_witness_adapters[env.get_client_index(&block2_chunk_producer)].clone(); + while let Some(request) = partial_witness_adapter.pop_distribution_request() { let DistributeStateWitnessRequest { epoch_id, chunk_header, state_witness } = request; let (encoded_witness, _) = EncodedChunkStateWitness::encode(&state_witness).unwrap(); let chunk_validators = env diff --git a/integration-tests/src/tests/network/runner.rs b/integration-tests/src/tests/network/runner.rs index e81f50a838d..63308c22fc5 100644 --- a/integration-tests/src/tests/network/runner.rs +++ b/integration-tests/src/tests/network/runner.rs @@ -8,7 +8,7 @@ use near_chain::{Chain, ChainGenesis}; use near_chain_configs::{ClientConfig, Genesis, GenesisConfig}; use near_chunks::shards_manager_actor::start_shards_manager; use near_client::adapter::client_sender_for_network; -use near_client::{start_client, start_view_client, StateWitnessActor, SyncAdapter}; +use near_client::{start_client, start_view_client, PartialWitnessActor, SyncAdapter}; use near_epoch_manager::shard_tracker::ShardTracker; use near_epoch_manager::EpochManager; use near_network::actix::ActixSystem; @@ -128,7 +128,7 @@ fn setup_network_node( runtime.store().clone(), client_config.chunk_request_retry_period, ); - let (state_witness_actor, _) = StateWitnessActor::spawn( + let (partial_witness_actor, _) = PartialWitnessActor::spawn( Clock::real(), network_adapter.as_multi_sender(), client_actor.clone().with_auto_span_context().into_multi_sender(), @@ -142,7 +142,7 @@ fn setup_network_node( config, client_sender_for_network(client_actor, view_client_actor), shards_manager_adapter.as_sender(), - state_witness_actor.with_auto_span_context().into_multi_sender(), + partial_witness_actor.with_auto_span_context().into_multi_sender(), genesis_id, ) .unwrap(); diff --git a/nearcore/src/lib.rs b/nearcore/src/lib.rs index e6aba5de83e..bcabb698dbd 100644 --- a/nearcore/src/lib.rs +++ b/nearcore/src/lib.rs @@ -24,8 +24,8 @@ use near_chunks::shards_manager_actor::start_shards_manager; use near_client::adapter::client_sender_for_network; use near_client::sync::adapter::SyncAdapter; use near_client::{ - start_client, start_view_client, ClientActor, ConfigUpdater, StartClientResult, - StateWitnessActor, ViewClientActor, + start_client, start_view_client, ClientActor, ConfigUpdater, PartialWitnessActor, + StartClientResult, ViewClientActor, }; use near_epoch_manager::shard_tracker::{ShardTracker, TrackedConfig}; use near_epoch_manager::EpochManager; @@ -324,7 +324,7 @@ pub fn start_with_config_and_synchronization( let network_adapter = LateBoundSender::new(); let shards_manager_adapter = LateBoundSender::new(); let client_adapter_for_shards_manager = LateBoundSender::new(); - let client_adapter_for_state_witness_actor = LateBoundSender::new(); + let client_adapter_for_partial_witness_actor = LateBoundSender::new(); let adv = near_client::adversarial::Controls::new(config.client_config.archive); let view_client = start_view_client( @@ -353,16 +353,16 @@ pub fn start_with_config_and_synchronization( ); let snapshot_callbacks = SnapshotCallbacks { make_snapshot_callback, delete_snapshot_callback }; - let (state_witness_actor, state_witness_arbiter) = if config.validator_signer.is_some() { + let (partial_witness_actor, partial_witness_arbiter) = if config.validator_signer.is_some() { let my_signer = config.validator_signer.clone().unwrap(); - let (state_witness_actor, state_witness_arbiter) = StateWitnessActor::spawn( + let (partial_witness_actor, partial_witness_arbiter) = PartialWitnessActor::spawn( Clock::real(), network_adapter.as_multi_sender(), - client_adapter_for_state_witness_actor.as_multi_sender(), + client_adapter_for_partial_witness_actor.as_multi_sender(), my_signer, epoch_manager.clone(), ); - (Some(state_witness_actor), Some(state_witness_arbiter)) + (Some(partial_witness_actor), Some(partial_witness_arbiter)) } else { (None, None) }; @@ -393,7 +393,7 @@ pub fn start_with_config_and_synchronization( shutdown_signal, adv, config_updater, - state_witness_actor + partial_witness_actor .clone() .map(|actor| actor.with_auto_span_context().into_multi_sender()) .unwrap_or_else(|| noop().into_multi_sender()), @@ -402,7 +402,7 @@ pub fn start_with_config_and_synchronization( client_adapter_for_sync.bind(client_actor.clone().with_auto_span_context()) }; client_adapter_for_shards_manager.bind(client_actor.clone().with_auto_span_context()); - client_adapter_for_state_witness_actor.bind(client_actor.clone().with_auto_span_context()); + client_adapter_for_partial_witness_actor.bind(client_actor.clone().with_auto_span_context()); let (shards_manager_actor, shards_manager_arbiter_handle) = start_shards_manager( epoch_manager.clone(), shard_tracker.clone(), @@ -443,7 +443,7 @@ pub fn start_with_config_and_synchronization( config.network_config, client_sender_for_network(client_actor.clone(), view_client.clone()), shards_manager_adapter.as_sender(), - state_witness_actor + partial_witness_actor .map(|actor| actor.with_auto_span_context().into_multi_sender()) .unwrap_or_else(|| noop().into_multi_sender()), genesis_id, @@ -500,8 +500,8 @@ pub fn start_with_config_and_synchronization( if let Some(db_metrics_arbiter) = db_metrics_arbiter { arbiters.push(db_metrics_arbiter); } - if let Some(state_witness_arbiter) = state_witness_arbiter { - arbiters.push(state_witness_arbiter); + if let Some(partial_witness_arbiter) = partial_witness_arbiter { + arbiters.push(partial_witness_arbiter); } Ok(NearNode {