Skip to content
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: Support unnamed OP chains #8488

Merged
merged 5 commits into from
Jun 3, 2024

Conversation

BrianBland
Copy link
Contributor

  • Update ChainSpec.is_optimism to return true if the chain has the Bedrock hardfork configured (past or present), which allows arbitrary genesis files to be used for unnamed OP chains.
  • Parse EIP-1559 elasticity parameters from Optimism genesis files instead of defaulting to using Ethereum's base fee params

@BrianBland BrianBland changed the title feat: Support un-named OP chains feat: Support unnamed OP chains May 29, 2024
Comment on lines 577 to 580
#[cfg(feature = "optimism")]
if self.hardforks.contains_key(&Hardfork::Bedrock) {
return true;
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems reasonable, doesn't impact regular eth nodes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I considered simply returning false if the optimism feature is disabled. Is it worth also making this change or simply keeping the previous name check?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we are trying to get rid of the feature all together, so this is good the way it is #7649

Comment on lines 1628 to 1679
let eip1559_elasticity = genesis.config.extra_fields.get("optimism").and_then(|value| {
value
.as_object()
.and_then(|obj| obj.get("eip1559Elasticity").and_then(|value| value.as_u64()))
});
let eip1559_denominator = genesis.config.extra_fields.get("optimism").and_then(|value| {
value
.as_object()
.and_then(|obj| obj.get("eip1559Denominator").and_then(|value| value.as_u64()))
});
let base_fee_params = if let (Some(elasticity), Some(denominator)) =
(eip1559_elasticity, eip1559_denominator)
{
BaseFeeParams::new(denominator as u128, elasticity as u128)
} else {
BaseFeeParams::ethereum()
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this does the "optimism" lookup twice, I think we can nest this with an if let Some

@mattsse mattsse marked this pull request as ready for review May 29, 2024 19:25
@mattsse mattsse requested a review from gakonst as a code owner May 29, 2024 19:25
@mattsse mattsse added the A-op-reth Related to Optimism and op-reth label May 29, 2024
@@ -573,6 +573,14 @@ impl ChainSpec {

/// Returns `true` if this chain contains Optimism configuration.
#[inline]
#[cfg(feature = "optimism")]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: This change attempts to preserve the const behavior when possible, and also prioritizes the const self.chain.is_optimism() case over the slower runtime-evaluated hardfork check. The performance penalty should only impact unnamed chains or non-OP chains when the optimism feature is enabled.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

crates/net/discv5/src/network_stack_id.rs Show resolved Hide resolved
@@ -573,6 +573,14 @@ impl ChainSpec {

/// Returns `true` if this chain contains Optimism configuration.
#[inline]
#[cfg(feature = "optimism")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

@mattsse mattsse added this pull request to the merge queue Jun 3, 2024
Merged via the queue into paradigmxyz:main with commit 6e44608 Jun 3, 2024
30 checks passed
mw2000 pushed a commit to mw2000/reth that referenced this pull request Jun 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-op-reth Related to Optimism and op-reth
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants