Skip to content

feat: euclid #107

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
996 changes: 569 additions & 427 deletions Cargo.lock

Large diffs are not rendered by default.

26 changes: 15 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -118,19 +118,19 @@ large_enum_variant = "allow"
[workspace.dependencies]
# alloy
alloy-chains = { version = "0.2.0", default-features = false }
alloy-consensus = { version = "0.14.0", default-features = false }
alloy-eips = { version = "0.14.0", default-features = false }
alloy-json-rpc = { version = "0.14.0", default-features = false }
alloy-network = { version = "0.14.0", default-features = false }
alloy-consensus = { version = "0.15.5", default-features = false }
alloy-eips = { version = "0.15.5", default-features = false }
alloy-json-rpc = { version = "0.15.5", default-features = false }
alloy-network = { version = "0.15.5", default-features = false }
alloy-primitives = { version = "1.0.0", default-features = false }
alloy-provider = { version = "0.14.0", default-features = false }
alloy-rpc-client = { version = "0.14.0", default-features = false }
alloy-rpc-types-engine = { version = "0.14.0", default-features = false }
alloy-rpc-types-eth = { version = "0.14.0", default-features = false }
alloy-provider = { version = "0.15.5", default-features = false }
alloy-rpc-client = { version = "0.15.5", default-features = false }
alloy-rpc-types-engine = { version = "0.15.5", default-features = false }
alloy-rpc-types-eth = { version = "0.15.5", default-features = false }
alloy-sol-types = { version = "1.0.0", default-features = false }
alloy-signer = { version = "0.14.0", default-features = false }
alloy-signer-local = { version = "0.14.0", default-features = false }
alloy-transport = { version = "0.14.0", default-features = false }
alloy-signer = { version = "0.15.5", default-features = false }
alloy-signer-local = { version = "0.15.5", default-features = false }
alloy-transport = { version = "0.15.5", default-features = false }

# scroll-alloy
scroll-alloy-consensus = { git = "https://github.com/scroll-tech/reth.git", default-features = false }
Expand Down Expand Up @@ -195,3 +195,7 @@ thiserror = "2.0"
tokio = { version = "1.39", default-features = false }
tokio-stream = { version = "0.1", default-features = false }
tracing = "0.1.0"

[patch.crates-io]
revm = { git = "https://github.com/scroll-tech/revm", branch = "feat/reth" }
op-revm = { git = "https://github.com/scroll-tech/revm", branch = "feat/reth" }
2 changes: 2 additions & 0 deletions bin/rollup/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ alloy-transport.workspace = true

# scroll-alloy
scroll-alloy-consensus.workspace = true
scroll-alloy-hardforks.workspace = true
scroll-alloy-provider.workspace = true
scroll-alloy-rpc-types-engine.workspace = true

Expand Down Expand Up @@ -114,6 +115,7 @@ serde = [
"alloy-chains/serde",
"reth-transaction-pool/serde",
"url/serde",
"scroll-alloy-hardforks/serde",
]

[[bin]]
Expand Down
4 changes: 4 additions & 0 deletions bin/rollup/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ pub struct ScrollRollupNodeArgs {
/// A bool that represents if the scroll wire protocol should be enabled.
#[arg(long, default_value_t = false)]
pub enable_scroll_wire: bool,
/// A bool that represents whether optimistic sync of the EN should be performed.
/// This is a temp solution and should be removed when implementing issue #23.
#[arg(long, default_value_t = false)]
pub optimistic_sync: bool,
/// Database path
#[arg(long)]
pub database_path: Option<PathBuf>,
Expand Down
7 changes: 5 additions & 2 deletions bin/rollup/src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use reth_node_builder::{components::NetworkBuilder, BuilderContext, FullNodeType
use reth_node_types::NodeTypes;
use reth_rpc_builder::config::RethRpcServerConfig;
use reth_scroll_chainspec::ScrollChainSpec;
use reth_scroll_node::ScrollHeaderTransform;
use reth_scroll_primitives::ScrollPrimitives;
use reth_transaction_pool::{PoolTransaction, TransactionPool};
use rollup_node_manager::{Consensus, NoopConsensus, PoAConsensus, RollupNodeManager};
Expand Down Expand Up @@ -77,6 +78,7 @@ where
// Create the network configuration.
let mut config = ctx.network_config()?;
config.network_mode = NetworkMode::Work;
config.header_transform = ScrollHeaderTransform::boxed(ctx.chain_spec());
if let Some(tx) = block_tx {
config.block_import = Box::new(super::BridgeBlockImport::new(tx.clone()))
}
Expand Down Expand Up @@ -113,7 +115,7 @@ where
compute_units_per_second,
))
.http(url);
Some(ProviderBuilder::new().on_client(client))
Some(ProviderBuilder::new().connect_client(client))
} else {
None
};
Expand All @@ -131,7 +133,7 @@ where
self.config.l2_provider_args.compute_units_per_second,
))
.http(Url::parse(&l2_provider_url)?);
let provider = ProviderBuilder::new().on_client(client);
let provider = ProviderBuilder::new().connect_client(client);
Some(AlloyExecutionPayloadProvider::new(provider))
};

