Skip to content

Commit

Permalink
Sort commitments in zk (#987)
Browse files Browse the repository at this point in the history
* Sort commitments in zk

* Impl Ord for commitment

* Replace std with core

---------

Co-authored-by: yaziciahmet <yaziciahmetcleargmail.com>
  • Loading branch information
yaziciahmet authored Aug 15, 2024
1 parent a680783 commit 12bb40f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,9 @@ where
}
}

// Sort commitments just in case
sequencer_commitments.sort_unstable();

// Then verify these soft confirmations.

let mut current_state_root = initial_state_root.clone();
Expand Down
12 changes: 12 additions & 0 deletions crates/sovereign-sdk/rollup-interface/src/state_machine/da.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@ pub struct SequencerCommitment {
pub l2_end_block_number: u64,
}

impl core::cmp::PartialOrd for SequencerCommitment {
fn partial_cmp(&self, other: &Self) -> Option<core::cmp::Ordering> {
Some(self.cmp(other))
}
}

impl core::cmp::Ord for SequencerCommitment {
fn cmp(&self, other: &Self) -> core::cmp::Ordering {
self.l2_start_block_number.cmp(&other.l2_start_block_number)
}
}

/// Data written to DA can only be one of these two types
/// Data written to DA and read from DA is must be borsh serialization of this enum
#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, BorshDeserialize, BorshSerialize)]
Expand Down

0 comments on commit 12bb40f

Please sign in to comment.