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

chore: complete optimism mainnet forkid tests #8114

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

estensen
Copy link
Contributor

@estensen estensen commented May 5, 2024

Closes #8012 when completed

Copy link
Member

@Rjected Rjected left a comment

Choose a reason for hiding this comment

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

left some comments, let me know if you're still stuck on getting the expected forkhash for these tests

@@ -287,6 +287,7 @@ pub static OP_MAINNET: Lazy<Arc<ChainSpec>> = Lazy::new(|| {
(Hardfork::Bedrock, ForkCondition::Block(105235063)),
(Hardfork::Regolith, ForkCondition::Timestamp(0)),
(Hardfork::Canyon, ForkCondition::Timestamp(1704992401)),
(Hardfork::Delta, ForkCondition::Timestamp(1708560000)),
Copy link
Member

Choose a reason for hiding this comment

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

where did you find this? Is there an op mainnet genesis link somewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added comment with link
2ea4bcc

Copy link
Member

Choose a reason for hiding this comment

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

ah, reading this it looks like that's an op-node (CL) change, so it does not need to exist here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Where do you see that?

Copy link
Member

Choose a reason for hiding this comment

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

see https://docs.optimism.io/builders/node-operators/network-upgrades

The Delta upgrade uses a L2 block-timestamp activation-rule, and is specified only in the rollup-node (delta_time).

Comment on lines 2354 to 2372
// Canyon
(
Head { timestamp: 1704992401, ..Default::default() },
ForkId { hash: ForkHash([0x0, 0x0, 0x0, 0x0]), next: 1708560000 },
),
// Delta
(
Head { timestamp: 1708560000, ..Default::default() },
ForkId { hash: ForkHash([0x0, 0x0, 0x0, 0x0]), next: 1710374401 },
),
Copy link
Member

Choose a reason for hiding this comment

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

re: #8012 (comment)

Is the forkhash supposed to be 00000000, do you have a source on that? That sounds incorrect

It's not supposed to be all zeros, typically values for this would be obtained from writing a similar test in geth, but since our final (ecotone) forkhash is compliant with geth, what we compute in test failures is probably also correct. However, starting at Canyon we can't use ..Default::default() because the block needs to be higher than the london / bedrock block. Let's change it back to the previous block number

Copy link
Contributor Author

@estensen estensen May 8, 2024

Choose a reason for hiding this comment

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

[0x0, 0x0, 0x0, 0x0] is just temporary since test failure output is not too useful, to be able to find back to the test case that failed

thread 'chain::spec::tests::op_mainnet_forkids' panicked at crates/primitives/src/chain/spec.rs:1643:13:
assertion `left == right` failed: Expected fork ID ForkId { hash: ForkHash("00000000"), next: 1708560000 }, computed fork ID ForkId { hash: ForkHash("caf517ed"), next: 3950000 } at block 0
  left: ForkId { hash: ForkHash("00000000"), next: 1708560000 }
 right: ForkId { hash: ForkHash("caf517ed"), next: 3950000 }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Comment on lines 2321 to 2362
Head { number: 0, ..Default::default() },
ForkId { hash: ForkHash([0xca, 0xf5, 0x17, 0xed]), next: 3950000 },
),
// TODO: complete these, see https://github.com/paradigmxyz/reth/issues/8012
// Berlin
(
Head { number: 105235063, timestamp: 1710374401, ..Default::default() },
Head { number: 3950000, ..Default::default() },
ForkId { hash: ForkHash([0x52, 0x6a, 0x21, 0x71]), next: 105235063 },
),
// London
(
Head { number: 105235063, ..Default::default() },
ForkId { hash: ForkHash([0xe3, 0x39, 0x8d, 0x7c]), next: 1704992401 },
),
// Arrow Glacier
(
Head { number: 105235063, ..Default::default() },
ForkId { hash: ForkHash([0xe3, 0x39, 0x8d, 0x7c]), next: 1704992401 },
),
// Grey Glacier
(
Head { number: 105235063, ..Default::default() },
ForkId { hash: ForkHash([0xe3, 0x39, 0x8d, 0x7c]), next: 1704992401 },
),
// Paris
(
Head { number: 105235063, ..Default::default() },
ForkId { hash: ForkHash([0xe3, 0x39, 0x8d, 0x7c]), next: 1704992401 },
),
// Bedrock
(
Head { number: 105235063, ..Default::default() },
ForkId { hash: ForkHash([0xe3, 0x39, 0x8d, 0x7c]), next: 1704992401 },
),
// Canyon
(
Head { timestamp: 1704992401, ..Default::default() },
ForkId { hash: ForkHash([0x0, 0x0, 0x0, 0x0]), next: 1708560000 },
),
// Delta
(
Head { timestamp: 1708560000, ..Default::default() },
ForkId { hash: ForkHash([0x0, 0x0, 0x0, 0x0]), next: 1710374401 },
Copy link
Member

Choose a reason for hiding this comment

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

let's make sure we specify number and timestamp explicitly for each of these

@estensen estensen marked this pull request as ready for review May 14, 2024 17:42
@estensen estensen requested a review from gakonst as a code owner May 14, 2024 17:42
@estensen estensen requested a review from Rjected May 14, 2024 18:09
@mattsse mattsse added C-test A change that impacts how or what we test A-op-reth Related to Optimism and op-reth labels May 14, 2024
Copy link
Member

@emhane emhane left a comment

Choose a reason for hiding this comment

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

using constants here, would be super helpful. would make it way easier to review if tests are correct + import values to other parts of codebase.

grouping constants in a type impl is nice.

pub struct OpMainnetForkHash;

impl OpMainnetForkHash {
    pub const BEDROCK: ForkHash = <fork-hash>;
    ..
}

pub struct OpMainnetForkId;

impl OpMainnetForkId {
    pub const BEDROCK: ForkId = ForkId::new(OpMainnetForkHash::BEDROCK, <next>);
    ..
}

pub struct OpMainnetForkTimestamp;

impl OpMainnetForkTimestamp {
    pub const REGOLITH: u64 = 0;
    ..
}

@Rjected
Copy link
Member

Rjected commented May 21, 2024

using constants here, would be super helpful. would make it way easier to review if tests are correct + import values to other parts of codebase.

grouping constants in a type impl is nice.

pub struct OpMainnetForkHash;

impl OpMainnetForkHash {
    pub const BEDROCK: ForkHash = <fork-hash>;
    ..
}

pub struct OpMainnetForkId;

impl OpMainnetForkId {
    pub const BEDROCK: ForkId = ForkId::new(OpMainnetForkHash::BEDROCK, <next>);
    ..
}

pub struct OpMainnetForkTimestamp;

impl OpMainnetForkTimestamp {
    pub const REGOLITH: u64 = 0;
    ..
}

IMO out of scope for this PR, since it should just be completing a few tests instead of introducing a new pattern for known forkhashes

Copy link
Member

@Rjected Rjected left a comment

Choose a reason for hiding this comment

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

needs lint and a few other small things

Comment on lines +2326 to +2360
// Berlin
(
Head { number: 3950000, ..Default::default() },
ForkId { hash: ForkHash([0x52, 0x6a, 0x21, 0x71]), next: 105235063 },
),
// London
(
Head { number: 105235063, ..Default::default() },
ForkId { hash: ForkHash([0xe3, 0x39, 0x8d, 0x7c]), next: 1704992401 },
),
// Arrow Glacier
(
Head { number: 105235063, ..Default::default() },
ForkId { hash: ForkHash([0xe3, 0x39, 0x8d, 0x7c]), next: 1704992401 },
),
// Grey Glacier
(
Head { number: 105235063, ..Default::default() },
ForkId { hash: ForkHash([0xe3, 0x39, 0x8d, 0x7c]), next: 1704992401 },
),
// Paris
(
Head { number: 105235063, ..Default::default() },
ForkId { hash: ForkHash([0xe3, 0x39, 0x8d, 0x7c]), next: 1704992401 },
),
// Bedrock
(
Head { number: 105235063, ..Default::default() },
ForkId { hash: ForkHash([0xe3, 0x39, 0x8d, 0x7c]), next: 1704992401 },
),
// Shanghai
(
Head { number: 105235063, timestamp: 1704992401, ..Default::default() },
ForkId { hash: ForkHash([0xbd, 0xd4, 0xfd, 0xb2]), next: 1710374401 },
),
Copy link
Member

@Rjected Rjected May 21, 2024

Choose a reason for hiding this comment

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

let's just use op-specific hardforks, I am realizing these are not super useful

Comment on lines +65 to +68
/// Delta:
/// https://github.com/ethereum-optimism/specs/blob/main/specs/protocol/superchain-upgrades.md#delta
#[cfg(feature = "optimism")]
Delta,
Copy link
Member

Choose a reason for hiding this comment

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

this still needs to be removed

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 C-test A change that impacts how or what we test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Complete optimism mainnet forkid tests
4 participants