Skip to content

Commit

Permalink
Use iterators to parse da_data into sequencer commitments (#1457)
Browse files Browse the repository at this point in the history
  • Loading branch information
yaziciahmet authored Nov 11, 2024
1 parent e699aeb commit 1a40a29
Showing 1 changed file with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use sov_modules_api::{
native_debug, native_warn, BasicAddress, BlobReaderTrait, Context, DaSpec, DispatchCall,
Genesis, Signature, Spec, StateCheckpoint, UnsignedSoftConfirmation, WorkingSet,
};
use sov_rollup_interface::da::{DaDataBatchProof, SequencerCommitment};
use sov_rollup_interface::da::DaDataBatchProof;
use sov_rollup_interface::fork::{Fork, ForkManager};
use sov_rollup_interface::soft_confirmation::SignedSoftConfirmation;
use sov_rollup_interface::spec::SpecId;
Expand Down Expand Up @@ -550,18 +550,22 @@ where
) -> ApplySequencerCommitmentsOutput<Self::StateRoot> {
let mut state_diff = CumulativeStateDiff::default();

// First extract all sequencer commitments
// Extract all sequencer commitments.
// Ignore broken DaData and zk proofs. Also ignore ForcedTransaction's (will be implemented in the future).
let mut sequencer_commitments: Vec<SequencerCommitment> = vec![];
for blob in da_data {
if blob.sender().as_ref() == sequencer_da_public_key {
let da_data = DaDataBatchProof::try_from_slice(blob.verified_data());
let mut sequencer_commitments = da_data
.into_iter()
.filter_map(|blob| {
if blob.sender().as_ref() == sequencer_da_public_key {
let da_data = DaDataBatchProof::try_from_slice(blob.verified_data());

if let Ok(DaDataBatchProof::SequencerCommitment(commitment)) = da_data {
sequencer_commitments.push(commitment);
if let Ok(DaDataBatchProof::SequencerCommitment(commitment)) = da_data {
return Some(commitment);
}
}
}
}

None
})
.collect::<Vec<_>>();

// A breakdown of why we sort the sequencer commitments, and why we need fields
// `StateTransitionData::preproven_commitments` and `StateTransitionData::sequencer_commitment_range`:
Expand Down

0 comments on commit 1a40a29

Please sign in to comment.