Skip to content

Commit

Permalink
add enable_event_processing option (MystenLabs#2462)
Browse files Browse the repository at this point in the history
  • Loading branch information
longbowlu authored Jun 7, 2022
1 parent 3cb71dc commit fae98f9
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 5 deletions.
1 change: 1 addition & 0 deletions crates/sui-config/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ impl<R: ::rand::RngCore + ::rand::CryptoRng> ConfigBuilder<R> {
metrics_address: utils::available_local_socket_address(),
json_rpc_address: utils::available_local_socket_address(),
consensus_config: Some(consensus_config),
enable_event_processing: false,
genesis: crate::node::Genesis::new(genesis.clone()),
}
})
Expand Down
3 changes: 3 additions & 0 deletions crates/sui-config/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ pub struct NodeConfig {
#[serde(skip_serializing_if = "Option::is_none")]
pub consensus_config: Option<ConsensusConfig>,

#[serde(default)]
pub enable_event_processing: bool,

pub genesis: Genesis,
}

Expand Down
3 changes: 1 addition & 2 deletions crates/sui-config/src/swarm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,8 @@ impl NetworkConfig {
network_address: utils::new_network_address(),
metrics_address: utils::available_local_socket_address(),
json_rpc_address: utils::available_local_socket_address(),

consensus_config: None,

enable_event_processing: true,
genesis: validator_config.genesis.clone(),
}
}
Expand Down
12 changes: 9 additions & 3 deletions crates/sui-core/src/authority.rs
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,7 @@ impl AuthorityState {
indexes: Option<Arc<IndexStore>>,
checkpoints: Option<Arc<Mutex<CheckpointStore>>>,
genesis: &Genesis,
enable_event_processing: bool,
) -> Self {
let (tx, _rx) = tokio::sync::broadcast::channel(BROADCAST_CAPACITY);
let native_functions =
Expand Down Expand Up @@ -825,6 +826,11 @@ impl AuthorityState {
.get_last_epoch_info()
.expect("Fail to load the current epoch info");

let event_handler = if enable_event_processing {
Some(Arc::new(EventHandler::new(store.clone())))
} else {
None
};
let mut state = AuthorityState {
name,
secret,
Expand All @@ -834,10 +840,10 @@ impl AuthorityState {
move_vm,
database: store.clone(),
indexes,
module_cache: SyncModuleCache::new(AuthorityStoreWrapper(store.clone())),
// `event_handler` uses a separate in-mem cache from `module_cache`
// `module_cache` uses a separate in-mem cache from `event_handler`
// this is because they largely deal with different types of MoveStructs
event_handler: Some(Arc::new(EventHandler::new(store.clone()))),
module_cache: SyncModuleCache::new(AuthorityStoreWrapper(store.clone())),
event_handler,
checkpoints,
batch_channels: tx,
batch_notifier: Arc::new(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ impl ConfigurableBatchActionClient {
None,
None,
&sui_config::genesis::Genesis::get_default_genesis(),
false,
)
.await;

Expand Down
1 change: 1 addition & 0 deletions crates/sui-core/src/authority_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ impl LocalAuthorityClient {
None,
Some(Arc::new(Mutex::new(checkpoints))),
genesis,
false,
)
.await;
Self {
Expand Down
4 changes: 4 additions & 0 deletions crates/sui-core/src/checkpoints/tests/checkpoint_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,7 @@ async fn test_batch_to_checkpointing() {
None,
Some(checkpoints.clone()),
&sui_config::genesis::Genesis::get_default_genesis(),
false,
)
.await;
let authority_state = Arc::new(state);
Expand Down Expand Up @@ -820,6 +821,7 @@ async fn test_batch_to_checkpointing_init_crash() {
None,
None,
&sui_config::genesis::Genesis::get_default_genesis(),
false,
)
.await;
let authority_state = Arc::new(state);
Expand Down Expand Up @@ -900,6 +902,7 @@ async fn test_batch_to_checkpointing_init_crash() {
None,
Some(checkpoints.clone()),
&sui_config::genesis::Genesis::get_default_genesis(),
false,
)
.await;
let authority_state = Arc::new(state);
Expand Down Expand Up @@ -1388,6 +1391,7 @@ pub async fn checkpoint_tests_setup(num_objects: usize, batch_interval: Duration
None,
Some(checkpoint.clone()),
&genesis,
false,
)
.await;

Expand Down
1 change: 1 addition & 0 deletions crates/sui-core/src/unit_tests/authority_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1326,6 +1326,7 @@ pub async fn init_state() -> AuthorityState {
None,
None,
&sui_config::genesis::Genesis::get_default_genesis(),
false,
)
.await
}
Expand Down
3 changes: 3 additions & 0 deletions crates/sui-core/src/unit_tests/batch_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ pub(crate) async fn init_state(
None,
None,
&sui_config::genesis::Genesis::get_default_genesis(),
false,
)
.await
}
Expand Down Expand Up @@ -770,6 +771,7 @@ async fn test_safe_batch_stream() {
None,
None,
&sui_config::genesis::Genesis::get_default_genesis(),
false,
)
.await;

Expand Down Expand Up @@ -815,6 +817,7 @@ async fn test_safe_batch_stream() {
None,
None,
&sui_config::genesis::Genesis::get_default_genesis(),
false,
)
.await;
let auth_client_from_byzantine = ByzantineAuthorityClient::new(state_b);
Expand Down
1 change: 1 addition & 0 deletions crates/sui-node/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ impl SuiNode {
index_store,
checkpoint_store,
genesis,
config.enable_event_processing,
)
.await,
);
Expand Down
1 change: 1 addition & 0 deletions crates/sui/src/benchmark/validator_preparer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ fn make_authority_state(
None,
None,
&sui_config::genesis::Genesis::get_default_genesis(),
false,
)
.await
}),
Expand Down

0 comments on commit fae98f9

Please sign in to comment.