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

Update the WASM compatibility tests for 0.36 release #2271

Merged
merged 14 commits into from
Oct 5, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions version-compatibility/forkless-upgrade/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ tokio = { version = "1.37.0", features = ["rt-multi-thread"] }

# Neutral deps
fuel-core-trace = { path = "../../crates/trace" }
fuel-crypto = { version = "0.49.0" }
fuel-tx = { version = "0.49.0", features = ["random"] }
fuel-crypto = { version = "0.57.0" }
fuel-tx = { version = "0.57.0", features = ["random"] }

# Latest fuel-core
latest-fuel-core-bin = { path = "../../bin/fuel-core", package = "fuel-core-bin", features = [
Expand All @@ -29,10 +29,9 @@ latest-fuel-core-type = { path = "../../crates/types", package = "fuel-core-type
"test-helpers",
] }
latest-fuel-core-client = { path = "../../crates/client", package = "fuel-core-client" }
# TODO: https://github.com/FuelLabs/fuel-core/issues/2198
#latest-fuel-core-upgradable-executor = { path = "../../crates/services/upgradable-executor", package = "fuel-core-upgradable-executor", features = [
# "wasm-executor",
#] }
latest-fuel-core-upgradable-executor = { path = "../../crates/services/upgradable-executor", package = "fuel-core-upgradable-executor", features = [
"wasm-executor",
] }

# Genesis fuel-core
genesis-fuel-core-bin = { version = "0.26.0", package = "fuel-core-bin", features = [
Expand All @@ -41,3 +40,11 @@ genesis-fuel-core-bin = { version = "0.26.0", package = "fuel-core-bin", feature
] }
genesis-fuel-core-client = { version = "0.26.0", package = "fuel-core-client" }
genesis-fuel-core-services = { version = "0.26.0", package = "fuel-core-services" }

# Fuel core version 0.36.0
version-36-fuel-core-bin = { version = "0.36.0", package = "fuel-core-bin", features = [
"parquet",
"p2p",
] }
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" }
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use crate::tests_helper::{
default_multiaddr,
GenesisFuelCoreDriver,
LatestFuelCoreDriver,
Version36FuelCoreDriver,
IGNITION_TESTNET_SNAPSHOT,
POA_SECRET_KEY,
};
Expand All @@ -25,6 +26,8 @@ use libp2p::{
};
use std::time::Duration;

const BLOCK_INCLUSION_TIMEOUT: Duration = Duration::from_secs(240);

#[tokio::test]
async fn latest_binary_is_backward_compatible_and_can_load_testnet_config() {
// When
Expand Down Expand Up @@ -109,7 +112,76 @@ async fn latest_binary_is_backward_compatible_and_follows_blocks_created_by_gene

// Then
for i in 0..BLOCKS_TO_PRODUCE {
let _ = tokio::time::timeout(Duration::from_secs(120), imported_blocks.next())
let _ = tokio::time::timeout(BLOCK_INCLUSION_TIMEOUT, imported_blocks.next())
.await
.expect(format!("Timed out waiting for block import {i}").as_str())
.expect(format!("Failed to import block {i}").as_str());
}
}

#[tokio::test]
async fn latest_binary_is_backward_compatible_and_follows_blocks_created_by_v36_binary() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

It still would be nice to have one more backward compatibility tests that produces blocks by fuel-core 0.26.0

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Genesis test is restored in 13f2653

// Given
let v36_keypair = SecpKeypair::generate();
let hexed_secret = hex::encode(v36_keypair.secret().to_bytes());
let v36_port = "30333";
let v36_node = Version36FuelCoreDriver::spawn(&[
"--service-name",
"V36Producer",
"--debug",
"--poa-instant",
"true",
"--consensus-key",
POA_SECRET_KEY,
"--snapshot",
IGNITION_TESTNET_SNAPSHOT,
Copy link
Collaborator

Choose a reason for hiding this comment

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

This snapshot using the state transition function from fuel-core 0.26.0. Maybe we want to add a new snapshot for fuel-core 0.36?=)

"--enable-p2p",
"--keypair",
hexed_secret.as_str(),
"--peering-port",
v36_port,
])
.await
.unwrap();
let public_key = Keypair::from(v36_keypair).public();
let v36_peer_id = PeerId::from_public_key(&public_key);
let v36_multiaddr = default_multiaddr(v36_port, v36_peer_id);

// Starting node that uses latest fuel core.
// It will connect to the v36 node and sync blocks.
let latest_keypair = SecpKeypair::generate();
let hexed_secret = hex::encode(latest_keypair.secret().to_bytes());
let latest_node = LatestFuelCoreDriver::spawn(&[
"--service-name",
"LatestValidator",
"--debug",
"--poa-instant",
"false",
"--snapshot",
IGNITION_TESTNET_SNAPSHOT,
"--enable-p2p",
"--keypair",
hexed_secret.as_str(),
"--reserved-nodes",
v36_multiaddr.as_str(),
"--peering-port",
"0",
])
.await
.unwrap();
let mut imported_blocks = latest_node.node.shared.block_importer.events();

// When
const BLOCKS_TO_PRODUCE: u32 = 10;
v36_node
.client
.produce_blocks(BLOCKS_TO_PRODUCE, None)
.await
.unwrap();

// Then
for i in 0..BLOCKS_TO_PRODUCE {
let _ = tokio::time::timeout(BLOCK_INCLUSION_TIMEOUT, imported_blocks.next())
.await
.expect(format!("Timed out waiting for block import {i}").as_str())
.expect(format!("Failed to import block {i}").as_str());
Expand Down Expand Up @@ -166,4 +238,4 @@ async fn latest_binary_is_backward_compatible_and_can_deserialize_errors_from_ge
result.skipped_transactions[0].1,
ExecutorError::TransactionValidity(TransactionValidityError::CoinDoesNotExist(_))
));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::tests_helper::{
default_multiaddr,
transactions_from_subsections,
upgrade_transaction,
GenesisFuelCoreDriver,
Version36FuelCoreDriver,
IGNITION_TESTNET_SNAPSHOT,
POA_SECRET_KEY,
SUBSECTION_SIZE,
Expand All @@ -31,24 +31,24 @@ use rand::{
use std::time::Duration;

#[tokio::test]
async fn latest_state_transition_function_is_forward_compatible_with_genesis_binary() {
// The test has a genesis block producer and one genesis validator.
// Genesis nodes execute several blocks by using the genesis state transition function.
async fn latest_state_transition_function_is_forward_compatible_with_v36_binary() {
// The test has a v36 block producer and one v36 validator.
// v36 nodes execute several blocks by using the v36 state transition function.
// At some point, we upgrade the network to use the latest state transition function.
// The network should be able to generate several new blocks with a new version.
// Genesis block producer and validator should process all blocks.
// v36 block producer and validator should process all blocks.
//
// These actions test that old nodes could use a new state transition function,
// and it is forward compatible.
//
// To simplify the upgrade of the network `utxo_validation` is `false`.

let genesis_keypair = SecpKeypair::generate();
let hexed_secret = hex::encode(genesis_keypair.secret().to_bytes());
let genesis_port = "40333";
let genesis_node = GenesisFuelCoreDriver::spawn(&[
let v36_keypair = SecpKeypair::generate();
let hexed_secret = hex::encode(v36_keypair.secret().to_bytes());
let v36_port = "40333";
let v36_node = Version36FuelCoreDriver::spawn(&[
"--service-name",
"GenesisProducer",
"V36Producer",
"--debug",
"--poa-instant",
"true",
Expand All @@ -60,21 +60,21 @@ async fn latest_state_transition_function_is_forward_compatible_with_genesis_bin
"--keypair",
hexed_secret.as_str(),
"--peering-port",
genesis_port,
v36_port,
])
.await
.unwrap();
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 public_key = Keypair::from(v36_keypair).public();
let v36_peer_id = PeerId::from_public_key(&public_key);
let v36_multiaddr = default_multiaddr(v36_port, v36_peer_id);

// Starting a genesis validator node.
// It will connect to the genesis node and sync blocks.
// Starting a v36 validator node.
// It will connect to the v36 node and sync blocks.
let latest_keypair = SecpKeypair::generate();
let hexed_secret = hex::encode(latest_keypair.secret().to_bytes());
let validator_node = GenesisFuelCoreDriver::spawn(&[
let validator_node = Version36FuelCoreDriver::spawn(&[
"--service-name",
"GenesisValidator",
"V36Validator",
"--debug",
"--poa-instant",
"false",
Expand All @@ -84,7 +84,7 @@ async fn latest_state_transition_function_is_forward_compatible_with_genesis_bin
"--keypair",
hexed_secret.as_str(),
"--reserved-nodes",
genesis_multiaddr.as_str(),
v36_multiaddr.as_str(),
"--peering-port",
"0",
])
Expand All @@ -94,7 +94,7 @@ async fn latest_state_transition_function_is_forward_compatible_with_genesis_bin
// Given
let mut imported_blocks = validator_node.node.shared.block_importer.events();
const BLOCKS_TO_PRODUCE: u32 = 10;
genesis_node
v36_node
.client
.produce_blocks(BLOCKS_TO_PRODUCE, None)
.await
Expand Down Expand Up @@ -144,7 +144,7 @@ async fn latest_state_transition_function_is_forward_compatible_with_genesis_bin

// Then
let mut imported_blocks = validator_node.node.shared.block_importer.events();
genesis_node
v36_node
.client
.produce_blocks(BLOCKS_TO_PRODUCE, None)
.await
Expand Down
7 changes: 2 additions & 5 deletions version-compatibility/forkless-upgrade/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@

#[cfg(test)]
mod backward_compatibility;
// TODO: Uncomment forward compatibility tests after release of the `fuel-core 0.36.0`.
// New forward compatibility test should use the `fuel-core 0.36.0`.
// https://github.com/FuelLabs/fuel-core/issues/2198
// #[cfg(test)]
// mod forward_compatibility;
#[cfg(test)]
mod forward_compatibility;
#[cfg(test)]
pub(crate) mod tests_helper;

Expand Down
11 changes: 11 additions & 0 deletions version-compatibility/forkless-upgrade/src/tests_helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ use rand::{
Rng,
};
use std::str::FromStr;
use version_36_fuel_core_bin::FuelService as Version36FuelService;
use version_36_fuel_core_client::client::FuelClient as Version36Client;
use version_36_fuel_core_services as _;

// Awful version compatibility hack.
// `$bin_crate::cli::run::get_service` is async in the later versions of fuel-core-bin.
Expand Down Expand Up @@ -92,6 +95,14 @@ define_core_driver!(
false
);

define_core_driver!(
version_36_fuel_core_bin,
Version36FuelService,
Version36Client,
Version36FuelCoreDriver,
true
);

define_core_driver!(
latest_fuel_core_bin,
LatestFuelService,
Expand Down
Loading