diff --git a/CHANGELOG.md b/CHANGELOG.md index b9a5c980da1..395700fc7e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ Description of the upcoming release here. ### Changed -- [#1600](https://github.com/FuelLabs/fuel-core/pull/1600): Upgrade to fuel-vm 0.44.0 +- [#1600](https://github.com/FuelLabs/fuel-core/pull/1640): Upgrade to fuel-vm 0.45.0 - [#1633](https://github.com/FuelLabs/fuel-core/pull/1633): Notify services about importing of the genesis block. - [#1625](https://github.com/FuelLabs/fuel-core/pull/1625): Making relayer independent from the executor and preparation for the force transaction inclusion. - [#1613](https://github.com/FuelLabs/fuel-core/pull/1613): Add api endpoint to retrieve a message by its nonce. diff --git a/Cargo.lock b/Cargo.lock index 187fe254f60..c5539af5629 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2591,9 +2591,9 @@ dependencies = [ [[package]] name = "fuel-asm" -version = "0.44.0" +version = "0.45.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe999b5964065e569092405bb58ec6a5b82c0368a0a9627ad48403583013506f" +checksum = "fb9742c03ebf8a385c4ff06365fc0b34feb2a6c302ad5ea9fa7c2201c97e3787" dependencies = [ "bitflags 2.4.2", "fuel-types", @@ -3125,9 +3125,9 @@ dependencies = [ [[package]] name = "fuel-crypto" -version = "0.44.0" +version = "0.45.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "607c74d6c2df713b3945ca9fc4ac5a50bec55b405d9375b7cc684b9e3960c74a" +checksum = "ea44d0234e5f422b1e9102431fadbc544474537ca82f590e7979d49f6c6a9644" dependencies = [ "coins-bip32", "coins-bip39", @@ -3146,9 +3146,9 @@ dependencies = [ [[package]] name = "fuel-derive" -version = "0.44.0" +version = "0.45.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92f1e5e1602c4b554b98e84a924d97621641d27ccec643c9468844329cee05e7" +checksum = "e14035997d8f28ac078227e72d081020c9383edc82fbf42ddd9ac8da120d71f1" dependencies = [ "proc-macro2", "quote", @@ -3158,9 +3158,9 @@ dependencies = [ [[package]] name = "fuel-merkle" -version = "0.44.0" +version = "0.45.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1077a43ef91efcd2839ec649e595b5d89f2b130e927c3abd71f78189b376c30" +checksum = "625db7a9d7c06e5ed9a02fcc61214e660bdd8756c19e2b4bb0ed4cb5fea2791b" dependencies = [ "derive_more", "digest 0.10.7", @@ -3173,15 +3173,15 @@ dependencies = [ [[package]] name = "fuel-storage" -version = "0.44.0" +version = "0.45.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ee976cc2f29f4ba6d6758d6892c421a7079a654b29777d808641c64288a98b9" +checksum = "b972d21d92bce35117c2dded7d9c820fc52628c586d4693f97e820c054148581" [[package]] name = "fuel-tx" -version = "0.44.0" +version = "0.45.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3ada9cb4520034ccce5f89c3b6b791fc830cc5b8c2b37ecfb2f50059e962672" +checksum = "7f7ae78697a841869fef2a15ad050682f52874d469440e09732a5b0d18eb10bf" dependencies = [ "bitflags 2.4.2", "derivative", @@ -3201,9 +3201,9 @@ dependencies = [ [[package]] name = "fuel-types" -version = "0.44.0" +version = "0.45.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8d2dd56d12e5022ac047de40e3e461d192d28e3931ed00338150fd62993ff49" +checksum = "7bbd77fd02a4390c120b1b5ba6543038965ab1c7aa9797d12cb8dcc5bb1157db" dependencies = [ "fuel-derive", "hex", @@ -3213,9 +3213,9 @@ dependencies = [ [[package]] name = "fuel-vm" -version = "0.44.0" +version = "0.45.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0615e83572095957e7e235356fa7f3e5706d17a3aff62d1d206ec480013ea99" +checksum = "65b450088ac08da9570fad4a12b42ceae1725921140d95e07a1fbcfa055945b7" dependencies = [ "anyhow", "async-trait", diff --git a/Cargo.toml b/Cargo.toml index 4bb79d81763..2db2dcc899a 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.44.0", package = "fuel-vm", default-features = false } +fuel-vm-private = { version = "0.45.0", package = "fuel-vm", default-features = false } # Common dependencies anyhow = "1.0" diff --git a/crates/client/src/client/schema/tx/transparent_tx.rs b/crates/client/src/client/schema/tx/transparent_tx.rs index d6b491e7f62..d6fe6a3b163 100644 --- a/crates/client/src/client/schema/tx/transparent_tx.rs +++ b/crates/client/src/client/schema/tx/transparent_tx.rs @@ -250,7 +250,7 @@ impl TryFrom for fuel_tx::Transaction { .collect(), ); create.into() - } else if tx.is_mint { + } else { let tx_pointer: fuel_tx::TxPointer = tx .tx_pointer .ok_or_else(|| ConversionError::MissingField("tx_pointer".to_string()))? @@ -279,8 +279,16 @@ impl TryFrom for fuel_tx::Transaction { .into(), ); mint.into() - } else { - return Err(ConversionError::UnknownVariant("Transaction")); + }; + + // This `match` block is added here to enforce compilation error if a new variant + // is added into the `fuel_tx::Transaction` enum. + // + // If you face a compilation error, please update the code above and add a new variant below. + match tx { + fuel_tx::Transaction::Script(_) => {} + fuel_tx::Transaction::Create(_) => {} + fuel_tx::Transaction::Mint(_) => {} }; Ok(tx) diff --git a/crates/fuel-core/src/graphql_api/worker_service.rs b/crates/fuel-core/src/graphql_api/worker_service.rs index 600e489708d..22f54719227 100644 --- a/crates/fuel-core/src/graphql_api/worker_service.rs +++ b/crates/fuel-core/src/graphql_api/worker_service.rs @@ -102,7 +102,7 @@ where inputs = tx.inputs().as_slice(); outputs = tx.outputs().as_slice(); } - _ => continue, + Transaction::Mint(_) => continue, } self.persist_owners_index( block_height, @@ -143,7 +143,6 @@ where owners.push(to); } Output::Contract(_) | Output::ContractCreated { .. } => {} - _ => {} } } diff --git a/crates/fuel-core/src/schema/tx/input.rs b/crates/fuel-core/src/schema/tx/input.rs index 1fef1956b27..fe037180273 100644 --- a/crates/fuel-core/src/schema/tx/input.rs +++ b/crates/fuel-core/src/schema/tx/input.rs @@ -298,7 +298,6 @@ impl From<&fuel_tx::Input> for Input { predicate: HexString(predicate.clone()), predicate_data: HexString(predicate_data.clone()), }), - input => todo!("No mapping for input {input:?}"), } } } diff --git a/crates/fuel-core/src/schema/tx/output.rs b/crates/fuel-core/src/schema/tx/output.rs index 59dd388bc4c..e4ae5dde7a6 100644 --- a/crates/fuel-core/src/schema/tx/output.rs +++ b/crates/fuel-core/src/schema/tx/output.rs @@ -27,8 +27,6 @@ pub enum Output { ContractCreated(ContractCreated), } -pub type OutputConversionError = String; - pub struct CoinOutput { to: fuel_types::Address, amount: Word, @@ -121,11 +119,9 @@ impl ContractCreated { } } -impl TryFrom<&fuel_tx::Output> for Output { - type Error = OutputConversionError; - - fn try_from(output: &fuel_tx::Output) -> Result { - let val = match output { +impl From<&fuel_tx::Output> for Output { + fn from(output: &fuel_tx::Output) -> Self { + match output { fuel_tx::Output::Coin { to, amount, @@ -161,9 +157,7 @@ impl TryFrom<&fuel_tx::Output> for Output { contract_id: *contract_id, state_root: *state_root, }), - _ => return Err(format!("Unsupported output type: {:?}", output)), - }; - Ok(val) + } } } diff --git a/crates/fuel-core/src/schema/tx/types.rs b/crates/fuel-core/src/schema/tx/types.rs index 02994d1503a..efd58aeeaec 100644 --- a/crates/fuel-core/src/schema/tx/types.rs +++ b/crates/fuel-core/src/schema/tx/types.rs @@ -367,7 +367,7 @@ impl Transaction { .map(|c| AssetId(*c)) .collect(), ), - _ => None, + fuel_tx::Transaction::Mint(_) => None, } } @@ -382,7 +382,6 @@ impl Transaction { fuel_tx::Transaction::Mint(mint) => { Some(vec![Contract(mint.input_contract().contract_id)]) } - _ => None, } } @@ -390,7 +389,6 @@ impl Transaction { match &self.0 { fuel_tx::Transaction::Script(_) | fuel_tx::Transaction::Create(_) => None, fuel_tx::Transaction::Mint(mint) => Some(mint.input_contract().into()), - _ => None, } } @@ -399,7 +397,6 @@ impl Transaction { fuel_tx::Transaction::Script(script) => Some((*script.policies()).into()), fuel_tx::Transaction::Create(create) => Some((*create.policies()).into()), fuel_tx::Transaction::Mint(_) => None, - _ => None, } } @@ -408,7 +405,6 @@ impl Transaction { fuel_tx::Transaction::Script(script) => Some(script.price().into()), fuel_tx::Transaction::Create(create) => Some(create.price().into()), fuel_tx::Transaction::Mint(_) => None, - _ => None, } } @@ -418,7 +414,7 @@ impl Transaction { Some((*script.script_gas_limit()).into()) } fuel_tx::Transaction::Create(_) => Some(0.into()), - _ => None, + fuel_tx::Transaction::Mint(_) => None, } } @@ -427,29 +423,29 @@ impl Transaction { fuel_tx::Transaction::Script(script) => Some(script.maturity().into()), fuel_tx::Transaction::Create(create) => Some(create.maturity().into()), fuel_tx::Transaction::Mint(_) => None, - _ => None, } } async fn mint_amount(&self) -> Option { match &self.0 { + fuel_tx::Transaction::Script(_) | fuel_tx::Transaction::Create(_) => None, fuel_tx::Transaction::Mint(mint) => Some((*mint.mint_amount()).into()), - _ => None, } } async fn mint_asset_id(&self) -> Option { match &self.0 { + fuel_tx::Transaction::Script(_) | fuel_tx::Transaction::Create(_) => None, fuel_tx::Transaction::Mint(mint) => Some((*mint.mint_asset_id()).into()), - _ => None, } } // TODO: Maybe we need to do the same `Script` and `Create` async fn tx_pointer(&self) -> Option { match &self.0 { + fuel_tx::Transaction::Script(_) => None, + fuel_tx::Transaction::Create(_) => None, fuel_tx::Transaction::Mint(mint) => Some((*mint.tx_pointer()).into()), - _ => None, } } @@ -473,32 +469,26 @@ impl Transaction { fuel_tx::Transaction::Create(create) => { Some(create.inputs().iter().map(Into::into).collect()) } - _ => None, + fuel_tx::Transaction::Mint(_) => None, } } - async fn outputs(&self) -> Result, async_graphql::Error> { + async fn outputs(&self) -> Vec { match &self.0 { - fuel_tx::Transaction::Script(script) => script - .outputs() - .iter() - .map(TryInto::try_into) - .collect::>() - .map_err(async_graphql::Error::new), - fuel_tx::Transaction::Create(create) => create - .outputs() - .iter() - .map(TryInto::try_into) - .collect::>() - .map_err(async_graphql::Error::new), - _ => Ok(vec![]), + fuel_tx::Transaction::Script(script) => { + script.outputs().iter().map(Into::into).collect() + } + fuel_tx::Transaction::Create(create) => { + create.outputs().iter().map(Into::into).collect() + } + fuel_tx::Transaction::Mint(_) => vec![], } } async fn output_contract(&self) -> Option { match &self.0 { + fuel_tx::Transaction::Script(_) | fuel_tx::Transaction::Create(_) => None, fuel_tx::Transaction::Mint(mint) => Some(mint.output_contract().into()), - _ => None, } } @@ -519,7 +509,6 @@ impl Transaction { .collect(), ), fuel_tx::Transaction::Mint(_) => None, - _ => None, } } @@ -528,7 +517,8 @@ impl Transaction { fuel_tx::Transaction::Script(script) => { Some((*script.receipts_root()).into()) } - _ => None, + fuel_tx::Transaction::Create(_) => None, + fuel_tx::Transaction::Mint(_) => None, } } @@ -558,7 +548,8 @@ impl Transaction { fuel_tx::Transaction::Script(script) => { Some(HexString(script.script().clone())) } - _ => None, + fuel_tx::Transaction::Create(_) => None, + fuel_tx::Transaction::Mint(_) => None, } } @@ -567,37 +558,42 @@ impl Transaction { fuel_tx::Transaction::Script(script) => { Some(HexString(script.script_data().clone())) } - _ => None, + fuel_tx::Transaction::Create(_) => None, + fuel_tx::Transaction::Mint(_) => None, } } 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()) } - _ => None, + 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()) } - _ => None, + fuel_tx::Transaction::Mint(_) => None, } } async fn salt(&self) -> Option { match &self.0 { + fuel_tx::Transaction::Script(_) => None, fuel_tx::Transaction::Create(create) => Some((*create.salt()).into()), - _ => None, + fuel_tx::Transaction::Mint(_) => None, } } async fn storage_slots(&self) -> Option> { match &self.0 { + fuel_tx::Transaction::Script(_) => None, fuel_tx::Transaction::Create(create) => Some( create .storage_slots() @@ -614,7 +610,7 @@ impl Transaction { }) .collect(), ), - _ => None, + fuel_tx::Transaction::Mint(_) => None, } } diff --git a/crates/services/executor/src/executor.rs b/crates/services/executor/src/executor.rs index ea9c7ab07c0..75851e4a760 100644 --- a/crates/services/executor/src/executor.rs +++ b/crates/services/executor/src/executor.rs @@ -1189,7 +1189,6 @@ where ) } } - _ => return Err(ExecutorError::UnknownTransactionType("Output")), } } @@ -1600,7 +1599,6 @@ where }, )?; } - _ => return Err(ExecutorError::UnknownTransactionType("Output")), } } Ok(()) diff --git a/crates/services/txpool/src/containers/dependency.rs b/crates/services/txpool/src/containers/dependency.rs index ec1efb4ea84..cdd8959899b 100644 --- a/crates/services/txpool/src/containers/dependency.rs +++ b/crates/services/txpool/src/containers/dependency.rs @@ -156,7 +156,6 @@ impl Dependency { | Input::MessageDataPredicate(_) => { // Message inputs do not depend on any other fuel transactions } - _ => {} } } } @@ -239,7 +238,6 @@ impl Dependency { Output::ContractCreated { .. } => { return Err(Error::NotInsertedIoContractOutput.into()) } - _ => todo!("Unsupported output type"), }; } else { return Err(anyhow!("Use it only for coin output check")) @@ -440,7 +438,6 @@ impl Dependency { // yey we got our contract } - _ => todo!("Unsupported input type"), } } @@ -521,7 +518,6 @@ impl Dependency { | Input::MessageCoinPredicate(_) | Input::MessageDataSigned(_) | Input::MessageDataPredicate(_) => {} - _ => todo!("Unsupported input type"), } } @@ -569,7 +565,6 @@ impl Dependency { // do nothing, this contract is already already found in dependencies. // as it is tied with input and used_by is already inserted. } - _ => todo!("Unsupported output type"), }; } @@ -629,7 +624,6 @@ impl Dependency { } } } - _ => todo!("Unsupported output type"), }; } @@ -673,7 +667,6 @@ impl Dependency { | Input::MessageDataPredicate(MessageDataPredicate { nonce, .. }) => { self.messages.remove(nonce); } - _ => todo!("Unsupported input type"), } } diff --git a/crates/services/txpool/src/txpool.rs b/crates/services/txpool/src/txpool.rs index 9d30c6e828c..63a84a803b5 100644 --- a/crates/services/txpool/src/txpool.rs +++ b/crates/services/txpool/src/txpool.rs @@ -455,7 +455,7 @@ fn verify_tx_min_gas_price(tx: &Transaction, config: &Config) -> Result<(), Erro let price = match tx { Transaction::Script(script) => script.price(), Transaction::Create(create) => create.price(), - _ => return Err(Error::NotSupportedTransactionType), + Transaction::Mint(_) => return Err(Error::NotSupportedTransactionType), }; if config.metrics { // Gas Price metrics are recorded here to avoid double matching for diff --git a/crates/storage/src/vm_storage.rs b/crates/storage/src/vm_storage.rs index 785dfbde1d3..f378e709474 100644 --- a/crates/storage/src/vm_storage.rs +++ b/crates/storage/src/vm_storage.rs @@ -378,6 +378,6 @@ where let slots = slots .map(|(key, value)| (ContractsStateKey::new(contract_id, &key), value)) .collect_vec(); - self.init_storage(slots.iter().map(|(key, value)| (key, value))) + self.init_storage(slots.iter().map(|kv| (&kv.0, &kv.1))) } } diff --git a/crates/types/src/services/executor.rs b/crates/types/src/services/executor.rs index af44c75ea21..f9cb76b72ce 100644 --- a/crates/types/src/services/executor.rs +++ b/crates/types/src/services/executor.rs @@ -273,8 +273,6 @@ pub enum Error { CoinbaseAmountMismatch, #[from] TransactionValidity(TransactionValidityError), - #[display(fmt = "Transaction contained an unsupported variant of {_0}.")] - UnknownTransactionType(&'static str), // TODO: Replace with `fuel_core_storage::Error` when execution error will live in the // `fuel-core-executor`. #[display(fmt = "got error during work with storage {_0}")]