Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions rust/kona/bin/host/src/interop/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ use kona_providers_alloy::{OnlineBeaconClient, OnlineBlobProvider};
use kona_std_fpvm::{FileChannel, FileDescriptor};
use op_alloy_network::Optimism;
use serde::Serialize;
use std::{collections::HashMap, path::PathBuf, str::FromStr, sync::Arc};
use std::{
collections::{BTreeMap, HashMap},
path::PathBuf,
str::FromStr,
sync::Arc,
};
use tokio::task::{self, JoinHandle};

/// The interop host application.
Expand Down Expand Up @@ -228,13 +233,14 @@ impl InteropHost {
}

/// Reads the [`RollupConfig`]s from the file system and returns a map of L2 chain ID ->
/// [`RollupConfig`]s.
/// [`RollupConfig`]s. Uses `BTreeMap` to ensure deterministic JSON serialization order when
/// these configs are served as preimages to the cannon VM.
pub fn read_rollup_configs(
&self,
) -> Option<Result<HashMap<u64, RollupConfig>, InteropHostError>> {
) -> Option<Result<BTreeMap<u64, RollupConfig>, InteropHostError>> {
let rollup_config_paths = self.rollup_config_paths.as_ref()?;

Some(rollup_config_paths.iter().try_fold(HashMap::default(), |mut acc, path| {
Some(rollup_config_paths.iter().try_fold(BTreeMap::default(), |mut acc, path| {
// Read the serialized config from the file system.
let ser_config = std::fs::read_to_string(path)?;

Expand Down
12 changes: 6 additions & 6 deletions rust/kona/crates/protocol/interop/src/depset.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::MESSAGE_EXPIRY_WINDOW;
use alloc::collections::BTreeMap;
use alloy_primitives::ChainId;
use kona_registry::HashMap;

/// Configuration for a dependency of a chain
#[derive(Debug, Clone, PartialEq, Eq)]
Expand All @@ -15,7 +15,7 @@ pub struct ChainDependency {}
#[allow(clippy::zero_sized_map_values)]
pub struct DependencySet {
/// Dependencies information per chain.
pub dependencies: HashMap<ChainId, ChainDependency>,
pub dependencies: BTreeMap<ChainId, ChainDependency>,

/// Override message expiry window to use for this dependency set.
pub override_message_expiry_window: Option<u64>,
Expand All @@ -35,19 +35,19 @@ impl DependencySet {
#[allow(clippy::zero_sized_map_values)]
mod tests {
use super::*;
use alloc::collections::BTreeMap;
use alloy_primitives::ChainId;
use kona_registry::HashMap;

const fn create_dependency_set(
dependencies: HashMap<ChainId, ChainDependency>,
dependencies: BTreeMap<ChainId, ChainDependency>,
override_expiry: u64,
) -> DependencySet {
DependencySet { dependencies, override_message_expiry_window: Some(override_expiry) }
}

#[test]
fn test_get_message_expiry_window_default() {
let deps = HashMap::default();
let deps = BTreeMap::default();
// override_message_expiry_window is 0, so default should be used
let ds = create_dependency_set(deps, 0);
assert_eq!(
Expand All @@ -59,7 +59,7 @@ mod tests {

#[test]
fn test_get_message_expiry_window_override() {
let deps = HashMap::default();
let deps = BTreeMap::default();
let override_value = 12345;
let ds = create_dependency_set(deps, override_value);
assert_eq!(
Expand Down
Loading