Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for STR-522 #406

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion bin/strata-client/src/helpers.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// TODO clean up this module

use std::{fs, path::Path, sync::Arc, time::Duration};

use anyhow::Context;
Expand All @@ -12,8 +14,8 @@ use reth_rpc_types::engine::JwtSecret;
use rockbound::{rocksdb, OptimisticTransactionDB};
use strata_btcio::rpc::{traits::Wallet, BitcoinClient};
use strata_consensus_logic::{
csm::state_tracker,
duty::types::{Identity, IdentityData, IdentityKey},
state_tracker,
};
use strata_db::{database::CommonDatabase, traits::Database};
use strata_evmexec::{engine::RpcExecEngineCtl, fork_choice_state_initial, EngineRpcClient};
Expand Down
4 changes: 3 additions & 1 deletion bin/strata-client/src/l1_reader.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// TODO clean up this module

use std::sync::Arc;

use strata_btcio::{reader::query::bitcoin_data_reader_task, rpc::traits::Reader};
use strata_consensus_logic::{ctl::CsmController, l1_handler::bitcoin_data_handler_task};
use strata_consensus_logic::{csm::ctl::CsmController, l1_handler::bitcoin_data_handler_task};
use strata_db::traits::{Database, L1DataProvider};
use strata_primitives::params::Params;
use strata_status::StatusTx;
Expand Down
27 changes: 27 additions & 0 deletions crates/consensus-logic/src/csm/config.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
use std::time;

const RETRY_BACKOFF_BASE: u32 = 1024;

/// Run-time config for CSM executor. This is *not* like system params.
pub struct CsmExecConfig {
/// Base retry duration, which is increases exponentially for each retry.
pub retry_base_dur: time::Duration,

/// Maximum retry count.
pub retry_cnt_max: u32,

/// Retry backoff multiplier used to control the exponential backoff.
///
/// This is multiplied against the current wait dur and then divided by
/// 1024. A sensible value for this should ensure that we don't sleep more
/// than 10x-20x `retry_base_dur` before terminating.
pub retry_backoff_mult: u32,
}

impl CsmExecConfig {
/// Computes the next step of retry backoff. This is effectively a fixp
/// multiplication by the `retry_backoff_mult`.
pub fn compute_retry_backoff(&self, cur_dur: time::Duration) -> time::Duration {
(cur_dur * self.retry_backoff_mult) / RETRY_BACKOFF_BASE
}

Check warning on line 26 in crates/consensus-logic/src/csm/config.rs

View check run for this annotation

Codecov / codecov/patch

crates/consensus-logic/src/csm/config.rs#L24-L26

Added lines #L24 - L26 were not covered by tests
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use strata_state::sync_event::SyncEvent;
use tokio::sync::{mpsc, oneshot};
use tracing::*;

use crate::message::CsmMessage;
use super::message::CsmMessage;

/// Controller handle for the consensus state machine. Used to submit new sync
/// events for persistence and processing.
Expand Down
14 changes: 14 additions & 0 deletions crates/consensus-logic/src/csm/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//! Consensus state machine
//!
//! This is responsible for managing the final view of the checkpointing state,
//! tracking unrecognized state from L1, and determining the basis for which
//! unfinalized blocks are committed.
// TODO clean up this module so that specific items are directly exported and
// modules don't have to be

pub mod client_transition;
pub mod config;
pub mod ctl;
pub mod message;
pub mod state_tracker;
pub mod worker;
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ use strata_state::{
};
use tracing::*;

use crate::{client_transition, errors::Error};
use super::client_transition;
use crate::errors::Error;

pub struct StateTracker<D: Database> {
params: Arc<Params>,
Expand Down
Loading
Loading