Skip to content

Commit

Permalink
types: first pass
Browse files Browse the repository at this point in the history
  • Loading branch information
tynes committed Feb 25, 2024
1 parent 1ca215b commit def9879
Show file tree
Hide file tree
Showing 7 changed files with 703 additions and 42 deletions.
89 changes: 48 additions & 41 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ exclude = ["**/target", "benches/", "tests"]

[workspace.dependencies]
anyhow = { version = "1.0.79", default-features = false }
tracing = "0.1.40"
cfg-if = "1.0.0"

[profile.dev]
Expand Down
1 change: 1 addition & 0 deletions crates/derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ alloy-primitives = { version = "0.6.3", default-features = false, features = ["r
alloy-rlp = { version = "0.3.4", default-features = false, features = ["derive"] }
alloy-sol-types = { version = "0.6.3", default-features = false }
async-trait = "0.1.77"
unsigned-varint = "0.8.0"

# Optional
serde = { version = "1.0.197", default-features = false, features = ["derive"], optional = true }
Expand Down
1 change: 1 addition & 0 deletions crates/derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#![allow(dead_code, unused, unreachable_pub)]

extern crate alloc;
extern crate std;

pub mod stages;
pub mod traits;
Expand Down
99 changes: 99 additions & 0 deletions crates/derive/src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,102 @@ pub use eips::{

mod genesis;
pub use genesis::Genesis;

use alloc::string::String;
use alloc::vec::Vec;
use alloy_primitives::{hex, Address, BlockHash};
use alloy_rlp::Decodable;

mod single_batch;
pub use single_batch::SingleBatch;

mod span_batch;
pub use span_batch::SpanBatch;

/// A raw transaction
#[derive(Clone, PartialEq, Eq)]
pub struct RawTransaction(pub Vec<u8>);

impl Decodable for RawTransaction {
/// Decodes RLP encoded bytes into [RawTransaction] bytes
fn decode(buf: &mut &[u8]) -> alloy_rlp::Result<Self> {
let tx_bytes: Vec<u8> = Decodable::decode(buf)?;
Ok(Self(tx_bytes))
}
}

/// A single L2 block derived from a batch.
#[derive(Clone)]
pub struct BlockInput {
/// Timestamp of the L2 block
pub timestamp: u64,
/// Transactions included in this block
pub transactions: Vec<RawTransaction>,
/// The L1 block this batch was fully derived from
pub l1_inclusion_block: u64,
}

/// The global `Magi` configuration.
#[derive(Clone)]
pub struct Config {
/// The L1 chain RPC URL
pub l1_rpc_url: String,
/// The L2 chain RPC URL
pub l2_rpc_url: String,
/// The L2 engine API URL
pub l2_engine_url: String,
/// The L2 chain config
pub chain: ChainConfig,
/// Engine API JWT Secret.
/// This is used to authenticate with the engine API
pub jwt_secret: String,
/// A trusted L2 RPC URL to use for fast/checkpoint syncing
pub checkpoint_sync_url: Option<String>,
/// The port of the `Magi` RPC server
pub rpc_port: u16,
/// If devnet is enabled.
pub devnet: bool,
}

/// Configurations for a blockchain.
#[derive(Clone)]
pub struct ChainConfig {
/// The network name
pub network: String,
/// The L1 chain id
pub l1_chain_id: u64,
/// The L2 chain id
pub l2_chain_id: u64,
/*
/// The L1 genesis block referenced by the L2 chain
pub l1_start_epoch: Epoch,
*/
/// The L2 genesis block info
pub l2_genesis: BlockInfo,
/*
/// The initial system config value
pub system_config: SystemConfig,
*/
/// The batch inbox address
pub batch_inbox: Address,
/// The deposit contract address
pub deposit_contract: Address,
/// The L1 system config contract address
pub system_config_contract: Address,
/// The maximum byte size of all pending channels
pub max_channel_size: u64,
/// The max timeout for a channel (as measured by the frame L1 block number)
pub channel_timeout: u64,
/// Number of L1 blocks in a sequence window
pub seq_window_size: u64,
/// Maximum timestamp drift
pub max_seq_drift: u64,
/// Timestamp of the regolith hardfork
pub regolith_time: u64,
/// Timestamp of the canyon hardfork
pub canyon_time: u64,
/// Timestamp of the delta hardfork
pub delta_time: u64,
/// Network blocktime
pub blocktime: u64,
}
Loading

0 comments on commit def9879

Please sign in to comment.