Skip to content

Commit

Permalink
Use fuel-vm 0.49.0 with new transactions types (#1822)
Browse files Browse the repository at this point in the history
Closes FuelLabs/fuel-core#1753
Closes FuelLabs/fuel-core#1754
Closes FuelLabs/fuel-core#1546

The change upgrade `fuel-vm` to `0.49` introducing `Upgrade` and
`Upload` transactions.

Supporting these transactions allows the upgrade of consensus parameters
and state transition functions for the whole network.

The change adds basic e2e tests. More advanced use cases will be tested
in the FuelLabs/fuel-core#1622.

## Checklist
- [x] Breaking changes are clearly marked as such in the PR description
and changelog
- [x] New behavior is reflected in tests

### Before requesting review
- [x] I have reviewed the code myself

### After merging, notify other teams

- [x] [Rust SDK](https://github.com/FuelLabs/fuels-rs/)
- [x] [Platform
documentation](https://github.com/FuelLabs/devrel-requests/issues/9)
  • Loading branch information
crypto523 committed Apr 16, 2024
1 parent ba19bf9 commit 7f03251
Show file tree
Hide file tree
Showing 48 changed files with 1,081 additions and 188 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ Description of the upcoming release here.
- [#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.

#### Breaking

- [#1822](https://github.com/FuelLabs/fuel-core/pull/1822): Removed support of `Create` transaction from debugger since it doesn't have any script to execute.
- [#1822](https://github.com/FuelLabs/fuel-core/pull/1822): Use `fuel-vm 0.49.0` with new transactions types - `Upgrade` and `Upload`. Also added `max_bytecode_subsections` field to the `ConsensusParameters` to limit the number of bytecode subsections in the state transition bytecode.
- [#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.

## [Version 0.24.2]

### Changed
Expand Down
34 changes: 18 additions & 16 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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ fuel-core-wasm-executor = { version = "0.24.2", path = "./crates/services/upgrad
fuel-core-xtask = { version = "0.0.0", path = "./xtask" }

# Fuel dependencies
fuel-vm-private = { version = "0.48.0", package = "fuel-vm", default-features = false }
fuel-vm-private = { version = "0.49.0", package = "fuel-vm", default-features = false }

# Common dependencies
anyhow = "1.0"
Expand Down
28 changes: 19 additions & 9 deletions benches/benches/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ use fuel_core_storage::{
vm_storage::VmStorage,
};
use fuel_core_types::{
blockchain::header::GeneratedConsensusFields,
blockchain::{
header::{
ApplicationHeader,
ConsensusHeader,
},
primitives::Empty,
},
fuel_tx::Bytes32,
fuel_types::ContractId,
fuel_vm::InterpreterStorage,
Expand Down Expand Up @@ -73,9 +79,10 @@ fn insert_state_single_contract_database(c: &mut Criterion) {
let mut elapsed_time = Duration::default();
for _ in 0..iters {
let inner = outer.read_transaction();
let mut inner_db = VmStorage::new::<GeneratedConsensusFields>(
let mut inner_db = VmStorage::new(
inner,
&Default::default(),
&ConsensusHeader::<Empty>::default(),
&ApplicationHeader::<Empty>::default(),
Default::default(),
);
let start = std::time::Instant::now();
Expand Down Expand Up @@ -134,9 +141,10 @@ fn insert_state_single_contract_transaction(c: &mut Criterion) {
let mut elapsed_time = Duration::default();
for _ in 0..iters {
let inner = outer.read_transaction();
let mut inner_db = VmStorage::new::<GeneratedConsensusFields>(
let mut inner_db = VmStorage::new(
inner,
&Default::default(),
&ConsensusHeader::<Empty>::default(),
&ApplicationHeader::<Empty>::default(),
Default::default(),
);
let start = std::time::Instant::now();
Expand Down Expand Up @@ -198,9 +206,10 @@ fn insert_state_multiple_contracts_database(c: &mut Criterion) {
let contract: ContractId = rng.gen();
for _ in 0..iters {
let inner = outer.read_transaction();
let mut inner_db = VmStorage::new::<GeneratedConsensusFields>(
let mut inner_db = VmStorage::new(
inner,
&Default::default(),
&ConsensusHeader::<Empty>::default(),
&ApplicationHeader::<Empty>::default(),
Default::default(),
);
let start = std::time::Instant::now();
Expand Down Expand Up @@ -262,9 +271,10 @@ fn insert_state_multiple_contracts_transaction(c: &mut Criterion) {
let contract: ContractId = rng.gen();
for _ in 0..iters {
let inner = outer.read_transaction();
let mut inner_db = VmStorage::new::<GeneratedConsensusFields>(
let mut inner_db = VmStorage::new(
inner,
&Default::default(),
&ConsensusHeader::<Empty>::default(),
&ApplicationHeader::<Empty>::default(),
Default::default(),
);
let start = std::time::Instant::now();
Expand Down
16 changes: 13 additions & 3 deletions benches/benches/vm_set/blockchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ use fuel_core_storage::{
StorageAsMut,
};
use fuel_core_types::{
blockchain::header::ConsensusHeader,
blockchain::header::{
ApplicationHeader,
ConsensusHeader,
},
fuel_asm::{
op,
GTFArgs,
Expand Down Expand Up @@ -123,15 +126,22 @@ impl BenchDb {

/// Creates a `VmDatabase` instance.
fn to_vm_database(&self) -> VmStorage<StorageTransaction<Database>> {
let header = ConsensusHeader {
let consensus = ConsensusHeader {
prev_root: Default::default(),
height: 1.into(),
time: Tai64::UNIX_EPOCH,
generated: (),
};
let application = ApplicationHeader {
da_height: Default::default(),
consensus_parameters_version: 0,
generated: (),
state_transition_bytecode_version: 0,
};
VmStorage::new(
self.db.clone().into_transaction(),
&header,
&consensus,
&application,
ContractId::zeroed(),
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"max_outputs": 255,
"max_witnesses": 255,
"max_gas_per_tx": 1000000000,
"max_size": 17825792
"max_size": 17825792,
"max_bytecode_subsections": 256
}
},
"predicate_params": {
Expand Down
3 changes: 2 additions & 1 deletion bin/fuel-core/chainspec/dev-testnet/chain_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"max_outputs": 255,
"max_witnesses": 255,
"max_gas_per_tx": 1000000000,
"max_size": 17825792
"max_size": 17825792,
"max_bytecode_subsections": 256
}
},
"predicate_params": {
Expand Down
3 changes: 2 additions & 1 deletion bin/fuel-core/chainspec/testnet/chain_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"max_outputs": 255,
"max_witnesses": 255,
"max_gas_per_tx": 30000000,
"max_size": 112640
"max_size": 112640,
"max_bytecode_subsections": 256
}
},
"predicate_params": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ expression: json
"max_outputs": 255,
"max_witnesses": 255,
"max_gas_per_tx": 100000000,
"max_size": 17825792
"max_size": 17825792,
"max_bytecode_subsections": 256
},
"predicate_params": {
"max_predicate_length": 1048576,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ expression: json
"max_outputs": 255,
"max_witnesses": 255,
"max_gas_per_tx": 100000000,
"max_size": 112640
"max_size": 112640,
"max_bytecode_subsections": 255
}
},
"predicate_params": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ expression: json
"max_outputs": 255,
"max_witnesses": 255,
"max_gas_per_tx": 100000000,
"max_size": 17825792
"max_size": 17825792,
"max_bytecode_subsections": 256
},
"predicate_params": {
"max_predicate_length": 1048576,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ expression: json
"max_outputs": 255,
"max_witnesses": 255,
"max_gas_per_tx": 100000000,
"max_size": 17825792
"max_size": 17825792,
"max_bytecode_subsections": 256
},
"predicate_params": {
"max_predicate_length": 1048576,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ expression: json
"max_outputs": 255,
"max_witnesses": 255,
"max_gas_per_tx": 100000000,
"max_size": 17825792
"max_size": 17825792,
"max_bytecode_subsections": 256
},
"predicate_params": {
"max_predicate_length": 1048576,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ expression: json
"max_outputs": 255,
"max_witnesses": 255,
"max_gas_per_tx": 100000000,
"max_size": 17825792
"max_size": 17825792,
"max_bytecode_subsections": 256
},
"predicate_params": {
"max_predicate_length": 1048576,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ expression: json
"max_outputs": 255,
"max_witnesses": 255,
"max_gas_per_tx": 100000000,
"max_size": 17825792
"max_size": 17825792,
"max_bytecode_subsections": 256
},
"predicate_params": {
"max_predicate_length": 1048576,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ expression: json
"max_outputs": 255,
"max_witnesses": 255,
"max_gas_per_tx": 100000000,
"max_size": 17825792
"max_size": 17825792,
"max_bytecode_subsections": 256
},
"predicate_params": {
"max_predicate_length": 1048576,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ expression: json
"max_outputs": 255,
"max_witnesses": 255,
"max_gas_per_tx": 100000000,
"max_size": 17825792
"max_size": 17825792,
"max_bytecode_subsections": 256
},
"predicate_params": {
"max_predicate_length": 1048576,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ expression: json
"max_outputs": 255,
"max_witnesses": 255,
"max_gas_per_tx": 100000000,
"max_size": 17825792
"max_size": 17825792,
"max_bytecode_subsections": 256
},
"predicate_params": {
"max_predicate_length": 1048576,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ expression: json
"max_outputs": 255,
"max_witnesses": 255,
"max_gas_per_tx": 100000000,
"max_size": 17825792
"max_size": 17825792,
"max_bytecode_subsections": 256
},
"predicate_params": {
"max_predicate_length": 1048576,
Expand Down
Loading

0 comments on commit 7f03251

Please sign in to comment.