From d15d5b9337d6389ca6c47d84c0da17c56de8544f Mon Sep 17 00:00:00 2001 From: AurelienFT Date: Fri, 6 Dec 2024 01:28:01 +0100 Subject: [PATCH 1/8] Make genesis block timestamp hardcoded. --- crates/fuel-core/src/service/genesis.rs | 3 +- .../forkless-upgrade/src/genesis.rs | 42 +++++++++++++++++++ .../forkless-upgrade/src/lib.rs | 2 + 3 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 version-compatibility/forkless-upgrade/src/genesis.rs diff --git a/crates/fuel-core/src/service/genesis.rs b/crates/fuel-core/src/service/genesis.rs index 55d36e2821b..fc216684f15 100644 --- a/crates/fuel-core/src/service/genesis.rs +++ b/crates/fuel-core/src/service/genesis.rs @@ -285,7 +285,8 @@ pub fn create_genesis_block(config: &Config) -> Block { consensus: ConsensusHeader:: { prev_root, height, - time: fuel_core_types::tai64::Tai64::UNIX_EPOCH, + // The time is set to UNIX_EPOCH + 10 leap seconds to make backward compatibility + time: fuel_core_types::tai64::Tai64(4611686018427387914), generated: Empty, }, }, diff --git a/version-compatibility/forkless-upgrade/src/genesis.rs b/version-compatibility/forkless-upgrade/src/genesis.rs new file mode 100644 index 00000000000..75ef9e17f08 --- /dev/null +++ b/version-compatibility/forkless-upgrade/src/genesis.rs @@ -0,0 +1,42 @@ +#![allow(non_snake_case)] +use crate::tests_helper::{ + LatestFuelCoreDriver, + IGNITION_TESTNET_SNAPSHOT, +}; +use latest_fuel_core_type::fuel_tx::Bytes32; +use std::str::FromStr; + +#[tokio::test(flavor = "multi_thread")] +async fn test__genesis_block__hash() { + let latest_node = LatestFuelCoreDriver::spawn(&[ + "--debug", + "--poa-instant", + "true", + "--snapshot", + IGNITION_TESTNET_SNAPSHOT, + "--enable-relayer", + "--relayer", + "https://eth-mainnet.public.blastapi.io", + "--relayer-da-deploy-height", + "5791365", + "--relayer-v2-listening-contracts", + "0x768f9459E3339A1F7d59CcF24C80Eb4A711a01FB", + ]) + .await + .unwrap(); + + // Given + let original_block = latest_node + .client + .block_by_height(0u32.into()) + .await + .expect("Failed to get blocks") + .expect("Genesis block should exists"); + assert_eq!( + original_block.id, + Bytes32::from_str( + "0x19ac99bf59711aca047b28443e599e26f733291c2fa45f5f309b2c5c9712b215" + ) + .unwrap() + ) +} diff --git a/version-compatibility/forkless-upgrade/src/lib.rs b/version-compatibility/forkless-upgrade/src/lib.rs index b40ca55c722..ae7415e13d0 100644 --- a/version-compatibility/forkless-upgrade/src/lib.rs +++ b/version-compatibility/forkless-upgrade/src/lib.rs @@ -6,6 +6,8 @@ mod backward_compatibility; #[cfg(test)] mod forward_compatibility; #[cfg(test)] +mod genesis; +#[cfg(test)] pub(crate) mod tests_helper; #[cfg(test)] From e76d2d2ce977fba2d78ce569c43b6fc124ee7ab5 Mon Sep 17 00:00:00 2001 From: AurelienFT Date: Fri, 6 Dec 2024 01:31:37 +0100 Subject: [PATCH 2/8] update changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 98f1e13c513..f3f1e9da6e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] +### Fix + +- [2476](https://github.com/FuelLabs/fuel-core/pull/2476): Hardcode the timestamp of the genesis block. + ## [Version 0.40.1] - [2450](https://github.com/FuelLabs/fuel-core/pull/2450): Added support for posting blocks to the shared sequencer. From eadeb5ef990d21f79bf7adc686ff5ffce59e3579 Mon Sep 17 00:00:00 2001 From: AurelienFT <32803821+AurelienFT@users.noreply.github.com> Date: Fri, 6 Dec 2024 01:36:35 +0100 Subject: [PATCH 3/8] Update version-compatibility/forkless-upgrade/src/genesis.rs Co-authored-by: Green Baneling --- version-compatibility/forkless-upgrade/src/genesis.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/version-compatibility/forkless-upgrade/src/genesis.rs b/version-compatibility/forkless-upgrade/src/genesis.rs index 75ef9e17f08..84602b63140 100644 --- a/version-compatibility/forkless-upgrade/src/genesis.rs +++ b/version-compatibility/forkless-upgrade/src/genesis.rs @@ -32,6 +32,9 @@ async fn test__genesis_block__hash() { .await .expect("Failed to get blocks") .expect("Genesis block should exists"); + // The hash of the genesis block should always be + // `0x19ac99bf59711aca047b28443e599e26f733291c2fa45f5f309b2c5c9712b215` + // regardless of the changes that we made. assert_eq!( original_block.id, Bytes32::from_str( From 84bda9a9d28faa399f19f88fd39a1808dc3b3ed5 Mon Sep 17 00:00:00 2001 From: AurelienFT Date: Fri, 6 Dec 2024 01:40:52 +0100 Subject: [PATCH 4/8] update test --- version-compatibility/forkless-upgrade/src/genesis.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/version-compatibility/forkless-upgrade/src/genesis.rs b/version-compatibility/forkless-upgrade/src/genesis.rs index 84602b63140..6374e069f79 100644 --- a/version-compatibility/forkless-upgrade/src/genesis.rs +++ b/version-compatibility/forkless-upgrade/src/genesis.rs @@ -8,6 +8,7 @@ use std::str::FromStr; #[tokio::test(flavor = "multi_thread")] async fn test__genesis_block__hash() { + // Given let latest_node = LatestFuelCoreDriver::spawn(&[ "--debug", "--poa-instant", @@ -16,7 +17,7 @@ async fn test__genesis_block__hash() { IGNITION_TESTNET_SNAPSHOT, "--enable-relayer", "--relayer", - "https://eth-mainnet.public.blastapi.io", + "https://google.com", "--relayer-da-deploy-height", "5791365", "--relayer-v2-listening-contracts", @@ -25,13 +26,14 @@ async fn test__genesis_block__hash() { .await .unwrap(); - // Given + // When let original_block = latest_node .client .block_by_height(0u32.into()) .await .expect("Failed to get blocks") .expect("Genesis block should exists"); + // Then // The hash of the genesis block should always be // `0x19ac99bf59711aca047b28443e599e26f733291c2fa45f5f309b2c5c9712b215` // regardless of the changes that we made. From edeaa72066808f407c85c7a2b885034461d621ff Mon Sep 17 00:00:00 2001 From: AurelienFT Date: Fri, 6 Dec 2024 01:51:46 +0100 Subject: [PATCH 5/8] Fix patch version of pyroscope_pprofrs to maintain MSRV 1.79 --- bin/fuel-core/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/fuel-core/Cargo.toml b/bin/fuel-core/Cargo.toml index cd95fc990df..d432208cd56 100644 --- a/bin/fuel-core/Cargo.toml +++ b/bin/fuel-core/Cargo.toml @@ -34,7 +34,7 @@ fuel-core-types = { workspace = true, features = ["std"] } hex = { workspace = true } humantime = "2.1" pyroscope = "0.5" -pyroscope_pprofrs = "0.2" +pyroscope_pprofrs = "0.2.7" serde_json = { workspace = true } tikv-jemallocator = { workspace = true } tokio = { workspace = true, features = ["macros", "rt-multi-thread"] } From 710bb14db8a37f06d4c89956969d94dcfc8a926b Mon Sep 17 00:00:00 2001 From: AurelienFT <32803821+AurelienFT@users.noreply.github.com> Date: Fri, 6 Dec 2024 01:52:38 +0100 Subject: [PATCH 6/8] Update CHANGELOG.md Co-authored-by: Green Baneling --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f3f1e9da6e3..a54f1358744 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] -### Fix +### Fixed - [2476](https://github.com/FuelLabs/fuel-core/pull/2476): Hardcode the timestamp of the genesis block. From ea8f45470da2f2c1e51f3fed21df347b6f228e0f Mon Sep 17 00:00:00 2001 From: AurelienFT Date: Fri, 6 Dec 2024 01:55:52 +0100 Subject: [PATCH 7/8] Fix pyroscope version too --- bin/fuel-core/Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/fuel-core/Cargo.toml b/bin/fuel-core/Cargo.toml index d432208cd56..7be4e4bf595 100644 --- a/bin/fuel-core/Cargo.toml +++ b/bin/fuel-core/Cargo.toml @@ -33,8 +33,8 @@ fuel-core-shared-sequencer = { workspace = true, optional = true } fuel-core-types = { workspace = true, features = ["std"] } hex = { workspace = true } humantime = "2.1" -pyroscope = "0.5" -pyroscope_pprofrs = "0.2.7" +pyroscope = "=0.5.7" +pyroscope_pprofrs = "=0.2.7" serde_json = { workspace = true } tikv-jemallocator = { workspace = true } tokio = { workspace = true, features = ["macros", "rt-multi-thread"] } From 751f496f05f3a930821fdbffd4ff59c59e6e24b8 Mon Sep 17 00:00:00 2001 From: AurelienFT Date: Fri, 6 Dec 2024 03:00:47 +0100 Subject: [PATCH 8/8] For tai64 4.0.0 --- Cargo.lock | 4 ++-- crates/client/Cargo.toml | 3 ++- crates/types/Cargo.toml | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9c90ee89ad8..03a44083c86 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9437,9 +9437,9 @@ dependencies = [ [[package]] name = "tai64" -version = "4.1.0" +version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "014639506e4f425c78e823eabf56e71c093f940ae55b43e58f682e7bc2f5887a" +checksum = "ed7401421025f4132e6c1f7af5e7f8287383969f36e6628016cd509b8d3da9dc" dependencies = [ "serde", ] diff --git a/crates/client/Cargo.toml b/crates/client/Cargo.toml index a6bb5c1e3dc..59432ea7990 100644 --- a/crates/client/Cargo.toml +++ b/crates/client/Cargo.toml @@ -30,7 +30,8 @@ reqwest = { version = "0.11.16", default-features = false, features = [ ] } serde = { workspace = true, features = ["derive"] } serde_json = { version = "1.0", features = ["raw_value"] } -tai64 = { version = "4.0", features = ["serde"] } +# We force the version because 4.1.0 update leap seconds that breaks our timestamps +tai64 = { version = "=4.0.0", features = ["serde"] } thiserror = "1.0" tracing = "0.1" diff --git a/crates/types/Cargo.toml b/crates/types/Cargo.toml index 505975b8ebe..18da5920477 100644 --- a/crates/types/Cargo.toml +++ b/crates/types/Cargo.toml @@ -29,7 +29,8 @@ k256 = { version = "0.13", default-features = false, features = ["ecdsa"] } rand = { workspace = true, optional = true } secrecy = "0.8" serde = { workspace = true, features = ["derive"], optional = true } -tai64 = { version = "4.0", features = ["serde"] } +# We force the version because 4.1.0 update leap seconds that breaks our timestamps +tai64 = { version = "=4.0.0", features = ["serde"] } zeroize = "1.5" [dev-dependencies]