-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added backward and forward compatibility integration tests for forkle…
…ss upgrades (#1895) Closes #1622 The change adds integration tests for the forkless upgrade feature. The tests verify that it is backward compatible and, where possible, forward compatible. The main idea is to use published `fuel-core` crates to produce blocks with different state transition functions. Tests are using Ignition testnet chain config as a main source to be compatible with. ### Before requesting review - [x] I have reviewed the code myself
- Loading branch information
Showing
20 changed files
with
1,316 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,6 +82,7 @@ async fn test_peer_info() { | |
.shared | ||
.config | ||
.p2p | ||
.as_ref() | ||
.unwrap() | ||
.keypair | ||
.public() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
[package] | ||
edition = "2021" | ||
license = "BUSL-1.1" | ||
name = "forkless-upgrade" | ||
publish = false | ||
version = "0.0.0" | ||
build = "build.rs" | ||
|
||
[dev-dependencies] | ||
anyhow = "1.0" | ||
clap = "4.4" | ||
libp2p = "0.53.2" | ||
hex = "0.4.3" | ||
rand = "0.8" | ||
tempfile = "3.4" | ||
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"] } | ||
|
||
# Latest fuel-core | ||
latest-fuel-core-bin = { path = "../../bin/fuel-core", package = "fuel-core-bin", features = [ | ||
"parquet", | ||
"p2p", | ||
] } | ||
latest-fuel-core-client = { path = "../../crates/client", package = "fuel-core-client" } | ||
latest-fuel-core-services = { path = "../../crates/services", package = "fuel-core-services" } | ||
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 = [ | ||
"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" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Forkless upgrade tests | ||
|
||
This crate tests that state transition functions for all releases of `fuel-core` are backward compatible. | ||
|
||
In addition, we also test that releases are forward-compatible unless we introduce a breaking change in the API. | ||
|
||
## Adding new test | ||
|
||
We need to add a new backward compatibility test for each new release. To add tests, we need to duplicate tests that are using the latest `fuel-core` and replace usage of the latest crate with a new release. | ||
|
||
## Forward compatibility | ||
|
||
If the forward compatibility test fails after your changes, it usually means that the change breaks a WASM API, and the network first must upgrade the binary before performing an upgrade of the network. | ||
|
||
In the case of breaking API, we need to remove old tests(usually, we need to create a new test per each release) and write a new test(only one) to track new forward compatibility. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
use std::{ | ||
env, | ||
path::{ | ||
Path, | ||
PathBuf, | ||
}, | ||
process::Command, | ||
}; | ||
|
||
fn main() { | ||
// It only forces a rerun of the build when `build.rs` is changed. | ||
println!("cargo:rerun-if-changed=build.rs"); | ||
// Because `fuel-core-wasm-executor 0.26.0` is using `--offline` flag, | ||
// we need to download all dependencies before building the WASM executor. | ||
// This is a workaround specifically for `fuel-core 0.26.0`. | ||
// Future version of the `fuel-core` will not use `--offline` flag. | ||
build_fuel_core_26() | ||
} | ||
|
||
fn build_fuel_core_26() { | ||
let cargo = env::var("CARGO").unwrap_or_else(|_| "cargo".to_string()); | ||
let args = vec![ | ||
"install".to_owned(), | ||
"fuel-core-wasm-executor".to_owned(), | ||
"--target=wasm32-unknown-unknown".to_owned(), | ||
"--no-default-features".to_owned(), | ||
"--locked".to_owned(), | ||
"--version".to_owned(), | ||
"0.26.0".to_owned(), | ||
]; | ||
|
||
let mut cargo = Command::new(cargo); | ||
cargo.current_dir(project_root()).args(args); | ||
|
||
let output = cargo.output(); | ||
|
||
match output { | ||
Ok(output) => { | ||
if !output.status.success() { | ||
panic!( | ||
"Got an error status during compiling WASM executor: \n{:#?}", | ||
output | ||
); | ||
} | ||
} | ||
Err(err) => { | ||
panic!("\n{:#?}", err); | ||
} | ||
} | ||
} | ||
|
||
fn project_root() -> PathBuf { | ||
Path::new(&env!("CARGO_MANIFEST_DIR")) | ||
.ancestors() | ||
.nth(1) | ||
.unwrap() | ||
.to_path_buf() | ||
} |
7 changes: 7 additions & 0 deletions
7
version-compatibility/forkless-upgrade/chain-configurations/ignition/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# The configuration of the Ignition network | ||
|
||
This configuration is copy of [this](https://github.com/FuelLabs/chain-configuration/tree/master/ignition) repository. | ||
|
||
With modifications: | ||
- PoA Key: `{"address":"3ba3b213c8d5ec4d4901ac34b0e924d635384a8b0a5df6e116bce9a783da8e02","secret":"e3d6eb39607650e22f0befa26d52e921d2e7924d0e165f38ffa8d9d0ac73de93","type":"block_production"}` | ||
- Privileged Key: `{"address":"f034f7859dbf1d775cba16fc175eef249a045d6484a8b9388c9e280267125b73","secret":"dcbe36d8e890d7489b6e1be442eab98ae2fdbb5c7d77e1f9e1e12a545852304f","type":"block_production"}` |
Oops, something went wrong.