Skip to content

Commit

Permalink
Patch to use fuel-vm 0.48.0 (#1783)
Browse files Browse the repository at this point in the history
The PR upgrade `fuel-vm` to `0.48.0` release. Because of some breaking
changes, we also adapted our codebase to follow them:

- Implementation of `Default` for configs was moved under the
`test-helpers` feature. The `fuel-core` binary uses testnet
configuration instead of `Default::default`(for cases when `ChainConfig`
was not provided by the user).
- All parameter types are enums now and require corresponding
modifications across the codebase(we need to use getters and setters).
The GraphQL API remains the same for simplicity, but each parameter now
has one more field - `version`, that can be used to decide how to
deserialize.
- The `UtxoId` type now is 34 bytes instead of 33. It affects hex
representation and requires adding `00`.
- The `block_gas_limit` was moved to `ConsensusParameters` from
`ChainConfig`. It means the block producer doesn't specify the block gas
limit anymore, and we don't need to propagate this information.
- The `bytecodeLength` field is removed from the `Create` transaction.
- Removed `ConsensusParameters` from executor config because
`ConsensusParameters::default` is not available anymore. Instead,
executors fetch `ConsensusParameters` from the database.
  • Loading branch information
xgreenx authored Mar 28, 2024
1 parent 30ad24e commit 33848a3
Show file tree
Hide file tree
Showing 103 changed files with 7,021 additions and 6,115 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ Description of the upcoming release here.
### Changed

#### Breaking
- [#1783](https://github.com/FuelLabs/fuel-core/pull/1783): The PR upgrade `fuel-vm` to `0.48.0` release. Because of some breaking changes, we also adapted our codebase to follow them:
- Implementation of `Default` for configs was moved under the `test-helpers` feature. The `fuel-core` binary uses testnet configuration instead of `Default::default`(for cases when `ChainConfig` was not provided by the user).
- All parameter types are enums now and require corresponding modifications across the codebase(we need to use getters and setters). The GraphQL API remains the same for simplicity, but each parameter now has one more field - `version`, that can be used to decide how to deserialize.
- The `UtxoId` type now is 34 bytes instead of 33. It affects hex representation and requires adding `00`.
- The `block_gas_limit` was moved to `ConsensusParameters` from `ChainConfig`. It means the block producer doesn't specify the block gas limit anymore, and we don't need to propagate this information.
- The `bytecodeLength` field is removed from the `Create` transaction.
- Removed `ConsensusParameters` from executor config because `ConsensusParameters::default` is not available anymore. Instead, executors fetch `ConsensusParameters` from the database.

- [#1769](https://github.com/FuelLabs/fuel-core/pull/1769): Include new field on header for the merkle root of imported events. Rename other message root field.
- [#1768](https://github.com/FuelLabs/fuel-core/pull/1768): Moved `ContractsInfo` table to the off-chain database. Removed `salt` field from the `ContractConfig`.
- [#1761](https://github.com/FuelLabs/fuel-core/pull/1761): Adjustments to the upcoming testnet configs:
Expand Down
38 changes: 22 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.23.0", path = "./crates/services/upgrad
fuel-core-xtask = { version = "0.0.0", path = "./xtask" }

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

# Common dependencies
anyhow = "1.0"
Expand Down
1 change: 1 addition & 0 deletions benches/benches-outputs/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use fuel_core_types::fuel_tx::{
consensus_parameters::gas::GasCostsValuesV1,
DependentCost,
GasCostsValues,
};
Expand Down
43 changes: 26 additions & 17 deletions benches/benches/block_target_gas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,12 @@ use fuel_core_types::{
},
fuel_tx::{
ContractIdExt,
FeeParameters,
GasCosts,
Input,
Output,
PredicateParameters,
TxParameters,
TxPointer,
UniqueIdentifier,
UtxoId,
Expand Down Expand Up @@ -261,12 +264,31 @@ fn service_with_many_contracts(
.unwrap();
let _drop = rt.enter();
let mut database = Database::rocksdb_temp();

let mut config = Config::local_node();

config.chain_config.consensus_parameters.set_tx_params(
TxParameters::default().with_max_gas_per_tx(TARGET_BLOCK_GAS_LIMIT),
);
config
.chain_config
.consensus_parameters
.set_predicate_params(
PredicateParameters::default()
.with_max_gas_per_predicate(TARGET_BLOCK_GAS_LIMIT),
);
config
.chain_config
.consensus_parameters
.set_fee_params(FeeParameters::default().with_gas_per_byte(0));
config
.chain_config
.consensus_parameters
.tx_params
.max_gas_per_tx = TARGET_BLOCK_GAS_LIMIT;
.set_block_gas_limit(TARGET_BLOCK_GAS_LIMIT);
config
.chain_config
.consensus_parameters
.set_gas_costs(GasCosts::new(default_gas_costs()));

let contract_configs = contract_ids
.iter()
Expand All @@ -281,19 +303,6 @@ fn service_with_many_contracts(
};
config.state_reader = StateReader::in_memory(state_config);

config
.chain_config
.consensus_parameters
.predicate_params
.max_gas_per_predicate = TARGET_BLOCK_GAS_LIMIT;
config.chain_config.block_gas_limit = TARGET_BLOCK_GAS_LIMIT;
config.chain_config.consensus_parameters.gas_costs =
GasCosts::new(default_gas_costs());
config
.chain_config
.consensus_parameters
.fee_params
.gas_per_byte = 0;
config.utxo_validation = false;
config.block_production = Trigger::Instant;

Expand Down Expand Up @@ -386,7 +395,7 @@ fn run_with_service_with_extra_inputs(
*contract_id,
);
let contract_output = Output::contract(
input_count as u8,
input_count as u16,
Bytes32::zeroed(),
Bytes32::zeroed(),
);
Expand Down Expand Up @@ -415,7 +424,7 @@ fn run_with_service_with_extra_inputs(
.unwrap();
async move {
let tx_id =
tx.id(&shared.config.chain_config.consensus_parameters.chain_id);
tx.id(&shared.config.chain_config.consensus_parameters.chain_id());

let mut sub = shared.block_importer.block_importer.subscribe();
shared
Expand Down
2 changes: 1 addition & 1 deletion benches/benches/vm_initialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ pub fn vm_initialization(c: &mut Criterion) {
let mut i = 5usize;
loop {
let size = 8 * (1 << i);
if size as u64 > consensus_params.script_params.max_script_data_length {
if size as u64 > consensus_params.script_params().max_script_data_length() {
break
}
let script = vec![op::ret(1); size / Instruction::SIZE]
Expand Down
2 changes: 1 addition & 1 deletion benches/benches/vm_set/blockchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ impl BenchDb {
.storage::<FuelBlocks>()
.insert(
&0u32.into(),
&block.compress(&config.chain_config.consensus_parameters.chain_id),
&block.compress(&config.chain_config.consensus_parameters.chain_id()),
)
.unwrap();

Expand Down
8 changes: 4 additions & 4 deletions benches/src/bin/collect.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use clap::Parser;
use fuel_core_types::fuel_tx::GasCostsValues;
use fuel_core_types::fuel_tx::consensus_parameters::gas::GasCostsValuesV1;
use serde::{
Deserialize,
Serialize,
Expand Down Expand Up @@ -358,8 +358,8 @@ pub const GIT: &str = ""#,
r#"";"#,
r##"
pub fn default_gas_costs() -> GasCostsValues {
GasCostsValues {"##,
r##" }
GasCostsValuesV1 {"##,
r##" }.into()
}
"##,
];
Expand Down Expand Up @@ -482,7 +482,7 @@ impl State {
)
}

fn to_gas_costs(&self) -> GasCostsValues {
fn to_gas_costs(&self) -> GasCostsValuesV1 {
serde_yaml::from_value(self.to_yaml()).unwrap()
}

Expand Down
4 changes: 3 additions & 1 deletion benches/src/default_gas_costs.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use super::*;
use fuel_core_types::fuel_tx::consensus_parameters::gas::GasCostsValuesV1;
pub fn default_gas_costs() -> GasCostsValues {
GasCostsValues {
GasCostsValuesV1 {
add: 2,
addi: 2,
aloc: 1,
Expand Down Expand Up @@ -176,4 +177,5 @@ pub fn default_gas_costs() -> GasCostsValues {
units_per_gas: 2,
},
}
.into()
}
35 changes: 19 additions & 16 deletions benches/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,15 @@ impl VmBench {
pub const CONTRACT: ContractId = ContractId::zeroed();

pub fn new(instruction: Instruction) -> Self {
let tx_params = TxParameters {
max_gas_per_tx: LARGE_GAS_LIMIT + 1,
..Default::default()
};
let mut consensus_params = ConsensusParameters::default();
consensus_params.set_tx_params(
TxParameters::default().with_max_gas_per_tx(LARGE_GAS_LIMIT + 1),
);
consensus_params.set_fee_params(FeeParameters::default().with_gas_per_byte(0));
consensus_params.set_gas_costs(GasCosts::free());

Self {
params: ConsensusParameters {
tx_params,
..Default::default()
},
params: consensus_params,
gas_price: 0,
gas_limit: LARGE_GAS_LIMIT,
maturity: Default::default(),
Expand Down Expand Up @@ -361,7 +361,7 @@ impl TryFrom<VmBench> for VmBenchPrepared {

let input = tx.inputs().len();
let output =
Output::contract(input as u8, Bytes32::zeroed(), Bytes32::zeroed());
Output::contract(input as u16, Bytes32::zeroed(), Bytes32::zeroed());
let input = Input::contract(
UtxoId::default(),
Bytes32::zeroed(),
Expand All @@ -385,8 +385,11 @@ impl TryFrom<VmBench> for VmBenchPrepared {
}) = contract_code
{
let input_count = tx.inputs().len();
let output =
Output::contract(input_count as u8, Bytes32::zeroed(), Bytes32::zeroed());
let output = Output::contract(
input_count as u16,
Bytes32::zeroed(),
Bytes32::zeroed(),
);
let input = Input::contract(
UtxoId::default(),
Bytes32::zeroed(),
Expand All @@ -403,8 +406,11 @@ impl TryFrom<VmBench> for VmBenchPrepared {

for contract_id in empty_contracts {
let input_count = tx.inputs().len();
let output =
Output::contract(input_count as u8, Bytes32::zeroed(), Bytes32::zeroed());
let output = Output::contract(
input_count as u16,
Bytes32::zeroed(),
Bytes32::zeroed(),
);
let input = Input::contract(
UtxoId::default(),
Bytes32::zeroed(),
Expand Down Expand Up @@ -434,9 +440,6 @@ impl TryFrom<VmBench> for VmBenchPrepared {
// add at least one coin input
tx.add_random_fee_input();

let mut params = params;
params.fee_params.gas_per_byte = 0;
params.gas_costs = GasCosts::free();
let mut tx = tx
.script_gas_limit(gas_limit)
.maturity(maturity)
Expand Down
2 changes: 1 addition & 1 deletion bin/e2e-test-client/src/test_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ impl Wallet {
let tx = self
.transfer_tx(destination, transfer_amount, asset_id)
.await?;
let tx_id = tx.id(&self.consensus_params.chain_id);
let tx_id = tx.id(&self.consensus_params.chain_id());
println!("submitting tx... {:?}", tx_id);
let status = self.client.submit_and_await_commit(&tx).await?;

Expand Down
2 changes: 1 addition & 1 deletion bin/e2e-test-client/src/tests/script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ async fn _dry_runs(
);
}

assert!(tx.id(&chain_info.consensus_parameters.chain_id) == tx_status.id);
assert!(tx.id(&chain_info.consensus_parameters.chain_id()) == tx_status.id);
if expect == DryRunResult::Successful {
assert!(matches!(
&tx_status.result,
Expand Down
Loading

0 comments on commit 33848a3

Please sign in to comment.