Skip to content

Commit

Permalink
Release v6.4.0-1 (#1277)
Browse files Browse the repository at this point in the history
* Adjust `GasLimitPovSizeRatio` (#1274)

* Try fix

* Better

* Add automate test

* Apply the changes to other networks

* Update comment

* Fix ts test

* Release `v6.4.0-1`

* Clear

---------

Co-authored-by: Bear Wang <boundless.forest@outlook.com>
  • Loading branch information
AurevoirXavier and boundless-forest authored Sep 20, 2023
1 parent 2f0941d commit b874775
Show file tree
Hide file tree
Showing 11 changed files with 81 additions and 46 deletions.
44 changes: 22 additions & 22 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ edition = "2021"
homepage = "https://darwinia.network"
license = "GPL-3.0"
repository = "https://github.com/darwinia-network/darwinia"
version = "6.4.0"
version = "6.4.0-1"

[workspace.dependencies]
# crates.io
Expand Down Expand Up @@ -50,7 +50,7 @@ parachain-info = { git = "https://github.com/paritytech/c
# darwinia
crab-runtime = { path = "runtime/crab" }
darwinia-account-migration = { path = "pallet/account-migration", default-features = false }
darwinia-asset-limit = { path = "pallet/asset-limit", default-features = false}
darwinia-asset-limit = { path = "pallet/asset-limit", default-features = false }
darwinia-common-runtime = { path = "runtime/common", default-features = false }
darwinia-deposit = { path = "pallet/deposit", default-features = false }
darwinia-ecdsa-authority = { path = "pallet/ecdsa-authority", default-features = false }
Expand Down
32 changes: 32 additions & 0 deletions runtime/common/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,38 @@ macro_rules! impl_weight_tests {
let time_o_proof = time_fee.checked_div(proof_fee).unwrap_or_default();
assert!(time_o_proof <= 30, "{} should be at most 30", time_o_proof);
}

#[test]
fn eth_transaction_max_allowed_gas_limit() {
// frontier
use pallet_evm::GasWeightMapping;

let max_extrinsic_weight = <Runtime as frame_system::Config>::BlockWeights::get()
.get(DispatchClass::Normal)
.max_extrinsic
.expect("Failed to get max extrinsic weight");

assert!(!<Runtime as pallet_evm::Config>::GasWeightMapping::gas_to_weight(
12_000_000, true
)
.any_gt(max_extrinsic_weight));
assert!(!<Runtime as pallet_evm::Config>::GasWeightMapping::gas_to_weight(
14_000_000, true
)
.any_gt(max_extrinsic_weight));
assert!(!<Runtime as pallet_evm::Config>::GasWeightMapping::gas_to_weight(
16_000_000, true
)
.any_gt(max_extrinsic_weight));
assert!(!<Runtime as pallet_evm::Config>::GasWeightMapping::gas_to_weight(
18_000_000, true
)
.any_gt(max_extrinsic_weight));
assert!(<Runtime as pallet_evm::Config>::GasWeightMapping::gas_to_weight(
20_000_000, true
)
.any_gt(max_extrinsic_weight));
}
}
};
}
Expand Down
2 changes: 1 addition & 1 deletion runtime/crab/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ pub const VERSION: sp_version::RuntimeVersion = sp_version::RuntimeVersion {
spec_name: sp_runtime::create_runtime_str!("Crab2"),
impl_name: sp_runtime::create_runtime_str!("DarwiniaOfficialRust"),
authoring_version: 0,
spec_version: 6_4_0_0,
spec_version: 6_4_0_1,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 0,
Expand Down
13 changes: 2 additions & 11 deletions runtime/crab/src/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,7 @@ impl frame_support::traits::OnRuntimeUpgrade for CustomOnRuntimeUpgrade {
}

fn migrate() -> frame_support::weights::Weight {
// substrate
use frame_support::traits::StorageVersion;

// Some pallets are added on chain after the migration.
// Thus, they never required the migration and we just missed to set the correct
// `StorageVersion`.
StorageVersion::new(4).put::<Scheduler>();
StorageVersion::new(1).put::<PolkadotXcm>();

// frame_support::weights::Weight::zero()
frame_support::weights::Weight::zero()
// RuntimeBlockWeights::get().max_block
<Runtime as frame_system::Config>::DbWeight::get().reads_writes(0, 2)
// <Runtime as frame_system::Config>::DbWeight::get().reads_writes(0, 2)
}
7 changes: 5 additions & 2 deletions runtime/crab/src/pallets/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,24 @@
// darwinia
use crate::*;
// substrate
use cumulus_primitives_core::relay_chain::MAX_POV_SIZE;
use frame_support::dispatch::{DispatchClass, GetDispatchInfo, Pays};
// frontier
use pallet_evm::{ExitError, IsPrecompileResult, Precompile};
use pallet_evm_precompile_dispatch::DispatchValidateT;

const BLOCK_GAS_LIMIT: u64 = 20_000_000;
const MAX_POV_SIZE: u64 = 5 * 1024 * 1024;
frame_support::parameter_types! {
pub BlockGasLimit: sp_core::U256 = sp_core::U256::from(BLOCK_GAS_LIMIT);
// Restrict the POV size of the Ethereum transactions in the same way as weight limit.
pub BlockPovSizeLimit: u64 = NORMAL_DISPATCH_RATIO * MAX_POV_SIZE as u64;
pub PrecompilesValue: CrabPrecompiles<Runtime> = CrabPrecompiles::<_>::new();
pub WeightPerGas: frame_support::weights::Weight = frame_support::weights::Weight::from_parts(
fp_evm::weight_per_gas(BLOCK_GAS_LIMIT, NORMAL_DISPATCH_RATIO, WEIGHT_MILLISECS_PER_BLOCK),
0
);
pub const GasLimitPovSizeRatio: u64 = BLOCK_GAS_LIMIT.saturating_div(MAX_POV_SIZE);
// TODO: FIX ME. https://github.com/rust-lang/rust/issues/88581
pub GasLimitPovSizeRatio: u64 = BLOCK_GAS_LIMIT.saturating_div(BlockPovSizeLimit::get()) + 1;
}

pub struct CrabPrecompiles<R>(sp_std::marker::PhantomData<R>);
Expand Down
2 changes: 1 addition & 1 deletion runtime/darwinia/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ pub const VERSION: sp_version::RuntimeVersion = sp_version::RuntimeVersion {
spec_name: sp_runtime::create_runtime_str!("Darwinia2"),
impl_name: sp_runtime::create_runtime_str!("DarwiniaOfficialRust"),
authoring_version: 0,
spec_version: 6_4_0_0,
spec_version: 6_4_0_1,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 0,
Expand Down
7 changes: 5 additions & 2 deletions runtime/darwinia/src/pallets/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,24 @@
// darwinia
use crate::*;
// substrate
use cumulus_primitives_core::relay_chain::MAX_POV_SIZE;
use frame_support::dispatch::{DispatchClass, GetDispatchInfo, Pays};
// frontier
use pallet_evm::{ExitError, IsPrecompileResult, Precompile};
use pallet_evm_precompile_dispatch::DispatchValidateT;

const BLOCK_GAS_LIMIT: u64 = 20_000_000;
const MAX_POV_SIZE: u64 = 5 * 1024 * 1024;
frame_support::parameter_types! {
pub BlockGasLimit: sp_core::U256 = sp_core::U256::from(BLOCK_GAS_LIMIT);
// Restrict the POV size of the Ethereum transactions in the same way as weight limit.
pub BlockPovSizeLimit: u64 = NORMAL_DISPATCH_RATIO * MAX_POV_SIZE as u64;
pub PrecompilesValue: DarwiniaPrecompiles<Runtime> = DarwiniaPrecompiles::<_>::new();
pub WeightPerGas: frame_support::weights::Weight = frame_support::weights::Weight::from_parts(
fp_evm::weight_per_gas(BLOCK_GAS_LIMIT, NORMAL_DISPATCH_RATIO, WEIGHT_MILLISECS_PER_BLOCK),
0
);
pub const GasLimitPovSizeRatio: u64 = BLOCK_GAS_LIMIT.saturating_div(MAX_POV_SIZE);
// TODO: FIX ME. https://github.com/rust-lang/rust/issues/88581
pub GasLimitPovSizeRatio: u64 = BLOCK_GAS_LIMIT.saturating_div(BlockPovSizeLimit::get()) + 1;
}
pub struct DarwiniaPrecompiles<R>(sp_std::marker::PhantomData<R>);
impl<R> DarwiniaPrecompiles<R>
Expand Down
7 changes: 5 additions & 2 deletions runtime/pangolin/src/pallets/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,24 @@
// darwinia
use crate::*;
// substrate
use cumulus_primitives_core::relay_chain::MAX_POV_SIZE;
use frame_support::dispatch::{DispatchClass, GetDispatchInfo, Pays};
// frontier
use pallet_evm::{ExitError, IsPrecompileResult, Precompile};
use pallet_evm_precompile_dispatch::DispatchValidateT;

const BLOCK_GAS_LIMIT: u64 = 20_000_000;
const MAX_POV_SIZE: u64 = 5 * 1024 * 1024;
frame_support::parameter_types! {
pub BlockGasLimit: sp_core::U256 = sp_core::U256::from(BLOCK_GAS_LIMIT);
// Restrict the POV size of the Ethereum transactions in the same way as weight limit.
pub BlockPovSizeLimit: u64 = NORMAL_DISPATCH_RATIO * MAX_POV_SIZE as u64;
pub PrecompilesValue: PangolinPrecompiles<Runtime> = PangolinPrecompiles::<_>::new();
pub WeightPerGas: frame_support::weights::Weight = frame_support::weights::Weight::from_parts(
fp_evm::weight_per_gas(BLOCK_GAS_LIMIT, NORMAL_DISPATCH_RATIO, WEIGHT_MILLISECS_PER_BLOCK),
0
);
pub const GasLimitPovSizeRatio: u64 = BLOCK_GAS_LIMIT.saturating_div(MAX_POV_SIZE);
// TODO: FIX ME. https://github.com/rust-lang/rust/issues/88581
pub GasLimitPovSizeRatio: u64 = BLOCK_GAS_LIMIT.saturating_div(BlockPovSizeLimit::get()) + 1;
}

pub struct PangolinPrecompiles<R>(sp_std::marker::PhantomData<R>);
Expand Down
7 changes: 5 additions & 2 deletions runtime/pangoro/src/pallets/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,24 @@
// darwinia
use crate::*;
// substrate
use cumulus_primitives_core::relay_chain::MAX_POV_SIZE;
use frame_support::dispatch::{DispatchClass, GetDispatchInfo, Pays};
// frontier
use pallet_evm::{ExitError, IsPrecompileResult, Precompile};
use pallet_evm_precompile_dispatch::DispatchValidateT;

const BLOCK_GAS_LIMIT: u64 = 20_000_000;
const MAX_POV_SIZE: u64 = 5 * 1024 * 1024;
frame_support::parameter_types! {
pub BlockGasLimit: sp_core::U256 = sp_core::U256::from(BLOCK_GAS_LIMIT);
// Restrict the POV size of the Ethereum transactions in the same way as weight limit.
pub BlockPovSizeLimit: u64 = NORMAL_DISPATCH_RATIO * MAX_POV_SIZE as u64;
pub PrecompilesValue: PangoroPrecompiles<Runtime> = PangoroPrecompiles::<_>::new();
pub WeightPerGas: frame_support::weights::Weight = frame_support::weights::Weight::from_parts(
fp_evm::weight_per_gas(BLOCK_GAS_LIMIT, NORMAL_DISPATCH_RATIO, WEIGHT_MILLISECS_PER_BLOCK),
0
);
pub const GasLimitPovSizeRatio: u64 = BLOCK_GAS_LIMIT.saturating_div(MAX_POV_SIZE);
// TODO: FIX ME. https://github.com/rust-lang/rust/issues/88581
pub GasLimitPovSizeRatio: u64 = BLOCK_GAS_LIMIT.saturating_div(BlockPovSizeLimit::get()) + 1;
}

pub struct PangoroPrecompiles<R>(sp_std::marker::PhantomData<R>);
Expand Down
Loading

0 comments on commit b874775

Please sign in to comment.