Skip to content

Commit

Permalink
refactor: rename idx to epoch
Browse files Browse the repository at this point in the history
  • Loading branch information
prajwolrg committed Jan 30, 2025
1 parent 1599816 commit c82518a
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion bin/strata-client/src/rpc_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ impl<D: Database + Send + Sync + 'static> StrataApiServer for StrataRpcImpl<D> {
Ok(client_state
.l1_view()
.last_finalized_checkpoint()
.map(|checkpoint| checkpoint.batch_info.idx()))
.map(|checkpoint| checkpoint.batch_info.epoch()))

Check warning on line 592 in bin/strata-client/src/rpc_server.rs

View check run for this annotation

Codecov / codecov/patch

bin/strata-client/src/rpc_server.rs#L592

Added line #L592 was not covered by tests
} else {
// get latest checkpoint index from db
let idx = self
Expand Down
4 changes: 2 additions & 2 deletions crates/consensus-logic/src/csm/client_transition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -407,13 +407,13 @@ pub fn filter_verified_checkpoints(
} else {
last_finalized
}
.map(|x| (x.batch_info.idx() + 1, Some(&x.batch_transition)))
.map(|x| (x.batch_info.epoch() + 1, Some(&x.batch_transition)))

Check warning on line 410 in crates/consensus-logic/src/csm/client_transition.rs

View check run for this annotation

Codecov / codecov/patch

crates/consensus-logic/src/csm/client_transition.rs#L410

Added line #L410 was not covered by tests
.unwrap_or((0, None)); // expect the first checkpoint

let mut result_checkpoints = Vec::new();

for checkpoint in checkpoints {
let curr_idx = checkpoint.batch_checkpoint.batch_info().idx;
let curr_idx = checkpoint.batch_checkpoint.batch_info().epoch;
let proof_receipt: ProofReceipt = checkpoint.batch_checkpoint.get_proof_receipt();

Check warning on line 417 in crates/consensus-logic/src/csm/client_transition.rs

View check run for this annotation

Codecov / codecov/patch

crates/consensus-logic/src/csm/client_transition.rs#L416-L417

Added lines #L416 - L417 were not covered by tests
if curr_idx != expected_idx {
warn!(%expected_idx, %curr_idx, "Received invalid checkpoint idx, ignoring.");
Expand Down
4 changes: 2 additions & 2 deletions crates/consensus-logic/src/csm/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ fn apply_action<D: Database>(
SyncAction::WriteCheckpoints(_height, checkpoints) => {
for c in checkpoints.iter() {
let batch_ckp = &c.batch_checkpoint;
let idx = batch_ckp.batch_info().idx();
let idx = batch_ckp.batch_info().epoch();

Check warning on line 313 in crates/consensus-logic/src/csm/worker.rs

View check run for this annotation

Codecov / codecov/patch

crates/consensus-logic/src/csm/worker.rs#L313

Added line #L313 was not covered by tests
let pstatus = CheckpointProvingStatus::ProofReady;
let cstatus = CheckpointConfStatus::Confirmed;
let entry = CheckpointEntry::new(
Expand All @@ -331,7 +331,7 @@ fn apply_action<D: Database>(
SyncAction::FinalizeCheckpoints(_height, checkpoints) => {
for c in checkpoints.iter() {
let batch_ckp = &c.batch_checkpoint;
let idx = batch_ckp.batch_info().idx();
let idx = batch_ckp.batch_info().epoch();

Check warning on line 334 in crates/consensus-logic/src/csm/worker.rs

View check run for this annotation

Codecov / codecov/patch

crates/consensus-logic/src/csm/worker.rs#L334

Added line #L334 was not covered by tests
let pstatus = CheckpointProvingStatus::ProofReady;
let cstatus = CheckpointConfStatus::Finalized;
let entry = CheckpointEntry::new(
Expand Down
2 changes: 1 addition & 1 deletion crates/consensus-logic/src/duty/extractor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ fn extract_batch_duties(
let current_chain_state_root = current_chain_state.compute_state_root();
let l2_transition = (prev_transition.l2_transition.1, current_chain_state_root);

let new_batch = BatchInfo::new(prev_batch_info.idx + 1, l1_range, l2_range, tip_id);
let new_batch = BatchInfo::new(prev_batch_info.epoch + 1, l1_range, l2_range, tip_id);
let new_batch_transition =
BatchTransition::new(l1_transition, l2_transition, rollup_params_commitment);

Check warning on line 142 in crates/consensus-logic/src/duty/extractor.rs

View check run for this annotation

Codecov / codecov/patch

crates/consensus-logic/src/duty/extractor.rs#L138-L142

Added lines #L138 - L142 were not covered by tests

Expand Down
2 changes: 1 addition & 1 deletion crates/consensus-logic/src/duty/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ impl BatchCheckpointDuty {
}

pub fn idx(&self) -> u64 {
self.batch_info.idx()
self.batch_info.epoch()

Check warning on line 111 in crates/consensus-logic/src/duty/types.rs

View check run for this annotation

Codecov / codecov/patch

crates/consensus-logic/src/duty/types.rs#L111

Added line #L111 was not covered by tests
}

pub fn batch_info(&self) -> &BatchInfo {
Expand Down
2 changes: 1 addition & 1 deletion crates/consensus-logic/src/duty/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ fn update_tracker(
let latest_finalized_batch = state
.l1_view()
.last_finalized_checkpoint()
.map(|x| x.batch_info.idx());
.map(|x| x.batch_info.epoch());

Check warning on line 166 in crates/consensus-logic/src/duty/worker.rs

View check run for this annotation

Codecov / codecov/patch

crates/consensus-logic/src/duty/worker.rs#L166

Added line #L166 was not covered by tests

let tracker_update = types::StateUpdate::new(
block_idx,
Expand Down
2 changes: 1 addition & 1 deletion crates/consensus-logic/src/l1_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ pub fn verify_proof(
rollup_params: &RollupParams,
) -> ZkVmResult<()> {
let rollup_vk = rollup_params.rollup_vk;
let checkpoint_idx = checkpoint.batch_info().idx();
let checkpoint_idx = checkpoint.batch_info().epoch();

Check warning on line 189 in crates/consensus-logic/src/l1_handler.rs

View check run for this annotation

Codecov / codecov/patch

crates/consensus-logic/src/l1_handler.rs#L189

Added line #L189 was not covered by tests
info!(%checkpoint_idx, "verifying proof");

// FIXME: we are accepting empty proofs for now (devnet) to reduce dependency on the prover
Expand Down
2 changes: 1 addition & 1 deletion crates/rpc/types/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ pub struct RpcCheckpointInfo {
impl From<BatchInfo> for RpcCheckpointInfo {
fn from(value: BatchInfo) -> Self {
Self {
idx: value.idx,
idx: value.epoch,

Check warning on line 310 in crates/rpc/types/src/types.rs

View check run for this annotation

Codecov / codecov/patch

crates/rpc/types/src/types.rs#L310

Added line #L310 was not covered by tests
l1_range: value.l1_range,
l2_range: value.l2_range,
l2_blockid: value.l2_blockid,
Expand Down
10 changes: 5 additions & 5 deletions crates/state/src/batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ impl From<SignedBatchCheckpoint> for BatchCheckpoint {
Clone, Debug, Eq, PartialEq, Arbitrary, BorshDeserialize, BorshSerialize, Deserialize, Serialize,
)]
pub struct BatchInfo {
/// The index of the checkpoint
pub idx: u64,
/// Checkpoint epoch
pub epoch: u64,

/// L1 height range(inclusive) the checkpoint covers
pub l1_range: (u64, u64),
Expand Down Expand Up @@ -200,15 +200,15 @@ impl BatchInfo {
l2_blockid: L2BlockId,
) -> Self {
Self {
idx: checkpoint_idx,
epoch: checkpoint_idx,
l1_range,
l2_range,
l2_blockid,
}

Check warning on line 207 in crates/state/src/batch.rs

View check run for this annotation

Codecov / codecov/patch

crates/state/src/batch.rs#L196-L207

Added lines #L196 - L207 were not covered by tests
}

pub fn idx(&self) -> u64 {
self.idx
pub fn epoch(&self) -> u64 {
self.epoch

Check warning on line 211 in crates/state/src/batch.rs

View check run for this annotation

Codecov / codecov/patch

crates/state/src/batch.rs#L210-L211

Added lines #L210 - L211 were not covered by tests
}

pub fn l2_blockid(&self) -> &L2BlockId {
Expand Down
2 changes: 1 addition & 1 deletion crates/state/src/operation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ pub fn apply_writes_to_state(
.last_finalized_checkpoint
.as_ref()
.is_none_or(|prev_chp| {
checkpt.batch_info.idx() == prev_chp.batch_info.idx() + 1
checkpt.batch_info.epoch() == prev_chp.batch_info.epoch() + 1

Check warning on line 240 in crates/state/src/operation.rs

View check run for this annotation

Codecov / codecov/patch

crates/state/src/operation.rs#L240

Added line #L240 was not covered by tests
})
{
panic!("operation: mismatched indices of pending checkpoint");
Expand Down

0 comments on commit c82518a

Please sign in to comment.