Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: inherent-data-provers #238

Merged
merged 1 commit into from
Dec 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use sc_service::{
use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker};
use sc_transaction_pool_api::OffchainTransactionPoolFactory;
use sp_consensus_aura::sr25519::AuthorityPair as AuraPair;
use sp_core::U256;
use sp_runtime::traits::Block as BlockT;
use std::{path::PathBuf, sync::Arc, time::Duration};

Expand Down Expand Up @@ -281,18 +280,22 @@ pub fn build_aura_grandpa_import_queue(
#[cfg(feature = "testnet")]
let target_gas_price = eth_config.target_gas_price;

#[cfg(not(feature = "testnet"))]
let target_gas_price = 0;

let create_inherent_data_providers = move |_, ()| async move {
let timestamp = sp_timestamp::InherentDataProvider::from_system_time();
let slot =
sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration(
*timestamp,
slot_duration,
);
let dynamic_fee = fp_dynamic_fee::InherentDataProvider(U256::from(target_gas_price));
Ok((slot, timestamp, dynamic_fee))

#[cfg(feature = "testnet")]
{
let dynamic_fee = fp_dynamic_fee::InherentDataProvider(U256::from(target_gas_price));
Ok((slot, timestamp, dynamic_fee))
}

#[cfg(not(feature = "testnet"))]
Ok((slot, timestamp))
Comment on lines +291 to +298

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#[cfg(feature = "testnet")]
{
let dynamic_fee = fp_dynamic_fee::InherentDataProvider(U256::from(target_gas_price));
Ok((slot, timestamp, dynamic_fee))
}
#[cfg(not(feature = "testnet"))]
Ok((slot, timestamp))
if cfg!(feature = "testnet") {
let dynamic_fee = fp_dynamic_fee::InherentDataProvider(U256::from(target_gas_price));
Ok((slot, timestamp, dynamic_fee))
} else {
Ok((slot, timestamp))
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can't return different sized tuples from if/else branches. rust needs both sides to be exactly the same type, that's why i have used #[cfg] before

};

let import_queue = sc_consensus_aura::import_queue::<AuraPair, _, _, _, _, _>(
Expand Down