Skip to content

Commit 4c0792e

Browse files
committed
apollo_batcher: commitment manager input uses apollo committer types
1 parent 028a59e commit 4c0792e

File tree

3 files changed

+19
-13
lines changed

3 files changed

+19
-13
lines changed

crates/apollo_batcher/src/commitment_manager/commitment_manager_impl.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
use std::sync::Arc;
44

55
use apollo_batcher_config::config::BatcherConfig;
6-
use apollo_committer_types::committer_types::CommitBlockResponse;
7-
use apollo_committer_types::communication::SharedCommitterClient;
6+
use apollo_committer_types::committer_types::{CommitBlockRequest, CommitBlockResponse};
7+
use apollo_committer_types::communication::{CommitterRequest, SharedCommitterClient};
88
use starknet_api::block::BlockNumber;
99
use starknet_api::block_hash::block_hash_calculator::{
1010
calculate_block_hash,
@@ -113,7 +113,11 @@ impl<S: StateCommitterTrait> CommitmentManager<S> {
113113
});
114114
}
115115
let commitment_task_input =
116-
CommitmentTaskInput { height, state_diff, state_diff_commitment };
116+
CommitmentTaskInput(CommitterRequest::CommitBlock(CommitBlockRequest {
117+
height,
118+
state_diff,
119+
state_diff_commitment,
120+
}));
117121
let error_message = format!(
118122
"Failed to send commitment task to state committer. Block: {height}, state diff \
119123
commitment: {state_diff_commitment:?}",

crates/apollo_batcher/src/commitment_manager/types.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
#![allow(dead_code)]
22

33
use apollo_committer_types::committer_types::{CommitBlockResponse, RevertBlockResponse};
4+
use apollo_committer_types::communication::CommitterRequest;
45
use apollo_committer_types::errors::CommitterClientResult;
56
use starknet_api::block::{BlockHash, BlockNumber};
6-
use starknet_api::core::{GlobalRoot, StateDiffCommitment};
7-
use starknet_api::state::ThinStateDiff;
7+
use starknet_api::core::GlobalRoot;
88

99
/// Input for commitment tasks.
10-
pub(crate) struct CommitmentTaskInput {
11-
pub(crate) state_diff: ThinStateDiff,
12-
pub(crate) height: BlockNumber,
13-
// Field is optional because for old blocks, the state diff commitment might not be available.
14-
pub(crate) state_diff_commitment: Option<StateDiffCommitment>,
15-
}
10+
pub(crate) struct CommitmentTaskInput(pub(crate) CommitterRequest);
1611

1712
#[derive(Clone)]
1813
pub(crate) struct CommitmentTaskOutput {

crates/apollo_batcher/src/test_utils.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ use apollo_batcher_config::config::{BatcherConfig, FirstBlockWithPartialBlockHas
66
use apollo_batcher_types::batcher_types::{ProposalId, ProposeBlockInput};
77
use apollo_class_manager_types::{EmptyClassManagerClient, SharedClassManagerClient};
88
use apollo_committer_types::committer_types::CommitBlockResponse;
9-
use apollo_committer_types::communication::{MockCommitterClient, SharedCommitterClient};
9+
use apollo_committer_types::communication::{
10+
CommitterRequest,
11+
MockCommitterClient,
12+
SharedCommitterClient,
13+
};
1014
use apollo_l1_provider_types::MockL1ProviderClient;
1115
use apollo_mempool_types::communication::MockMempoolClient;
1216
use apollo_mempool_types::mempool_types::CommitBlockArgs;
@@ -347,7 +351,10 @@ impl MockStateCommitter {
347351
let task = tasks_receiver.try_recv().unwrap();
348352
let result = CommitterTaskResult::Commit(Ok(CommitmentTaskOutput {
349353
response: CommitBlockResponse { state_root: GlobalRoot::default() },
350-
height: task.height,
354+
height: match task.0 {
355+
CommitterRequest::CommitBlock(request) => request.height,
356+
CommitterRequest::RevertBlock(request) => request.height,
357+
},
351358
}));
352359
results_sender.try_send(result).unwrap();
353360
}

0 commit comments

Comments
 (0)