Skip to content

Commit 0d137c1

Browse files
authored
chore: upgrade reth dependency to 48941e6 (#74)
prompt ``` I am trying to upgrade my bera-reth, reth dependency to the latest reth version. I have started the changes, but i'm runnign into issues. I need to you to study all the commits between my last reth version and the current and then figure out the changes that need to be done to bera-reth to stay compatible without compiler issues. Spin up as many subagents as you need. I've tried started the changes but its tricky. Ultrathink. You don't need to research the tags. Look at my staged changes to see the diff in reth commits. I'm technically still in the same reth version but trying to bump. Remember that I also have reth locally at ./reth ``` closes #65
1 parent 6be3611 commit 0d137c1

File tree

14 files changed

+345
-402
lines changed

14 files changed

+345
-402
lines changed

Cargo.lock

Lines changed: 172 additions & 170 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 33 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -30,38 +30,37 @@ jsonrpsee-proc-macros = "0.25.1"
3030

3131
async-trait = "0.1.88"
3232
modular-bitfield = "0.11.2"
33-
reth = { git = "https://github.com/paradigmxyz/reth", rev = "876e964" }
34-
reth-basic-payload-builder = { git = "https://github.com/paradigmxyz/reth", rev = "876e964" }
35-
reth-chainspec = { git = "https://github.com/paradigmxyz/reth", rev = "876e964" }
36-
reth-cli = { git = "https://github.com/paradigmxyz/reth", rev = "876e964" }
37-
reth-cli-commands = { git = "https://github.com/paradigmxyz/reth", rev = "876e964" }
38-
reth-cli-util = { git = "https://github.com/paradigmxyz/reth", rev = "876e964" }
39-
reth-codecs = { git = "https://github.com/paradigmxyz/reth", rev = "876e964" }
40-
reth-db = { git = "https://github.com/paradigmxyz/reth", rev = "876e964" }
41-
reth-db-api = { git = "https://github.com/paradigmxyz/reth", rev = "876e964" }
42-
reth-engine-local = { git = "https://github.com/paradigmxyz/reth", rev = "876e964" }
43-
reth-engine-primitives = { git = "https://github.com/paradigmxyz/reth", rev = "876e964" }
44-
reth-engine-tree = { git = "https://github.com/paradigmxyz/reth", rev = "876e964" }
45-
reth-ethereum-cli = { git = "https://github.com/paradigmxyz/reth", rev = "876e964" }
46-
reth-ethereum-engine-primitives = { git = "https://github.com/paradigmxyz/reth", rev = "876e964" }
47-
reth-ethereum-payload-builder = { git = "https://github.com/paradigmxyz/reth", rev = "876e964" }
48-
reth-ethereum-primitives = { git = "https://github.com/paradigmxyz/reth", rev = "876e964" }
49-
reth-evm = { git = "https://github.com/paradigmxyz/reth", rev = "876e964" }
50-
reth-evm-ethereum = { git = "https://github.com/paradigmxyz/reth", rev = "876e964" }
51-
reth-network-peers = { git = "https://github.com/paradigmxyz/reth", rev = "876e964" }
52-
reth-node-api = { git = "https://github.com/paradigmxyz/reth", rev = "876e964" }
53-
reth-node-builder = { git = "https://github.com/paradigmxyz/reth", rev = "876e964" }
54-
reth-node-core = { git = "https://github.com/paradigmxyz/reth", rev = "876e964" }
55-
reth-node-ethereum = { git = "https://github.com/paradigmxyz/reth", rev = "876e964" }
56-
reth-payload-primitives = { git = "https://github.com/paradigmxyz/reth", rev = "876e964" }
57-
reth-payload-validator = { git = "https://github.com/paradigmxyz/reth", rev = "876e964" }
58-
reth-primitives-traits = { git = "https://github.com/paradigmxyz/reth", rev = "876e964" }
59-
reth-rpc = { git = "https://github.com/paradigmxyz/reth", rev = "876e964" }
60-
reth-rpc-convert = { git = "https://github.com/paradigmxyz/reth", rev = "876e964" }
61-
reth-rpc-engine-api = { git = "https://github.com/paradigmxyz/reth", rev = "876e964" }
62-
reth-rpc-eth-api = { git = "https://github.com/paradigmxyz/reth", rev = "876e964" }
63-
reth-rpc-eth-types = { git = "https://github.com/paradigmxyz/reth", rev = "876e964" }
64-
reth-transaction-pool = { git = "https://github.com/paradigmxyz/reth", rev = "876e964" }
33+
reth = { git = "https://github.com/paradigmxyz/reth", rev = "48941e6" }
34+
reth-basic-payload-builder = { git = "https://github.com/paradigmxyz/reth", rev = "48941e6" }
35+
reth-chainspec = { git = "https://github.com/paradigmxyz/reth", rev = "48941e6" }
36+
reth-cli = { git = "https://github.com/paradigmxyz/reth", rev = "48941e6" }
37+
reth-cli-commands = { git = "https://github.com/paradigmxyz/reth", rev = "48941e6" }
38+
reth-cli-util = { git = "https://github.com/paradigmxyz/reth", rev = "48941e6" }
39+
reth-codecs = { git = "https://github.com/paradigmxyz/reth", rev = "48941e6" }
40+
reth-db = { git = "https://github.com/paradigmxyz/reth", rev = "48941e6" }
41+
reth-db-api = { git = "https://github.com/paradigmxyz/reth", rev = "48941e6" }
42+
reth-engine-local = { git = "https://github.com/paradigmxyz/reth", rev = "48941e6" }
43+
reth-engine-primitives = { git = "https://github.com/paradigmxyz/reth", rev = "48941e6" }
44+
reth-ethereum-cli = { git = "https://github.com/paradigmxyz/reth", rev = "48941e6" }
45+
reth-ethereum-engine-primitives = { git = "https://github.com/paradigmxyz/reth", rev = "48941e6" }
46+
reth-ethereum-payload-builder = { git = "https://github.com/paradigmxyz/reth", rev = "48941e6" }
47+
reth-ethereum-primitives = { git = "https://github.com/paradigmxyz/reth", rev = "48941e6" }
48+
reth-evm = { git = "https://github.com/paradigmxyz/reth", rev = "48941e6" }
49+
reth-evm-ethereum = { git = "https://github.com/paradigmxyz/reth", rev = "48941e6" }
50+
reth-network-peers = { git = "https://github.com/paradigmxyz/reth", rev = "48941e6" }
51+
reth-node-api = { git = "https://github.com/paradigmxyz/reth", rev = "48941e6" }
52+
reth-node-builder = { git = "https://github.com/paradigmxyz/reth", rev = "48941e6" }
53+
reth-node-core = { git = "https://github.com/paradigmxyz/reth", rev = "48941e6" }
54+
reth-node-ethereum = { git = "https://github.com/paradigmxyz/reth", rev = "48941e6" }
55+
reth-payload-primitives = { git = "https://github.com/paradigmxyz/reth", rev = "48941e6" }
56+
reth-payload-validator = { git = "https://github.com/paradigmxyz/reth", rev = "48941e6" }
57+
reth-primitives-traits = { git = "https://github.com/paradigmxyz/reth", rev = "48941e6" }
58+
reth-rpc = { git = "https://github.com/paradigmxyz/reth", rev = "48941e6" }
59+
reth-rpc-convert = { git = "https://github.com/paradigmxyz/reth", rev = "48941e6" }
60+
reth-rpc-engine-api = { git = "https://github.com/paradigmxyz/reth", rev = "48941e6" }
61+
reth-rpc-eth-api = { git = "https://github.com/paradigmxyz/reth", rev = "48941e6" }
62+
reth-rpc-eth-types = { git = "https://github.com/paradigmxyz/reth", rev = "48941e6" }
63+
reth-transaction-pool = { git = "https://github.com/paradigmxyz/reth", rev = "48941e6" }
6564
serde = { version = "1.0", features = ["derive"], default-features = false }
6665
thiserror = "2.0"
6766
tokio = "1.46.0"
@@ -71,8 +70,8 @@ tracing = "0.1.41"
7170
alloy-provider = "1.0.17"
7271
alloy-rpc-client = "1.0.17"
7372
eyre = "0.6.12"
74-
reth-e2e-test-utils = { git = "https://github.com/paradigmxyz/reth", rev = "876e964" }
75-
reth-rpc-builder = { git = "https://github.com/paradigmxyz/reth", rev = "876e964" }
73+
reth-e2e-test-utils = { git = "https://github.com/paradigmxyz/reth", rev = "48941e6" }
74+
reth-rpc-builder = { git = "https://github.com/paradigmxyz/reth", rev = "48941e6" }
7675
serde_json = "1.0"
7776
test-fuzz = "7"
7877

src/consensus/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ where
3333

3434
#[derive(Debug, Clone)]
3535
pub struct BerachainBeaconConsensus {
36-
/// Inner Ethereum beacon consensus implementation
3736
inner: EthBeaconConsensus<BerachainChainSpec>,
3837
chain_spec: Arc<BerachainChainSpec>,
3938
}

src/engine/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ impl BerachainExecutionPayloadSidecar {
161161
}
162162

163163
/// Returns the EIP-7685 requests if available
164-
pub fn requests(&self) -> Option<&alloy_eips::eip7685::Requests> {
164+
pub fn requests(&self) -> Option<&Requests> {
165165
self.inner.requests()
166166
}
167167

@@ -244,7 +244,7 @@ impl From<ExecutionPayloadInputV2> for BerachainExecutionData {
244244
}
245245
}
246246

247-
/// Validates that proposer pubkey is present after Prague1 and absent before Prague1
247+
/// Validates that the proposer pubkey is present after Prague1 and absent before Prague1
248248
pub fn validate_proposer_pubkey_prague1<ChainSpec: BerachainHardforks>(
249249
chain_spec: &ChainSpec,
250250
timestamp: u64,

src/engine/payload.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,6 @@ use reth_primitives_traits::{NodePrimitives, SealedBlock};
2626
use std::{convert::Infallible, sync::Arc};
2727

2828
/// Berachain-specific payload attributes
29-
///
30-
/// This structure wraps Ethereum payload attributes and provides extension
31-
/// points for Berachain-specific functionality. Currently it delegates to
32-
/// Ethereum attributes but can be extended with additional fields as needed.
3329
#[derive(Clone, Debug, Default, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
3430
pub struct BerachainPayloadAttributes {
3531
#[serde(flatten)]
@@ -58,10 +54,6 @@ impl BerachainPayloadAttributes {
5854
}
5955

6056
/// Berachain payload builder attributes
61-
///
62-
/// Internal representation of payload attributes used during the payload building process.
63-
/// This structure maintains compatibility with Ethereum while providing extension points
64-
/// for Berachain-specific payload building logic.
6557
#[derive(Clone, Debug, PartialEq, Eq)]
6658
pub struct BerachainPayloadBuilderAttributes {
6759
/// Id of the payload
@@ -80,6 +72,7 @@ pub struct BerachainPayloadBuilderAttributes {
8072
pub withdrawals: Withdrawals,
8173
/// Root of the parent beacon block
8274
pub parent_beacon_block_root: Option<B256>,
75+
/// Previous proposer public key
8376
pub prev_proposer_pubkey: Option<BlsPublicKey>,
8477
}
8578

src/engine/rpc.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,17 @@ use reth::{
2525
providers::{BlockReader, HeaderProvider, StateProviderFactory},
2626
rpc::api::IntoEngineApiRpcModule,
2727
};
28-
use reth_engine_primitives::EngineTypes;
29-
use reth_engine_tree::tree::EngineValidator;
28+
use reth_engine_primitives::{EngineApiValidator, EngineTypes};
3029
use reth_node_api::{AddOnsContext, FullNodeComponents};
31-
use reth_node_builder::rpc::{EngineApiBuilder, EngineValidatorBuilder};
30+
use reth_node_builder::rpc::{EngineApiBuilder, PayloadValidatorBuilder};
3231
use reth_node_core::version::{CARGO_PKG_VERSION, CLIENT_CODE, NAME_CLIENT, VERGEN_GIT_SHA};
3332
use reth_payload_primitives::{EngineObjectValidationError, PayloadAttributes, PayloadTypes};
3433
use reth_rpc_engine_api::{EngineApi, EngineApiError, EngineCapabilities};
3534
use reth_transaction_pool::TransactionPool;
3635
use std::sync::Arc;
3736
use tracing::{debug, trace};
3837

39-
/// Builder for basic [`EngineApi`] implementation.
40-
///
41-
/// This provides a basic default implementation for opstack and ethereum engine API via
42-
/// [`EngineTypes`] and uses the general purpose [`EngineApi`] implementation as the builder's
43-
/// output.
38+
/// Builder for [`BerachainEngineApi`] implementation.
4439
#[derive(Debug, Default)]
4540
pub struct BerachainEngineApiBuilder<EV> {
4641
engine_validator_builder: EV,
@@ -60,7 +55,8 @@ where
6055
> + EngineTypes,
6156
>,
6257
>,
63-
EV: EngineValidatorBuilder<N>,
58+
EV: PayloadValidatorBuilder<N>,
59+
EV::Validator: EngineApiValidator<<N::Types as NodeTypes>::Payload>,
6460
{
6561
type EngineApi = BerachainEngineApi<
6662
N::Provider,
@@ -383,7 +379,7 @@ where
383379
PayloadAttributes = BerachainPayloadAttributes,
384380
>,
385381
Pool: TransactionPool + 'static,
386-
Validator: EngineValidator<EngineT>,
382+
Validator: EngineApiValidator<EngineT>,
387383
ChainSpec: EthereumHardforks + BerachainHardforks + Send + Sync + 'static,
388384
{
389385
async fn new_payload_v1(&self, payload: ExecutionPayloadV1) -> RpcResult<PayloadStatus> {

src/engine/validator.rs

Lines changed: 33 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,13 @@ use crate::{
1111
transaction::BerachainTxEnvelope,
1212
};
1313
use reth::chainspec::EthereumHardforks;
14-
use reth_engine_primitives::PayloadValidator;
15-
use reth_engine_tree::tree::EngineValidator;
14+
use reth_engine_primitives::{EngineApiValidator, PayloadValidator};
1615
use reth_ethereum_payload_builder::EthereumExecutionPayloadValidator;
17-
use reth_node_api::{AddOnsContext, FullNodeComponents, NodeTypes, PayloadTypes};
18-
use reth_node_builder::rpc::EngineValidatorBuilder;
16+
use reth_node_api::{AddOnsContext, FullNodeComponents, NodeTypes};
17+
use reth_node_builder::rpc::PayloadValidatorBuilder;
1918
use reth_payload_primitives::{
2019
EngineApiMessageVersion, EngineObjectValidationError, NewPayloadError, PayloadOrAttributes,
21-
validate_execution_requests, validate_version_specific_fields,
20+
PayloadTypes, validate_execution_requests, validate_version_specific_fields,
2221
};
2322
use reth_payload_validator::{cancun, prague, shanghai};
2423
use reth_primitives_traits::{Block, RecoveredBlock, SealedBlock};
@@ -27,14 +26,12 @@ use std::{marker::PhantomData, sync::Arc};
2726
#[derive(Debug, Clone)]
2827
pub struct BerachainEngineValidator {
2928
inner: EthereumExecutionPayloadValidator<BerachainChainSpec>,
30-
/// The inner chainspec is private, so we need this.
31-
chain_spec: Arc<BerachainChainSpec>,
3229
}
3330

3431
impl BerachainEngineValidator {
3532
/// Instantiates a new validator.
3633
pub fn new(chain_spec: Arc<BerachainChainSpec>) -> Self {
37-
Self { inner: EthereumExecutionPayloadValidator::new(chain_spec.clone()), chain_spec }
34+
Self { inner: EthereumExecutionPayloadValidator::new(chain_spec.clone()) }
3835
}
3936

4037
/// Returns the chain spec used by the validator.
@@ -55,15 +52,21 @@ impl BerachainEngineValidator {
5552
.map_err(|e| NewPayloadError::Other(e.into()))?;
5653

5754
// Convert header from standard to BerachainHeader
58-
let mut berachain_header = BerachainHeader::from(standard_block.header.clone());
59-
60-
berachain_header.prev_proposer_pubkey = sidecar.parent_proposer_pub_key;
55+
let berachain_header = BerachainHeader::from_header_with_proposer(
56+
standard_block.header.clone(),
57+
sidecar.parent_proposer_pub_key,
58+
);
6159

6260
// Create BerachainBlock with converted header and body
6361
// Ommers are empty on Berachain anyway as we don't have uncle blocks due to different
6462
// consensus mechanism.
65-
let berachain_ommers: Vec<BerachainHeader> =
66-
standard_block.body.ommers.iter().map(|h| BerachainHeader::from(h.clone())).collect();
63+
let berachain_ommers: Vec<BerachainHeader> = standard_block
64+
.body
65+
.ommers
66+
.iter()
67+
.map(|h| BerachainHeader::from_header_with_proposer(h.clone(), None))
68+
.collect();
69+
6770
let berachain_body: alloy_consensus::BlockBody<BerachainTxEnvelope, BerachainHeader> =
6871
alloy_consensus::BlockBody {
6972
transactions: standard_block.body.transactions.clone(),
@@ -84,34 +87,33 @@ impl BerachainEngineValidator {
8487
) -> Result<(), NewPayloadError> {
8588
shanghai::ensure_well_formed_fields(
8689
sealed_block.body(),
87-
self.chain_spec.is_shanghai_active_at_timestamp(sealed_block.timestamp),
90+
self.chain_spec().is_shanghai_active_at_timestamp(sealed_block.timestamp),
8891
)?;
8992

9093
cancun::ensure_well_formed_fields(
9194
sealed_block,
9295
sidecar.inner.cancun(),
93-
self.chain_spec.is_cancun_active_at_timestamp(sealed_block.timestamp),
96+
self.chain_spec().is_cancun_active_at_timestamp(sealed_block.timestamp),
9497
)?;
9598

9699
prague::ensure_well_formed_fields(
97100
sealed_block.body(),
98101
sidecar.inner.prague(),
99-
self.chain_spec.is_prague_active_at_timestamp(sealed_block.timestamp),
102+
self.chain_spec().is_prague_active_at_timestamp(sealed_block.timestamp),
100103
)?;
101104

102105
prague1::ensure_well_formed_fields(
103106
sealed_block,
104107
sidecar.parent_proposer_pub_key,
105-
self.chain_spec.is_prague1_active_at_timestamp(sealed_block.timestamp),
108+
self.chain_spec().is_prague1_active_at_timestamp(sealed_block.timestamp),
106109
)?;
107110

108111
Ok(())
109112
}
110113
}
111114

112-
impl PayloadValidator for BerachainEngineValidator {
115+
impl PayloadValidator<BerachainEngineTypes> for BerachainEngineValidator {
113116
type Block = BerachainBlock;
114-
type ExecutionData = BerachainExecutionData;
115117

116118
fn ensure_well_formed_payload(
117119
&self,
@@ -142,7 +144,7 @@ impl PayloadValidator for BerachainEngineValidator {
142144
}
143145
}
144146

145-
impl<Types> EngineValidator<Types> for BerachainEngineValidator
147+
impl<Types> EngineApiValidator<Types> for BerachainEngineValidator
146148
where
147149
Types: PayloadTypes<
148150
PayloadAttributes = BerachainPayloadAttributes,
@@ -152,18 +154,12 @@ where
152154
fn validate_version_specific_fields(
153155
&self,
154156
version: EngineApiMessageVersion,
155-
payload_or_attrs: PayloadOrAttributes<'_, Self::ExecutionData, BerachainPayloadAttributes>,
157+
payload_or_attrs: PayloadOrAttributes<'_, Types::ExecutionData, Types::PayloadAttributes>,
156158
) -> Result<(), EngineObjectValidationError> {
157-
// Extract execution requests from the payload if present
158-
let execution_requests =
159-
if let PayloadOrAttributes::ExecutionPayload(payload) = &payload_or_attrs {
160-
payload.sidecar.requests()
161-
} else {
162-
None
163-
};
164-
165-
// Validate execution requests if present
166-
if let Some(requests) = execution_requests {
159+
// Validate execution requests if present in the payload
160+
if let PayloadOrAttributes::ExecutionPayload(payload) = &payload_or_attrs &&
161+
let Some(requests) = payload.sidecar.requests()
162+
{
167163
validate_execution_requests(requests)?;
168164
}
169165

@@ -173,12 +169,12 @@ where
173169
fn ensure_well_formed_attributes(
174170
&self,
175171
version: EngineApiMessageVersion,
176-
attributes: &BerachainPayloadAttributes,
172+
attributes: &Types::PayloadAttributes,
177173
) -> Result<(), EngineObjectValidationError> {
178174
validate_version_specific_fields(
179175
self.chain_spec(),
180176
version,
181-
PayloadOrAttributes::<Self::ExecutionData, BerachainPayloadAttributes>::PayloadAttributes(
177+
PayloadOrAttributes::<Types::ExecutionData, Types::PayloadAttributes>::PayloadAttributes(
182178
attributes,
183179
),
184180
)
@@ -191,14 +187,15 @@ pub struct BerachainEngineValidatorBuilder {
191187
_phantom: PhantomData<BerachainChainSpec>,
192188
}
193189

194-
impl<Node, Types> EngineValidatorBuilder<Node> for BerachainEngineValidatorBuilder
190+
impl<Node> PayloadValidatorBuilder<Node> for BerachainEngineValidatorBuilder
195191
where
196-
Types: NodeTypes<
192+
Node: FullNodeComponents<
193+
Types: NodeTypes<
197194
ChainSpec = BerachainChainSpec,
198195
Payload = BerachainEngineTypes,
199196
Primitives = BerachainPrimitives,
200197
>,
201-
Node: FullNodeComponents<Types = Types>,
198+
>,
202199
{
203200
type Validator = BerachainEngineValidator;
204201

src/genesis/mod.rs

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -64,35 +64,15 @@ impl Default for BerachainGenesisConfig {
6464
fn default() -> Self {
6565
Self {
6666
prague1: BerachainForkConfig {
67-
time: 0, // Activate immediately at genesis
68-
base_fee_change_denominator: 48, // Berachain standard value
69-
minimum_base_fee_wei: 1_000_000_000, // 1 gwei
67+
time: 0, // Activate immediately at genesis
68+
base_fee_change_denominator: 48, // Berachain standard value
69+
minimum_base_fee_wei: 10_000_000_000, // 10 gwei
7070
pol_distributor_address: default_pol_contract_address(),
7171
},
7272
}
7373
}
7474
}
7575

76-
impl BerachainForkConfig {
77-
/// Creates validated config. Returns error if denominator is 0.
78-
pub fn new(
79-
time: u64,
80-
base_fee_change_denominator: u128,
81-
minimum_base_fee_wei: u64,
82-
pol_distributor_address: Address,
83-
) -> Result<Self, BerachainConfigError> {
84-
if base_fee_change_denominator == 0 {
85-
return Err(BerachainConfigError::InvalidDenominator);
86-
}
87-
Ok(Self {
88-
time,
89-
base_fee_change_denominator,
90-
minimum_base_fee_wei,
91-
pol_distributor_address,
92-
})
93-
}
94-
}
95-
9676
impl TryFrom<&OtherFields> for BerachainGenesisConfig {
9777
type Error = BerachainConfigError;
9878

0 commit comments

Comments
 (0)