Skip to content

Commit

Permalink
Adapt the client side
Browse files Browse the repository at this point in the history
  • Loading branch information
boundless-forest committed Feb 21, 2024
1 parent ad01fe8 commit 89888d0
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 61 deletions.
5 changes: 2 additions & 3 deletions frame/base-fee/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use frame_support::{
traits::{ConstU32, OnFinalize},
weights::Weight,
};
use sp_core::{H256, U256};
use sp_core::{ConstU64, H256, U256};
use sp_io::TestExternalities;
use sp_runtime::{
traits::{BlakeTwo256, IdentityLookup},
Expand All @@ -34,7 +34,6 @@ use crate as pallet_base_fee;
use crate::BaseFeeThreshold as BaseFeeThresholdT;

parameter_types! {
pub const BlockHashCount: u64 = 250;
pub BlockWeights: frame_system::limits::BlockWeights =
frame_system::limits::BlockWeights::simple_max(Weight::from_parts(1024, 0));
}
Expand All @@ -52,7 +51,7 @@ impl frame_system::Config for Test {
type AccountId = u64;
type Lookup = IdentityLookup<Self::AccountId>;
type Block = frame_system::mocking::MockBlock<Self>;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU64<256>;
type DbWeight = ();
type Version = ();
type PalletInfo = PalletInfo;
Expand Down
4 changes: 0 additions & 4 deletions template/node/src/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ pub struct EthConfiguration {
#[arg(long)]
pub enable_dev_signer: bool,

/// The dynamic-fee pallet target gas price set by block author
#[arg(long, default_value = "1")]
pub target_gas_price: u64,

/// Maximum allowed gas limit will be `block.gas_limit * execute_gas_limit_multiplier`
/// when using eth_call/eth_estimateGas.
#[arg(long, default_value = "10")]
Expand Down
23 changes: 4 additions & 19 deletions template/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker};
use sc_transaction_pool_api::OffchainTransactionPoolFactory;
use sp_api::ConstructRuntimeApi;
use sp_consensus_aura::sr25519::AuthorityPair as AuraPair;
use sp_core::U256;
// Runtime
use frontier_template_runtime::{opaque::Block, Hash, TransactionConverter};

Expand Down Expand Up @@ -73,7 +72,6 @@ where
BIQ: FnOnce(
Arc<FullClient<RuntimeApi, Executor>>,
&Configuration,
&EthConfiguration,
&TaskManager,
Option<TelemetryHandle>,
GrandpaBlockImport<FullClient<RuntimeApi, Executor>>,
Expand Down Expand Up @@ -149,7 +147,6 @@ where
let (import_queue, block_import) = build_import_queue(
client.clone(),
config,
eth_config,
&task_manager,
telemetry.as_ref().map(|x| x.handle()),
grandpa_block_import,
Expand Down Expand Up @@ -185,7 +182,6 @@ where
pub fn build_aura_grandpa_import_queue<RuntimeApi, Executor>(
client: Arc<FullClient<RuntimeApi, Executor>>,
config: &Configuration,
eth_config: &EthConfiguration,
task_manager: &TaskManager,
telemetry: Option<TelemetryHandle>,
grandpa_block_import: GrandpaBlockImport<FullClient<RuntimeApi, Executor>>,
Expand All @@ -200,16 +196,14 @@ where
FrontierBlockImport::new(grandpa_block_import.clone(), client.clone());

let slot_duration = sc_consensus_aura::slot_duration(&*client)?;
let target_gas_price = eth_config.target_gas_price;
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))
Ok((slot, timestamp))
};

let import_queue = sc_consensus_aura::import_queue::<AuraPair, _, _, _, _, _>(
Expand All @@ -234,7 +228,6 @@ where
pub fn build_manual_seal_import_queue<RuntimeApi, Executor>(
client: Arc<FullClient<RuntimeApi, Executor>>,
config: &Configuration,
_eth_config: &EthConfiguration,
task_manager: &TaskManager,
_telemetry: Option<TelemetryHandle>,
_grandpa_block_import: GrandpaBlockImport<FullClient<RuntimeApi, Executor>>,
Expand Down Expand Up @@ -391,7 +384,6 @@ where
));

let slot_duration = sc_consensus_aura::slot_duration(&*client)?;
let target_gas_price = eth_config.target_gas_price;
let pending_create_inherent_data_providers = move |_, ()| async move {
let current = sp_timestamp::InherentDataProvider::from_system_time();
let next_slot = current.timestamp().as_millis() + slot_duration.as_millis();
Expand All @@ -400,8 +392,7 @@ where
*timestamp,
slot_duration,
);
let dynamic_fee = fp_dynamic_fee::InherentDataProvider(U256::from(target_gas_price));
Ok((slot, timestamp, dynamic_fee))
Ok((slot, timestamp))
};

Box::new(move |deny_unsafe, subscription_task_executor| {
Expand Down Expand Up @@ -481,7 +472,6 @@ where
// manual-seal authorship
if let Some(sealing) = sealing {
run_manual_seal_authorship(
&eth_config,
sealing,
client,
transaction_pool,
Expand All @@ -507,15 +497,13 @@ where
);

let slot_duration = sc_consensus_aura::slot_duration(&*client)?;
let target_gas_price = eth_config.target_gas_price;
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))
Ok((slot, timestamp))
};

let aura = sc_consensus_aura::start_aura::<AuraPair, _, _, _, _, _, _, _, _, _, _>(
Expand Down Expand Up @@ -597,7 +585,6 @@ where
}

fn run_manual_seal_authorship<RuntimeApi, Executor>(
eth_config: &EthConfiguration,
sealing: Sealing,
client: Arc<FullClient<RuntimeApi, Executor>>,
transaction_pool: Arc<FullPool<FullClient<RuntimeApi, Executor>>>,
Expand Down Expand Up @@ -650,11 +637,9 @@ where
}
}

