-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(workspace):
kona-interop
crate (#899)
- Loading branch information
Showing
13 changed files
with
1,211 additions
and
123 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
[package] | ||
name = "kona-interop" | ||
description = "Core functionality and primitives for the Interop feature of the OP Stack." | ||
version = "0.1.0" | ||
edition.workspace = true | ||
authors.workspace = true | ||
license.workspace = true | ||
repository.workspace = true | ||
homepage.workspace = true | ||
|
||
[lints] | ||
workspace = true | ||
|
||
[dependencies] | ||
# General | ||
thiserror.workspace = true | ||
async-trait.workspace = true | ||
tracing.workspace = true | ||
|
||
# Alloy | ||
alloy-primitives = { workspace = true, features = ["rlp"] } | ||
alloy-sol-types.workspace = true | ||
alloy-consensus.workspace = true | ||
alloy-rlp.workspace = true | ||
op-alloy-consensus.workspace = true | ||
|
||
# Arbitrary | ||
arbitrary = { version = "1.4", features = ["derive"], optional = true } | ||
|
||
[dev-dependencies] | ||
tokio = { workspace = true, features = ["full"] } | ||
alloy-primitives = { workspace = true, features = ["rlp", "arbitrary"] } | ||
arbitrary = { version = "1.4", features = ["derive"] } | ||
rand.workspace = true | ||
|
||
[features] | ||
arbitrary = ["dep:arbitrary", "alloy-primitives/arbitrary"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# `kona-interop` | ||
|
||
<a href="https://github.com/op-rs/kona/actions/workflows/rust_ci.yaml"><img src="https://github.com/op-rs/kona/actions/workflows/rust_ci.yaml/badge.svg?label=ci" alt="CI"></a> | ||
<a href="https://crates.io/crates/kona-interop"><img src="https://img.shields.io/crates/v/kona-interop.svg?label=kona-interop&labelColor=2a2f35" alt="Kona MPT"></a> | ||
<a href="https://github.com/op-rs/kona/blob/main/LICENSE.md"><img src="https://img.shields.io/badge/License-MIT-d1d1f6.svg?label=license&labelColor=2a2f35" alt="License"></a> | ||
<a href="https://img.shields.io/codecov/c/github/op-rs/kona"><img src="https://img.shields.io/codecov/c/github/op-rs/kona" alt="Codecov"></a> | ||
|
||
Core functionality and primitives for the [Interop feature](https://specs.optimism.io/interop/overview.html) of the OP Stack. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
//! Constants for the OP Stack interop protocol. | ||
use alloy_primitives::{address, Address}; | ||
|
||
/// The address of the L2 cross chain inbox predeploy proxy. | ||
pub const CROSS_L2_INBOX_ADDRESS: Address = address!("4200000000000000000000000000000000000022"); | ||
|
||
/// The expiry window for relaying an initiating message (in seconds). | ||
/// <https://specs.optimism.io/interop/messaging.html#message-expiry-invariant> | ||
pub const MESSAGE_EXPIRY_WINDOW: u64 = 180 * 24 * 60 * 60; | ||
|
||
/// The current version of the [SuperRoot] encoding format. | ||
/// | ||
/// [SuperRoot]: crate::SuperRoot | ||
pub const SUPER_ROOT_VERSION: u8 = 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
//! Error types for the `kona-interop` crate. | ||
use alloc::vec::Vec; | ||
use alloy_primitives::{Address, B256}; | ||
use thiserror::Error; | ||
|
||
/// An error type for the [MessageGraph] struct. | ||
/// | ||
/// [MessageGraph]: crate::MessageGraph | ||
#[derive(Debug, Clone, PartialEq, Eq, Error)] | ||
pub enum MessageGraphError { | ||
/// Dependency set is impossibly empty | ||
#[error("Dependency set is impossibly empty")] | ||
EmptyDependencySet, | ||
/// Remote message not found | ||
#[error("Remote message not found on chain ID {0} with message hash {1}")] | ||
RemoteMessageNotFound(u64, B256), | ||
/// Invalid message origin | ||
#[error("Invalid message origin. Expected {0}, got {1}")] | ||
InvalidMessageOrigin(Address, Address), | ||
/// Invalid message payload hash | ||
#[error("Invalid message hash. Expected {0}, got {1}")] | ||
InvalidMessageHash(B256, B256), | ||
/// Invalid message timestamp | ||
#[error("Invalid message timestamp. Expected {0}, got {1}")] | ||
InvalidMessageTimestamp(u64, u64), | ||
/// Message is in the future | ||
#[error("Message is in the future. Expected timestamp to be <= {0}, got {1}")] | ||
MessageInFuture(u64, u64), | ||
/// Invalid messages were found | ||
#[error("Invalid messages found on chains: {0:?}")] | ||
InvalidMessages(Vec<u64>), | ||
/// Interop provider error | ||
#[error("Interop provider: {0}")] | ||
InteropProviderError(#[from] InteropProviderError), | ||
} | ||
|
||
/// A [Result] alias for the [MessageGraphError] type. | ||
pub type MessageGraphResult<T> = core::result::Result<T, MessageGraphError>; | ||
|
||
/// An error type for the [InteropProvider] trait. | ||
/// | ||
/// [InteropProvider]: crate::InteropProvider | ||
#[derive(Debug, Clone, PartialEq, Eq, Error)] | ||
pub enum InteropProviderError { | ||
/// Unknown Chain ID | ||
#[error("Unknown Chain ID")] | ||
UnknownChainId, | ||
/// Not found | ||
#[error("Not found")] | ||
NotFound, | ||
} | ||
|
||
/// A [Result] alias for the [InteropProviderError] type. | ||
pub type InteropProviderResult<T> = core::result::Result<T, InteropProviderError>; | ||
|
||
/// An error type for the [SuperRoot] struct's serialization and deserialization. | ||
/// | ||
/// [SuperRoot]: crate::SuperRoot | ||
#[derive(Debug, Clone, PartialEq, Eq, Error)] | ||
pub enum SuperRootError { | ||
/// Invalid super root version byte | ||
#[error("Invalid super root version byte")] | ||
InvalidVersionByte, | ||
/// Unexpected encoded super root length | ||
#[error("Unexpected encoded super root length")] | ||
UnexpectedLength, | ||
} | ||
|
||
/// A [Result] alias for the [SuperRootError] type. | ||
pub type SuperRootResult<T> = core::result::Result<T, SuperRootError>; |
Oops, something went wrong.