diff --git a/version-compatibility/forkless-upgrade/Cargo.toml b/version-compatibility/forkless-upgrade/Cargo.toml index 509880e015..ec5c4feb2c 100644 --- a/version-compatibility/forkless-upgrade/Cargo.toml +++ b/version-compatibility/forkless-upgrade/Cargo.toml @@ -50,3 +50,5 @@ version-36-fuel-core-bin = { version = "0.36.0", package = "fuel-core-bin", feat ] } version-36-fuel-core-client = { version = "0.36.0", package = "fuel-core-client" } version-36-fuel-core-services = { version = "0.36.0", package = "fuel-core-services" } +version-36-fuel-core-gas-price-service = { version = "0.36.0", package = "fuel-core-gas-price-service" } +version-36-fuel-core-storage = { version = "0.36.0", package = "fuel-core-storage" } diff --git a/version-compatibility/forkless-upgrade/src/gas_price_algo_compatibility.rs b/version-compatibility/forkless-upgrade/src/gas_price_algo_compatibility.rs index 4b4cd45426..ebdd1b1473 100644 --- a/version-compatibility/forkless-upgrade/src/gas_price_algo_compatibility.rs +++ b/version-compatibility/forkless-upgrade/src/gas_price_algo_compatibility.rs @@ -9,15 +9,15 @@ use crate::tests_helper::{ }; use latest_fuel_core_gas_price_service::{ common::{ - fuel_core_storage_adapter::storage::GasPriceMetadata, - updater_metadata::UpdaterMetadata, + fuel_core_storage_adapter::storage::GasPriceMetadata as NewGasPriceMetadata, + updater_metadata::UpdaterMetadata as NewUpdaterMetadata, }, - ports::GasPriceData, + ports::GasPriceData as NewGasPriceData, v1::metadata::V1Metadata, }; use latest_fuel_core_storage::{ - transactional::AtomicView, - StorageAsRef, + transactional::AtomicView as NewAtomicView, + StorageAsRef as NewStorageAsRef, }; use libp2p::{ identity::{ @@ -27,6 +27,18 @@ use libp2p::{ PeerId, }; use std::ops::Deref; +use version_36_fuel_core_gas_price_service::fuel_gas_price_updater::{ + fuel_core_storage_adapter::storage::GasPriceMetadata as OldGasPriceMetadata, + UpdaterMetadata as OldUpdaterMetadata, + V0Metadata, +}; +use version_36_fuel_core_storage::{ + transactional::{ + AtomicView as OldAtomicView, + HistoricalView as OldHistoricalView, + }, + StorageAsRef as OldStorageAsRef, +}; #[tokio::test] async fn v1_gas_price_metadata_updates_successfully_from_v0() { @@ -53,15 +65,29 @@ async fn v1_gas_price_metadata_updates_successfully_from_v0() { "--starting-gas-price", starting_gas_price.to_string().as_str(), ]) - .await - .unwrap(); + .await + .unwrap(); + + let db = &old_driver.node.shared.database; + let latest_height = db.gas_price().latest_height().unwrap(); + let view = db.gas_price().latest_view().unwrap(); + let v0_metadata = match OldStorageAsRef::storage::(&view) + .get(&latest_height) + .unwrap() + .unwrap() + .deref() + .clone() + { + OldUpdaterMetadata::V0(v0) => v0, + }; + let public_key = Keypair::from(genesis_keypair).public(); let genesis_peer_id = PeerId::from_public_key(&public_key); let genesis_multiaddr = default_multiaddr(genesis_port, genesis_peer_id); let temp_dir = old_driver.kill().await; // Starting node that uses latest fuel core. - // It will connect to the genesis node and sync blocks. + // When let latest_keypair = SecpKeypair::generate(); let hexed_secret = hex::encode(latest_keypair.secret().to_bytes()); let latest_node = LatestFuelCoreDriver::spawn_with_directory( @@ -83,29 +109,26 @@ async fn v1_gas_price_metadata_updates_successfully_from_v0() { "0", ], ) - .await - .unwrap(); - - // When - const BLOCKS_TO_PRODUCE: u32 = 10; - latest_node - .client - .produce_blocks(BLOCKS_TO_PRODUCE, None) - .await - .unwrap(); - tokio::time::sleep(tokio::time::Duration::from_millis(100)).await; + .await + .unwrap(); // Then let db = &latest_node.node.shared.database; let latest_height = db.gas_price().latest_height().unwrap(); let view = db.gas_price().latest_view().unwrap(); - let metadata = view - .storage::() - .get(&latest_height.into()) - .unwrap() - .unwrap() - .deref() - .clone(); + let v1_metadata = V1Metadata::try_from( + NewStorageAsRef::storage::(&view) + .get(&latest_height.into()) + .unwrap() + .unwrap() + .deref() + .clone(), + ) + .unwrap(); - assert!(matches!(metadata, UpdaterMetadata::V1(_))); + assert_eq!(v0_metadata.l2_block_height, v1_metadata.l2_block_height); + assert_eq!( + v0_metadata.new_exec_price, + v1_metadata.new_scaled_exec_price * v1_metadata.gas_price_factor.get() + ); } diff --git a/version-compatibility/forkless-upgrade/src/genesis.rs b/version-compatibility/forkless-upgrade/src/genesis.rs index 702eaf0e07..6374e069f7 100644 --- a/version-compatibility/forkless-upgrade/src/genesis.rs +++ b/version-compatibility/forkless-upgrade/src/genesis.rs @@ -44,4 +44,4 @@ async fn test__genesis_block__hash() { ) .unwrap() ) -} \ No newline at end of file +}