[EPM pallet]: remove number of signed submissions (#10945)

* [EPM pallet]: remove `number of signed submissions`

Closing #9229

* fix tests

* remove needless assert

* Update frame/election-provider-multi-phase/src/lib.rs

* cargo fmt

Signed-off-by: Niklas <niklasadolfsson1@gmail.com>

* fix grumbles

* cargo run --quiet --profile=production  --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_election_provider_multi_phase --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/election-provider-multi-phase/src/weights.rs --template=./.maintain/frame-weight-template.hbs

* drop `num_signed_submissions` in WeightInfo too

* fix build

Co-authored-by: Parity Bot <admin@parity.io>
This commit is contained in:
Niklas Adolfsson
2022-03-03 23:47:10 +01:00
committed by GitHub
parent d6a52c637c
commit e6b6c8aac6
6 changed files with 101 additions and 156 deletions
@@ -963,25 +963,13 @@ pub mod pallet {
///
/// A deposit is reserved and recorded for the solution. Based on the outcome, the solution
/// might be rewarded, slashed, or get all or a part of the deposit back.
///
/// # <weight>
/// Queue size must be provided as witness data.
/// # </weight>
#[pallet::weight(T::WeightInfo::submit(*num_signed_submissions))]
#[pallet::weight(T::WeightInfo::submit())]
pub fn submit(
origin: OriginFor<T>,
raw_solution: Box<RawSolution<SolutionOf<T>>>,
num_signed_submissions: u32,
) -> DispatchResult {
let who = ensure_signed(origin)?;
// ensure witness data is correct.
ensure!(
num_signed_submissions >=
<SignedSubmissions<T>>::decode_len().unwrap_or_default() as u32,
Error::<T>::SignedInvalidWitness,
);
// ensure solution is timely.
ensure!(Self::current_phase().is_signed(), Error::<T>::PreDispatchEarlySubmission);
@@ -1000,8 +988,7 @@ pub mod pallet {
// create the submission
let deposit = Self::deposit_for(&raw_solution, size);
let reward = {
let call =
Call::submit { raw_solution: raw_solution.clone(), num_signed_submissions };
let call = Call::submit { raw_solution: raw_solution.clone() };
let call_fee = T::EstimateCallFee::estimate_call_fee(&call, None.into());
T::SignedRewardBase::get().saturating_add(call_fee)
};
@@ -1970,11 +1957,7 @@ mod tests {
score: ElectionScore { minimal_stake: (5 + s).into(), ..Default::default() },
..Default::default()
};
assert_ok!(MultiPhase::submit(
crate::mock::Origin::signed(99),
Box::new(solution),
MultiPhase::signed_submissions().len() as u32
));
assert_ok!(MultiPhase::submit(crate::mock::Origin::signed(99), Box::new(solution)));
}
// an unexpected call to elect.