Merge pull request #59 from logos-co/sovereign-zones-offsite-2025

Sovereign Zones PoC Offsite 2025
This commit is contained in:
Antonio 2025-04-14 10:43:23 +02:00 committed by GitHub
commit 609aa9f880
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 122 additions and 0 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
Cargo.lock
target/
.vscode

View File

@ -0,0 +1,19 @@
[workspace]
members = ["evm/aggregator", "evm/sequencer-node"]
resolver = "3"
[workspace.package]
edition = "2024"
[workspace.dependencies]
# Internal
evm-aggregator = { path = "evm/aggregator" }
evm-sequencer-node = { path = "evm/sequencer-node" }
# External
eyre = { version = "0.6" }
futures = { version = "0.3" }
reth = { git = "https://github.com/paradigmxyz/reth", tag = "v1.3.8" }
reth-ethereum = { git = "https://github.com/paradigmxyz/reth", tag = "v1.3.8" }
reth-ethereum-primitives = { git = "https://github.com/paradigmxyz/reth", tag = "v1.3.8" }
reth-tracing = { git = "https://github.com/paradigmxyz/reth", tag = "v1.3.8" }

View File

@ -0,0 +1,6 @@
[package]
name = "evm-aggregator"
edition = { workspace = true }
[dependencies]
reth-ethereum = { workspace = true }

View File

@ -0,0 +1,14 @@
use reth_ethereum::Block;
// TODO: The logic to batch multiple of these blocks (or the transactions within them) and send them to DA and generate proofs is still missing. It will have to be added at the offsite.
// This type does not support any recovery mechanism, so if the node is stopped, the state DB should be cleaned before starting again. The folder is specified by the `--datadir` option in the binary.
#[derive(Default)]
pub struct Aggregator {
unprocessed_blocks: Vec<Block>,
}
impl Aggregator {
pub fn process_blocks(&mut self, new_blocks: impl Iterator<Item = Block>) {
self.unprocessed_blocks.extend(new_blocks);
}
}

View File

@ -0,0 +1,14 @@
[package]
name = "evm-sequencer-node"
edition = { workspace = true }
[dependencies]
evm-aggregator = { workspace = true }
eyre = { workspace = true }
futures = { workspace = true }
reth = { workspace = true }
reth-ethereum = { workspace = true, features = ["full"] }
reth-ethereum-primitives = { workspace = true }
reth-tracing = { workspace = true }

View File

@ -0,0 +1,68 @@
use evm_aggregator::Aggregator;
use futures::TryStreamExt as _;
use reth::{
api::{FullNodeTypes, NodePrimitives, NodeTypes},
cli::Cli,
};
use reth_ethereum::{
exex::{ExExContext, ExExEvent, ExExNotification},
node::{EthereumNode, api::FullNodeComponents},
};
use reth_tracing::tracing::info;
async fn aggregate_block_txs<Node: FullNodeComponents>(
mut ctx: ExExContext<Node>,
mut aggregator: Aggregator,
) -> eyre::Result<()>
where
<<Node as FullNodeTypes>::Types as NodeTypes>::Primitives:
NodePrimitives<Block = reth_ethereum::Block>,
{
while let Some(notification) = ctx.notifications.try_next().await? {
let ExExNotification::ChainCommitted { new } = &notification else {
continue;
};
info!(committed_chain = ?new.range(), "Received commit");
aggregator.process_blocks(
new.inner()
.0
.clone()
.into_blocks()
.map(reth_ethereum::primitives::RecoveredBlock::into_block),
);
ctx.events
.send(ExExEvent::FinishedHeight(new.tip().num_hash()))
.unwrap();
}
Ok(())
}
fn main() -> eyre::Result<()> {
Cli::try_parse_args_from([
"reth",
"node",
"--datadir=/tmp/reth-dev/",
"--dev",
"--dev.block-time=2s",
"--http.addr=0.0.0.0",
])
.unwrap()
.run(|builder, _| {
Box::pin(async move {
let aggregator = Aggregator::default();
let handle = Box::pin(
builder
.node(EthereumNode::default())
.install_exex("aggregate-block-txs", async move |ctx| {
Ok(aggregate_block_txs(ctx, aggregator))
})
.launch(),
)
.await?;
handle.wait_for_node_exit().await
})
})
}