-
Notifications
You must be signed in to change notification settings - Fork 391
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fee Alignment - Shibuya/local (#1025)
* Fee Alignment - Shibuya/local * Further modifications * Some improvements * Mock/tests, type fixes * Tests * Integration test, removal of genesis * Tests * Bounds tests * Spectrum test * Updates to logic, more comments, more tests * Documentation & benchmarking code * Fixes * Typo fixes * Extra rustdocs * Shibuya updates, addressing review comments for the pallet * Temp weight benchmarks * Storage version, additional benchmark * Fix writes * Compilation & test fixes * Integrated local * Integration adaptation * Fixes for integration compilation * Integration test fix & new weights
- Loading branch information
Showing
16 changed files
with
1,235 additions
and
123 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
[package] | ||
name = "pallet-dynamic-evm-base-fee" | ||
version = "0.1.0" | ||
license = "GPL-3.0-or-later" | ||
description = "Handler for dynamic EVM base fee for Astar tokenomics v2." | ||
authors.workspace = true | ||
edition.workspace = true | ||
homepage.workspace = true | ||
repository.workspace = true | ||
|
||
[dependencies] | ||
parity-scale-codec = { workspace = true } | ||
scale-info = { workspace = true } | ||
|
||
# Substrate | ||
frame-benchmarking = { workspace = true, optional = true } | ||
frame-support = { workspace = true } | ||
frame-system = { workspace = true } | ||
pallet-transaction-payment = { workspace = true } | ||
sp-core = { workspace = true } | ||
sp-runtime = { workspace = true } | ||
|
||
# Frontier | ||
fp-evm = { workspace = true } | ||
|
||
[dev-dependencies] | ||
num-traits = { workspace = true } | ||
pallet-balances = { workspace = true } | ||
pallet-timestamp = { workspace = true } | ||
|
||
[features] | ||
default = ["std"] | ||
std = [ | ||
"parity-scale-codec/std", | ||
"scale-info/std", | ||
"num-traits/std", | ||
# Substrate | ||
"frame-support/std", | ||
"frame-system/std", | ||
"sp-core/std", | ||
"sp-runtime/std", | ||
"pallet-transaction-payment/std", | ||
"pallet-balances/std", | ||
"pallet-timestamp/std", | ||
"frame-benchmarking/std", | ||
# Frontier | ||
"fp-evm/std", | ||
] | ||
runtime-benchmarks = [ | ||
"frame-benchmarking", | ||
"frame-support/runtime-benchmarks", | ||
"frame-system/runtime-benchmarks", | ||
"sp-runtime/runtime-benchmarks", | ||
] | ||
try-runtime = [ | ||
"frame-support/try-runtime", | ||
"frame-system/try-runtime", | ||
"pallet-transaction-payment/try-runtime", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
// This file is part of Astar. | ||
|
||
// Copyright (C) 2019-2023 Stake Technologies Pte.Ltd. | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
// Astar is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
|
||
// Astar is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
|
||
// You should have received a copy of the GNU General Public License | ||
// along with Astar. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
use super::*; | ||
|
||
use fp_evm::FeeCalculator; | ||
use frame_benchmarking::v2::*; | ||
use frame_support::traits::Hooks; | ||
use frame_system::RawOrigin; | ||
|
||
#[benchmarks] | ||
mod benchmarks { | ||
use super::*; | ||
|
||
#[benchmark] | ||
fn base_fee_per_gas_adjustment() { | ||
let (first_block, second_block) = (T::BlockNumber::from(1u32), T::BlockNumber::from(2u32)); | ||
|
||
// Setup actions, should ensure some value is written to storage. | ||
Pallet::<T>::on_initialize(first_block); | ||
Pallet::<T>::on_finalize(first_block); | ||
assert!( | ||
BaseFeePerGas::<T>::exists(), | ||
"Value should exist in storage after first on_finalize call" | ||
); | ||
|
||
Pallet::<T>::on_initialize(second_block); | ||
let init_bfpg = BaseFeePerGas::<T>::get(); | ||
|
||
#[block] | ||
{ | ||
Pallet::<T>::on_finalize(second_block); | ||
} | ||
|
||
// Ensure that the value has changed. | ||
assert!(BaseFeePerGas::<T>::get() != init_bfpg); | ||
} | ||
|
||
#[benchmark] | ||
fn set_base_fee_per_gas() { | ||
let old_bfpg = BaseFeePerGas::<T>::get(); | ||
let new_bfpg = old_bfpg + 1; | ||
|
||
#[extrinsic_call] | ||
_(RawOrigin::Root, new_bfpg); | ||
|
||
// Ensure that the value has changed. | ||
assert_eq!(BaseFeePerGas::<T>::get(), new_bfpg); | ||
} | ||
|
||
#[benchmark] | ||
fn min_gas_price() { | ||
let first_block = T::BlockNumber::from(1u32); | ||
|
||
// Setup actions, should ensure some value is written to storage. | ||
Pallet::<T>::on_initialize(first_block); | ||
Pallet::<T>::on_finalize(first_block); | ||
assert!( | ||
BaseFeePerGas::<T>::exists(), | ||
"Value should exist in storage after first on_finalize call" | ||
); | ||
|
||
#[block] | ||
{ | ||
let _ = Pallet::<T>::min_gas_price(); | ||
} | ||
} | ||
|
||
impl_benchmark_test_suite!( | ||
Pallet, | ||
crate::benchmarking::tests::new_test_ext(), | ||
crate::mock::TestRuntime, | ||
); | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use crate::mock; | ||
use frame_support::sp_io::TestExternalities; | ||
|
||
pub fn new_test_ext() -> TestExternalities { | ||
mock::ExtBuilder::build() | ||
} | ||
} |
Oops, something went wrong.