let target_gas_price = eth_config.target_gas_price;
let create_inherent_data_providers = move |_, ()| async move {
let timestamp = MockTimestampInherentDataProvider;
let dynamic_fee = fp_dynamic_fee::InherentDataProvider(U256::from(target_gas_price));
Ok((timestamp, dynamic_fee))
Ok(timestamp)
};

let manual_seal = match sealing {
Expand Down
35 changes: 0 additions & 35 deletions template/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,39 +385,6 @@ impl pallet_ethereum::Config for Runtime {
type ExtraDataLength = ConstU32<30>;
}

// parameter_types! {
// pub BoundDivision: U256 = U256::from(1024);
// }

// impl pallet_dynamic_fee::Config for Runtime {
// type MinGasPriceBoundDivisor = BoundDivision;
// }

// parameter_types! {
// pub DefaultBaseFeePerGas: U256 = U256::from(1_000_000_000);
// pub DefaultElasticity: Permill = Permill::from_parts(125_000);
// }

// pub struct BaseFeeThreshold;
// impl pallet_base_fee::BaseFeeThreshold for BaseFeeThreshold {
// fn lower() -> Permill {
// Permill::zero()
// }
// fn ideal() -> Permill {
// Permill::from_parts(500_000)
// }
// fn upper() -> Permill {
// Permill::from_parts(1_000_000)
// }
// }

// impl pallet_base_fee::Config for Runtime {
// type RuntimeEvent = RuntimeEvent;
// type Threshold = BaseFeeThreshold;
// type DefaultBaseFeePerGas = DefaultBaseFeePerGas;
// type DefaultElasticity = DefaultElasticity;
// }

impl pallet_hotfix_sufficients::Config for Runtime {
type AddressMapping = IdentityAddressMapping;
type WeightInfo = pallet_hotfix_sufficients::weights::SubstrateWeight<Self>;
Expand Down Expand Up @@ -465,8 +432,6 @@ frame_support::construct_runtime!(
Ethereum: pallet_ethereum,
EVM: pallet_evm,
EVMChainId: pallet_evm_chain_id,
// DynamicFee: pallet_dynamic_fee,
// BaseFee: pallet_base_fee,
HotfixSufficients: pallet_hotfix_sufficients,

ManualSeal: pallet_manual_seal,
Expand Down

0 comments on commit 89888d0

Please sign in to comment.