diff --git a/crates/bin/prove_block/src/lib.rs b/crates/bin/prove_block/src/lib.rs index f0bd0f0b..f179fbbc 100644 --- a/crates/bin/prove_block/src/lib.rs +++ b/crates/bin/prove_block/src/lib.rs @@ -309,8 +309,15 @@ pub async fn prove_block( let updated_root = block_hash_storage_proof.class_commitment.unwrap_or(Felt::ZERO); let previous_root = previous_block_hash_storage_proof.class_commitment.unwrap_or(Felt::ZERO); - let previous_contract_trie_root = previous_block_hash_storage_proof.contract_proof[0].hash::(); - let current_contract_trie_root = block_hash_storage_proof.contract_proof[0].hash::(); + // On devnet and until block 10, the storage_root_idx might be None and that means that contract_proof is empty + let previous_contract_trie_root = match previous_block_hash_storage_proof.contract_proof.first() { + Some(proof) => proof.hash::(), + None => Felt252::ZERO, + }; + let current_contract_trie_root = match block_hash_storage_proof.contract_proof.first() { + Some(proof) => proof.hash::(), + None => Felt252::ZERO, + }; let previous_contract_proofs: Vec<_> = previous_storage_proofs.values().map(|proof| proof.contract_proof.clone()).collect(); diff --git a/crates/bin/prove_block/src/reexecute.rs b/crates/bin/prove_block/src/reexecute.rs index ba33e3ce..15c49195 100644 --- a/crates/bin/prove_block/src/reexecute.rs +++ b/crates/bin/prove_block/src/reexecute.rs @@ -10,7 +10,7 @@ use blockifier::transaction::objects::TransactionExecutionInfo; use blockifier::transaction::transaction_execution::Transaction; use blockifier::transaction::transactions::ExecutableTransaction; use cairo_vm::Felt252; -use rpc_client::pathfinder::proofs::{PathfinderProof, TrieNode}; +use rpc_client::pathfinder::proofs::{ContractData, PathfinderProof, TrieNode}; use rpc_client::RpcClient; use starknet::core::types::{BlockId, StarknetError}; use starknet::providers::{Provider as _, ProviderError}; @@ -163,8 +163,11 @@ pub(crate) fn format_commitment_facts( impl PerContractStorage for ProverPerContractStorage { async fn compute_commitment(&mut self) -> Result { // TODO: error code - let contract_data = - self.storage_proof.contract_data.as_ref().expect("storage proof should have a contract_data field"); + let contract_data = match self.storage_proof.contract_data.as_ref() { + None => &ContractData::default(), + Some(data) => data, + }; + let updated_root = contract_data.root; let commitment_facts = format_commitment_facts::(&contract_data.storage_proofs); diff --git a/crates/rpc-client/src/pathfinder/proofs.rs b/crates/rpc-client/src/pathfinder/proofs.rs index 500156f1..f0315a40 100644 --- a/crates/rpc-client/src/pathfinder/proofs.rs +++ b/crates/rpc-client/src/pathfinder/proofs.rs @@ -38,7 +38,7 @@ impl TrieNode { } } -#[derive(Debug, Clone, Deserialize)] +#[derive(Debug, Clone, Deserialize, Default)] pub struct ContractData { /// Root of the Contract state tree pub root: Felt, @@ -75,7 +75,7 @@ impl ContractData { #[derive(Debug, Clone, Deserialize)] pub struct PathfinderProof { - pub state_commitment: Felt, + pub state_commitment: Option, pub class_commitment: Option, pub contract_proof: Vec, pub contract_data: Option,