From 2d35a4494b3507e769b815624e97ffbd98642e73 Mon Sep 17 00:00:00 2001 From: Mauro Piazza Date: Tue, 14 May 2024 18:36:48 +0200 Subject: [PATCH] fix: pass through `NetworkConfig` instead of `NetworkId` as expected from the `SignedEvents` type --- .gitignore | 1 + .../websocket_messages_args/process_batch_args.rs | 9 +++++---- .../src/rpc_server/handlers/handle_process_block.rs | 4 +++- v3_bridges/sentinel-app/src/syncer/syncer_loop.rs | 3 ++- .../src/android/handlers/process_batch.rs | 4 ++-- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 6b0181bcd..dd981deb8 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ target/ *.gz *.env /server +sentinel-app diff --git a/common/sentinel/src/messages/websocket/websocket_messages_args/process_batch_args.rs b/common/sentinel/src/messages/websocket/websocket_messages_args/process_batch_args.rs index 8fd0c3214..fbc985d35 100644 --- a/common/sentinel/src/messages/websocket/websocket_messages_args/process_batch_args.rs +++ b/common/sentinel/src/messages/websocket/websocket_messages_args/process_batch_args.rs @@ -1,16 +1,16 @@ use common_eth::EthSubmissionMaterials; -use common_network_ids::NetworkId; use derive_getters::{Dissolve, Getters}; use derive_more::Constructor; use ethereum_types::Address as EthAddress; use serde::{Deserialize, Serialize}; +use crate::{NetworkConfig}; #[derive(Debug, Clone, PartialEq, Constructor, Serialize, Deserialize, Getters, Dissolve)] pub struct WebSocketMessagesProcessBatchArgs { validate: bool, dry_run: bool, reprocess: bool, - network_id: NetworkId, + network_config: NetworkConfig, pnetwork_hub: EthAddress, sub_mat_batch: EthSubmissionMaterials, governance_address: Option, @@ -19,7 +19,7 @@ pub struct WebSocketMessagesProcessBatchArgs { impl WebSocketMessagesProcessBatchArgs { pub fn new_for_syncer( validate: bool, - network_id: NetworkId, + network_config: NetworkConfig, pnetwork_hub: EthAddress, sub_mat_batch: EthSubmissionMaterials, governance_address: Option, @@ -30,7 +30,8 @@ impl WebSocketMessagesProcessBatchArgs { validate, dry_run, reprocess, - network_id, + // network_id, + network_config, pnetwork_hub, sub_mat_batch, governance_address, diff --git a/v3_bridges/sentinel-app/src/rpc_server/handlers/handle_process_block.rs b/v3_bridges/sentinel-app/src/rpc_server/handlers/handle_process_block.rs index 051cc3ee7..13e35cf42 100644 --- a/v3_bridges/sentinel-app/src/rpc_server/handlers/handle_process_block.rs +++ b/v3_bridges/sentinel-app/src/rpc_server/handlers/handle_process_block.rs @@ -45,11 +45,13 @@ impl RpcCalls { // NOTE: The processor always works on batches let batch = EthSubmissionMaterials::new(vec![sub_mat]); + let network_config = config.networks.get(&network_id).unwrap(); + let submit_args = WebSocketMessagesProcessBatchArgs::new( config.validate(&network_id)?, dry_run, reprocess, - network_id, + network_config.clone(), config.pnetwork_hub(&network_id)?, batch, config.governance_address(&network_id), diff --git a/v3_bridges/sentinel-app/src/syncer/syncer_loop.rs b/v3_bridges/sentinel-app/src/syncer/syncer_loop.rs index f610e8728..a62d2f2a3 100644 --- a/v3_bridges/sentinel-app/src/syncer/syncer_loop.rs +++ b/v3_bridges/sentinel-app/src/syncer/syncer_loop.rs @@ -26,6 +26,7 @@ pub(super) async fn syncer_loop( core_time_limit: &u64, ) -> Result<(), SentinelError> { let network_id = *batch.network_id(); + let network_config = config.networks().get(&network_id).unwrap(); let log_prefix = format!("{network_id} syncer"); let validate = matches!(config.validate(&network_id), Ok(true)); let pnetwork_hub = config.pnetwork_hub(&network_id)?; @@ -76,7 +77,7 @@ pub(super) async fn syncer_loop( info!("{log_prefix} batch is ready to submit!"); let args = WebSocketMessagesProcessBatchArgs::new_for_syncer( validate, - network_id, + network_config.clone(), pnetwork_hub, batch.to_submission_material(), *batch.governance_address(), diff --git a/v3_bridges/sentinel-strongbox/src/android/handlers/process_batch.rs b/v3_bridges/sentinel-strongbox/src/android/handlers/process_batch.rs index c3f426eb7..a087c245e 100644 --- a/v3_bridges/sentinel-strongbox/src/android/handlers/process_batch.rs +++ b/v3_bridges/sentinel-strongbox/src/android/handlers/process_batch.rs @@ -11,7 +11,7 @@ use serde_json::json; use crate::android::State; pub fn process_batch(args: WebSocketMessagesProcessBatchArgs, state: State) -> Result { - let network_id = args.network_id(); + let network_config = args.network_config(); let sentinel_address = ChainDbUtils::new(state.db()).get_signing_address()?; let result = process_batch_of_blocks( @@ -19,7 +19,7 @@ pub fn process_batch(args: WebSocketMessagesProcessBatchArgs, state: State) -> R args.pnetwork_hub(), args.sub_mat_batch(), *args.validate(), - network_id, + network_config, *args.reprocess(), *args.dry_run(), *args.governance_address(),