Skip to content

Commit

Permalink
feat: Add reth-chainspec and reth-rpc-types-compat as optional depend…
Browse files Browse the repository at this point in the history
…encies

The code changes include adding "reth-chainspec" and "reth-rpc-types-compat" as optional dependencies in the "taiko" feature of the "payload/builder" crate. This change allows the "taiko" feature to include these dependencies when enabled.

Recent user commits:
- fix: taiko features
- Merge branch 'v1.0.0' of gh_work:taikoxyz/taiko-reth into HEAD
- fix(op): configure discv5 properly in op builder (paradigmxyz#9058)
- fix: Change Arc<KzgSettings> to EnvKzgSettings (paradigmxyz#9054)
- feat(examples): remote exex (paradigmxyz#8890)
- chore: tweak profiles, rename debug-fast to profiling (paradigmxyz#9051)
- ci: use reth-prod.png for release notes (paradigmxyz#9047)
- feat: integrate Node traits into LaunchContextWith (paradigmxyz#8993)
- feat(node): derive `Clone` for `FullNode` (paradigmxyz#9046)
- feat(rpc): remove ipc future and now using ServerHandle and StopHandle from jsonrpsee (paradigmxyz#9044)

Recent repository commits:
- fix: taiko features
- Merge branch 'v1.0.0' of gh_work:taikoxyz/taiko-reth into HEAD
- fix(op): configure discv5 properly in op builder (paradigmxyz#9058)
- fix: Change Arc<KzgSettings> to EnvKzgSettings (paradigmxyz#9054)
- feat(examples): remote exex (paradigmxyz#8890)
- chore: tweak profiles, rename debug-fast to profiling (paradigmxyz#9051)
- ci: use reth-prod.png for release notes (paradigmxyz#9047)
- feat: integrate Node traits into LaunchContextWith (paradigmxyz#8993)
- feat(node): derive `Clone` for `FullNode` (paradigmxyz#9046)
- feat(rpc): remove ipc future and now using ServerHandle and StopHandle from jsonrpsee (paradigmxyz#9044)
  • Loading branch information
johntaiko committed Jul 3, 2024
1 parent eb55ad2 commit 191e810
Show file tree
Hide file tree
Showing 16 changed files with 199 additions and 1,701 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

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

7 changes: 5 additions & 2 deletions crates/node-taiko/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@ use serde::{Deserialize, Serialize};
#[non_exhaustive]
pub struct TaikoEngineTypes;

impl EngineTypes for TaikoEngineTypes {
impl PayloadTypes for TaikoEngineTypes {
type BuiltPayload = TaikoBuiltPayload;
type PayloadAttributes = TaikoPayloadAttributes;
type PayloadBuilderAttributes = TaikoPayloadBuilderAttributes;
type BuiltPayload = TaikoBuiltPayload;
}

impl EngineTypes for TaikoEngineTypes {
type ExecutionPayloadV1 = ExecutionPayloadV1;
type ExecutionPayloadV2 = ExecutionPayloadEnvelopeV2;
type ExecutionPayloadV3 = TaikoExecutionPayloadEnvelope;
Expand Down
18 changes: 11 additions & 7 deletions crates/node-taiko/src/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,7 @@ use reth_primitives::{
pub struct TaikoEvmConfig;

impl ConfigureEvmEnv for TaikoEvmConfig {
type TxMeta = ();

fn fill_tx_env<T>(tx_env: &mut TxEnv, transaction: T, sender: Address, _meta: ())
where
T: AsRef<Transaction>,
{
fn fill_tx_env(tx_env: &mut TxEnv, transaction: &TransactionSigned, sender: Address) {
fill_tx_env(tx_env, transaction, sender)
}

Expand Down Expand Up @@ -44,7 +39,16 @@ impl ConfigureEvmEnv for TaikoEvmConfig {
}
}

impl ConfigureEvm for TaikoEvmConfig {}
impl ConfigureEvm for TaikoEvmConfig {
type DefaultExternalContext<'a> = ();

fn evm<'a, DB: Database + 'a>(
&self,
db: DB,
) -> reth_revm::Evm<'a, Self::DefaultExternalContext<'a>, DB> {
EvmBuilder::default().with_db(db).build()
}
}

#[cfg(test)]
mod tests {
Expand Down
9 changes: 7 additions & 2 deletions crates/payload/builder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ reth-errors.workspace = true
reth-provider.workspace = true
reth-payload-primitives.workspace = true
reth-ethereum-engine-primitives.workspace = true

reth-chainspec = { workspace = true, optional = true }
reth-rpc-types-compat = { workspace = true, optional = true }
# ethereum
alloy-rlp.workspace = true
revm-primitives.workspace = true
Expand All @@ -46,4 +47,8 @@ serde_json.workspace = true

[features]
test-utils = []
taiko = ["reth-primitives/taiko"]
taiko = [
"reth-primitives/taiko",
"dep:reth-chainspec",
"dep:reth-rpc-types-compat",
]
42 changes: 18 additions & 24 deletions crates/payload/builder/src/taiko.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
use crate::EthPayloadBuilderAttributes;
use alloy_rlp::Error as DecodeError;
use reth_node_api::{BuiltPayload, PayloadBuilderAttributes};
use reth_chainspec::ChainSpec;
use reth_payload_primitives::{
BuiltPayload, EngineApiMessageVersion, EngineObjectValidationError, PayloadBuilderAttributes,
};
use reth_primitives::{
revm::config::revm_spec_by_timestamp_after_merge,
revm_primitives::{BlobExcessGasAndPrice, BlockEnv, CfgEnv, CfgEnvWithHandlerCfg, SpecId},
Address, BlobTransactionSidecar, Bytes, ChainSpec, Header, L1Origin, SealedBlock,
TaikoBlockMetadata, Withdrawals, B256, U256,
Address, BlobTransactionSidecar, Header, L1Origin, SealedBlock, TaikoBlockMetadata,
Withdrawals, B256, U256,
};
use reth_rpc_types::{
engine::{
BlobsBundleV1, ExecutionPayloadEnvelopeV2, ExecutionPayloadEnvelopeV3, ExecutionPayloadV1,
PayloadAttributes, PayloadId,
},
ExecutionPayload, ExecutionPayloadV2, ExecutionPayloadV3,
ExecutionPayload,
};
use reth_rpc_types_compat::engine::{
convert_withdrawal_to_standalone_withdraw,
payload::{block_to_payload_v3, convert_block_to_payload_field_v2, try_block_to_payload_v1},
use reth_rpc_types_compat::engine::payload::{
block_to_payload_v1, block_to_payload_v3, convert_block_to_payload_field_v2,
};
use serde::{Deserialize, Serialize};
// use std::sync::Arc;
Expand All @@ -35,7 +37,7 @@ pub struct TaikoPayloadAttributes {
pub l1_origin: L1Origin,
}

impl reth_node_api::PayloadAttributes for TaikoPayloadAttributes {
impl reth_payload_primitives::PayloadAttributes for TaikoPayloadAttributes {
fn timestamp(&self) -> u64 {
self.payload_attributes.timestamp()
}
Expand All @@ -51,8 +53,8 @@ impl reth_node_api::PayloadAttributes for TaikoPayloadAttributes {
fn ensure_well_formed_attributes(
&self,
chain_spec: &ChainSpec,
version: reth_node_api::EngineApiMessageVersion,
) -> Result<(), reth_node_api::AttributesValidationError> {
version: EngineApiMessageVersion,
) -> Result<(), EngineObjectValidationError> {
self.payload_attributes.ensure_well_formed_attributes(chain_spec, version)
}
}
Expand Down Expand Up @@ -148,7 +150,7 @@ impl PayloadBuilderAttributes for TaikoPayloadBuilderAttributes {
*base_fee_per_gas
} else {
parent
.next_block_base_fee(chain_spec.base_fee_params(self.timestamp()))
.next_block_base_fee(chain_spec.base_fee_params_at_timestamp(self.timestamp()))
.unwrap_or_default()
});

Expand Down Expand Up @@ -248,7 +250,7 @@ impl<'a> BuiltPayload for &'a TaikoBuiltPayload {
// V1 engine_getPayloadV1 response
impl From<TaikoBuiltPayload> for ExecutionPayloadV1 {
fn from(value: TaikoBuiltPayload) -> Self {
try_block_to_payload_v1(value.block)
block_to_payload_v1(value.block)
}
}

Expand All @@ -268,8 +270,8 @@ impl From<TaikoBuiltPayload> for ExecutionPayloadEnvelopeV3 {
fn from(value: TaikoBuiltPayload) -> Self {
let TaikoBuiltPayload { block, fees, sidecars, .. } = value;

ExecutionPayloadEnvelopeV3 {
execution_payload: block_to_payload_v3(block.clone()),
Self {
execution_payload: block_to_payload_v3(block).0,
block_value: fees,
// From the engine API spec:
//
Expand Down Expand Up @@ -343,21 +345,13 @@ impl From<TaikoBuiltPayload> for TaikoExecutionPayloadEnvelope {
fn from(value: TaikoBuiltPayload) -> Self {
let TaikoBuiltPayload { block, fees, sidecars, .. } = value;

let withdrawals: Vec<reth_rpc_types::withdrawal::Withdrawal> = block
.withdrawals
.clone()
.unwrap_or_default()
.into_iter()
.map(convert_withdrawal_to_standalone_withdraw)
.collect();

TaikoExecutionPayloadEnvelope {
execution_payload: TaikoExecutionPayload {
tx_hash: block.header.transactions_root,
withdrawals_hash: block.header.withdrawals_root.unwrap_or_default(),
taiko_block: true,

payload_inner: ExecutionPayload::V3(block_to_payload_v3(block)),
payload_inner: ExecutionPayload::V3(block_to_payload_v3(block).0),
},
block_value: fees,
blobs_bundle: sidecars.into_iter().map(Into::into).collect::<Vec<_>>().into(),
Expand All @@ -374,7 +368,7 @@ impl From<TaikoBuiltPayload> for TaikoExecutionPayload {
tx_hash: block.header.transactions_root,
withdrawals_hash: block.header.withdrawals_root.unwrap_or_default(),
taiko_block: true,
payload_inner: ExecutionPayload::V3(block_to_payload_v3(block)),
payload_inner: ExecutionPayload::V3(block_to_payload_v3(block).0),
}
}
}
Loading

0 comments on commit 191e810

Please sign in to comment.