Skip to content

Commit

Permalink
feat(starknet_batcher): add state diff to decision reached response (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ArniStarkware authored Dec 17, 2024
1 parent 86e1541 commit d89c5fb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions crates/starknet_batcher/src/batcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,8 @@ impl Batcher {
let ProposalOutput { state_diff, nonces: address_to_nonce, tx_hashes, .. } =
proposal_output;

self.commit_proposal_and_block(state_diff, address_to_nonce, tx_hashes).await?;
Ok(DecisionReachedResponse {})
self.commit_proposal_and_block(state_diff.clone(), address_to_nonce, tx_hashes).await?;
Ok(DecisionReachedResponse { state_diff })
}

async fn commit_proposal_and_block(
Expand Down
8 changes: 5 additions & 3 deletions crates/starknet_batcher/src/batcher_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ async fn decision_reached() {
.return_once(move |_| {
async move {
Some(Ok(ProposalOutput {
state_diff: ThinStateDiff::default(),
state_diff: test_state_diff(),
commitment: ProposalCommitment::default(),
tx_hashes: test_tx_hashes(),
nonces: test_contract_nonces(),
Expand All @@ -549,12 +549,14 @@ async fn decision_reached() {
.storage_writer
.expect_commit_proposal()
.times(1)
.with(eq(INITIAL_HEIGHT), eq(ThinStateDiff::default()))
.with(eq(INITIAL_HEIGHT), eq(test_state_diff()))
.returning(|_, _| Ok(()));

let mut batcher = create_batcher(mock_dependencies);

batcher.decision_reached(DecisionReachedInput { proposal_id: PROPOSAL_ID }).await.unwrap();
let response =
batcher.decision_reached(DecisionReachedInput { proposal_id: PROPOSAL_ID }).await.unwrap();
assert_eq!(response.state_diff, test_state_diff());
}

#[rstest]
Expand Down
5 changes: 4 additions & 1 deletion crates/starknet_batcher_types/src/batcher_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use serde::{Deserialize, Serialize};
use starknet_api::block::{BlockHashAndNumber, BlockInfo, BlockNumber};
use starknet_api::core::StateDiffCommitment;
use starknet_api::executable_transaction::Transaction;
use starknet_api::state::ThinStateDiff;

use crate::errors::BatcherError;

Expand Down Expand Up @@ -89,7 +90,9 @@ pub struct SendProposalContentResponse {
}

#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
pub struct DecisionReachedResponse {}
pub struct DecisionReachedResponse {
pub state_diff: ThinStateDiff,
}

#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
pub enum ProposalStatus {
Expand Down

0 comments on commit d89c5fb

Please sign in to comment.