diff --git a/simulators/history/portal-interop/Cargo.toml b/simulators/history/portal-interop/Cargo.toml index 8ed17a5d..da64a7f8 100644 --- a/simulators/history/portal-interop/Cargo.toml +++ b/simulators/history/portal-interop/Cargo.toml @@ -6,6 +6,7 @@ edition = "2021" [dependencies] ethportal-api = { git = "https://github.com/ethereum/trin", rev = "2a32224e3c2b0b80bc37c1b692c33016371f197a" } +portal-spec-test-utils-rs = { git = "https://github.com/ethereum/portal-spec-tests", rev = "d1e996d0d4dc2136b3cd38d9e25cdc3a6b74dcd9" } hivesim = { path = "../../../hivesim-rs" } itertools = "0.10.5" serde_json = "1.0.87" diff --git a/simulators/history/portal-interop/src/constants.rs b/simulators/history/portal-interop/src/constants.rs index 184c3af7..f0401543 100644 --- a/simulators/history/portal-interop/src/constants.rs +++ b/simulators/history/portal-interop/src/constants.rs @@ -1,11 +1 @@ -// Execution Layer hard forks https://ethereum.org/en/history/ -pub const SHANGHAI_BLOCK_NUMBER: u64 = 17034870; -pub const MERGE_BLOCK_NUMBER: u64 = 15537394; -pub const LONDON_BLOCK_NUMBER: u64 = 12965000; -pub const BERLIN_BLOCK_NUMBER: u64 = 12244000; -pub const ISTANBUL_BLOCK_NUMBER: u64 = 9069000; -pub const CONSTANTINOPLE_BLOCK_NUMBER: u64 = 7280000; -pub const BYZANTIUM_BLOCK_NUMBER: u64 = 4370000; -pub const HOMESTEAD_BLOCK_NUMBER: u64 = 1150000; - pub const TEST_DATA_FILE_PATH: &str = "./test-data/test_data_collection_of_forks_blocks.yaml"; diff --git a/simulators/history/portal-interop/src/main.rs b/simulators/history/portal-interop/src/main.rs index a1371342..695ba70f 100644 --- a/simulators/history/portal-interop/src/main.rs +++ b/simulators/history/portal-interop/src/main.rs @@ -1,10 +1,6 @@ mod constants; -use crate::constants::{ - BERLIN_BLOCK_NUMBER, BYZANTIUM_BLOCK_NUMBER, CONSTANTINOPLE_BLOCK_NUMBER, - HOMESTEAD_BLOCK_NUMBER, ISTANBUL_BLOCK_NUMBER, LONDON_BLOCK_NUMBER, MERGE_BLOCK_NUMBER, - SHANGHAI_BLOCK_NUMBER, TEST_DATA_FILE_PATH, -}; +use crate::constants::TEST_DATA_FILE_PATH; use ethportal_api::types::portal::ContentInfo; use ethportal_api::utils::bytes::hex_encode; use ethportal_api::{ @@ -15,6 +11,7 @@ use hivesim::{ dyn_async, Client, NClientTestSpec, Simulation, Suite, Test, TestSpec, TwoClientTestSpec, }; use itertools::Itertools; +use portal_spec_test_utils_rs::get_flair; use serde_json::json; use serde_yaml::Value; use tokio::time::Duration; @@ -130,28 +127,6 @@ fn process_content( result } -fn get_flair(block_number: u64) -> String { - if block_number > SHANGHAI_BLOCK_NUMBER { - " (post-shanghai)".to_string() - } else if block_number > MERGE_BLOCK_NUMBER { - " (post-merge)".to_string() - } else if block_number > LONDON_BLOCK_NUMBER { - " (post-london)".to_string() - } else if block_number > BERLIN_BLOCK_NUMBER { - " (post-berlin)".to_string() - } else if block_number > ISTANBUL_BLOCK_NUMBER { - " (post-istanbul)".to_string() - } else if block_number > CONSTANTINOPLE_BLOCK_NUMBER { - " (post-constantinople)".to_string() - } else if block_number > BYZANTIUM_BLOCK_NUMBER { - " (post-byzantium)".to_string() - } else if block_number > HOMESTEAD_BLOCK_NUMBER { - " (post-homestead)".to_string() - } else { - "".to_string() - } -} - dyn_async! { async fn test_portal_interop<'a> (test: &'a mut Test, _client: Option) { // Get all available portal clients diff --git a/simulators/history/trin-bridge/Cargo.toml b/simulators/history/trin-bridge/Cargo.toml index beba18b1..79c01963 100644 --- a/simulators/history/trin-bridge/Cargo.toml +++ b/simulators/history/trin-bridge/Cargo.toml @@ -6,6 +6,7 @@ edition = "2021" [dependencies] ethportal-api = { git = "https://github.com/ethereum/trin", rev = "b530dc3d40d51c21c800089eacb2852ebd8c4d45" } +portal-spec-test-utils-rs = { git = "https://github.com/ethereum/portal-spec-tests", rev = "d1e996d0d4dc2136b3cd38d9e25cdc3a6b74dcd9" } hivesim = { path = "../../../hivesim-rs" } itertools = "0.10.5" serde_yaml = "0.9" diff --git a/simulators/history/trin-bridge/src/constants.rs b/simulators/history/trin-bridge/src/constants.rs index 2fa17457..2679b06b 100644 --- a/simulators/history/trin-bridge/src/constants.rs +++ b/simulators/history/trin-bridge/src/constants.rs @@ -1,13 +1,3 @@ -// Execution Layer hard forks https://ethereum.org/en/history/ -pub const SHANGHAI_BLOCK_NUMBER: u64 = 17034870; -pub const MERGE_BLOCK_NUMBER: u64 = 15537394; -pub const LONDON_BLOCK_NUMBER: u64 = 12965000; -pub const BERLIN_BLOCK_NUMBER: u64 = 12244000; -pub const ISTANBUL_BLOCK_NUMBER: u64 = 9069000; -pub const CONSTANTINOPLE_BLOCK_NUMBER: u64 = 7280000; -pub const BYZANTIUM_BLOCK_NUMBER: u64 = 4370000; -pub const HOMESTEAD_BLOCK_NUMBER: u64 = 1150000; - pub const TRIN_BRIDGE_CLIENT_TYPE: &str = "trin-bridge"; pub const BOOTNODES_ENVIRONMENT_VARIABLE: &str = "HIVE_BOOTNODES"; pub const HIVE_CHECK_LIVE_PORT: &str = "HIVE_CHECK_LIVE_PORT"; diff --git a/simulators/history/trin-bridge/src/main.rs b/simulators/history/trin-bridge/src/main.rs index 1fcf3873..af42c41d 100644 --- a/simulators/history/trin-bridge/src/main.rs +++ b/simulators/history/trin-bridge/src/main.rs @@ -1,10 +1,8 @@ mod constants; use crate::constants::{ - BERLIN_BLOCK_NUMBER, BOOTNODES_ENVIRONMENT_VARIABLE, BYZANTIUM_BLOCK_NUMBER, - CONSTANTINOPLE_BLOCK_NUMBER, HIVE_CHECK_LIVE_PORT, HOMESTEAD_BLOCK_NUMBER, - ISTANBUL_BLOCK_NUMBER, LONDON_BLOCK_NUMBER, MERGE_BLOCK_NUMBER, SHANGHAI_BLOCK_NUMBER, - TEST_DATA_FILE_PATH, TRIN_BRIDGE_CLIENT_TYPE, + BOOTNODES_ENVIRONMENT_VARIABLE, HIVE_CHECK_LIVE_PORT, TEST_DATA_FILE_PATH, + TRIN_BRIDGE_CLIENT_TYPE, }; use ethportal_api::HistoryContentKey; use ethportal_api::HistoryContentValue; @@ -13,32 +11,11 @@ use ethportal_api::{Discv5ApiClient, HistoryNetworkApiClient}; use hivesim::types::ClientDefinition; use hivesim::{dyn_async, Client, Simulation, Suite, Test, TestSpec, TwoClientTestSpec}; use itertools::Itertools; +use portal_spec_test_utils_rs::get_flair; use serde_yaml::Value; use std::collections::HashMap; use tokio::time::Duration; -fn get_flair(block_number: u64) -> String { - if block_number > SHANGHAI_BLOCK_NUMBER { - " (post-shanghai)".to_string() - } else if block_number > MERGE_BLOCK_NUMBER { - " (post-merge)".to_string() - } else if block_number > LONDON_BLOCK_NUMBER { - " (post-london)".to_string() - } else if block_number > BERLIN_BLOCK_NUMBER { - " (post-berlin)".to_string() - } else if block_number > ISTANBUL_BLOCK_NUMBER { - " (post-istanbul)".to_string() - } else if block_number > CONSTANTINOPLE_BLOCK_NUMBER { - " (post-constantinople)".to_string() - } else if block_number > BYZANTIUM_BLOCK_NUMBER { - " (post-byzantium)".to_string() - } else if block_number > HOMESTEAD_BLOCK_NUMBER { - " (post-homestead)".to_string() - } else { - "".to_string() - } -} - fn process_content(content: Vec<(HistoryContentKey, HistoryContentValue)>) -> Vec { let mut last_header = content.get(0).unwrap().clone();