From 6fa02df2278d757d4ef6dc32ebf213c3b8249537 Mon Sep 17 00:00:00 2001 From: Brandon Vrooman Date: Sun, 11 Feb 2024 22:35:06 -0500 Subject: [PATCH 01/12] Separate Contract salt and root in storage --- Cargo.lock | 16 ---------------- Cargo.toml | 4 ++++ benches/src/lib.rs | 10 ++++------ crates/fuel-core/src/database/contracts.rs | 4 ++-- crates/fuel-core/src/query/contract.rs | 4 ++-- crates/fuel-core/src/service/genesis.rs | 6 +++--- .../storage/src/structured_storage/contracts.rs | 3 ++- crates/storage/src/tables.rs | 1 + crates/storage/src/vm_storage.rs | 6 ++++-- 9 files changed, 22 insertions(+), 32 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f08833f36ef..b5053826c93 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2591,8 +2591,6 @@ dependencies = [ [[package]] name = "fuel-asm" version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb9742c03ebf8a385c4ff06365fc0b34feb2a6c302ad5ea9fa7c2201c97e3787" dependencies = [ "bitflags 2.4.2", "fuel-types", @@ -3129,8 +3127,6 @@ dependencies = [ [[package]] name = "fuel-crypto" version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea44d0234e5f422b1e9102431fadbc544474537ca82f590e7979d49f6c6a9644" dependencies = [ "coins-bip32", "coins-bip39", @@ -3150,8 +3146,6 @@ dependencies = [ [[package]] name = "fuel-derive" version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e14035997d8f28ac078227e72d081020c9383edc82fbf42ddd9ac8da120d71f1" dependencies = [ "proc-macro2", "quote", @@ -3162,8 +3156,6 @@ dependencies = [ [[package]] name = "fuel-merkle" version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "625db7a9d7c06e5ed9a02fcc61214e660bdd8756c19e2b4bb0ed4cb5fea2791b" dependencies = [ "derive_more", "digest 0.10.7", @@ -3177,14 +3169,10 @@ dependencies = [ [[package]] name = "fuel-storage" version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b972d21d92bce35117c2dded7d9c820fc52628c586d4693f97e820c054148581" [[package]] name = "fuel-tx" version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f7ae78697a841869fef2a15ad050682f52874d469440e09732a5b0d18eb10bf" dependencies = [ "bitflags 2.4.2", "derivative", @@ -3205,8 +3193,6 @@ dependencies = [ [[package]] name = "fuel-types" version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bbd77fd02a4390c120b1b5ba6543038965ab1c7aa9797d12cb8dcc5bb1157db" dependencies = [ "fuel-derive", "hex", @@ -3217,8 +3203,6 @@ dependencies = [ [[package]] name = "fuel-vm" version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65b450088ac08da9570fad4a12b42ceae1725921140d95e07a1fbcfa055945b7" dependencies = [ "anyhow", "async-trait", diff --git a/Cargo.toml b/Cargo.toml index 2db2dcc899a..9a2c1e77fff 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -118,3 +118,7 @@ itertools = "0.10" insta = "1.8" tempfile = "3.4" tikv-jemallocator = "0.5" + +[patch.crates-io] +fuel-vm-private = { path = "../fuel-vm/fuel-vm", package = "fuel-vm" } +#fuel-vm-private = { git = 'https://github.com/FuelLabs/fuel-vm', package = "fuel-vm", branch = "bvrooman/feat/versionable-contract-info" } \ No newline at end of file diff --git a/benches/src/lib.rs b/benches/src/lib.rs index 8bef9f52409..39c1b4884d0 100644 --- a/benches/src/lib.rs +++ b/benches/src/lib.rs @@ -175,7 +175,7 @@ impl VmBench { let input = Input::contract(utxo_id, balance_root, state_root, tx_pointer, id); let output = Output::contract(0, rng.gen(), rng.gen()); - db.deploy_contract_with_id(&salt, &[], &contract, &state_root, &id)?; + db.deploy_contract_with_id(&salt, &[], &contract, &id)?; let data = id .iter() @@ -359,7 +359,6 @@ impl TryFrom for VmBenchPrepared { let code = iter::once(op::ret(RegId::ONE)); let code: Vec = code.collect(); let code = Contract::from(code); - let root = code.root(); let input = tx.inputs().len(); let output = @@ -375,16 +374,16 @@ impl TryFrom for VmBenchPrepared { tx.add_input(input); tx.add_output(output); - db.deploy_contract_with_id(&VmBench::SALT, &[], &code, &root, &contract)?; + db.deploy_contract_with_id(&VmBench::SALT, &[], &code, &contract)?; } if let Some(ContractCode { contract, salt, id, - root, slots, storage_root, + .. }) = contract_code { let input_count = tx.inputs().len(); @@ -401,7 +400,7 @@ impl TryFrom for VmBenchPrepared { tx.add_input(input); tx.add_output(output); - db.deploy_contract_with_id(&salt, &slots, &contract, &root, &id)?; + db.deploy_contract_with_id(&salt, &slots, &contract, &id)?; } for contract_id in empty_contracts { @@ -423,7 +422,6 @@ impl TryFrom for VmBenchPrepared { &VmBench::SALT, &[], &Contract::default(), - &Bytes32::zeroed(), &contract_id, )?; } diff --git a/crates/fuel-core/src/database/contracts.rs b/crates/fuel-core/src/database/contracts.rs index f6bb2cbee76..d6a5b136489 100644 --- a/crates/fuel-core/src/database/contracts.rs +++ b/crates/fuel-core/src/database/contracts.rs @@ -35,12 +35,12 @@ impl Database { .into_owned() .into(); - let (salt, _) = self + let salt = *self .storage::() .get(&contract_id) .unwrap() .expect("Contract does not exist") - .into_owned(); + .salt(); let ContractUtxoInfo { utxo_id, diff --git a/crates/fuel-core/src/query/contract.rs b/crates/fuel-core/src/query/contract.rs index d4bbb8b5d62..1a6fd8d47b7 100644 --- a/crates/fuel-core/src/query/contract.rs +++ b/crates/fuel-core/src/query/contract.rs @@ -64,11 +64,11 @@ impl ContractQueryData for D { } fn contract_salt(&self, id: ContractId) -> StorageResult { - let (salt, _) = self + let salt = *self .storage::() .get(&id)? .ok_or(not_found!(ContractsInfo))? - .into_owned(); + .salt(); Ok(salt) } diff --git a/crates/fuel-core/src/service/genesis.rs b/crates/fuel-core/src/service/genesis.rs index 6bcbc50b873..dafbee3e21a 100644 --- a/crates/fuel-core/src/service/genesis.rs +++ b/crates/fuel-core/src/service/genesis.rs @@ -13,6 +13,7 @@ use fuel_core_storage::{ tables::{ Coins, ContractsInfo, + ContractsInfoType, ContractsLatestUtxo, ContractsRawCode, Messages, @@ -234,7 +235,6 @@ fn init_contracts( { let contract = Contract::from(contract_config.code.as_slice()); let salt = contract_config.salt; - let root = contract.root(); let contract_id = contract_config.contract_id; let utxo_id = if let (Some(tx_id), Some(output_idx)) = (contract_config.tx_id, contract_config.output_index) @@ -283,10 +283,10 @@ fn init_contracts( return Err(anyhow!("Contract code should not exist")) } - // insert contract root + // insert contract salt if db .storage::() - .insert(&contract_id, &(salt, root))? + .insert(&contract_id, &ContractsInfoType::V1(salt))? .is_some() { return Err(anyhow!("Contract info should not exist")) diff --git a/crates/storage/src/structured_storage/contracts.rs b/crates/storage/src/structured_storage/contracts.rs index 58bb9c2b884..6db9fb5b20f 100644 --- a/crates/storage/src/structured_storage/contracts.rs +++ b/crates/storage/src/structured_storage/contracts.rs @@ -76,6 +76,7 @@ impl TableWithBlueprint for ContractsLatestUtxo { #[cfg(test)] mod test { use super::*; + use crate::tables::ContractsInfoType; crate::basic_storage_tests!( ContractsRawCode, @@ -87,7 +88,7 @@ mod test { crate::basic_storage_tests!( ContractsInfo, ::Key::from([1u8; 32]), - ([2u8; 32].into(), [3u8; 32].into()) + ContractsInfoType::V1([2u8; 32].into()) ); crate::basic_storage_tests!( diff --git a/crates/storage/src/tables.rs b/crates/storage/src/tables.rs index ce8d98233e0..addde1729bd 100644 --- a/crates/storage/src/tables.rs +++ b/crates/storage/src/tables.rs @@ -26,6 +26,7 @@ use fuel_core_types::{ pub use fuel_vm_private::storage::{ ContractsAssets, ContractsInfo, + ContractsInfoType, ContractsRawCode, ContractsState, }; diff --git a/crates/storage/src/vm_storage.rs b/crates/storage/src/vm_storage.rs index f378e709474..fd2b0e9b480 100644 --- a/crates/storage/src/vm_storage.rs +++ b/crates/storage/src/vm_storage.rs @@ -42,6 +42,7 @@ use fuel_core_types::{ fuel_vm::InterpreterStorage, tai64::Tai64, }; +use fuel_vm_private::storage::ContractsInfoType; use itertools::Itertools; use primitive_types::U256; use std::borrow::Cow; @@ -227,11 +228,12 @@ where salt: &Salt, slots: &[StorageSlot], contract: &Contract, - root: &Bytes32, id: &ContractId, ) -> Result<(), Self::DataError> { self.storage_contract_insert(id, contract)?; - self.storage_contract_root_insert(id, salt, root)?; + + let info = ContractsInfoType::V1(*salt); + self.storage_contract_info_insert(id, &info)?; self.database.init_contract_state( id, From 793b8c719663b119989c29d8c170253152350c14 Mon Sep 17 00:00:00 2001 From: Brandon Vrooman Date: Mon, 26 Feb 2024 18:07:14 -0500 Subject: [PATCH 02/12] Add ContractsInfo to on-chain --- Cargo.lock | 16 ++++++++-------- Cargo.toml | 2 +- crates/storage/src/tables.rs | 17 ++++++++++++++--- crates/types/src/entities/contract.rs | 21 +++++++++++++++++++-- 4 files changed, 42 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index adb8685f008..34737235540 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2610,7 +2610,7 @@ dependencies = [ [[package]] name = "fuel-asm" -version = "0.45.0" +version = "0.46.0" dependencies = [ "bitflags 2.4.2", "fuel-types", @@ -3148,7 +3148,7 @@ dependencies = [ [[package]] name = "fuel-crypto" -version = "0.45.0" +version = "0.46.0" dependencies = [ "coins-bip32", "coins-bip39", @@ -3167,7 +3167,7 @@ dependencies = [ [[package]] name = "fuel-derive" -version = "0.45.0" +version = "0.46.0" dependencies = [ "proc-macro2", "quote", @@ -3177,7 +3177,7 @@ dependencies = [ [[package]] name = "fuel-merkle" -version = "0.45.0" +version = "0.46.0" dependencies = [ "derive_more", "digest 0.10.7", @@ -3190,11 +3190,11 @@ dependencies = [ [[package]] name = "fuel-storage" -version = "0.45.0" +version = "0.46.0" [[package]] name = "fuel-tx" -version = "0.45.0" +version = "0.46.0" dependencies = [ "bitflags 2.4.2", "derivative", @@ -3214,7 +3214,7 @@ dependencies = [ [[package]] name = "fuel-types" -version = "0.45.0" +version = "0.46.0" dependencies = [ "fuel-derive", "hex", @@ -3224,7 +3224,7 @@ dependencies = [ [[package]] name = "fuel-vm" -version = "0.45.0" +version = "0.46.0" dependencies = [ "anyhow", "async-trait", diff --git a/Cargo.toml b/Cargo.toml index af3ff07094d..7ab9dae6159 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -77,7 +77,7 @@ fuel-core-tests = { version = "0.0.0", path = "./tests" } fuel-core-xtask = { version = "0.0.0", path = "./xtask" } # Fuel dependencies -fuel-vm-private = { version = "0.45.0", package = "fuel-vm", default-features = false } +fuel-vm-private = { version = "0.46.0", package = "fuel-vm", default-features = false } # Common dependencies anyhow = "1.0" diff --git a/crates/storage/src/tables.rs b/crates/storage/src/tables.rs index e7cbbfed441..e72fc6243fc 100644 --- a/crates/storage/src/tables.rs +++ b/crates/storage/src/tables.rs @@ -9,7 +9,10 @@ use fuel_core_types::{ }, entities::{ coins::coin::CompressedCoin, - contract::ContractUtxoInfo, + contract::{ + ContractUtxoInfo, + ContractsInfoType, + }, message::Message, }, fuel_tx::{ @@ -25,8 +28,6 @@ use fuel_core_types::{ }; pub use fuel_vm_private::storage::{ ContractsAssets, - ContractsInfo, - ContractsInfoType, ContractsRawCode, ContractsState, }; @@ -56,6 +57,16 @@ impl Mappable for ContractsLatestUtxo { type OwnedValue = ContractUtxoInfo; } +/// Contract info +pub struct ContractsInfo; + +impl Mappable for ContractsInfo { + type Key = Self::OwnedKey; + type OwnedKey = ContractId; + type Value = Self::OwnedValue; + type OwnedValue = ContractsInfoType; +} + /// The table of consensus metadata associated with sealed (finalized) blocks pub struct SealedBlockConsensus; diff --git a/crates/types/src/entities/contract.rs b/crates/types/src/entities/contract.rs index 7ac16bf9aaf..fc20689ed15 100644 --- a/crates/types/src/entities/contract.rs +++ b/crates/types/src/entities/contract.rs @@ -1,14 +1,31 @@ //! Contract entities -use crate::fuel_tx::TxPointer; +use crate::fuel_tx::{ + Salt, + TxPointer, +}; use fuel_vm_private::fuel_tx::UtxoId; /// Contains information related to the latest contract utxo -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Debug, Default, Clone, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct ContractUtxoInfo { /// the utxo id of the contract pub utxo_id: UtxoId, /// the tx pointer to the utxo pub tx_pointer: TxPointer, } + +/// Versioned enum for holding information about a contract +#[derive(Debug, Clone, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[non_exhaustive] +pub enum ContractsInfoType { + V1(ContractsInfoTypeV1), +} + +#[derive(Debug, Default, Clone, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +pub struct ContractsInfoTypeV1 { + pub salt: Salt, +} From 15d06b57da9c16c6714c320a4ed058d90164b406 Mon Sep 17 00:00:00 2001 From: Brandon Vrooman Date: Mon, 26 Feb 2024 18:54:04 -0500 Subject: [PATCH 03/12] Update fuel-vm and breaking changes --- Cargo.lock | 16 ++++++++++++++++ Cargo.toml | 4 ---- benches/src/default_gas_costs.rs | 6 +++++- benches/src/lib.rs | 18 ++++++------------ crates/client/assets/schema.sdl | 2 +- crates/client/src/client/schema/chain.rs | 2 +- .../src/client/schema/tx/transparent_tx.rs | 1 + crates/client/src/client/types/gas_costs.rs | 2 +- crates/fuel-core/src/executor.rs | 5 +++++ crates/fuel-core/src/schema/chain.rs | 8 ++++---- crates/fuel-core/src/service/genesis.rs | 8 +++++--- crates/services/executor/src/executor.rs | 1 + crates/services/executor/src/ports.rs | 1 + .../services/txpool/src/service/tests_p2p.rs | 1 + .../src/structured_storage/contracts.rs | 10 +++++++--- crates/storage/src/vm_storage.rs | 15 ++++++++------- crates/types/src/entities/contract.rs | 19 ++++++++++++++++++- 17 files changed, 81 insertions(+), 38 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 34737235540..8bfd27af5cc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2611,6 +2611,8 @@ dependencies = [ [[package]] name = "fuel-asm" version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "860332346c3b1c4a893627b591e8db907b54a629d593981e55d833224cdaccc0" dependencies = [ "bitflags 2.4.2", "fuel-types", @@ -3149,6 +3151,8 @@ dependencies = [ [[package]] name = "fuel-crypto" version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c57b1f04f678e1a2396d1348903631da4b855b9594b3c0c7c589f18caa74658" dependencies = [ "coins-bip32", "coins-bip39", @@ -3168,6 +3172,8 @@ dependencies = [ [[package]] name = "fuel-derive" version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb8cc3c60e13b80177816f53f33d77f917f7cf9a480cb10ff9a64f78672359b1" dependencies = [ "proc-macro2", "quote", @@ -3178,6 +3184,8 @@ dependencies = [ [[package]] name = "fuel-merkle" version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7aeaf25539537561819c48c6f1dd79e6d77a238c45f45269a1452b92543fe64" dependencies = [ "derive_more", "digest 0.10.7", @@ -3191,10 +3199,14 @@ dependencies = [ [[package]] name = "fuel-storage" version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f374251c753bb601ad7dbe1efb45b14c170bcfc15f449b6029cc2e3c02dffee2" [[package]] name = "fuel-tx" version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ac64fab32d5058828ead93c74a41724d1082dc1cdc039415dc4566f5c2305e1" dependencies = [ "bitflags 2.4.2", "derivative", @@ -3215,6 +3227,8 @@ dependencies = [ [[package]] name = "fuel-types" version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9829c1dbdeb29c203f3bd431a69d25bd557fa06ad5bb4dab7773d05e6ffd2824" dependencies = [ "fuel-derive", "hex", @@ -3225,6 +3239,8 @@ dependencies = [ [[package]] name = "fuel-vm" version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8b451aa96729e97704d23238c7c28f6daec2d1761bc406a49856f189ee8b909" dependencies = [ "anyhow", "async-trait", diff --git a/Cargo.toml b/Cargo.toml index 7ab9dae6159..f5a0377663b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -121,7 +121,3 @@ itertools = "0.10" insta = "1.8" tempfile = "3.4" tikv-jemallocator = "0.5" - -[patch.crates-io] -fuel-vm-private = { path = "../fuel-vm/fuel-vm", package = "fuel-vm" } -#fuel-vm-private = { git = 'https://github.com/FuelLabs/fuel-vm', package = "fuel-vm", branch = "bvrooman/feat/versionable-contract-info" } \ No newline at end of file diff --git a/benches/src/default_gas_costs.rs b/benches/src/default_gas_costs.rs index 3bcaa5a595b..a117736bf2a 100644 --- a/benches/src/default_gas_costs.rs +++ b/benches/src/default_gas_costs.rs @@ -13,7 +13,6 @@ pub fn default_gas_costs() -> GasCostsValues { cb: 2, cfei: 2, cfsi: 2, - croo: 40, div: 2, divi: 2, eck1: 3347, @@ -101,6 +100,11 @@ pub fn default_gas_costs() -> GasCostsValues { base: 59, units_per_gas: 20, }, + // TODO: Update CROO values based on benchmarks: https://github.com/FuelLabs/fuel-core/issues/1660 + croo: DependentCost::LightOperation { + base: 1, + units_per_gas: 1, + }, csiz: DependentCost::LightOperation { base: 59, units_per_gas: 195, diff --git a/benches/src/lib.rs b/benches/src/lib.rs index 39c1b4884d0..6de7abd9054 100644 --- a/benches/src/lib.rs +++ b/benches/src/lib.rs @@ -61,10 +61,10 @@ impl From> for ContractCode { Self { contract, + salt, id, root, storage_root, - salt, slots, } } @@ -162,7 +162,7 @@ impl VmBench { let program = Witness::from(program); - let salt = rng.gen(); + // let salt = rng.gen(); let contract = Contract::from(program.as_ref()); let state_root = Contract::default_state_root(); @@ -175,7 +175,7 @@ impl VmBench { let input = Input::contract(utxo_id, balance_root, state_root, tx_pointer, id); let output = Output::contract(0, rng.gen(), rng.gen()); - db.deploy_contract_with_id(&salt, &[], &contract, &id)?; + db.deploy_contract_with_id(&[], &contract, &id)?; let data = id .iter() @@ -374,12 +374,11 @@ impl TryFrom for VmBenchPrepared { tx.add_input(input); tx.add_output(output); - db.deploy_contract_with_id(&VmBench::SALT, &[], &code, &contract)?; + db.deploy_contract_with_id(&[], &code, &contract)?; } if let Some(ContractCode { contract, - salt, id, slots, storage_root, @@ -400,7 +399,7 @@ impl TryFrom for VmBenchPrepared { tx.add_input(input); tx.add_output(output); - db.deploy_contract_with_id(&salt, &slots, &contract, &id)?; + db.deploy_contract_with_id(&slots, &contract, &id)?; } for contract_id in empty_contracts { @@ -418,12 +417,7 @@ impl TryFrom for VmBenchPrepared { tx.add_input(input); tx.add_output(output); - db.deploy_contract_with_id( - &VmBench::SALT, - &[], - &Contract::default(), - &contract_id, - )?; + db.deploy_contract_with_id(&[], &Contract::default(), &contract_id)?; } inputs.into_iter().for_each(|i| { diff --git a/crates/client/assets/schema.sdl b/crates/client/assets/schema.sdl index a760d45c8e1..50590fa6344 100644 --- a/crates/client/assets/schema.sdl +++ b/crates/client/assets/schema.sdl @@ -318,7 +318,6 @@ type GasCosts { cb: U64! cfei: U64! cfsi: U64! - croo: U64! div: U64! divi: U64! ecr1: U64! @@ -397,6 +396,7 @@ type GasCosts { xori: U64! call: DependentCost! ccp: DependentCost! + croo: DependentCost! csiz: DependentCost! k256: DependentCost! ldc: DependentCost! diff --git a/crates/client/src/client/schema/chain.rs b/crates/client/src/client/schema/chain.rs index 3c3bacf8c2f..3b552d4d5e6 100644 --- a/crates/client/src/client/schema/chain.rs +++ b/crates/client/src/client/schema/chain.rs @@ -145,7 +145,6 @@ include_from_impls_and_cynic! { pub cb: U64, pub cfei: U64, pub cfsi: U64, - pub croo: U64, pub div: U64, pub divi: U64, pub eck1: U64, @@ -225,6 +224,7 @@ include_from_impls_and_cynic! { pub call: DependentCost, pub ccp: DependentCost, + pub croo: DependentCost, pub csiz: DependentCost, pub k256: DependentCost, pub ldc: DependentCost, diff --git a/crates/client/src/client/schema/tx/transparent_tx.rs b/crates/client/src/client/schema/tx/transparent_tx.rs index 3962a0f2965..91cc6067f39 100644 --- a/crates/client/src/client/schema/tx/transparent_tx.rs +++ b/crates/client/src/client/schema/tx/transparent_tx.rs @@ -274,6 +274,7 @@ impl TryFrom for fuel_tx::Transaction { ConversionError::MissingField("mint_asset_id".to_string()) })? .into(), + 0, ); mint.into() }; diff --git a/crates/client/src/client/types/gas_costs.rs b/crates/client/src/client/types/gas_costs.rs index e7f1fd7c109..f84dbee0551 100644 --- a/crates/client/src/client/types/gas_costs.rs +++ b/crates/client/src/client/types/gas_costs.rs @@ -44,7 +44,6 @@ include_from_impls! { pub cb: u64, pub cfei: u64, pub cfsi: u64, - pub croo: u64, pub div: u64, pub divi: u64, pub eck1: u64, @@ -125,6 +124,7 @@ include_from_impls! { pub call: DependentCost, pub ccp: DependentCost, pub csiz: DependentCost, + pub croo: DependentCost, pub k256: DependentCost, pub ldc: DependentCost, pub logd: DependentCost, diff --git a/crates/fuel-core/src/executor.rs b/crates/fuel-core/src/executor.rs index 583970466e2..4cc401b514a 100644 --- a/crates/fuel-core/src/executor.rs +++ b/crates/fuel-core/src/executor.rs @@ -757,6 +757,7 @@ mod tests { Default::default(), Default::default(), Default::default(), + Default::default(), ); let mut block = Block::default(); @@ -787,6 +788,7 @@ mod tests { Default::default(), Default::default(), Default::default(), + Default::default(), ); let tx = Transaction::default_test_tx(); @@ -823,6 +825,7 @@ mod tests { Default::default(), Default::default(), Default::default(), + Default::default(), ); let mut block = Block::default(); @@ -850,6 +853,7 @@ mod tests { Default::default(), Default::default(), Default::default(), + Default::default(), ); let mut block = Block::default(); @@ -879,6 +883,7 @@ mod tests { Default::default(), 123, Default::default(), + Default::default(), ); let mut block = Block::default(); diff --git a/crates/fuel-core/src/schema/chain.rs b/crates/fuel-core/src/schema/chain.rs index 535f1c11ae3..5f65f3eb2d6 100644 --- a/crates/fuel-core/src/schema/chain.rs +++ b/crates/fuel-core/src/schema/chain.rs @@ -264,10 +264,6 @@ impl GasCosts { self.0.cfsi.into() } - async fn croo(&self) -> U64 { - self.0.croo.into() - } - async fn div(&self) -> U64 { self.0.div.into() } @@ -580,6 +576,10 @@ impl GasCosts { self.0.ccp.into() } + async fn croo(&self) -> DependentCost { + self.0.croo.into() + } + async fn csiz(&self) -> DependentCost { self.0.csiz.into() } diff --git a/crates/fuel-core/src/service/genesis.rs b/crates/fuel-core/src/service/genesis.rs index 8fbdb26f03c..b6598e9e195 100644 --- a/crates/fuel-core/src/service/genesis.rs +++ b/crates/fuel-core/src/service/genesis.rs @@ -14,7 +14,6 @@ use fuel_core_storage::{ tables::{ Coins, ContractsInfo, - ContractsInfoType, ContractsLatestUtxo, ContractsRawCode, Messages, @@ -43,7 +42,10 @@ use fuel_core_types::{ }, entities::{ coins::coin::Coin, - contract::ContractUtxoInfo, + contract::{ + ContractUtxoInfo, + ContractsInfoType, + }, message::Message, }, fuel_merkle::binary, @@ -250,7 +252,7 @@ fn init_contracts( // insert contract salt if db .storage::() - .insert(&contract_id, &ContractsInfoType::V1(salt))? + .insert(&contract_id, &ContractsInfoType::V1(salt.into()))? .is_some() { return Err(anyhow!("Contract info should not exist")) diff --git a/crates/services/executor/src/executor.rs b/crates/services/executor/src/executor.rs index 92a4cf7f5d6..3d9c5986f88 100644 --- a/crates/services/executor/src/executor.rs +++ b/crates/services/executor/src/executor.rs @@ -642,6 +642,7 @@ where }, amount_to_mint, self.config.consensus_parameters.base_asset_id, + 0, // TODO: ); execute_transaction( diff --git a/crates/services/executor/src/ports.rs b/crates/services/executor/src/ports.rs index 7176731f111..17e78c3b25d 100644 --- a/crates/services/executor/src/ports.rs +++ b/crates/services/executor/src/ports.rs @@ -78,6 +78,7 @@ pub trait ExecutorDatabaseTrait: + StorageMutate + StorageMutate + StorageMutate + + StorageMutate + StorageRead + StorageMutate + MerkleRootStorage diff --git a/crates/services/txpool/src/service/tests_p2p.rs b/crates/services/txpool/src/service/tests_p2p.rs index 614f6153d44..9d779eee713 100644 --- a/crates/services/txpool/src/service/tests_p2p.rs +++ b/crates/services/txpool/src/service/tests_p2p.rs @@ -193,6 +193,7 @@ async fn test_gossipped_mint_rejected() { Default::default(), 1, AssetId::BASE, + 0, ) .finalize_as_transaction(); // setup p2p mock - with tx incoming from p2p diff --git a/crates/storage/src/structured_storage/contracts.rs b/crates/storage/src/structured_storage/contracts.rs index 6db9fb5b20f..ee8eec73da0 100644 --- a/crates/storage/src/structured_storage/contracts.rs +++ b/crates/storage/src/structured_storage/contracts.rs @@ -19,9 +19,10 @@ use crate::{ }, StorageRead, }; -use core::ops::Deref; use fuel_core_types::fuel_tx::ContractId; +use core::ops::Deref; + // # Dev-note: The value of the `ContractsRawCode` has a unique implementation of serialization // and deserialization and uses `Raw` codec. Because the value is a contract byte code represented // by bytes, we don't use `serde::Deserialization` and `serde::Serialization` for `Vec`, @@ -76,7 +77,10 @@ impl TableWithBlueprint for ContractsLatestUtxo { #[cfg(test)] mod test { use super::*; - use crate::tables::ContractsInfoType; + use fuel_core_types::{ + entities::contract::ContractsInfoType, + fuel_tx::Salt, + }; crate::basic_storage_tests!( ContractsRawCode, @@ -88,7 +92,7 @@ mod test { crate::basic_storage_tests!( ContractsInfo, ::Key::from([1u8; 32]), - ContractsInfoType::V1([2u8; 32].into()) + ContractsInfoType::V1(Salt::new([2u8; 32]).into()) ); crate::basic_storage_tests!( diff --git a/crates/storage/src/vm_storage.rs b/crates/storage/src/vm_storage.rs index fd2b0e9b480..f1a7c6a324e 100644 --- a/crates/storage/src/vm_storage.rs +++ b/crates/storage/src/vm_storage.rs @@ -28,6 +28,10 @@ use fuel_core_types::{ header::ConsensusHeader, primitives::BlockId, }, + // entities::contract::{ + // ContractsInfoType, + // ContractsInfoTypeV1, + // }, fuel_tx::{ Contract, StorageSlot, @@ -36,13 +40,12 @@ use fuel_core_types::{ BlockHeight, Bytes32, ContractId, - Salt, + // Salt, Word, }, fuel_vm::InterpreterStorage, tai64::Tai64, }; -use fuel_vm_private::storage::ContractsInfoType; use itertools::Itertools; use primitive_types::U256; use std::borrow::Cow; @@ -174,6 +177,7 @@ where impl ContractsAssetsStorage for VmStorage where D: MerkleRootStorage + + StorageMutate { } @@ -181,7 +185,9 @@ impl InterpreterStorage for VmStorage where D: StorageMutate + MerkleRootStorage + + StorageMutate + StorageMutate + + StorageMutate + StorageRead + MerkleRootStorage + VmStorageRequirements, @@ -225,16 +231,11 @@ where fn deploy_contract_with_id( &mut self, - salt: &Salt, slots: &[StorageSlot], contract: &Contract, id: &ContractId, ) -> Result<(), Self::DataError> { self.storage_contract_insert(id, contract)?; - - let info = ContractsInfoType::V1(*salt); - self.storage_contract_info_insert(id, &info)?; - self.database.init_contract_state( id, slots.iter().map(|slot| (*slot.key(), *slot.value())), diff --git a/crates/types/src/entities/contract.rs b/crates/types/src/entities/contract.rs index fc20689ed15..44aef4f4a45 100644 --- a/crates/types/src/entities/contract.rs +++ b/crates/types/src/entities/contract.rs @@ -21,11 +21,28 @@ pub struct ContractUtxoInfo { #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[non_exhaustive] pub enum ContractsInfoType { + /// V1 V1(ContractsInfoTypeV1), } +impl ContractsInfoType { + /// Get the contract salt + pub fn salt(&self) -> &Salt { + match self { + ContractsInfoType::V1(info) => &info.salt, + } + } +} + +/// Version 1 of the ContractsInfoType #[derive(Debug, Default, Clone, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct ContractsInfoTypeV1 { - pub salt: Salt, + salt: Salt, +} + +impl From for ContractsInfoTypeV1 { + fn from(salt: Salt) -> Self { + Self { salt } + } } From 7d2fd6f91aa87574b8f1af2ef2bedcc73cc9d24f Mon Sep 17 00:00:00 2001 From: Brandon Vrooman Date: Mon, 26 Feb 2024 19:01:08 -0500 Subject: [PATCH 04/12] Update CHANGELOG.md --- CHANGELOG.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a875ec88c41..f8cf014143b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] -Description of the upcoming release here. +### Added + +- [#1657](https://github.com/FuelLabs/fuel-core/pull/1657): Moved `ContractsInfo` table from `fuel-vm` to on-chain tables, and created version-able `ContractsInfoType` to act as the table's data type. + +### Changed + +- [#1657](https://github.com/FuelLabs/fuel-core/pull/1657): Upgrade to `fuel-vm` 0.46.0. +- [#1657](https://github.com/FuelLabs/fuel-core/pull/1657): Changed `CROO` gas price type from `Word` to `DependentGasPrice`. The dependent gas price values are dummy values while awaiting updated benchmarks. ### Added From 1dd14710eb75588cd5d622f7532df97b62d6235a Mon Sep 17 00:00:00 2001 From: Brandon Vrooman Date: Mon, 26 Feb 2024 19:33:11 -0500 Subject: [PATCH 05/12] Update snapshots --- benches/src/lib.rs | 2 -- ..._tests__snapshot_configurable_block_height.snap | 7 ++++++- ...ig__tests__snapshot_contract_with_balances.snap | 7 ++++++- ...onfig__tests__snapshot_contract_with_state.snap | 7 ++++++- ...__tests__snapshot_contract_with_tx_pointer.snap | 7 ++++++- ...fig__tests__snapshot_contract_with_utxo_id.snap | 7 ++++++- ...nfig__tests__snapshot_local_testnet_config.snap | 7 ++++++- ..._config__tests__snapshot_simple_coin_state.snap | 7 ++++++- ...g__config__tests__snapshot_simple_contract.snap | 7 ++++++- ...nfig__tests__snapshot_simple_message_state.snap | 7 ++++++- ...hema__chain__tests__chain_gql_query_output.snap | 14 +++++++++++--- crates/storage/src/vm_storage.rs | 4 ---- 12 files changed, 65 insertions(+), 18 deletions(-) diff --git a/benches/src/lib.rs b/benches/src/lib.rs index 6de7abd9054..98f4e59b3e0 100644 --- a/benches/src/lib.rs +++ b/benches/src/lib.rs @@ -162,8 +162,6 @@ impl VmBench { let program = Witness::from(program); - // let salt = rng.gen(); - let contract = Contract::from(program.as_ref()); let state_root = Contract::default_state_root(); let id = VmBench::CONTRACT; diff --git a/crates/chain-config/src/snapshots/fuel_core_chain_config__config__tests__snapshot_configurable_block_height.snap b/crates/chain-config/src/snapshots/fuel_core_chain_config__config__tests__snapshot_configurable_block_height.snap index 89d4b12b943..cae09b5ff35 100644 --- a/crates/chain-config/src/snapshots/fuel_core_chain_config__config__tests__snapshot_configurable_block_height.snap +++ b/crates/chain-config/src/snapshots/fuel_core_chain_config__config__tests__snapshot_configurable_block_height.snap @@ -48,7 +48,6 @@ expression: json "cb": 1, "cfei": 1, "cfsi": 1, - "croo": 16, "div": 1, "divi": 1, "eck1": 951, @@ -137,6 +136,12 @@ expression: json "units_per_gas": 103 } }, + "croo": { + "LightOperation": { + "base": 1, + "units_per_gas": 1 + } + }, "csiz": { "LightOperation": { "base": 17, diff --git a/crates/chain-config/src/snapshots/fuel_core_chain_config__config__tests__snapshot_contract_with_balances.snap b/crates/chain-config/src/snapshots/fuel_core_chain_config__config__tests__snapshot_contract_with_balances.snap index 10fe5c632b6..6d3474a601d 100644 --- a/crates/chain-config/src/snapshots/fuel_core_chain_config__config__tests__snapshot_contract_with_balances.snap +++ b/crates/chain-config/src/snapshots/fuel_core_chain_config__config__tests__snapshot_contract_with_balances.snap @@ -60,7 +60,6 @@ expression: json "cb": 1, "cfei": 1, "cfsi": 1, - "croo": 16, "div": 1, "divi": 1, "eck1": 951, @@ -149,6 +148,12 @@ expression: json "units_per_gas": 103 } }, + "croo": { + "LightOperation": { + "base": 1, + "units_per_gas": 1 + } + }, "csiz": { "LightOperation": { "base": 17, diff --git a/crates/chain-config/src/snapshots/fuel_core_chain_config__config__tests__snapshot_contract_with_state.snap b/crates/chain-config/src/snapshots/fuel_core_chain_config__config__tests__snapshot_contract_with_state.snap index f229c4dc094..fdec4af2317 100644 --- a/crates/chain-config/src/snapshots/fuel_core_chain_config__config__tests__snapshot_contract_with_state.snap +++ b/crates/chain-config/src/snapshots/fuel_core_chain_config__config__tests__snapshot_contract_with_state.snap @@ -60,7 +60,6 @@ expression: json "cb": 1, "cfei": 1, "cfsi": 1, - "croo": 16, "div": 1, "divi": 1, "eck1": 951, @@ -149,6 +148,12 @@ expression: json "units_per_gas": 103 } }, + "croo": { + "LightOperation": { + "base": 1, + "units_per_gas": 1 + } + }, "csiz": { "LightOperation": { "base": 17, diff --git a/crates/chain-config/src/snapshots/fuel_core_chain_config__config__tests__snapshot_contract_with_tx_pointer.snap b/crates/chain-config/src/snapshots/fuel_core_chain_config__config__tests__snapshot_contract_with_tx_pointer.snap index bd6825f663f..d1e5371b3cd 100644 --- a/crates/chain-config/src/snapshots/fuel_core_chain_config__config__tests__snapshot_contract_with_tx_pointer.snap +++ b/crates/chain-config/src/snapshots/fuel_core_chain_config__config__tests__snapshot_contract_with_tx_pointer.snap @@ -56,7 +56,6 @@ expression: json "cb": 1, "cfei": 1, "cfsi": 1, - "croo": 16, "div": 1, "divi": 1, "eck1": 951, @@ -145,6 +144,12 @@ expression: json "units_per_gas": 103 } }, + "croo": { + "LightOperation": { + "base": 1, + "units_per_gas": 1 + } + }, "csiz": { "LightOperation": { "base": 17, diff --git a/crates/chain-config/src/snapshots/fuel_core_chain_config__config__tests__snapshot_contract_with_utxo_id.snap b/crates/chain-config/src/snapshots/fuel_core_chain_config__config__tests__snapshot_contract_with_utxo_id.snap index 0c6ca69e3be..56aa3aa41e9 100644 --- a/crates/chain-config/src/snapshots/fuel_core_chain_config__config__tests__snapshot_contract_with_utxo_id.snap +++ b/crates/chain-config/src/snapshots/fuel_core_chain_config__config__tests__snapshot_contract_with_utxo_id.snap @@ -56,7 +56,6 @@ expression: json "cb": 1, "cfei": 1, "cfsi": 1, - "croo": 16, "div": 1, "divi": 1, "eck1": 951, @@ -145,6 +144,12 @@ expression: json "units_per_gas": 103 } }, + "croo": { + "LightOperation": { + "base": 1, + "units_per_gas": 1 + } + }, "csiz": { "LightOperation": { "base": 17, diff --git a/crates/chain-config/src/snapshots/fuel_core_chain_config__config__tests__snapshot_local_testnet_config.snap b/crates/chain-config/src/snapshots/fuel_core_chain_config__config__tests__snapshot_local_testnet_config.snap index 510029469c1..89f44d1829c 100644 --- a/crates/chain-config/src/snapshots/fuel_core_chain_config__config__tests__snapshot_local_testnet_config.snap +++ b/crates/chain-config/src/snapshots/fuel_core_chain_config__config__tests__snapshot_local_testnet_config.snap @@ -74,7 +74,6 @@ expression: json "cb": 1, "cfei": 1, "cfsi": 1, - "croo": 16, "div": 1, "divi": 1, "eck1": 951, @@ -163,6 +162,12 @@ expression: json "units_per_gas": 103 } }, + "croo": { + "LightOperation": { + "base": 1, + "units_per_gas": 1 + } + }, "csiz": { "LightOperation": { "base": 17, diff --git a/crates/chain-config/src/snapshots/fuel_core_chain_config__config__tests__snapshot_simple_coin_state.snap b/crates/chain-config/src/snapshots/fuel_core_chain_config__config__tests__snapshot_simple_coin_state.snap index ab9bcb57e0d..86468fcca9c 100644 --- a/crates/chain-config/src/snapshots/fuel_core_chain_config__config__tests__snapshot_simple_coin_state.snap +++ b/crates/chain-config/src/snapshots/fuel_core_chain_config__config__tests__snapshot_simple_coin_state.snap @@ -59,7 +59,6 @@ expression: json "cb": 1, "cfei": 1, "cfsi": 1, - "croo": 16, "div": 1, "divi": 1, "eck1": 951, @@ -148,6 +147,12 @@ expression: json "units_per_gas": 103 } }, + "croo": { + "LightOperation": { + "base": 1, + "units_per_gas": 1 + } + }, "csiz": { "LightOperation": { "base": 17, diff --git a/crates/chain-config/src/snapshots/fuel_core_chain_config__config__tests__snapshot_simple_contract.snap b/crates/chain-config/src/snapshots/fuel_core_chain_config__config__tests__snapshot_simple_contract.snap index f5106e5728a..91cf7e0af7c 100644 --- a/crates/chain-config/src/snapshots/fuel_core_chain_config__config__tests__snapshot_simple_contract.snap +++ b/crates/chain-config/src/snapshots/fuel_core_chain_config__config__tests__snapshot_simple_contract.snap @@ -54,7 +54,6 @@ expression: json "cb": 1, "cfei": 1, "cfsi": 1, - "croo": 16, "div": 1, "divi": 1, "eck1": 951, @@ -143,6 +142,12 @@ expression: json "units_per_gas": 103 } }, + "croo": { + "LightOperation": { + "base": 1, + "units_per_gas": 1 + } + }, "csiz": { "LightOperation": { "base": 17, diff --git a/crates/chain-config/src/snapshots/fuel_core_chain_config__config__tests__snapshot_simple_message_state.snap b/crates/chain-config/src/snapshots/fuel_core_chain_config__config__tests__snapshot_simple_message_state.snap index 5ae1f15c2a9..36887ff47b8 100644 --- a/crates/chain-config/src/snapshots/fuel_core_chain_config__config__tests__snapshot_simple_message_state.snap +++ b/crates/chain-config/src/snapshots/fuel_core_chain_config__config__tests__snapshot_simple_message_state.snap @@ -57,7 +57,6 @@ expression: json "cb": 1, "cfei": 1, "cfsi": 1, - "croo": 16, "div": 1, "divi": 1, "eck1": 951, @@ -146,6 +145,12 @@ expression: json "units_per_gas": 103 } }, + "croo": { + "LightOperation": { + "base": 1, + "units_per_gas": 1 + } + }, "csiz": { "LightOperation": { "base": 17, 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 77256901502..0cc14d286a9 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 @@ -77,7 +77,6 @@ query { cb cfei cfsi - croo div divi eck1 @@ -176,6 +175,17 @@ query { gasPerUnit } } + croo { + __typename + ... on LightOperation { + base + unitsPerGas + } + ... on HeavyOperation { + base + gasPerUnit + } + } csiz { __typename ... on LightOperation { @@ -379,5 +389,3 @@ query { } } } - - diff --git a/crates/storage/src/vm_storage.rs b/crates/storage/src/vm_storage.rs index f1a7c6a324e..5d294947ffd 100644 --- a/crates/storage/src/vm_storage.rs +++ b/crates/storage/src/vm_storage.rs @@ -28,10 +28,6 @@ use fuel_core_types::{ header::ConsensusHeader, primitives::BlockId, }, - // entities::contract::{ - // ContractsInfoType, - // ContractsInfoTypeV1, - // }, fuel_tx::{ Contract, StorageSlot, From 00acc5cc1bd94930fdc5d33e17342042ab4ddd77 Mon Sep 17 00:00:00 2001 From: Brandon Vrooman Date: Mon, 26 Feb 2024 19:56:35 -0500 Subject: [PATCH 06/12] Update chainspecs --- deployment/scripts/chainspec/beta_chainspec.json | 7 ++++++- deployment/scripts/chainspec/dev_chainspec.json | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/deployment/scripts/chainspec/beta_chainspec.json b/deployment/scripts/chainspec/beta_chainspec.json index a2695bc4da5..f0430c60a78 100644 --- a/deployment/scripts/chainspec/beta_chainspec.json +++ b/deployment/scripts/chainspec/beta_chainspec.json @@ -87,7 +87,6 @@ "cb": 2, "cfei": 2, "cfsi": 2, - "croo": 40, "div": 2, "divi": 2, "eck1": 3347, @@ -176,6 +175,12 @@ "units_per_gas": 20 } }, + "croo": { + "LightOperation": { + "base": 1, + "units_per_gas": 1 + } + }, "csiz": { "LightOperation": { "base": 59, diff --git a/deployment/scripts/chainspec/dev_chainspec.json b/deployment/scripts/chainspec/dev_chainspec.json index d41afd02cbe..097e11e745c 100644 --- a/deployment/scripts/chainspec/dev_chainspec.json +++ b/deployment/scripts/chainspec/dev_chainspec.json @@ -117,7 +117,6 @@ "cb": 2, "cfei": 2, "cfsi": 2, - "croo": 40, "div": 2, "divi": 2, "eck1": 3347, @@ -206,6 +205,12 @@ "units_per_gas": 20 } }, + "croo": { + "LightOperation": { + "base": 1, + "units_per_gas": 1 + } + }, "csiz": { "LightOperation": { "base": 59, From be42f5d8783b7ca473a0381721ac58a5de2664bd Mon Sep 17 00:00:00 2001 From: Brandon Vrooman Date: Mon, 26 Feb 2024 20:18:34 -0500 Subject: [PATCH 07/12] Minor --- crates/services/txpool/src/service/tests_p2p.rs | 2 +- crates/storage/src/vm_storage.rs | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/services/txpool/src/service/tests_p2p.rs b/crates/services/txpool/src/service/tests_p2p.rs index 9d779eee713..71270feec1c 100644 --- a/crates/services/txpool/src/service/tests_p2p.rs +++ b/crates/services/txpool/src/service/tests_p2p.rs @@ -193,7 +193,7 @@ async fn test_gossipped_mint_rejected() { Default::default(), 1, AssetId::BASE, - 0, + Default::default(), ) .finalize_as_transaction(); // setup p2p mock - with tx incoming from p2p diff --git a/crates/storage/src/vm_storage.rs b/crates/storage/src/vm_storage.rs index 5d294947ffd..d8566634ea6 100644 --- a/crates/storage/src/vm_storage.rs +++ b/crates/storage/src/vm_storage.rs @@ -36,7 +36,6 @@ use fuel_core_types::{ BlockHeight, Bytes32, ContractId, - // Salt, Word, }, fuel_vm::InterpreterStorage, From 0f14d37cd208bd61f2ff0baed9af65601790c5cd Mon Sep 17 00:00:00 2001 From: Brandon Vrooman Date: Mon, 26 Feb 2024 20:20:18 -0500 Subject: [PATCH 08/12] Update todo --- crates/services/executor/src/executor.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/services/executor/src/executor.rs b/crates/services/executor/src/executor.rs index 3d9c5986f88..4ed6685e0db 100644 --- a/crates/services/executor/src/executor.rs +++ b/crates/services/executor/src/executor.rs @@ -642,7 +642,7 @@ where }, amount_to_mint, self.config.consensus_parameters.base_asset_id, - 0, // TODO: + 0, // TODO: Provide gas price ); execute_transaction( From 22acaea52292d9b0d1f5ac26300735e98568edbd Mon Sep 17 00:00:00 2001 From: Brandon Vrooman Date: Mon, 26 Feb 2024 20:29:47 -0500 Subject: [PATCH 09/12] Update comments --- crates/types/src/entities/contract.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/types/src/entities/contract.rs b/crates/types/src/entities/contract.rs index 44aef4f4a45..6260413ece6 100644 --- a/crates/types/src/entities/contract.rs +++ b/crates/types/src/entities/contract.rs @@ -16,12 +16,14 @@ pub struct ContractUtxoInfo { pub tx_pointer: TxPointer, } -/// Versioned enum for holding information about a contract +/// Versioned type for storing information about a contract. Contract +/// information is off-chain data. +// TODO: Move ContractsInfoType to off-chain data storage #[derive(Debug, Clone, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[non_exhaustive] pub enum ContractsInfoType { - /// V1 + /// V1 ContractsInfoType V1(ContractsInfoTypeV1), } From 7cd057a35ea60e04812cc54f62709b69fc13fb08 Mon Sep 17 00:00:00 2001 From: Brandon Vrooman Date: Mon, 26 Feb 2024 20:40:23 -0500 Subject: [PATCH 10/12] Update transparent_tx todo --- crates/client/src/client/schema/tx/transparent_tx.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/client/src/client/schema/tx/transparent_tx.rs b/crates/client/src/client/schema/tx/transparent_tx.rs index 91cc6067f39..1ed8970ea9f 100644 --- a/crates/client/src/client/schema/tx/transparent_tx.rs +++ b/crates/client/src/client/schema/tx/transparent_tx.rs @@ -274,7 +274,7 @@ impl TryFrom for fuel_tx::Transaction { ConversionError::MissingField("mint_asset_id".to_string()) })? .into(), - 0, + 0, // TODO: Provide gas price ); mint.into() }; From 40950657021bb8e12e65140b0b241e3530fb720d Mon Sep 17 00:00:00 2001 From: xgreenx Date: Tue, 27 Feb 2024 10:41:24 +0100 Subject: [PATCH 11/12] Fix small nits --- CHANGELOG.md | 11 +++-------- crates/client/assets/schema.sdl | 1 + crates/client/src/client/schema/tx/transparent_tx.rs | 8 +++++++- crates/fuel-core/src/schema/tx/types.rs | 8 ++++++++ crates/services/executor/src/executor.rs | 3 ++- crates/storage/src/structured_storage/contracts.rs | 3 +-- crates/types/src/entities/contract.rs | 2 +- 7 files changed, 23 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f8cf014143b..aa42094d527 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,19 +8,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Added +- [#1671](https://github.com/FuelLabs/fuel-core/pull/1671): Added a new `Merklized` blueprint that maintains the binary Merkle tree over the storage data. It supports only the insertion of the objects without removing them. - [#1657](https://github.com/FuelLabs/fuel-core/pull/1657): Moved `ContractsInfo` table from `fuel-vm` to on-chain tables, and created version-able `ContractsInfoType` to act as the table's data type. ### Changed - [#1657](https://github.com/FuelLabs/fuel-core/pull/1657): Upgrade to `fuel-vm` 0.46.0. -- [#1657](https://github.com/FuelLabs/fuel-core/pull/1657): Changed `CROO` gas price type from `Word` to `DependentGasPrice`. The dependent gas price values are dummy values while awaiting updated benchmarks. - -### Added - -- [#1671](https://github.com/FuelLabs/fuel-core/pull/1671): Added a new `Merklized` blueprint that maintains the binary Merkle tree over the storage data. It supports only the insertion of the objects without removing them. - -### Changed - - [#1671](https://github.com/FuelLabs/fuel-core/pull/1671): The logic related to the `FuelBlockIdsToHeights` is moved to the off-chain worker. - [#1663](https://github.com/FuelLabs/fuel-core/pull/1663): Reduce the punishment criteria for mempool gossipping. - [#1658](https://github.com/FuelLabs/fuel-core/pull/1658): Removed `Receipts` table. Instead, receipts are part of the `TransactionStatuses` table. @@ -45,6 +38,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - [#1636](https://github.com/FuelLabs/fuel-core/pull/1636): Add more docs to GraphQL DAP API. #### Breaking + +- [#1657](https://github.com/FuelLabs/fuel-core/pull/1657): Changed `CROO` gas price type from `Word` to `DependentGasPrice`. The dependent gas price values are dummy values while awaiting updated benchmarks. - [#1671](https://github.com/FuelLabs/fuel-core/pull/1671): The GraphQL API uses block height instead of the block id where it is possible. The transaction status contains `block_height` instead of the `block_id`. - [#1675](https://github.com/FuelLabs/fuel-core/pull/1675): Simplify GQL schema by disabling contract resolvers in most cases, and just return a ContractId scalar instead. - [#1658](https://github.com/FuelLabs/fuel-core/pull/1658): Receipts are part of the transaction status. diff --git a/crates/client/assets/schema.sdl b/crates/client/assets/schema.sdl index 50590fa6344..0726ef81df7 100644 --- a/crates/client/assets/schema.sdl +++ b/crates/client/assets/schema.sdl @@ -969,6 +969,7 @@ type Transaction { maturity: U32 mintAmount: U64 mintAssetId: AssetId + mintGasPrice: U64 txPointer: TxPointer isScript: Boolean! isCreate: Boolean! diff --git a/crates/client/src/client/schema/tx/transparent_tx.rs b/crates/client/src/client/schema/tx/transparent_tx.rs index 1ed8970ea9f..2d357ccfa8f 100644 --- a/crates/client/src/client/schema/tx/transparent_tx.rs +++ b/crates/client/src/client/schema/tx/transparent_tx.rs @@ -123,6 +123,8 @@ pub struct Transaction { pub mint_amount: Option, /// The field of the `Transaction::Mint`. pub mint_asset_id: Option, + /// The field of the `Transaction::Mint`. + pub mint_gas_price: Option, /// The field of the `Transaction::Script`. pub receipts_root: Option, /// The status of the transaction fetched from the database. @@ -274,7 +276,11 @@ impl TryFrom for fuel_tx::Transaction { ConversionError::MissingField("mint_asset_id".to_string()) })? .into(), - 0, // TODO: Provide gas price + tx.mint_gas_price + .ok_or_else(|| { + ConversionError::MissingField("mint_gas_price".to_string()) + })? + .into(), ); mint.into() }; diff --git a/crates/fuel-core/src/schema/tx/types.rs b/crates/fuel-core/src/schema/tx/types.rs index 4279361177e..a2723ab6ba3 100644 --- a/crates/fuel-core/src/schema/tx/types.rs +++ b/crates/fuel-core/src/schema/tx/types.rs @@ -430,6 +430,14 @@ impl Transaction { } } + async fn mint_gas_price(&self) -> Option { + match &self.0 { + fuel_tx::Transaction::Script(_) | fuel_tx::Transaction::Create(_) => None, + // TODO: We need to add a getter for the `gas_price` field in `Mint` transaction + fuel_tx::Transaction::Mint(_) => Some((0).into()), + } + } + // TODO: Maybe we need to do the same `Script` and `Create` async fn tx_pointer(&self) -> Option { match &self.0 { diff --git a/crates/services/executor/src/executor.rs b/crates/services/executor/src/executor.rs index 4ed6685e0db..1b220ab7207 100644 --- a/crates/services/executor/src/executor.rs +++ b/crates/services/executor/src/executor.rs @@ -642,7 +642,8 @@ where }, amount_to_mint, self.config.consensus_parameters.base_asset_id, - 0, // TODO: Provide gas price + // TODO: Provide gas price https://github.com/FuelLabs/fuel-core/issues/1642 + 0, ); execute_transaction( diff --git a/crates/storage/src/structured_storage/contracts.rs b/crates/storage/src/structured_storage/contracts.rs index ee8eec73da0..8a9b4fd57b6 100644 --- a/crates/storage/src/structured_storage/contracts.rs +++ b/crates/storage/src/structured_storage/contracts.rs @@ -19,9 +19,8 @@ use crate::{ }, StorageRead, }; -use fuel_core_types::fuel_tx::ContractId; - use core::ops::Deref; +use fuel_core_types::fuel_tx::ContractId; // # Dev-note: The value of the `ContractsRawCode` has a unique implementation of serialization // and deserialization and uses `Raw` codec. Because the value is a contract byte code represented diff --git a/crates/types/src/entities/contract.rs b/crates/types/src/entities/contract.rs index 6260413ece6..b7f95b4fdae 100644 --- a/crates/types/src/entities/contract.rs +++ b/crates/types/src/entities/contract.rs @@ -18,7 +18,7 @@ pub struct ContractUtxoInfo { /// Versioned type for storing information about a contract. Contract /// information is off-chain data. -// TODO: Move ContractsInfoType to off-chain data storage +// TODO: Move ContractsInfoType to off-chain data storage https://github.com/FuelLabs/fuel-core/issues/1654 #[derive(Debug, Clone, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[non_exhaustive] From 213402e6ac0a32e4ca7b8075a7dc6f3115da061e Mon Sep 17 00:00:00 2001 From: xgreenx Date: Tue, 27 Feb 2024 10:59:21 +0100 Subject: [PATCH 12/12] Make CI happy --- ..._tests__transparent_transaction_by_id_query_gql_output.snap | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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 5f5e7b0143b..7b9508e7fdb 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 @@ -86,6 +86,7 @@ query($id: TransactionId!) { } mintAmount mintAssetId + mintGasPrice receiptsRoot status { __typename @@ -194,5 +195,3 @@ query($id: TransactionId!) { bytecodeLength } } - -