Skip to content

Commit

Permalink
Merge branch 'master' into HEAD
Browse files Browse the repository at this point in the history
  • Loading branch information
acerone85 committed Sep 30, 2024
2 parents 9cf115e + 4a55b7d commit 910186c
Show file tree
Hide file tree
Showing 32 changed files with 640 additions and 249 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
## [Unreleased]

### Added
- [2195](https://github.com/FuelLabs/fuel-core/pull/2195): Added enforcement of the limit on the size of the L2 transactions per block according to the `block_transaction_size_limit` parameter.
- [2131](https://github.com/FuelLabs/fuel-core/pull/2131): Add flow in TxPool in order to ask to newly connected peers to share their transaction pool
- [2182](https://github.com/FuelLabs/fuel-core/pull/2151): Limit number of transactions that can be fetched via TxSource::next
- [2189](https://github.com/FuelLabs/fuel-core/pull/2151): Select next DA height to never include more than u16::MAX -1 transactions from L1.
Expand Down
44 changes: 23 additions & 21 deletions benches/benches/transaction_throughput.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,9 @@ where

fn signed_transfers(c: &mut Criterion) {
let generator = |rng: &mut StdRng| {
TransactionBuilder::script(vec![], vec![])
let predicate = op::ret(RegId::ONE).to_bytes().to_vec();
let owner = Input::predicate_owner(&predicate);
let mut tx = TransactionBuilder::script(vec![], vec![])
.script_gas_limit(10000)
.add_unsigned_coin_input(
SecretKey::random(rng),
Expand All @@ -179,16 +181,22 @@ fn signed_transfers(c: &mut Criterion) {
Default::default(),
Default::default(),
)
.add_unsigned_coin_input(
SecretKey::random(rng),
.add_input(Input::coin_predicate(
rng.gen(),
owner,
1000,
Default::default(),
Default::default(),
)
Default::default(),
predicate.clone(),
vec![],
))
.add_output(Output::coin(rng.gen(), 50, AssetId::default()))
.add_output(Output::change(rng.gen(), 0, AssetId::default()))
.finalize()
.finalize();
tx.estimate_predicates(&checked_parameters(), MemoryInstance::new())
.expect("Predicate check failed");
tx
};
bench_txs("signed transfers", c, generator);
}
Expand All @@ -209,16 +217,6 @@ fn predicate_transfers(c: &mut Criterion) {
predicate.clone(),
vec![],
))
.add_input(Input::coin_predicate(
rng.gen(),
owner,
1000,
Default::default(),
Default::default(),
Default::default(),
predicate,
vec![],
))
.add_output(Output::coin(rng.gen(), 50, AssetId::default()))
.add_output(Output::change(rng.gen(), 0, AssetId::default()))
.finalize();
Expand Down Expand Up @@ -262,6 +260,8 @@ fn predicate_transfers_eck1(c: &mut Criterion) {
.chain(message.as_ref().iter().copied())
.chain(public.as_ref().iter().copied())
.collect();
let predicate_2 = op::ret(RegId::ONE).to_bytes().to_vec();
let owner_2 = Input::predicate_owner(&predicate_2);

let mut tx = TransactionBuilder::script(vec![], vec![])
.script_gas_limit(10000)
Expand All @@ -277,13 +277,13 @@ fn predicate_transfers_eck1(c: &mut Criterion) {
))
.add_input(Input::coin_predicate(
rng.gen(),
owner,
owner_2,
1000,
Default::default(),
Default::default(),
Default::default(),
predicate,
predicate_data,
predicate_2,
vec![],
))
.add_output(Output::coin(rng.gen(), 50, AssetId::default()))
.add_output(Output::change(rng.gen(), 0, AssetId::default()))
Expand Down Expand Up @@ -330,6 +330,8 @@ fn predicate_transfers_ed19(c: &mut Criterion) {
.chain(message.as_ref().iter().copied()),
)
.collect();
let predicate_2 = op::ret(RegId::ONE).to_bytes().to_vec();
let owner_2 = Input::predicate_owner(&predicate_2);

let mut tx = TransactionBuilder::script(vec![], vec![])
.script_gas_limit(10000)
Expand All @@ -345,13 +347,13 @@ fn predicate_transfers_ed19(c: &mut Criterion) {
))
.add_input(Input::coin_predicate(
rng.gen(),
owner,
owner_2,
1000,
Default::default(),
Default::default(),
Default::default(),
predicate,
predicate_data,
predicate_2,
vec![],
))
.add_output(Output::coin(rng.gen(), 50, AssetId::default()))
.add_output(Output::change(rng.gen(), 0, AssetId::default()))
Expand Down
6 changes: 6 additions & 0 deletions bin/e2e-test-client/tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@ fn dev_config() -> Config {
.consensus_parameters
.set_tx_params(tx_parameters);
chain_config.consensus_parameters.set_fee_params(fee_params);
if let Err(_e) = chain_config
.consensus_parameters
.set_block_transaction_size_limit(u64::MAX)
{
eprintln!("failed to set block transaction size limit");
}
chain_config.state_transition_bytecode =
fuel_core::upgradable_executor::WASM_BYTECODE.to_vec();
let reader = reader.with_chain_config(chain_config);
Expand Down
15 changes: 15 additions & 0 deletions crates/fuel-core/src/combined_database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,21 @@ impl CombinedDatabase {

Ok(())
}

pub fn sync_aux_db_heights<S>(&self, shutdown_listener: &mut S) -> anyhow::Result<()>
where
S: ShutdownListener,
{
if let Some(on_chain_height) = self.on_chain().latest_height_from_metadata()? {
// todo(https://github.com/FuelLabs/fuel-core/issues/2239): This is a temporary fix
let res = self.rollback_to(on_chain_height, shutdown_listener);
if res.is_err() {
tracing::warn!("Failed to rollback auxiliary databases to on-chain database height: {:?}", res);
}
};

Ok(())
}
}

/// A trait for listening to shutdown signals.
Expand Down
2 changes: 1 addition & 1 deletion crates/fuel-core/src/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ pub type Database<Description = OnChain, Stage = RegularStage<Description>> =
GenericDatabase<DataSource<Description, Stage>>;
pub type OnChainIterableKeyValueView = IterableKeyValueView<ColumnType<OnChain>>;
pub type OffChainIterableKeyValueView = IterableKeyValueView<ColumnType<OffChain>>;
pub type ReyalerIterableKeyValueView = IterableKeyValueView<ColumnType<Relayer>>;
pub type RelayerIterableKeyValueView = IterableKeyValueView<ColumnType<Relayer>>;

pub type GenesisDatabase<Description = OnChain> = Database<Description, GenesisStage>;

Expand Down
4 changes: 2 additions & 2 deletions crates/fuel-core/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3641,11 +3641,11 @@ mod tests {
);

// when
let verifyer_db = database_with_genesis_block(genesis_da_height);
let verifier_db = database_with_genesis_block(genesis_da_height);
let mut verifier_relayer_db = Database::<Relayer>::default();
let events = vec![event];
add_events_to_relayer(&mut verifier_relayer_db, da_height.into(), &events);
let verifier = create_relayer_executor(verifyer_db, verifier_relayer_db);
let verifier = create_relayer_executor(verifier_db, verifier_relayer_db);
let (result, _) = verifier.validate(&produced_block).unwrap().into();

// then
Expand Down
1 change: 1 addition & 0 deletions crates/fuel-core/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ impl FuelService {

// initialize sub services
tracing::info!("Initializing sub services");
database.sync_aux_db_heights(shutdown_listener)?;
let (services, shared) = sub_services::init_sub_services(&config, database)?;

let sub_services = Arc::new(services);
Expand Down
13 changes: 8 additions & 5 deletions crates/fuel-core/src/service/adapters/executor.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{
database::ReyalerIterableKeyValueView,
database::RelayerIterableKeyValueView,
service::adapters::TransactionsSource,
};
use fuel_core_executor::ports::MaybeCheckedTransaction;
Expand All @@ -9,15 +9,18 @@ use fuel_core_types::{
};

impl fuel_core_executor::ports::TransactionsSource for TransactionsSource {
// TODO: Use `size_limit` https://github.com/FuelLabs/fuel-core/issues/2133
fn next(
&self,
gas_limit: u64,
transactions_limit: u16,
_: u32,
block_transaction_size_limit: u32,
) -> Vec<MaybeCheckedTransaction> {
self.txpool
.select_transactions(gas_limit, transactions_limit)
.select_transactions(
gas_limit,
transactions_limit,
block_transaction_size_limit,
)
.into_iter()
.map(|tx| {
MaybeCheckedTransaction::CheckedTransaction(
Expand All @@ -29,7 +32,7 @@ impl fuel_core_executor::ports::TransactionsSource for TransactionsSource {
}
}

impl fuel_core_executor::ports::RelayerPort for ReyalerIterableKeyValueView {
impl fuel_core_executor::ports::RelayerPort for RelayerIterableKeyValueView {
fn enabled(&self) -> bool {
#[cfg(feature = "relayer")]
{
Expand Down
36 changes: 34 additions & 2 deletions crates/fuel-core/src/service/adapters/gas_price_adapters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,16 @@ use fuel_core_gas_price_service::{
Error as GasPriceError,
Result as GasPriceResult,
},
ports::L2Data,
ports::{
GasPriceData,
GasPriceServiceConfig,
L2Data,
},
};
use fuel_core_storage::{
transactional::HistoricalView,
Result as StorageResult,
};
use fuel_core_storage::Result as StorageResult;
use fuel_core_types::{
blockchain::{
block::Block,
Expand All @@ -23,6 +30,14 @@ use fuel_core_types::{
fuel_types::BlockHeight,
};

use crate::{
database::{
database_description::gas_price::GasPriceDatabase,
Database,
},
service::Config,
};

#[cfg(test)]
mod tests;

Expand All @@ -39,6 +54,23 @@ impl L2Data for OnChainIterableKeyValueView {
}
}

impl GasPriceData for Database<GasPriceDatabase> {
fn latest_height(&self) -> Option<BlockHeight> {
HistoricalView::latest_height(self)
}
}

impl From<Config> for GasPriceServiceConfig {
fn from(value: Config) -> Self {
GasPriceServiceConfig::new(
value.min_gas_price,
value.starting_gas_price,
value.gas_price_change_percent,
value.gas_price_threshold_percent,
)
}
}

impl GasPriceSettingsProvider for ConsensusParametersProvider {
fn settings(
&self,
Expand Down
5 changes: 2 additions & 3 deletions crates/fuel-core/src/service/sub_services.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ use crate::{
};
#[allow(unused_imports)]
use fuel_core_gas_price_service::fuel_gas_price_updater::{
algorithm_updater,
fuel_core_storage_adapter::FuelL2BlockSource,
Algorithm,
AlgorithmV0,
Expand All @@ -64,8 +65,6 @@ use fuel_core_types::blockchain::primitives::DaBlockHeight;
use std::sync::Arc;
use tokio::sync::Mutex;

mod algorithm_updater;

pub type PoAService = fuel_core_poa::Service<
TxPoolAdapter,
BlockProducerAdapter,
Expand Down Expand Up @@ -201,7 +200,7 @@ pub fn init_sub_services(
let block_stream = importer_adapter.events_shared_result();

let gas_price_init = algorithm_updater::InitializeTask::new(
config.clone(),
config.clone().into(),
genesis_block_height,
settings,
block_stream,
Expand Down
2 changes: 1 addition & 1 deletion crates/fuel-gas-price-algorithm/src/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ pub struct AlgorithmUpdaterV1 {
pub max_da_gas_price_change_percent: u16,
/// The cumulative reward from the DA portion of the gas price
pub total_da_rewards_excess: u128,
/// The height of the las L2 block recorded on the DA chain
/// The height of the last L2 block recorded on the DA chain
pub da_recorded_block_height: u32,
/// The cumulative cost of recording L2 blocks on the DA chain as of the last recorded block
pub latest_known_total_da_cost_excess: u128,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ fn update_da_record_data__updates_known_total_cost() {
}

#[test]
fn update_da_record_data__if_da_height_matches_l2_height_prjected_and_known_match() {
fn update_da_record_data__if_da_height_matches_l2_height_projected_and_known_match() {
// given
let da_cost_per_byte = 20;
let da_recorded_block_height = 10;
Expand Down
2 changes: 1 addition & 1 deletion crates/services/consensus_module/poa/src/signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub enum SignMode {
}

impl SignMode {
/// Is block sigining (production) available
/// Is block signing (production) available
pub fn is_available(&self) -> bool {
!matches!(self, SignMode::Unavailable)
}
Expand Down
Loading

0 comments on commit 910186c

Please sign in to comment.