Expand All @@ -144,6 +146,7 @@ where
Arc::new(engine_api),
payload_provider,
fcs,
self.config.optimistic_sync,
Duration::from_millis(self.config.sequencer_args.payload_building_duration),
);

Expand Down
1 change: 1 addition & 0 deletions bin/rollup/tests/e2e.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ pub async fn build_bridge_node(
test: true,
enable_eth_scroll_wire_bridge: true,
enable_scroll_wire: true,
optimistic_sync: false,
database_path: Some(PathBuf::from("sqlite::memory:")),
l1_provider_args: L1ProviderArgs::default(),
engine_api_url: None,
Expand Down
19 changes: 16 additions & 3 deletions crates/engine/src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ pub struct EngineDriver<EC, P = ()> {
execution_payload_provider: Option<P>,
/// The fork choice state of the engine.
fcs: ForkchoiceState,
/// Whether the node should perform optimistic sync.
optimistic_sync: bool,
/// Block building duration.
block_building_duration: Duration,
/// The pending payload attributes derived from batches on L1.
Expand All @@ -48,13 +50,15 @@ where
client: Arc<EC>,
execution_payload_provider: Option<P>,
fcs: ForkchoiceState,
optimistic_sync: bool,
block_building_duration: Duration,
) -> Self {
Self {
client,
execution_payload_provider,
fcs,
block_building_duration,
optimistic_sync,
l1_payload_attributes: VecDeque::new(),
block_imports: VecDeque::new(),
sequencer_payload_attributes: None,
Expand Down Expand Up @@ -222,7 +226,16 @@ where
let fcs = this.fcs.get_alloy_fcs();
let client = this.client.clone();

this.future = Some(EngineDriverFuture::block_import(client, block_with_peer, fcs));
this.future = Some(EngineDriverFuture::block_import(
client,
block_with_peer,
fcs,
this.optimistic_sync,
));

// only perform optimistic sync once.
this.optimistic_sync = false;

this.waker.wake();
return Poll::Pending;
}
Expand Down Expand Up @@ -281,7 +294,7 @@ mod tests {
ForkchoiceState::from_block_info(BlockInfo { number: 0, hash: Default::default() });
let duration = Duration::from_secs(2);

let mut driver = EngineDriver::new(client, None::<()>, fcs, duration);
let mut driver = EngineDriver::new(client, None::<()>, fcs, false, duration);

// Initially, it should be false
assert!(!driver.is_payload_building_in_progress());
Expand All @@ -300,7 +313,7 @@ mod tests {
ForkchoiceState::from_block_info(BlockInfo { number: 0, hash: Default::default() });
let duration = Duration::from_secs(2);

let mut driver = EngineDriver::new(client.clone(), None::<()>, fcs, duration);
let mut driver = EngineDriver::new(client.clone(), None::<()>, fcs, false, duration);

// Initially, it should be false
assert!(!driver.is_payload_building_in_progress());
Expand Down
9 changes: 8 additions & 1 deletion crates/engine/src/future/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use super::{payload::matching_payloads, EngineDriverError};
use crate::api::*;
use alloy_primitives::B256;
use alloy_rpc_types_engine::{
ExecutionPayloadV1, ForkchoiceState as AlloyForkchoiceState, PayloadStatusEnum,
};
Expand Down Expand Up @@ -56,11 +57,17 @@ impl EngineDriverFuture {
pub(crate) fn block_import<EC>(
client: Arc<EC>,
block_with_peer: NewBlockWithPeer,
fcs: AlloyForkchoiceState,
mut fcs: AlloyForkchoiceState,
optimistic_sync: bool,
) -> Self
where
EC: ScrollEngineApi + Unpin + Send + Sync + 'static,
{
// Mask the finalized block hash and safe block hash.
if optimistic_sync {
fcs.finalized_block_hash = B256::ZERO;
fcs.safe_block_hash = B256::ZERO;
}
Self::BlockImport(Box::pin(handle_execution_payload(client, block_with_peer, fcs)))
}

Expand Down
11 changes: 9 additions & 2 deletions crates/node/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ pub struct RollupNodeManager<EC, P, L1P, L1MP, CS> {
l1_notification_rx: Option<ReceiverStream<Arc<L1Notification>>>,
/// An indexer used to index data for the rollup node.
indexer: Indexer<CS>,
/// The chain specification.
chain_spec: Arc<CS>,
/// The consensus algorithm used by the rollup node.
consensus: Box<dyn Consensus>,
/// The receiver for new blocks received from the network (used to bridge from eth-wire).
Expand Down Expand Up @@ -118,7 +120,7 @@ where
signer: Option<SignerHandle>,
block_time: Option<u64>,
) -> Self {
let indexer = Indexer::new(database.clone(), chain_spec);
let indexer = Indexer::new(database.clone(), chain_spec.clone());
let derivation_pipeline =
l1_provider.map(|provider| DerivationPipeline::new(provider, database));
Self {
Expand All @@ -127,6 +129,7 @@ where
derivation_pipeline,
l1_notification_rx: l1_notification_rx.map(Into::into),
indexer,
chain_spec,
consensus,
new_block_rx: new_block_rx.map(Into::into),
event_sender: None,
Expand Down Expand Up @@ -154,7 +157,7 @@ where
///
/// We will first validate the consensus of the block, then we will send the block to the engine
/// to validate the correctness of the block.
pub fn handle_new_block(&mut self, block_with_peer: NewBlockWithPeer) {
pub fn handle_new_block(&mut self, mut block_with_peer: NewBlockWithPeer) {
trace!(target: "scroll::node::manager", "Received new block from peer {:?} - hash {:?}", block_with_peer.peer_id, block_with_peer.block.hash_slow());
if let Some(event_sender) = self.event_sender.as_ref() {
event_sender.notify(RollupEvent::NewBlockReceived(block_with_peer.clone()));
Expand All @@ -172,6 +175,10 @@ where
result: Err(err.into()),
});
} else {
// Wipe the extra data field after signature verification.
if self.chain_spec.is_euclid_v2_active_at_timestamp(block_with_peer.block.timestamp) {
block_with_peer.block.header.extra_data = Default::default();
}
self.engine.handle_block_import(block_with_peer);
}
}
Expand Down
1 change: 1 addition & 0 deletions crates/primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,5 @@ arbitrary = [
"reth-scroll-primitives/arbitrary",
"reth-scroll-primitives/std",
"alloy-consensus/arbitrary",
"alloy-rpc-types-engine/arbitrary",
]
2 changes: 1 addition & 1 deletion crates/providers/src/execution_payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ mod tests {
// Get a provider to the node.
let url = node.rpc_url();
let client = RpcClient::new_http(url);
let provider = ProviderBuilder::new().on_client(client);
let provider = ProviderBuilder::new().connect_client(client);

let execution_payload_provider = AlloyExecutionPayloadProvider::new(provider);

Expand Down
4 changes: 2 additions & 2 deletions crates/sequencer/tests/e2e.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async fn can_build_blocks() {
let auth_client = node.inner.engine_http_client();
let engine_client = ScrollAuthApiEngineClient::new(auth_client);
let mut engine_driver =
EngineDriver::new(Arc::new(engine_client), None::<()>, fcs, BLOCK_BUILDING_DURATION);
EngineDriver::new(Arc::new(engine_client), None::<()>, fcs, false, BLOCK_BUILDING_DURATION);

// create a test database
let database = Arc::new(setup_test_db().await);
Expand Down Expand Up @@ -144,7 +144,7 @@ async fn can_build_blocks_with_delayed_l1_messages() {
let auth_client = node.inner.engine_http_client();
let engine_client = ScrollAuthApiEngineClient::new(auth_client);
let mut engine_driver =
EngineDriver::new(Arc::new(engine_client), None::<()>, fcs, BLOCK_BUILDING_DURATION);
EngineDriver::new(Arc::new(engine_client), None::<()>, fcs, false, BLOCK_BUILDING_DURATION);

// create a test database
let database = Arc::new(setup_test_db().await);
Expand Down
Loading