mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 05:51:02 +00:00
Estimate call fee (#9395)
* Estimate call fee * More fix * Fix * Update frame/support/src/traits/misc.rs Co-authored-by: Zeke Mostov <32168567+emostov@users.noreply.github.com> * try and fix fmt stuff * fmt aain Co-authored-by: Parity Benchmarking Bot <admin@parity.io> Co-authored-by: Zeke Mostov <32168567+emostov@users.noreply.github.com>
This commit is contained in:
@@ -237,7 +237,7 @@ use frame_support::{
|
||||
};
|
||||
use frame_system::{ensure_none, offchain::SendTransactionTypes};
|
||||
use sp_arithmetic::{
|
||||
traits::{CheckedAdd, Zero},
|
||||
traits::{CheckedAdd, Saturating, Zero},
|
||||
UpperOf,
|
||||
};
|
||||
use sp_npos_elections::{
|
||||
@@ -554,7 +554,7 @@ pub use pallet::*;
|
||||
#[frame_support::pallet]
|
||||
pub mod pallet {
|
||||
use super::*;
|
||||
use frame_support::pallet_prelude::*;
|
||||
use frame_support::{pallet_prelude::*, traits::EstimateCallFee};
|
||||
use frame_system::pallet_prelude::*;
|
||||
|
||||
#[pallet::config]
|
||||
@@ -566,6 +566,9 @@ pub mod pallet {
|
||||
/// Currency type.
|
||||
type Currency: ReservableCurrency<Self::AccountId> + Currency<Self::AccountId>;
|
||||
|
||||
/// Something that can predict the fee of a call. Used to sensibly distribute rewards.
|
||||
type EstimateCallFee: EstimateCallFee<Call<Self>, BalanceOf<Self>>;
|
||||
|
||||
/// Duration of the unsigned phase.
|
||||
#[pallet::constant]
|
||||
type UnsignedPhase: Get<Self::BlockNumber>;
|
||||
@@ -973,7 +976,13 @@ pub mod pallet {
|
||||
|
||||
// create the submission
|
||||
let deposit = Self::deposit_for(&solution, size);
|
||||
let submission = SignedSubmission { who: who.clone(), deposit, solution };
|
||||
let reward = {
|
||||
let call = Call::submit(solution.clone(), num_signed_submissions);
|
||||
let call_fee = T::EstimateCallFee::estimate_call_fee(&call, None.into());
|
||||
T::SignedRewardBase::get().saturating_add(call_fee)
|
||||
};
|
||||
|
||||
let submission = SignedSubmission { who: who.clone(), deposit, solution, reward };
|
||||
|
||||
// insert the submission if the queue has space or it's better than the weakest
|
||||
// eject the weakest if the queue was full
|
||||
|
||||
Reference in New Issue
Block a user