Skip to content

Commit

Permalink
Cosmetic changes
Browse files Browse the repository at this point in the history
  • Loading branch information
acerone85 committed Sep 19, 2024
1 parent 494d792 commit bd67a39
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
16 changes: 10 additions & 6 deletions crates/fuel-core/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ mod tests {
use crate as fuel_core;
use fuel_core::database::Database;
use fuel_core_executor::{
executor::OnceTransactionsSource,
executor::{
OnceTransactionsSource,
MAX_TX_COUNT,
},
ports::{
MaybeCheckedTransaction,
RelayerPort,
Expand Down Expand Up @@ -2984,14 +2987,14 @@ mod tests {
}

#[test]
fn block_producer_never_includes_more_than_u16_max_transactions() {
fn block_producer_never_includes_more_than_max_tx_count_transactions() {
let block_height = 1u32;
let block_da_height = 2u64;

let mut consensus_parameters = ConsensusParameters::default();

// Given
let transactions_in_tx_source = u16::MAX as usize + 10;
let transactions_in_tx_source = (MAX_TX_COUNT as usize) + 10;
consensus_parameters.set_block_gas_limit(u64::MAX);
let config = Config {
consensus_parameters,
Expand All @@ -3013,9 +3016,10 @@ mod tests {
.into();

// Then
// u16::MAX -1 transactions have been included from the transaction source, plus the mint transaction
// In total we expect to see u16::MAX transactions in the block
assert_eq!(result.block.transactions().len(), (u16::MAX) as usize);
assert_eq!(
result.block.transactions().len(),
(MAX_TX_COUNT as usize + 1)
);
}

#[cfg(feature = "relayer")]
Expand Down
4 changes: 3 additions & 1 deletion crates/services/executor/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ use alloc::{
vec::Vec,
};

/// The maximum amount of transactions that can be included in a block,
/// excluding the mint transaction.
pub const MAX_TX_COUNT: u16 = u16::MAX.saturating_sub(1);

pub struct OnceTransactionsSource {
Expand Down Expand Up @@ -578,7 +580,7 @@ where
// TODO: Handle `remaining_size` https://github.com/FuelLabs/fuel-core/issues/2133
let remaining_size = u32::MAX;

// We allow at most u64::MAX transactions in a block, including the mint transaction.
// We allow at most u16::MAX transactions in a block, including the mint transaction.
// When processing l2 transactions, we must take into account transactions from the l1
// that have been included in the block already (stored in `data.tx_count`), as well
// as the final mint transaction.
Expand Down
3 changes: 2 additions & 1 deletion tests/tests/blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,8 @@ mod full_block {
}

// Then
let last_block_height: u32 = client.produce_blocks(2, None).await.unwrap().into();
let _last_block_height: u32 =
client.produce_blocks(2, None).await.unwrap().into();
let second_last_block = client
.block_by_height(BlockHeight::from(1))
.await
Expand Down

0 comments on commit bd67a39

Please sign in to comment.