-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
feat: add storage_proof_only
argument to RollupArgs
#13009
base: main
Are you sure you want to change the base?
Changes from all commits
45e2119
4c174a5
932e1bc
059334d
dabc31d
45318e2
3f2eb26
ccd271b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ use crate::{ | |
OpEngineTypes, | ||
}; | ||
use alloy_consensus::Header; | ||
use alloy_primitives::Address; | ||
use reth_basic_payload_builder::{BasicPayloadJobGenerator, BasicPayloadJobGeneratorConfig}; | ||
use reth_chainspec::{EthChainSpec, EthereumHardforks, Hardforks}; | ||
use reth_db::transaction::{DbTx, DbTxMut}; | ||
|
@@ -31,7 +32,7 @@ use reth_optimism_payload_builder::builder::OpPayloadTransactions; | |
use reth_optimism_primitives::OpPrimitives; | ||
use reth_optimism_rpc::{ | ||
witness::{DebugExecutionWitnessApiServer, OpDebugWitnessApi}, | ||
OpEthApi, | ||
OpEthApi, SequencerClient, | ||
}; | ||
use reth_payload_builder::{PayloadBuilderHandle, PayloadBuilderService}; | ||
use reth_primitives::BlockBody; | ||
|
@@ -46,7 +47,7 @@ use reth_transaction_pool::{ | |
TransactionValidationTaskExecutor, | ||
}; | ||
use reth_trie_db::MerklePatriciaTrie; | ||
use std::sync::Arc; | ||
use std::{marker::PhantomData, sync::Arc}; | ||
|
||
/// Storage implementation for Optimism. | ||
#[derive(Debug, Default, Clone)] | ||
|
@@ -122,7 +123,7 @@ impl OpNode { | |
|
||
/// Returns the components for the given [`RollupArgs`]. | ||
pub fn components<Node>( | ||
args: RollupArgs, | ||
args: &RollupArgs, | ||
) -> ComponentsBuilder< | ||
Node, | ||
OpPoolBuilder, | ||
|
@@ -144,9 +145,9 @@ impl OpNode { | |
ComponentsBuilder::default() | ||
.node_types::<Node>() | ||
.pool(OpPoolBuilder::default()) | ||
.payload(OpPayloadBuilder::new(compute_pending_block)) | ||
.payload(OpPayloadBuilder::new(*compute_pending_block)) | ||
.network(OpNetworkBuilder { | ||
disable_txpool_gossip, | ||
disable_txpool_gossip: *disable_txpool_gossip, | ||
disable_discovery_v4: !discovery_v4, | ||
}) | ||
.executor(OpExecutorBuilder::default()) | ||
|
@@ -178,12 +179,20 @@ where | |
OpAddOns<NodeAdapter<N, <Self::ComponentsBuilder as NodeComponentsBuilder<N>>::Components>>; | ||
|
||
fn components_builder(&self) -> Self::ComponentsBuilder { | ||
let Self { args } = self; | ||
Self::components(args.clone()) | ||
Self::components(&self.args) | ||
} | ||
|
||
fn add_ons(&self) -> Self::AddOns { | ||
OpAddOns::new(self.args.sequencer_http.clone()) | ||
let mut builder = OpAddOns::builder(); | ||
if let Some(sequencer) = &self.args.sequencer_http { | ||
builder = builder.with_sequencer(sequencer.clone()); | ||
} | ||
|
||
if !self.args.storage_proof_only.is_empty() { | ||
builder = builder.with_storage_proof_only(self.args.storage_proof_only.clone()); | ||
} | ||
|
||
builder.build() | ||
} | ||
} | ||
|
||
|
@@ -204,14 +213,14 @@ pub struct OpAddOns<N: FullNodeComponents>(pub RpcAddOns<N, OpEthApi<N>, OpEngin | |
|
||
impl<N: FullNodeComponents<Types: NodeTypes<Primitives = OpPrimitives>>> Default for OpAddOns<N> { | ||
fn default() -> Self { | ||
Self::new(None) | ||
Self::builder().build() | ||
} | ||
} | ||
|
||
impl<N: FullNodeComponents<Types: NodeTypes<Primitives = OpPrimitives>>> OpAddOns<N> { | ||
/// Create a new instance with the given `sequencer_http` URL. | ||
pub fn new(sequencer_http: Option<String>) -> Self { | ||
Self(RpcAddOns::new(move |ctx| OpEthApi::new(ctx, sequencer_http), Default::default())) | ||
impl<N: FullNodeComponents> OpAddOns<N> { | ||
/// Build a [`OpAddOns`] using [`OpAddOnsBuilder`]. | ||
pub fn builder() -> OpAddOnsBuilder<N> { | ||
OpAddOnsBuilder::default() | ||
} | ||
} | ||
|
||
|
@@ -270,6 +279,67 @@ where | |
} | ||
} | ||
|
||
/// A regular optimism evm and executor builder. | ||
#[derive(Debug, Clone)] | ||
#[non_exhaustive] | ||
pub struct OpAddOnsBuilder<N> { | ||
/// Sequencer client, configured to forward submitted transactions to sequencer of given OP | ||
/// network. | ||
sequencer_client: Option<SequencerClient>, | ||
/// List of addresses that _ONLY_ return storage proofs _WITHOUT_ an account proof when called | ||
/// with `eth_getProof`. | ||
storage_proof_only: Vec<Address>, | ||
_marker: PhantomData<N>, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm, we can probably get rid of this entirely if we make this accept the type on |
||
} | ||
|
||
impl<N> Default for OpAddOnsBuilder<N> { | ||
fn default() -> Self { | ||
Self { sequencer_client: None, storage_proof_only: vec![], _marker: PhantomData } | ||
} | ||
} | ||
|
||
impl<N> OpAddOnsBuilder<N> { | ||
/// With a [`SequencerClient`]. | ||
pub fn with_sequencer(mut self, sequencer_client: String) -> Self { | ||
self.sequencer_client = Some(SequencerClient::new(sequencer_client)); | ||
self | ||
} | ||
|
||
/// With a list of addresses that _ONLY_ return storage proofs _WITHOUT_ an account proof when | ||
/// called with `eth_getProof`. | ||
pub fn with_storage_proof_only(mut self, storage_proof_only: Vec<Address>) -> Self { | ||
self.storage_proof_only = storage_proof_only; | ||
self | ||
} | ||
} | ||
|
||
impl<N> OpAddOnsBuilder<N> | ||
where | ||
N: FullNodeComponents<Types: NodeTypes<Primitives = OpPrimitives>>, | ||
{ | ||
/// Builds an instance of [`OpAddOns`]. | ||
pub fn build(self) -> OpAddOns<N> { | ||
let Self { sequencer_client, storage_proof_only, .. } = self; | ||
|
||
OpAddOns(RpcAddOns::new( | ||
move |ctx| { | ||
let mut builder = OpEthApi::builder(ctx); | ||
|
||
if let Some(sequencer_client) = sequencer_client { | ||
builder = builder.with_sequencer(sequencer_client) | ||
} | ||
|
||
if !storage_proof_only.is_empty() { | ||
builder = builder.with_storage_proof_only(storage_proof_only); | ||
} | ||
|
||
builder.build() | ||
Comment on lines
+326
to
+336
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here |
||
}, | ||
Default::default(), | ||
)) | ||
} | ||
} | ||
|
||
/// A regular optimism evm and executor builder. | ||
#[derive(Debug, Default, Clone, Copy)] | ||
#[non_exhaustive] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,8 +14,8 @@ fn test_basic_setup() { | |
let _builder = NodeBuilder::new(config) | ||
.with_database(db) | ||
.with_types::<OpNode>() | ||
.with_components(OpNode::components(Default::default())) | ||
.with_add_ons(OpAddOns::new(None)) | ||
.with_components(OpNode::components(&Default::default())) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this feels weird, imo we should consume here, no reference |
||
.with_add_ons(OpAddOns::builder().build()) | ||
.on_component_initialized(move |ctx| { | ||
let _provider = ctx.provider(); | ||
Ok(()) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be a chain of
with_
calls instead, we can make the args on builder optional instead