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

Add DefaultBaseFeePerGas to runtimes #1233

Merged
merged 2 commits into from
Jan 31, 2022
Merged
Show file tree
Hide file tree
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
38 changes: 19 additions & 19 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions runtime/moonbase/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1659,6 +1659,7 @@ impl pallet_proxy_genesis_companion::Config for Runtime {
parameter_types! {
// Tells `pallet_base_fee` whether to calculate a new BaseFee `on_finalize` or not.
pub IsActive: bool = false;
pub DefaultBaseFeePerGas: U256 = (1 * currency::GIGAWEI * currency::SUPPLY_FACTOR).into();
Copy link
Contributor

Choose a reason for hiding this comment

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

It might make sense to define this in currency since it's also used for min_gas_price(). But maybe not since this will change soon (?)

}

pub struct BaseFeeThreshold;
Expand All @@ -1678,6 +1679,7 @@ impl pallet_base_fee::Config for Runtime {
type Event = Event;
type Threshold = BaseFeeThreshold;
type IsActive = IsActive;
type DefaultBaseFeePerGas = DefaultBaseFeePerGas;
}

construct_runtime! {
Expand Down
9 changes: 8 additions & 1 deletion runtime/moonbase/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use frame_support::{
};
use frame_system::InitKind;
pub use moonbase_runtime::{
currency::{UNIT, WEI},
currency::{GIGAWEI, SUPPLY_FACTOR, UNIT, WEI},
AccountId, AssetId, AssetManager, Assets, AuthorInherent, Balance, Balances, Call,
CrowdloanRewards, Ethereum, Event, Executive, FixedGasPrice, InflationInfo, ParachainStaking,
Range, Runtime, System, TransactionConverter, UncheckedExtrinsic, WEEKS,
Expand Down Expand Up @@ -280,6 +280,13 @@ impl ExtBuilder {
&mut t,
)
.unwrap();

<pallet_base_fee::GenesisConfig<Runtime> as GenesisBuild<Runtime>>::assimilate_storage(
&pallet_base_fee::GenesisConfig::<Runtime>::default(),
&mut t,
)
.unwrap();

let mut ext = sp_io::TestExternalities::new(t);

let assets = self.assets.clone();
Expand Down
12 changes: 11 additions & 1 deletion runtime/moonbase/tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use frame_support::{
};
use moonbase_runtime::{
currency::UNIT, AccountId, AssetId, AssetManager, AssetRegistrarMetadata, AssetType, Assets,
Balances, BlockWeights, Call, CrowdloanRewards, Event, ParachainStaking, PolkadotXcm,
Balances, BaseFee, BlockWeights, Call, CrowdloanRewards, Event, ParachainStaking, PolkadotXcm,
Precompiles, Runtime, System, XTokens, XcmTransactor,
};
use nimbus_primitives::NimbusId;
Expand Down Expand Up @@ -1908,3 +1908,13 @@ fn precompile_existance() {
}
});
}

#[test]
fn base_fee_should_default_to_associate_type_value() {
ExtBuilder::default().build().execute_with(|| {
assert_eq!(
BaseFee::base_fee_per_gas(),
(1 * GIGAWEI * SUPPLY_FACTOR).into()
);
});
}
2 changes: 2 additions & 0 deletions runtime/moonbeam/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,7 @@ impl pallet_evm::Config for Runtime {
parameter_types! {
// Tells `pallet_base_fee` whether to calculate a new BaseFee `on_finalize` or not.
pub IsActive: bool = false;
pub DefaultBaseFeePerGas: U256 = (1 * currency::GIGAWEI * currency::SUPPLY_FACTOR).into();
}

pub struct BaseFeeThreshold;
Expand All @@ -449,6 +450,7 @@ impl pallet_base_fee::Config for Runtime {
type Event = Event;
type Threshold = BaseFeeThreshold;
type IsActive = IsActive;
type DefaultBaseFeePerGas = DefaultBaseFeePerGas;
}

parameter_types! {
Expand Down
8 changes: 7 additions & 1 deletion runtime/moonbeam/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use frame_support::{
};
use frame_system::InitKind;
pub use moonbeam_runtime::{
currency::{GLMR, WEI},
currency::{GIGAWEI, GLMR, SUPPLY_FACTOR, WEI},
AccountId, AssetId, AssetManager, AssetRegistrarMetadata, AssetType, Assets, AuthorInherent,
Balance, Balances, Call, CrowdloanRewards, Ethereum, Event, Executive, FixedGasPrice,
InflationInfo, ParachainStaking, Range, Runtime, System, TransactionConverter,
Expand Down Expand Up @@ -281,6 +281,12 @@ impl ExtBuilder {
)
.unwrap();

<pallet_base_fee::GenesisConfig<Runtime> as GenesisBuild<Runtime>>::assimilate_storage(
&pallet_base_fee::GenesisConfig::<Runtime>::default(),
&mut t,
)
.unwrap();

let mut ext = sp_io::TestExternalities::new(t);
let assets = self.assets.clone();
let xcm_assets = self.xcm_assets.clone();
Expand Down
15 changes: 12 additions & 3 deletions runtime/moonbeam/tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ use frame_support::{
StorageHasher, Twox128,
};
use moonbeam_runtime::{
currency::{GIGAWEI, GLMR},
AccountId, Balances, BlockWeights, Call, CrowdloanRewards, CurrencyId, Event, ParachainStaking,
PolkadotXcm, Precompiles, Runtime, System, XTokens, XcmTransactor,
currency::GLMR, AccountId, Balances, BaseFee, BlockWeights, Call, CrowdloanRewards, CurrencyId,
Event, ParachainStaking, PolkadotXcm, Precompiles, Runtime, System, XTokens, XcmTransactor,
};
use nimbus_primitives::NimbusId;
use pallet_evm::PrecompileSet;
Expand Down Expand Up @@ -1980,3 +1979,13 @@ fn precompile_existance() {
}
});
}

