From daa185493d902dd7865e7a77a6efdb832b3ccaf1 Mon Sep 17 00:00:00 2001 From: Branan Riley Date: Wed, 7 Jun 2023 14:58:03 -0700 Subject: [PATCH] Defer to DealWithFees for treasury/author split --- runtime/common/src/evm/fees.rs | 20 +++++++------------- runtime/development/src/evm.rs | 2 +- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/runtime/common/src/evm/fees.rs b/runtime/common/src/evm/fees.rs index 27820e5798..83638d9cd5 100644 --- a/runtime/common/src/evm/fees.rs +++ b/runtime/common/src/evm/fees.rs @@ -15,7 +15,6 @@ use core::marker::PhantomData; -use cfg_primitives::constants::TREASURY_FEE_RATIO; use frame_support::traits::{ Currency, ExistenceRequirement, Imbalance, OnUnbalanced, SignedImbalance, WithdrawReasons, }; @@ -25,10 +24,10 @@ use pallet_treasury::Pallet as Treasury; use sp_core::{H160, U256}; use sp_runtime::{ traits::{UniqueSaturatedInto, Zero}, - Perbill, Saturating, + Saturating, }; -use crate::fees::{NegativeImbalance, ToAuthor}; +use crate::fees::{DealWithFees, NegativeImbalance}; type AccountIdOf = ::AccountId; type Balance = as Currency>>::Balance; @@ -36,6 +35,7 @@ type PositiveImbalance = as Currency>>::PositiveI type Error = pallet_evm::Error; +/// Handler for EVM fees pub struct DealWithEVMFees(PhantomData); impl OnChargeEVMTransaction for DealWithEVMFees @@ -111,20 +111,14 @@ where .unwrap_or_else(|_| NegativeImbalance::::zero()); let (base_fee, tip) = adjusted_paid.split(base_fee.unique_saturated_into()); - - // Handle base fee and tips - let (treasury_amount, mut author_amount) = base_fee.ration( - TREASURY_FEE_RATIO.deconstruct(), - (Perbill::one() - TREASURY_FEE_RATIO).deconstruct(), - ); - tip.merge_into(&mut author_amount); - as OnUnbalanced<_>>::on_unbalanced(treasury_amount); - as OnUnbalanced<_>>::on_unbalanced(author_amount); - + DealWithFees::::on_unbalanceds([base_fee, tip].into_iter()); None } fn pay_priority_fee(tip: Self::LiquidityInfo) { + // Because we handle the priority fee in the above function, + // there's nothing to do here. Assert for verification + // purposes. assert!(tip.is_none()) } } diff --git a/runtime/development/src/evm.rs b/runtime/development/src/evm.rs index 4bfd0d7e1c..c69c4e3845 100644 --- a/runtime/development/src/evm.rs +++ b/runtime/development/src/evm.rs @@ -16,7 +16,7 @@ use frame_system::EnsureRoot; use pallet_evm::EnsureAddressTruncated; use runtime_common::{ account_conversion::AccountConverter, - evm::{fees::DealWithEVMFees, precompile::Developmennt, BaseFeeThreshold, WEIGHT_PER_GAS}, + evm::{fees::DealWithEVMFees, precompile::Development, BaseFeeThreshold, WEIGHT_PER_GAS}, }; use sp_core::{crypto::ByteArray, H160, U256}; use sp_runtime::Permill;