From 33848a3da21ccbb5f8c8a7a1cb4bb47229d8007f Mon Sep 17 00:00:00 2001 From: Green Baneling Date: Thu, 28 Mar 2024 21:16:51 +0100 Subject: [PATCH] Patch to use `fuel-vm 0.48.0` (#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. --- CHANGELOG.md | 8 + Cargo.lock | 38 +- Cargo.toml | 2 +- benches/benches-outputs/src/lib.rs | 1 + benches/benches/block_target_gas.rs | 43 +- benches/benches/vm_initialization.rs | 2 +- benches/benches/vm_set/blockchain.rs | 2 +- benches/src/bin/collect.rs | 8 +- benches/src/default_gas_costs.rs | 4 +- benches/src/lib.rs | 35 +- bin/e2e-test-client/src/test_context.rs | 2 +- bin/e2e-test-client/src/tests/script.rs | 2 +- .../test_data/large_state/chain_config.json | 481 +- .../src/tests/test_data/large_state/tx.json | 8240 +++++++++-------- .../src/tests/test_data/non_specific_tx.raw | 2 +- .../tests/integration_tests.rs | 4 +- bin/fuel-core/Cargo.toml | 1 + bin/fuel-core/src/cli.rs | 10 + bin/fuel-core/src/cli/run.rs | 2 +- bin/fuel-core/src/cli/run/tx_pool.rs | 4 +- bin/fuel-core/src/cli/snapshot.rs | 2 +- ci_checks.sh | 3 + crates/chain-config/Cargo.toml | 3 +- crates/chain-config/src/config/chain.rs | 7 +- crates/chain-config/src/config/coin.rs | 17 +- crates/chain-config/src/config/contract.rs | 2 +- ..._tests__snapshot_local_testnet_config.snap | 481 +- .../chain-config/src/config/state/parquet.rs | 4 +- crates/client/assets/schema.sdl | 42 +- crates/client/src/client.rs | 5 +- crates/client/src/client/schema/chain.rs | 616 +- crates/client/src/client/schema/coins.rs | 2 + crates/client/src/client/schema/primitives.rs | 1 + ..._chain__tests__chain_gql_query_output.snap | 44 + ...s__tests__coin_by_id_query_gql_output.snap | 1 + ...ts__coins_connection_query_gql_output.snap | 1 + ...nt_transaction_by_id_query_gql_output.snap | 1 - .../src/client/schema/tx/transparent_tx.rs | 20 +- crates/client/src/client/types/chain_info.rs | 13 +- crates/client/src/client/types/coins.rs | 2 + crates/client/src/client/types/gas_costs.rs | 628 +- crates/fuel-core/Cargo.toml | 7 +- crates/fuel-core/src/database/coin.rs | 4 +- .../src/database/genesis_progress.rs | 4 +- crates/fuel-core/src/executor.rs | 113 +- .../src/graphql_api/storage/coins.rs | 11 +- .../src/graphql_api/storage/messages.rs | 22 +- crates/fuel-core/src/schema/chain.rs | 375 +- crates/fuel-core/src/schema/coins.rs | 5 +- crates/fuel-core/src/schema/dap.rs | 21 +- crates/fuel-core/src/schema/scalars.rs | 1 + crates/fuel-core/src/schema/tx.rs | 11 +- crates/fuel-core/src/schema/tx/input.rs | 11 +- crates/fuel-core/src/schema/tx/output.rs | 7 +- crates/fuel-core/src/schema/tx/types.rs | 16 +- .../service/adapters/consensus_module/poa.rs | 8 +- .../src/service/adapters/producer.rs | 2 - crates/fuel-core/src/service/config.rs | 23 +- crates/fuel-core/src/service/query.rs | 4 +- crates/fuel-core/src/service/sub_services.rs | 5 +- crates/metrics/src/txpool_metrics.rs | 5 +- .../services/consensus_module/poa/Cargo.toml | 7 + .../consensus_module/poa/src/config.rs | 4 +- .../consensus_module/poa/src/ports.rs | 2 - .../consensus_module/poa/src/service.rs | 6 +- .../consensus_module/poa/src/service_test.rs | 10 +- .../service_test/manually_produce_tests.rs | 5 +- .../poa/src/service_test/trigger_tests.rs | 7 +- .../poa/src/verifier/tests.rs | 3 +- crates/services/executor/src/executor.rs | 145 +- crates/services/executor/src/refs/contract.rs | 2 +- crates/services/importer/src/config.rs | 2 +- .../services/producer/src/block_producer.rs | 17 +- .../producer/src/block_producer/tests.rs | 16 +- crates/services/producer/src/mocks.rs | 2 +- crates/services/txpool/Cargo.toml | 1 + crates/services/txpool/src/config.rs | 1 + .../txpool/src/containers/dependency.rs | 4 +- crates/services/txpool/src/service.rs | 2 +- .../txpool/src/transaction_selector.rs | 7 +- crates/services/txpool/src/txpool.rs | 15 +- .../txpool/src/txpool/test_helpers.rs | 2 +- crates/services/txpool/src/txpool/tests.rs | 36 +- crates/services/upgradable-executor/build.rs | 14 +- .../upgradable-executor/src/config.rs | 6 - .../upgradable-executor/src/executor.rs | 12 +- .../wasm-executor/src/main.rs | 27 +- crates/storage/src/codec/manual.rs | 43 - crates/storage/src/codec/primitive.rs | 17 +- .../src/structured_storage/balances.rs | 5 +- .../storage/src/structured_storage/coins.rs | 2 +- .../storage/src/structured_storage/state.rs | 8 +- crates/types/src/blockchain/header.rs | 2 +- crates/types/src/services/block_producer.rs | 2 - crates/types/src/services/executor.rs | 3 + .../chainspec/dev-testnet/chain_config.json | 481 +- .../chainspec/testnet/chain_config.json | 481 +- tests/test-helpers/src/builder.rs | 8 +- tests/tests/chain.rs | 14 +- tests/tests/coin.rs | 2 +- tests/tests/deployment.rs | 4 +- tests/tests/example_tx.json | 266 +- tests/tests/fee_collection_contract.rs | 2 +- 103 files changed, 7021 insertions(+), 6115 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b6957bcfcc..7fa057f60db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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: diff --git a/Cargo.lock b/Cargo.lock index ee416b58144..93a3e5fe943 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1983,6 +1983,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" dependencies = [ "powerfmt", + "serde", ] [[package]] @@ -2843,9 +2844,9 @@ dependencies = [ [[package]] name = "fuel-asm" -version = "0.47.1" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1b088ac4762d59736b90803db239f96c66f2a1a2c616715ef0a9c196b58edc9" +checksum = "20bc683784e35f3421aab3dc5a31a94c8ad80f1e9ec614ddddac930b4081cd92" dependencies = [ "bitflags 2.4.2", "fuel-types", @@ -2963,6 +2964,7 @@ dependencies = [ "pyroscope", "pyroscope_pprofrs", "rand", + "serde_json", "tempfile", "test-case", "tikv-jemallocator", @@ -3193,6 +3195,7 @@ dependencies = [ "anyhow", "async-trait", "fuel-core-chain-config", + "fuel-core-poa", "fuel-core-services", "fuel-core-storage", "fuel-core-types", @@ -3424,9 +3427,9 @@ dependencies = [ [[package]] name = "fuel-crypto" -version = "0.47.1" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f00ba92f0e13a0dd06a7ad4e9a61221dc43d665519b50bfdb18755aebfdcf0" +checksum = "f6112c726b5254cad831e61db36dcd0d83b28c50180ea22cb8815343fb162526" dependencies = [ "coins-bip32", "coins-bip39", @@ -3445,9 +3448,9 @@ dependencies = [ [[package]] name = "fuel-derive" -version = "0.47.1" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b9b265467fe9d3d613a5bae9b8d3005d558d3e830dc416c9836bc16609a000f" +checksum = "5896603b839f04f27e8bddbae2990dc799fb119f5e62973d6666b2ea1a4b036b" dependencies = [ "proc-macro2", "quote", @@ -3457,9 +3460,9 @@ dependencies = [ [[package]] name = "fuel-merkle" -version = "0.47.1" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b21ea035ff06a28791c862496c3b03cfb2d87778476c419724796e945e282ad" +checksum = "c8f75d97f6d43fbd15aa5ca0d594b33cc59ba5fd73ce42f4a10dfa9288a9a4a4" dependencies = [ "derive_more", "digest 0.10.7", @@ -3472,15 +3475,15 @@ dependencies = [ [[package]] name = "fuel-storage" -version = "0.47.1" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1048957b744e448840eb9a09cb58c4647dec32e1cf49c0029e5445cbdc86f6d2" +checksum = "6899452bbf8b09d536b0adf98d6a28d1081ce38c3490fa2d8cc1dd47ba153351" [[package]] name = "fuel-tx" -version = "0.47.1" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8dc917bb2d1892ef6792624782bed7cee5670f3f836b344f06c4233bb1124aff" +checksum = "305c12d87f47d139505cbbaee1effa7750ce171c9a4362d212f4f7a651902121" dependencies = [ "bitflags 2.4.2", "derivative", @@ -3500,9 +3503,9 @@ dependencies = [ [[package]] name = "fuel-types" -version = "0.47.1" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2444c92791b02016aa1cbab6cfa38e34920e61ec61d564f7bdb3ad8ddfae35de" +checksum = "3d92d34c6625f0c3b88463f01027e836ba561125f6ccfb1402d12743fc7b2c96" dependencies = [ "fuel-derive", "hex", @@ -3512,9 +3515,9 @@ dependencies = [ [[package]] name = "fuel-vm" -version = "0.47.1" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e29c2333edbf3c55906b92a5f3dfb9639e2b0eabc7fd754e7a8e18d67ded3c2" +checksum = "b06f02e86ebf357689e34412af34faf7f0d35a9b8b6ccb2ec42fd369559d6914" dependencies = [ "anyhow", "async-trait", @@ -3537,6 +3540,7 @@ dependencies = [ "primitive-types", "rand", "serde", + "serde_with", "sha3", "static_assertions", "strum 0.24.1", @@ -7481,6 +7485,8 @@ dependencies = [ "base64 0.21.7", "chrono", "hex", + "indexmap 1.9.3", + "indexmap 2.2.5", "serde", "serde_derive", "serde_json", diff --git a/Cargo.toml b/Cargo.toml index 33c1ca0a28b..8e776e93a6f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/benches/benches-outputs/src/lib.rs b/benches/benches-outputs/src/lib.rs index a9ac6311937..cff4d42db87 100644 --- a/benches/benches-outputs/src/lib.rs +++ b/benches/benches-outputs/src/lib.rs @@ -1,4 +1,5 @@ use fuel_core_types::fuel_tx::{ + consensus_parameters::gas::GasCostsValuesV1, DependentCost, GasCostsValues, }; diff --git a/benches/benches/block_target_gas.rs b/benches/benches/block_target_gas.rs index cb1bc1617b9..9c3d77784df 100644 --- a/benches/benches/block_target_gas.rs +++ b/benches/benches/block_target_gas.rs @@ -64,9 +64,12 @@ use fuel_core_types::{ }, fuel_tx::{ ContractIdExt, + FeeParameters, GasCosts, Input, Output, + PredicateParameters, + TxParameters, TxPointer, UniqueIdentifier, UtxoId, @@ -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() @@ -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; @@ -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(), ); @@ -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 diff --git a/benches/benches/vm_initialization.rs b/benches/benches/vm_initialization.rs index 514099d2464..ff996271537 100644 --- a/benches/benches/vm_initialization.rs +++ b/benches/benches/vm_initialization.rs @@ -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] diff --git a/benches/benches/vm_set/blockchain.rs b/benches/benches/vm_set/blockchain.rs index d886b0e0b32..0422fde3764 100644 --- a/benches/benches/vm_set/blockchain.rs +++ b/benches/benches/vm_set/blockchain.rs @@ -110,7 +110,7 @@ impl BenchDb { .storage::() .insert( &0u32.into(), - &block.compress(&config.chain_config.consensus_parameters.chain_id), + &block.compress(&config.chain_config.consensus_parameters.chain_id()), ) .unwrap(); diff --git a/benches/src/bin/collect.rs b/benches/src/bin/collect.rs index e0f5eb64ecf..bcc2cf27350 100644 --- a/benches/src/bin/collect.rs +++ b/benches/src/bin/collect.rs @@ -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, @@ -358,8 +358,8 @@ pub const GIT: &str = ""#, r#"";"#, r##" pub fn default_gas_costs() -> GasCostsValues { - GasCostsValues {"##, - r##" } + GasCostsValuesV1 {"##, + r##" }.into() } "##, ]; @@ -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() } diff --git a/benches/src/default_gas_costs.rs b/benches/src/default_gas_costs.rs index a117736bf2a..05ea0582d9c 100644 --- a/benches/src/default_gas_costs.rs +++ b/benches/src/default_gas_costs.rs @@ -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, @@ -176,4 +177,5 @@ pub fn default_gas_costs() -> GasCostsValues { units_per_gas: 2, }, } + .into() } diff --git a/benches/src/lib.rs b/benches/src/lib.rs index 11bd39c6001..2807ddf0fc5 100644 --- a/benches/src/lib.rs +++ b/benches/src/lib.rs @@ -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(), @@ -361,7 +361,7 @@ impl TryFrom 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(), @@ -385,8 +385,11 @@ impl TryFrom 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(), @@ -403,8 +406,11 @@ impl TryFrom 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(), @@ -434,9 +440,6 @@ impl TryFrom 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) diff --git a/bin/e2e-test-client/src/test_context.rs b/bin/e2e-test-client/src/test_context.rs index 26281c9f3f4..1c14c5cfe75 100644 --- a/bin/e2e-test-client/src/test_context.rs +++ b/bin/e2e-test-client/src/test_context.rs @@ -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?; diff --git a/bin/e2e-test-client/src/tests/script.rs b/bin/e2e-test-client/src/tests/script.rs index 8d50f7c41ea..1234726384d 100644 --- a/bin/e2e-test-client/src/tests/script.rs +++ b/bin/e2e-test-client/src/tests/script.rs @@ -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, diff --git a/bin/e2e-test-client/src/tests/test_data/large_state/chain_config.json b/bin/e2e-test-client/src/tests/test_data/large_state/chain_config.json index a57d96fa780..2aa33ca96eb 100644 --- a/bin/e2e-test-client/src/tests/test_data/large_state/chain_config.json +++ b/bin/e2e-test-client/src/tests/test_data/large_state/chain_config.json @@ -1,251 +1,266 @@ { "chain_name": "Testnet", - "block_gas_limit": 1000000000, "consensus_parameters": { - "tx_params": { - "max_inputs": 255, - "max_outputs": 255, - "max_witnesses": 255, - "max_gas_per_tx": 1000000000, - "max_size": 17825792 - }, - "predicate_params": { - "max_predicate_length": 1048576, - "max_predicate_data_length": 1048576, - "max_message_data_length": 1048576, - "max_gas_per_predicate": 1000000000 - }, - "script_params": { - "max_script_length": 1048576, - "max_script_data_length": 1048576 - }, - "contract_params": { - "contract_max_size": 16777216, - "max_storage_slots": 131072 - }, - "fee_params": { - "gas_price_factor": 92, - "gas_per_byte": 63 - }, - "chain_id": 0, - "gas_costs": { - "add": 2, - "addi": 2, - "aloc": 1, - "and": 2, - "andi": 2, - "bal": 366, - "bhei": 2, - "bhsh": 2, - "burn": 33949, - "cb": 2, - "cfei": 2, - "cfsi": 2, - "div": 2, - "divi": 2, - "eck1": 3347, - "ecr1": 46165, - "ed19": 4210, - "eq": 2, - "exp": 2, - "expi": 2, - "flag": 1, - "gm": 2, - "gt": 2, - "gtf": 16, - "ji": 2, - "jmp": 2, - "jne": 2, - "jnei": 2, - "jnzi": 2, - "jmpf": 2, - "jmpb": 2, - "jnzf": 2, - "jnzb": 2, - "jnef": 2, - "jneb": 2, - "lb": 2, - "log": 754, - "lt": 2, - "lw": 2, - "mint": 35718, - "mlog": 2, - "mod": 2, - "modi": 2, - "move": 2, - "movi": 2, - "mroo": 5, - "mul": 2, - "muli": 2, - "mldv": 4, - "noop": 1, - "not": 2, - "or": 2, - "ori": 2, - "poph": 3, - "popl": 3, - "pshh": 4, - "pshl": 4, - "ret_contract": 733, - "rvrt_contract": 722, - "sb": 2, - "sll": 2, - "slli": 2, - "srl": 2, - "srli": 2, - "srw": 253, - "sub": 2, - "subi": 2, - "sw": 2, - "sww": 29053, - "time": 79, - "tr": 46242, - "tro": 33251, - "wdcm": 3, - "wqcm": 3, - "wdop": 3, - "wqop": 3, - "wdml": 3, - "wqml": 4, - "wddv": 5, - "wqdv": 7, - "wdmd": 11, - "wqmd": 18, - "wdam": 9, - "wqam": 12, - "wdmm": 11, - "wqmm": 11, - "xor": 2, - "xori": 2, - "call": { - "LightOperation": { - "base": 21687, - "units_per_gas": 4 + "V1": { + "tx_params": { + "V1": { + "max_inputs": 255, + "max_outputs": 255, + "max_witnesses": 255, + "max_gas_per_tx": 1000000000, + "max_size": 17825792 } }, - "ccp": { - "LightOperation": { - "base": 59, - "units_per_gas": 20 + "predicate_params": { + "V1": { + "max_predicate_length": 1048576, + "max_predicate_data_length": 1048576, + "max_message_data_length": 1048576, + "max_gas_per_predicate": 1000000000 } }, - "croo": { - "LightOperation": { - "base": 1, - "units_per_gas": 1 + "script_params": { + "V1": { + "max_script_length": 1048576, + "max_script_data_length": 1048576 } }, - "csiz": { - "LightOperation": { - "base": 59, - "units_per_gas": 195 + "contract_params": { + "V1": { + "contract_max_size": 16777216, + "max_storage_slots": 131072 } }, - "k256": { - "LightOperation": { - "base": 282, - "units_per_gas": 3 + "fee_params": { + "V1": { + "gas_price_factor": 92, + "gas_per_byte": 63 } }, - "ldc": { - "LightOperation": { - "base": 45, - "units_per_gas": 65 + "chain_id": 0, + "gas_costs": { + "V1": { + "add": 2, + "addi": 2, + "aloc": 1, + "and": 2, + "andi": 2, + "bal": 366, + "bhei": 2, + "bhsh": 2, + "burn": 33949, + "cb": 2, + "cfei": 2, + "cfsi": 2, + "div": 2, + "divi": 2, + "eck1": 3347, + "ecr1": 46165, + "ed19": 4210, + "eq": 2, + "exp": 2, + "expi": 2, + "flag": 1, + "gm": 2, + "gt": 2, + "gtf": 16, + "ji": 2, + "jmp": 2, + "jne": 2, + "jnei": 2, + "jnzi": 2, + "jmpf": 2, + "jmpb": 2, + "jnzf": 2, + "jnzb": 2, + "jnef": 2, + "jneb": 2, + "lb": 2, + "log": 754, + "lt": 2, + "lw": 2, + "mint": 35718, + "mlog": 2, + "mod": 2, + "modi": 2, + "move": 2, + "movi": 2, + "mroo": 5, + "mul": 2, + "muli": 2, + "mldv": 4, + "noop": 1, + "not": 2, + "or": 2, + "ori": 2, + "poph": 3, + "popl": 3, + "pshh": 4, + "pshl": 4, + "ret_contract": 733, + "rvrt_contract": 722, + "sb": 2, + "sll": 2, + "slli": 2, + "srl": 2, + "srli": 2, + "srw": 253, + "sub": 2, + "subi": 2, + "sw": 2, + "sww": 29053, + "time": 79, + "tr": 46242, + "tro": 33251, + "wdcm": 3, + "wqcm": 3, + "wdop": 3, + "wqop": 3, + "wdml": 3, + "wqml": 4, + "wddv": 5, + "wqdv": 7, + "wdmd": 11, + "wqmd": 18, + "wdam": 9, + "wqam": 12, + "wdmm": 11, + "wqmm": 11, + "xor": 2, + "xori": 2, + "call": { + "LightOperation": { + "base": 21687, + "units_per_gas": 4 + } + }, + "ccp": { + "LightOperation": { + "base": 59, + "units_per_gas": 20 + } + }, + "croo": { + "LightOperation": { + "base": 1, + "units_per_gas": 1 + } + }, + "csiz": { + "LightOperation": { + "base": 59, + "units_per_gas": 195 + } + }, + "k256": { + "LightOperation": { + "base": 282, + "units_per_gas": 3 + } + }, + "ldc": { + "LightOperation": { + "base": 45, + "units_per_gas": 65 + } + }, + "logd": { + "LightOperation": { + "base": 1134, + "units_per_gas": 2 + } + }, + "mcl": { + "LightOperation": { + "base": 3, + "units_per_gas": 523 + } + }, + "mcli": { + "LightOperation": { + "base": 3, + "units_per_gas": 526 + } + }, + "mcp": { + "LightOperation": { + "base": 3, + "units_per_gas": 448 + } + }, + "mcpi": { + "LightOperation": { + "base": 7, + "units_per_gas": 585 + } + }, + "meq": { + "LightOperation": { + "base": 11, + "units_per_gas": 1097 + } + }, + "retd_contract": { + "LightOperation": { + "base": 1086, + "units_per_gas": 2 + } + }, + "s256": { + "LightOperation": { + "base": 45, + "units_per_gas": 3 + } + }, + "scwq": { + "HeavyOperation": { + "base": 30375, + "gas_per_unit": 28628 + } + }, + "smo": { + "LightOperation": { + "base": 64196, + "units_per_gas": 1 + } + }, + "srwq": { + "HeavyOperation": { + "base": 262, + "gas_per_unit": 249 + } + }, + "swwq": { + "HeavyOperation": { + "base": 28484, + "gas_per_unit": 26613 + } + }, + "contract_root": { + "LightOperation": { + "base": 45, + "units_per_gas": 1 + } + }, + "state_root": { + "HeavyOperation": { + "base": 350, + "gas_per_unit": 176 + } + }, + "new_storage_per_byte": 63, + "vm_initialization": { + "LightOperation": { + "base": 1645, + "units_per_gas": 14 + } + } } }, - "logd": { - "LightOperation": { - "base": 1134, - "units_per_gas": 2 - } - }, - "mcl": { - "LightOperation": { - "base": 3, - "units_per_gas": 523 - } - }, - "mcli": { - "LightOperation": { - "base": 3, - "units_per_gas": 526 - } - }, - "mcp": { - "LightOperation": { - "base": 3, - "units_per_gas": 448 - } - }, - "mcpi": { - "LightOperation": { - "base": 7, - "units_per_gas": 585 - } - }, - "meq": { - "LightOperation": { - "base": 11, - "units_per_gas": 1097 - } - }, - "retd_contract": { - "LightOperation": { - "base": 1086, - "units_per_gas": 2 - } - }, - "s256": { - "LightOperation": { - "base": 45, - "units_per_gas": 3 - } - }, - "scwq": { - "HeavyOperation": { - "base": 30375, - "gas_per_unit": 28628 - } - }, - "smo": { - "LightOperation": { - "base": 64196, - "units_per_gas": 1 - } - }, - "srwq": { - "HeavyOperation": { - "base": 262, - "gas_per_unit": 249 - } - }, - "swwq": { - "HeavyOperation": { - "base": 28484, - "gas_per_unit": 26613 - } - }, - "contract_root": { - "LightOperation": { - "base": 45, - "units_per_gas": 1 - } - }, - "state_root": { - "HeavyOperation": { - "base": 350, - "gas_per_unit": 176 - } - }, - "new_storage_per_byte": 63, - "vm_initialization": { - "LightOperation": { - "base": 1645, - "units_per_gas": 14 - } - } - }, - "base_asset_id": "0000000000000000000000000000000000000000000000000000000000000000" + "base_asset_id": "0000000000000000000000000000000000000000000000000000000000000000", + "block_gas_limit": 1000000000, + "privileged_address": "0000000000000000000000000000000000000000000000000000000000000000" + } }, "consensus": { "PoA": { diff --git a/bin/e2e-test-client/src/tests/test_data/large_state/tx.json b/bin/e2e-test-client/src/tests/test_data/large_state/tx.json index c87b4400029..e15f1bf5eb5 100644 --- a/bin/e2e-test-client/src/tests/test_data/large_state/tx.json +++ b/bin/e2e-test-client/src/tests/test_data/large_state/tx.json @@ -1,4106 +1,4145 @@ { "Script": { - "script_gas_limit": 1000000, - "script": [ - 144, - 0, - 0, - 4, - 71, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 12, - 212, - 93, - 252, - 192, - 1, - 16, - 255, - 243, - 0, - 26, - 92, - 80, - 0, - 145, - 0, - 5, - 184, - 97, - 68, - 0, - 6, - 114, - 64, - 2, - 208, - 22, - 65, - 20, - 0, - 91, - 64, - 16, - 13, - 54, - 0, - 0, - 0, - 97, - 88, - 0, - 12, - 97, - 68, - 0, - 1, - 80, - 65, - 117, - 48, - 95, - 93, - 16, - 166, - 80, - 65, - 117, - 48, - 93, - 69, - 112, - 166, - 80, - 65, - 113, - 56, - 95, - 93, - 16, - 39, - 80, - 65, - 113, - 56, - 93, - 65, - 112, - 39, - 19, - 65, - 0, - 0, - 115, - 64, - 0, - 26, - 144, - 0, - 0, - 31, - 26, - 68, - 80, - 0, - 145, - 0, - 0, - 8, - 93, - 67, - 240, - 0, - 95, - 69, - 0, - 0, - 144, - 0, - 0, - 43, - 80, - 65, - 113, - 56, - 93, - 65, - 112, - 39, - 19, - 65, - 0, - 64, - 115, - 64, - 0, - 36, - 144, - 0, - 0, - 41, - 26, - 68, - 80, - 0, - 145, - 0, - 0, - 8, - 93, - 67, - 240, - 1, - 95, - 69, - 0, - 0, - 144, - 0, - 0, - 43, - 54, - 0, - 0, - 0, - 26, - 68, - 0, - 0, - 80, - 65, - 117, - 40, - 80, - 65, - 117, - 40, - 96, - 65, - 16, - 8, - 80, - 69, - 117, - 40, - 80, - 65, - 112, - 8, - 80, - 65, - 112, - 8, - 96, - 65, - 16, - 8, - 80, - 65, - 112, - 8, - 93, - 65, - 0, - 0, - 19, - 65, - 0, - 0, - 115, - 64, - 0, - 55, - 144, - 0, - 0, - 57, - 97, - 68, - 0, - 12, - 144, - 0, - 0, - 59, - 54, - 0, - 0, - 0, - 26, - 68, - 0, - 0, - 80, - 65, - 116, - 48, - 95, - 93, - 16, - 134, - 80, - 65, - 116, - 48, - 93, - 69, - 112, - 134, - 93, - 67, - 240, - 2, - 16, - 69, - 4, - 64, - 80, - 65, - 116, - 72, - 95, - 93, - 16, - 137, - 97, - 68, - 0, - 1, - 80, - 65, - 117, - 64, - 95, - 93, - 16, - 168, - 80, - 65, - 117, - 64, - 93, - 69, - 112, - 168, - 80, - 65, - 113, - 64, - 95, - 93, - 16, - 40, - 80, - 65, - 113, - 64, - 93, - 65, - 112, - 40, - 19, - 65, - 0, - 0, - 115, - 64, - 0, - 79, - 144, - 0, - 0, - 84, - 26, - 68, - 80, - 0, - 145, - 0, - 0, - 8, - 93, - 67, - 240, - 0, - 95, - 69, - 0, - 0, - 144, - 0, - 0, - 96, - 80, - 65, - 113, - 64, - 93, - 65, - 112, - 40, - 19, - 65, - 0, - 64, - 115, - 64, - 0, - 89, - 144, - 0, - 0, - 94, - 26, - 68, - 80, - 0, - 145, - 0, - 0, - 8, - 93, - 67, - 240, - 1, - 95, - 69, - 0, - 0, - 144, - 0, - 0, - 96, - 54, - 0, - 0, - 0, - 26, - 68, - 0, - 0, - 80, - 65, - 117, - 56, - 80, - 65, - 117, - 56, - 96, - 65, - 16, - 8, - 80, - 69, - 117, - 56, - 80, - 65, - 112, - 0, - 80, - 65, - 112, - 0, - 96, - 65, - 16, - 8, - 80, - 65, - 112, - 0, - 93, - 65, - 0, - 0, - 19, - 65, - 0, - 0, - 115, - 64, - 0, - 108, - 144, - 0, - 0, - 110, - 97, - 68, - 0, - 6, - 144, - 0, - 0, - 120, - 80, - 65, - 112, - 0, - 93, - 65, - 0, - 0, - 19, - 65, - 0, - 64, - 115, - 64, - 0, - 115, - 144, - 0, - 0, - 118, - 54, - 0, - 0, - 0, - 26, - 68, - 0, - 0, - 144, - 0, - 0, - 120, - 54, - 0, - 0, - 0, - 26, - 68, - 0, - 0, - 93, - 67, - 240, - 2, - 32, - 69, - 20, - 0, - 80, - 65, - 115, - 128, - 95, - 93, - 16, - 112, - 80, - 65, - 116, - 72, - 93, - 73, - 112, - 137, - 80, - 65, - 115, - 128, - 93, - 65, - 112, - 112, - 26, - 68, - 80, - 0, - 145, - 0, - 0, - 16, - 95, - 69, - 32, - 0, - 95, - 69, - 0, - 1, - 80, - 65, - 117, - 168, - 80, - 65, - 117, - 168, - 96, - 65, - 16, - 16, - 93, - 71, - 240, - 3, - 38, - 68, - 0, - 0, - 80, - 68, - 112, - 1, - 80, - 65, - 114, - 96, - 80, - 65, - 114, - 96, - 96, - 65, - 16, - 160, - 38, - 0, - 0, - 0, - 80, - 64, - 112, - 1, - 26, - 68, - 80, - 0, - 145, - 0, - 0, - 16, - 95, - 69, - 0, - 0, - 95, - 68, - 0, - 1, - 80, - 65, - 116, - 120, - 80, - 65, - 116, - 120, - 96, - 65, - 16, - 16, - 80, - 65, - 115, - 80, - 95, - 92, - 0, - 106, - 93, - 71, - 240, - 2, - 93, - 67, - 240, - 4, - 18, - 69, - 20, - 0, - 80, - 65, - 115, - 0, - 95, - 93, - 16, - 96, - 80, - 65, - 115, - 80, - 93, - 69, - 112, - 106, - 80, - 65, - 115, - 0, - 93, - 65, - 112, - 96, - 22, - 65, - 20, - 0, - 115, - 64, - 0, - 164, - 144, - 0, - 0, - 177, - 80, - 73, - 96, - 0, - 80, - 65, - 115, - 80, - 93, - 65, - 112, - 106, - 85, - 69, - 0, - 144, - 16, - 69, - 36, - 64, - 80, - 65, - 112, - 120, - 80, - 65, - 112, - 120, - 96, - 65, - 16, - 144, - 80, - 65, - 112, - 120, - 93, - 65, - 0, - 0, - 19, - 65, - 0, - 64, - 115, - 64, - 1, - 36, - 144, - 0, - 3, - 31, - 80, - 73, - 114, - 96, - 26, - 68, - 80, - 0, - 145, - 0, - 0, - 160, - 80, - 65, - 16, - 0, - 96, - 65, - 32, - 160, - 80, - 65, - 116, - 136, - 80, - 65, - 116, - 136, - 96, - 65, - 16, - 160, - 38, - 0, - 0, - 0, - 80, - 64, - 112, - 1, - 26, - 68, - 80, - 0, - 145, - 0, - 0, - 16, - 95, - 69, - 0, - 0, - 95, - 68, - 0, - 1, - 80, - 65, - 113, - 152, - 80, - 65, - 113, - 152, - 96, - 65, - 16, - 16, - 80, - 81, - 113, - 152, - 80, - 85, - 116, - 136, - 93, - 69, - 64, - 1, - 80, - 65, - 116, - 8, - 95, - 93, - 16, - 129, - 93, - 69, - 64, - 1, - 93, - 67, - 240, - 3, - 16, - 69, - 4, - 64, - 80, - 65, - 115, - 200, - 95, - 93, - 16, - 121, - 93, - 65, - 64, - 0, - 93, - 77, - 64, - 1, - 80, - 69, - 115, - 200, - 93, - 69, - 112, - 121, - 21, - 73, - 20, - 192, - 115, - 72, - 0, - 211, - 144, - 0, - 0, - 225, - 38, - 68, - 0, - 0, - 80, - 72, - 112, - 1, - 80, - 69, - 115, - 168, - 95, - 93, - 32, - 117, - 21, - 69, - 48, - 0, - 115, - 68, - 0, - 218, - 144, - 0, - 0, - 222, - 80, - 69, - 115, - 168, - 93, - 69, - 112, - 117, - 40, - 69, - 4, - 192, - 144, - 0, - 0, - 222, - 80, - 65, - 115, - 168, - 93, - 65, - 112, - 117, - 144, - 0, - 0, - 225, - 95, - 81, - 0, - 0, - 80, - 65, - 115, - 200, - 93, - 65, - 112, - 121, - 95, - 81, - 0, - 1, - 93, - 69, - 64, - 0, - 80, - 65, - 116, - 8, - 93, - 65, - 112, - 129, - 16, - 69, - 4, - 64, - 93, - 67, - 240, - 3, - 40, - 69, - 84, - 0, - 80, - 85, - 113, - 152, - 80, - 81, - 116, - 120, - 93, - 65, - 64, - 1, - 19, - 65, - 0, - 0, - 115, - 64, - 0, - 241, - 144, - 0, - 0, - 243, - 93, - 65, - 80, - 1, - 144, - 0, - 1, - 28, - 93, - 69, - 80, - 1, - 80, - 65, - 116, - 16, - 95, - 93, - 16, - 130, - 93, - 69, - 80, - 1, - 93, - 65, - 64, - 1, - 16, - 69, - 4, - 64, - 80, - 65, - 115, - 208, - 95, - 93, - 16, - 122, - 93, - 65, - 80, - 0, - 93, - 77, - 80, - 1, - 80, - 69, - 115, - 208, - 93, - 69, - 112, - 122, - 21, - 73, - 20, - 192, - 115, - 72, - 1, - 2, - 144, - 0, - 1, - 16, - 38, - 68, - 0, - 0, - 80, - 72, - 112, - 1, - 80, - 69, - 115, - 176, - 95, - 93, - 32, - 118, - 21, - 69, - 48, - 0, - 115, - 68, - 1, - 9, - 144, - 0, - 1, - 13, - 80, - 69, - 115, - 176, - 93, - 69, - 112, - 118, - 40, - 69, - 4, - 192, - 144, - 0, - 1, - 13, - 80, - 65, - 115, - 176, - 93, - 65, - 112, - 118, - 144, - 0, - 1, - 16, - 95, - 85, - 0, - 0, - 80, - 65, - 115, - 208, - 93, - 65, - 112, - 122, - 95, - 85, - 0, - 1, - 93, - 73, - 64, - 0, - 93, - 69, - 80, - 0, - 80, - 65, - 116, - 16, - 93, - 65, - 112, - 130, - 16, - 69, - 4, - 64, - 93, - 65, - 64, - 1, - 40, - 69, - 36, - 0, - 93, - 65, - 112, - 130, - 80, - 65, - 113, - 152, - 93, - 69, - 0, - 0, - 80, - 65, - 113, - 152, - 93, - 65, - 0, - 1, - 37, - 69, - 0, - 0, - 80, - 69, - 116, - 136, - 93, - 67, - 240, - 3, - 37, - 69, - 0, - 0, - 80, - 65, - 112, - 120, - 80, - 69, - 0, - 8, - 80, - 65, - 113, - 168, - 80, - 65, - 113, - 168, - 96, - 65, - 16, - 136, - 80, - 65, - 113, - 168, - 80, - 69, - 0, - 40, - 80, - 65, - 113, - 8, - 80, - 65, - 113, - 8, - 96, - 65, - 16, - 24, - 80, - 65, - 113, - 8, - 93, - 65, - 0, - 0, - 19, - 65, - 0, - 0, - 115, - 64, - 1, - 51, - 144, - 0, - 1, - 63, - 80, - 65, - 113, - 8, - 93, - 69, - 0, - 2, - 80, - 65, - 117, - 72, - 95, - 93, - 16, - 169, - 80, - 65, - 117, - 72, - 93, - 73, - 112, - 169, - 26, - 68, - 80, - 0, - 145, - 0, - 0, - 24, - 93, - 67, - 240, - 0, - 95, - 69, - 0, - 0, - 95, - 69, - 32, - 2, - 144, - 0, - 1, - 123, - 80, - 65, - 113, - 8, - 93, - 65, - 0, - 0, - 19, - 65, - 0, - 64, - 115, - 64, - 1, - 68, - 144, - 0, - 1, - 96, - 80, - 65, - 113, - 8, - 80, - 65, - 0, - 8, - 93, - 69, - 0, - 0, - 80, - 65, - 115, - 232, - 95, - 93, - 16, - 125, - 80, - 65, - 113, - 8, - 80, - 65, - 0, - 8, - 93, - 69, - 0, - 1, - 80, - 65, - 115, - 120, - 95, - 93, - 16, - 111, - 80, - 65, - 117, - 168, - 93, - 69, - 0, - 0, - 80, - 65, - 115, - 232, - 93, - 65, - 112, - 125, - 16, - 69, - 4, - 64, - 80, - 65, - 115, - 120, - 93, - 65, - 112, - 111, - 26, - 72, - 80, - 0, - 145, - 0, - 0, - 16, - 95, - 73, - 16, - 0, - 95, - 73, - 0, - 1, - 26, - 68, - 80, - 0, - 145, - 0, - 0, - 24, - 93, - 67, - 240, - 1, - 95, - 69, - 0, - 0, - 80, - 65, - 16, - 8, - 96, - 65, - 32, - 16, - 144, - 0, - 1, - 123, - 80, - 65, - 113, - 8, - 80, - 65, - 0, - 8, - 93, - 69, - 0, - 0, - 80, - 65, - 115, - 240, - 95, - 93, - 16, - 126, - 80, - 65, - 113, - 8, - 80, - 65, - 0, - 8, - 93, - 69, - 0, - 1, - 80, - 65, - 115, - 144, - 95, - 93, - 16, - 114, - 80, - 65, - 117, - 168, - 93, - 69, - 0, - 0, - 80, - 65, - 115, - 240, - 93, - 65, - 112, - 126, - 16, - 69, - 4, - 64, - 80, - 65, - 115, - 144, - 93, - 65, - 112, - 114, - 26, - 72, - 80, - 0, - 145, - 0, - 0, - 16, - 95, - 73, - 16, - 0, - 95, - 73, - 0, - 1, - 26, - 68, - 80, - 0, - 145, - 0, - 0, - 24, - 93, - 67, - 240, - 1, - 95, - 69, - 0, - 0, - 80, - 65, - 16, - 8, - 96, - 65, - 32, - 16, - 80, - 65, - 115, - 8, - 80, - 65, - 115, - 8, - 96, - 65, - 16, - 24, - 80, - 65, - 113, - 168, - 80, - 85, - 0, - 0, - 80, - 65, - 113, - 168, - 93, - 81, - 0, - 4, - 80, - 69, - 115, - 8, - 80, - 65, - 113, - 168, - 80, - 77, - 0, - 64, - 80, - 65, - 112, - 16, - 80, - 65, - 112, - 16, - 96, - 65, - 16, - 24, - 80, - 65, - 112, - 16, - 93, - 65, - 0, - 0, - 19, - 65, - 0, - 0, - 115, - 64, - 1, - 141, - 144, - 0, - 1, - 148, - 80, - 65, - 112, - 16, - 93, - 69, - 0, - 2, - 80, - 65, - 117, - 80, - 95, - 93, - 16, - 170, - 80, - 65, - 117, - 80, - 93, - 69, - 112, - 170, - 144, - 0, - 1, - 168, - 80, - 65, - 112, - 16, - 93, - 65, - 0, - 0, - 19, - 65, - 0, - 64, - 115, - 64, - 1, - 153, - 144, - 0, - 1, - 161, - 80, - 65, - 112, - 16, - 80, - 65, - 0, - 8, - 93, - 69, - 0, - 0, - 80, - 65, - 116, - 56, - 95, - 93, - 16, - 135, - 80, - 65, - 116, - 56, - 93, - 69, - 112, - 135, - 144, - 0, - 1, - 168, - 80, - 65, - 112, - 16, - 80, - 65, - 0, - 8, - 93, - 69, - 0, - 0, - 80, - 65, - 116, - 80, - 95, - 93, - 16, - 138, - 80, - 65, - 116, - 80, - 93, - 69, - 112, - 138, - 80, - 65, - 115, - 32, - 95, - 93, - 16, - 100, - 80, - 65, - 115, - 32, - 93, - 73, - 112, - 100, - 26, - 68, - 80, - 0, - 145, - 0, - 0, - 48, - 80, - 65, - 16, - 0, - 96, - 65, - 80, - 32, - 95, - 69, - 64, - 4, - 95, - 69, - 32, - 5, - 80, - 65, - 114, - 48, - 80, - 65, - 114, - 48, - 96, - 65, - 16, - 48, - 80, - 69, - 48, - 0, - 80, - 65, - 112, - 40, - 80, - 65, - 112, - 40, - 96, - 65, - 16, - 16, - 80, - 65, - 112, - 40, - 93, - 65, - 0, - 0, - 19, - 65, - 0, - 64, - 115, - 64, - 1, - 190, - 144, - 0, - 1, - 197, - 80, - 65, - 112, - 40, - 93, - 69, - 0, - 1, - 80, - 65, - 113, - 72, - 95, - 93, - 16, - 41, - 80, - 65, - 113, - 72, - 93, - 69, - 112, - 41, - 144, - 0, - 1, - 205, - 80, - 65, - 112, - 40, - 93, - 65, - 0, - 0, - 19, - 65, - 0, - 0, - 115, - 64, - 1, - 202, - 144, - 0, - 1, - 204, - 26, - 68, - 0, - 0, - 144, - 0, - 1, - 205, - 26, - 68, - 0, - 0, - 80, - 65, - 113, - 80, - 95, - 93, - 16, - 42, - 80, - 69, - 48, - 16, - 80, - 65, - 112, - 56, - 80, - 65, - 112, - 56, - 96, - 65, - 16, - 40, - 80, - 65, - 112, - 56, - 93, - 65, - 0, - 0, - 19, - 65, - 0, - 64, - 115, - 64, - 1, - 216, - 144, - 0, - 1, - 223, - 80, - 65, - 112, - 56, - 80, - 69, - 0, - 8, - 80, - 65, - 115, - 88, - 80, - 65, - 115, - 88, - 96, - 65, - 16, - 32, - 80, - 73, - 115, - 88, - 144, - 0, - 1, - 241, - 80, - 65, - 112, - 56, - 93, - 65, - 0, - 0, - 19, - 65, - 0, - 0, - 115, - 64, - 1, - 228, - 144, - 0, - 1, - 235, - 26, - 72, - 80, - 0, - 145, - 0, - 0, - 32, - 93, - 71, - 240, - 10, - 16, - 69, - 19, - 0, - 80, - 65, - 32, - 0, - 96, - 65, - 16, - 32, - 144, - 0, - 1, - 241, - 26, - 72, - 80, - 0, - 145, - 0, - 0, - 32, - 93, - 71, - 240, - 10, - 16, - 69, - 19, - 0, - 80, - 65, - 32, - 0, - 96, - 65, - 16, - 32, - 80, - 65, - 113, - 88, - 80, - 65, - 113, - 88, - 96, - 65, - 32, - 32, - 80, - 69, - 48, - 56, - 80, - 65, - 112, - 96, - 80, - 65, - 112, - 96, - 96, - 65, - 16, - 16, - 80, - 65, - 112, - 96, - 93, - 65, - 0, - 0, - 19, - 65, - 0, - 64, - 115, - 64, - 1, - 253, - 144, - 0, - 2, - 4, - 80, - 65, - 112, - 96, - 93, - 69, - 0, - 1, - 80, - 65, - 115, - 64, - 95, - 93, - 16, - 104, - 80, - 65, - 115, - 64, - 93, - 69, - 112, - 104, - 144, - 0, - 2, - 12, - 80, - 65, - 112, - 96, - 93, - 65, - 0, - 0, - 19, - 65, - 0, - 0, - 115, - 64, - 2, - 9, - 144, - 0, - 2, - 11, - 26, - 68, - 160, - 0, - 144, - 0, - 2, - 12, - 26, - 68, - 160, - 0, - 80, - 65, - 115, - 72, - 95, - 93, - 16, - 105, - 80, - 77, - 114, - 48, - 80, - 65, - 113, - 80, - 93, - 73, - 112, - 42, - 80, - 69, - 113, - 88, - 80, - 65, - 115, - 72, - 93, - 65, - 112, - 105, - 45, - 77, - 36, - 80, - 26, - 68, - 224, - 0, - 80, - 65, - 112, - 112, - 95, - 93, - 16, - 14, - 80, - 65, - 112, - 112, - 93, - 65, - 112, - 14, - 19, - 65, - 0, - 0, - 115, - 64, - 2, - 29, - 144, - 0, - 2, - 40, - 26, - 68, - 208, - 0, - 80, - 65, - 117, - 120, - 95, - 93, - 16, - 175, - 80, - 65, - 117, - 120, - 93, - 69, - 112, - 175, - 26, - 72, - 80, - 0, - 145, - 0, - 0, - 24, - 93, - 67, - 240, - 0, - 95, - 73, - 0, - 0, - 95, - 73, - 16, - 2, - 144, - 0, - 2, - 61, - 80, - 65, - 112, - 112, - 93, - 69, - 112, - 14, - 80, - 65, - 115, - 136, - 95, - 93, - 16, - 113, - 26, - 68, - 208, - 0, - 80, - 65, - 116, - 88, - 95, - 93, - 16, - 139, - 80, - 65, - 116, - 88, - 93, - 73, - 112, - 139, - 80, - 65, - 115, - 136, - 93, - 65, - 112, - 113, - 26, - 68, - 80, - 0, - 145, - 0, - 0, - 16, - 95, - 69, - 32, - 0, - 95, - 69, - 0, - 1, - 26, - 72, - 80, - 0, - 145, - 0, - 0, - 24, - 93, - 67, - 240, - 1, - 95, - 73, - 0, - 0, - 80, - 65, - 32, - 8, - 96, - 65, - 16, - 16, - 80, - 65, - 116, - 96, - 80, - 65, - 116, - 96, - 96, - 65, - 32, - 24, - 80, - 69, - 116, - 96, - 80, - 65, - 113, - 32, - 80, - 65, - 113, - 32, - 96, - 65, - 16, - 24, - 80, - 65, - 113, - 32, - 93, - 65, - 0, - 0, - 19, - 65, - 0, - 0, - 115, - 64, - 2, - 73, - 144, - 0, - 2, - 85, - 80, - 65, - 113, - 32, - 93, - 69, - 0, - 2, - 80, - 65, - 117, - 160, - 95, - 93, - 16, - 180, - 80, - 65, - 117, - 160, - 93, - 73, - 112, - 180, - 26, - 68, - 80, - 0, - 145, - 0, - 0, - 24, - 93, - 67, - 240, - 0, - 95, - 69, - 0, - 0, - 95, - 69, - 32, - 2, - 144, - 0, - 3, - 9, - 80, - 65, - 113, - 32, - 93, - 65, - 0, - 0, - 19, - 65, - 0, - 64, - 115, - 64, - 2, - 90, - 144, - 0, - 2, - 178, - 80, - 65, - 113, - 32, - 80, - 65, - 0, - 8, - 93, - 69, - 0, - 0, - 80, - 65, - 116, - 40, - 95, - 93, - 16, - 133, - 80, - 65, - 113, - 32, - 80, - 65, - 0, - 8, - 93, - 69, - 0, - 1, - 80, - 65, - 115, - 152, - 95, - 93, - 16, - 115, - 80, - 65, - 116, - 40, - 93, - 73, - 112, - 133, - 80, - 65, - 115, - 152, - 93, - 65, - 112, - 115, - 26, - 68, - 80, - 0, - 145, - 0, - 0, - 16, - 95, - 69, - 32, - 0, - 95, - 69, - 0, - 1, - 80, - 65, - 113, - 120, - 80, - 65, - 113, - 120, - 96, - 65, - 16, - 16, - 80, - 85, - 116, - 120, - 80, - 81, - 113, - 120, - 93, - 65, - 64, - 1, - 19, - 65, - 0, - 0, - 115, - 64, - 2, - 117, - 144, - 0, - 2, - 119, - 93, - 69, - 80, - 1, - 144, - 0, - 2, - 161, - 93, - 69, - 80, - 1, - 80, - 65, - 116, - 24, - 95, - 93, - 16, - 131, - 93, - 69, - 80, - 1, - 93, - 65, - 64, - 1, - 16, - 69, - 4, - 64, - 80, - 65, - 115, - 216, - 95, - 93, - 16, - 123, - 93, - 65, - 80, - 0, - 93, - 77, - 80, - 1, - 80, - 69, - 115, - 216, - 93, - 69, - 112, - 123, - 21, - 73, - 20, - 192, - 115, - 72, - 2, - 134, - 144, - 0, - 2, - 148, - 38, - 68, - 0, - 0, - 80, - 72, - 112, - 1, - 80, - 69, - 115, - 184, - 95, - 93, - 32, - 119, - 21, - 69, - 48, - 0, - 115, - 68, - 2, - 141, - 144, - 0, - 2, - 145, - 80, - 69, - 115, - 184, - 93, - 69, - 112, - 119, - 40, - 69, - 4, - 192, - 144, - 0, - 2, - 145, - 80, - 65, - 115, - 184, - 93, - 65, - 112, - 119, - 144, - 0, - 2, - 148, - 95, - 85, - 0, - 0, - 80, - 65, - 115, - 216, - 93, - 65, - 112, - 123, - 95, - 85, - 0, - 1, - 93, - 73, - 64, - 0, - 93, - 69, - 80, - 0, - 80, - 65, - 116, - 24, - 93, - 65, - 112, - 131, - 16, - 69, - 4, - 64, - 93, - 65, - 64, - 1, - 40, - 69, - 36, - 0, - 80, - 65, - 116, - 24, - 93, - 69, - 112, - 131, - 80, - 65, - 115, - 248, - 95, - 93, - 16, - 127, - 80, - 65, - 115, - 248, - 93, - 69, - 112, - 127, - 80, - 65, - 115, - 152, - 93, - 65, - 112, - 115, - 26, - 72, - 80, - 0, - 145, - 0, - 0, - 16, - 95, - 73, - 16, - 0, - 95, - 73, - 0, - 1, - 26, - 68, - 80, - 0, - 145, - 0, - 0, - 24, - 93, - 67, - 240, - 1, - 95, - 69, - 0, - 0, - 80, - 65, - 16, - 8, - 96, - 65, - 32, - 16, - 144, - 0, - 3, - 9, - 80, - 65, - 113, - 32, - 80, - 65, - 0, - 8, - 93, - 69, - 0, - 0, - 80, - 65, - 116, - 64, - 95, - 93, - 16, - 136, - 80, - 65, - 113, - 32, - 80, - 65, - 0, - 8, - 93, - 69, - 0, - 1, - 80, - 65, - 115, - 160, - 95, - 93, - 16, - 116, - 80, - 65, - 116, - 64, - 93, - 73, - 112, - 136, - 80, - 65, - 115, - 160, - 93, - 65, - 112, - 116, - 26, - 68, - 80, - 0, - 145, - 0, - 0, - 16, - 95, - 69, - 32, - 0, - 95, - 69, - 0, - 1, - 80, - 65, - 113, - 136, - 80, - 65, - 113, - 136, - 96, - 65, - 16, - 16, - 80, - 85, - 116, - 120, - 80, - 81, - 113, - 136, - 93, - 65, - 64, - 1, - 19, - 65, - 0, - 0, - 115, - 64, - 2, - 205, - 144, - 0, - 2, - 207, - 93, - 69, - 80, - 1, - 144, - 0, - 2, - 249, - 93, - 69, - 80, - 1, - 80, - 65, - 116, - 32, - 95, - 93, - 16, - 132, - 93, - 69, - 80, - 1, - 93, - 65, - 64, - 1, - 16, - 69, - 4, - 64, - 80, - 65, - 115, - 224, - 95, - 93, - 16, - 124, - 93, - 65, - 80, - 0, - 93, - 77, - 80, - 1, - 80, - 69, - 115, - 224, - 93, - 69, - 112, - 124, - 21, - 73, - 20, - 192, - 115, - 72, - 2, - 222, - 144, - 0, - 2, - 236, - 38, - 68, - 0, - 0, - 80, - 72, - 112, - 1, - 80, - 69, - 115, - 192, - 95, - 93, - 32, - 120, - 21, - 69, - 48, - 0, - 115, - 68, - 2, - 229, - 144, - 0, - 2, - 233, - 80, - 69, - 115, - 192, - 93, - 69, - 112, - 120, - 40, - 69, - 4, - 192, - 144, - 0, - 2, - 233, - 80, - 65, - 115, - 192, - 93, - 65, - 112, - 120, - 144, - 0, - 2, - 236, - 95, - 85, - 0, - 0, - 80, - 65, - 115, - 224, - 93, - 65, - 112, - 124, - 95, - 85, - 0, - 1, - 93, - 73, - 64, - 0, - 93, - 69, - 80, - 0, - 80, - 65, - 116, - 32, - 93, - 65, - 112, - 132, - 16, - 69, - 4, - 64, - 93, - 65, - 64, - 1, - 40, - 69, - 36, - 0, - 80, - 65, - 116, - 32, - 93, - 69, - 112, - 132, - 80, - 65, - 116, - 0, - 95, - 93, - 16, - 128, - 80, - 65, - 116, - 0, - 93, - 69, - 112, - 128, - 80, - 65, - 115, - 160, - 93, - 65, - 112, - 116, - 26, - 72, - 80, - 0, - 145, - 0, - 0, - 16, - 95, - 73, - 16, - 0, - 95, - 73, - 0, - 1, - 26, - 68, - 80, - 0, - 145, - 0, - 0, - 24, - 93, - 67, - 240, - 1, - 95, - 69, - 0, - 0, - 80, - 65, - 16, - 8, - 96, - 65, - 32, - 16, - 80, - 65, - 115, - 40, - 80, - 65, - 115, - 40, - 96, - 65, - 16, - 24, - 80, - 73, - 115, - 40, - 26, - 68, - 80, - 0, - 145, - 0, - 0, - 32, - 93, - 67, - 240, - 1, - 95, - 69, - 0, - 0, - 80, - 65, - 16, - 8, - 96, - 65, - 32, - 24, - 80, - 65, - 117, - 88, - 80, - 65, - 117, - 88, - 96, - 65, - 16, - 32, - 80, - 69, - 114, - 96, - 80, - 65, - 115, - 80, - 93, - 65, - 112, - 106, - 85, - 73, - 0, - 32, - 16, - 73, - 20, - 128, - 80, - 69, - 117, - 88, - 93, - 67, - 240, - 9, - 40, - 73, - 20, - 0, - 144, - 0, - 3, - 46, - 80, - 65, - 117, - 128, - 26, - 68, - 80, - 0, - 145, - 0, - 0, - 32, - 93, - 67, - 240, - 0, - 95, - 69, - 0, - 0, - 80, - 65, - 117, - 128, - 96, - 65, - 16, - 32, - 80, - 69, - 114, - 96, - 80, - 65, - 115, - 80, - 93, - 65, - 112, - 106, - 85, - 73, - 0, - 32, - 16, - 73, - 20, - 128, - 80, - 69, - 117, - 128, - 93, - 67, - 240, - 9, - 40, - 73, - 20, - 0, - 80, - 65, - 115, - 80, - 80, - 65, - 115, - 80, - 93, - 65, - 112, - 106, - 16, - 64, - 20, - 0, - 95, - 93, - 0, - 106, - 144, - 0, - 0, - 157, - 71, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 1, - 0, - 0, - 0, - 0, - 0, - 0, - 2, - 208, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 160, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 144, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 32, - 0, - 0, - 0, - 0, - 0, - 0, - 12, - 252 - ], - "script_data": [ - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 1, - 244, 41, 47, 229, 13, 33, 102, 142, 20, 6, 54, 171, 105, 199, 212, 179, 208, 105, 246, 110, 185, 239, 61, 164, 176, 163, 36, 64, 156, 195, 107, 140, - 0, - 0, - 0, - 0, - 0, - 62, - 190, - 102, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 1, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 32, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 137, - 234, - 194, - 93, - 65, - 44, - 92, - 27, - 99, - 210, - 18, - 222, - 172, - 193, - 9, - 220, - 255, - 128, - 78, - 255, - 112, - 16, - 31, - 224, - 252, - 114, - 22, - 123, - 199, - 136, - 74, - 162 - ], + "body": { + "script_gas_limit": 1000000, + "script": [ + 144, + 0, + 0, + 4, + 71, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 12, + 212, + 93, + 252, + 192, + 1, + 16, + 255, + 243, + 0, + 26, + 92, + 80, + 0, + 145, + 0, + 5, + 184, + 97, + 68, + 0, + 6, + 114, + 64, + 2, + 208, + 22, + 65, + 20, + 0, + 91, + 64, + 16, + 13, + 54, + 0, + 0, + 0, + 97, + 88, + 0, + 12, + 97, + 68, + 0, + 1, + 80, + 65, + 117, + 48, + 95, + 93, + 16, + 166, + 80, + 65, + 117, + 48, + 93, + 69, + 112, + 166, + 80, + 65, + 113, + 56, + 95, + 93, + 16, + 39, + 80, + 65, + 113, + 56, + 93, + 65, + 112, + 39, + 19, + 65, + 0, + 0, + 115, + 64, + 0, + 26, + 144, + 0, + 0, + 31, + 26, + 68, + 80, + 0, + 145, + 0, + 0, + 8, + 93, + 67, + 240, + 0, + 95, + 69, + 0, + 0, + 144, + 0, + 0, + 43, + 80, + 65, + 113, + 56, + 93, + 65, + 112, + 39, + 19, + 65, + 0, + 64, + 115, + 64, + 0, + 36, + 144, + 0, + 0, + 41, + 26, + 68, + 80, + 0, + 145, + 0, + 0, + 8, + 93, + 67, + 240, + 1, + 95, + 69, + 0, + 0, + 144, + 0, + 0, + 43, + 54, + 0, + 0, + 0, + 26, + 68, + 0, + 0, + 80, + 65, + 117, + 40, + 80, + 65, + 117, + 40, + 96, + 65, + 16, + 8, + 80, + 69, + 117, + 40, + 80, + 65, + 112, + 8, + 80, + 65, + 112, + 8, + 96, + 65, + 16, + 8, + 80, + 65, + 112, + 8, + 93, + 65, + 0, + 0, + 19, + 65, + 0, + 0, + 115, + 64, + 0, + 55, + 144, + 0, + 0, + 57, + 97, + 68, + 0, + 12, + 144, + 0, + 0, + 59, + 54, + 0, + 0, + 0, + 26, + 68, + 0, + 0, + 80, + 65, + 116, + 48, + 95, + 93, + 16, + 134, + 80, + 65, + 116, + 48, + 93, + 69, + 112, + 134, + 93, + 67, + 240, + 2, + 16, + 69, + 4, + 64, + 80, + 65, + 116, + 72, + 95, + 93, + 16, + 137, + 97, + 68, + 0, + 1, + 80, + 65, + 117, + 64, + 95, + 93, + 16, + 168, + 80, + 65, + 117, + 64, + 93, + 69, + 112, + 168, + 80, + 65, + 113, + 64, + 95, + 93, + 16, + 40, + 80, + 65, + 113, + 64, + 93, + 65, + 112, + 40, + 19, + 65, + 0, + 0, + 115, + 64, + 0, + 79, + 144, + 0, + 0, + 84, + 26, + 68, + 80, + 0, + 145, + 0, + 0, + 8, + 93, + 67, + 240, + 0, + 95, + 69, + 0, + 0, + 144, + 0, + 0, + 96, + 80, + 65, + 113, + 64, + 93, + 65, + 112, + 40, + 19, + 65, + 0, + 64, + 115, + 64, + 0, + 89, + 144, + 0, + 0, + 94, + 26, + 68, + 80, + 0, + 145, + 0, + 0, + 8, + 93, + 67, + 240, + 1, + 95, + 69, + 0, + 0, + 144, + 0, + 0, + 96, + 54, + 0, + 0, + 0, + 26, + 68, + 0, + 0, + 80, + 65, + 117, + 56, + 80, + 65, + 117, + 56, + 96, + 65, + 16, + 8, + 80, + 69, + 117, + 56, + 80, + 65, + 112, + 0, + 80, + 65, + 112, + 0, + 96, + 65, + 16, + 8, + 80, + 65, + 112, + 0, + 93, + 65, + 0, + 0, + 19, + 65, + 0, + 0, + 115, + 64, + 0, + 108, + 144, + 0, + 0, + 110, + 97, + 68, + 0, + 6, + 144, + 0, + 0, + 120, + 80, + 65, + 112, + 0, + 93, + 65, + 0, + 0, + 19, + 65, + 0, + 64, + 115, + 64, + 0, + 115, + 144, + 0, + 0, + 118, + 54, + 0, + 0, + 0, + 26, + 68, + 0, + 0, + 144, + 0, + 0, + 120, + 54, + 0, + 0, + 0, + 26, + 68, + 0, + 0, + 93, + 67, + 240, + 2, + 32, + 69, + 20, + 0, + 80, + 65, + 115, + 128, + 95, + 93, + 16, + 112, + 80, + 65, + 116, + 72, + 93, + 73, + 112, + 137, + 80, + 65, + 115, + 128, + 93, + 65, + 112, + 112, + 26, + 68, + 80, + 0, + 145, + 0, + 0, + 16, + 95, + 69, + 32, + 0, + 95, + 69, + 0, + 1, + 80, + 65, + 117, + 168, + 80, + 65, + 117, + 168, + 96, + 65, + 16, + 16, + 93, + 71, + 240, + 3, + 38, + 68, + 0, + 0, + 80, + 68, + 112, + 1, + 80, + 65, + 114, + 96, + 80, + 65, + 114, + 96, + 96, + 65, + 16, + 160, + 38, + 0, + 0, + 0, + 80, + 64, + 112, + 1, + 26, + 68, + 80, + 0, + 145, + 0, + 0, + 16, + 95, + 69, + 0, + 0, + 95, + 68, + 0, + 1, + 80, + 65, + 116, + 120, + 80, + 65, + 116, + 120, + 96, + 65, + 16, + 16, + 80, + 65, + 115, + 80, + 95, + 92, + 0, + 106, + 93, + 71, + 240, + 2, + 93, + 67, + 240, + 4, + 18, + 69, + 20, + 0, + 80, + 65, + 115, + 0, + 95, + 93, + 16, + 96, + 80, + 65, + 115, + 80, + 93, + 69, + 112, + 106, + 80, + 65, + 115, + 0, + 93, + 65, + 112, + 96, + 22, + 65, + 20, + 0, + 115, + 64, + 0, + 164, + 144, + 0, + 0, + 177, + 80, + 73, + 96, + 0, + 80, + 65, + 115, + 80, + 93, + 65, + 112, + 106, + 85, + 69, + 0, + 144, + 16, + 69, + 36, + 64, + 80, + 65, + 112, + 120, + 80, + 65, + 112, + 120, + 96, + 65, + 16, + 144, + 80, + 65, + 112, + 120, + 93, + 65, + 0, + 0, + 19, + 65, + 0, + 64, + 115, + 64, + 1, + 36, + 144, + 0, + 3, + 31, + 80, + 73, + 114, + 96, + 26, + 68, + 80, + 0, + 145, + 0, + 0, + 160, + 80, + 65, + 16, + 0, + 96, + 65, + 32, + 160, + 80, + 65, + 116, + 136, + 80, + 65, + 116, + 136, + 96, + 65, + 16, + 160, + 38, + 0, + 0, + 0, + 80, + 64, + 112, + 1, + 26, + 68, + 80, + 0, + 145, + 0, + 0, + 16, + 95, + 69, + 0, + 0, + 95, + 68, + 0, + 1, + 80, + 65, + 113, + 152, + 80, + 65, + 113, + 152, + 96, + 65, + 16, + 16, + 80, + 81, + 113, + 152, + 80, + 85, + 116, + 136, + 93, + 69, + 64, + 1, + 80, + 65, + 116, + 8, + 95, + 93, + 16, + 129, + 93, + 69, + 64, + 1, + 93, + 67, + 240, + 3, + 16, + 69, + 4, + 64, + 80, + 65, + 115, + 200, + 95, + 93, + 16, + 121, + 93, + 65, + 64, + 0, + 93, + 77, + 64, + 1, + 80, + 69, + 115, + 200, + 93, + 69, + 112, + 121, + 21, + 73, + 20, + 192, + 115, + 72, + 0, + 211, + 144, + 0, + 0, + 225, + 38, + 68, + 0, + 0, + 80, + 72, + 112, + 1, + 80, + 69, + 115, + 168, + 95, + 93, + 32, + 117, + 21, + 69, + 48, + 0, + 115, + 68, + 0, + 218, + 144, + 0, + 0, + 222, + 80, + 69, + 115, + 168, + 93, + 69, + 112, + 117, + 40, + 69, + 4, + 192, + 144, + 0, + 0, + 222, + 80, + 65, + 115, + 168, + 93, + 65, + 112, + 117, + 144, + 0, + 0, + 225, + 95, + 81, + 0, + 0, + 80, + 65, + 115, + 200, + 93, + 65, + 112, + 121, + 95, + 81, + 0, + 1, + 93, + 69, + 64, + 0, + 80, + 65, + 116, + 8, + 93, + 65, + 112, + 129, + 16, + 69, + 4, + 64, + 93, + 67, + 240, + 3, + 40, + 69, + 84, + 0, + 80, + 85, + 113, + 152, + 80, + 81, + 116, + 120, + 93, + 65, + 64, + 1, + 19, + 65, + 0, + 0, + 115, + 64, + 0, + 241, + 144, + 0, + 0, + 243, + 93, + 65, + 80, + 1, + 144, + 0, + 1, + 28, + 93, + 69, + 80, + 1, + 80, + 65, + 116, + 16, + 95, + 93, + 16, + 130, + 93, + 69, + 80, + 1, + 93, + 65, + 64, + 1, + 16, + 69, + 4, + 64, + 80, + 65, + 115, + 208, + 95, + 93, + 16, + 122, + 93, + 65, + 80, + 0, + 93, + 77, + 80, + 1, + 80, + 69, + 115, + 208, + 93, + 69, + 112, + 122, + 21, + 73, + 20, + 192, + 115, + 72, + 1, + 2, + 144, + 0, + 1, + 16, + 38, + 68, + 0, + 0, + 80, + 72, + 112, + 1, + 80, + 69, + 115, + 176, + 95, + 93, + 32, + 118, + 21, + 69, + 48, + 0, + 115, + 68, + 1, + 9, + 144, + 0, + 1, + 13, + 80, + 69, + 115, + 176, + 93, + 69, + 112, + 118, + 40, + 69, + 4, + 192, + 144, + 0, + 1, + 13, + 80, + 65, + 115, + 176, + 93, + 65, + 112, + 118, + 144, + 0, + 1, + 16, + 95, + 85, + 0, + 0, + 80, + 65, + 115, + 208, + 93, + 65, + 112, + 122, + 95, + 85, + 0, + 1, + 93, + 73, + 64, + 0, + 93, + 69, + 80, + 0, + 80, + 65, + 116, + 16, + 93, + 65, + 112, + 130, + 16, + 69, + 4, + 64, + 93, + 65, + 64, + 1, + 40, + 69, + 36, + 0, + 93, + 65, + 112, + 130, + 80, + 65, + 113, + 152, + 93, + 69, + 0, + 0, + 80, + 65, + 113, + 152, + 93, + 65, + 0, + 1, + 37, + 69, + 0, + 0, + 80, + 69, + 116, + 136, + 93, + 67, + 240, + 3, + 37, + 69, + 0, + 0, + 80, + 65, + 112, + 120, + 80, + 69, + 0, + 8, + 80, + 65, + 113, + 168, + 80, + 65, + 113, + 168, + 96, + 65, + 16, + 136, + 80, + 65, + 113, + 168, + 80, + 69, + 0, + 40, + 80, + 65, + 113, + 8, + 80, + 65, + 113, + 8, + 96, + 65, + 16, + 24, + 80, + 65, + 113, + 8, + 93, + 65, + 0, + 0, + 19, + 65, + 0, + 0, + 115, + 64, + 1, + 51, + 144, + 0, + 1, + 63, + 80, + 65, + 113, + 8, + 93, + 69, + 0, + 2, + 80, + 65, + 117, + 72, + 95, + 93, + 16, + 169, + 80, + 65, + 117, + 72, + 93, + 73, + 112, + 169, + 26, + 68, + 80, + 0, + 145, + 0, + 0, + 24, + 93, + 67, + 240, + 0, + 95, + 69, + 0, + 0, + 95, + 69, + 32, + 2, + 144, + 0, + 1, + 123, + 80, + 65, + 113, + 8, + 93, + 65, + 0, + 0, + 19, + 65, + 0, + 64, + 115, + 64, + 1, + 68, + 144, + 0, + 1, + 96, + 80, + 65, + 113, + 8, + 80, + 65, + 0, + 8, + 93, + 69, + 0, + 0, + 80, + 65, + 115, + 232, + 95, + 93, + 16, + 125, + 80, + 65, + 113, + 8, + 80, + 65, + 0, + 8, + 93, + 69, + 0, + 1, + 80, + 65, + 115, + 120, + 95, + 93, + 16, + 111, + 80, + 65, + 117, + 168, + 93, + 69, + 0, + 0, + 80, + 65, + 115, + 232, + 93, + 65, + 112, + 125, + 16, + 69, + 4, + 64, + 80, + 65, + 115, + 120, + 93, + 65, + 112, + 111, + 26, + 72, + 80, + 0, + 145, + 0, + 0, + 16, + 95, + 73, + 16, + 0, + 95, + 73, + 0, + 1, + 26, + 68, + 80, + 0, + 145, + 0, + 0, + 24, + 93, + 67, + 240, + 1, + 95, + 69, + 0, + 0, + 80, + 65, + 16, + 8, + 96, + 65, + 32, + 16, + 144, + 0, + 1, + 123, + 80, + 65, + 113, + 8, + 80, + 65, + 0, + 8, + 93, + 69, + 0, + 0, + 80, + 65, + 115, + 240, + 95, + 93, + 16, + 126, + 80, + 65, + 113, + 8, + 80, + 65, + 0, + 8, + 93, + 69, + 0, + 1, + 80, + 65, + 115, + 144, + 95, + 93, + 16, + 114, + 80, + 65, + 117, + 168, + 93, + 69, + 0, + 0, + 80, + 65, + 115, + 240, + 93, + 65, + 112, + 126, + 16, + 69, + 4, + 64, + 80, + 65, + 115, + 144, + 93, + 65, + 112, + 114, + 26, + 72, + 80, + 0, + 145, + 0, + 0, + 16, + 95, + 73, + 16, + 0, + 95, + 73, + 0, + 1, + 26, + 68, + 80, + 0, + 145, + 0, + 0, + 24, + 93, + 67, + 240, + 1, + 95, + 69, + 0, + 0, + 80, + 65, + 16, + 8, + 96, + 65, + 32, + 16, + 80, + 65, + 115, + 8, + 80, + 65, + 115, + 8, + 96, + 65, + 16, + 24, + 80, + 65, + 113, + 168, + 80, + 85, + 0, + 0, + 80, + 65, + 113, + 168, + 93, + 81, + 0, + 4, + 80, + 69, + 115, + 8, + 80, + 65, + 113, + 168, + 80, + 77, + 0, + 64, + 80, + 65, + 112, + 16, + 80, + 65, + 112, + 16, + 96, + 65, + 16, + 24, + 80, + 65, + 112, + 16, + 93, + 65, + 0, + 0, + 19, + 65, + 0, + 0, + 115, + 64, + 1, + 141, + 144, + 0, + 1, + 148, + 80, + 65, + 112, + 16, + 93, + 69, + 0, + 2, + 80, + 65, + 117, + 80, + 95, + 93, + 16, + 170, + 80, + 65, + 117, + 80, + 93, + 69, + 112, + 170, + 144, + 0, + 1, + 168, + 80, + 65, + 112, + 16, + 93, + 65, + 0, + 0, + 19, + 65, + 0, + 64, + 115, + 64, + 1, + 153, + 144, + 0, + 1, + 161, + 80, + 65, + 112, + 16, + 80, + 65, + 0, + 8, + 93, + 69, + 0, + 0, + 80, + 65, + 116, + 56, + 95, + 93, + 16, + 135, + 80, + 65, + 116, + 56, + 93, + 69, + 112, + 135, + 144, + 0, + 1, + 168, + 80, + 65, + 112, + 16, + 80, + 65, + 0, + 8, + 93, + 69, + 0, + 0, + 80, + 65, + 116, + 80, + 95, + 93, + 16, + 138, + 80, + 65, + 116, + 80, + 93, + 69, + 112, + 138, + 80, + 65, + 115, + 32, + 95, + 93, + 16, + 100, + 80, + 65, + 115, + 32, + 93, + 73, + 112, + 100, + 26, + 68, + 80, + 0, + 145, + 0, + 0, + 48, + 80, + 65, + 16, + 0, + 96, + 65, + 80, + 32, + 95, + 69, + 64, + 4, + 95, + 69, + 32, + 5, + 80, + 65, + 114, + 48, + 80, + 65, + 114, + 48, + 96, + 65, + 16, + 48, + 80, + 69, + 48, + 0, + 80, + 65, + 112, + 40, + 80, + 65, + 112, + 40, + 96, + 65, + 16, + 16, + 80, + 65, + 112, + 40, + 93, + 65, + 0, + 0, + 19, + 65, + 0, + 64, + 115, + 64, + 1, + 190, + 144, + 0, + 1, + 197, + 80, + 65, + 112, + 40, + 93, + 69, + 0, + 1, + 80, + 65, + 113, + 72, + 95, + 93, + 16, + 41, + 80, + 65, + 113, + 72, + 93, + 69, + 112, + 41, + 144, + 0, + 1, + 205, + 80, + 65, + 112, + 40, + 93, + 65, + 0, + 0, + 19, + 65, + 0, + 0, + 115, + 64, + 1, + 202, + 144, + 0, + 1, + 204, + 26, + 68, + 0, + 0, + 144, + 0, + 1, + 205, + 26, + 68, + 0, + 0, + 80, + 65, + 113, + 80, + 95, + 93, + 16, + 42, + 80, + 69, + 48, + 16, + 80, + 65, + 112, + 56, + 80, + 65, + 112, + 56, + 96, + 65, + 16, + 40, + 80, + 65, + 112, + 56, + 93, + 65, + 0, + 0, + 19, + 65, + 0, + 64, + 115, + 64, + 1, + 216, + 144, + 0, + 1, + 223, + 80, + 65, + 112, + 56, + 80, + 69, + 0, + 8, + 80, + 65, + 115, + 88, + 80, + 65, + 115, + 88, + 96, + 65, + 16, + 32, + 80, + 73, + 115, + 88, + 144, + 0, + 1, + 241, + 80, + 65, + 112, + 56, + 93, + 65, + 0, + 0, + 19, + 65, + 0, + 0, + 115, + 64, + 1, + 228, + 144, + 0, + 1, + 235, + 26, + 72, + 80, + 0, + 145, + 0, + 0, + 32, + 93, + 71, + 240, + 10, + 16, + 69, + 19, + 0, + 80, + 65, + 32, + 0, + 96, + 65, + 16, + 32, + 144, + 0, + 1, + 241, + 26, + 72, + 80, + 0, + 145, + 0, + 0, + 32, + 93, + 71, + 240, + 10, + 16, + 69, + 19, + 0, + 80, + 65, + 32, + 0, + 96, + 65, + 16, + 32, + 80, + 65, + 113, + 88, + 80, + 65, + 113, + 88, + 96, + 65, + 32, + 32, + 80, + 69, + 48, + 56, + 80, + 65, + 112, + 96, + 80, + 65, + 112, + 96, + 96, + 65, + 16, + 16, + 80, + 65, + 112, + 96, + 93, + 65, + 0, + 0, + 19, + 65, + 0, + 64, + 115, + 64, + 1, + 253, + 144, + 0, + 2, + 4, + 80, + 65, + 112, + 96, + 93, + 69, + 0, + 1, + 80, + 65, + 115, + 64, + 95, + 93, + 16, + 104, + 80, + 65, + 115, + 64, + 93, + 69, + 112, + 104, + 144, + 0, + 2, + 12, + 80, + 65, + 112, + 96, + 93, + 65, + 0, + 0, + 19, + 65, + 0, + 0, + 115, + 64, + 2, + 9, + 144, + 0, + 2, + 11, + 26, + 68, + 160, + 0, + 144, + 0, + 2, + 12, + 26, + 68, + 160, + 0, + 80, + 65, + 115, + 72, + 95, + 93, + 16, + 105, + 80, + 77, + 114, + 48, + 80, + 65, + 113, + 80, + 93, + 73, + 112, + 42, + 80, + 69, + 113, + 88, + 80, + 65, + 115, + 72, + 93, + 65, + 112, + 105, + 45, + 77, + 36, + 80, + 26, + 68, + 224, + 0, + 80, + 65, + 112, + 112, + 95, + 93, + 16, + 14, + 80, + 65, + 112, + 112, + 93, + 65, + 112, + 14, + 19, + 65, + 0, + 0, + 115, + 64, + 2, + 29, + 144, + 0, + 2, + 40, + 26, + 68, + 208, + 0, + 80, + 65, + 117, + 120, + 95, + 93, + 16, + 175, + 80, + 65, + 117, + 120, + 93, + 69, + 112, + 175, + 26, + 72, + 80, + 0, + 145, + 0, + 0, + 24, + 93, + 67, + 240, + 0, + 95, + 73, + 0, + 0, + 95, + 73, + 16, + 2, + 144, + 0, + 2, + 61, + 80, + 65, + 112, + 112, + 93, + 69, + 112, + 14, + 80, + 65, + 115, + 136, + 95, + 93, + 16, + 113, + 26, + 68, + 208, + 0, + 80, + 65, + 116, + 88, + 95, + 93, + 16, + 139, + 80, + 65, + 116, + 88, + 93, + 73, + 112, + 139, + 80, + 65, + 115, + 136, + 93, + 65, + 112, + 113, + 26, + 68, + 80, + 0, + 145, + 0, + 0, + 16, + 95, + 69, + 32, + 0, + 95, + 69, + 0, + 1, + 26, + 72, + 80, + 0, + 145, + 0, + 0, + 24, + 93, + 67, + 240, + 1, + 95, + 73, + 0, + 0, + 80, + 65, + 32, + 8, + 96, + 65, + 16, + 16, + 80, + 65, + 116, + 96, + 80, + 65, + 116, + 96, + 96, + 65, + 32, + 24, + 80, + 69, + 116, + 96, + 80, + 65, + 113, + 32, + 80, + 65, + 113, + 32, + 96, + 65, + 16, + 24, + 80, + 65, + 113, + 32, + 93, + 65, + 0, + 0, + 19, + 65, + 0, + 0, + 115, + 64, + 2, + 73, + 144, + 0, + 2, + 85, + 80, + 65, + 113, + 32, + 93, + 69, + 0, + 2, + 80, + 65, + 117, + 160, + 95, + 93, + 16, + 180, + 80, + 65, + 117, + 160, + 93, + 73, + 112, + 180, + 26, + 68, + 80, + 0, + 145, + 0, + 0, + 24, + 93, + 67, + 240, + 0, + 95, + 69, + 0, + 0, + 95, + 69, + 32, + 2, + 144, + 0, + 3, + 9, + 80, + 65, + 113, + 32, + 93, + 65, + 0, + 0, + 19, + 65, + 0, + 64, + 115, + 64, + 2, + 90, + 144, + 0, + 2, + 178, + 80, + 65, + 113, + 32, + 80, + 65, + 0, + 8, + 93, + 69, + 0, + 0, + 80, + 65, + 116, + 40, + 95, + 93, + 16, + 133, + 80, + 65, + 113, + 32, + 80, + 65, + 0, + 8, + 93, + 69, + 0, + 1, + 80, + 65, + 115, + 152, + 95, + 93, + 16, + 115, + 80, + 65, + 116, + 40, + 93, + 73, + 112, + 133, + 80, + 65, + 115, + 152, + 93, + 65, + 112, + 115, + 26, + 68, + 80, + 0, + 145, + 0, + 0, + 16, + 95, + 69, + 32, + 0, + 95, + 69, + 0, + 1, + 80, + 65, + 113, + 120, + 80, + 65, + 113, + 120, + 96, + 65, + 16, + 16, + 80, + 85, + 116, + 120, + 80, + 81, + 113, + 120, + 93, + 65, + 64, + 1, + 19, + 65, + 0, + 0, + 115, + 64, + 2, + 117, + 144, + 0, + 2, + 119, + 93, + 69, + 80, + 1, + 144, + 0, + 2, + 161, + 93, + 69, + 80, + 1, + 80, + 65, + 116, + 24, + 95, + 93, + 16, + 131, + 93, + 69, + 80, + 1, + 93, + 65, + 64, + 1, + 16, + 69, + 4, + 64, + 80, + 65, + 115, + 216, + 95, + 93, + 16, + 123, + 93, + 65, + 80, + 0, + 93, + 77, + 80, + 1, + 80, + 69, + 115, + 216, + 93, + 69, + 112, + 123, + 21, + 73, + 20, + 192, + 115, + 72, + 2, + 134, + 144, + 0, + 2, + 148, + 38, + 68, + 0, + 0, + 80, + 72, + 112, + 1, + 80, + 69, + 115, + 184, + 95, + 93, + 32, + 119, + 21, + 69, + 48, + 0, + 115, + 68, + 2, + 141, + 144, + 0, + 2, + 145, + 80, + 69, + 115, + 184, + 93, + 69, + 112, + 119, + 40, + 69, + 4, + 192, + 144, + 0, + 2, + 145, + 80, + 65, + 115, + 184, + 93, + 65, + 112, + 119, + 144, + 0, + 2, + 148, + 95, + 85, + 0, + 0, + 80, + 65, + 115, + 216, + 93, + 65, + 112, + 123, + 95, + 85, + 0, + 1, + 93, + 73, + 64, + 0, + 93, + 69, + 80, + 0, + 80, + 65, + 116, + 24, + 93, + 65, + 112, + 131, + 16, + 69, + 4, + 64, + 93, + 65, + 64, + 1, + 40, + 69, + 36, + 0, + 80, + 65, + 116, + 24, + 93, + 69, + 112, + 131, + 80, + 65, + 115, + 248, + 95, + 93, + 16, + 127, + 80, + 65, + 115, + 248, + 93, + 69, + 112, + 127, + 80, + 65, + 115, + 152, + 93, + 65, + 112, + 115, + 26, + 72, + 80, + 0, + 145, + 0, + 0, + 16, + 95, + 73, + 16, + 0, + 95, + 73, + 0, + 1, + 26, + 68, + 80, + 0, + 145, + 0, + 0, + 24, + 93, + 67, + 240, + 1, + 95, + 69, + 0, + 0, + 80, + 65, + 16, + 8, + 96, + 65, + 32, + 16, + 144, + 0, + 3, + 9, + 80, + 65, + 113, + 32, + 80, + 65, + 0, + 8, + 93, + 69, + 0, + 0, + 80, + 65, + 116, + 64, + 95, + 93, + 16, + 136, + 80, + 65, + 113, + 32, + 80, + 65, + 0, + 8, + 93, + 69, + 0, + 1, + 80, + 65, + 115, + 160, + 95, + 93, + 16, + 116, + 80, + 65, + 116, + 64, + 93, + 73, + 112, + 136, + 80, + 65, + 115, + 160, + 93, + 65, + 112, + 116, + 26, + 68, + 80, + 0, + 145, + 0, + 0, + 16, + 95, + 69, + 32, + 0, + 95, + 69, + 0, + 1, + 80, + 65, + 113, + 136, + 80, + 65, + 113, + 136, + 96, + 65, + 16, + 16, + 80, + 85, + 116, + 120, + 80, + 81, + 113, + 136, + 93, + 65, + 64, + 1, + 19, + 65, + 0, + 0, + 115, + 64, + 2, + 205, + 144, + 0, + 2, + 207, + 93, + 69, + 80, + 1, + 144, + 0, + 2, + 249, + 93, + 69, + 80, + 1, + 80, + 65, + 116, + 32, + 95, + 93, + 16, + 132, + 93, + 69, + 80, + 1, + 93, + 65, + 64, + 1, + 16, + 69, + 4, + 64, + 80, + 65, + 115, + 224, + 95, + 93, + 16, + 124, + 93, + 65, + 80, + 0, + 93, + 77, + 80, + 1, + 80, + 69, + 115, + 224, + 93, + 69, + 112, + 124, + 21, + 73, + 20, + 192, + 115, + 72, + 2, + 222, + 144, + 0, + 2, + 236, + 38, + 68, + 0, + 0, + 80, + 72, + 112, + 1, + 80, + 69, + 115, + 192, + 95, + 93, + 32, + 120, + 21, + 69, + 48, + 0, + 115, + 68, + 2, + 229, + 144, + 0, + 2, + 233, + 80, + 69, + 115, + 192, + 93, + 69, + 112, + 120, + 40, + 69, + 4, + 192, + 144, + 0, + 2, + 233, + 80, + 65, + 115, + 192, + 93, + 65, + 112, + 120, + 144, + 0, + 2, + 236, + 95, + 85, + 0, + 0, + 80, + 65, + 115, + 224, + 93, + 65, + 112, + 124, + 95, + 85, + 0, + 1, + 93, + 73, + 64, + 0, + 93, + 69, + 80, + 0, + 80, + 65, + 116, + 32, + 93, + 65, + 112, + 132, + 16, + 69, + 4, + 64, + 93, + 65, + 64, + 1, + 40, + 69, + 36, + 0, + 80, + 65, + 116, + 32, + 93, + 69, + 112, + 132, + 80, + 65, + 116, + 0, + 95, + 93, + 16, + 128, + 80, + 65, + 116, + 0, + 93, + 69, + 112, + 128, + 80, + 65, + 115, + 160, + 93, + 65, + 112, + 116, + 26, + 72, + 80, + 0, + 145, + 0, + 0, + 16, + 95, + 73, + 16, + 0, + 95, + 73, + 0, + 1, + 26, + 68, + 80, + 0, + 145, + 0, + 0, + 24, + 93, + 67, + 240, + 1, + 95, + 69, + 0, + 0, + 80, + 65, + 16, + 8, + 96, + 65, + 32, + 16, + 80, + 65, + 115, + 40, + 80, + 65, + 115, + 40, + 96, + 65, + 16, + 24, + 80, + 73, + 115, + 40, + 26, + 68, + 80, + 0, + 145, + 0, + 0, + 32, + 93, + 67, + 240, + 1, + 95, + 69, + 0, + 0, + 80, + 65, + 16, + 8, + 96, + 65, + 32, + 24, + 80, + 65, + 117, + 88, + 80, + 65, + 117, + 88, + 96, + 65, + 16, + 32, + 80, + 69, + 114, + 96, + 80, + 65, + 115, + 80, + 93, + 65, + 112, + 106, + 85, + 73, + 0, + 32, + 16, + 73, + 20, + 128, + 80, + 69, + 117, + 88, + 93, + 67, + 240, + 9, + 40, + 73, + 20, + 0, + 144, + 0, + 3, + 46, + 80, + 65, + 117, + 128, + 26, + 68, + 80, + 0, + 145, + 0, + 0, + 32, + 93, + 67, + 240, + 0, + 95, + 69, + 0, + 0, + 80, + 65, + 117, + 128, + 96, + 65, + 16, + 32, + 80, + 69, + 114, + 96, + 80, + 65, + 115, + 80, + 93, + 65, + 112, + 106, + 85, + 73, + 0, + 32, + 16, + 73, + 20, + 128, + 80, + 69, + 117, + 128, + 93, + 67, + 240, + 9, + 40, + 73, + 20, + 0, + 80, + 65, + 115, + 80, + 80, + 65, + 115, + 80, + 93, + 65, + 112, + 106, + 16, + 64, + 20, + 0, + 95, + 93, + 0, + 106, + 144, + 0, + 0, + 157, + 71, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 2, + 208, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 160, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 144, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 32, + 0, + 0, + 0, + 0, + 0, + 0, + 12, + 252 + ], + "script_data": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 244, + 41, + 47, + 229, + 13, + 33, + 102, + 142, + 20, + 6, + 54, + 171, + 105, + 199, + 212, + 179, + 208, + 105, + 246, + 110, + 185, + 239, + 61, + 164, + 176, + 163, + 36, + 64, + 156, + 195, + 107, + 140, + 0, + 0, + 0, + 0, + 0, + 62, + 190, + 102, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 32, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 137, + 234, + 194, + 93, + 65, + 44, + 92, + 27, + 99, + 210, + 18, + 222, + 172, + 193, + 9, + 220, + 255, + 128, + 78, + 255, + 112, + 16, + 31, + 224, + 252, + 114, + 22, + 123, + 199, + 136, + 74, + 162 + ], + "receipts_root": "0000000000000000000000000000000000000000000000000000000000000000" + }, "policies": { "bits": "MaxFee", - "values": [0, 0, 0, 100000] + "values": [ + 0, + 0, + 0, + 100000 + ] }, "inputs": [ { @@ -4237,7 +4276,6 @@ 5 ] } - ], - "receipts_root": "0000000000000000000000000000000000000000000000000000000000000000" + ] } } \ No newline at end of file diff --git a/bin/e2e-test-client/src/tests/test_data/non_specific_tx.raw b/bin/e2e-test-client/src/tests/test_data/non_specific_tx.raw index 80c23be64e9..b1ac7f48ed0 100644 --- a/bin/e2e-test-client/src/tests/test_data/non_specific_tx.raw +++ b/bin/e2e-test-client/src/tests/test_data/non_specific_tx.raw @@ -1 +1 @@ -0x00000000000000000000000005f5e1000000000000000004000000000000000000000000000000080000000000000001000000000000000200000000000000010000000000000000000000000000000000000000000000000000000000000000240000000000000000000000000186a000000000000000008b5a47933cbb7ddbc0392a45a124a2a01f17c657d34d4951324003a2f9aff24a000000000000000157cd0f26d30e6e0361742800f0cb39b87d2bd58e052c4389d7e507e39e504a01000000001d34a76e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000eeb709945b9058c3d50f3922bd1b49f92ced2950a9ecaf810aa7829295550cd200000000000027100000000000000000000000000000000000000000000000000000000000000000000000000000000357cd0f26d30e6e0361742800f0cb39b87d2bd58e052c4389d7e507e39e504a01000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 \ No newline at end of file +0x00000000000000000000000005f5e1000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000008000000000000000100000000000000020000000000000001240000000000000000000000000186a000000000000000008b5a47933cbb7ddbc0392a45a124a2a01f17c657d34d4951324003a2f9aff24a000000000000000157cd0f26d30e6e0361742800f0cb39b87d2bd58e052c4389d7e507e39e504a01000000001d34a76e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000eeb709945b9058c3d50f3922bd1b49f92ced2950a9ecaf810aa7829295550cd200000000000027100000000000000000000000000000000000000000000000000000000000000000000000000000000357cd0f26d30e6e0361742800f0cb39b87d2bd58e052c4389d7e507e39e504a01000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 \ No newline at end of file diff --git a/bin/e2e-test-client/tests/integration_tests.rs b/bin/e2e-test-client/tests/integration_tests.rs index d18fa519726..c5e18a3a21b 100644 --- a/bin/e2e-test-client/tests/integration_tests.rs +++ b/bin/e2e-test-client/tests/integration_tests.rs @@ -112,8 +112,8 @@ fn dev_config() -> Config { assert!( chain_config .consensus_parameters - .contract_params - .max_storage_slots + .contract_params() + .max_storage_slots() >= 1 << 17 // 131072 ); diff --git a/bin/fuel-core/Cargo.toml b/bin/fuel-core/Cargo.toml index 93f81e5de7c..ed9f32ebf74 100644 --- a/bin/fuel-core/Cargo.toml +++ b/bin/fuel-core/Cargo.toml @@ -30,6 +30,7 @@ humantime = "2.1" itertools = { workspace = true, optional = true } pyroscope = "0.5" pyroscope_pprofrs = "0.2" +serde_json = { workspace = true } tikv-jemallocator = { workspace = true } tokio = { workspace = true, features = ["macros", "rt-multi-thread"] } tracing = { workspace = true } diff --git a/bin/fuel-core/src/cli.rs b/bin/fuel-core/src/cli.rs index d5e958f5bda..0c4d1aaf074 100644 --- a/bin/fuel-core/src/cli.rs +++ b/bin/fuel-core/src/cli.rs @@ -1,4 +1,5 @@ use clap::Parser; +use fuel_core_chain_config::ChainConfig; use std::{ env, path::PathBuf, @@ -130,6 +131,15 @@ pub async fn run_cli() -> anyhow::Result<()> { } } +/// Returns the chain configuration for the local testnet. +pub fn local_testnet() -> ChainConfig { + const TESTNET_CHAIN_CONFIG: &[u8] = + include_bytes!("../../../deployment/scripts/chainspec/testnet/chain_config.json"); + + let config: ChainConfig = serde_json::from_slice(TESTNET_CHAIN_CONFIG).unwrap(); + config +} + #[cfg(any(feature = "rocksdb", feature = "rocksdb-production"))] #[cfg(test)] mod tests { diff --git a/bin/fuel-core/src/cli/run.rs b/bin/fuel-core/src/cli/run.rs index 6f0e57fc141..cef6a290cc1 100644 --- a/bin/fuel-core/src/cli/run.rs +++ b/bin/fuel-core/src/cli/run.rs @@ -245,7 +245,7 @@ impl Command { let (chain_conf, state_reader) = match snapshot.as_ref() { None => ( - ChainConfig::local_testnet(), + crate::cli::local_testnet(), StateReader::in_memory(StateConfig::local_testnet()), ), Some(path) => { diff --git a/bin/fuel-core/src/cli/run/tx_pool.rs b/bin/fuel-core/src/cli/run/tx_pool.rs index 6ad5faef6f5..a06550bd597 100644 --- a/bin/fuel-core/src/cli/run/tx_pool.rs +++ b/bin/fuel-core/src/cli/run/tx_pool.rs @@ -73,8 +73,8 @@ mod tests { ] => Ok(blacklist(vec![[0; 32].into(), [1; 32].into()], vec![], vec![], vec![])); "addresses works")] #[test_case(&["", "--tx-blacklist-coins=\ - 0x000000000000000000000000000000000000000000000000000000000000000002,\ - 010101010101010101010101010101010101010101010101010101010101010103" + 0x00000000000000000000000000000000000000000000000000000000000000000002,\ + 01010101010101010101010101010101010101010101010101010101010101010003" ] => Ok(blacklist(vec![], vec![UtxoId::new([0; 32].into(), 2), UtxoId::new([1; 32].into(), 3)], vec![], vec![])); "coins works")] #[test_case(&["", "--tx-blacklist-messages=\ diff --git a/bin/fuel-core/src/cli/snapshot.rs b/bin/fuel-core/src/cli/snapshot.rs index 99b4284fc65..5b72fc0c576 100644 --- a/bin/fuel-core/src/cli/snapshot.rs +++ b/bin/fuel-core/src/cli/snapshot.rs @@ -234,7 +234,7 @@ fn load_chain_config( ) -> Result { let chain_config = match chain_config { Some(file) => ChainConfig::load(file)?, - None => ChainConfig::local_testnet(), + None => crate::cli::local_testnet(), }; Ok(chain_config) diff --git a/ci_checks.sh b/ci_checks.sh index 5e042f03cd5..b1545341522 100755 --- a/ci_checks.sh +++ b/ci_checks.sh @@ -1,5 +1,8 @@ #!/usr/bin/env bash +#export FUEL_TRACE=1 +#export RUST_LOG=info + # The script runs almost all CI checks locally. # # Requires installed: diff --git a/crates/chain-config/Cargo.toml b/crates/chain-config/Cargo.toml index dafd40c2d51..2154fbd6ea5 100644 --- a/crates/chain-config/Cargo.toml +++ b/crates/chain-config/Cargo.toml @@ -29,7 +29,7 @@ tracing = { version = "0.1", default-features = false } [dev-dependencies] bytes = { workspace = true } -fuel-core-chain-config = { path = ".", features = ["parquet"] } +fuel-core-chain-config = { path = ".", features = ["parquet", "test-helpers"] } fuel-core-types = { workspace = true, default-features = false, features = [ "random", "serde", @@ -53,3 +53,4 @@ std = [ default = ["std", "random"] parquet = ["std", "dep:parquet", "postcard/use-std"] random = ["dep:rand", "fuel-core-types/random"] +test-helpers = ["fuel-core-types/test-helpers"] diff --git a/crates/chain-config/src/config/chain.rs b/crates/chain-config/src/config/chain.rs index b5212374bcb..2f221680196 100644 --- a/crates/chain-config/src/config/chain.rs +++ b/crates/chain-config/src/config/chain.rs @@ -4,7 +4,6 @@ use fuel_core_types::{ fuel_tx::{ ConsensusParameters, GasCosts, - TxParameters, }, fuel_types::AssetId, }; @@ -39,16 +38,15 @@ pub const CHAIN_CONFIG_FILENAME: &str = "chain_config.json"; #[derive(Clone, Debug, Deserialize, Serialize, Eq, PartialEq)] pub struct ChainConfig { pub chain_name: String, - pub block_gas_limit: u64, pub consensus_parameters: ConsensusParameters, pub consensus: ConsensusConfig, } +#[cfg(feature = "test-helpers")] impl Default for ChainConfig { fn default() -> Self { Self { chain_name: "local".into(), - block_gas_limit: TxParameters::DEFAULT.max_gas_per_tx * 10, /* TODO: Pick a sensible default */ consensus_parameters: ConsensusParameters::default(), consensus: ConsensusConfig::default_poa(), } @@ -89,6 +87,7 @@ impl ChainConfig { Ok(()) } + #[cfg(feature = "test-helpers")] pub fn local_testnet() -> Self { Self { chain_name: LOCAL_TESTNET.to_string(), @@ -104,7 +103,6 @@ impl GenesisCommitment for ChainConfig { // the field. Explicit fields help to prevent a bug of missing fields in the hash. let ChainConfig { chain_name, - block_gas_limit, consensus_parameters, consensus, } = self; @@ -112,7 +110,6 @@ impl GenesisCommitment for ChainConfig { // TODO: Hash settlement configuration when it will be available. let config_hash = *Hasher::default() .chain(chain_name.as_bytes()) - .chain(block_gas_limit.to_be_bytes()) .chain(consensus_parameters.root()?) .chain(consensus.root()?) .finalize(); diff --git a/crates/chain-config/src/config/coin.rs b/crates/chain-config/src/config/coin.rs index cab7ddcddeb..85caf1bbc3e 100644 --- a/crates/chain-config/src/config/coin.rs +++ b/crates/chain-config/src/config/coin.rs @@ -1,7 +1,7 @@ use crate::GenesisCommitment; use fuel_core_storage::MerkleRoot; use fuel_core_types::{ - entities::coins::coin::CompressedCoin, + entities::coins::coin::Coin, fuel_crypto::Hasher, fuel_tx::{ TxPointer, @@ -24,7 +24,7 @@ use serde::{ pub struct CoinConfig { /// auto-generated if None pub tx_id: Bytes32, - pub output_index: u8, + pub output_index: u16, /// used if coin is forked from another chain to preserve id & tx_pointer pub tx_pointer_block_height: BlockHeight, /// used if coin is forked from another chain to preserve id & tx_pointer @@ -95,12 +95,13 @@ impl crate::Randomize for CoinConfig { } } -impl GenesisCommitment for CompressedCoin { +impl GenesisCommitment for Coin { fn root(&self) -> anyhow::Result { - let owner = self.owner(); - let amount = self.amount(); - let asset_id = self.asset_id(); - let tx_pointer = self.tx_pointer(); + let owner = self.owner; + let amount = self.amount; + let asset_id = self.asset_id; + let tx_pointer = self.tx_pointer; + let utxo_id = self.utxo_id; let coin_hash = *Hasher::default() .chain(owner) @@ -108,6 +109,8 @@ impl GenesisCommitment for CompressedCoin { .chain(asset_id) .chain(tx_pointer.block_height().to_be_bytes()) .chain(tx_pointer.tx_index().to_be_bytes()) + .chain(utxo_id.tx_id()) + .chain(utxo_id.output_index().to_be_bytes()) .finalize(); Ok(coin_hash) diff --git a/crates/chain-config/src/config/contract.rs b/crates/chain-config/src/config/contract.rs index 07502dd5359..8936374a611 100644 --- a/crates/chain-config/src/config/contract.rs +++ b/crates/chain-config/src/config/contract.rs @@ -26,7 +26,7 @@ pub struct ContractConfig { #[serde_as(as = "HexIfHumanReadable")] pub code: Vec, pub tx_id: Bytes32, - pub output_index: u8, + pub output_index: u16, /// TxPointer: auto-generated if None /// used if contract is forked from another chain to preserve id & tx_pointer /// The block height that the contract was last used in diff --git a/crates/chain-config/src/config/snapshots/fuel_core_chain_config__config__chain__tests__snapshot_local_testnet_config.snap b/crates/chain-config/src/config/snapshots/fuel_core_chain_config__config__chain__tests__snapshot_local_testnet_config.snap index be3fd997a5a..a7082e20028 100644 --- a/crates/chain-config/src/config/snapshots/fuel_core_chain_config__config__chain__tests__snapshot_local_testnet_config.snap +++ b/crates/chain-config/src/config/snapshots/fuel_core_chain_config__config__chain__tests__snapshot_local_testnet_config.snap @@ -4,252 +4,267 @@ expression: json --- { "chain_name": "local_testnet", - "block_gas_limit": 1000000000, "consensus_parameters": { - "tx_params": { - "max_inputs": 255, - "max_outputs": 255, - "max_witnesses": 255, - "max_gas_per_tx": 100000000, - "max_size": 17825792 - }, - "predicate_params": { - "max_predicate_length": 1048576, - "max_predicate_data_length": 1048576, - "max_message_data_length": 1048576, - "max_gas_per_predicate": 100000000 - }, - "script_params": { - "max_script_length": 1048576, - "max_script_data_length": 1048576 - }, - "contract_params": { - "contract_max_size": 16777216, - "max_storage_slots": 255 - }, - "fee_params": { - "gas_price_factor": 1000000000, - "gas_per_byte": 4 - }, - "chain_id": 0, - "gas_costs": { - "add": 1, - "addi": 1, - "aloc": 1, - "and": 1, - "andi": 1, - "bal": 13, - "bhei": 1, - "bhsh": 1, - "burn": 132, - "cb": 1, - "cfei": 1, - "cfsi": 1, - "div": 1, - "divi": 1, - "eck1": 951, - "ecr1": 3000, - "ed19": 3000, - "eq": 1, - "exp": 1, - "expi": 1, - "flag": 1, - "gm": 1, - "gt": 1, - "gtf": 1, - "ji": 1, - "jmp": 1, - "jne": 1, - "jnei": 1, - "jnzi": 1, - "jmpf": 1, - "jmpb": 1, - "jnzf": 1, - "jnzb": 1, - "jnef": 1, - "jneb": 1, - "lb": 1, - "log": 9, - "lt": 1, - "lw": 1, - "mint": 135, - "mlog": 1, - "mod": 1, - "modi": 1, - "move": 1, - "movi": 1, - "mroo": 2, - "mul": 1, - "muli": 1, - "mldv": 1, - "noop": 1, - "not": 1, - "or": 1, - "ori": 1, - "poph": 2, - "popl": 2, - "pshh": 2, - "pshl": 2, - "ret_contract": 13, - "rvrt_contract": 13, - "sb": 1, - "sll": 1, - "slli": 1, - "srl": 1, - "srli": 1, - "srw": 12, - "sub": 1, - "subi": 1, - "sw": 1, - "sww": 67, - "time": 1, - "tr": 105, - "tro": 60, - "wdcm": 1, - "wqcm": 1, - "wdop": 1, - "wqop": 1, - "wdml": 1, - "wqml": 1, - "wddv": 1, - "wqdv": 2, - "wdmd": 3, - "wqmd": 4, - "wdam": 2, - "wqam": 3, - "wdmm": 3, - "wqmm": 3, - "xor": 1, - "xori": 1, - "call": { - "LightOperation": { - "base": 144, - "units_per_gas": 214 + "V1": { + "tx_params": { + "V1": { + "max_inputs": 255, + "max_outputs": 255, + "max_witnesses": 255, + "max_gas_per_tx": 100000000, + "max_size": 112640 } }, - "ccp": { - "LightOperation": { - "base": 15, - "units_per_gas": 103 + "predicate_params": { + "V1": { + "max_predicate_length": 1048576, + "max_predicate_data_length": 1048576, + "max_message_data_length": 1048576, + "max_gas_per_predicate": 100000000 } }, - "croo": { - "LightOperation": { - "base": 1, - "units_per_gas": 1 + "script_params": { + "V1": { + "max_script_length": 1048576, + "max_script_data_length": 1048576 } }, - "csiz": { - "LightOperation": { - "base": 17, - "units_per_gas": 790 + "contract_params": { + "V1": { + "contract_max_size": 102400, + "max_storage_slots": 255 } }, - "k256": { - "LightOperation": { - "base": 11, - "units_per_gas": 214 + "fee_params": { + "V1": { + "gas_price_factor": 1000000000, + "gas_per_byte": 4 } }, - "ldc": { - "LightOperation": { - "base": 15, - "units_per_gas": 272 + "chain_id": 0, + "gas_costs": { + "V1": { + "add": 1, + "addi": 1, + "aloc": 1, + "and": 1, + "andi": 1, + "bal": 13, + "bhei": 1, + "bhsh": 1, + "burn": 132, + "cb": 1, + "cfei": 1, + "cfsi": 1, + "div": 1, + "divi": 1, + "eck1": 951, + "ecr1": 3000, + "ed19": 3000, + "eq": 1, + "exp": 1, + "expi": 1, + "flag": 1, + "gm": 1, + "gt": 1, + "gtf": 1, + "ji": 1, + "jmp": 1, + "jne": 1, + "jnei": 1, + "jnzi": 1, + "jmpf": 1, + "jmpb": 1, + "jnzf": 1, + "jnzb": 1, + "jnef": 1, + "jneb": 1, + "lb": 1, + "log": 9, + "lt": 1, + "lw": 1, + "mint": 135, + "mlog": 1, + "mod": 1, + "modi": 1, + "move": 1, + "movi": 1, + "mroo": 2, + "mul": 1, + "muli": 1, + "mldv": 1, + "noop": 1, + "not": 1, + "or": 1, + "ori": 1, + "poph": 2, + "popl": 2, + "pshh": 2, + "pshl": 2, + "ret_contract": 13, + "rvrt_contract": 13, + "sb": 1, + "sll": 1, + "slli": 1, + "srl": 1, + "srli": 1, + "srw": 12, + "sub": 1, + "subi": 1, + "sw": 1, + "sww": 67, + "time": 1, + "tr": 105, + "tro": 60, + "wdcm": 1, + "wqcm": 1, + "wdop": 1, + "wqop": 1, + "wdml": 1, + "wqml": 1, + "wddv": 1, + "wqdv": 2, + "wdmd": 3, + "wqmd": 4, + "wdam": 2, + "wqam": 3, + "wdmm": 3, + "wqmm": 3, + "xor": 1, + "xori": 1, + "call": { + "LightOperation": { + "base": 144, + "units_per_gas": 214 + } + }, + "ccp": { + "LightOperation": { + "base": 15, + "units_per_gas": 103 + } + }, + "croo": { + "LightOperation": { + "base": 1, + "units_per_gas": 1 + } + }, + "csiz": { + "LightOperation": { + "base": 17, + "units_per_gas": 790 + } + }, + "k256": { + "LightOperation": { + "base": 11, + "units_per_gas": 214 + } + }, + "ldc": { + "LightOperation": { + "base": 15, + "units_per_gas": 272 + } + }, + "logd": { + "LightOperation": { + "base": 26, + "units_per_gas": 64 + } + }, + "mcl": { + "LightOperation": { + "base": 1, + "units_per_gas": 3333 + } + }, + "mcli": { + "LightOperation": { + "base": 1, + "units_per_gas": 3333 + } + }, + "mcp": { + "LightOperation": { + "base": 1, + "units_per_gas": 2000 + } + }, + "mcpi": { + "LightOperation": { + "base": 3, + "units_per_gas": 2000 + } + }, + "meq": { + "LightOperation": { + "base": 1, + "units_per_gas": 2500 + } + }, + "retd_contract": { + "LightOperation": { + "base": 29, + "units_per_gas": 62 + } + }, + "s256": { + "LightOperation": { + "base": 2, + "units_per_gas": 214 + } + }, + "scwq": { + "LightOperation": { + "base": 13, + "units_per_gas": 5 + } + }, + "smo": { + "LightOperation": { + "base": 209, + "units_per_gas": 55 + } + }, + "srwq": { + "LightOperation": { + "base": 47, + "units_per_gas": 5 + } + }, + "swwq": { + "LightOperation": { + "base": 44, + "units_per_gas": 5 + } + }, + "contract_root": { + "LightOperation": { + "base": 75, + "units_per_gas": 1 + } + }, + "state_root": { + "LightOperation": { + "base": 412, + "units_per_gas": 1 + } + }, + "new_storage_per_byte": 1, + "vm_initialization": { + "HeavyOperation": { + "base": 2000, + "gas_per_unit": 0 + } + } } }, - "logd": { - "LightOperation": { - "base": 26, - "units_per_gas": 64 - } - }, - "mcl": { - "LightOperation": { - "base": 1, - "units_per_gas": 3333 - } - }, - "mcli": { - "LightOperation": { - "base": 1, - "units_per_gas": 3333 - } - }, - "mcp": { - "LightOperation": { - "base": 1, - "units_per_gas": 2000 - } - }, - "mcpi": { - "LightOperation": { - "base": 3, - "units_per_gas": 2000 - } - }, - "meq": { - "LightOperation": { - "base": 1, - "units_per_gas": 2500 - } - }, - "retd_contract": { - "LightOperation": { - "base": 29, - "units_per_gas": 62 - } - }, - "s256": { - "LightOperation": { - "base": 2, - "units_per_gas": 214 - } - }, - "scwq": { - "LightOperation": { - "base": 13, - "units_per_gas": 5 - } - }, - "smo": { - "LightOperation": { - "base": 209, - "units_per_gas": 55 - } - }, - "srwq": { - "LightOperation": { - "base": 47, - "units_per_gas": 5 - } - }, - "swwq": { - "LightOperation": { - "base": 44, - "units_per_gas": 5 - } - }, - "contract_root": { - "LightOperation": { - "base": 75, - "units_per_gas": 1 - } - }, - "state_root": { - "LightOperation": { - "base": 412, - "units_per_gas": 1 - } - }, - "new_storage_per_byte": 1, - "vm_initialization": { - "HeavyOperation": { - "base": 2000, - "gas_per_unit": 0 - } - } - }, - "base_asset_id": "0000000000000000000000000000000000000000000000000000000000000000" + "base_asset_id": "0000000000000000000000000000000000000000000000000000000000000000", + "block_gas_limit": 100000000, + "privileged_address": "0000000000000000000000000000000000000000000000000000000000000000" + } }, "consensus": { "PoA": { diff --git a/crates/chain-config/src/config/state/parquet.rs b/crates/chain-config/src/config/state/parquet.rs index dfd2aa82821..1cf66bcd665 100644 --- a/crates/chain-config/src/config/state/parquet.rs +++ b/crates/chain-config/src/config/state/parquet.rs @@ -137,7 +137,7 @@ mod tests { // then let actually_read = bytes_read.load(std::sync::atomic::Ordering::SeqCst); - assert_eq!(total_size, 121649); - assert_eq!(actually_read, 1086); + assert_eq!(total_size, 123416); + assert_eq!(actually_read, 1094); } } diff --git a/crates/client/assets/schema.sdl b/crates/client/assets/schema.sdl index 7b37606bb27..3c848ae8a0f 100644 --- a/crates/client/assets/schema.sdl +++ b/crates/client/assets/schema.sdl @@ -120,7 +120,7 @@ type Coin { """ TxPointer - the index of the transaction that created this coin """ - txCreatedIdx: U64! + txCreatedIdx: U16! } type CoinConnection { @@ -177,16 +177,21 @@ union CoinType = Coin | MessageCoin union Consensus = Genesis | PoAConsensus type ConsensusParameters { + version: ConsensusParametersVersion! txParams: TxParameters! predicateParams: PredicateParameters! scriptParams: ScriptParameters! contractParams: ContractParameters! feeParams: FeeParameters! baseAssetId: AssetId! + blockGasLimit: U64! chainId: U64! gasCosts: GasCosts! + privilegedAddress: Address! } +union ConsensusParametersVersion = Version + type Contract { id: ContractId! bytecode: HexString! @@ -243,16 +248,19 @@ type ContractCreated { scalar ContractId type ContractOutput { - inputIndex: Int! + inputIndex: U16! balanceRoot: Bytes32! stateRoot: Bytes32! } type ContractParameters { + version: ContractParametersVersion! contractMaxSize: U64! maxStorageSlots: U64! } +union ContractParametersVersion = Version + union DependentCost = LightOperation | HeavyOperation type DryRunFailureStatus { @@ -299,12 +307,16 @@ type FailureStatus { } type FeeParameters { + version: FeeParametersVersion! gasPriceFactor: U64! gasPerByte: U64! } +union FeeParametersVersion = Version + type GasCosts { + version: GasCostsVersion! add: U64! addi: U64! aloc: U64! @@ -417,6 +429,8 @@ type GasCosts { newStoragePerByte: U64! } +union GasCostsVersion = Version + type Genesis { """ The chain configs define what consensus type to use, what settlement layer to use, @@ -527,7 +541,7 @@ type InputMessage { recipient: Address! amount: U64! nonce: Nonce! - witnessIndex: Int! + witnessIndex: U16! predicateGasUsed: U64! data: HexString! predicate: HexString! @@ -762,12 +776,15 @@ type Policies { } type PredicateParameters { + version: PredicateParametersVersion! maxPredicateLength: U64! maxPredicateDataLength: U64! maxGasPerPredicate: U64! maxMessageDataLength: U64! } +union PredicateParametersVersion = Version + type ProgramState { returnType: ReturnType! data: HexString! @@ -905,10 +922,13 @@ enum RunState { scalar Salt type ScriptParameters { + version: ScriptParametersVersion! maxScriptLength: U64! maxScriptDataLength: U64! } +union ScriptParametersVersion = Version + scalar Signature input SpendQueryElementInput { @@ -990,8 +1010,7 @@ type Transaction { status: TransactionStatus script: HexString scriptData: HexString - bytecodeWitnessIndex: Int - bytecodeLength: U64 + bytecodeWitnessIndex: U16 salt: Salt storageSlots: [HexString!] """ @@ -1034,15 +1053,20 @@ scalar TransactionId union TransactionStatus = SubmittedStatus | SuccessStatus | SqueezedOutStatus | FailureStatus type TxParameters { - maxInputs: U8! - maxOutputs: U8! + version: TxParametersVersion! + maxInputs: U16! + maxOutputs: U16! maxWitnesses: U32! maxGasPerTx: U64! maxSize: U64! } +union TxParametersVersion = Version + scalar TxPointer +scalar U16 + scalar U32 scalar U64 @@ -1057,6 +1081,10 @@ type VariableOutput { assetId: AssetId! } +type Version { + value: U8! +} + schema { query: Query mutation: Mutation diff --git a/crates/client/src/client.rs b/crates/client/src/client.rs index 05dd40c43e9..ccdd4cadb73 100644 --- a/crates/client/src/client.rs +++ b/crates/client/src/client.rs @@ -372,7 +372,10 @@ impl FuelClient { pub async fn chain_info(&self) -> io::Result { let query = schema::chain::ChainQuery::build(()); - self.query(query).await.map(|r| r.chain.into()) + self.query(query).await.and_then(|r| { + let result = r.chain.try_into()?; + Ok(result) + }) } /// Default dry run, matching the exact configuration as the node diff --git a/crates/client/src/client/schema/chain.rs b/crates/client/src/client/schema/chain.rs index 7442bb89bc5..b0b5903ffc1 100644 --- a/crates/client/src/client/schema/chain.rs +++ b/crates/client/src/client/schema/chain.rs @@ -1,43 +1,82 @@ use crate::client::schema::{ block::Block, schema, + Address, AssetId, + ConversionError, + U16, U32, U64, U8, }; +#[derive(cynic::QueryFragment, Clone, Debug)] +#[cynic(schema_path = "./assets/schema.sdl")] +pub struct Version { + pub value: U8, +} + #[derive(cynic::QueryFragment, Clone, Debug)] #[cynic(schema_path = "./assets/schema.sdl")] pub struct ConsensusParameters { + pub version: ConsensusParametersVersion, pub tx_params: TxParameters, pub predicate_params: PredicateParameters, pub script_params: ScriptParameters, pub contract_params: ContractParameters, pub fee_params: FeeParameters, pub base_asset_id: AssetId, + pub block_gas_limit: U64, pub chain_id: U64, pub gas_costs: GasCosts, + pub privileged_address: Address, +} + +#[derive(cynic::InlineFragments, Clone, Debug)] +#[cynic(schema_path = "./assets/schema.sdl")] +pub enum ConsensusParametersVersion { + V1(Version), + #[cynic(fallback)] + Unknown, } #[derive(cynic::QueryFragment, Clone, Debug)] #[cynic(schema_path = "./assets/schema.sdl")] pub struct TxParameters { - pub max_inputs: U8, - pub max_outputs: U8, + pub version: TxParametersVersion, + pub max_inputs: U16, + pub max_outputs: U16, pub max_witnesses: U32, pub max_gas_per_tx: U64, pub max_size: U64, } -impl From for fuel_core_types::fuel_tx::TxParameters { - fn from(params: TxParameters) -> Self { - Self { - max_inputs: params.max_inputs.into(), - max_outputs: params.max_outputs.into(), - max_witnesses: params.max_witnesses.into(), - max_gas_per_tx: params.max_gas_per_tx.into(), - max_size: params.max_size.into(), +#[derive(cynic::InlineFragments, Clone, Debug)] +#[cynic(schema_path = "./assets/schema.sdl")] +pub enum TxParametersVersion { + V1(Version), + #[cynic(fallback)] + Unknown, +} + +impl TryFrom for fuel_core_types::fuel_tx::TxParameters { + type Error = ConversionError; + + fn try_from(params: TxParameters) -> Result { + match params.version { + TxParametersVersion::V1(_) => Ok( + fuel_core_types::fuel_tx::consensus_parameters::TxParametersV1 { + max_inputs: params.max_inputs.into(), + max_outputs: params.max_outputs.into(), + max_witnesses: params.max_witnesses.into(), + max_gas_per_tx: params.max_gas_per_tx.into(), + max_size: params.max_size.into(), + } + .into(), + ), + TxParametersVersion::Unknown => { + Err(ConversionError::UnknownVariant("TxParametersVersion")) + } } } } @@ -45,19 +84,38 @@ impl From for fuel_core_types::fuel_tx::TxParameters { #[derive(cynic::QueryFragment, Clone, Debug)] #[cynic(schema_path = "./assets/schema.sdl")] pub struct PredicateParameters { + pub version: PredicateParametersVersion, pub max_predicate_length: U64, pub max_predicate_data_length: U64, pub max_message_data_length: U64, pub max_gas_per_predicate: U64, } -impl From for fuel_core_types::fuel_tx::PredicateParameters { - fn from(params: PredicateParameters) -> Self { - Self { - max_predicate_length: params.max_predicate_length.into(), - max_predicate_data_length: params.max_predicate_data_length.into(), - max_message_data_length: params.max_message_data_length.into(), - max_gas_per_predicate: params.max_gas_per_predicate.into(), +#[derive(cynic::InlineFragments, Clone, Debug)] +#[cynic(schema_path = "./assets/schema.sdl")] +pub enum PredicateParametersVersion { + V1(Version), + #[cynic(fallback)] + Unknown, +} + +impl TryFrom for fuel_core_types::fuel_tx::PredicateParameters { + type Error = ConversionError; + + fn try_from(params: PredicateParameters) -> Result { + match params.version { + PredicateParametersVersion::V1(_) => Ok( + fuel_core_types::fuel_tx::consensus_parameters::PredicateParametersV1 { + max_predicate_length: params.max_predicate_length.into(), + max_predicate_data_length: params.max_predicate_data_length.into(), + max_message_data_length: params.max_message_data_length.into(), + max_gas_per_predicate: params.max_gas_per_predicate.into(), + } + .into(), + ), + PredicateParametersVersion::Unknown => Err(ConversionError::UnknownVariant( + "PredicateParametersVersion", + )), } } } @@ -65,15 +123,34 @@ impl From for fuel_core_types::fuel_tx::PredicateParameters #[derive(cynic::QueryFragment, Clone, Debug)] #[cynic(schema_path = "./assets/schema.sdl")] pub struct ScriptParameters { + pub version: ScriptParametersVersion, pub max_script_length: U64, pub max_script_data_length: U64, } -impl From for fuel_core_types::fuel_tx::ScriptParameters { - fn from(params: ScriptParameters) -> Self { - Self { - max_script_length: params.max_script_length.into(), - max_script_data_length: params.max_script_data_length.into(), +#[derive(cynic::InlineFragments, Clone, Debug)] +#[cynic(schema_path = "./assets/schema.sdl")] +pub enum ScriptParametersVersion { + V1(Version), + #[cynic(fallback)] + Unknown, +} + +impl TryFrom for fuel_core_types::fuel_tx::ScriptParameters { + type Error = ConversionError; + + fn try_from(params: ScriptParameters) -> Result { + match params.version { + ScriptParametersVersion::V1(_) => Ok( + fuel_core_types::fuel_tx::consensus_parameters::ScriptParametersV1 { + max_script_length: params.max_script_length.into(), + max_script_data_length: params.max_script_data_length.into(), + } + .into(), + ), + ScriptParametersVersion::Unknown => { + Err(ConversionError::UnknownVariant("ScriptParametersVersion")) + } } } } @@ -81,15 +158,34 @@ impl From for fuel_core_types::fuel_tx::ScriptParameters { #[derive(cynic::QueryFragment, Clone, Debug)] #[cynic(schema_path = "./assets/schema.sdl")] pub struct ContractParameters { + pub version: ContractParametersVersion, pub contract_max_size: U64, pub max_storage_slots: U64, } -impl From for fuel_core_types::fuel_tx::ContractParameters { - fn from(params: ContractParameters) -> Self { - Self { - contract_max_size: params.contract_max_size.into(), - max_storage_slots: params.max_storage_slots.into(), +#[derive(cynic::InlineFragments, Clone, Debug)] +#[cynic(schema_path = "./assets/schema.sdl")] +pub enum ContractParametersVersion { + V1(Version), + #[cynic(fallback)] + Unknown, +} + +impl TryFrom for fuel_core_types::fuel_tx::ContractParameters { + type Error = ConversionError; + + fn try_from(params: ContractParameters) -> Result { + match params.version { + ContractParametersVersion::V1(_) => Ok( + fuel_core_types::fuel_tx::consensus_parameters::ContractParametersV1 { + contract_max_size: params.contract_max_size.into(), + max_storage_slots: params.max_storage_slots.into(), + } + .into(), + ), + ContractParametersVersion::Unknown => { + Err(ConversionError::UnknownVariant("ContractParametersVersion")) + } } } } @@ -97,155 +193,289 @@ impl From for fuel_core_types::fuel_tx::ContractParameters { #[derive(cynic::QueryFragment, Clone, Debug)] #[cynic(schema_path = "./assets/schema.sdl")] pub struct FeeParameters { + pub version: FeeParametersVersion, pub gas_price_factor: U64, pub gas_per_byte: U64, } -impl From for fuel_core_types::fuel_tx::FeeParameters { - fn from(params: FeeParameters) -> Self { - Self { - gas_price_factor: params.gas_price_factor.into(), - gas_per_byte: params.gas_per_byte.into(), - } - } +#[derive(cynic::InlineFragments, Clone, Debug)] +#[cynic(schema_path = "./assets/schema.sdl")] +pub enum FeeParametersVersion { + V1(Version), + #[cynic(fallback)] + Unknown, } -macro_rules! include_from_impls_and_cynic { - ($(#[$meta:meta])* $vis:vis struct $name:ident { - $($field_vis:vis $field_name:ident: $field_type:ty,)* - }) => { - #[derive(cynic::QueryFragment, Clone, Debug)] - #[cynic(schema_path = "./assets/schema.sdl")] - $vis struct $name { - $($field_vis $field_name: $field_type,)* - } +impl TryFrom for fuel_core_types::fuel_tx::FeeParameters { + type Error = ConversionError; - impl From<$name> for fuel_core_types::fuel_tx::GasCosts { - fn from(value: $name) -> Self { - let values = fuel_core_types::fuel_tx::GasCostsValues { - $($field_name: value.$field_name.into(),)* - }; - Self::new(values) - } + fn try_from(params: FeeParameters) -> Result { + match params.version { + FeeParametersVersion::V1(_) => Ok( + fuel_core_types::fuel_tx::consensus_parameters::FeeParametersV1 { + gas_price_factor: params.gas_price_factor.into(), + gas_per_byte: params.gas_per_byte.into(), + } + .into(), + ), + FeeParametersVersion::Unknown => { + Err(ConversionError::UnknownVariant("FeeParametersVersion")) + } } } } -include_from_impls_and_cynic! { - pub struct GasCosts { - pub add: U64, - pub addi: U64, - pub aloc: U64, - pub and: U64, - pub andi: U64, - pub bal: U64, - pub bhei: U64, - pub bhsh: U64, - pub burn: U64, - pub cb: U64, - pub cfei: U64, - pub cfsi: U64, - pub div: U64, - pub divi: U64, - pub eck1: U64, - pub ecr1: U64, - pub ed19: U64, - pub eq: U64, - pub exp: U64, - pub expi: U64, - pub flag: U64, - pub gm: U64, - pub gt: U64, - pub gtf: U64, - pub ji: U64, - pub jmp: U64, - pub jne: U64, - pub jnei: U64, - pub jnzi: U64, - pub jmpf: U64, - pub jmpb: U64, - pub jnzf: U64, - pub jnzb: U64, - pub jnef: U64, - pub jneb: U64, - pub lb: U64, - pub log: U64, - pub lt: U64, - pub lw: U64, - pub mint: U64, - pub mlog: U64, - pub mod_op: U64, - pub modi: U64, - pub move_op: U64, - pub movi: U64, - pub mroo: U64, - pub mul: U64, - pub muli: U64, - pub mldv: U64, - pub noop: U64, - pub not: U64, - pub or: U64, - pub ori: U64, - pub poph: U64, - pub popl: U64, - pub pshh: U64, - pub pshl: U64, - pub ret: U64, - pub rvrt: U64, - pub sb: U64, - pub sll: U64, - pub slli: U64, - pub srl: U64, - pub srli: U64, - pub srw: U64, - pub sub: U64, - pub subi: U64, - pub sw: U64, - pub sww: U64, - pub time: U64, - pub tr: U64, - pub tro: U64, - pub wdcm: U64, - pub wqcm: U64, - pub wdop: U64, - pub wqop: U64, - pub wdml: U64, - pub wqml: U64, - pub wddv: U64, - pub wqdv: U64, - pub wdmd: U64, - pub wqmd: U64, - pub wdam: U64, - pub wqam: U64, - pub wdmm: U64, - pub wqmm: U64, - pub xor: U64, - pub xori: U64, - - pub call: DependentCost, - pub ccp: DependentCost, - pub croo: DependentCost, - pub csiz: DependentCost, - pub k256: DependentCost, - pub ldc: DependentCost, - pub logd: DependentCost, - pub mcl: DependentCost, - pub mcli: DependentCost, - pub mcp: DependentCost, - pub mcpi: DependentCost, - pub meq: DependentCost, - pub retd: DependentCost, - pub s256: DependentCost, - pub scwq: DependentCost, - pub smo: DependentCost, - pub srwq: DependentCost, - pub swwq: DependentCost, - - // Non-opcodes prices - pub contract_root: DependentCost, - pub state_root: DependentCost, - pub vm_initialization: DependentCost, - pub new_storage_per_byte: U64, +#[derive(cynic::QueryFragment, Clone, Debug)] +#[cynic(schema_path = "./assets/schema.sdl")] +pub struct GasCosts { + pub version: GasCostsVersion, + pub add: U64, + pub addi: U64, + pub aloc: U64, + pub and: U64, + pub andi: U64, + pub bal: U64, + pub bhei: U64, + pub bhsh: U64, + pub burn: U64, + pub cb: U64, + pub cfei: U64, + pub cfsi: U64, + pub div: U64, + pub divi: U64, + pub eck1: U64, + pub ecr1: U64, + pub ed19: U64, + pub eq: U64, + pub exp: U64, + pub expi: U64, + pub flag: U64, + pub gm: U64, + pub gt: U64, + pub gtf: U64, + pub ji: U64, + pub jmp: U64, + pub jne: U64, + pub jnei: U64, + pub jnzi: U64, + pub jmpf: U64, + pub jmpb: U64, + pub jnzf: U64, + pub jnzb: U64, + pub jnef: U64, + pub jneb: U64, + pub lb: U64, + pub log: U64, + pub lt: U64, + pub lw: U64, + pub mint: U64, + pub mlog: U64, + pub mod_op: U64, + pub modi: U64, + pub move_op: U64, + pub movi: U64, + pub mroo: U64, + pub mul: U64, + pub muli: U64, + pub mldv: U64, + pub noop: U64, + pub not: U64, + pub or: U64, + pub ori: U64, + pub poph: U64, + pub popl: U64, + pub pshh: U64, + pub pshl: U64, + pub ret: U64, + pub rvrt: U64, + pub sb: U64, + pub sll: U64, + pub slli: U64, + pub srl: U64, + pub srli: U64, + pub srw: U64, + pub sub: U64, + pub subi: U64, + pub sw: U64, + pub sww: U64, + pub time: U64, + pub tr: U64, + pub tro: U64, + pub wdcm: U64, + pub wqcm: U64, + pub wdop: U64, + pub wqop: U64, + pub wdml: U64, + pub wqml: U64, + pub wddv: U64, + pub wqdv: U64, + pub wdmd: U64, + pub wqmd: U64, + pub wdam: U64, + pub wqam: U64, + pub wdmm: U64, + pub wqmm: U64, + pub xor: U64, + pub xori: U64, + + pub call: DependentCost, + pub ccp: DependentCost, + pub croo: DependentCost, + pub csiz: DependentCost, + pub k256: DependentCost, + pub ldc: DependentCost, + pub logd: DependentCost, + pub mcl: DependentCost, + pub mcli: DependentCost, + pub mcp: DependentCost, + pub mcpi: DependentCost, + pub meq: DependentCost, + pub retd: DependentCost, + pub s256: DependentCost, + pub scwq: DependentCost, + pub smo: DependentCost, + pub srwq: DependentCost, + pub swwq: DependentCost, + + // Non-opcodes prices + pub contract_root: DependentCost, + pub state_root: DependentCost, + pub vm_initialization: DependentCost, + pub new_storage_per_byte: U64, +} + +#[derive(cynic::InlineFragments, Clone, Debug)] +#[cynic(schema_path = "./assets/schema.sdl")] +pub enum GasCostsVersion { + V1(Version), + #[cynic(fallback)] + Unknown, +} + +impl TryFrom for fuel_core_types::fuel_tx::GasCosts { + type Error = ConversionError; + + fn try_from(value: GasCosts) -> Result { + match value.version { + GasCostsVersion::V1(_) => { + let values = fuel_core_types::fuel_tx::consensus_parameters::gas::GasCostsValuesV1 { + add: value.add.into(), + addi: value.addi.into(), + aloc: value.aloc.into(), + and: value.and.into(), + andi: value.andi.into(), + bal: value.bal.into(), + bhei: value.bhei.into(), + bhsh: value.bhsh.into(), + burn: value.burn.into(), + cb: value.cb.into(), + cfei: value.cfei.into(), + cfsi: value.cfsi.into(), + div: value.div.into(), + divi: value.divi.into(), + eck1: value.eck1.into(), + ecr1: value.ecr1.into(), + ed19: value.ed19.into(), + eq: value.eq.into(), + exp: value.exp.into(), + expi: value.expi.into(), + flag: value.flag.into(), + gm: value.gm.into(), + gt: value.gt.into(), + gtf: value.gtf.into(), + ji: value.ji.into(), + jmp: value.jmp.into(), + jne: value.jne.into(), + jnei: value.jnei.into(), + jnzi: value.jnzi.into(), + jmpf: value.jmpf.into(), + jmpb: value.jmpb.into(), + jnzf: value.jnzf.into(), + jnzb: value.jnzb.into(), + jnef: value.jnef.into(), + jneb: value.jneb.into(), + lb: value.lb.into(), + log: value.log.into(), + lt: value.lt.into(), + lw: value.lw.into(), + mint: value.mint.into(), + mlog: value.mlog.into(), + mod_op: value.mod_op.into(), + modi: value.modi.into(), + move_op: value.move_op.into(), + movi: value.movi.into(), + mroo: value.mroo.into(), + mul: value.mul.into(), + muli: value.muli.into(), + mldv: value.mldv.into(), + noop: value.noop.into(), + not: value.not.into(), + or: value.or.into(), + ori: value.ori.into(), + poph: value.poph.into(), + popl: value.popl.into(), + pshh: value.pshh.into(), + pshl: value.pshl.into(), + ret: value.ret.into(), + rvrt: value.rvrt.into(), + sb: value.sb.into(), + sll: value.sll.into(), + slli: value.slli.into(), + srl: value.srl.into(), + srli: value.srli.into(), + srw: value.srw.into(), + sub: value.sub.into(), + subi: value.subi.into(), + sw: value.sw.into(), + sww: value.sww.into(), + time: value.time.into(), + tr: value.tr.into(), + tro: value.tro.into(), + wdcm: value.wdcm.into(), + wqcm: value.wqcm.into(), + wdop: value.wdop.into(), + wqop: value.wqop.into(), + wdml: value.wdml.into(), + wqml: value.wqml.into(), + wddv: value.wddv.into(), + wqdv: value.wqdv.into(), + wdmd: value.wdmd.into(), + wqmd: value.wqmd.into(), + wdam: value.wdam.into(), + wqam: value.wqam.into(), + wdmm: value.wdmm.into(), + wqmm: value.wqmm.into(), + xor: value.xor.into(), + xori: value.xori.into(), + call: value.call.into(), + ccp: value.ccp.into(), + croo: value.croo.into(), + csiz: value.csiz.into(), + k256: value.k256.into(), + ldc: value.ldc.into(), + logd: value.logd.into(), + mcl: value.mcl.into(), + mcli: value.mcli.into(), + mcp: value.mcp.into(), + mcpi: value.mcpi.into(), + meq: value.meq.into(), + retd: value.retd.into(), + s256: value.s256.into(), + scwq: value.scwq.into(), + smo: value.smo.into(), + srwq: value.srwq.into(), + swwq: value.swwq.into(), + contract_root: value.contract_root.into(), + state_root: value.state_root.into(), + vm_initialization: value.vm_initialization.into(), + new_storage_per_byte: value.new_storage_per_byte.into(), + }; + Ok(fuel_core_types::fuel_tx::GasCosts::new(values.into())) + } + GasCostsVersion::Unknown => { + Err(ConversionError::UnknownVariant("GasCostsVersion")) + } + } } } @@ -272,41 +502,29 @@ pub enum DependentCost { Unknown, } -impl From for fuel_core_types::fuel_tx::DependentCost { - fn from(value: DependentCost) -> Self { - match value { - DependentCost::LightOperation(LightOperation { - base, - units_per_gas, - }) => fuel_core_types::fuel_tx::DependentCost::LightOperation { - base: base.into(), - units_per_gas: units_per_gas.into(), - }, - DependentCost::HeavyOperation(HeavyOperation { base, gas_per_unit }) => { - fuel_core_types::fuel_tx::DependentCost::HeavyOperation { - base: base.into(), - gas_per_unit: gas_per_unit.into(), - } - } - _ => fuel_core_types::fuel_tx::DependentCost::HeavyOperation { - base: 0u64, - gas_per_unit: 0u64, - }, - } - } -} +impl TryFrom for fuel_core_types::fuel_tx::ConsensusParameters { + type Error = ConversionError; -impl From for fuel_core_types::fuel_tx::ConsensusParameters { - fn from(params: ConsensusParameters) -> Self { - Self { - tx_params: params.tx_params.into(), - predicate_params: params.predicate_params.into(), - script_params: params.script_params.into(), - contract_params: params.contract_params.into(), - fee_params: params.fee_params.into(), - base_asset_id: params.base_asset_id.into(), - chain_id: params.chain_id.0.into(), - gas_costs: params.gas_costs.into(), + fn try_from(params: ConsensusParameters) -> Result { + match params.version { + ConsensusParametersVersion::V1(_) => Ok( + fuel_core_types::fuel_tx::consensus_parameters::ConsensusParametersV1 { + tx_params: params.tx_params.try_into()?, + predicate_params: params.predicate_params.try_into()?, + script_params: params.script_params.try_into()?, + contract_params: params.contract_params.try_into()?, + fee_params: params.fee_params.try_into()?, + base_asset_id: params.base_asset_id.into(), + block_gas_limit: params.block_gas_limit.into(), + chain_id: params.chain_id.0.into(), + gas_costs: params.gas_costs.try_into()?, + privileged_address: params.privileged_address.into(), + } + .into(), + ), + ConsensusParametersVersion::Unknown => Err(ConversionError::UnknownVariant( + "ConsensusParametersVersion", + )), } } } diff --git a/crates/client/src/client/schema/coins.rs b/crates/client/src/client/schema/coins.rs index 555ade72f98..c8ff7cb238e 100644 --- a/crates/client/src/client/schema/coins.rs +++ b/crates/client/src/client/schema/coins.rs @@ -6,6 +6,7 @@ use crate::client::{ Nonce, PageInfo, UtxoId, + U16, U32, U64, }, @@ -110,6 +111,7 @@ pub struct CoinEdge { pub struct Coin { pub amount: U64, pub block_created: U32, + pub tx_created_idx: U16, pub asset_id: AssetId, pub utxo_id: UtxoId, pub owner: Address, diff --git a/crates/client/src/client/schema/primitives.rs b/crates/client/src/client/schema/primitives.rs index 63fdb9df5fe..db41e3ff0ba 100644 --- a/crates/client/src/client/schema/primitives.rs +++ b/crates/client/src/client/schema/primitives.rs @@ -272,6 +272,7 @@ macro_rules! number_scalar { number_scalar!(U64, u64); number_scalar!(U32, u32); +number_scalar!(U16, u16); number_scalar!(U8, u8); impl TryFrom for PanicInstruction { diff --git a/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__chain__tests__chain_gql_query_output.snap b/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__chain__tests__chain_gql_query_output.snap index 74f755e8e58..6e73075608d 100644 --- a/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__chain__tests__chain_gql_query_output.snap +++ b/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__chain__tests__chain_gql_query_output.snap @@ -40,7 +40,19 @@ query { } } consensusParameters { + version { + __typename + ... on Version { + value + } + } txParams { + version { + __typename + ... on Version { + value + } + } maxInputs maxOutputs maxWitnesses @@ -48,26 +60,57 @@ query { maxSize } predicateParams { + version { + __typename + ... on Version { + value + } + } maxPredicateLength maxPredicateDataLength maxMessageDataLength maxGasPerPredicate } scriptParams { + version { + __typename + ... on Version { + value + } + } maxScriptLength maxScriptDataLength } contractParams { + version { + __typename + ... on Version { + value + } + } contractMaxSize maxStorageSlots } feeParams { + version { + __typename + ... on Version { + value + } + } gasPriceFactor gasPerByte } baseAssetId + blockGasLimit chainId gasCosts { + version { + __typename + ... on Version { + value + } + } add addi aloc @@ -389,6 +432,7 @@ query { } newStoragePerByte } + privilegedAddress } } } diff --git a/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__coins__tests__coin_by_id_query_gql_output.snap b/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__coins__tests__coin_by_id_query_gql_output.snap index 2aeac0a537a..ab8c41dfc93 100644 --- a/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__coins__tests__coin_by_id_query_gql_output.snap +++ b/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__coins__tests__coin_by_id_query_gql_output.snap @@ -6,6 +6,7 @@ query($utxoId: UtxoId!) { coin(utxoId: $utxoId) { amount blockCreated + txCreatedIdx assetId utxoId owner diff --git a/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__coins__tests__coins_connection_query_gql_output.snap b/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__coins__tests__coins_connection_query_gql_output.snap index 1c4baf4c3f8..a1ed7145a55 100644 --- a/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__coins__tests__coins_connection_query_gql_output.snap +++ b/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__coins__tests__coins_connection_query_gql_output.snap @@ -9,6 +9,7 @@ query($filter: CoinFilterInput!, $after: String, $before: String, $first: Int, $ node { amount blockCreated + txCreatedIdx assetId utxoId owner diff --git a/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__tx__tests__transparent_transaction_by_id_query_gql_output.snap b/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__tx__tests__transparent_transaction_by_id_query_gql_output.snap index 74a9933284a..f2941ee72fc 100644 --- a/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__tx__tests__transparent_transaction_by_id_query_gql_output.snap +++ b/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__tx__tests__transparent_transaction_by_id_query_gql_output.snap @@ -191,6 +191,5 @@ query($id: TransactionId!) { salt storageSlots bytecodeWitnessIndex - bytecodeLength } } diff --git a/crates/client/src/client/schema/tx/transparent_tx.rs b/crates/client/src/client/schema/tx/transparent_tx.rs index 4dd647d2d8b..d7288883a09 100644 --- a/crates/client/src/client/schema/tx/transparent_tx.rs +++ b/crates/client/src/client/schema/tx/transparent_tx.rs @@ -17,6 +17,7 @@ use crate::client::schema::{ TransactionId, TxPointer, UtxoId, + U16, U32, U64, }; @@ -142,12 +143,7 @@ pub struct Transaction { /// The field of the `Transaction::Create`. pub storage_slots: Option>, /// The field of the `Transaction::Create`. - pub bytecode_witness_index: Option, - /// The size of the bytecode of the `Transaction::Create`. - /// - /// The result of a `bytecode_length()` helper function is stored here. - /// It is not an original field of the `Transaction`. - pub bytecode_length: Option, + pub bytecode_witness_index: Option, } impl TryFrom for fuel_tx::Transaction { @@ -204,7 +200,7 @@ impl TryFrom for fuel_tx::Transaction { "bytecode_witness_index".to_string(), ) })? - .try_into()?, + .into(), tx.policies .ok_or_else(|| ConversionError::MissingField("policies".to_string()))? .into(), @@ -340,7 +336,7 @@ pub struct InputMessage { recipient: Address, amount: U64, nonce: Nonce, - witness_index: i32, + witness_index: U16, predicate_gas_used: U64, data: HexString, predicate: HexString, @@ -386,7 +382,7 @@ impl TryFrom for fuel_tx::Input { message.recipient.into(), message.amount.into(), message.nonce.into(), - message.witness_index.try_into()?, + message.witness_index.into(), ), (true, false) => Self::message_coin_predicate( message.sender.into(), @@ -402,7 +398,7 @@ impl TryFrom for fuel_tx::Input { message.recipient.into(), message.amount.into(), message.nonce.into(), - message.witness_index.try_into()?, + message.witness_index.into(), message.data.into(), ), (false, false) => Self::message_data_predicate( @@ -461,7 +457,7 @@ pub struct VariableOutput { #[derive(cynic::QueryFragment, Clone, Debug)] #[cynic(schema_path = "./assets/schema.sdl")] pub struct ContractOutput { - pub input_index: i32, + pub input_index: U16, pub balance_root: Bytes32, pub state_root: Bytes32, } @@ -520,7 +516,7 @@ impl TryFrom for output::contract::Contract { fn try_from(contract: ContractOutput) -> Result { Ok(output::contract::Contract { - input_index: contract.input_index.try_into()?, + input_index: contract.input_index.into(), balance_root: contract.balance_root.into(), state_root: contract.state_root.into(), }) diff --git a/crates/client/src/client/types/chain_info.rs b/crates/client/src/client/types/chain_info.rs index f5f7aff992e..c39c2852bc6 100644 --- a/crates/client/src/client/types/chain_info.rs +++ b/crates/client/src/client/types/chain_info.rs @@ -1,5 +1,6 @@ use crate::client::{ schema, + schema::ConversionError, types::Block, }; use fuel_core_types::{ @@ -17,13 +18,15 @@ pub struct ChainInfo { // GraphQL Translation -impl From for ChainInfo { - fn from(value: schema::chain::ChainInfo) -> Self { - Self { +impl TryFrom for ChainInfo { + type Error = ConversionError; + + fn try_from(value: schema::chain::ChainInfo) -> Result { + Ok(Self { da_height: value.da_height.into(), name: value.name, latest_block: value.latest_block.into(), - consensus_parameters: value.consensus_parameters.into(), - } + consensus_parameters: value.consensus_parameters.try_into()?, + }) } } diff --git a/crates/client/src/client/types/coins.rs b/crates/client/src/client/types/coins.rs index aa5c5080fbb..6f6986e264b 100644 --- a/crates/client/src/client/types/coins.rs +++ b/crates/client/src/client/types/coins.rs @@ -30,6 +30,7 @@ impl CoinType { pub struct Coin { pub amount: u64, pub block_created: u32, + pub tx_created_idx: u16, pub asset_id: AssetId, pub utxo_id: UtxoId, pub owner: Address, @@ -63,6 +64,7 @@ impl From for Coin { Self { amount: value.amount.into(), block_created: value.block_created.into(), + tx_created_idx: value.tx_created_idx.into(), asset_id: value.asset_id.into(), utxo_id: value.utxo_id.into(), owner: value.owner.into(), diff --git a/crates/client/src/client/types/gas_costs.rs b/crates/client/src/client/types/gas_costs.rs index c57ed9f0afa..f6427556671 100644 --- a/crates/client/src/client/types/gas_costs.rs +++ b/crates/client/src/client/types/gas_costs.rs @@ -1,150 +1,459 @@ use crate::client::schema; +use fuel_core_types::fuel_tx::Word; -macro_rules! include_from_impls { - ($(#[$meta:meta])* $vis:vis struct $name:ident { - $($field_vis:vis $field_name:ident: $field_type:ty,)* - }) => { - $(#[$meta])* - $vis struct $name { - $($field_vis $field_name: $field_type,)* - } +#[derive(Clone, Debug)] +pub struct GasCosts(fuel_core_types::fuel_tx::GasCosts); - impl From<$name> for fuel_core_types::fuel_tx::GasCosts { - fn from(value: $name) -> Self { - let values = fuel_core_types::fuel_tx::GasCostsValues { - $($field_name: value.$field_name.into(),)* - }; - Self::new(values) - } - } +impl GasCosts { + pub fn new(gas_costs: fuel_core_types::fuel_tx::GasCosts) -> Self { + GasCosts(gas_costs) + } +} - impl From for $name { - fn from(value: schema::chain::GasCosts) -> Self { - Self { - $($field_name: value.$field_name.into(),)* - } - } +impl GasCosts { + pub fn add(&self) -> Word { + self.0.add() + } - } + pub fn addi(&self) -> Word { + self.0.addi() + } + + pub fn aloc(&self) -> Word { + self.0.aloc() + } + + pub fn and(&self) -> Word { + self.0.and() + } + + pub fn andi(&self) -> Word { + self.0.andi() + } + + pub fn bal(&self) -> Word { + self.0.bal() + } + + pub fn bhei(&self) -> Word { + self.0.bhei() + } + + pub fn bhsh(&self) -> Word { + self.0.bhsh() + } + + pub fn burn(&self) -> Word { + self.0.burn() + } + + pub fn cb(&self) -> Word { + self.0.cb() + } + + pub fn cfei(&self) -> Word { + self.0.cfei() + } + + pub fn cfsi(&self) -> Word { + self.0.cfsi() + } + + pub fn div(&self) -> Word { + self.0.div() + } + + pub fn divi(&self) -> Word { + self.0.divi() + } + + pub fn eck1(&self) -> Word { + self.0.eck1() + } + + pub fn ecr1(&self) -> Word { + self.0.ecr1() + } + + pub fn ed19(&self) -> Word { + self.0.ed19() + } + + pub fn eq_(&self) -> Word { + self.0.eq_() + } + + pub fn exp(&self) -> Word { + self.0.exp() + } + + pub fn expi(&self) -> Word { + self.0.expi() + } + + pub fn flag(&self) -> Word { + self.0.flag() + } + + pub fn gm(&self) -> Word { + self.0.gm() + } + + pub fn gt(&self) -> Word { + self.0.gt() + } + + pub fn gtf(&self) -> Word { + self.0.gtf() + } + + pub fn ji(&self) -> Word { + self.0.ji() + } + + pub fn jmp(&self) -> Word { + self.0.jmp() + } + + pub fn jne(&self) -> Word { + self.0.jne() + } + + pub fn jnei(&self) -> Word { + self.0.jnei() + } + + pub fn jnzi(&self) -> Word { + self.0.jnzi() + } + + pub fn jmpf(&self) -> Word { + self.0.jmpf() + } + + pub fn jmpb(&self) -> Word { + self.0.jmpb() + } + + pub fn jnzf(&self) -> Word { + self.0.jnzf() + } + + pub fn jnzb(&self) -> Word { + self.0.jnzb() + } + + pub fn jnef(&self) -> Word { + self.0.jnef() + } + + pub fn jneb(&self) -> Word { + self.0.jneb() + } + + pub fn lb(&self) -> Word { + self.0.lb() + } + + pub fn log(&self) -> Word { + self.0.log() + } + + pub fn lt(&self) -> Word { + self.0.lt() + } + + pub fn lw(&self) -> Word { + self.0.lw() + } + + pub fn mint(&self) -> Word { + self.0.mint() + } + + pub fn mlog(&self) -> Word { + self.0.mlog() + } + + pub fn mod_op(&self) -> Word { + self.0.mod_op() + } + + pub fn modi(&self) -> Word { + self.0.modi() + } + + pub fn move_op(&self) -> Word { + self.0.move_op() + } + + pub fn movi(&self) -> Word { + self.0.movi() + } + + pub fn mroo(&self) -> Word { + self.0.mroo() + } + + pub fn mul(&self) -> Word { + self.0.mul() + } + + pub fn muli(&self) -> Word { + self.0.muli() + } + + pub fn mldv(&self) -> Word { + self.0.mldv() + } + + pub fn noop(&self) -> Word { + self.0.noop() + } + + pub fn not(&self) -> Word { + self.0.not() + } + + pub fn or(&self) -> Word { + self.0.or() + } + + pub fn ori(&self) -> Word { + self.0.ori() + } + + pub fn poph(&self) -> Word { + self.0.poph() + } + + pub fn popl(&self) -> Word { + self.0.popl() + } + + pub fn pshh(&self) -> Word { + self.0.pshh() + } + + pub fn pshl(&self) -> Word { + self.0.pshl() + } + + pub fn ret(&self) -> Word { + self.0.ret() + } + + pub fn rvrt(&self) -> Word { + self.0.rvrt() + } + + pub fn sb(&self) -> Word { + self.0.sb() + } + + pub fn sll(&self) -> Word { + self.0.sll() + } + + pub fn slli(&self) -> Word { + self.0.slli() + } + + pub fn srl(&self) -> Word { + self.0.srl() + } + + pub fn srli(&self) -> Word { + self.0.srli() + } + + pub fn srw(&self) -> Word { + self.0.srw() + } + + pub fn sub(&self) -> Word { + self.0.sub() + } + + pub fn subi(&self) -> Word { + self.0.subi() + } + + pub fn sw(&self) -> Word { + self.0.sw() + } + + pub fn sww(&self) -> Word { + self.0.sww() + } + + pub fn time(&self) -> Word { + self.0.time() + } + + pub fn tr(&self) -> Word { + self.0.tr() + } + + pub fn tro(&self) -> Word { + self.0.tro() + } + + pub fn wdcm(&self) -> Word { + self.0.wdcm() + } + + pub fn wqcm(&self) -> Word { + self.0.wqcm() + } + pub fn wdop(&self) -> Word { + self.0.wdop() + } + + pub fn wqop(&self) -> Word { + self.0.wqop() + } + + pub fn wdml(&self) -> Word { + self.0.wdml() + } + + pub fn wqml(&self) -> Word { + self.0.wqml() + } + + pub fn wddv(&self) -> Word { + self.0.wddv() + } + + pub fn wqdv(&self) -> Word { + self.0.wqdv() + } + + pub fn wdmd(&self) -> Word { + self.0.wdmd() + } + + pub fn wqmd(&self) -> Word { + self.0.wqmd() + } + + pub fn wdam(&self) -> Word { + self.0.wdam() + } + + pub fn wqam(&self) -> Word { + self.0.wqam() + } + + pub fn wdmm(&self) -> Word { + self.0.wdmm() + } + + pub fn wqmm(&self) -> Word { + self.0.wqmm() + } + + pub fn xor(&self) -> Word { + self.0.xor() + } + + pub fn xori(&self) -> Word { + self.0.xori() + } + + pub fn call(&self) -> DependentCost { + self.0.call().into() + } + + pub fn ccp(&self) -> DependentCost { + self.0.ccp().into() + } + + pub fn croo(&self) -> DependentCost { + self.0.croo().into() + } + + pub fn csiz(&self) -> DependentCost { + self.0.csiz().into() + } + + pub fn k256(&self) -> DependentCost { + self.0.k256().into() + } + + pub fn ldc(&self) -> DependentCost { + self.0.ldc().into() + } + + pub fn logd(&self) -> DependentCost { + self.0.logd().into() + } + + pub fn mcl(&self) -> DependentCost { + self.0.mcl().into() + } + + pub fn mcli(&self) -> DependentCost { + self.0.mcli().into() + } + + pub fn mcp(&self) -> DependentCost { + self.0.mcp().into() + } + + pub fn mcpi(&self) -> DependentCost { + self.0.mcpi().into() + } + + pub fn meq(&self) -> DependentCost { + self.0.meq().into() + } + + pub fn retd(&self) -> DependentCost { + self.0.retd().into() + } + + pub fn s256(&self) -> DependentCost { + self.0.s256().into() + } + + pub fn scwq(&self) -> DependentCost { + self.0.scwq().into() + } + + pub fn smo(&self) -> DependentCost { + self.0.smo().into() + } + + pub fn srwq(&self) -> DependentCost { + self.0.srwq().into() + } + + pub fn swwq(&self) -> DependentCost { + self.0.swwq().into() + } + + pub fn contract_root(&self) -> DependentCost { + self.0.contract_root().into() + } + + pub fn state_root(&self) -> DependentCost { + self.0.state_root().into() + } + + pub fn new_storage_per_byte(&self) -> Word { + self.0.new_storage_per_byte() + } + + pub fn vm_initialization(&self) -> DependentCost { + self.0.vm_initialization().into() } } -include_from_impls! { - #[derive(Copy, Clone, Debug)] - pub struct GasCosts { - pub add: u64, - pub addi: u64, - pub aloc: u64, - pub and: u64, - pub andi: u64, - pub bal: u64, - pub bhei: u64, - pub bhsh: u64, - pub burn: u64, - pub cb: u64, - pub cfei: u64, - pub cfsi: u64, - pub div: u64, - pub divi: u64, - pub eck1: u64, - pub ecr1: u64, - pub ed19: u64, - pub eq: u64, - pub exp: u64, - pub expi: u64, - pub flag: u64, - pub gm: u64, - pub gt: u64, - pub gtf: u64, - pub ji: u64, - pub jmp: u64, - pub jne: u64, - pub jnei: u64, - pub jnzi: u64, - pub jmpf: u64, - pub jmpb: u64, - pub jnzf: u64, - pub jnzb: u64, - pub jnef: u64, - pub jneb: u64, - pub lb: u64, - pub log: u64, - pub lt: u64, - pub lw: u64, - pub mint: u64, - pub mlog: u64, - pub mod_op: u64, - pub modi: u64, - pub move_op: u64, - pub movi: u64, - pub mroo: u64, - pub mul: u64, - pub muli: u64, - pub mldv: u64, - pub noop: u64, - pub not: u64, - pub or: u64, - pub ori: u64, - pub poph: u64, - pub popl: u64, - pub pshh: u64, - pub pshl: u64, - pub ret: u64, - pub rvrt: u64, - pub sb: u64, - pub sll: u64, - pub slli: u64, - pub srl: u64, - pub srli: u64, - pub srw: u64, - pub sub: u64, - pub subi: u64, - pub sw: u64, - pub sww: u64, - pub time: u64, - pub tr: u64, - pub tro: u64, - pub wdcm: u64, - pub wqcm: u64, - pub wdop: u64, - pub wqop: u64, - pub wdml: u64, - pub wqml: u64, - pub wddv: u64, - pub wqdv: u64, - pub wdmd: u64, - pub wqmd: u64, - pub wdam: u64, - pub wqam: u64, - pub wdmm: u64, - pub wqmm: u64, - pub xor: u64, - pub xori: u64, - - pub call: DependentCost, - pub ccp: DependentCost, - pub csiz: DependentCost, - pub croo: DependentCost, - pub k256: DependentCost, - pub ldc: DependentCost, - pub logd: DependentCost, - pub mcl: DependentCost, - pub mcli: DependentCost, - pub mcp: DependentCost, - pub mcpi: DependentCost, - pub meq: DependentCost, - pub retd: DependentCost, - pub s256: DependentCost, - pub scwq: DependentCost, - pub smo: DependentCost, - pub srwq: DependentCost, - pub swwq: DependentCost, - - // Non-opcode prices - pub contract_root: DependentCost, - pub state_root: DependentCost, - pub vm_initialization: DependentCost, - pub new_storage_per_byte: u64, +impl From for fuel_core_types::fuel_tx::GasCosts { + fn from(value: GasCosts) -> Self { + value.0 } } @@ -174,7 +483,25 @@ impl From for fuel_core_types::fuel_tx::DependentCost { } } -impl From for DependentCost { +impl From for DependentCost { + fn from(value: fuel_core_types::fuel_tx::DependentCost) -> Self { + match value { + fuel_core_types::fuel_tx::DependentCost::LightOperation { + base, + units_per_gas, + } => DependentCost::LightOperation { + base, + units_per_gas, + }, + fuel_core_types::fuel_tx::DependentCost::HeavyOperation { + base, + gas_per_unit, + } => DependentCost::HeavyOperation { base, gas_per_unit }, + } + } +} + +impl From for fuel_core_types::fuel_tx::DependentCost { fn from(value: schema::chain::DependentCost) -> Self { match value { schema::chain::DependentCost::LightOperation( @@ -182,20 +509,29 @@ impl From for DependentCost { base, units_per_gas, }, - ) => DependentCost::LightOperation { + ) => fuel_core_types::fuel_tx::DependentCost::LightOperation { base: base.into(), units_per_gas: units_per_gas.into(), }, schema::chain::DependentCost::HeavyOperation( schema::chain::HeavyOperation { base, gas_per_unit }, - ) => DependentCost::HeavyOperation { + ) => fuel_core_types::fuel_tx::DependentCost::HeavyOperation { base: base.into(), gas_per_unit: gas_per_unit.into(), }, - schema::chain::DependentCost::Unknown => DependentCost::HeavyOperation { - base: 0, - gas_per_unit: 0, - }, + schema::chain::DependentCost::Unknown => { + fuel_core_types::fuel_tx::DependentCost::HeavyOperation { + base: 0, + gas_per_unit: 0, + } + } } } } + +impl From for DependentCost { + fn from(value: schema::chain::DependentCost) -> Self { + let vm_value: fuel_core_types::fuel_tx::DependentCost = value.into(); + vm_value.into() + } +} diff --git a/crates/fuel-core/Cargo.toml b/crates/fuel-core/Cargo.toml index 655b50e5b40..269387d5b49 100644 --- a/crates/fuel-core/Cargo.toml +++ b/crates/fuel-core/Cargo.toml @@ -81,7 +81,12 @@ default = ["rocksdb"] p2p = ["dep:fuel-core-p2p", "dep:fuel-core-sync"] relayer = ["dep:fuel-core-relayer"] rocksdb = ["dep:rocksdb", "dep:tempfile", "dep:num_cpus"] -test-helpers = ["fuel-core-p2p?/test-helpers", "fuel-core-storage/test-helpers"] +test-helpers = [ + "fuel-core-p2p?/test-helpers", + "fuel-core-storage/test-helpers", + "fuel-core-chain-config/test-helpers", + "fuel-core-txpool/test-helpers", +] # features to enable in production, but increase build times rocksdb-production = ["rocksdb", "rocksdb/jemalloc"] wasm-executor = ["fuel-core-upgradable-executor/wasm-executor"] diff --git a/crates/fuel-core/src/database/coin.rs b/crates/fuel-core/src/database/coin.rs index 16614512d5b..d393e9a86dd 100644 --- a/crates/fuel-core/src/database/coin.rs +++ b/crates/fuel-core/src/database/coin.rs @@ -45,7 +45,9 @@ impl Database { res.map(|(key, _)| { UtxoId::new( TxId::try_from(&key[32..64]).expect("The slice has size 32"), - key[64], + u16::from_be_bytes( + key[64..].try_into().expect("The slice has size 2"), + ) ) }) }) diff --git a/crates/fuel-core/src/database/genesis_progress.rs b/crates/fuel-core/src/database/genesis_progress.rs index 0ce25e1d8d9..9cb9796a6e3 100644 --- a/crates/fuel-core/src/database/genesis_progress.rs +++ b/crates/fuel-core/src/database/genesis_progress.rs @@ -100,8 +100,8 @@ impl Database { let mut root_calculator = MerkleRootCalculator::new(); for coin in coins { - let (_, coin) = coin?; - root_calculator.push(coin.root()?.as_slice()); + let (utxo_id, coin) = coin?; + root_calculator.push(coin.uncompress(utxo_id).root()?.as_slice()); } Ok(root_calculator.root()) diff --git a/crates/fuel-core/src/executor.rs b/crates/fuel-core/src/executor.rs index 4106bbcd1b7..a99151d85f1 100644 --- a/crates/fuel-core/src/executor.rs +++ b/crates/fuel-core/src/executor.rs @@ -13,12 +13,17 @@ mod tests { use fuel_core_storage::{ tables::{ Coins, + ConsensusParametersVersions, ContractsRawCode, Messages, }, - transactional::AtomicView, + transactional::{ + AtomicView, + WriteTransaction, + }, Result as StorageResult, StorageAsMut, + StorageAsRef, }; use fuel_core_types::{ blockchain::{ @@ -122,10 +127,7 @@ mod tests { }, tai64::Tai64, }; - use fuel_core_upgradable_executor::{ - config::Config, - executor::Executor, - }; + use fuel_core_upgradable_executor::executor::Executor; use itertools::Itertools; use rand::{ prelude::StdRng, @@ -133,6 +135,18 @@ mod tests { SeedableRng, }; + #[derive(Clone, Debug, Default)] + struct Config { + /// Network-wide common parameters used for validating the chain. + /// The executor already has these parameters, and this field allows us + /// to override the existing value. + pub consensus_parameters: ConsensusParameters, + /// Print execution backtraces if transaction execution reverts. + pub backtrace: bool, + /// Default mode for utxo_validation + pub utxo_validation_default: bool, + } + #[derive(Clone, Debug)] struct DisabledRelayer; @@ -163,11 +177,31 @@ mod tests { } } + fn add_consensus_parameters( + mut database: Database, + consensus_parameters: &ConsensusParameters, + ) -> Database { + // Set the consensus parameters for the executor. + let mut tx = database.write_transaction(); + tx.storage_as_mut::() + .insert(&0, consensus_parameters) + .unwrap(); + tx.commit().unwrap(); + database + } + fn create_executor( database: Database, config: Config, ) -> Executor { - Executor::new(database, DisabledRelayer, config) + let executor_config = fuel_core_upgradable_executor::config::Config { + backtrace: config.backtrace, + utxo_validation_default: config.utxo_validation_default, + }; + + let database = add_consensus_parameters(database, &config.consensus_parameters); + + Executor::new(database, DisabledRelayer, executor_config) } pub(crate) fn setup_executable_script() -> (Create, Script) { @@ -230,7 +264,7 @@ mod tests { .collect(); let script = TxBuilder::new(2322) - .script_gas_limit(TxParameters::DEFAULT.max_gas_per_tx >> 1) + .script_gas_limit(TxParameters::DEFAULT.max_gas_per_tx() >> 1) .start_script(script, script_data) .contract_input(contract_id) .coin_input(asset_id, input_amount) @@ -386,14 +420,10 @@ mod tests { let recipient = Contract::EMPTY_CONTRACT_ID; - let fee_params = FeeParameters { - gas_price_factor, - ..Default::default() - }; - let consensus_parameters = ConsensusParameters { - fee_params, - ..Default::default() - }; + let fee_params = + FeeParameters::default().with_gas_price_factor(gas_price_factor); + let mut consensus_parameters = ConsensusParameters::default(); + consensus_parameters.set_fee_params(fee_params); let config = Config { consensus_parameters: consensus_parameters.clone(), ..Default::default() @@ -436,7 +466,6 @@ mod tests { invalid_duplicate_tx, ]), gas_price: price, - gas_limit: u64::MAX, coinbase_recipient: recipient, }, )) @@ -518,7 +547,6 @@ mod tests { script.into() ]), gas_price: price, - gas_limit: u64::MAX, coinbase_recipient: recipient, }, )) @@ -547,7 +575,7 @@ mod tests { ); assert_eq!( second_mint.input_contract().utxo_id, - UtxoId::new(first_mint.id(&consensus_parameters.chain_id), 0) + UtxoId::new(first_mint.id(&consensus_parameters.chain_id()), 0) ); assert_eq!( second_mint.input_contract().tx_pointer, @@ -591,8 +619,10 @@ mod tests { .transaction() .clone(); + let fee_params = + FeeParameters::default().with_gas_price_factor(gas_price_factor); let mut consensus_parameters = ConsensusParameters::default(); - consensus_parameters.fee_params.gas_price_factor = gas_price_factor; + consensus_parameters.set_fee_params(fee_params); let config = Config { consensus_parameters, ..Default::default() @@ -607,7 +637,6 @@ mod tests { transactions_source: OnceTransactionsSource::new(vec![script.into()]), coinbase_recipient: recipient, gas_price: 0, - gas_limit: u64::MAX, })) .unwrap(); let ExecutionResult { block, .. } = result.into_result(); @@ -631,15 +660,12 @@ mod tests { .clone(); let recipient = Contract::EMPTY_CONTRACT_ID; - let fee_params = FeeParameters { - gas_price_factor, - ..Default::default() - }; + let fee_params = + FeeParameters::default().with_gas_price_factor(gas_price_factor); + let mut consensus_parameters = ConsensusParameters::default(); + consensus_parameters.set_fee_params(fee_params); let config = Config { - consensus_parameters: ConsensusParameters { - fee_params, - ..Default::default() - }, + consensus_parameters, ..Default::default() }; let database = &mut Database::default(); @@ -663,7 +689,6 @@ mod tests { script.into() ]), gas_price: price, - gas_limit: u64::MAX, coinbase_recipient: recipient, }, )) @@ -890,10 +915,8 @@ mod tests { *block.transactions_mut() = vec![mint.into()]; block.header_mut().recalculate_metadata(); - let consensus_parameters = ConsensusParameters { - base_asset_id: [1u8; 32].into(), - ..Default::default() - }; + let mut consensus_parameters = ConsensusParameters::default(); + consensus_parameters.set_base_asset_id([1u8; 32].into()); let config = Config { consensus_parameters, @@ -1501,7 +1524,7 @@ mod tests { .clone() .into(); - let mut db = &Database::default(); + let db = &Database::default(); let mut executor = create_executor(db.clone(), Default::default()); let block = PartialFuelBlock { @@ -1844,7 +1867,7 @@ mod tests { let mut new_tx = executed_tx.clone(); *new_tx.script_mut() = vec![]; - new_tx.precompute(&consensus_parameters.chain_id).unwrap(); + new_tx.precompute(&consensus_parameters.chain_id()).unwrap(); let block = PartialFuelBlock { header: PartialBlockHeader { @@ -1864,7 +1887,6 @@ mod tests { header_to_produce: block.header, transactions_source: OnceTransactionsSource::new(block.transactions), gas_price: 0, - gas_limit: u64::MAX, coinbase_recipient: Default::default(), })) .unwrap() @@ -2168,7 +2190,7 @@ mod tests { let (deploy, script) = setup_executable_script(); let script_id = script.id(&ChainId::default()); - let mut database = &Database::default(); + let database = &Database::default(); let mut executor = create_executor(database.clone(), Default::default()); let block = PartialFuelBlock { @@ -2188,7 +2210,7 @@ mod tests { .iter() .enumerate() { - let id = UtxoId::new(script_id, idx as u8); + let id = UtxoId::new(script_id, idx as u16); match output { Output::Change { .. } | Output::Variable { .. } | Output::Coin { .. } => { let maybe_utxo = database.storage::().get(&id).unwrap(); @@ -2219,7 +2241,7 @@ mod tests { .into(); let tx_id = tx.id(&ChainId::default()); - let mut database = &Database::default(); + let database = &Database::default(); let mut executor = create_executor(database.clone(), Default::default()); let block = PartialFuelBlock { @@ -2768,7 +2790,6 @@ mod tests { transactions_source: OnceTransactionsSource::new(vec![tx.into()]), coinbase_recipient: Default::default(), gas_price: 1, - gas_limit: u64::MAX, })) .unwrap() .into_result(); @@ -2807,12 +2828,15 @@ mod tests { }; fn database_with_genesis_block(da_block_height: u64) -> Database { - let mut db = Database::default(); + let mut db = add_consensus_parameters( + Database::default(), + &ConsensusParameters::default(), + ); let mut block = Block::default(); block.header_mut().set_da_height(da_block_height.into()); block.header_mut().recalculate_metadata(); - db.storage::() + db.storage_as_mut::() .insert(&0.into(), &block) .expect("Should insert genesis block without any problems"); db @@ -2914,7 +2938,10 @@ mod tests { let on_chain_db = if let Some(genesis_da_height) = input.genesis_da_height { database_with_genesis_block(genesis_da_height) } else { - Database::default() + add_consensus_parameters( + Database::default(), + &ConsensusParameters::default(), + ) }; let mut relayer_db = Database::::default(); diff --git a/crates/fuel-core/src/graphql_api/storage/coins.rs b/crates/fuel-core/src/graphql_api/storage/coins.rs index f617c27bf37..58c8a23958d 100644 --- a/crates/fuel-core/src/graphql_api/storage/coins.rs +++ b/crates/fuel-core/src/graphql_api/storage/coins.rs @@ -16,16 +16,17 @@ use fuel_core_types::fuel_tx::{ // TODO: Reuse `fuel_vm::storage::double_key` macro. pub fn owner_coin_id_key(owner: &Address, coin_id: &UtxoId) -> OwnedCoinKey { - let mut default = [0u8; Address::LEN + TxId::LEN + 1]; + let mut default = [0u8; Address::LEN + TxId::LEN + 2]; default[0..Address::LEN].copy_from_slice(owner.as_ref()); - default[Address::LEN..].copy_from_slice(utxo_id_to_bytes(coin_id).as_ref()); + let utxo_id_bytes: [u8; TxId::LEN + 2] = utxo_id_to_bytes(coin_id); + default[Address::LEN..].copy_from_slice(utxo_id_bytes.as_ref()); default } /// The storage table of owned coin ids. Maps addresses to owned coins. pub struct OwnedCoins; /// The storage key for owned coins: `Address ++ UtxoId` -pub type OwnedCoinKey = [u8; Address::LEN + TxId::LEN + 1]; +pub type OwnedCoinKey = [u8; Address::LEN + TxId::LEN + 2]; impl Mappable for OwnedCoins { type Key = Self::OwnedKey; @@ -48,14 +49,14 @@ mod test { use super::*; fn generate_key(rng: &mut impl rand::Rng) -> ::Key { - let mut bytes = [0u8; 65]; + let mut bytes = [0u8; 66]; rng.fill(bytes.as_mut()); bytes } fuel_core_storage::basic_storage_tests!( OwnedCoins, - [0u8; 65], + [0u8; 66], ::Value::default(), ::Value::default(), generate_key diff --git a/crates/fuel-core/src/graphql_api/storage/messages.rs b/crates/fuel-core/src/graphql_api/storage/messages.rs index 832120eb644..951cb3a2a7c 100644 --- a/crates/fuel-core/src/graphql_api/storage/messages.rs +++ b/crates/fuel-core/src/graphql_api/storage/messages.rs @@ -1,10 +1,8 @@ use fuel_core_storage::{ blueprint::plain::Plain, codec::{ - manual::Manual, postcard::Postcard, - Decode, - Encode, + raw::Raw, }, structured_storage::TableWithBlueprint, Mappable, @@ -20,7 +18,6 @@ use rand::{ }, Rng, }; -use std::borrow::Cow; fuel_core_types::fuel_vm::double_key!(OwnedMessageKey, Address, address, Nonce, nonce); @@ -44,23 +41,8 @@ impl Mappable for OwnedMessageIds { type OwnedValue = Self::Value; } -impl Encode for Manual { - type Encoder<'a> = Cow<'a, [u8]>; - - fn encode(t: &OwnedMessageKey) -> Self::Encoder<'_> { - Cow::Borrowed(t.as_ref()) - } -} - -impl Decode for Manual { - fn decode(bytes: &[u8]) -> anyhow::Result { - OwnedMessageKey::from_slice(bytes) - .map_err(|_| anyhow::anyhow!("Unable to decode bytes")) - } -} - impl TableWithBlueprint for OwnedMessageIds { - type Blueprint = Plain, Postcard>; + type Blueprint = Plain; type Column = super::Column; fn column() -> Self::Column { diff --git a/crates/fuel-core/src/schema/chain.rs b/crates/fuel-core/src/schema/chain.rs index 5f65f3eb2d6..97e9b23ffc9 100644 --- a/crates/fuel-core/src/schema/chain.rs +++ b/crates/fuel-core/src/schema/chain.rs @@ -11,7 +11,9 @@ use crate::{ schema::{ block::Block, scalars::{ + Address, AssetId, + U16, U32, U64, U8, @@ -23,7 +25,11 @@ use async_graphql::{ Object, Union, }; -use fuel_core_types::fuel_tx; +use fuel_core_types::{ + fuel_tx, + fuel_tx::GasCostsValues, +}; +use std::ops::Deref; pub struct ChainInfo; pub struct ConsensusParameters(fuel_tx::ConsensusParameters); @@ -35,6 +41,43 @@ pub struct FeeParameters(fuel_tx::FeeParameters); pub struct GasCosts(fuel_tx::GasCosts); +pub struct Version(u8); + +#[derive(Union)] +pub enum GasCostsVersion { + V1(Version), +} + +#[derive(Union)] +pub enum FeeParametersVersion { + V1(Version), +} + +#[derive(Union)] +pub enum ContractParametersVersion { + V1(Version), +} + +#[derive(Union)] +pub enum ScriptParametersVersion { + V1(Version), +} + +#[derive(Union)] +pub enum PredicateParametersVersion { + V1(Version), +} + +#[derive(Union)] +pub enum TxParametersVersion { + V1(Version), +} + +#[derive(Union)] +pub enum ConsensusParametersVersion { + V1(Version), +} + #[derive(Union)] pub enum DependentCost { LightOperation(LightOperation), @@ -68,8 +111,23 @@ impl From for DependentCost { } } +#[Object] +impl Version { + async fn value(&self) -> U8 { + self.0.into() + } +} + #[Object] impl ConsensusParameters { + async fn version(&self) -> ConsensusParametersVersion { + match self.0 { + fuel_tx::ConsensusParameters::V1(_) => { + ConsensusParametersVersion::V1(Version(1)) + } + } + } + async fn tx_params(&self, ctx: &Context<'_>) -> async_graphql::Result { let config = ctx.data_unchecked::(); @@ -128,534 +186,589 @@ impl ConsensusParameters { Ok(AssetId(*config.consensus_parameters.base_asset_id())) } + async fn block_gas_limit(&self, ctx: &Context<'_>) -> async_graphql::Result { + let config = ctx.data_unchecked::(); + + Ok(config.consensus_parameters.block_gas_limit().into()) + } + async fn chain_id(&self) -> U64 { - (*self.0.chain_id).into() + (*self.0.chain_id()).into() } async fn gas_costs(&self, ctx: &Context<'_>) -> async_graphql::Result { let config = ctx.data_unchecked::(); - Ok(GasCosts(config.consensus_parameters.gas_costs.clone())) + Ok(GasCosts(config.consensus_parameters.gas_costs().clone())) + } + + async fn privileged_address( + &self, + ctx: &Context<'_>, + ) -> async_graphql::Result
{ + let config = ctx.data_unchecked::(); + + Ok(Address(*config.consensus_parameters.privileged_address())) } } #[Object] impl TxParameters { - async fn max_inputs(&self) -> U8 { - self.0.max_inputs.into() + async fn version(&self) -> TxParametersVersion { + match self.0 { + fuel_tx::TxParameters::V1(_) => TxParametersVersion::V1(Version(1)), + } } - async fn max_outputs(&self) -> U8 { - self.0.max_outputs.into() + async fn max_inputs(&self) -> U16 { + self.0.max_inputs().into() + } + + async fn max_outputs(&self) -> U16 { + self.0.max_outputs().into() } async fn max_witnesses(&self) -> U32 { - self.0.max_witnesses.into() + self.0.max_witnesses().into() } async fn max_gas_per_tx(&self) -> U64 { - self.0.max_gas_per_tx.into() + self.0.max_gas_per_tx().into() } async fn max_size(&self) -> U64 { - self.0.max_size.into() + self.0.max_size().into() } } #[Object] impl PredicateParameters { + async fn version(&self) -> PredicateParametersVersion { + match self.0 { + fuel_tx::PredicateParameters::V1(_) => { + PredicateParametersVersion::V1(Version(1)) + } + } + } + async fn max_predicate_length(&self) -> U64 { - self.0.max_predicate_length.into() + self.0.max_predicate_length().into() } async fn max_predicate_data_length(&self) -> U64 { - self.0.max_predicate_data_length.into() + self.0.max_predicate_data_length().into() } async fn max_gas_per_predicate(&self) -> U64 { - self.0.max_gas_per_predicate.into() + self.0.max_gas_per_predicate().into() } async fn max_message_data_length(&self) -> U64 { - self.0.max_message_data_length.into() + self.0.max_message_data_length().into() } } #[Object] impl ScriptParameters { + async fn version(&self) -> ScriptParametersVersion { + match self.0 { + fuel_tx::ScriptParameters::V1(_) => ScriptParametersVersion::V1(Version(1)), + } + } + async fn max_script_length(&self) -> U64 { - self.0.max_script_length.into() + self.0.max_script_length().into() } async fn max_script_data_length(&self) -> U64 { - self.0.max_script_data_length.into() + self.0.max_script_data_length().into() } } #[Object] impl ContractParameters { + async fn version(&self) -> ContractParametersVersion { + match self.0 { + fuel_tx::ContractParameters::V1(_) => { + ContractParametersVersion::V1(Version(1)) + } + } + } + async fn contract_max_size(&self) -> U64 { - self.0.contract_max_size.into() + self.0.contract_max_size().into() } async fn max_storage_slots(&self) -> U64 { - self.0.max_storage_slots.into() + self.0.max_storage_slots().into() } } #[Object] impl FeeParameters { + async fn version(&self) -> FeeParametersVersion { + match self.0 { + fuel_tx::FeeParameters::V1(_) => FeeParametersVersion::V1(Version(1)), + } + } + async fn gas_price_factor(&self) -> U64 { - self.0.gas_price_factor.into() + self.0.gas_price_factor().into() } async fn gas_per_byte(&self) -> U64 { - self.0.gas_per_byte.into() + self.0.gas_per_byte().into() } } #[Object] impl GasCosts { + async fn version(&self) -> GasCostsVersion { + match self.0.deref() { + GasCostsValues::V1(_) => GasCostsVersion::V1(Version(1)), + } + } + async fn add(&self) -> U64 { - self.0.add.into() + self.0.add().into() } async fn addi(&self) -> U64 { - self.0.addi.into() + self.0.addi().into() } async fn aloc(&self) -> U64 { - self.0.aloc.into() + self.0.aloc().into() } async fn and(&self) -> U64 { - self.0.and.into() + self.0.and().into() } async fn andi(&self) -> U64 { - self.0.andi.into() + self.0.andi().into() } async fn bal(&self) -> U64 { - self.0.bal.into() + self.0.bal().into() } async fn bhei(&self) -> U64 { - self.0.bhei.into() + self.0.bhei().into() } async fn bhsh(&self) -> U64 { - self.0.bhsh.into() + self.0.bhsh().into() } async fn burn(&self) -> U64 { - self.0.burn.into() + self.0.burn().into() } async fn cb(&self) -> U64 { - self.0.cb.into() + self.0.cb().into() } async fn cfei(&self) -> U64 { - self.0.cfei.into() + self.0.cfei().into() } async fn cfsi(&self) -> U64 { - self.0.cfsi.into() + self.0.cfsi().into() } async fn div(&self) -> U64 { - self.0.div.into() + self.0.div().into() } async fn divi(&self) -> U64 { - self.0.divi.into() + self.0.divi().into() } async fn ecr1(&self) -> U64 { - self.0.ecr1.into() + self.0.ecr1().into() } async fn eck1(&self) -> U64 { - self.0.eck1.into() + self.0.eck1().into() } async fn ed19(&self) -> U64 { - self.0.ed19.into() + self.0.ed19().into() } async fn eq(&self) -> U64 { - self.0.eq.into() + self.0.eq_().into() } async fn exp(&self) -> U64 { - self.0.exp.into() + self.0.exp().into() } async fn expi(&self) -> U64 { - self.0.expi.into() + self.0.expi().into() } async fn flag(&self) -> U64 { - self.0.flag.into() + self.0.flag().into() } async fn gm(&self) -> U64 { - self.0.gm.into() + self.0.gm().into() } async fn gt(&self) -> U64 { - self.0.gt.into() + self.0.gt().into() } async fn gtf(&self) -> U64 { - self.0.gtf.into() + self.0.gtf().into() } async fn ji(&self) -> U64 { - self.0.ji.into() + self.0.ji().into() } async fn jmp(&self) -> U64 { - self.0.jmp.into() + self.0.jmp().into() } async fn jne(&self) -> U64 { - self.0.jne.into() + self.0.jne().into() } async fn jnei(&self) -> U64 { - self.0.jnei.into() + self.0.jnei().into() } async fn jnzi(&self) -> U64 { - self.0.jnzi.into() + self.0.jnzi().into() } async fn jmpf(&self) -> U64 { - self.0.jmpf.into() + self.0.jmpf().into() } async fn jmpb(&self) -> U64 { - self.0.jmpb.into() + self.0.jmpb().into() } async fn jnzf(&self) -> U64 { - self.0.jnzf.into() + self.0.jnzf().into() } async fn jnzb(&self) -> U64 { - self.0.jnzb.into() + self.0.jnzb().into() } async fn jnef(&self) -> U64 { - self.0.jnef.into() + self.0.jnef().into() } async fn jneb(&self) -> U64 { - self.0.jneb.into() + self.0.jneb().into() } async fn lb(&self) -> U64 { - self.0.lb.into() + self.0.lb().into() } async fn log(&self) -> U64 { - self.0.log.into() + self.0.log().into() } async fn lt(&self) -> U64 { - self.0.lt.into() + self.0.lt().into() } async fn lw(&self) -> U64 { - self.0.lw.into() + self.0.lw().into() } async fn mint(&self) -> U64 { - self.0.mint.into() + self.0.mint().into() } async fn mlog(&self) -> U64 { - self.0.mlog.into() + self.0.mlog().into() } async fn mod_op(&self) -> U64 { - self.0.mod_op.into() + self.0.mod_op().into() } async fn modi(&self) -> U64 { - self.0.modi.into() + self.0.modi().into() } async fn move_op(&self) -> U64 { - self.0.move_op.into() + self.0.move_op().into() } async fn movi(&self) -> U64 { - self.0.movi.into() + self.0.movi().into() } async fn mroo(&self) -> U64 { - self.0.mroo.into() + self.0.mroo().into() } async fn mul(&self) -> U64 { - self.0.mul.into() + self.0.mul().into() } async fn muli(&self) -> U64 { - self.0.muli.into() + self.0.muli().into() } async fn mldv(&self) -> U64 { - self.0.mldv.into() + self.0.mldv().into() } async fn noop(&self) -> U64 { - self.0.noop.into() + self.0.noop().into() } async fn not(&self) -> U64 { - self.0.not.into() + self.0.not().into() } async fn or(&self) -> U64 { - self.0.or.into() + self.0.or().into() } async fn ori(&self) -> U64 { - self.0.ori.into() + self.0.ori().into() } async fn poph(&self) -> U64 { - self.0.poph.into() + self.0.poph().into() } async fn popl(&self) -> U64 { - self.0.popl.into() + self.0.popl().into() } async fn pshh(&self) -> U64 { - self.0.pshh.into() + self.0.pshh().into() } async fn pshl(&self) -> U64 { - self.0.pshl.into() + self.0.pshl().into() } async fn ret(&self) -> U64 { - self.0.ret.into() + self.0.ret().into() } async fn rvrt(&self) -> U64 { - self.0.rvrt.into() + self.0.rvrt().into() } async fn sb(&self) -> U64 { - self.0.sb.into() + self.0.sb().into() } async fn sll(&self) -> U64 { - self.0.sll.into() + self.0.sll().into() } async fn slli(&self) -> U64 { - self.0.slli.into() + self.0.slli().into() } async fn srl(&self) -> U64 { - self.0.srl.into() + self.0.srl().into() } async fn srli(&self) -> U64 { - self.0.srli.into() + self.0.srli().into() } async fn srw(&self) -> U64 { - self.0.srw.into() + self.0.srw().into() } async fn sub(&self) -> U64 { - self.0.sub.into() + self.0.sub().into() } async fn subi(&self) -> U64 { - self.0.subi.into() + self.0.subi().into() } async fn sw(&self) -> U64 { - self.0.sw.into() + self.0.sw().into() } async fn sww(&self) -> U64 { - self.0.sww.into() + self.0.sww().into() } async fn time(&self) -> U64 { - self.0.time.into() + self.0.time().into() } async fn tr(&self) -> U64 { - self.0.tr.into() + self.0.tr().into() } async fn tro(&self) -> U64 { - self.0.tro.into() + self.0.tro().into() } async fn wdcm(&self) -> U64 { - self.0.wdcm.into() + self.0.wdcm().into() } async fn wqcm(&self) -> U64 { - self.0.wqcm.into() + self.0.wqcm().into() } async fn wdop(&self) -> U64 { - self.0.wdop.into() + self.0.wdop().into() } async fn wqop(&self) -> U64 { - self.0.wqop.into() + self.0.wqop().into() } async fn wdml(&self) -> U64 { - self.0.wdml.into() + self.0.wdml().into() } async fn wqml(&self) -> U64 { - self.0.wqml.into() + self.0.wqml().into() } async fn wddv(&self) -> U64 { - self.0.wddv.into() + self.0.wddv().into() } async fn wqdv(&self) -> U64 { - self.0.wqdv.into() + self.0.wqdv().into() } async fn wdmd(&self) -> U64 { - self.0.wdmd.into() + self.0.wdmd().into() } async fn wqmd(&self) -> U64 { - self.0.wqmd.into() + self.0.wqmd().into() } async fn wdam(&self) -> U64 { - self.0.wdam.into() + self.0.wdam().into() } async fn wqam(&self) -> U64 { - self.0.wqam.into() + self.0.wqam().into() } async fn wdmm(&self) -> U64 { - self.0.wdmm.into() + self.0.wdmm().into() } async fn wqmm(&self) -> U64 { - self.0.wqmm.into() + self.0.wqmm().into() } async fn xor(&self) -> U64 { - self.0.xor.into() + self.0.xor().into() } async fn xori(&self) -> U64 { - self.0.xori.into() + self.0.xori().into() } async fn call(&self) -> DependentCost { - self.0.call.into() + self.0.call().into() } async fn ccp(&self) -> DependentCost { - self.0.ccp.into() + self.0.ccp().into() } async fn croo(&self) -> DependentCost { - self.0.croo.into() + self.0.croo().into() } async fn csiz(&self) -> DependentCost { - self.0.csiz.into() + self.0.csiz().into() } async fn k256(&self) -> DependentCost { - self.0.k256.into() + self.0.k256().into() } async fn ldc(&self) -> DependentCost { - self.0.ldc.into() + self.0.ldc().into() } async fn logd(&self) -> DependentCost { - self.0.logd.into() + self.0.logd().into() } async fn mcl(&self) -> DependentCost { - self.0.mcl.into() + self.0.mcl().into() } async fn mcli(&self) -> DependentCost { - self.0.mcli.into() + self.0.mcli().into() } async fn mcp(&self) -> DependentCost { - self.0.mcp.into() + self.0.mcp().into() } async fn mcpi(&self) -> DependentCost { - self.0.mcpi.into() + self.0.mcpi().into() } async fn meq(&self) -> DependentCost { - self.0.meq.into() + self.0.meq().into() } async fn retd(&self) -> DependentCost { - self.0.retd.into() + self.0.retd().into() } async fn s256(&self) -> DependentCost { - self.0.s256.into() + self.0.s256().into() } async fn scwq(&self) -> DependentCost { - self.0.scwq.into() + self.0.scwq().into() } async fn smo(&self) -> DependentCost { - self.0.smo.into() + self.0.smo().into() } async fn srwq(&self) -> DependentCost { - self.0.srwq.into() + self.0.srwq().into() } async fn swwq(&self) -> DependentCost { - self.0.swwq.into() + self.0.swwq().into() } // Non-opcode prices async fn contract_root(&self) -> DependentCost { - self.0.contract_root.into() + self.0.contract_root().into() } async fn state_root(&self) -> DependentCost { - self.0.state_root.into() + self.0.state_root().into() } async fn vm_initialization(&self) -> DependentCost { - self.0.vm_initialization.into() + self.0.vm_initialization().into() } async fn new_storage_per_byte(&self) -> U64 { - self.0.new_storage_per_byte.into() + self.0.new_storage_per_byte().into() } } @@ -717,7 +830,7 @@ impl ChainInfo { async fn gas_costs(&self, ctx: &Context<'_>) -> async_graphql::Result { let config = ctx.data_unchecked::(); - Ok(GasCosts(config.consensus_parameters.gas_costs.clone())) + Ok(GasCosts(config.consensus_parameters.gas_costs().clone())) } } diff --git a/crates/fuel-core/src/schema/coins.rs b/crates/fuel-core/src/schema/coins.rs index 3e8200b07e8..6df3adcd662 100644 --- a/crates/fuel-core/src/schema/coins.rs +++ b/crates/fuel-core/src/schema/coins.rs @@ -17,6 +17,7 @@ use crate::{ AssetId, Nonce, UtxoId, + U16, U32, U64, }, @@ -66,8 +67,8 @@ impl Coin { } /// TxPointer - the index of the transaction that created this coin - async fn tx_created_idx(&self) -> U64 { - u64::from(self.0.tx_pointer.tx_index()).into() + async fn tx_created_idx(&self) -> U16 { + self.0.tx_pointer.tx_index().into() } } diff --git a/crates/fuel-core/src/schema/dap.rs b/crates/fuel-core/src/schema/dap.rs index acceb76ce14..b8f24a91fc1 100644 --- a/crates/fuel-core/src/schema/dap.rs +++ b/crates/fuel-core/src/schema/dap.rs @@ -31,9 +31,12 @@ use fuel_core_types::{ Word, }, fuel_tx::{ - field::Policies, + field::{ + Policies, + ScriptGasLimit, + Witnesses, + }, policies::PolicyType, - Buildable, ConsensusParameters, Executable, Script, @@ -70,7 +73,7 @@ pub struct Config { type FrozenDatabase = VmStorage>>; -#[derive(Debug, Clone, Default)] +#[derive(Debug, Clone)] pub struct ConcreteStorage { vm: HashMap>, tx: HashMap>, @@ -85,8 +88,9 @@ const GAS_PRICE: u64 = 0; impl ConcreteStorage { pub fn new(params: ConsensusParameters) -> Self { Self { + vm: Default::default(), + tx: Default::default(), params, - ..Default::default() } } @@ -114,7 +118,7 @@ impl ConcreteStorage { let id = ID::from(id); let vm_database = Self::vm_database(storage)?; - let tx = Self::dummy_tx(); + let tx = Self::dummy_tx(self.params.tx_params().max_gas_per_tx() / 2); let checked_tx = tx .into_checked_basic(vm_database.block_height()?, &self.params) .map_err(|e| anyhow::anyhow!("{:?}", e))?; @@ -154,7 +158,7 @@ impl ConcreteStorage { .get(id) .and_then(|tx| tx.first()) .cloned() - .unwrap_or(Self::dummy_tx()); + .unwrap_or(Self::dummy_tx(self.params.tx_params().max_gas_per_tx() / 2)); let checked_tx = tx .into_checked_basic(vm_database.block_height()?, &self.params) @@ -203,9 +207,10 @@ impl ConcreteStorage { Ok(vm_database) } - fn dummy_tx() -> Script { + fn dummy_tx(gas_limit: u64) -> Script { // Create `Script` transaction with dummy coin let mut tx = Script::default(); + *tx.script_gas_limit_mut() = gas_limit; tx.add_unsigned_coin_input( Default::default(), &Default::default(), @@ -214,7 +219,7 @@ impl ConcreteStorage { Default::default(), Default::default(), ); - tx.add_witness(vec![].into()); + tx.witnesses_mut().push(vec![].into()); tx.policies_mut().set(PolicyType::MaxFee, Some(0)); tx } diff --git a/crates/fuel-core/src/schema/scalars.rs b/crates/fuel-core/src/schema/scalars.rs index c5d8cf9fd33..2b95ee79622 100644 --- a/crates/fuel-core/src/schema/scalars.rs +++ b/crates/fuel-core/src/schema/scalars.rs @@ -81,6 +81,7 @@ macro_rules! number_scalar { number_scalar!(U64, u64, "U64"); number_scalar!(U32, u32, "U32"); +number_scalar!(U16, u16, "U16"); number_scalar!(U8, u8, "U8"); impl From for U32 { diff --git a/crates/fuel-core/src/schema/tx.rs b/crates/fuel-core/src/schema/tx.rs index 5a38b1ca2c7..b1de0a5c9b8 100644 --- a/crates/fuel-core/src/schema/tx.rs +++ b/crates/fuel-core/src/schema/tx.rs @@ -189,7 +189,8 @@ impl TxQuery { .owned_transactions(owner, start, direction) .map(|result| { result.map(|(cursor, tx)| { - let tx_id = tx.id(&config.consensus_parameters.chain_id); + let tx_id = + tx.id(&config.consensus_parameters.chain_id()); (cursor.into(), Transaction::from_tx(tx_id, tx)) }) }); @@ -216,7 +217,7 @@ impl TxQuery { .map_err(|err| anyhow::anyhow!("{:?}", err))?; Ok(Transaction::from_tx( - tx.id(&config.consensus_parameters.chain_id), + tx.id(&config.consensus_parameters.chain_id()), tx, )) } @@ -254,7 +255,7 @@ impl TxMutation { .map(|tx| FuelTx::from_bytes(&tx.0)) .collect::, _>>()?; for transaction in &mut transactions { - transaction.precompute(&config.consensus_parameters.chain_id)?; + transaction.precompute(&config.consensus_parameters.chain_id())?; } let tx_statuses = block_producer @@ -285,7 +286,7 @@ impl TxMutation { .await .into_iter() .try_collect()?; - let id = tx.id(&config.consensus_parameters.chain_id); + let id = tx.id(&config.consensus_parameters.chain_id()); let tx = Transaction(tx, id); Ok(tx) @@ -344,7 +345,7 @@ impl TxStatusSubscription { let txpool = ctx.data_unchecked::(); let config = ctx.data_unchecked::(); let tx = FuelTx::from_bytes(&tx.0)?; - let tx_id = tx.id(&config.consensus_parameters.chain_id); + let tx_id = tx.id(&config.consensus_parameters.chain_id()); let subscription = txpool.tx_update_subscribe(tx_id)?; let _: Vec<_> = txpool diff --git a/crates/fuel-core/src/schema/tx/input.rs b/crates/fuel-core/src/schema/tx/input.rs index 65599e4fdda..226526b888b 100644 --- a/crates/fuel-core/src/schema/tx/input.rs +++ b/crates/fuel-core/src/schema/tx/input.rs @@ -7,6 +7,7 @@ use crate::schema::scalars::{ Nonce, TxPointer, UtxoId, + U16, U64, }; use async_graphql::{ @@ -28,7 +29,7 @@ pub struct InputCoin { amount: U64, asset_id: AssetId, tx_pointer: TxPointer, - witness_index: u8, + witness_index: u16, predicate_gas_used: U64, predicate: HexString, predicate_data: HexString, @@ -56,7 +57,7 @@ impl InputCoin { self.tx_pointer } - async fn witness_index(&self) -> u8 { + async fn witness_index(&self) -> u16 { self.witness_index } @@ -109,7 +110,7 @@ pub struct InputMessage { recipient: Address, amount: U64, nonce: Nonce, - witness_index: u8, + witness_index: u16, predicate_gas_used: U64, data: HexString, predicate: HexString, @@ -134,8 +135,8 @@ impl InputMessage { self.nonce } - async fn witness_index(&self) -> u8 { - self.witness_index + async fn witness_index(&self) -> U16 { + self.witness_index.into() } async fn predicate_gas_used(&self) -> U64 { diff --git a/crates/fuel-core/src/schema/tx/output.rs b/crates/fuel-core/src/schema/tx/output.rs index eeab332dd86..8a5e2ed543b 100644 --- a/crates/fuel-core/src/schema/tx/output.rs +++ b/crates/fuel-core/src/schema/tx/output.rs @@ -3,6 +3,7 @@ use crate::schema::scalars::{ AssetId, Bytes32, ContractId, + U16, U64, }; use async_graphql::{ @@ -81,15 +82,15 @@ impl VariableOutput { } pub struct ContractOutput { - input_index: u8, + input_index: u16, balance_root: fuel_types::Bytes32, state_root: fuel_types::Bytes32, } #[Object] impl ContractOutput { - async fn input_index(&self) -> u8 { - self.input_index + async fn input_index(&self) -> U16 { + self.input_index.into() } async fn balance_root(&self) -> Bytes32 { diff --git a/crates/fuel-core/src/schema/tx/types.rs b/crates/fuel-core/src/schema/tx/types.rs index c3bf1edc6f9..c65884cf48c 100644 --- a/crates/fuel-core/src/schema/tx/types.rs +++ b/crates/fuel-core/src/schema/tx/types.rs @@ -25,6 +25,7 @@ use crate::{ Tai64Timestamp, TransactionId, TxPointer, + U16, U32, U64, }, @@ -45,7 +46,6 @@ use fuel_core_types::{ fuel_tx::{ self, field::{ - BytecodeLength, BytecodeWitnessIndex, InputContract, Inputs, @@ -541,21 +541,11 @@ impl Transaction { } } - async fn bytecode_witness_index(&self) -> Option { + async fn bytecode_witness_index(&self) -> Option { match &self.0 { fuel_tx::Transaction::Script(_) => None, fuel_tx::Transaction::Create(create) => { - Some(*create.bytecode_witness_index()) - } - fuel_tx::Transaction::Mint(_) => None, - } - } - - async fn bytecode_length(&self) -> Option { - match &self.0 { - fuel_tx::Transaction::Script(_) => None, - fuel_tx::Transaction::Create(create) => { - Some((*create.bytecode_length()).into()) + Some((*create.bytecode_witness_index()).into()) } fuel_tx::Transaction::Mint(_) => None, } diff --git a/crates/fuel-core/src/service/adapters/consensus_module/poa.rs b/crates/fuel-core/src/service/adapters/consensus_module/poa.rs index 32220003fc6..713ac2e6cc4 100644 --- a/crates/fuel-core/src/service/adapters/consensus_module/poa.rs +++ b/crates/fuel-core/src/service/adapters/consensus_module/poa.rs @@ -24,7 +24,6 @@ use fuel_core_poa::{ use fuel_core_services::stream::BoxStream; use fuel_core_storage::transactional::Changes; use fuel_core_types::{ - fuel_asm::Word, fuel_tx::TxId, fuel_types::BlockHeight, services::{ @@ -107,19 +106,16 @@ impl fuel_core_poa::ports::BlockProducer for BlockProducerAdapter { height: BlockHeight, block_time: Tai64, source: TransactionsSource, - max_gas: Word, ) -> anyhow::Result> { match source { TransactionsSource::TxPool => { self.block_producer - .produce_and_execute_block_txpool(height, block_time, max_gas) + .produce_and_execute_block_txpool(height, block_time) .await } TransactionsSource::SpecificTransactions(txs) => { self.block_producer - .produce_and_execute_block_transactions( - height, block_time, txs, max_gas, - ) + .produce_and_execute_block_transactions(height, block_time, txs) .await } } diff --git a/crates/fuel-core/src/service/adapters/producer.rs b/crates/fuel-core/src/service/adapters/producer.rs index 499f4be510d..11fbc8287fc 100644 --- a/crates/fuel-core/src/service/adapters/producer.rs +++ b/crates/fuel-core/src/service/adapters/producer.rs @@ -101,14 +101,12 @@ impl fuel_core_producer::ports::Executor> for ExecutorAdapter { transactions_source, gas_price, coinbase_recipient, - gas_limit, } = component; self._execute_without_commit(ExecutionTypes::Production(Components { header_to_produce, transactions_source: OnceTransactionsSource::new(transactions_source), gas_price, coinbase_recipient, - gas_limit, })) } } diff --git a/crates/fuel-core/src/service/config.rs b/crates/fuel-core/src/service/config.rs index a1d6f397671..e6e7012f227 100644 --- a/crates/fuel-core/src/service/config.rs +++ b/crates/fuel-core/src/service/config.rs @@ -1,8 +1,6 @@ use clap::ValueEnum; use fuel_core_chain_config::{ - default_consensus_dev_key, ChainConfig, - StateConfig, StateReader, }; use fuel_core_types::{ @@ -10,10 +8,7 @@ use fuel_core_types::{ secrecy::Secret, }; use std::{ - net::{ - Ipv4Addr, - SocketAddr, - }, + net::SocketAddr, time::Duration, }; use strum_macros::{ @@ -75,9 +70,10 @@ pub struct Config { } impl Config { + #[cfg(feature = "test-helpers")] pub fn local_node() -> Self { let chain_config = ChainConfig::local_testnet(); - let state_config = StateConfig::local_testnet(); + let state_config = fuel_core_chain_config::StateConfig::local_testnet(); let block_importer = fuel_core_importer::Config::new(&chain_config); let state_reader = StateReader::in_memory(state_config.clone()); @@ -95,7 +91,7 @@ impl Config { }; Self { - addr: SocketAddr::new(Ipv4Addr::new(127, 0, 0, 1).into(), 0), + addr: SocketAddr::new(std::net::Ipv4Addr::new(127, 0, 0, 1).into(), 0), api_request_timeout: Duration::from_secs(60), combined_db_config, debug: true, @@ -121,7 +117,9 @@ impl Config { p2p: Some(P2PConfig::::default("test_network")), #[cfg(feature = "p2p")] sync: fuel_core_sync::Config::default(), - consensus_key: Some(Secret::new(default_consensus_dev_key().into())), + consensus_key: Some(Secret::new( + fuel_core_chain_config::default_consensus_dev_key().into(), + )), name: String::default(), relayer_consensus_config: Default::default(), min_connected_reserved_peers: 0, @@ -144,10 +142,12 @@ impl Config { self.txpool.chain_config = self.chain_config.clone(); } - if self.block_importer.chain_id != self.chain_config.consensus_parameters.chain_id + if self.block_importer.chain_id + != self.chain_config.consensus_parameters.chain_id() { tracing::warn!("The `ChainConfig` of `BlockImporter` was inconsistent"); - self.block_importer.chain_id = self.chain_config.consensus_parameters.chain_id + self.block_importer.chain_id = + self.chain_config.consensus_parameters.chain_id() } if self.txpool.utxo_validation != self.utxo_validation { @@ -167,7 +167,6 @@ impl From<&Config> for fuel_core_poa::Config { fn from(config: &Config) -> Self { fuel_core_poa::Config { trigger: config.block_production, - block_gas_limit: config.chain_config.block_gas_limit, signing_key: config.consensus_key.clone(), metrics: false, consensus_params: config.chain_config.consensus_parameters.clone(), diff --git a/crates/fuel-core/src/service/query.rs b/crates/fuel-core/src/service/query.rs index 15b915daffb..ff6eea42806 100644 --- a/crates/fuel-core/src/service/query.rs +++ b/crates/fuel-core/src/service/query.rs @@ -47,7 +47,7 @@ impl FuelService { .config .chain_config .consensus_parameters - .chain_id); + .chain_id()); let stream = self.transaction_status_change(id)?; self.submit(tx).await?; Ok(stream) @@ -63,7 +63,7 @@ impl FuelService { .config .chain_config .consensus_parameters - .chain_id); + .chain_id()); let stream = self.transaction_status_change(id)?.filter(|status| { futures::future::ready(!matches!(status, Ok(TransactionStatus::Submitted(_)))) }); diff --git a/crates/fuel-core/src/service/sub_services.rs b/crates/fuel-core/src/service/sub_services.rs index 49e7819eb4e..e073c490a0e 100644 --- a/crates/fuel-core/src/service/sub_services.rs +++ b/crates/fuel-core/src/service/sub_services.rs @@ -63,7 +63,6 @@ pub fn init_sub_services( database.on_chain().clone(), database.relayer().clone(), fuel_core_upgradable_executor::config::Config { - consensus_parameters: config.chain_config.consensus_parameters.clone(), backtrace: config.vm.backtrace, utxo_validation_default: config.utxo_validation, }, @@ -101,7 +100,7 @@ pub fn init_sub_services( #[cfg(feature = "p2p")] let mut network = config.p2p.clone().map(|p2p_config| { fuel_core_p2p::service::new_service( - config.chain_config.consensus_parameters.chain_id, + config.chain_config.consensus_parameters.chain_id(), p2p_config, database.on_chain().clone(), importer_adapter.clone(), @@ -197,7 +196,7 @@ pub fn init_sub_services( tx_pool_adapter.clone(), importer_adapter.clone(), database.off_chain().clone(), - config.chain_config.consensus_parameters.chain_id, + config.chain_config.consensus_parameters.chain_id(), ); let graphql_config = GraphQLConfig { diff --git a/crates/metrics/src/txpool_metrics.rs b/crates/metrics/src/txpool_metrics.rs index 6965f4ff983..c060a01852b 100644 --- a/crates/metrics/src/txpool_metrics.rs +++ b/crates/metrics/src/txpool_metrics.rs @@ -2,10 +2,7 @@ use prometheus_client::{ metrics::histogram::Histogram, registry::Registry, }; -use std::{ - default::Default, - sync::OnceLock, -}; +use std::sync::OnceLock; pub struct TxPoolMetrics { // Attaches each Metric to the Registry diff --git a/crates/services/consensus_module/poa/Cargo.toml b/crates/services/consensus_module/poa/Cargo.toml index 76467e4a0de..3a96a22e015 100644 --- a/crates/services/consensus_module/poa/Cargo.toml +++ b/crates/services/consensus_module/poa/Cargo.toml @@ -21,9 +21,16 @@ tokio-stream = { workspace = true } tracing = { workspace = true } [dev-dependencies] +fuel-core-poa = { path = ".", features = ["test-helpers"] } fuel-core-storage = { path = "./../../../storage", features = ["test-helpers"] } fuel-core-types = { path = "./../../../types", features = ["test-helpers"] } mockall = { workspace = true } rand = { workspace = true } test-case = { workspace = true } tokio = { workspace = true, features = ["full", "test-util"] } + +[features] +test-helpers = [ + "fuel-core-storage/test-helpers", + "fuel-core-types/test-helpers", +] diff --git a/crates/services/consensus_module/poa/src/config.rs b/crates/services/consensus_module/poa/src/config.rs index 5380b3dd75b..07bbc818e20 100644 --- a/crates/services/consensus_module/poa/src/config.rs +++ b/crates/services/consensus_module/poa/src/config.rs @@ -1,6 +1,5 @@ use fuel_core_types::{ blockchain::primitives::SecretKeyWrapper, - fuel_asm::Word, fuel_tx::ConsensusParameters, secrecy::Secret, }; @@ -9,7 +8,6 @@ use tokio::time::Duration; #[derive(Debug, Clone)] pub struct Config { pub trigger: Trigger, - pub block_gas_limit: Word, pub signing_key: Option>, pub metrics: bool, pub consensus_params: ConsensusParameters, @@ -17,11 +15,11 @@ pub struct Config { pub time_until_synced: Duration, } +#[cfg(feature = "test-helpers")] impl Default for Config { fn default() -> Self { Config { trigger: Trigger::default(), - block_gas_limit: 0, signing_key: None, metrics: false, consensus_params: ConsensusParameters::default(), diff --git a/crates/services/consensus_module/poa/src/ports.rs b/crates/services/consensus_module/poa/src/ports.rs index e3d7519078f..41ed8ad4adb 100644 --- a/crates/services/consensus_module/poa/src/ports.rs +++ b/crates/services/consensus_module/poa/src/ports.rs @@ -8,7 +8,6 @@ use fuel_core_types::{ header::BlockHeader, primitives::DaBlockHeight, }, - fuel_asm::Word, fuel_tx::{ Transaction, TxId, @@ -59,7 +58,6 @@ pub trait BlockProducer: Send + Sync { height: BlockHeight, block_time: Tai64, source: TransactionsSource, - max_gas: Word, ) -> anyhow::Result>; } diff --git a/crates/services/consensus_module/poa/src/service.rs b/crates/services/consensus_module/poa/src/service.rs index 296d8ceeae9..0266de90631 100644 --- a/crates/services/consensus_module/poa/src/service.rs +++ b/crates/services/consensus_module/poa/src/service.rs @@ -41,7 +41,6 @@ use fuel_core_types::{ primitives::SecretKeyWrapper, SealedBlock, }, - fuel_asm::Word, fuel_crypto::Signature, fuel_tx::{ Transaction, @@ -130,7 +129,6 @@ pub(crate) enum RequestType { } pub struct MainTask { - block_gas_limit: Word, signing_key: Option>, block_producer: B, block_importer: I, @@ -169,7 +167,6 @@ where let peer_connections_stream = p2p_port.reserved_peers_count(); let Config { - block_gas_limit, signing_key, min_connected_reserved_peers, time_until_synced, @@ -188,7 +185,6 @@ where let sync_task_handle = ServiceRunner::new(sync_task); Self { - block_gas_limit, signing_key, txpool, block_producer, @@ -259,7 +255,7 @@ where source: TransactionsSource, ) -> anyhow::Result> { self.block_producer - .produce_and_execute_block(height, block_time, source, self.block_gas_limit) + .produce_and_execute_block(height, block_time, source) .await } diff --git a/crates/services/consensus_module/poa/src/service_test.rs b/crates/services/consensus_module/poa/src/service_test.rs index c864a5187c0..a9aacc3531f 100644 --- a/crates/services/consensus_module/poa/src/service_test.rs +++ b/crates/services/consensus_module/poa/src/service_test.rs @@ -119,7 +119,7 @@ impl TestContextBuilder { let mut producer = MockBlockProducer::default(); producer .expect_produce_and_execute_block() - .returning(|_, _, _, _| { + .returning(|_, _, _| { Ok(UncommittedResult::new( ExecutionResult { block: Default::default(), @@ -249,7 +249,7 @@ impl MockTransactionPool { fn make_tx(rng: &mut StdRng) -> Script { TransactionBuilder::script(vec![], vec![]) .max_fee_limit(0) - .script_gas_limit(rng.gen_range(1..TxParameters::DEFAULT.max_gas_per_tx)) + .script_gas_limit(rng.gen_range(1..TxParameters::DEFAULT.max_gas_per_tx())) .finalize_without_signature() } @@ -269,7 +269,7 @@ async fn remove_skipped_transactions() { block_producer .expect_produce_and_execute_block() .times(1) - .returning(move |_, _, _, _| { + .returning(move |_, _, _| { Ok(UncommittedResult::new( ExecutionResult { block: Default::default(), @@ -325,7 +325,6 @@ async fn remove_skipped_transactions() { let config = Config { trigger: Trigger::Instant, - block_gas_limit: 1000000, signing_key: Some(Secret::new(secret_key.into())), metrics: false, ..Default::default() @@ -356,7 +355,7 @@ async fn does_not_produce_when_txpool_empty_in_instant_mode() { block_producer .expect_produce_and_execute_block() - .returning(|_, _, _, _| panic!("Block production should not be called")); + .returning(|_, _, _| panic!("Block production should not be called")); let mut block_importer = MockBlockImporter::default(); @@ -373,7 +372,6 @@ async fn does_not_produce_when_txpool_empty_in_instant_mode() { let config = Config { trigger: Trigger::Instant, - block_gas_limit: 1000000, signing_key: Some(Secret::new(secret_key.into())), metrics: false, ..Default::default() diff --git a/crates/services/consensus_module/poa/src/service_test/manually_produce_tests.rs b/crates/services/consensus_module/poa/src/service_test/manually_produce_tests.rs index c562d61c288..1acbe0f5fa6 100644 --- a/crates/services/consensus_module/poa/src/service_test/manually_produce_tests.rs +++ b/crates/services/consensus_module/poa/src/service_test/manually_produce_tests.rs @@ -53,7 +53,6 @@ async fn can_manually_produce_block( let consensus_params = ConsensusParameters::default(); ctx_builder.with_config(Config { trigger, - block_gas_limit: 100_000, signing_key: Some(test_signing_key()), metrics: false, consensus_params: consensus_params.clone(), @@ -83,7 +82,7 @@ async fn can_manually_produce_block( let mut producer = MockBlockProducer::default(); producer .expect_produce_and_execute_block() - .returning(|_, time, _, _| { + .returning(|_, time, _| { let mut block = Block::default(); block.header_mut().set_time(time); block.header_mut().recalculate_metadata(); @@ -107,7 +106,7 @@ async fn can_manually_produce_block( .await .unwrap(); for tx in txs { - status_sender.send_replace(Some(tx.id(&consensus_params.chain_id))); + status_sender.send_replace(Some(tx.id(&consensus_params.chain_id()))); } for t in times.into_iter() { diff --git a/crates/services/consensus_module/poa/src/service_test/trigger_tests.rs b/crates/services/consensus_module/poa/src/service_test/trigger_tests.rs index 38dff25db33..dd42ecf94fd 100644 --- a/crates/services/consensus_module/poa/src/service_test/trigger_tests.rs +++ b/crates/services/consensus_module/poa/src/service_test/trigger_tests.rs @@ -12,7 +12,6 @@ async fn clean_startup_shutdown_each_trigger() -> anyhow::Result<()> { let mut ctx_builder = TestContextBuilder::new(); ctx_builder.with_config(Config { trigger, - block_gas_limit: 100_000, signing_key: Some(test_signing_key()), metrics: false, ..Default::default() @@ -33,7 +32,6 @@ async fn never_trigger_never_produces_blocks() { let consensus_params = ConsensusParameters::default(); ctx_builder.with_config(Config { trigger: Trigger::Never, - block_gas_limit: 100_000, signing_key: Some(test_signing_key()), metrics: false, consensus_params: consensus_params.clone(), @@ -59,7 +57,7 @@ async fn never_trigger_never_produces_blocks() { ctx_builder.with_importer(importer); let ctx = ctx_builder.build(); for tx in txs { - status_sender.send_replace(Some(tx.id(&consensus_params.chain_id))); + status_sender.send_replace(Some(tx.id(&consensus_params.chain_id()))); } // Make sure enough time passes for the block to be produced @@ -120,7 +118,6 @@ impl DefaultContext { async fn instant_trigger_produces_block_instantly() { let mut ctx = DefaultContext::new(Config { trigger: Trigger::Instant, - block_gas_limit: 100_000, signing_key: Some(test_signing_key()), metrics: false, ..Default::default() @@ -140,7 +137,6 @@ async fn interval_trigger_produces_blocks_periodically() -> anyhow::Result<()> { trigger: Trigger::Interval { block_time: Duration::new(2, 0), }, - block_gas_limit: 100_000, signing_key: Some(test_signing_key()), metrics: false, ..Default::default() @@ -206,7 +202,6 @@ async fn interval_trigger_doesnt_react_to_full_txpool() -> anyhow::Result<()> { trigger: Trigger::Interval { block_time: Duration::new(2, 0), }, - block_gas_limit: 100_000, signing_key: Some(test_signing_key()), metrics: false, ..Default::default() diff --git a/crates/services/consensus_module/poa/src/verifier/tests.rs b/crates/services/consensus_module/poa/src/verifier/tests.rs index 9865b915b4b..1666a1e401c 100644 --- a/crates/services/consensus_module/poa/src/verifier/tests.rs +++ b/crates/services/consensus_module/poa/src/verifier/tests.rs @@ -1,5 +1,6 @@ use super::*; -use crate::ports::MockDatabase; +use crate as fuel_core_poa; +use fuel_core_poa::ports::MockDatabase; use fuel_core_types::{ blockchain::header::{ ApplicationHeader, diff --git a/crates/services/executor/src/executor.rs b/crates/services/executor/src/executor.rs index a4f29f19fcc..9daf8ae0974 100644 --- a/crates/services/executor/src/executor.rs +++ b/crates/services/executor/src/executor.rs @@ -13,6 +13,7 @@ use fuel_core_storage::{ structured_storage::StructuredStorage, tables::{ Coins, + ConsensusParametersVersions, ContractsLatestUtxo, FuelBlocks, Messages, @@ -22,6 +23,7 @@ use fuel_core_storage::{ transactional::{ Changes, ConflictPolicy, + IntoTransaction, Modifiable, ReadTransaction, StorageTransaction, @@ -189,11 +191,6 @@ pub struct ExecutionOptions { pub utxo_validation: bool, /// Print execution backtraces if transaction execution reverts. pub backtrace: bool, - // TODO: It is a temporary workaround to pass the `consensus_params` - // into the WASM executor. Later WASM will fetch it from the storage directly. - // https://github.com/FuelLabs/fuel-core/issues/1753 - /// The configuration allows overriding the default consensus parameters. - pub consensus_params: Option, } /// The executor instance performs block production and validation. Given a block, it will execute all @@ -204,7 +201,6 @@ pub struct ExecutionOptions { pub struct ExecutionInstance { pub relayer: R, pub database: D, - pub consensus_params: ConsensusParameters, pub options: ExecutionOptions, } @@ -233,7 +229,6 @@ pub mod block_component { pub transactions_source: TxSource, pub coinbase_contract_id: ContractId, pub gas_price: u64, - pub gas_limit: u64, /// The private marker to allow creation of the type only by constructor. _marker: core::marker::PhantomData<()>, } @@ -253,7 +248,6 @@ pub mod block_component { transactions_source: OnceTransactionsSource::new(transaction), coinbase_contract_id, gas_price, - gas_limit: u64::MAX, _marker: Default::default(), } } @@ -265,7 +259,6 @@ pub mod block_component { transactions_source: TxSource, coinbase_contract_id: ContractId, gas_price: u64, - gas_limit: u64, ) -> Self { debug_assert!(block.transactions.is_empty()); PartialBlockComponent { @@ -273,7 +266,6 @@ pub mod block_component { transactions_source, gas_price, coinbase_contract_id, - gas_limit, _marker: Default::default(), } } @@ -304,37 +296,56 @@ where ExecutionTypes::DryRun(component) => { let mut block = PartialFuelBlock::new(component.header_to_produce, vec![]); + let block_executor = BlockExecutor::new( + self.relayer, + self.database, + self.options, + &block, + )?; let component = PartialBlockComponent::from_component( &mut block, component.transactions_source, component.coinbase_recipient, component.gas_price, - component.gas_limit, ); - let execution_data = - self.execute_block(ExecutionType::DryRun(component))?; + block_executor.execute_block(ExecutionType::DryRun(component))?; + (block, execution_data) } ExecutionTypes::Production(component) => { let mut block = PartialFuelBlock::new(component.header_to_produce, vec![]); + let block_executor = BlockExecutor::new( + self.relayer, + self.database, + self.options, + &block, + )?; + let component = PartialBlockComponent::from_component( &mut block, component.transactions_source, component.coinbase_recipient, component.gas_price, - component.gas_limit, ); let execution_data = - self.execute_block(ExecutionType::Production(component))?; + block_executor.execute_block(ExecutionType::Production(component))?; + (block, execution_data) } ExecutionTypes::Validation(mut block) => { + let block_executor = BlockExecutor::new( + self.relayer, + self.database, + self.options, + &block, + )?; + let component = PartialBlockComponent::from_partial_block(&mut block); let execution_data = - self.execute_block(ExecutionType::Validation(component))?; + block_executor.execute_block(ExecutionType::Validation(component))?; (block, execution_data) } }; @@ -382,20 +393,63 @@ where // Get the complete fuel block. Ok(UncommittedResult::new(result, changes)) } +} + +#[derive(Clone, Debug)] +pub struct BlockExecutor { + relayer: R, + block_st_transaction: StorageTransaction, + consensus_params: ConsensusParameters, + options: ExecutionOptions, +} + +impl BlockExecutor +where + D: KeyValueInspect, +{ + pub fn new( + relayer: R, + database: D, + options: ExecutionOptions, + block: &PartialFuelBlock, + ) -> ExecutorResult { + let consensus_params_version = block.header.consensus_parameters_version; + + let block_st_transaction = database + .into_transaction() + .with_policy(ConflictPolicy::Overwrite); + let consensus_params = block_st_transaction + .storage::() + .get(&consensus_params_version)? + .ok_or(ExecutorError::ConsensusParametersNotFound( + consensus_params_version, + ))? + .into_owned(); + + Ok(Self { + relayer, + block_st_transaction, + consensus_params, + options, + }) + } +} +impl BlockExecutor +where + R: RelayerPort, + D: KeyValueInspect, +{ #[tracing::instrument(skip_all)] /// Execute the fuel block with all transactions. fn execute_block( - &self, + mut self, block: ExecutionType>, ) -> ExecutorResult where TxSource: TransactionsSource, { - let mut block_st_transaction = self - .database - .read_transaction() - .with_policy(ConflictPolicy::Overwrite); + let block_gas_limit = self.consensus_params.block_gas_limit(); let mut data = ExecutionData { coinbase: 0, used_gas: 0, @@ -416,17 +470,17 @@ where let source = component.transactions_source; let gas_price = component.gas_price; let coinbase_contract_id = component.coinbase_contract_id; - let mut remaining_gas_limit = component.gas_limit; + let mut remaining_gas_limit = block_gas_limit; let block_height = *block.header.height(); if self.relayer.enabled() { - self.process_da(&mut block_st_transaction, &block.header, execution_data)?; + self.process_da(&block.header, execution_data)?; } // The block level storage transaction that also contains data from the relayer. // Starting from this point, modifications from each thread should be independent // and shouldn't touch the same data. - let mut block_with_relayer_data_transaction = block_st_transaction.write_transaction() + let mut block_with_relayer_data_transaction = self.block_st_transaction.read_transaction() // Enforces independent changes from each thread. .with_policy(ConflictPolicy::Fail); @@ -449,7 +503,7 @@ where let mut tx_st_transaction = thread_block_transaction .write_transaction() .with_policy(ConflictPolicy::Overwrite); - let tx_id = tx.id(&self.consensus_params.chain_id); + let tx_id = tx.id(&self.consensus_params.chain_id()); let result = self.execute_transaction( tx, &tx_id, @@ -500,8 +554,7 @@ where execute_transaction(&mut *execution_data, transaction)?; } - remaining_gas_limit = - component.gas_limit.saturating_sub(execution_data.used_gas); + remaining_gas_limit = block_gas_limit.saturating_sub(execution_data.used_gas); iter = source.next(remaining_gas_limit).into_iter().peekable(); } @@ -529,7 +582,7 @@ where state_root: Bytes32::zeroed(), }, amount_to_mint, - self.consensus_params.base_asset_id, + *self.consensus_params.base_asset_id(), gas_price, ); @@ -541,32 +594,30 @@ where let changes_from_thread = thread_block_transaction.into_changes(); block_with_relayer_data_transaction.commit_changes(changes_from_thread)?; - block_with_relayer_data_transaction.commit()?; + self.block_st_transaction + .commit_changes(block_with_relayer_data_transaction.into_changes())?; if execution_kind != ExecutionKind::DryRun && !data.found_mint { return Err(ExecutorError::MintMissing) } - data.changes = block_st_transaction.into_changes(); + data.changes = self.block_st_transaction.into_changes(); Ok(data) } - fn process_da( - &self, - block_st_transaction: &mut StorageTransaction, + fn process_da( + &mut self, header: &PartialBlockHeader, execution_data: &mut ExecutionData, - ) -> ExecutorResult<()> - where - T: KeyValueInspect, - { + ) -> ExecutorResult<()> { let block_height = *header.height(); let prev_block_height = block_height .pred() .ok_or(ExecutorError::ExecutingGenesisBlock)?; - let prev_block_header = block_st_transaction + let prev_block_header = self + .block_st_transaction .storage::() .get(&prev_block_height)? .ok_or(ExecutorError::PreviousBlockIsNotFound)?; @@ -590,8 +641,8 @@ where if message.da_height() != da_height { return Err(ExecutorError::RelayerGivesIncorrectMessages) } - block_st_transaction - .storage::() + self.block_st_transaction + .storage_as_mut::() .insert(message.nonce(), &message)?; execution_data .events @@ -868,7 +919,7 @@ where )?; // validate transaction signature checked_tx = checked_tx - .check_signatures(&self.consensus_params.chain_id) + .check_signatures(&self.consensus_params.chain_id()) .map_err(TransactionValidityError::from)?; debug_assert!(checked_tx.checks().contains(Checks::Signatures)); } @@ -899,8 +950,8 @@ where InterpreterParams::new(gas_price, &self.consensus_params), ); - let gas_costs = &self.consensus_params.gas_costs; - let fee_params = &self.consensus_params.fee_params; + let gas_costs = self.consensus_params.gas_costs(); + let fee_params = self.consensus_params.fee_params(); let ready_tx = checked_tx .clone() @@ -918,8 +969,8 @@ where let (state, mut tx, receipts): (_, Tx, _) = vm_result.into_inner(); #[cfg(debug_assertions)] { - tx.precompute(&self.consensus_params.chain_id)?; - debug_assert_eq!(tx.id(&self.consensus_params.chain_id), tx_id); + tx.precompute(&self.consensus_params.chain_id())?; + debug_assert_eq!(tx.id(&self.consensus_params.chain_id()), tx_id); } for (original_input, produced_input) in checked_tx @@ -1467,8 +1518,8 @@ where { let tx_idx = execution_data.tx_count; for (output_index, output) in outputs.iter().enumerate() { - let index = u8::try_from(output_index) - .expect("Transaction can have only up to `u8::MAX` outputs"); + let index = u16::try_from(output_index) + .expect("Transaction can have only up to `u16::MAX` outputs"); let utxo_id = UtxoId::new(*tx_id, index); match output { Output::Coin { diff --git a/crates/services/executor/src/refs/contract.rs b/crates/services/executor/src/refs/contract.rs index 8917c702297..d75f7018c50 100644 --- a/crates/services/executor/src/refs/contract.rs +++ b/crates/services/executor/src/refs/contract.rs @@ -156,7 +156,7 @@ where // `ContractId` already is based on contract's code and salt so we don't need it. .chain(contract_id.as_ref()) .chain(utxo.tx_id().as_ref()) - .chain([utxo.output_index()]) + .chain(utxo.output_index().to_be_bytes()) .chain(state_root.as_slice()) .chain(balance_root.as_slice()) .finalize(); diff --git a/crates/services/importer/src/config.rs b/crates/services/importer/src/config.rs index 0e9d938be93..20250a4dc26 100644 --- a/crates/services/importer/src/config.rs +++ b/crates/services/importer/src/config.rs @@ -13,7 +13,7 @@ impl Config { Self { max_block_notify_buffer: 1 << 10, metrics: false, - chain_id: chain_config.consensus_parameters.chain_id, + chain_id: chain_config.consensus_parameters.chain_id(), } } } diff --git a/crates/services/producer/src/block_producer.rs b/crates/services/producer/src/block_producer.rs index 16492f6b779..f4eb19e942e 100644 --- a/crates/services/producer/src/block_producer.rs +++ b/crates/services/producer/src/block_producer.rs @@ -21,7 +21,6 @@ use fuel_core_types::{ }, primitives::DaBlockHeight, }, - fuel_asm::Word, fuel_tx::Transaction, fuel_types::{ BlockHeight, @@ -98,7 +97,6 @@ where height: BlockHeight, block_time: Tai64, tx_source: impl FnOnce(BlockHeight) -> TxSource, - max_gas: Word, ) -> anyhow::Result> where Executor: ports::Executor + 'static, @@ -128,7 +126,6 @@ where transactions_source: source, coinbase_recipient: self.config.coinbase_recipient.unwrap_or_default(), gas_price, - gas_limit: max_gas, }; // Store the context string in case we error. @@ -159,14 +156,10 @@ where &self, height: BlockHeight, block_time: Tai64, - max_gas: Word, ) -> anyhow::Result> { - self.produce_and_execute( - height, - block_time, - |height| self.txpool.get_source(height), - max_gas, - ) + self.produce_and_execute(height, block_time, |height| { + self.txpool.get_source(height) + }) .await } } @@ -185,9 +178,8 @@ where height: BlockHeight, block_time: Tai64, transactions: Vec, - max_gas: Word, ) -> anyhow::Result> { - self.produce_and_execute(height, block_time, |_| transactions, max_gas) + self.produce_and_execute(height, block_time, |_| transactions) .await } } @@ -234,7 +226,6 @@ where transactions_source: transactions.clone(), coinbase_recipient: self.config.coinbase_recipient.unwrap_or_default(), gas_price, - gas_limit: u64::MAX, }; let executor = self.executor.clone(); diff --git a/crates/services/producer/src/block_producer/tests.rs b/crates/services/producer/src/block_producer/tests.rs index 9366a71f225..5103ba0a160 100644 --- a/crates/services/producer/src/block_producer/tests.rs +++ b/crates/services/producer/src/block_producer/tests.rs @@ -76,7 +76,7 @@ mod produce_and_execute_block_txpool { let producer = ctx.producer(); let err = producer - .produce_and_execute_block_txpool(0u32.into(), Tai64::now(), 1_000_000_000) + .produce_and_execute_block_txpool(0u32.into(), Tai64::now()) .await .expect_err("expected failure"); @@ -95,7 +95,7 @@ mod produce_and_execute_block_txpool { let producer = ctx.producer(); let result = producer - .produce_and_execute_block_txpool(1u32.into(), Tai64::now(), 1_000_000_000) + .produce_and_execute_block_txpool(1u32.into(), Tai64::now()) .await; assert!(result.is_ok()); @@ -139,7 +139,6 @@ mod produce_and_execute_block_txpool { .succ() .expect("The block height should be valid"), Tai64::now(), - 1_000_000_000, ) .await; @@ -185,7 +184,6 @@ mod produce_and_execute_block_txpool { .succ() .expect("The block height should be valid"), Tai64::now(), - 1_000_000_000, ) .await .expect("Should produce next block successfully") @@ -238,7 +236,6 @@ mod produce_and_execute_block_txpool { .succ() .expect("The block height should be valid"), Tai64::now(), - 1_000_000_000, ) .await .expect("Should produce next block successfully") @@ -259,7 +256,7 @@ mod produce_and_execute_block_txpool { let producer = ctx.producer(); let err = producer - .produce_and_execute_block_txpool(100u32.into(), Tai64::now(), 1_000_000_000) + .produce_and_execute_block_txpool(100u32.into(), Tai64::now()) .await .expect_err("expected failure"); @@ -310,7 +307,6 @@ mod produce_and_execute_block_txpool { .succ() .expect("The block height should be valid"), Tai64::now(), - 1_000_000_000, ) .await .expect_err("expected failure"); @@ -336,7 +332,7 @@ mod produce_and_execute_block_txpool { let producer = ctx.producer(); let err = producer - .produce_and_execute_block_txpool(1u32.into(), Tai64::now(), 1_000_000_000) + .produce_and_execute_block_txpool(1u32.into(), Tai64::now()) .await .expect_err("expected failure"); @@ -363,7 +359,7 @@ mod produce_and_execute_block_txpool { // when let _ = producer - .produce_and_execute_block_txpool(1u32.into(), Tai64::now(), 1_000_000_000) + .produce_and_execute_block_txpool(1u32.into(), Tai64::now()) .await .unwrap(); @@ -387,7 +383,7 @@ mod produce_and_execute_block_txpool { // when let result = producer - .produce_and_execute_block_txpool(1u32.into(), Tai64::now(), 1_000_000_000) + .produce_and_execute_block_txpool(1u32.into(), Tai64::now()) .await; // then diff --git a/crates/services/producer/src/mocks.rs b/crates/services/producer/src/mocks.rs index ece2ed0673d..185a775591a 100644 --- a/crates/services/producer/src/mocks.rs +++ b/crates/services/producer/src/mocks.rs @@ -122,7 +122,7 @@ fn to_block(component: &Components>) -> Block { .map(|tx| tx.as_ref().into()) .collect(); Block::new( - component.header_to_produce.clone(), + component.header_to_produce, transactions, &[], Default::default(), diff --git a/crates/services/txpool/Cargo.toml b/crates/services/txpool/Cargo.toml index 296cfeedf5f..8fa684e9a13 100644 --- a/crates/services/txpool/Cargo.toml +++ b/crates/services/txpool/Cargo.toml @@ -40,4 +40,5 @@ tokio = { workspace = true, features = ["sync", "test-util"] } test-helpers = [ "fuel-core-types/test-helpers", "fuel-core-storage/test-helpers", + "fuel-core-chain-config/test-helpers", ] diff --git a/crates/services/txpool/src/config.rs b/crates/services/txpool/src/config.rs index d14033d65c0..6f92be657d7 100644 --- a/crates/services/txpool/src/config.rs +++ b/crates/services/txpool/src/config.rs @@ -76,6 +76,7 @@ pub struct Config { pub blacklist: BlackList, } +#[cfg(feature = "test-helpers")] impl Default for Config { fn default() -> Self { let max_tx = 4064; diff --git a/crates/services/txpool/src/containers/dependency.rs b/crates/services/txpool/src/containers/dependency.rs index 165d65355a4..84d53cec3fc 100644 --- a/crates/services/txpool/src/containers/dependency.rs +++ b/crates/services/txpool/src/containers/dependency.rs @@ -531,7 +531,7 @@ impl Dependency { // iterate over all outputs and insert them, marking them as available. for (index, output) in tx.outputs().iter().enumerate() { - let index = u8::try_from(index).map_err(|_| { + let index = u16::try_from(index).map_err(|_| { Error::Other(format!( "The number of outputs in `{}` is more than `u8::max`", tx.id() @@ -586,7 +586,7 @@ impl Dependency { // no other transactions can depend on these types of outputs } Output::Coin { .. } | Output::Change { .. } | Output::Variable { .. } => { - let index = u8::try_from(index) + let index = u16::try_from(index) .expect("The number of outputs is more than `u8::max`. \ But it should be impossible because we don't include transactions with so many outputs."); // remove transactions that depend on this coin output diff --git a/crates/services/txpool/src/service.rs b/crates/services/txpool/src/service.rs index f6ac475c35c..cd5053bc76d 100644 --- a/crates/services/txpool/src/service.rs +++ b/crates/services/txpool/src/service.rs @@ -232,7 +232,7 @@ where new_transaction = self.gossiped_tx_stream.next() => { if let Some(GossipData { data: Some(tx), message_id, peer_id }) = new_transaction { - let id = tx.id(&self.tx_pool_shared_state.consensus_params.chain_id); + let id = tx.id(&self.tx_pool_shared_state.consensus_params.chain_id()); let current_height = *self.tx_pool_shared_state.current_height.lock(); // verify tx diff --git a/crates/services/txpool/src/transaction_selector.rs b/crates/services/txpool/src/transaction_selector.rs index a148df39d55..ef4ab001b83 100644 --- a/crates/services/txpool/src/transaction_selector.rs +++ b/crates/services/txpool/src/transaction_selector.rs @@ -78,10 +78,9 @@ mod tests { fn make_txs_and_select(txs: &[TxGas], block_gas_limit: Word) -> Vec { let mut rng = thread_rng(); - let fee_params = FeeParameters { - gas_price_factor: 1, - gas_per_byte: 0, - }; + let fee_params = FeeParameters::default() + .with_gas_per_byte(0) + .with_gas_price_factor(1); let mut txs = txs .iter() diff --git a/crates/services/txpool/src/txpool.rs b/crates/services/txpool/src/txpool.rs index 4e575f41aa2..8dfe4224051 100644 --- a/crates/services/txpool/src/txpool.rs +++ b/crates/services/txpool/src/txpool.rs @@ -372,10 +372,15 @@ where } // verify max gas is less than block limit - if tx.max_gas() > self.config.chain_config.block_gas_limit { + let block_gas_limit = self + .config + .chain_config + .consensus_parameters + .block_gas_limit(); + if tx.max_gas() > block_gas_limit { return Err(Error::NotInsertedMaxGasLimit { tx_gas: tx.max_gas(), - block_limit: self.config.chain_config.block_gas_limit, + block_limit: block_gas_limit, }) } @@ -516,7 +521,7 @@ pub async fn check_single_tx( let tx = tx .into_checked_basic(current_height, consensus_params)? - .check_signatures(&consensus_params.chain_id)?; + .check_signatures(&consensus_params.chain_id())?; let tx = tx .check_predicates_async::(&CheckPredicateParams::from( @@ -546,8 +551,8 @@ fn verify_tx_min_gas_price( gas_price: GasPrice, ) -> Result, Error> { let tx: CheckedTransaction = tx.into(); - let gas_costs = &config.chain_config.consensus_parameters.gas_costs; - let fee_parameters = &config.chain_config.consensus_parameters.fee_params; + let gas_costs = config.chain_config.consensus_parameters.gas_costs(); + let fee_parameters = config.chain_config.consensus_parameters.fee_params(); let read = match tx { CheckedTransaction::Script(script) => { let ready = script.into_ready(gas_price, gas_costs, fee_parameters)?; diff --git a/crates/services/txpool/src/txpool/test_helpers.rs b/crates/services/txpool/src/txpool/test_helpers.rs index 7b25ca7ef32..0b2e0d9ea8a 100644 --- a/crates/services/txpool/src/txpool/test_helpers.rs +++ b/crates/services/txpool/src/txpool/test_helpers.rs @@ -51,7 +51,7 @@ pub(crate) fn create_coin_output() -> Output { pub(crate) fn create_contract_input( tx_id: TxId, - output_index: u8, + output_index: u16, contract_id: ContractId, ) -> Input { Input::contract( diff --git a/crates/services/txpool/src/txpool/tests.rs b/crates/services/txpool/src/txpool/tests.rs index d131ad64aea..2ea3640129c 100644 --- a/crates/services/txpool/src/txpool/tests.rs +++ b/crates/services/txpool/src/txpool/tests.rs @@ -40,7 +40,13 @@ use fuel_core_types::{ }; use crate::types::GasPrice; -use fuel_core_types::fuel_tx::Finalizable; +use fuel_core_chain_config::ChainConfig; +use fuel_core_types::fuel_tx::{ + ConsensusParameters, + Finalizable, + PredicateParameters, + TxParameters, +}; use std::{ cmp::Reverse, collections::HashMap, @@ -1180,17 +1186,23 @@ async fn predicates_with_incorrect_owner_fails() { #[tokio::test] async fn predicate_without_enough_gas_returns_out_of_gas() { let mut context = TextContext::default(); - let mut config = Config::default(); - config - .chain_config - .consensus_parameters - .predicate_params - .max_gas_per_predicate = 10000; - config - .chain_config - .consensus_parameters - .tx_params - .max_gas_per_tx = 10000; + + let gas_limit = 10000; + + let mut consensus_parameters = ConsensusParameters::default(); + consensus_parameters + .set_tx_params(TxParameters::default().with_max_gas_per_tx(gas_limit)); + consensus_parameters.set_predicate_params( + PredicateParameters::default().with_max_gas_per_predicate(gas_limit), + ); + let config = Config { + chain_config: ChainConfig { + consensus_parameters, + ..Default::default() + }, + ..Default::default() + }; + let coin = context .custom_predicate( AssetId::BASE, diff --git a/crates/services/upgradable-executor/build.rs b/crates/services/upgradable-executor/build.rs index c4a6f9eaa02..3bbd314cba2 100644 --- a/crates/services/upgradable-executor/build.rs +++ b/crates/services/upgradable-executor/build.rs @@ -1,3 +1,4 @@ +#[cfg(feature = "wasm-executor")] use std::{ env, path::{ @@ -8,15 +9,15 @@ use std::{ }; fn main() { - let wasm_executor_enabled = env::var_os("CARGO_FEATURE_WASM_EXECUTOR").is_some(); - println!("cargo:rerun-if-changed=build.rs"); - println!("cargo:rerun-if-changed=wasm-executor/src/*"); + println!("cargo:rerun-if-changed=wasm-executor/src/main.rs"); - if !wasm_executor_enabled { - return; - } + #[cfg(feature = "wasm-executor")] + build_wasm() +} +#[cfg(feature = "wasm-executor")] +fn build_wasm() { let out_dir = env::var_os("OUT_DIR").unwrap(); let dest_path = Path::new(&out_dir); @@ -59,6 +60,7 @@ fn main() { } } +#[cfg(feature = "wasm-executor")] fn project_root() -> PathBuf { Path::new(&env!("CARGO_MANIFEST_DIR")) .ancestors() diff --git a/crates/services/upgradable-executor/src/config.rs b/crates/services/upgradable-executor/src/config.rs index bf2e0140cee..b51de7e0441 100644 --- a/crates/services/upgradable-executor/src/config.rs +++ b/crates/services/upgradable-executor/src/config.rs @@ -1,12 +1,7 @@ use fuel_core_executor::executor::ExecutionOptions; -use fuel_core_types::fuel_tx::ConsensusParameters; #[derive(Clone, Debug, Default)] pub struct Config { - /// Network-wide common parameters used for validating the chain. - /// The executor already has these parameters, and this field allows us - /// to override the existing value. - pub consensus_parameters: ConsensusParameters, /// Print execution backtraces if transaction execution reverts. pub backtrace: bool, /// Default mode for utxo_validation @@ -18,7 +13,6 @@ impl From<&Config> for ExecutionOptions { Self { utxo_validation: value.utxo_validation_default, backtrace: value.backtrace, - consensus_params: Some(value.consensus_parameters.clone()), } } } diff --git a/crates/services/upgradable-executor/src/executor.rs b/crates/services/upgradable-executor/src/executor.rs index a86d2266316..639342780b2 100644 --- a/crates/services/upgradable-executor/src/executor.rs +++ b/crates/services/upgradable-executor/src/executor.rs @@ -148,7 +148,6 @@ where transactions_source: OnceTransactionsSource::new(block.transactions), coinbase_recipient, gas_price, - gas_limit: u64::MAX, }), ExecutionTypes::Validation(block) => ExecutionTypes::Validation(block), }; @@ -191,7 +190,6 @@ where let options = ExecutionOptions { utxo_validation, backtrace: self.config.backtrace, - consensus_params: Some(self.config.consensus_parameters.clone()), }; let component = Components { @@ -201,7 +199,6 @@ where ), coinbase_recipient: Default::default(), gas_price: component.gas_price, - gas_limit: component.gas_limit, }; let ExecutionResult { @@ -251,7 +248,6 @@ where transactions_source, coinbase_recipient, gas_price, - gas_limit, } = component; source = Some(transactions_source); @@ -261,7 +257,6 @@ where transactions_source: (), coinbase_recipient, gas_price, - gas_limit, } }); @@ -281,22 +276,17 @@ where fn native_execute_inner( &self, block: ExecutionBlockWithSource, - mut options: ExecutionOptions, + options: ExecutionOptions, ) -> ExecutorResult> where TxSource: TransactionsSource + Send + Sync + 'static, { let storage = self.storage_view_provider.latest_view(); let relayer = self.relayer_view_provider.latest_view(); - let consensus_params = options - .consensus_params - .take() - .unwrap_or_else(|| self.config.consensus_parameters.clone()); let instance = fuel_core_executor::executor::ExecutionInstance { relayer, database: storage, - consensus_params, options, }; instance.execute_without_commit(block) diff --git a/crates/services/upgradable-executor/wasm-executor/src/main.rs b/crates/services/upgradable-executor/wasm-executor/src/main.rs index af08ebc08dd..6bfdea914f9 100644 --- a/crates/services/upgradable-executor/wasm-executor/src/main.rs +++ b/crates/services/upgradable-executor/wasm-executor/src/main.rs @@ -23,16 +23,13 @@ use crate::{ }, }; use fuel_core_executor::executor::ExecutionInstance; -use fuel_core_types::{ - fuel_tx::ConsensusParameters, - services::{ - block_producer::Components, - executor::{ - Error as ExecutorError, - ExecutionResult, - }, - Uncommitted, +use fuel_core_types::services::{ + block_producer::Components, + executor::{ + Error as ExecutorError, + ExecutionResult, }, + Uncommitted, }; use fuel_core_wasm_executor as _; @@ -56,27 +53,18 @@ pub extern "C" fn execute(component_len: u32, options_len: u32) -> u64 { pub fn execute_without_commit(component_len: u32, options_len: u32) -> ReturnType { let block = ext::input_component(component_len as usize) .map_err(|e| ExecutorError::Other(e.to_string()))?; - let mut options = ext::input_options(options_len as usize) + let options = ext::input_options(options_len as usize) .map_err(|e| ExecutorError::Other(e.to_string()))?; - let consensus_params = if let Some(consensus_params) = options.consensus_params.take() - { - consensus_params - } else { - ConsensusParameters::default() - }; - let instance = ExecutionInstance { relayer: WasmRelayer {}, database: WasmStorage {}, - consensus_params, options, }; let block = block.map_p(|component| { let Components { header_to_produce, - gas_limit, gas_price, coinbase_recipient, .. @@ -84,7 +72,6 @@ pub fn execute_without_commit(component_len: u32, options_len: u32) -> ReturnTyp Components { header_to_produce, - gas_limit, gas_price, transactions_source: WasmTxSource::new(), coinbase_recipient, diff --git a/crates/storage/src/codec/manual.rs b/crates/storage/src/codec/manual.rs index 34a93566cdd..17e1431d282 100644 --- a/crates/storage/src/codec/manual.rs +++ b/crates/storage/src/codec/manual.rs @@ -3,48 +3,5 @@ //! types that don't follow any patterns from other codecs. Anyone can implement //! a codec like that, and it's more of an example of how it can be done for foreign types. -use crate::codec::{ - Decode, - Encode, -}; -use fuel_core_types::fuel_vm::{ - ContractsAssetKey, - ContractsStateKey, -}; -use std::borrow::Cow; - /// The codec allows the definition of manual implementation for specific type `T`. pub struct Manual(core::marker::PhantomData); - -// TODO: Use `Raw` instead of `Manual` for `ContractsAssetKey`, `ContractsStateKey`, and `OwnedMessageKey` -// when `double_key` macro will generate `TryFrom<&[u8]>` implementation. - -impl Encode for Manual { - type Encoder<'a> = Cow<'a, [u8]>; - - fn encode(t: &ContractsAssetKey) -> Self::Encoder<'_> { - Cow::Borrowed(t.as_ref()) - } -} - -impl Decode for Manual { - fn decode(bytes: &[u8]) -> anyhow::Result { - ContractsAssetKey::from_slice(bytes) - .map_err(|_| anyhow::anyhow!("Unable to decode bytes")) - } -} - -impl Encode for Manual { - type Encoder<'a> = Cow<'a, [u8]>; - - fn encode(t: &ContractsStateKey) -> Self::Encoder<'_> { - Cow::Borrowed(t.as_ref()) - } -} - -impl Decode for Manual { - fn decode(bytes: &[u8]) -> anyhow::Result { - ContractsStateKey::from_slice(bytes) - .map_err(|_| anyhow::anyhow!("Unable to decode bytes")) - } -} diff --git a/crates/storage/src/codec/primitive.rs b/crates/storage/src/codec/primitive.rs index 4f39ddb982f..815a7d0e7f8 100644 --- a/crates/storage/src/codec/primitive.rs +++ b/crates/storage/src/codec/primitive.rs @@ -76,25 +76,26 @@ impl Decode for Primitive<8> { } /// Converts the `UtxoId` into an array of bytes. -pub fn utxo_id_to_bytes(utxo_id: &UtxoId) -> [u8; TxId::LEN + 1] { - let mut default = [0; TxId::LEN + 1]; +pub fn utxo_id_to_bytes(utxo_id: &UtxoId) -> [u8; TxId::LEN + 2] { + let mut default = [0; TxId::LEN + 2]; default[0..TxId::LEN].copy_from_slice(utxo_id.tx_id().as_ref()); - default[TxId::LEN] = utxo_id.output_index(); + default[TxId::LEN..].copy_from_slice(utxo_id.output_index().to_be_bytes().as_slice()); default } -impl Encode for Primitive<{ TxId::LEN + 1 }> { - type Encoder<'a> = [u8; TxId::LEN + 1]; +impl Encode for Primitive<{ TxId::LEN + 2 }> { + type Encoder<'a> = [u8; TxId::LEN + 2]; fn encode(t: &UtxoId) -> Self::Encoder<'_> { utxo_id_to_bytes(t) } } -impl Decode for Primitive<{ TxId::LEN + 1 }> { +impl Decode for Primitive<{ TxId::LEN + 2 }> { fn decode(bytes: &[u8]) -> anyhow::Result { - let bytes = <[u8; TxId::LEN + 1]>::try_from(bytes)?; + let bytes = <[u8; TxId::LEN + 2]>::try_from(bytes)?; let tx_id: [u8; TxId::LEN] = bytes[0..TxId::LEN].try_into()?; - Ok(UtxoId::new(TxId::from(tx_id), bytes[TxId::LEN])) + let output_index = u16::from_be_bytes(bytes[TxId::LEN..].try_into()?); + Ok(UtxoId::new(TxId::from(tx_id), output_index)) } } diff --git a/crates/storage/src/structured_storage/balances.rs b/crates/storage/src/structured_storage/balances.rs index 4d26b0e19f0..89be009b1a1 100644 --- a/crates/storage/src/structured_storage/balances.rs +++ b/crates/storage/src/structured_storage/balances.rs @@ -6,8 +6,8 @@ use crate::{ Sparse, }, codec::{ - manual::Manual, primitive::Primitive, + raw::Raw, }, column::Column, structured_storage::TableWithBlueprint, @@ -20,7 +20,6 @@ use crate::{ }, Mappable, }; -use fuel_core_types::fuel_vm::ContractsAssetKey; /// The key convertor used to convert the key from the `ContractsAssets` table /// to the key of the `ContractsAssetsMerkleMetadata` table. @@ -37,7 +36,7 @@ impl PrimaryKey for KeyConverter { impl TableWithBlueprint for ContractsAssets { type Blueprint = Sparse< - Manual, + Raw, Primitive<8>, ContractsAssetsMerkleMetadata, ContractsAssetsMerkleData, diff --git a/crates/storage/src/structured_storage/coins.rs b/crates/storage/src/structured_storage/coins.rs index 759f2c774a8..58ac2cf7e3f 100644 --- a/crates/storage/src/structured_storage/coins.rs +++ b/crates/storage/src/structured_storage/coins.rs @@ -12,7 +12,7 @@ use crate::{ }; impl TableWithBlueprint for Coins { - type Blueprint = Plain, Postcard>; + type Blueprint = Plain, Postcard>; type Column = Column; fn column() -> Column { diff --git a/crates/storage/src/structured_storage/state.rs b/crates/storage/src/structured_storage/state.rs index 68d5d79ef65..6fceb6b1d78 100644 --- a/crates/storage/src/structured_storage/state.rs +++ b/crates/storage/src/structured_storage/state.rs @@ -5,10 +5,7 @@ use crate::{ PrimaryKey, Sparse, }, - codec::{ - manual::Manual, - raw::Raw, - }, + codec::raw::Raw, column::Column, structured_storage::TableWithBlueprint, tables::{ @@ -20,7 +17,6 @@ use crate::{ }, Mappable, }; -use fuel_core_types::fuel_vm::ContractsStateKey; /// The key convertor used to convert the key from the `ContractsState` table /// to the key of the `ContractsStateMerkleMetadata` table. @@ -37,7 +33,7 @@ impl PrimaryKey for KeyConverter { impl TableWithBlueprint for ContractsState { type Blueprint = Sparse< - Manual, + Raw, Raw, ContractsStateMerkleMetadata, ContractsStateMerkleData, diff --git a/crates/types/src/blockchain/header.rs b/crates/types/src/blockchain/header.rs index 32154fb310a..843be807059 100644 --- a/crates/types/src/blockchain/header.rs +++ b/crates/types/src/blockchain/header.rs @@ -146,7 +146,7 @@ impl BlockHeader { } } -#[derive(Clone, Debug)] +#[derive(Copy, Clone, Debug)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(any(test, feature = "test-helpers"), derive(Default))] /// A partially complete fuel block header that doesn't not diff --git a/crates/types/src/services/block_producer.rs b/crates/types/src/services/block_producer.rs index d1e03335e32..429371b22b9 100644 --- a/crates/types/src/services/block_producer.rs +++ b/crates/types/src/services/block_producer.rs @@ -19,6 +19,4 @@ pub struct Components { pub coinbase_recipient: ContractId, /// The gas price for all transactions in the block. pub gas_price: u64, - /// The gas limit of the block. - pub gas_limit: u64, } diff --git a/crates/types/src/services/executor.rs b/crates/types/src/services/executor.rs index 78ae5bdd514..d8c10c1f17c 100644 --- a/crates/types/src/services/executor.rs +++ b/crates/types/src/services/executor.rs @@ -6,6 +6,7 @@ use crate::{ Block, PartialFuelBlock, }, + header::ConsensusParametersVersion, primitives::BlockId, }, entities::{ @@ -355,6 +356,8 @@ pub enum Error { PreviousBlockIsNotFound, #[display(fmt = "The relayer gives incorrect messages for the requested da height")] RelayerGivesIncorrectMessages, + #[display(fmt = "Consensus parameters not found for version {_0}")] + ConsensusParametersNotFound(ConsensusParametersVersion), /// It is possible to occur untyped errors in the case of the upgrade. #[display(fmt = "Occurred untyped error: {_0}")] Other(String), diff --git a/deployment/scripts/chainspec/dev-testnet/chain_config.json b/deployment/scripts/chainspec/dev-testnet/chain_config.json index 6b47b6e4b7d..494b88a2d63 100644 --- a/deployment/scripts/chainspec/dev-testnet/chain_config.json +++ b/deployment/scripts/chainspec/dev-testnet/chain_config.json @@ -1,251 +1,266 @@ { "chain_name": "Upgradable Dev Testnet", - "block_gas_limit": 1000000000, "consensus_parameters": { - "tx_params": { - "max_inputs": 255, - "max_outputs": 255, - "max_witnesses": 255, - "max_gas_per_tx": 1000000000, - "max_size": 17825792 - }, - "predicate_params": { - "max_predicate_length": 1048576, - "max_predicate_data_length": 1048576, - "max_message_data_length": 1048576, - "max_gas_per_predicate": 1000000000 - }, - "script_params": { - "max_script_length": 1048576, - "max_script_data_length": 1048576 - }, - "contract_params": { - "contract_max_size": 16777216, - "max_storage_slots": 131072 - }, - "fee_params": { - "gas_price_factor": 92, - "gas_per_byte": 63 - }, - "chain_id": 0, - "gas_costs": { - "add": 2, - "addi": 2, - "aloc": 1, - "and": 2, - "andi": 2, - "bal": 366, - "bhei": 2, - "bhsh": 2, - "burn": 33949, - "cb": 2, - "cfei": 2, - "cfsi": 2, - "div": 2, - "divi": 2, - "eck1": 3347, - "ecr1": 46165, - "ed19": 4210, - "eq": 2, - "exp": 2, - "expi": 2, - "flag": 1, - "gm": 2, - "gt": 2, - "gtf": 16, - "ji": 2, - "jmp": 2, - "jne": 2, - "jnei": 2, - "jnzi": 2, - "jmpf": 2, - "jmpb": 2, - "jnzf": 2, - "jnzb": 2, - "jnef": 2, - "jneb": 2, - "lb": 2, - "log": 754, - "lt": 2, - "lw": 2, - "mint": 35718, - "mlog": 2, - "mod": 2, - "modi": 2, - "move": 2, - "movi": 2, - "mroo": 5, - "mul": 2, - "muli": 2, - "mldv": 4, - "noop": 1, - "not": 2, - "or": 2, - "ori": 2, - "poph": 3, - "popl": 3, - "pshh": 4, - "pshl": 4, - "ret_contract": 733, - "rvrt_contract": 722, - "sb": 2, - "sll": 2, - "slli": 2, - "srl": 2, - "srli": 2, - "srw": 253, - "sub": 2, - "subi": 2, - "sw": 2, - "sww": 29053, - "time": 79, - "tr": 46242, - "tro": 33251, - "wdcm": 3, - "wqcm": 3, - "wdop": 3, - "wqop": 3, - "wdml": 3, - "wqml": 4, - "wddv": 5, - "wqdv": 7, - "wdmd": 11, - "wqmd": 18, - "wdam": 9, - "wqam": 12, - "wdmm": 11, - "wqmm": 11, - "xor": 2, - "xori": 2, - "call": { - "LightOperation": { - "base": 21687, - "units_per_gas": 4 + "V1": { + "tx_params": { + "V1": { + "max_inputs": 255, + "max_outputs": 255, + "max_witnesses": 255, + "max_gas_per_tx": 1000000000, + "max_size": 17825792 } }, - "ccp": { - "LightOperation": { - "base": 59, - "units_per_gas": 20 + "predicate_params": { + "V1": { + "max_predicate_length": 1048576, + "max_predicate_data_length": 1048576, + "max_message_data_length": 1048576, + "max_gas_per_predicate": 1000000000 } }, - "croo": { - "LightOperation": { - "base": 1, - "units_per_gas": 1 + "script_params": { + "V1": { + "max_script_length": 1048576, + "max_script_data_length": 1048576 } }, - "csiz": { - "LightOperation": { - "base": 59, - "units_per_gas": 195 + "contract_params": { + "V1": { + "contract_max_size": 16777216, + "max_storage_slots": 131072 } }, - "k256": { - "LightOperation": { - "base": 282, - "units_per_gas": 3 + "fee_params": { + "V1": { + "gas_price_factor": 92, + "gas_per_byte": 63 } }, - "ldc": { - "LightOperation": { - "base": 45, - "units_per_gas": 65 + "chain_id": 0, + "gas_costs": { + "V1": { + "add": 2, + "addi": 2, + "aloc": 1, + "and": 2, + "andi": 2, + "bal": 366, + "bhei": 2, + "bhsh": 2, + "burn": 33949, + "cb": 2, + "cfei": 2, + "cfsi": 2, + "div": 2, + "divi": 2, + "eck1": 3347, + "ecr1": 46165, + "ed19": 4210, + "eq": 2, + "exp": 2, + "expi": 2, + "flag": 1, + "gm": 2, + "gt": 2, + "gtf": 16, + "ji": 2, + "jmp": 2, + "jne": 2, + "jnei": 2, + "jnzi": 2, + "jmpf": 2, + "jmpb": 2, + "jnzf": 2, + "jnzb": 2, + "jnef": 2, + "jneb": 2, + "lb": 2, + "log": 754, + "lt": 2, + "lw": 2, + "mint": 35718, + "mlog": 2, + "mod": 2, + "modi": 2, + "move": 2, + "movi": 2, + "mroo": 5, + "mul": 2, + "muli": 2, + "mldv": 4, + "noop": 1, + "not": 2, + "or": 2, + "ori": 2, + "poph": 3, + "popl": 3, + "pshh": 4, + "pshl": 4, + "ret_contract": 733, + "rvrt_contract": 722, + "sb": 2, + "sll": 2, + "slli": 2, + "srl": 2, + "srli": 2, + "srw": 253, + "sub": 2, + "subi": 2, + "sw": 2, + "sww": 29053, + "time": 79, + "tr": 46242, + "tro": 33251, + "wdcm": 3, + "wqcm": 3, + "wdop": 3, + "wqop": 3, + "wdml": 3, + "wqml": 4, + "wddv": 5, + "wqdv": 7, + "wdmd": 11, + "wqmd": 18, + "wdam": 9, + "wqam": 12, + "wdmm": 11, + "wqmm": 11, + "xor": 2, + "xori": 2, + "call": { + "LightOperation": { + "base": 21687, + "units_per_gas": 4 + } + }, + "ccp": { + "LightOperation": { + "base": 59, + "units_per_gas": 20 + } + }, + "croo": { + "LightOperation": { + "base": 1, + "units_per_gas": 1 + } + }, + "csiz": { + "LightOperation": { + "base": 59, + "units_per_gas": 195 + } + }, + "k256": { + "LightOperation": { + "base": 282, + "units_per_gas": 3 + } + }, + "ldc": { + "LightOperation": { + "base": 45, + "units_per_gas": 65 + } + }, + "logd": { + "LightOperation": { + "base": 1134, + "units_per_gas": 2 + } + }, + "mcl": { + "LightOperation": { + "base": 3, + "units_per_gas": 523 + } + }, + "mcli": { + "LightOperation": { + "base": 3, + "units_per_gas": 526 + } + }, + "mcp": { + "LightOperation": { + "base": 3, + "units_per_gas": 448 + } + }, + "mcpi": { + "LightOperation": { + "base": 7, + "units_per_gas": 585 + } + }, + "meq": { + "LightOperation": { + "base": 11, + "units_per_gas": 1097 + } + }, + "retd_contract": { + "LightOperation": { + "base": 1086, + "units_per_gas": 2 + } + }, + "s256": { + "LightOperation": { + "base": 45, + "units_per_gas": 3 + } + }, + "scwq": { + "HeavyOperation": { + "base": 30375, + "gas_per_unit": 28628 + } + }, + "smo": { + "LightOperation": { + "base": 64196, + "units_per_gas": 1 + } + }, + "srwq": { + "HeavyOperation": { + "base": 262, + "gas_per_unit": 249 + } + }, + "swwq": { + "HeavyOperation": { + "base": 28484, + "gas_per_unit": 26613 + } + }, + "contract_root": { + "LightOperation": { + "base": 45, + "units_per_gas": 1 + } + }, + "state_root": { + "HeavyOperation": { + "base": 350, + "gas_per_unit": 176 + } + }, + "new_storage_per_byte": 63, + "vm_initialization": { + "LightOperation": { + "base": 1645, + "units_per_gas": 14 + } + } } }, - "logd": { - "LightOperation": { - "base": 1134, - "units_per_gas": 2 - } - }, - "mcl": { - "LightOperation": { - "base": 3, - "units_per_gas": 523 - } - }, - "mcli": { - "LightOperation": { - "base": 3, - "units_per_gas": 526 - } - }, - "mcp": { - "LightOperation": { - "base": 3, - "units_per_gas": 448 - } - }, - "mcpi": { - "LightOperation": { - "base": 7, - "units_per_gas": 585 - } - }, - "meq": { - "LightOperation": { - "base": 11, - "units_per_gas": 1097 - } - }, - "retd_contract": { - "LightOperation": { - "base": 1086, - "units_per_gas": 2 - } - }, - "s256": { - "LightOperation": { - "base": 45, - "units_per_gas": 3 - } - }, - "scwq": { - "HeavyOperation": { - "base": 30375, - "gas_per_unit": 28628 - } - }, - "smo": { - "LightOperation": { - "base": 64196, - "units_per_gas": 1 - } - }, - "srwq": { - "HeavyOperation": { - "base": 262, - "gas_per_unit": 249 - } - }, - "swwq": { - "HeavyOperation": { - "base": 28484, - "gas_per_unit": 26613 - } - }, - "contract_root": { - "LightOperation": { - "base": 45, - "units_per_gas": 1 - } - }, - "state_root": { - "HeavyOperation": { - "base": 350, - "gas_per_unit": 176 - } - }, - "new_storage_per_byte": 63, - "vm_initialization": { - "LightOperation": { - "base": 1645, - "units_per_gas": 14 - } - } - }, - "base_asset_id": "0000000000000000000000000000000000000000000000000000000000000000" + "base_asset_id": "0000000000000000000000000000000000000000000000000000000000000000", + "block_gas_limit": 1000000000, + "privileged_address": "0000000000000000000000000000000000000000000000000000000000000000" + } }, "consensus": { "PoA": { diff --git a/deployment/scripts/chainspec/testnet/chain_config.json b/deployment/scripts/chainspec/testnet/chain_config.json index dd2609d2162..525e6f5ef4a 100644 --- a/deployment/scripts/chainspec/testnet/chain_config.json +++ b/deployment/scripts/chainspec/testnet/chain_config.json @@ -1,251 +1,266 @@ { "chain_name": "Upgradable Testnet", - "block_gas_limit": 30000000, "consensus_parameters": { - "tx_params": { - "max_inputs": 255, - "max_outputs": 255, - "max_witnesses": 255, - "max_gas_per_tx": 30000000, - "max_size": 112640 - }, - "predicate_params": { - "max_predicate_length": 102400, - "max_predicate_data_length": 102400, - "max_message_data_length": 102400, - "max_gas_per_predicate": 30000000 - }, - "script_params": { - "max_script_length": 102400, - "max_script_data_length": 102400 - }, - "contract_params": { - "contract_max_size": 102400, - "max_storage_slots": 1760 - }, - "fee_params": { - "gas_price_factor": 92, - "gas_per_byte": 63 - }, - "chain_id": 0, - "gas_costs": { - "add": 2, - "addi": 2, - "aloc": 1, - "and": 2, - "andi": 2, - "bal": 366, - "bhei": 2, - "bhsh": 2, - "burn": 33949, - "cb": 2, - "cfei": 2, - "cfsi": 2, - "div": 2, - "divi": 2, - "eck1": 3347, - "ecr1": 46165, - "ed19": 4210, - "eq": 2, - "exp": 2, - "expi": 2, - "flag": 1, - "gm": 2, - "gt": 2, - "gtf": 16, - "ji": 2, - "jmp": 2, - "jne": 2, - "jnei": 2, - "jnzi": 2, - "jmpf": 2, - "jmpb": 2, - "jnzf": 2, - "jnzb": 2, - "jnef": 2, - "jneb": 2, - "lb": 2, - "log": 754, - "lt": 2, - "lw": 2, - "mint": 35718, - "mlog": 2, - "mod": 2, - "modi": 2, - "move": 2, - "movi": 2, - "mroo": 5, - "mul": 2, - "muli": 2, - "mldv": 4, - "noop": 1, - "not": 2, - "or": 2, - "ori": 2, - "poph": 3, - "popl": 3, - "pshh": 4, - "pshl": 4, - "ret_contract": 733, - "rvrt_contract": 722, - "sb": 2, - "sll": 2, - "slli": 2, - "srl": 2, - "srli": 2, - "srw": 253, - "sub": 2, - "subi": 2, - "sw": 2, - "sww": 29053, - "time": 79, - "tr": 46242, - "tro": 33251, - "wdcm": 3, - "wqcm": 3, - "wdop": 3, - "wqop": 3, - "wdml": 3, - "wqml": 4, - "wddv": 5, - "wqdv": 7, - "wdmd": 11, - "wqmd": 18, - "wdam": 9, - "wqam": 12, - "wdmm": 11, - "wqmm": 11, - "xor": 2, - "xori": 2, - "call": { - "LightOperation": { - "base": 21687, - "units_per_gas": 4 + "V1": { + "tx_params": { + "V1": { + "max_inputs": 255, + "max_outputs": 255, + "max_witnesses": 255, + "max_gas_per_tx": 30000000, + "max_size": 112640 } }, - "ccp": { - "LightOperation": { - "base": 59, - "units_per_gas": 20 + "predicate_params": { + "V1": { + "max_predicate_length": 102400, + "max_predicate_data_length": 102400, + "max_message_data_length": 102400, + "max_gas_per_predicate": 30000000 } }, - "croo": { - "LightOperation": { - "base": 1, - "units_per_gas": 1 + "script_params": { + "V1": { + "max_script_length": 102400, + "max_script_data_length": 102400 } }, - "csiz": { - "LightOperation": { - "base": 59, - "units_per_gas": 195 + "contract_params": { + "V1": { + "contract_max_size": 102400, + "max_storage_slots": 1760 } }, - "k256": { - "LightOperation": { - "base": 282, - "units_per_gas": 3 + "fee_params": { + "V1": { + "gas_price_factor": 92, + "gas_per_byte": 63 } }, - "ldc": { - "LightOperation": { - "base": 45, - "units_per_gas": 65 + "chain_id": 0, + "gas_costs": { + "V1": { + "add": 2, + "addi": 2, + "aloc": 1, + "and": 2, + "andi": 2, + "bal": 366, + "bhei": 2, + "bhsh": 2, + "burn": 33949, + "cb": 2, + "cfei": 2, + "cfsi": 2, + "div": 2, + "divi": 2, + "eck1": 3347, + "ecr1": 46165, + "ed19": 4210, + "eq": 2, + "exp": 2, + "expi": 2, + "flag": 1, + "gm": 2, + "gt": 2, + "gtf": 16, + "ji": 2, + "jmp": 2, + "jne": 2, + "jnei": 2, + "jnzi": 2, + "jmpf": 2, + "jmpb": 2, + "jnzf": 2, + "jnzb": 2, + "jnef": 2, + "jneb": 2, + "lb": 2, + "log": 754, + "lt": 2, + "lw": 2, + "mint": 35718, + "mlog": 2, + "mod": 2, + "modi": 2, + "move": 2, + "movi": 2, + "mroo": 5, + "mul": 2, + "muli": 2, + "mldv": 4, + "noop": 1, + "not": 2, + "or": 2, + "ori": 2, + "poph": 3, + "popl": 3, + "pshh": 4, + "pshl": 4, + "ret_contract": 733, + "rvrt_contract": 722, + "sb": 2, + "sll": 2, + "slli": 2, + "srl": 2, + "srli": 2, + "srw": 253, + "sub": 2, + "subi": 2, + "sw": 2, + "sww": 29053, + "time": 79, + "tr": 46242, + "tro": 33251, + "wdcm": 3, + "wqcm": 3, + "wdop": 3, + "wqop": 3, + "wdml": 3, + "wqml": 4, + "wddv": 5, + "wqdv": 7, + "wdmd": 11, + "wqmd": 18, + "wdam": 9, + "wqam": 12, + "wdmm": 11, + "wqmm": 11, + "xor": 2, + "xori": 2, + "call": { + "LightOperation": { + "base": 21687, + "units_per_gas": 4 + } + }, + "ccp": { + "LightOperation": { + "base": 59, + "units_per_gas": 20 + } + }, + "croo": { + "LightOperation": { + "base": 1, + "units_per_gas": 1 + } + }, + "csiz": { + "LightOperation": { + "base": 59, + "units_per_gas": 195 + } + }, + "k256": { + "LightOperation": { + "base": 282, + "units_per_gas": 3 + } + }, + "ldc": { + "LightOperation": { + "base": 45, + "units_per_gas": 65 + } + }, + "logd": { + "LightOperation": { + "base": 1134, + "units_per_gas": 2 + } + }, + "mcl": { + "LightOperation": { + "base": 3, + "units_per_gas": 523 + } + }, + "mcli": { + "LightOperation": { + "base": 3, + "units_per_gas": 526 + } + }, + "mcp": { + "LightOperation": { + "base": 3, + "units_per_gas": 448 + } + }, + "mcpi": { + "LightOperation": { + "base": 7, + "units_per_gas": 585 + } + }, + "meq": { + "LightOperation": { + "base": 11, + "units_per_gas": 1097 + } + }, + "retd_contract": { + "LightOperation": { + "base": 1086, + "units_per_gas": 2 + } + }, + "s256": { + "LightOperation": { + "base": 45, + "units_per_gas": 3 + } + }, + "scwq": { + "HeavyOperation": { + "base": 30375, + "gas_per_unit": 28628 + } + }, + "smo": { + "LightOperation": { + "base": 64196, + "units_per_gas": 1 + } + }, + "srwq": { + "HeavyOperation": { + "base": 262, + "gas_per_unit": 249 + } + }, + "swwq": { + "HeavyOperation": { + "base": 28484, + "gas_per_unit": 26613 + } + }, + "contract_root": { + "LightOperation": { + "base": 45, + "units_per_gas": 1 + } + }, + "state_root": { + "HeavyOperation": { + "base": 350, + "gas_per_unit": 176 + } + }, + "new_storage_per_byte": 63, + "vm_initialization": { + "LightOperation": { + "base": 1645, + "units_per_gas": 14 + } + } } }, - "logd": { - "LightOperation": { - "base": 1134, - "units_per_gas": 2 - } - }, - "mcl": { - "LightOperation": { - "base": 3, - "units_per_gas": 523 - } - }, - "mcli": { - "LightOperation": { - "base": 3, - "units_per_gas": 526 - } - }, - "mcp": { - "LightOperation": { - "base": 3, - "units_per_gas": 448 - } - }, - "mcpi": { - "LightOperation": { - "base": 7, - "units_per_gas": 585 - } - }, - "meq": { - "LightOperation": { - "base": 11, - "units_per_gas": 1097 - } - }, - "retd_contract": { - "LightOperation": { - "base": 1086, - "units_per_gas": 2 - } - }, - "s256": { - "LightOperation": { - "base": 45, - "units_per_gas": 3 - } - }, - "scwq": { - "HeavyOperation": { - "base": 30375, - "gas_per_unit": 28628 - } - }, - "smo": { - "LightOperation": { - "base": 64196, - "units_per_gas": 1 - } - }, - "srwq": { - "HeavyOperation": { - "base": 262, - "gas_per_unit": 249 - } - }, - "swwq": { - "HeavyOperation": { - "base": 28484, - "gas_per_unit": 26613 - } - }, - "contract_root": { - "LightOperation": { - "base": 45, - "units_per_gas": 1 - } - }, - "state_root": { - "HeavyOperation": { - "base": 350, - "gas_per_unit": 176 - } - }, - "new_storage_per_byte": 63, - "vm_initialization": { - "LightOperation": { - "base": 1645, - "units_per_gas": 14 - } - } - }, - "base_asset_id": "0000000000000000000000000000000000000000000000000000000000000000" + "base_asset_id": "0000000000000000000000000000000000000000000000000000000000000000", + "block_gas_limit": 30000000, + "privileged_address": "0000000000000000000000000000000000000000000000000000000000000000" + } }, "consensus": { "PoA": { diff --git a/tests/test-helpers/src/builder.rs b/tests/test-helpers/src/builder.rs index 7142af31112..63962ab914c 100644 --- a/tests/test-helpers/src/builder.rs +++ b/tests/test-helpers/src/builder.rs @@ -190,8 +190,12 @@ impl TestSetupBuilder { // setup chainspec and spin up a fuel-node pub async fn finalize(&mut self) -> TestContext { let mut chain_conf = ChainConfig::local_testnet(); - chain_conf.consensus_parameters.tx_params.max_gas_per_tx = self.gas_limit; - chain_conf.block_gas_limit = self.gas_limit; + let tx_params = TxParameters::default(); + tx_params.with_max_gas_per_tx(self.gas_limit); + chain_conf.consensus_parameters.set_tx_params(tx_params); + chain_conf + .consensus_parameters + .set_block_gas_limit(self.gas_limit); let state = StateConfig { coins: self.initial_coins.clone(), diff --git a/tests/tests/chain.rs b/tests/tests/chain.rs index db610e9ac02..ead24913a41 100644 --- a/tests/tests/chain.rs +++ b/tests/tests/chain.rs @@ -46,8 +46,8 @@ async fn chain_info() { ); assert_eq!( - node_config.chain_config.consensus_parameters.gas_costs, - chain_info.consensus_parameters.gas_costs + node_config.chain_config.consensus_parameters.gas_costs(), + chain_info.consensus_parameters.gas_costs() ); } @@ -80,7 +80,10 @@ async fn network_operates_with_non_zero_chain_id() { // Given let chain_id = ChainId::new(0xDEAD); - node_config.chain_config.consensus_parameters.chain_id = chain_id; + node_config + .chain_config + .consensus_parameters + .set_chain_id(chain_id); let srv = FuelService::new_node(node_config.clone()).await.unwrap(); let client = FuelClient::from(srv.bound_address); let script = TransactionBuilder::script(vec![], vec![]) @@ -140,7 +143,10 @@ async fn network_operates_with_non_zero_base_asset_id() { ..Config::local_node() }; - node_config.chain_config.consensus_parameters.base_asset_id = new_base_asset_id; + node_config + .chain_config + .consensus_parameters + .set_base_asset_id(new_base_asset_id); let srv = FuelService::new_node(node_config.clone()).await.unwrap(); let client = FuelClient::from(srv.bound_address); let script = TransactionBuilder::script(vec![], vec![]) diff --git a/tests/tests/coin.rs b/tests/tests/coin.rs index 7d5a9b4c204..769bd261482 100644 --- a/tests/tests/coin.rs +++ b/tests/tests/coin.rs @@ -155,7 +155,7 @@ async fn get_coins_forwards_backwards( owner, amount: i as Word, asset_id, - output_index: i as u8, + output_index: i as u16, ..Default::default() }) .collect(); diff --git a/tests/tests/deployment.rs b/tests/tests/deployment.rs index 035500c6443..ee9f44d2301 100644 --- a/tests/tests/deployment.rs +++ b/tests/tests/deployment.rs @@ -21,7 +21,9 @@ fn test_deployment_chainconfig(path: impl AsRef) -> anyhow::Result<()> { // Deployment configuration should use gas costs from benchmarks. let benchmark_gas_costs = GasCosts::new(fuel_core_benches::default_gas_costs::default_gas_costs()); - chain_config.consensus_parameters.gas_costs = benchmark_gas_costs; + chain_config + .consensus_parameters + .set_gas_costs(benchmark_gas_costs); let temp_dir = tempfile::tempdir()?; let generated_snapshot = SnapshotMetadata::write_json(temp_dir.path())?; diff --git a/tests/tests/example_tx.json b/tests/tests/example_tx.json index 346625301b3..4e0803cebf5 100755 --- a/tests/tests/example_tx.json +++ b/tests/tests/example_tx.json @@ -1,123 +1,147 @@ { - "Script": { - "script_gas_limit": 10000, - "script": [80,64,0,202,80,68,0,186,51,65,16,0,36,4,0,0], - "script_data": [], - "policies": { - "bits": "Maturity | MaxFee", - "values": [0, 0, 0, 0] - }, - "inputs": [ - { - "CoinSigned": { - "utxo_id": { - "tx_id": "c49d65de61cf04588a764b557d25cc6c6b4bc0d7429227e2a21e61c213b3a3e2", - "output_index": 0 - }, - "owner": "f1e92c42b90934aa6372e30bc568a326f6e66a1a0288595e6e3fbd392a4f3e6e", - "amount": 10599410012256088338, - "asset_id": "2cafad611543e0265d89f1c2b60d9ebf5d56ad7e23d9827d6b522fd4d6e44bc3", - "tx_pointer": { - "block_height": 0, - "tx_index": 0 - }, - "witness_index": 0, - "predicate_gas_used": null, - "predicate": null, - "predicate_data": null - } - }, - { - "CoinSigned": { - "utxo_id": { - "tx_id": "c49d65de61cf04588a764b557d25cc6c6b4bc0d7429227e2a21e61c213b3a3e2", - "output_index": 1 - }, - "owner": "f1e92c42b90934aa6372e30bc568a326f6e66a1a0288595e6e3fbd392a4f3e6e", - "amount": 10599410012256088338, - "asset_id": "0000000000000000000000000000000000000000000000000000000000000000", - "tx_pointer": { - "block_height": 0, - "tx_index": 0 - }, - "witness_index": 0, - "predicate_gas_used": null, - "predicate": null, - "predicate_data": null - } - } - ], - "outputs": [], - "witnesses": [ - { - "data": [ - 197, - 10, - 72, - 106, - 127, - 15, - 86, - 133, - 15, - 73, - 201, - 126, - 197, - 108, - 170, - 75, - 13, - 99, - 107, - 130, - 75, - 103, - 171, - 186, - 150, - 79, - 200, - 53, - 108, - 122, - 156, - 188, - 75, - 130, - 96, - 253, - 0, - 70, - 27, - 125, - 159, - 151, - 158, - 55, - 196, - 51, - 204, - 229, - 59, - 148, - 136, - 63, - 187, - 14, - 209, - 167, - 123, - 97, - 90, - 197, - 16, - 143, - 242, - 103 - ] - } - ], - "receipts_root": "0000000000000000000000000000000000000000000000000000000000000000" - } + "Script": { + "body": { + "script_gas_limit": 10000, + "script": [ + 80, + 64, + 0, + 202, + 80, + 68, + 0, + 186, + 51, + 65, + 16, + 0, + 36, + 4, + 0, + 0 + ], + "script_data": [], + "receipts_root": "0000000000000000000000000000000000000000000000000000000000000000" + }, + "policies": { + "bits": "Maturity | MaxFee", + "values": [ + 0, + 0, + 0, + 0 + ] + }, + "inputs": [ + { + "CoinSigned": { + "utxo_id": { + "tx_id": "c49d65de61cf04588a764b557d25cc6c6b4bc0d7429227e2a21e61c213b3a3e2", + "output_index": 0 + }, + "owner": "f1e92c42b90934aa6372e30bc568a326f6e66a1a0288595e6e3fbd392a4f3e6e", + "amount": 10599410012256088338, + "asset_id": "2cafad611543e0265d89f1c2b60d9ebf5d56ad7e23d9827d6b522fd4d6e44bc3", + "tx_pointer": { + "block_height": 0, + "tx_index": 0 + }, + "witness_index": 0, + "predicate_gas_used": null, + "predicate": null, + "predicate_data": null + } + }, + { + "CoinSigned": { + "utxo_id": { + "tx_id": "c49d65de61cf04588a764b557d25cc6c6b4bc0d7429227e2a21e61c213b3a3e2", + "output_index": 1 + }, + "owner": "f1e92c42b90934aa6372e30bc568a326f6e66a1a0288595e6e3fbd392a4f3e6e", + "amount": 10599410012256088338, + "asset_id": "0000000000000000000000000000000000000000000000000000000000000000", + "tx_pointer": { + "block_height": 0, + "tx_index": 0 + }, + "witness_index": 0, + "predicate_gas_used": null, + "predicate": null, + "predicate_data": null + } + } + ], + "outputs": [], + "witnesses": [ + { + "data": [ + 197, + 10, + 72, + 106, + 127, + 15, + 86, + 133, + 15, + 73, + 201, + 126, + 197, + 108, + 170, + 75, + 13, + 99, + 107, + 130, + 75, + 103, + 171, + 186, + 150, + 79, + 200, + 53, + 108, + 122, + 156, + 188, + 75, + 130, + 96, + 253, + 0, + 70, + 27, + 125, + 159, + 151, + 158, + 55, + 196, + 51, + 204, + 229, + 59, + 148, + 136, + 63, + 187, + 14, + 209, + 167, + 123, + 97, + 90, + 197, + 16, + 143, + 242, + 103 + ] + } + ] + } } \ No newline at end of file diff --git a/tests/tests/fee_collection_contract.rs b/tests/tests/fee_collection_contract.rs index d7d2f818c66..4105efc6202 100644 --- a/tests/tests/fee_collection_contract.rs +++ b/tests/tests/fee_collection_contract.rs @@ -69,7 +69,7 @@ async fn setup(rng: &mut StdRng) -> TestContext { create_tx .precompute(&ChainId::default()) .expect("tx should be valid"); - let contract_id = create_tx.metadata().as_ref().unwrap().contract_id; + let contract_id = create_tx.metadata().as_ref().unwrap().body.contract_id; // Start up a node let mut config = Config::local_node();