#[test]
fn base_fee_should_default_to_associate_type_value() {
ExtBuilder::default().build().execute_with(|| {
assert_eq!(
BaseFee::base_fee_per_gas(),
(1 * GIGAWEI * SUPPLY_FACTOR).into()
);
});
}
2 changes: 2 additions & 0 deletions runtime/moonriver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,7 @@ impl pallet_ethereum::Config for Runtime {
parameter_types! {
// Tells `pallet_base_fee` whether to calculate a new BaseFee `on_finalize` or not.
pub IsActive: bool = false;
pub DefaultBaseFeePerGas: U256 = (1 * currency::GIGAWEI * currency::SUPPLY_FACTOR).into();
}

pub struct BaseFeeThreshold;
Expand All @@ -681,6 +682,7 @@ impl pallet_base_fee::Config for Runtime {
type Event = Event;
type Threshold = BaseFeeThreshold;
type IsActive = IsActive;
type DefaultBaseFeePerGas = DefaultBaseFeePerGas;
}

parameter_types! {
Expand Down
8 changes: 7 additions & 1 deletion runtime/moonriver/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use frame_support::{
};
use frame_system::InitKind;
pub use moonriver_runtime::{
currency::{MOVR, WEI},
currency::{GIGAWEI, MOVR, SUPPLY_FACTOR, WEI},
AccountId, AssetId, AssetManager, AssetRegistrarMetadata, AssetType, Assets, AuthorInherent,
Balance, Balances, Call, CrowdloanRewards, Ethereum, Event, Executive, FixedGasPrice,
InflationInfo, ParachainStaking, Range, Runtime, System, TransactionConverter,
Expand Down Expand Up @@ -281,6 +281,12 @@ impl ExtBuilder {
)
.unwrap();

<pallet_base_fee::GenesisConfig<Runtime> as GenesisBuild<Runtime>>::assimilate_storage(
&pallet_base_fee::GenesisConfig::<Runtime>::default(),
&mut t,
)
.unwrap();

let mut ext = sp_io::TestExternalities::new(t);
let assets = self.assets.clone();
let xcm_assets = self.xcm_assets.clone();
Expand Down
12 changes: 11 additions & 1 deletion runtime/moonriver/tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use frame_support::{
StorageHasher, Twox128,
};
use moonriver_runtime::{
BlockWeights, CurrencyId, PolkadotXcm, Precompiles, XTokens, XcmTransactor,
BaseFee, BlockWeights, CurrencyId, PolkadotXcm, Precompiles, XTokens, XcmTransactor,
};
use nimbus_primitives::NimbusId;
use pallet_evm::PrecompileSet;
Expand Down Expand Up @@ -1968,3 +1968,13 @@ fn precompile_existance() {
}
});
}

#[test]
fn base_fee_should_default_to_associate_type_value() {
ExtBuilder::default().build().execute_with(|| {
assert_eq!(
BaseFee::base_fee_per_gas(),
(1 * GIGAWEI * SUPPLY_FACTOR).into()
);
});
}