Skip to content

Commit

Permalink
fix(claimer): make genesis block configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
gligneul committed Nov 21, 2023
1 parent 0169aed commit e17f391
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions offchain/authority-claimer/src/checker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ use std::sync::Arc;
use tracing::trace;
use url::{ParseError, Url};

const GENESIS_BLOCK: u64 = 1;
const MAX_RETRIES: u32 = 10;
const INITIAL_BACKOFF: u64 = 1000;

Expand Down Expand Up @@ -75,6 +74,7 @@ impl DefaultDuplicateChecker {
http_endpoint: String,
history_address: Address,
confirmations: usize,
genesis_block: u64,
) -> Result<Self, DuplicateCheckerError> {
let http = Http::new(Url::parse(&http_endpoint).context(ParseSnafu)?);
let retry_client = RetryClient::new(
Expand All @@ -93,7 +93,7 @@ impl DefaultDuplicateChecker {
history,
claims: Vec::new(),
confirmations,
next_block_to_read: GENESIS_BLOCK,
next_block_to_read: genesis_block,
})
}
}
Expand Down
5 changes: 5 additions & 0 deletions offchain/authority-claimer/src/config/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ pub(crate) struct AuthorityClaimerCLI {

#[command(flatten)]
pub blockchain_config: BlockchainCLIConfig,

/// Genesis block for reading blockchain events
#[arg(long, env, default_value_t = 1)]
pub genesis_block: u64,
}

impl TryFrom<AuthorityClaimerCLI> for AuthorityClaimerConfig {
Expand Down Expand Up @@ -73,6 +77,7 @@ impl TryFrom<AuthorityClaimerCLI> for AuthorityClaimerConfig {
broker_config,
log_config,
blockchain_config,
genesis_block: cli_config.genesis_block,
})
}
}
Expand Down
1 change: 1 addition & 0 deletions offchain/authority-claimer/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ pub struct AuthorityClaimerConfig {
pub broker_config: BrokerConfig,
pub log_config: LogConfig,
pub blockchain_config: BlockchainConfig,
pub genesis_block: u64,
}

#[derive(Debug, Clone)]
Expand Down
1 change: 1 addition & 0 deletions offchain/authority-claimer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ pub async fn run(config: Config) -> Result<(), Box<dyn Error>> {
config.tx_manager_config.provider_http_endpoint.clone(),
config.blockchain_config.history_address.clone(),
config.tx_manager_config.default_confirmations,
config.genesis_block,
)?;

// Creating the transaction sender.
Expand Down

0 comments on commit e17f391

Please sign in to comment.