Skip to content

Commit

Permalink
feat: Single batch type (#43)
Browse files Browse the repository at this point in the history
* types: first pass

* cleanup

* lint

* Remove span batch for now

---------

Co-authored-by: clabby <[email protected]>
  • Loading branch information
tynes and clabby authored Feb 26, 2024
1 parent 6149c7c commit adbab24
Show file tree
Hide file tree
Showing 4 changed files with 182 additions and 42 deletions.
91 changes: 49 additions & 42 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions crates/derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ 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"
hashbrown = "0.14.3"
unsigned-varint = "0.8.0"

# Optional
serde = { version = "1.0.197", default-features = false, features = ["derive"], optional = true }
Expand Down
35 changes: 35 additions & 0 deletions crates/derive/src/types/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
//! This module contains all of the types used within the derivation pipeline.
use alloc::vec::Vec;
use alloy_rlp::{Decodable, Encodable};

mod system_config;
pub use system_config::{SystemAccounts, SystemConfig, SystemConfigUpdateType};

Expand Down Expand Up @@ -38,3 +41,35 @@ pub use channel::Channel;

mod errors;
pub use errors::{StageError, StageResult};

mod single_batch;
pub use single_batch::SingleBatch;

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

impl Encodable for RawTransaction {
fn encode(&self, out: &mut dyn alloy_rlp::BufMut) {
self.0.encode(out)
}
}

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(Debug, 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,
}
Loading

0 comments on commit adbab24

Please sign in to comment.