mirror of
https://github.com/logos-blockchain/logos-blockchain-pocs.git
synced 2026-01-03 21:53:08 +00:00
Merge pull request #59 from logos-co/sovereign-zones-offsite-2025
Sovereign Zones PoC Offsite 2025
This commit is contained in:
commit
609aa9f880
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
Cargo.lock
|
||||
target/
|
||||
.vscode
|
||||
19
sz-poc-offsite-2025/Cargo.toml
Normal file
19
sz-poc-offsite-2025/Cargo.toml
Normal 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" }
|
||||
6
sz-poc-offsite-2025/evm/aggregator/Cargo.toml
Normal file
6
sz-poc-offsite-2025/evm/aggregator/Cargo.toml
Normal file
@ -0,0 +1,6 @@
|
||||
[package]
|
||||
name = "evm-aggregator"
|
||||
edition = { workspace = true }
|
||||
|
||||
[dependencies]
|
||||
reth-ethereum = { workspace = true }
|
||||
14
sz-poc-offsite-2025/evm/aggregator/src/lib.rs
Normal file
14
sz-poc-offsite-2025/evm/aggregator/src/lib.rs
Normal 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);
|
||||
}
|
||||
}
|
||||
14
sz-poc-offsite-2025/evm/sequencer-node/Cargo.toml
Normal file
14
sz-poc-offsite-2025/evm/sequencer-node/Cargo.toml
Normal 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 }
|
||||
68
sz-poc-offsite-2025/evm/sequencer-node/src/main.rs
Normal file
68
sz-poc-offsite-2025/evm/sequencer-node/src/main.rs
Normal 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 } = ¬ification 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
|
||||
})
|
||||
})
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user