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 3 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
20 changes: 9 additions & 11 deletions version-compatibility/forkless-upgrade/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ license = "BUSL-1.1"
name = "forkless-upgrade"
publish = false
version = "0.0.0"
build = "build.rs"

[dev-dependencies]
anyhow = "1.0"
Expand All @@ -17,8 +16,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,15 +28,14 @@ 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 = [
# Fuel core version 0.36.0
version-36-fuel-core-bin = { version = "0.36.0", package = "fuel-core-bin", features = [
"parquet",
"p2p",
] }
genesis-fuel-core-client = { version = "0.26.0", package = "fuel-core-client" }
genesis-fuel-core-services = { version = "0.26.0", package = "fuel-core-services" }
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" }
58 changes: 0 additions & 58 deletions version-compatibility/forkless-upgrade/build.rs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::tests_helper::{
default_multiaddr,
GenesisFuelCoreDriver,
LatestFuelCoreDriver,
Version36FuelCoreDriver,
IGNITION_TESTNET_SNAPSHOT,
POA_SECRET_KEY,
};
Expand Down Expand Up @@ -47,15 +47,14 @@ async fn latest_binary_is_backward_compatible_and_can_load_testnet_config() {
}

#[tokio::test]
async fn latest_binary_is_backward_compatible_and_follows_blocks_created_by_genesis_binary(
) {
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 genesis_keypair = SecpKeypair::generate();
let hexed_secret = hex::encode(genesis_keypair.secret().to_bytes());
let genesis_port = "30333";
let genesis_node = GenesisFuelCoreDriver::spawn(&[
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",
"GenesisProducer",
"V36Producer",
"--debug",
"--poa-instant",
"true",
Expand All @@ -67,16 +66,16 @@ async fn latest_binary_is_backward_compatible_and_follows_blocks_created_by_gene
"--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 node that uses latest fuel core.
// It will connect to the genesis node and sync blocks.
// 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(&[
Expand All @@ -91,7 +90,7 @@ async fn latest_binary_is_backward_compatible_and_follows_blocks_created_by_gene
"--keypair",
hexed_secret.as_str(),
"--reserved-nodes",
genesis_multiaddr.as_str(),
v36_multiaddr.as_str(),
"--peering-port",
"0",
])
Expand All @@ -101,7 +100,7 @@ async fn latest_binary_is_backward_compatible_and_follows_blocks_created_by_gene

// When
const BLOCKS_TO_PRODUCE: u32 = 10;
genesis_node
v36_node
.client
.produce_blocks(BLOCKS_TO_PRODUCE, None)
.await
Expand All @@ -117,15 +116,15 @@ async fn latest_binary_is_backward_compatible_and_follows_blocks_created_by_gene
}

#[tokio::test]
async fn latest_binary_is_backward_compatible_and_can_deserialize_errors_from_genesis_binary(
) {
async fn latest_binary_is_backward_compatible_and_can_deserialize_errors_from_v36_binary()
{
// Given
let genesis_keypair = SecpKeypair::generate();
let hexed_secret = hex::encode(genesis_keypair.secret().to_bytes());
let genesis_port = "30333";
let node_with_genesis_transition = LatestFuelCoreDriver::spawn(&[
let v36_keypair = SecpKeypair::generate();
let hexed_secret = hex::encode(v36_keypair.secret().to_bytes());
let v36_port = "30333";
let node_with_v36_transition = LatestFuelCoreDriver::spawn(&[
"--service-name",
"GenesisProducer",
"V36Producer",
"--debug",
"--poa-instant",
"true",
Expand All @@ -137,7 +136,7 @@ async fn latest_binary_is_backward_compatible_and_can_deserialize_errors_from_ge
"--keypair",
hexed_secret.as_str(),
"--peering-port",
genesis_port,
v36_port,
"--utxo-validation",
])
.await
Expand All @@ -147,13 +146,13 @@ async fn latest_binary_is_backward_compatible_and_can_deserialize_errors_from_ge
let invalid_transaction = Transaction::default_test_tx();
let mut component: Components<Vec<Transaction>> = Default::default();
component.header_to_produce.consensus.height = 1u32.into();
// Use version of the genesis state transition
// Use version of the v36 state transition
component
.header_to_produce
.application
.state_transition_bytecode_version = 0;
component.transactions_source = vec![invalid_transaction];
let result = node_with_genesis_transition
let result = node_with_v36_transition
.node
.shared
.executor
Expand Down
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
Loading
Loading