Skip to content
This repository was archived by the owner on Dec 26, 2024. It is now read-only.

Commit 5c1b07a

Browse files
authored
fix(storage): remove option from state diff commitment (#2150)
1 parent 8f745ec commit 5c1b07a

File tree

13 files changed

+29
-23
lines changed

13 files changed

+29
-23
lines changed

Cargo.lock

+2-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+4-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ serde_repr = "0.1"
128128
serde_yaml = "0.9.16"
129129
sha3 = "0.10.8"
130130
simple_logger = "4.0.0"
131-
starknet_api = "0.13.0-dev.4"
131+
starknet_api = "0.13.0-dev.6"
132132
starknet-core = "0.6.0"
133133
starknet-crypto = "0.5.1"
134134
starknet-types-core = "0.1.2"
@@ -151,3 +151,6 @@ url = "2.2.2"
151151
validator = "0.12"
152152
void = "1.0.2"
153153
zstd = "0.13.1"
154+
155+
[patch.crates-io]
156+
starknet_api = { git = "https://github.com/starkware-libs/starknet-api", rev = "008afd0" }

crates/papyrus_common/resources/block_hash.json

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"l1_da_mode": "CALLDATA",
1818
"transaction_commitment": "0x03ef487dcb7c114e91ffba49b91567a5719a188abe7a03466943588a4b06c453",
1919
"event_commitment": "0x04ca88a5447b4885563a074af8316c6cd0e4e8949ba8f532f08770d2f986fc91",
20+
"state_diff_commitment": "0x0",
2021
"n_transactions": 332,
2122
"n_events": 1561,
2223
"starknet_version": "0.12.1"

crates/papyrus_common/resources/deprecated_block_hash_v0.json

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"l1_da_mode": "CALLDATA",
1818
"transaction_commitment": "0x053191054b8acc338d6624212707ac73ec274150a032ac34fc2a5f22f0ff8104",
1919
"event_commitment": "0x0",
20+
"state_diff_commitment": "0x0",
2021
"n_transactions": 31,
2122
"n_events": 0,
2223
"starknet_version": ""

crates/papyrus_common/resources/deprecated_block_hash_v1.json

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"l1_da_mode": "CALLDATA",
1818
"transaction_commitment": "0x071b80fd924ec690bee7c0bfe7c60c2e222d97e00b8ec5f8cc9cb9dad096dd9d",
1919
"event_commitment": "0x058795269651aea99e230f442a90ba2cf240f19a50b7e50bc36fc35bc7e29cfb",
20+
"state_diff_commitment": "0x0",
2021
"n_transactions": 44,
2122
"n_events": 1,
2223
"starknet_version": ""

crates/papyrus_common/resources/deprecated_block_hash_v1_no_events.json

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"l1_da_mode": "CALLDATA",
1818
"transaction_commitment": "0x018990b555b92ed88c651f0e7e49fe22a3250c1f1d51766ed8c74f33eddb31ca",
1919
"event_commitment": "0x0",
20+
"state_diff_commitment": "0x0",
2021
"n_transactions": 111,
2122
"n_events": 0,
2223
"starknet_version": ""

crates/papyrus_common/resources/deprecated_block_hash_v2.json

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"l1_da_mode": "CALLDATA",
1818
"transaction_commitment": "0x04d94f068f4ed885b4df1c88c7630d7a8d7fb5eb2293a3b302f94d291aff4d0e",
1919
"event_commitment": "0x05a778a5ae9b99428744b982fdb13c4cf5f08db15694c74ce0133c88faf26ba9",
20+
"state_diff_commitment": "0x0",
2021
"n_transactions": 171,
2122
"n_events": 36,
2223
"starknet_version": ""

crates/papyrus_protobuf/src/converters/header.rs

+13-14
Original file line numberDiff line numberDiff line change
@@ -178,17 +178,18 @@ impl TryFrom<protobuf::SignedBlockHeader> for SignedBlockHeader {
178178
.map(|receipts| receipts.try_into().map(ReceiptCommitment))
179179
.transpose()?;
180180

181-
let state_diff_commitment = match value.state_diff_commitment {
182-
None => None,
183-
Some(state_diff_commitment) => Some(StateDiffCommitment(PoseidonHash(
184-
state_diff_commitment
185-
.root
186-
.ok_or(ProtobufConversionError::MissingField {
187-
field_description: "StateDiffCommitment::root",
188-
})?
189-
.try_into()?,
190-
))),
191-
};
181+
let state_diff_commitment = StateDiffCommitment(PoseidonHash(
182+
value
183+
.state_diff_commitment
184+
.ok_or(ProtobufConversionError::MissingField {
185+
field_description: "SignedBlockHeader::state_diff_commitment",
186+
})?
187+
.root
188+
.ok_or(ProtobufConversionError::MissingField {
189+
field_description: "StateDiffCommitment::root",
190+
})?
191+
.try_into()?,
192+
));
192193

193194
Ok(SignedBlockHeader {
194195
block_header: BlockHeader {
@@ -242,9 +243,7 @@ impl From<(BlockHeader, Vec<BlockSignature>)> for protobuf::SignedBlockHeader {
242243
.unwrap_or(0)
243244
.try_into()
244245
.expect("Converting usize to u64 failed"),
245-
root: header
246-
.state_diff_commitment
247-
.map(|state_diff_commitment| state_diff_commitment.0.0.into()),
246+
root: Some(header.state_diff_commitment.0.0.into()),
248247
}),
249248
state_root: Some(header.state_root.0.into()),
250249
// This will be Some only if both n_transactions and transaction_commitment are Some.

crates/papyrus_storage/src/header.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ pub(crate) struct StorageBlockHeader {
7575
pub sequencer: SequencerContractAddress,
7676
pub timestamp: BlockTimestamp,
7777
pub l1_da_mode: L1DataAvailabilityMode,
78-
pub state_diff_commitment: Option<StateDiffCommitment>,
78+
pub state_diff_commitment: StateDiffCommitment,
7979
pub transaction_commitment: Option<TransactionCommitment>,
8080
pub event_commitment: Option<EventCommitment>,
8181
pub receipt_commitment: Option<ReceiptCommitment>,

crates/papyrus_storage/src/serialization/serializers.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ auto_storage_serde! {
159159
pub sequencer: SequencerContractAddress,
160160
pub timestamp: BlockTimestamp,
161161
pub l1_da_mode: L1DataAvailabilityMode,
162-
pub state_diff_commitment: Option<StateDiffCommitment>,
162+
pub state_diff_commitment: StateDiffCommitment,
163163
pub transaction_commitment: Option<TransactionCommitment>,
164164
pub event_commitment: Option<EventCommitment>,
165165
pub receipt_commitment: Option<ReceiptCommitment>,

crates/papyrus_storage/src/test_instances.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ auto_impl_get_test_instance! {
3434
pub sequencer: SequencerContractAddress,
3535
pub timestamp: BlockTimestamp,
3636
pub l1_da_mode: L1DataAvailabilityMode,
37-
pub state_diff_commitment: Option<StateDiffCommitment>,
37+
pub state_diff_commitment: StateDiffCommitment,
3838
pub transaction_commitment: Option<TransactionCommitment>,
3939
pub event_commitment: Option<EventCommitment>,
4040
pub receipt_commitment: Option<ReceiptCommitment>,

crates/starknet_client/src/reader/objects/block.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ impl BlockOrDeprecated {
348348
timestamp: self.timestamp(),
349349
l1_data_gas_price: self.l1_data_gas_price(),
350350
l1_da_mode: self.l1_da_mode(),
351-
state_diff_commitment: Some(StateDiffCommitment(PoseidonHash(state_diff_commitment.0))),
351+
state_diff_commitment: StateDiffCommitment(PoseidonHash(state_diff_commitment.0)),
352352
transaction_commitment,
353353
event_commitment,
354354
// TODO(shahak): Add receipt commitment once it's added to the FGW

crates/test_utils/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ auto_impl_get_test_instance! {
433433
pub sequencer: SequencerContractAddress,
434434
pub timestamp: BlockTimestamp,
435435
pub l1_da_mode: L1DataAvailabilityMode,
436-
pub state_diff_commitment: Option<StateDiffCommitment>,
436+
pub state_diff_commitment: StateDiffCommitment,
437437
pub transaction_commitment: Option<TransactionCommitment>,
438438
pub event_commitment: Option<EventCommitment>,
439439
pub receipt_commitment: Option<ReceiptCommitment>,

0 commit comments

Comments
 (0)