Skip to content

Commit

Permalink
fix: pass through NetworkConfig instead of NetworkId as expected …
Browse files Browse the repository at this point in the history
…from the `SignedEvents` type
  • Loading branch information
gitmp01 committed May 15, 2024
1 parent 9400d93 commit 2d35a44
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ target/
*.gz
*.env
/server
sentinel-app
Original file line number Diff line number Diff line change
@@ -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<EthAddress>,
Expand All @@ -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<EthAddress>,
Expand All @@ -30,7 +30,8 @@ impl WebSocketMessagesProcessBatchArgs {
validate,
dry_run,
reprocess,
network_id,
// network_id,
network_config,
pnetwork_hub,
sub_mat_batch,
governance_address,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
3 changes: 2 additions & 1 deletion v3_bridges/sentinel-app/src/syncer/syncer_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
Expand Down Expand Up @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ use serde_json::json;
use crate::android::State;

pub fn process_batch(args: WebSocketMessagesProcessBatchArgs, state: State) -> Result<State, SentinelError> {
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(
state.db(),
args.pnetwork_hub(),
args.sub_mat_batch(),
*args.validate(),
network_id,
network_config,
*args.reprocess(),
*args.dry_run(),
*args.governance_address(),
Expand Down

0 comments on commit 2d35a44

Please sign in to comment.