diff --git a/CHANGELOG.md b/CHANGELOG.md index 95e7126d..4e9e8c3b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -67,6 +67,7 @@ Description of the upcoming release here. - [#1408](https://github.com/FuelLabs/fuel-core/pull/1408): Update gas benchmarks for storage opcodes to use a pre-populated database to get more accurate worst-case costs. #### Breaking +- [#1464](https://github.com/FuelLabs/fuel-core/pull/1464): Avoid possible truncation of higher bits. It may invalidate the code that truncated higher bits causing different behavior on 32-bit vs. 64-bit systems. The change affects some endpoints that now require lesser integers. - [#1432](https://github.com/FuelLabs/fuel-core/pull/1432): All subscriptions and requests have a TTL now. So each subscription lifecycle is limited in time. If the subscription is closed because of TTL, it means that you subscribed after your transaction had been dropped by the network. - [#1407](https://github.com/FuelLabs/fuel-core/pull/1407): The recipient is a `ContractId` instead of `Address`. The block producer should deploy its contract to receive the transaction fee. The collected fee is zero until the recipient contract is set. - [#1407](https://github.com/FuelLabs/fuel-core/pull/1407): The `Mint` transaction is reworked with new fields to support the account-base model. It affects serialization and deserialization of the transaction and also affects GraphQL schema. diff --git a/Cargo.lock b/Cargo.lock index a533b9aa..6ca591c2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2789,11 +2789,6 @@ dependencies = [ [[package]] name = "fuel-core-bft" version = "0.20.8" -dependencies = [ - "anyhow", - "parking_lot 0.12.1", - "tokio", -] [[package]] name = "fuel-core-bin" diff --git a/benches/src/bin/collect.rs b/benches/src/bin/collect.rs index 9d61686f..fbd17425 100644 --- a/benches/src/bin/collect.rs +++ b/benches/src/bin/collect.rs @@ -185,7 +185,7 @@ fn main() { let mut reader = readers.next().unwrap(); while let Err(TryRecvError::Empty) = rx.try_recv() { match reader.read_line(&mut line) { - Ok(amount) if amount == 0 => { + Ok(0) => { reader = match readers.next() { Some(r) => r, None => break, diff --git a/benches/src/import.rs b/benches/src/import.rs index 88f26857..aa686a98 100644 --- a/benches/src/import.rs +++ b/benches/src/import.rs @@ -48,7 +48,7 @@ pub fn provision_import_test( ) { let shared_notify = Arc::new(Notify::new()); let params = Config { - header_batch_size, + header_batch_size: header_batch_size as usize, block_stream_buffer_size, }; let p2p = Arc::new(PressurePeerToPeer::new( diff --git a/bin/fuel-core/src/cli/run/p2p.rs b/bin/fuel-core/src/cli/run/p2p.rs index 64af86b4..d7917c8b 100644 --- a/bin/fuel-core/src/cli/run/p2p.rs +++ b/bin/fuel-core/src/cli/run/p2p.rs @@ -228,7 +228,7 @@ impl From for fuel_core::sync::Config { fn from(value: SyncArgs) -> Self { Self { block_stream_buffer_size: value.block_stream_buffer_size, - header_batch_size: value.header_batch_size, + header_batch_size: value.header_batch_size as usize, } } } diff --git a/crates/chain-config/src/lib.rs b/crates/chain-config/src/lib.rs index a59e2474..a3ead0bc 100644 --- a/crates/chain-config/src/lib.rs +++ b/crates/chain-config/src/lib.rs @@ -1,3 +1,4 @@ +#![deny(clippy::cast_possible_truncation)] #![deny(unused_crate_dependencies)] #![deny(warnings)] diff --git a/crates/client/assets/schema.sdl b/crates/client/assets/schema.sdl index a309827f..bd3aaa85 100644 --- a/crates/client/assets/schema.sdl +++ b/crates/client/assets/schema.sdl @@ -590,7 +590,7 @@ type Mutation { `Trigger::Interval { block_time }`, produces blocks with `block_time ` intervals between them. The `start_timestamp` is the timestamp in seconds. """ - produceBlocks(startTimestamp: Tai64Timestamp, blocksToProduce: U64!): U32! + produceBlocks(startTimestamp: Tai64Timestamp, blocksToProduce: U32!): U32! } type NodeInfo { @@ -657,11 +657,11 @@ type ProgramState { } type Query { - register(id: ID!, register: U64!): U64! - memory(id: ID!, start: U64!, size: U64!): String! + register(id: ID!, register: U32!): U64! + memory(id: ID!, start: U32!, size: U32!): String! balance(owner: Address!, assetId: AssetId!): Balance! balances(filter: BalanceFilterInput!, first: Int, after: String, last: Int, before: String): BalanceConnection! - block(id: BlockId, height: U64): Block + block(id: BlockId, height: U32): Block blocks(first: Int, after: String, last: Int, before: String): BlockConnection! chain: ChainInfo! transaction(id: TransactionId!): Transaction @@ -794,7 +794,7 @@ input SpendQueryElementInput { """ The maximum number of currencies for selection. """ - max: U64 + max: U32 } type SqueezedOutStatus { diff --git a/crates/client/src/client.rs b/crates/client/src/client.rs index 2097c7e5..4164c422 100644 --- a/crates/client/src/client.rs +++ b/crates/client/src/client.rs @@ -36,7 +36,6 @@ use cynic::{ use fuel_core_types::{ fuel_asm::{ Instruction, - RegisterId, Word, }, fuel_tx::{ @@ -83,6 +82,7 @@ use schema::{ SetSingleSteppingArgs, StartTx, StartTxArgs, + U32, U64, }; #[cfg(feature = "subscriptions")] @@ -115,6 +115,8 @@ pub mod pagination; pub mod schema; pub mod types; +type RegisterId = u32; + #[derive(Debug, Clone)] pub struct FuelClient { client: reqwest::Client, @@ -473,12 +475,7 @@ impl FuelClient { Ok(self.query(query).await?.register.0 as Word) } - pub async fn memory( - &self, - id: &str, - start: usize, - size: usize, - ) -> io::Result> { + pub async fn memory(&self, id: &str, start: u32, size: u32) -> io::Result> { let query = schema::Memory::build(MemoryArgs { id: id.into(), start: start.into(), @@ -689,7 +686,7 @@ impl FuelClient { pub async fn produce_blocks( &self, - blocks_to_produce: u64, + blocks_to_produce: u32, start_timestamp: Option, ) -> io::Result { let query = schema::block::BlockMutation::build(ProduceBlockArgs { @@ -713,9 +710,9 @@ impl FuelClient { Ok(block) } - pub async fn block_by_height(&self, height: u64) -> io::Result> { + pub async fn block_by_height(&self, height: u32) -> io::Result> { let query = schema::block::BlockByHeightQuery::build(BlockByHeightArgs { - height: Some(U64(height)), + height: Some(U32(height)), }); let block = self.query(query).await?.block.map(Into::into); @@ -765,7 +762,7 @@ impl FuelClient { pub async fn coins_to_spend( &self, owner: &Address, - spend_query: Vec<(AssetId, u64, Option)>, + spend_query: Vec<(AssetId, u64, Option)>, // (Utxos, Messages Nonce) excluded_ids: Option<(Vec, Vec)>, ) -> io::Result>> { diff --git a/crates/client/src/client/pagination.rs b/crates/client/src/client/pagination.rs index afc99678..7f843db7 100644 --- a/crates/client/src/client/pagination.rs +++ b/crates/client/src/client/pagination.rs @@ -11,7 +11,7 @@ pub struct PaginationRequest { /// The cursor returned from a previous query to indicate an offset pub cursor: Option, /// The number of results to take - pub results: usize, + pub results: i32, /// The direction of the query (e.g. asc, desc order). pub direction: PageDirection, } diff --git a/crates/client/src/client/schema.rs b/crates/client/src/client/schema.rs index 2ede5eaf..11de7251 100644 --- a/crates/client/src/client/schema.rs +++ b/crates/client/src/client/schema.rs @@ -95,7 +95,7 @@ pub struct Execute { #[derive(cynic::QueryVariables)] pub struct RegisterArgs { pub id: cynic::Id, - pub register: U64, + pub register: U32, } #[derive(cynic::QueryFragment, Debug)] @@ -112,8 +112,8 @@ pub struct Register { #[derive(cynic::QueryVariables)] pub struct MemoryArgs { pub id: cynic::Id, - pub start: U64, - pub size: U64, + pub start: U32, + pub size: U32, } #[derive(cynic::QueryFragment, Debug)] @@ -263,14 +263,14 @@ impl> From> for ConnectionArgs { PageDirection::Forward => Self { after: req.cursor.map(Into::into), before: None, - first: Some(req.results as i32), + first: Some(req.results), last: None, }, PageDirection::Backward => Self { after: None, before: req.cursor.map(Into::into), first: None, - last: Some(req.results as i32), + last: Some(req.results), }, } } diff --git a/crates/client/src/client/schema/balance.rs b/crates/client/src/client/schema/balance.rs index 98b0a7b3..50f85a4a 100644 --- a/crates/client/src/client/schema/balance.rs +++ b/crates/client/src/client/schema/balance.rs @@ -56,7 +56,7 @@ impl From<(Address, PaginationRequest)> for BalancesConnectionArgs { filter: BalanceFilterInput { owner: r.0 }, after: r.1.cursor, before: None, - first: Some(r.1.results as i32), + first: Some(r.1.results), last: None, }, PageDirection::Backward => BalancesConnectionArgs { @@ -64,7 +64,7 @@ impl From<(Address, PaginationRequest)> for BalancesConnectionArgs { after: None, before: r.1.cursor, first: None, - last: Some(r.1.results as i32), + last: Some(r.1.results), }, } } diff --git a/crates/client/src/client/schema/block.rs b/crates/client/src/client/schema/block.rs index 638d0997..54bee132 100644 --- a/crates/client/src/client/schema/block.rs +++ b/crates/client/src/client/schema/block.rs @@ -33,7 +33,7 @@ pub struct BlockByIdQuery { #[derive(cynic::QueryVariables, Debug)] pub struct BlockByHeightArgs { - pub height: Option, + pub height: Option, } #[derive(cynic::QueryFragment, Debug)] @@ -90,7 +90,7 @@ pub struct BlockIdFragment { #[derive(cynic::QueryVariables, Debug)] pub struct ProduceBlockArgs { pub start_timestamp: Option, - pub blocks_to_produce: U64, + pub blocks_to_produce: U32, } #[derive(cynic::QueryFragment, Debug)] @@ -176,7 +176,7 @@ mod tests { fn block_by_height_query_gql_output() { use cynic::QueryBuilder; let operation = BlockByHeightQuery::build(BlockByHeightArgs { - height: Some(U64(0)), + height: Some(U32(0)), }); insta::assert_snapshot!(operation.query) } @@ -185,7 +185,7 @@ mod tests { fn block_mutation_query_gql_output() { use cynic::MutationBuilder; let operation = BlockMutation::build(ProduceBlockArgs { - blocks_to_produce: U64(0), + blocks_to_produce: U32(0), start_timestamp: None, }); insta::assert_snapshot!(operation.query) diff --git a/crates/client/src/client/schema/coins.rs b/crates/client/src/client/schema/coins.rs index debfa67e..4aa265a8 100644 --- a/crates/client/src/client/schema/coins.rs +++ b/crates/client/src/client/schema/coins.rs @@ -63,7 +63,7 @@ impl From<(Address, AssetId, PaginationRequest)> for CoinsConnectionArgs }, after: r.2.cursor, before: None, - first: Some(r.2.results as i32), + first: Some(r.2.results), last: None, }, PageDirection::Backward => CoinsConnectionArgs { @@ -74,7 +74,7 @@ impl From<(Address, AssetId, PaginationRequest)> for CoinsConnectionArgs after: None, before: r.2.cursor, first: None, - last: Some(r.2.results as i32), + last: Some(r.2.results), }, } } @@ -146,7 +146,7 @@ pub struct SpendQueryElementInput { /// address of the owner pub amount: U64, /// the maximum number of coins per asset from the owner to return. - pub max: Option, + pub max: Option, } #[derive(cynic::QueryFragment, Debug, Clone)] diff --git a/crates/client/src/client/schema/contract.rs b/crates/client/src/client/schema/contract.rs index 2bdbc1be..5bd9303d 100644 --- a/crates/client/src/client/schema/contract.rs +++ b/crates/client/src/client/schema/contract.rs @@ -121,7 +121,7 @@ impl From<(ContractId, PaginationRequest)> for ContractBalancesConnectio filter: ContractBalanceFilterInput { contract: r.0 }, after: r.1.cursor, before: None, - first: Some(r.1.results as i32), + first: Some(r.1.results), last: None, }, PageDirection::Backward => ContractBalancesConnectionArgs { @@ -129,7 +129,7 @@ impl From<(ContractId, PaginationRequest)> for ContractBalancesConnectio after: None, before: r.1.cursor, first: None, - last: Some(r.1.results as i32), + last: Some(r.1.results), }, } } diff --git a/crates/client/src/client/schema/message.rs b/crates/client/src/client/schema/message.rs index f0f1efb7..b8af4b36 100644 --- a/crates/client/src/client/schema/message.rs +++ b/crates/client/src/client/schema/message.rs @@ -177,7 +177,7 @@ impl From<(Option
, PaginationRequest)> for OwnedMessagesConnect owner: r.0, after: r.1.cursor, before: None, - first: Some(r.1.results as i32), + first: Some(r.1.results), last: None, }, PageDirection::Backward => OwnedMessagesConnectionArgs { @@ -185,7 +185,7 @@ impl From<(Option
, PaginationRequest)> for OwnedMessagesConnect after: None, before: r.1.cursor, first: None, - last: Some(r.1.results as i32), + last: Some(r.1.results), }, } } diff --git a/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__block__tests__block_by_height_query_gql_output.snap b/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__block__tests__block_by_height_query_gql_output.snap index d17eda9e..71c3853a 100644 --- a/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__block__tests__block_by_height_query_gql_output.snap +++ b/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__block__tests__block_by_height_query_gql_output.snap @@ -2,7 +2,7 @@ source: crates/client/src/client/schema/block.rs expression: operation.query --- -query($height: U64) { +query($height: U32) { block(height: $height) { id header { diff --git a/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__block__tests__block_mutation_query_gql_output.snap b/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__block__tests__block_mutation_query_gql_output.snap index 31910e67..5fbb114c 100644 --- a/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__block__tests__block_mutation_query_gql_output.snap +++ b/crates/client/src/client/schema/snapshots/fuel_core_client__client__schema__block__tests__block_mutation_query_gql_output.snap @@ -2,7 +2,7 @@ source: crates/client/src/client/schema/block.rs expression: operation.query --- -mutation($startTimestamp: Tai64Timestamp, $blocksToProduce: U64!) { +mutation($startTimestamp: Tai64Timestamp, $blocksToProduce: U32!) { produceBlocks(blocksToProduce: $blocksToProduce, startTimestamp: $startTimestamp) } diff --git a/crates/client/src/client/schema/tx.rs b/crates/client/src/client/schema/tx.rs index 64776d2a..04a699d9 100644 --- a/crates/client/src/client/schema/tx.rs +++ b/crates/client/src/client/schema/tx.rs @@ -216,7 +216,7 @@ impl From<(Address, PaginationRequest)> for TransactionsByOwnerConnectio owner: r.0, after: r.1.cursor, before: None, - first: Some(r.1.results as i32), + first: Some(r.1.results), last: None, }, PageDirection::Backward => TransactionsByOwnerConnectionArgs { @@ -224,7 +224,7 @@ impl From<(Address, PaginationRequest)> for TransactionsByOwnerConnectio after: None, before: r.1.cursor, first: None, - last: Some(r.1.results as i32), + last: Some(r.1.results), }, } } diff --git a/crates/client/src/lib.rs b/crates/client/src/lib.rs index 13576822..75c244d5 100644 --- a/crates/client/src/lib.rs +++ b/crates/client/src/lib.rs @@ -1,3 +1,4 @@ +#![deny(clippy::cast_possible_truncation)] #![deny(unused_crate_dependencies)] #![deny(warnings)] pub mod client; diff --git a/crates/database/src/lib.rs b/crates/database/src/lib.rs index f30e91c0..2c4d856d 100644 --- a/crates/database/src/lib.rs +++ b/crates/database/src/lib.rs @@ -4,6 +4,7 @@ //! defined here are used by services but are flexible enough to customize the //! logic when the `Database` is known. +#![deny(clippy::cast_possible_truncation)] #![deny(missing_docs)] #![deny(unused_crate_dependencies)] #![deny(warnings)] diff --git a/crates/fuel-core/src/coins_query.rs b/crates/fuel-core/src/coins_query.rs index 070ced7f..91cf0542 100644 --- a/crates/fuel-core/src/coins_query.rs +++ b/crates/fuel-core/src/coins_query.rs @@ -344,7 +344,7 @@ mod tests { // Query some targets, including higher than the owner's balance for target in 0..20 { let coins = query( - &[AssetSpendTarget::new(asset_id, target, u64::MAX)], + &[AssetSpendTarget::new(asset_id, target, usize::MAX)], &owner, base_asset_id, &db.service_database(), @@ -440,8 +440,8 @@ mod tests { ) { let coins = query( &[ - AssetSpendTarget::new(asset_ids[0], 3, u64::MAX), - AssetSpendTarget::new(asset_ids[1], 6, u64::MAX), + AssetSpendTarget::new(asset_ids[0], 3, usize::MAX), + AssetSpendTarget::new(asset_ids[1], 6, usize::MAX), ], &owner, base_asset_id, @@ -514,7 +514,7 @@ mod tests { // Query some amounts, including higher than the owner's balance for amount in 0..20 { let coins = query( - vec![AssetSpendTarget::new(asset_id, amount, u64::MAX)], + vec![AssetSpendTarget::new(asset_id, amount, usize::MAX)], owner, asset_ids, base_asset_id, @@ -706,7 +706,7 @@ mod tests { // Query some amounts, including higher than the owner's balance for amount in 0..20 { let coins = query( - vec![AssetSpendTarget::new(asset_id, amount, u64::MAX)], + vec![AssetSpendTarget::new(asset_id, amount, usize::MAX)], excluded_ids.clone(), ); diff --git a/crates/fuel-core/src/database/block.rs b/crates/fuel-core/src/database/block.rs index 74198364..b8584aa2 100644 --- a/crates/fuel-core/src/database/block.rs +++ b/crates/fuel-core/src/database/block.rs @@ -371,20 +371,20 @@ mod tests { assert!(matches!(err, fuel_core_storage::Error::NotFound(_, _))); } - const TEST_BLOCKS_COUNT: usize = 10; + const TEST_BLOCKS_COUNT: u32 = 10; fn insert_test_ascending_blocks( database: &mut Database, genesis_height: BlockHeight, ) { - let start = genesis_height.as_usize(); + let start = *genesis_height; // Generate 10 blocks with ascending heights let blocks = (start..start + TEST_BLOCKS_COUNT) .map(|height| { let header = PartialBlockHeader { application: Default::default(), consensus: ConsensusHeader:: { - height: BlockHeight::from(height as u32), + height: BlockHeight::from(height), ..Default::default() }, }; @@ -431,8 +431,8 @@ mod tests { for r in l..TEST_BLOCKS_COUNT { let proof = database .block_history_proof( - &BlockHeight::from(genesis_height + l as u32), - &BlockHeight::from(genesis_height + r as u32), + &BlockHeight::from(genesis_height + l), + &BlockHeight::from(genesis_height + r), ) .expect("Should return the merkle proof"); assert_eq!(proof.proof_index, l as u64); @@ -447,8 +447,8 @@ mod tests { insert_test_ascending_blocks(&mut database, BlockHeight::from(0)); let result = database.block_history_proof( - &BlockHeight::from(TEST_BLOCKS_COUNT as u32), - &BlockHeight::from(TEST_BLOCKS_COUNT as u32 - 1), + &BlockHeight::from(TEST_BLOCKS_COUNT), + &BlockHeight::from(TEST_BLOCKS_COUNT - 1), ); assert!(result.is_err()); } diff --git a/crates/fuel-core/src/database/vm_database.rs b/crates/fuel-core/src/database/vm_database.rs index df4ecf3e..59200765 100644 --- a/crates/fuel-core/src/database/vm_database.rs +++ b/crates/fuel-core/src/database/vm_database.rs @@ -234,7 +234,8 @@ impl InterpreterStorage for VmDatabase { Some(ContractsStateKey::new(contract_id, start_key)), Some(IterDirection::Forward), ); - let range = range as usize; + let range = usize::try_from(range) + .expect("Corresponding PR in `fuel-vm` https://github.com/FuelLabs/fuel-vm/pull/619 will use `usize`"); let mut expected_key = U256::from_big_endian(start_key.as_ref()); let mut results = vec![]; @@ -609,7 +610,7 @@ mod tests { .is_some(); // check stored data - let results: Vec<_> = (0..(remove_count as usize)) + let results: Vec<_> = (0..remove_count) .filter_map(|i| { let current_key = U256::from_big_endian(&start_key) + i; let current_key = u256_to_bytes32(current_key); diff --git a/crates/fuel-core/src/executor.rs b/crates/fuel-core/src/executor.rs index 0bd0f4e3..4fb215e6 100644 --- a/crates/fuel-core/src/executor.rs +++ b/crates/fuel-core/src/executor.rs @@ -1494,13 +1494,18 @@ where .copied() .map(|result| FuelBacktrace::from_vm_error(vm, result)) { + let sp = usize::try_from(backtrace.registers()[RegId::SP]).expect( + "The `$sp` register points to the memory of the VM. \ + Because the VM's memory is limited by the `usize` of the system, \ + it is impossible to lose higher bits during truncation.", + ); warn!( target = "vm", "Backtrace on contract: 0x{:x}\nregisters: {:?}\ncall_stack: {:?}\nstack\n: {}", backtrace.contract(), backtrace.registers(), backtrace.call_stack(), - hex::encode(&backtrace.memory()[..backtrace.registers()[RegId::SP] as usize]), // print stack + hex::encode(&backtrace.memory()[..sp]), // print stack ); } } @@ -1516,7 +1521,9 @@ where outputs: &[Output], ) -> ExecutorResult<()> { for (output_index, output) in outputs.iter().enumerate() { - let utxo_id = UtxoId::new(*tx_id, output_index as u8); + let index = u8::try_from(output_index) + .expect("Transaction can have only up to `u8::MAX` outputs"); + let utxo_id = UtxoId::new(*tx_id, index); match output { Output::Coin { amount, @@ -1639,6 +1646,8 @@ where let block_height = *block.header().height(); let inputs; let outputs; + let tx_idx = + u16::try_from(tx_idx).map_err(|_| ExecutorError::TooManyTransactions)?; let tx_id = tx.id(&self.config.consensus_parameters.chain_id); match tx { Transaction::Script(tx) => { @@ -1656,7 +1665,7 @@ where inputs, outputs, &tx_id, - tx_idx as u16, + tx_idx, block_db_transaction.deref_mut(), )?; } @@ -1771,6 +1780,7 @@ impl Fee for CreateCheckedMetadata { } } +#[allow(clippy::cast_possible_truncation)] #[cfg(test)] mod tests { use super::*; diff --git a/crates/fuel-core/src/lib.rs b/crates/fuel-core/src/lib.rs index 90a3ca1b..6653d97d 100644 --- a/crates/fuel-core/src/lib.rs +++ b/crates/fuel-core/src/lib.rs @@ -1,3 +1,4 @@ +#![deny(clippy::cast_possible_truncation)] #![deny(unused_crate_dependencies)] #![deny(warnings)] diff --git a/crates/fuel-core/src/query/balance.rs b/crates/fuel-core/src/query/balance.rs index df6eb13b..aa25157e 100644 --- a/crates/fuel-core/src/query/balance.rs +++ b/crates/fuel-core/src/query/balance.rs @@ -52,7 +52,7 @@ impl BalanceQueryData for Database { ) -> StorageResult { let amount = AssetQuery::new( &owner, - &AssetSpendTarget::new(asset_id, u64::MAX, u64::MAX), + &AssetSpendTarget::new(asset_id, u64::MAX, usize::MAX), &base_asset_id, None, self, diff --git a/crates/fuel-core/src/query/balance/asset_query.rs b/crates/fuel-core/src/query/balance/asset_query.rs index 73ed9b70..e93c9d0f 100644 --- a/crates/fuel-core/src/query/balance/asset_query.rs +++ b/crates/fuel-core/src/query/balance/asset_query.rs @@ -32,12 +32,8 @@ pub struct AssetSpendTarget { } impl AssetSpendTarget { - pub fn new(id: AssetId, target: u64, max: u64) -> Self { - Self { - id, - target, - max: max as usize, - } + pub fn new(id: AssetId, target: u64, max: usize) -> Self { + Self { id, target, max } } } diff --git a/crates/fuel-core/src/schema/block.rs b/crates/fuel-core/src/schema/block.rs index 67321118..5d503f28 100644 --- a/crates/fuel-core/src/schema/block.rs +++ b/crates/fuel-core/src/schema/block.rs @@ -190,7 +190,7 @@ impl BlockQuery { &self, ctx: &Context<'_>, #[graphql(desc = "ID of the block")] id: Option, - #[graphql(desc = "Height of the block")] height: Option, + #[graphql(desc = "Height of the block")] height: Option, ) -> async_graphql::Result> { let data: &Database = ctx.data_unchecked(); let id = match (id, height) { @@ -201,8 +201,7 @@ impl BlockQuery { } (Some(id), None) => Ok(id.0.into()), (None, Some(height)) => { - let height: u64 = height.into(); - let height: u32 = height.try_into()?; + let height: u32 = height.into(); data.block_id(&height.into()) } (None, None) => { @@ -238,7 +237,7 @@ impl HeaderQuery { &self, ctx: &Context<'_>, #[graphql(desc = "ID of the block")] id: Option, - #[graphql(desc = "Height of the block")] height: Option, + #[graphql(desc = "Height of the block")] height: Option, ) -> async_graphql::Result> { Ok(BlockQuery {} .block(ctx, id, height) @@ -291,7 +290,7 @@ impl BlockMutation { &self, ctx: &Context<'_>, start_timestamp: Option, - blocks_to_produce: U64, + blocks_to_produce: U32, ) -> async_graphql::Result { let query: &Database = ctx.data_unchecked(); let consensus_module = ctx.data_unchecked::(); @@ -302,9 +301,9 @@ impl BlockMutation { } let start_time = start_timestamp.map(|timestamp| timestamp.0); - let blocks_to_produce: u64 = blocks_to_produce.into(); + let blocks_to_produce: u32 = blocks_to_produce.into(); consensus_module - .manually_produce_blocks(start_time, blocks_to_produce as u32) + .manually_produce_blocks(start_time, blocks_to_produce) .await?; query diff --git a/crates/fuel-core/src/schema/coins.rs b/crates/fuel-core/src/schema/coins.rs index 322fcdfe..81f8f587 100644 --- a/crates/fuel-core/src/schema/coins.rs +++ b/crates/fuel-core/src/schema/coins.rs @@ -131,7 +131,7 @@ pub struct SpendQueryElementInput { /// Target amount for the query. amount: U64, /// The maximum number of currencies for selection. - max: Option, + max: Option, } #[derive(async_graphql::InputObject)] @@ -226,9 +226,7 @@ impl CoinQuery { AssetSpendTarget::new( e.asset_id.0, e.amount.0, - e.max - .map(|max| max.0) - .unwrap_or(config.consensus_parameters.tx_params().max_inputs), + e.max.map(|max| max.0 as usize).unwrap_or(usize::MAX), ) }) .collect_vec(); diff --git a/crates/fuel-core/src/schema/dap.rs b/crates/fuel-core/src/schema/dap.rs index 97a1bf7e..38ed5b4f 100644 --- a/crates/fuel-core/src/schema/dap.rs +++ b/crates/fuel-core/src/schema/dap.rs @@ -51,6 +51,7 @@ use tracing::{ }; use uuid::Uuid; +use crate::schema::scalars::U32; use fuel_core_types::fuel_vm::state::DebugEval; pub struct Config { @@ -82,7 +83,7 @@ impl ConcreteStorage { pub fn memory(&self, id: &ID, start: usize, size: usize) -> Option<&[u8]> { let (end, overflow) = start.overflowing_add(size); - if overflow || end > consts::VM_MAX_RAM as usize { + if overflow || end as u64 > consts::VM_MAX_RAM { return None } @@ -221,7 +222,7 @@ impl DapQuery { &self, ctx: &Context<'_>, id: ID, - register: U64, + register: U32, ) -> async_graphql::Result { require_debug(ctx)?; ctx.data_unchecked::() @@ -236,8 +237,8 @@ impl DapQuery { &self, ctx: &Context<'_>, id: ID, - start: U64, - size: U64, + start: U32, + size: U32, ) -> async_graphql::Result { require_debug(ctx)?; ctx.data_unchecked::() diff --git a/crates/fuel-core/src/service/genesis.rs b/crates/fuel-core/src/service/genesis.rs index 96b3df45..4b8208dd 100644 --- a/crates/fuel-core/src/service/genesis.rs +++ b/crates/fuel-core/src/service/genesis.rs @@ -228,6 +228,7 @@ fn init_contracts( { UtxoId::new(tx_id, output_idx) } else { + #[allow(clippy::cast_possible_truncation)] UtxoId::new( // generated transaction id([0..[out_index/255]]) Bytes32::try_from( diff --git a/crates/fuel-core/src/service/sub_services.rs b/crates/fuel-core/src/service/sub_services.rs index 70ddf06c..b68fae2a 100644 --- a/crates/fuel-core/src/service/sub_services.rs +++ b/crates/fuel-core/src/service/sub_services.rs @@ -134,8 +134,6 @@ pub fn init_sub_services( #[cfg(not(feature = "p2p"))] let p2p_adapter = P2PAdapter::new(); - let p2p_adapter = p2p_adapter; - let txpool = fuel_core_txpool::new_service( config.txpool.clone(), database.clone(), diff --git a/crates/keygen/src/lib.rs b/crates/keygen/src/lib.rs index 8dfe2700..f7145103 100644 --- a/crates/keygen/src/lib.rs +++ b/crates/keygen/src/lib.rs @@ -1,5 +1,7 @@ //! Keygen crate +#![deny(clippy::cast_possible_truncation)] + pub const BLOCK_PRODUCTION: &str = "block-production"; pub const P2P: &str = "p2p"; diff --git a/crates/metrics/src/lib.rs b/crates/metrics/src/lib.rs index 1e1489fa..808e73da 100644 --- a/crates/metrics/src/lib.rs +++ b/crates/metrics/src/lib.rs @@ -1,3 +1,4 @@ +#![deny(clippy::cast_possible_truncation)] #![deny(unused_crate_dependencies)] #![deny(warnings)] diff --git a/crates/services/consensus_module/bft/Cargo.toml b/crates/services/consensus_module/bft/Cargo.toml index c3428783..9e24611f 100644 --- a/crates/services/consensus_module/bft/Cargo.toml +++ b/crates/services/consensus_module/bft/Cargo.toml @@ -8,8 +8,3 @@ keywords = ["blockchain", "fuel", "consensus", "bft"] license = { workspace = true } repository = { workspace = true } description = "Fuel Core BFT" - -[dependencies] -anyhow = { workspace = true } -parking_lot = { workspace = true } -tokio = { workspace = true, features = ["full"] } diff --git a/crates/services/consensus_module/bft/src/config.rs b/crates/services/consensus_module/bft/src/config.rs deleted file mode 100644 index fd170939..00000000 --- a/crates/services/consensus_module/bft/src/config.rs +++ /dev/null @@ -1,2 +0,0 @@ -#[derive(Default, Debug, Clone)] -pub struct Config {} diff --git a/crates/services/consensus_module/bft/src/lib.rs b/crates/services/consensus_module/bft/src/lib.rs index d6712385..facbc5b6 100644 --- a/crates/services/consensus_module/bft/src/lib.rs +++ b/crates/services/consensus_module/bft/src/lib.rs @@ -1,8 +1,3 @@ +#![deny(clippy::cast_possible_truncation)] #![deny(unused_crate_dependencies)] #![deny(warnings)] - -pub mod config; -pub mod service; - -pub use config::Config; -pub use service::Service; diff --git a/crates/services/consensus_module/bft/src/service.rs b/crates/services/consensus_module/bft/src/service.rs deleted file mode 100644 index e9877a4a..00000000 --- a/crates/services/consensus_module/bft/src/service.rs +++ /dev/null @@ -1,40 +0,0 @@ -use crate::Config; -use parking_lot::Mutex; -use tokio::{ - sync::mpsc, - task::JoinHandle, -}; - -pub struct Service { - join: Mutex>>, - sender: mpsc::Sender<()>, -} - -impl Service { - pub async fn new(_config: &Config, _db: ()) -> anyhow::Result { - let (sender, _receiver) = mpsc::channel(100); - Ok(Self { - sender, - join: Mutex::new(None), - }) - } - - pub async fn start(&self) { - let mut join = self.join.lock(); - if join.is_none() { - *join = Some(tokio::spawn(async {})); - } - } - - pub async fn stop(&self) -> Option> { - let join = self.join.lock().take(); - if join.is_some() { - let _ = self.sender.send(()).await; - } - join - } - - pub fn sender(&self) -> &mpsc::Sender<()> { - &self.sender - } -} diff --git a/crates/services/consensus_module/poa/src/lib.rs b/crates/services/consensus_module/poa/src/lib.rs index c96bfd5b..f9eedfc7 100644 --- a/crates/services/consensus_module/poa/src/lib.rs +++ b/crates/services/consensus_module/poa/src/lib.rs @@ -1,3 +1,4 @@ +#![deny(clippy::cast_possible_truncation)] #![deny(unused_crate_dependencies)] #![deny(unused_must_use)] #![deny(warnings)] diff --git a/crates/services/consensus_module/src/lib.rs b/crates/services/consensus_module/src/lib.rs index 9b07d1ee..6e590b0f 100644 --- a/crates/services/consensus_module/src/lib.rs +++ b/crates/services/consensus_module/src/lib.rs @@ -1,4 +1,5 @@ //! Common traits and logic for managing the lifecycle of services +#![deny(clippy::cast_possible_truncation)] #![deny(unused_crate_dependencies)] #![deny(missing_docs)] #![deny(warnings)] diff --git a/crates/services/executor/src/lib.rs b/crates/services/executor/src/lib.rs index 76935c8c..ba5ece3c 100644 --- a/crates/services/executor/src/lib.rs +++ b/crates/services/executor/src/lib.rs @@ -1,3 +1,4 @@ +#![deny(clippy::cast_possible_truncation)] #![deny(unused_crate_dependencies)] #![deny(warnings)] diff --git a/crates/services/importer/src/lib.rs b/crates/services/importer/src/lib.rs index 33ed8721..4e4bafdb 100644 --- a/crates/services/importer/src/lib.rs +++ b/crates/services/importer/src/lib.rs @@ -1,3 +1,4 @@ +#![deny(clippy::cast_possible_truncation)] #![deny(unused_crate_dependencies)] #![deny(warnings)] diff --git a/crates/services/p2p/src/lib.rs b/crates/services/p2p/src/lib.rs index 5db0022f..b8a576ea 100644 --- a/crates/services/p2p/src/lib.rs +++ b/crates/services/p2p/src/lib.rs @@ -1,3 +1,5 @@ +#![deny(clippy::cast_possible_truncation)] + pub mod behavior; pub mod codecs; pub mod config; diff --git a/crates/services/p2p/src/p2p_service.rs b/crates/services/p2p/src/p2p_service.rs index 81660939..23c2d5e0 100644 --- a/crates/services/p2p/src/p2p_service.rs +++ b/crates/services/p2p/src/p2p_service.rs @@ -167,8 +167,10 @@ impl FuelP2PService { let total_connections = { // Reserved nodes do not count against the configured peer input/output limits. - let total_peers = - config.max_peers_connected + config.reserved_nodes.len() as u32; + let total_peers = config.max_peers_connected + + u32::try_from(config.reserved_nodes.len()).expect( + "The number of reserved nodes should be less than `u32::MAX`", + ); total_peers * config.max_connections_per_peer }; @@ -664,6 +666,7 @@ impl FuelP2PService { } } +#[allow(clippy::cast_possible_truncation)] #[cfg(test)] mod tests { use super::FuelP2PService; diff --git a/crates/services/p2p/src/peer_manager/heartbeat_data.rs b/crates/services/p2p/src/peer_manager/heartbeat_data.rs index a2889dc2..c96e689e 100644 --- a/crates/services/p2p/src/peer_manager/heartbeat_data.rs +++ b/crates/services/p2p/src/peer_manager/heartbeat_data.rs @@ -32,7 +32,10 @@ impl HeartbeatData { if self.durations.is_empty() { Duration::from_secs(0) } else { - self.durations.iter().sum::() / self.durations.len() as u32 + self.durations.iter().sum::() + / u32::try_from(self.durations.len()).expect( + "The size of window is `u32`, so it is impossible to overflow", + ) } } @@ -52,6 +55,7 @@ impl HeartbeatData { } } +#[allow(clippy::cast_possible_truncation)] #[cfg(test)] mod tests { #![allow(non_snake_case)] diff --git a/crates/services/producer/src/lib.rs b/crates/services/producer/src/lib.rs index 08e55542..1b380432 100644 --- a/crates/services/producer/src/lib.rs +++ b/crates/services/producer/src/lib.rs @@ -1,3 +1,4 @@ +#![deny(clippy::cast_possible_truncation)] #![deny(unused_crate_dependencies)] #![deny(unused_must_use)] #![deny(warnings)] diff --git a/crates/services/producer/src/mocks.rs b/crates/services/producer/src/mocks.rs index 8676030a..187a56a5 100644 --- a/crates/services/producer/src/mocks.rs +++ b/crates/services/producer/src/mocks.rs @@ -225,7 +225,9 @@ impl BlockProducerDatabase for MockDb { } fn block_header_merkle_root(&self, height: &BlockHeight) -> StorageResult { - Ok(Bytes32::new([height.as_usize() as u8; 32])) + Ok(Bytes32::new( + [u8::try_from(height.as_usize()).expect("Test use small values"); 32], + )) } fn current_block_height(&self) -> StorageResult { diff --git a/crates/services/relayer/src/lib.rs b/crates/services/relayer/src/lib.rs index dd88f18b..22db3640 100644 --- a/crates/services/relayer/src/lib.rs +++ b/crates/services/relayer/src/lib.rs @@ -1,5 +1,6 @@ //! # Fuel Relayer +#![deny(clippy::cast_possible_truncation)] #![deny(unused_crate_dependencies)] #![forbid(unsafe_code)] #![deny(missing_docs)] diff --git a/crates/services/src/lib.rs b/crates/services/src/lib.rs index ae7adf22..b3bdecef 100644 --- a/crates/services/src/lib.rs +++ b/crates/services/src/lib.rs @@ -1,4 +1,5 @@ //! Common traits and logic for managing the lifecycle of services +#![deny(clippy::cast_possible_truncation)] #![deny(unused_crate_dependencies)] #![deny(missing_docs)] #![deny(warnings)] diff --git a/crates/services/src/service.rs b/crates/services/src/service.rs index 65ca0cf2..ef084e04 100644 --- a/crates/services/src/service.rs +++ b/crates/services/src/service.rs @@ -358,8 +358,14 @@ async fn run( let tracked_result = panic_result.expect("Checked the panic above"); // TODO: Use `u128` when `AtomicU128` is stable. - metric.busy.inc_by(tracked_result.busy.as_nanos() as u64); - metric.idle.inc_by(tracked_result.idle.as_nanos() as u64); + metric.busy.inc_by( + u64::try_from(tracked_result.busy.as_nanos()) + .expect("The task doesn't live longer than `u64`"), + ); + metric.idle.inc_by( + u64::try_from(tracked_result.idle.as_nanos()) + .expect("The task doesn't live longer than `u64`"), + ); let result = tracked_result.output; diff --git a/crates/services/sync/src/import.rs b/crates/services/sync/src/import.rs index 5e35ff75..ee474d4d 100644 --- a/crates/services/sync/src/import.rs +++ b/crates/services/sync/src/import.rs @@ -64,7 +64,7 @@ pub struct Config { /// The maximum number of get transaction requests to make in a single batch. pub block_stream_buffer_size: usize, /// The maximum number of headers to request in a single batch. - pub header_batch_size: u32, + pub header_batch_size: usize, } impl Default for Config { @@ -165,11 +165,13 @@ where let count = self.launch_stream(range.clone(), shutdown).await; // Get the size of the range. - let range_len = range.size_hint().0 as u32; + let range_len = range.size_hint().0; // If we did not process the entire range, mark the failed heights as failed. - if (count as u32) < range_len { - let incomplete_range = (*range.start() + count as u32)..=*range.end(); + if count < range_len { + let count = u32::try_from(count) + .expect("Size of the range can't be more than maximum `BlockHeight`"); + let incomplete_range = (*range.start() + count)..=*range.end(); self.state .apply(|s| s.failed_to_process(incomplete_range.clone())); Err(anyhow::anyhow!( @@ -367,11 +369,14 @@ fn get_header_batch_stream( fn range_chunks( range: RangeInclusive, - chunk_size: u32, + chunk_size: usize, ) -> impl Iterator> { let end = *range.end() + 1; - range.step_by(chunk_size as usize).map(move |chunk_start| { - let block_end = (chunk_start + chunk_size).min(end); + range.step_by(chunk_size).map(move |chunk_start| { + let block_end = (chunk_start + + u32::try_from(chunk_size) + .expect("The size of the chunk can't exceed `u32`")) + .min(end); chunk_start..block_end }) } diff --git a/crates/services/sync/src/import/tests.rs b/crates/services/sync/src/import/tests.rs index b97f2795..91d49eed 100644 --- a/crates/services/sync/src/import/tests.rs +++ b/crates/services/sync/src/import/tests.rs @@ -115,7 +115,8 @@ async fn test_import_3_to_5() { #[tokio::test] async fn test_import_0_to_499() { // The observed block height - let end = 499; + let end_u32: u32 = 499; + let end = end_u32 as usize; // The number of headers/blocks in range 0..end let n = end + 1; // The number of headers/blocks per batch @@ -162,7 +163,7 @@ async fn test_import_0_to_499() { let params = Config { block_stream_buffer_size: 10, - header_batch_size: header_batch_size as u32, + header_batch_size, }; let mocks = Mocks { consensus_port, @@ -170,10 +171,10 @@ async fn test_import_0_to_499() { executor: DefaultMocks::times([n]), }; - let state = State::new(None, end as u32); + let state = State::new(None, end_u32); let state = SharedMutex::new(state); let v = test_import_inner(state, mocks, None, params).await; - let expected = (State::new(end as u32, None), true); + let expected = (State::new(end_u32, None), true); assert_eq!(v, expected); } diff --git a/crates/services/sync/src/lib.rs b/crates/services/sync/src/lib.rs index 2b2fcdc8..e3596d5f 100644 --- a/crates/services/sync/src/lib.rs +++ b/crates/services/sync/src/lib.rs @@ -1,3 +1,4 @@ +#![deny(clippy::cast_possible_truncation)] #![deny(unused_crate_dependencies)] #![deny(missing_docs)] #![deny(warnings)] diff --git a/crates/services/txpool/src/containers/dependency.rs b/crates/services/txpool/src/containers/dependency.rs index 698b06bc..64c3dbcb 100644 --- a/crates/services/txpool/src/containers/dependency.rs +++ b/crates/services/txpool/src/containers/dependency.rs @@ -606,7 +606,13 @@ impl Dependency { // iterate over all outputs and insert them, marking them as available. for (index, output) in tx.outputs().iter().enumerate() { - let utxo_id = UtxoId::new(tx.id(), index as u8); + let index = u8::try_from(index).map_err(|_| { + anyhow::anyhow!( + "The number of outputs in `{}` is more than `u8::max`", + tx.id() + ) + })?; + let utxo_id = UtxoId::new(tx.id(), index); match output { Output::Coin { .. } | Output::Change { .. } | Output::Variable { .. } => { // insert output coin inside by_coin @@ -655,8 +661,11 @@ impl Dependency { // no other transactions can depend on these types of outputs } Output::Coin { .. } | Output::Change { .. } | Output::Variable { .. } => { + let index = u8::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 - let utxo = UtxoId::new(tx.id(), index as u8); + let utxo = UtxoId::new(tx.id(), index); if let Some(state) = self.coins.remove(&utxo).map(|c| c.is_spend_by) { // there may or may not be any dependents for this coin output if let Some(spend_by) = state { diff --git a/crates/services/txpool/src/containers/price_sort.rs b/crates/services/txpool/src/containers/price_sort.rs index d27d0727..c82bfac3 100644 --- a/crates/services/txpool/src/containers/price_sort.rs +++ b/crates/services/txpool/src/containers/price_sort.rs @@ -46,11 +46,7 @@ impl Eq for PriceSortKey {} impl PartialOrd for PriceSortKey { fn partial_cmp(&self, other: &Self) -> Option { - match self.price.partial_cmp(&other.price) { - Some(core::cmp::Ordering::Equal) => {} - ord => return ord, - } - self.tx_id.partial_cmp(&other.tx_id) + Some(self.cmp(other)) } } diff --git a/crates/services/txpool/src/containers/time_sort.rs b/crates/services/txpool/src/containers/time_sort.rs index 5d4cd9b7..d4af6273 100644 --- a/crates/services/txpool/src/containers/time_sort.rs +++ b/crates/services/txpool/src/containers/time_sort.rs @@ -57,11 +57,7 @@ impl Eq for TimeSortKey {} impl PartialOrd for TimeSortKey { fn partial_cmp(&self, other: &Self) -> Option { - match self.time.partial_cmp(&other.time) { - Some(core::cmp::Ordering::Equal) => {} - ord => return ord, - } - self.tx_id.partial_cmp(&other.tx_id) + Some(self.cmp(other)) } } diff --git a/crates/services/txpool/src/lib.rs b/crates/services/txpool/src/lib.rs index d966e323..cb625e44 100644 --- a/crates/services/txpool/src/lib.rs +++ b/crates/services/txpool/src/lib.rs @@ -1,3 +1,4 @@ +#![deny(clippy::cast_possible_truncation)] #![deny(unused_crate_dependencies)] #![deny(warnings)] diff --git a/crates/storage/src/lib.rs b/crates/storage/src/lib.rs index 9636d00f..59691da2 100644 --- a/crates/storage/src/lib.rs +++ b/crates/storage/src/lib.rs @@ -4,6 +4,7 @@ //! defined here are used by services but are flexible enough to customize the //! logic when the `Database` is known. +#![deny(clippy::cast_possible_truncation)] #![deny(unused_crate_dependencies)] #![deny(missing_docs)] #![deny(warnings)] diff --git a/crates/trace/src/lib.rs b/crates/trace/src/lib.rs index 47ee58b6..9f5c4d04 100644 --- a/crates/trace/src/lib.rs +++ b/crates/trace/src/lib.rs @@ -1,3 +1,5 @@ +#![deny(clippy::cast_possible_truncation)] + use ctor::ctor; use std::env::var; use tracing_subscriber::{ diff --git a/crates/types/src/blockchain/primitives.rs b/crates/types/src/blockchain/primitives.rs index 0738e710..f72cb7f6 100644 --- a/crates/types/src/blockchain/primitives.rs +++ b/crates/types/src/blockchain/primitives.rs @@ -125,16 +125,6 @@ impl DaBlockHeight { self.0.to_be_bytes() } - /// Convert to usize - pub fn to_usize(self) -> usize { - self.0 as usize - } - - /// Convert to usize - pub fn as_usize(&self) -> usize { - self.0 as usize - } - /// Convert to u64 pub fn as_u64(&self) -> u64 { self.0 diff --git a/crates/types/src/lib.rs b/crates/types/src/lib.rs index e0811b96..d4149eae 100644 --- a/crates/types/src/lib.rs +++ b/crates/types/src/lib.rs @@ -2,6 +2,7 @@ //! libraries. This crate doesn't contain any business logic and is to be such primitive as that //! is possible. +#![deny(clippy::cast_possible_truncation)] #![deny(unused_crate_dependencies)] #![deny(missing_docs)] #![deny(warnings)] diff --git a/tests/tests/blocks.rs b/tests/tests/blocks.rs index 24f57828..05f3ba38 100644 --- a/tests/tests/blocks.rs +++ b/tests/tests/blocks.rs @@ -317,7 +317,7 @@ mod full_block { schema, tx::OpaqueTransaction, BlockId, - U64, + U32, }, FuelClient, }; @@ -349,7 +349,7 @@ mod full_block { pub trait ClientExt { async fn full_block_by_height( &self, - height: u64, + height: u32, ) -> std::io::Result>; } @@ -357,10 +357,10 @@ mod full_block { impl ClientExt for FuelClient { async fn full_block_by_height( &self, - height: u64, + height: u32, ) -> std::io::Result> { let query = FullBlockByHeightQuery::build(BlockByHeightArgs { - height: Some(U64(height)), + height: Some(U32(height)), }); let block = self.query(query).await?.block; diff --git a/tests/tests/dap.rs b/tests/tests/dap.rs index 58b84ce3..55649a4d 100644 --- a/tests/tests/dap.rs +++ b/tests/tests/dap.rs @@ -71,7 +71,8 @@ async fn reset() { assert!(result); let memory = client.register(id, 0x11).await.unwrap(); - let memory = client.memory(id, memory as RegisterId, 8).await.unwrap(); + let memory = u32::try_from(memory).unwrap(); + let memory = client.memory(id, memory, 8).await.unwrap(); let memory = Word::from_be_bytes(memory.as_slice().try_into().unwrap()); assert_eq!(0xfa, memory); diff --git a/tests/tests/tx/utxo_validation.rs b/tests/tests/tx/utxo_validation.rs index 629de692..f91aa63d 100644 --- a/tests/tests/tx/utxo_validation.rs +++ b/tests/tests/tx/utxo_validation.rs @@ -222,7 +222,7 @@ async fn dry_run_no_utxo_validation_override() { #[tokio::test(flavor = "multi_thread", worker_threads = 8)] async fn concurrent_tx_submission_produces_expected_blocks() { - const TEST_TXS: usize = 10; + const TEST_TXS: i32 = 10; let mut rng = StdRng::seed_from_u64(2322u64); let mut test_builder = TestSetupBuilder::new(100);