Skip to content

Commit

Permalink
Use state transition bytecode from the database (#1816)
Browse files Browse the repository at this point in the history
Related issue #1754

Updated the upgradable executor to fetch the state transition bytecode
from the database when the version doesn't match a native one. This
change enables the WASM executor in the "production" build and requires
a `wasm32-unknown-unknown` target.

The executor has a `VERSION` constant that must be updated when the
behavior of the state transition function is changed. That constant is
used to decide what executor to use(WASM or native).

## Checklist
- [x] New behavior is reflected in tests

### Before requesting review
- [x] I have reviewed the code myself
  • Loading branch information
xgreenx authored Apr 15, 2024
1 parent 376894e commit 2e71605
Show file tree
Hide file tree
Showing 10 changed files with 610 additions and 22 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ env:
RUSTFLAGS: -D warnings
REGISTRY: ghcr.io
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 2
FUEL_ALWAYS_USE_WASM: true

jobs:
check-changelog:
Expand Down Expand Up @@ -317,7 +318,7 @@ jobs:
publish-docker-image-profiling:
needs:
- verifications-complete
runs-on: buildjet-4vcpu-ubuntu-2204
runs-on: buildjet-16vcpu-ubuntu-2204
permissions:
contents: read
packages: write
Expand Down
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
## [Unreleased]

Description of the upcoming release here.

### Fixed

- [#1814](https://github.com/FuelLabs/fuel-core/pull/1814): Bugfix: the `iter_all_by_prefix` was not working for all tables. The change adds a `Rust` level filtering.
=======

### Added

- [#1813](https://github.com/FuelLabs/fuel-core/pull/1813): Added back support for `/health` endpoint.
- [#1799](https://github.com/FuelLabs/fuel-core/pull/1799): Snapshot creation is now concurrent.

### Changed

- [#1816](https://github.com/FuelLabs/fuel-core/pull/1816): Updated the upgradable executor to fetch the state transition bytecode from the database when the version doesn't match a native one. This change enables the WASM executor in the "production" build and requires a `wasm32-unknown-unknown` target.
- [#1812](https://github.com/FuelLabs/fuel-core/pull/1812): Follow-up PR to simplify the logic around parallel snapshot creation.

### Changed
- [#1809](https://github.com/FuelLabs/fuel-core/pull/1809): Fetch `ConsensusParameters` from the database
- [#1808](https://github.com/FuelLabs/fuel-core/pull/1808): Fetch consensus parameters from the provider.

Expand Down
36 changes: 36 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bin/fuel-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ clap = { workspace = true, features = ["derive", "env", "string"] }
const_format = { version = "0.2", optional = true }
dirs = "4.0"
dotenvy = { version = "0.15", optional = true }
fuel-core = { workspace = true }
fuel-core = { workspace = true, features = ["wasm-executor"] }
fuel-core-chain-config = { workspace = true }
fuel-core-types = { workspace = true }
hex = "0.4"
Expand Down
4 changes: 2 additions & 2 deletions ci_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ cargo clippy -p fuel-core-wasm-executor --target wasm32-unknown-unknown --no-def
cargo clippy --all-targets --all-features &&
cargo doc --all-features --workspace --no-deps &&
cargo make check --locked &&
cargo make check --all-features --locked &&
FUEL_ALWAYS_USE_WASM=true cargo make check --all-features --locked &&
cargo check -p fuel-core-types --target wasm32-unknown-unknown --no-default-features &&
cargo check -p fuel-core-storage --target wasm32-unknown-unknown --no-default-features &&
cargo check -p fuel-core-client --target wasm32-unknown-unknown --no-default-features &&
cargo check -p fuel-core-chain-config --target wasm32-unknown-unknown --no-default-features &&
cargo check -p fuel-core-executor --target wasm32-unknown-unknown --no-default-features &&
cargo test --workspace &&
cargo test --all-features --workspace &&
FUEL_ALWAYS_USE_WASM=true cargo test --all-features --workspace &&
cargo test -p fuel-core --no-default-features &&
cargo test -p fuel-core-client --no-default-features &&
cargo test -p fuel-core-chain-config --no-default-features &&
Expand Down
6 changes: 6 additions & 0 deletions crates/services/upgradable-executor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ fuel-core-executor = { workspace = true }
fuel-core-storage = { workspace = true }
fuel-core-types = { workspace = true }
fuel-core-wasm-executor = { workspace = true, optional = true }
parking_lot = { workspace = true, optional = true }
postcard = { workspace = true, optional = true }
tracing = { workspace = true, optional = true }
wasmtime = { version = "18.0.1", default-features = false, features = [
"cache",
"cranelift",
Expand All @@ -26,15 +28,19 @@ wasmtime = { version = "18.0.1", default-features = false, features = [
], optional = true }

[dev-dependencies]
anyhow = { workspace = true }
fuel-core-storage = { workspace = true, features = ["test-helpers"] }
fuel-core-types = { workspace = true, features = ["test-helpers"] }
ntest = "0.9.2"

[features]
default = ["std"]
std = ["fuel-core-executor/std", "fuel-core-storage/std", "fuel-core-types/std"]
wasm-executor = [
"dep:anyhow",
"dep:parking_lot",
"dep:postcard",
"dep:tracing",
"dep:fuel-core-wasm-executor",
"dep:wasmtime",
]
Expand Down
1 change: 1 addition & 0 deletions crates/services/upgradable-executor/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ fn build_wasm() {
cargo.env("CARGO_PROFILE_RELEASE_CODEGEN_UNITS", "1");
cargo.env("CARGO_PROFILE_RELEASE_OPT_LEVEL", "3");
cargo.env("CARGO_PROFILE_RELEASE_STRIP", "symbols");
cargo.env("CARGO_PROFILE_RELEASE_DEBUG", "false");
cargo.current_dir(project_root()).args(args);

let output = cargo.output();
Expand Down
Loading

0 comments on commit 2e71605

Please sign in to comment.