From 55158fd796d771d1a1795c0cb4ce63807ba0bb99 Mon Sep 17 00:00:00 2001 From: Ayelet Zilber <138376632+ayeletstarkware@users.noreply.github.com> Date: Thu, 26 Dec 2024 11:48:29 +0200 Subject: [PATCH] feat(starknet_batcher): add l2 gas used to decision_reached (#2950) --- crates/starknet_batcher/src/batcher.rs | 5 ++++- crates/starknet_batcher/src/batcher_test.rs | 1 + crates/starknet_batcher_types/src/batcher_types.rs | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/starknet_batcher/src/batcher.rs b/crates/starknet_batcher/src/batcher.rs index 31aea93802..98c40fbcf2 100644 --- a/crates/starknet_batcher/src/batcher.rs +++ b/crates/starknet_batcher/src/batcher.rs @@ -423,7 +423,10 @@ impl Batcher { block_execution_artifacts.tx_hashes(), ) .await?; - Ok(DecisionReachedResponse { state_diff }) + Ok(DecisionReachedResponse { + state_diff, + l2_gas_used: block_execution_artifacts.l2_gas_used, + }) } async fn commit_proposal_and_block( diff --git a/crates/starknet_batcher/src/batcher_test.rs b/crates/starknet_batcher/src/batcher_test.rs index 208697f8f5..cafa2b4faf 100644 --- a/crates/starknet_batcher/src/batcher_test.rs +++ b/crates/starknet_batcher/src/batcher_test.rs @@ -571,6 +571,7 @@ async fn decision_reached() { let response = batcher.decision_reached(DecisionReachedInput { proposal_id: PROPOSAL_ID }).await.unwrap(); assert_eq!(response.state_diff, expected_artifacts.state_diff()); + assert_eq!(response.l2_gas_used, expected_artifacts.l2_gas_used); } #[rstest] diff --git a/crates/starknet_batcher_types/src/batcher_types.rs b/crates/starknet_batcher_types/src/batcher_types.rs index 09765aeb2d..10191a5da2 100644 --- a/crates/starknet_batcher_types/src/batcher_types.rs +++ b/crates/starknet_batcher_types/src/batcher_types.rs @@ -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::execution_resources::GasAmount; use starknet_api::state::ThinStateDiff; use crate::errors::BatcherError; @@ -92,6 +93,7 @@ pub struct SendProposalContentResponse { #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] pub struct DecisionReachedResponse { pub state_diff: ThinStateDiff, + pub l2_gas_used: GasAmount, } #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]