fix: Complete snowbridge pezpallet rebrand and critical bug fixes
- snowbridge-pezpallet-* → pezsnowbridge-pezpallet-* (201 refs) - pallet/ directories → pezpallet/ (4 locations) - Fixed pezpallet.rs self-include recursion bug - Fixed sc-chain-spec hardcoded crate name in derive macro - Reverted .pezpallet_by_name() to .pallet_by_name() (subxt API) - Added BizinikiwiConfig type alias for zombienet tests - Deleted obsolete session state files Verified: pezsnowbridge-pezpallet-*, pezpallet-staking, pezpallet-staking-async, pezframe-benchmarking-cli all pass cargo check
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
// limitations under the License.
|
||||
|
||||
use crate::{
|
||||
unsigned::{miner::OffchainWorkerMiner, Call, Config, Pallet},
|
||||
unsigned::{miner::OffchainWorkerMiner, Call, Config, Pezpallet},
|
||||
verifier::Verifier,
|
||||
CurrentPhase, Phase,
|
||||
};
|
||||
@@ -34,9 +34,9 @@ mod benchmarks {
|
||||
fn validate_unsigned() -> Result<(), BenchmarkError> {
|
||||
#[cfg(test)]
|
||||
crate::mock::ElectionStart::set(pezsp_runtime::traits::Bounded::max_value());
|
||||
crate::Pallet::<T>::start().unwrap();
|
||||
crate::Pezpallet::<T>::start().unwrap();
|
||||
|
||||
crate::Pallet::<T>::roll_until_matches(|| {
|
||||
crate::Pezpallet::<T>::roll_until_matches(|| {
|
||||
matches!(CurrentPhase::<T>::get(), Phase::Unsigned(_))
|
||||
});
|
||||
let call: Call<T> = OffchainWorkerMiner::<T>::mine_solution(T::MinerPages::get(), false)
|
||||
@@ -45,7 +45,7 @@ mod benchmarks {
|
||||
|
||||
#[block]
|
||||
{
|
||||
assert_ok!(Pallet::<T>::validate_unsigned(TransactionSource::Local, &call));
|
||||
assert_ok!(Pezpallet::<T>::validate_unsigned(TransactionSource::Local, &call));
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -55,10 +55,10 @@ mod benchmarks {
|
||||
fn submit_unsigned() -> Result<(), BenchmarkError> {
|
||||
#[cfg(test)]
|
||||
crate::mock::ElectionStart::set(pezsp_runtime::traits::Bounded::max_value());
|
||||
crate::Pallet::<T>::start().unwrap();
|
||||
crate::Pezpallet::<T>::start().unwrap();
|
||||
|
||||
// roll to unsigned phase open
|
||||
crate::Pallet::<T>::roll_until_matches(|| {
|
||||
crate::Pezpallet::<T>::roll_until_matches(|| {
|
||||
matches!(CurrentPhase::<T>::get(), Phase::Unsigned(_))
|
||||
});
|
||||
// TODO: we need to better ensure that this is actually worst case
|
||||
@@ -69,7 +69,7 @@ mod benchmarks {
|
||||
assert!(T::Verifier::queued_score().is_none());
|
||||
#[block]
|
||||
{
|
||||
assert_ok!(Pallet::<T>::submit_unsigned(RawOrigin::None.into(), Box::new(solution)));
|
||||
assert_ok!(Pezpallet::<T>::submit_unsigned(RawOrigin::None.into(), Box::new(solution)));
|
||||
}
|
||||
|
||||
// something is queued
|
||||
@@ -81,10 +81,10 @@ mod benchmarks {
|
||||
fn mine_solution(p: Linear<1, { T::Pages::get() }>) -> Result<(), BenchmarkError> {
|
||||
#[cfg(test)]
|
||||
crate::mock::ElectionStart::set(pezsp_runtime::traits::Bounded::max_value());
|
||||
crate::Pallet::<T>::start().unwrap();
|
||||
crate::Pezpallet::<T>::start().unwrap();
|
||||
|
||||
// roll to unsigned phase open
|
||||
crate::Pallet::<T>::roll_until_matches(|| {
|
||||
crate::Pezpallet::<T>::roll_until_matches(|| {
|
||||
matches!(CurrentPhase::<T>::get(), Phase::Unsigned(_))
|
||||
});
|
||||
|
||||
@@ -97,7 +97,7 @@ mod benchmarks {
|
||||
}
|
||||
|
||||
impl_benchmark_test_suite!(
|
||||
Pallet,
|
||||
Pezpallet,
|
||||
crate::mock::ExtBuilder::full().build_unchecked(),
|
||||
crate::mock::Runtime
|
||||
);
|
||||
|
||||
@@ -15,17 +15,17 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! The miner code for the EPMB pallet.
|
||||
//! The miner code for the EPMB pezpallet.
|
||||
//!
|
||||
//! It is broadly consisted of two main types:
|
||||
//!
|
||||
//! * [`crate::unsigned::miner::BaseMiner`], which is more generic, needs parameterization via
|
||||
//! [`crate::unsigned::miner::MinerConfig`], and can be used by an external implementation.
|
||||
//! * [`crate::unsigned::miner::OffchainWorkerMiner`], which is more opinionated, and is used by
|
||||
//! this pallet via the `offchain_worker` hook to also mine solutions during the
|
||||
//! this pezpallet via the `offchain_worker` hook to also mine solutions during the
|
||||
//! `Phase::Unsigned`.
|
||||
|
||||
use super::{Call, Config, Pallet};
|
||||
use super::{Call, Config, Pezpallet};
|
||||
use crate::{
|
||||
helpers,
|
||||
types::{PadSolutionPages, *},
|
||||
@@ -75,7 +75,7 @@ pub enum MinerError<T: MinerConfig> {
|
||||
Solver(MinerSolverErrorOf<T>),
|
||||
/// Snapshot data was unavailable unexpectedly.
|
||||
SnapshotUnAvailable(SnapshotType),
|
||||
/// The base, common errors from the pallet.
|
||||
/// The base, common errors from the pezpallet.
|
||||
Common(CommonError),
|
||||
/// The solution generated from the miner is not feasible.
|
||||
Feasibility(verifier::FeasibilityError),
|
||||
@@ -112,7 +112,7 @@ impl<T: MinerConfig> From<CommonError> for MinerError<T> {
|
||||
pub enum OffchainMinerError<T: Config> {
|
||||
/// An error in the base miner.
|
||||
BaseMiner(MinerError<T::MinerConfig>),
|
||||
/// The base, common errors from the pallet.
|
||||
/// The base, common errors from the pezpallet.
|
||||
Common(CommonError),
|
||||
/// Something went wrong fetching the lock.
|
||||
Lock(&'static str),
|
||||
@@ -143,7 +143,7 @@ impl<T: Config> From<CommonError> for OffchainMinerError<T> {
|
||||
/// Configurations for the miner.
|
||||
///
|
||||
/// This is extracted from the main crate's config so that an offchain miner can readily use the
|
||||
/// [`BaseMiner`] without needing to deal with the rest of the pallet's configuration.
|
||||
/// [`BaseMiner`] without needing to deal with the rest of the pezpallet's configuration.
|
||||
pub trait MinerConfig {
|
||||
/// The account id type.
|
||||
type AccountId: Ord + Clone + codec::Codec + core::fmt::Debug;
|
||||
@@ -165,7 +165,7 @@ pub trait MinerConfig {
|
||||
///
|
||||
/// This value is not set in stone, and it is up to an individual miner to configure. A good
|
||||
/// value is something like 75% of the total block length, which can be fetched from the system
|
||||
/// pallet.
|
||||
/// pezpallet.
|
||||
type MaxLength: Get<u32>;
|
||||
/// Maximum number of votes per voter.
|
||||
///
|
||||
@@ -208,7 +208,7 @@ pub trait MinerConfig {
|
||||
}
|
||||
|
||||
/// A base miner that is only capable of mining a new solution and checking it against the state of
|
||||
/// this pallet for feasibility, and trimming its length/weight.
|
||||
/// this pezpallet for feasibility, and trimming its length/weight.
|
||||
pub struct BaseMiner<T: MinerConfig>(pezsp_std::marker::PhantomData<T>);
|
||||
|
||||
/// Parameterized `BoundedSupports` for the miner.
|
||||
@@ -690,7 +690,7 @@ impl<T: Config> OffchainWorkerMiner<T> {
|
||||
.ok_or(MinerError::SnapshotUnAvailable(SnapshotType::Targets))?;
|
||||
|
||||
// This is the range of voters that we are interested in.
|
||||
let voter_pages_range = crate::Pallet::<T>::msp_range_for(pages as usize);
|
||||
let voter_pages_range = crate::Pezpallet::<T>::msp_range_for(pages as usize);
|
||||
|
||||
sublog!(
|
||||
debug,
|
||||
@@ -727,7 +727,7 @@ impl<T: Config> OffchainWorkerMiner<T> {
|
||||
return Err(OffchainMinerError::<T>::ZeroPages);
|
||||
}
|
||||
let (voter_pages, all_targets, desired_targets) = Self::fetch_snapshot(pages)?;
|
||||
let round = crate::Pallet::<T>::round();
|
||||
let round = crate::Pezpallet::<T>::round();
|
||||
BaseMiner::<T::MinerConfig>::mine_solution(MineInput {
|
||||
desired_targets,
|
||||
all_targets,
|
||||
@@ -782,7 +782,7 @@ impl<T: Config> OffchainWorkerMiner<T> {
|
||||
do_feasibility: bool,
|
||||
) -> Result<(), OffchainMinerError<T>> {
|
||||
// NOTE: we prefer cheap checks first, so first run unsigned checks.
|
||||
Pallet::<T>::unsigned_specific_checks(paged_solution)?;
|
||||
Pezpallet::<T>::unsigned_specific_checks(paged_solution)?;
|
||||
Self::base_check_solution(paged_solution, maybe_snapshot_fingerprint, do_feasibility)
|
||||
}
|
||||
|
||||
@@ -817,7 +817,7 @@ impl<T: Config> OffchainWorkerMiner<T> {
|
||||
maybe_snapshot_fingerprint: Option<T::Hash>,
|
||||
do_feasibility: bool,
|
||||
) -> Result<(), OffchainMinerError<T>> {
|
||||
let _ = crate::Pallet::<T>::snapshot_independent_checks(
|
||||
let _ = crate::Pezpallet::<T>::snapshot_independent_checks(
|
||||
paged_solution,
|
||||
maybe_snapshot_fingerprint,
|
||||
)?;
|
||||
|
||||
@@ -17,10 +17,10 @@
|
||||
|
||||
//! ## The unsigned phase, and its miner.
|
||||
//!
|
||||
//! This pallet deals with unsigned submissions. These are backup, "possibly" multi-page submissions
|
||||
//! This pezpallet deals with unsigned submissions. These are backup, "possibly" multi-page submissions
|
||||
//! from validators.
|
||||
//!
|
||||
//! This pallet has two miners, described in [`unsigned::miner`].
|
||||
//! This pezpallet has two miners, described in [`unsigned::miner`].
|
||||
//!
|
||||
//! As it stands, a validator can, during the unsigned phase, submit up to
|
||||
//! [`unsigned::Config::MinerPages`] pages. While this can be more than 1, it can likely not be a
|
||||
@@ -71,16 +71,16 @@
|
||||
|
||||
/// Export weights
|
||||
pub use crate::weights::traits::pezpallet_election_provider_multi_block_unsigned::*;
|
||||
/// Exports of this pallet
|
||||
pub use pallet::*;
|
||||
/// Exports of this pezpallet
|
||||
pub use pezpallet::*;
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
mod benchmarking;
|
||||
|
||||
/// The miner.
|
||||
pub mod miner;
|
||||
|
||||
#[pezframe_support::pallet]
|
||||
mod pallet {
|
||||
#[pezframe_support::pezpallet]
|
||||
mod pezpallet {
|
||||
use super::WeightInfo;
|
||||
use crate::{
|
||||
types::*,
|
||||
@@ -102,8 +102,8 @@ mod pallet {
|
||||
|
||||
pub(crate) type UnsignedWeightsOf<T> = <T as Config>::WeightInfo;
|
||||
|
||||
#[pallet::config]
|
||||
#[pallet::disable_pezframe_system_supertrait_check]
|
||||
#[pezpallet::config]
|
||||
#[pezpallet::disable_pezframe_system_supertrait_check]
|
||||
pub trait Config: crate::Config + CreateBare<Call<Self>> {
|
||||
/// The repeat threshold of the offchain worker.
|
||||
///
|
||||
@@ -127,15 +127,15 @@ mod pallet {
|
||||
/// The number of pages that the offchain miner will try and submit.
|
||||
type MinerPages: Get<PageIndex>;
|
||||
|
||||
/// Runtime weight information of this pallet.
|
||||
/// Runtime weight information of this pezpallet.
|
||||
type WeightInfo: WeightInfo;
|
||||
}
|
||||
|
||||
#[pallet::pallet]
|
||||
pub struct Pallet<T>(PhantomData<T>);
|
||||
#[pezpallet::pezpallet]
|
||||
pub struct Pezpallet<T>(PhantomData<T>);
|
||||
|
||||
#[pallet::call]
|
||||
impl<T: Config> Pallet<T> {
|
||||
#[pezpallet::call]
|
||||
impl<T: Config> Pezpallet<T> {
|
||||
/// Submit an unsigned solution.
|
||||
///
|
||||
/// This works very much like an inherent, as only the validators are permitted to submit
|
||||
@@ -146,13 +146,13 @@ mod pallet {
|
||||
/// verified on the fly.
|
||||
///
|
||||
/// The `paged_solution` may contain at most [`Config::MinerPages`] pages. They are
|
||||
/// interpreted as msp -> lsp, as per [`crate::Pallet::msp_range_for`].
|
||||
/// interpreted as msp -> lsp, as per [`crate::Pezpallet::msp_range_for`].
|
||||
///
|
||||
/// For example, if `Pages = 4`, and `MinerPages = 2`, our full snapshot range would be [0,
|
||||
/// 1, 2, 3], with 3 being msp. But, in this case, then the `paged_raw_solution.pages` is
|
||||
/// expected to correspond to `[snapshot(2), snapshot(3)]`.
|
||||
#[pallet::weight((UnsignedWeightsOf::<T>::submit_unsigned(), DispatchClass::Operational))]
|
||||
#[pallet::call_index(0)]
|
||||
#[pezpallet::weight((UnsignedWeightsOf::<T>::submit_unsigned(), DispatchClass::Operational))]
|
||||
#[pezpallet::call_index(0)]
|
||||
pub fn submit_unsigned(
|
||||
origin: OriginFor<T>,
|
||||
paged_solution: Box<PagedRawSolution<T::MinerConfig>>,
|
||||
@@ -168,7 +168,7 @@ mod pallet {
|
||||
let claimed_score = paged_solution.score;
|
||||
|
||||
// we select the most significant pages, based on `T::MinerPages`.
|
||||
let page_indices = crate::Pallet::<T>::msp_range_for(T::MinerPages::get() as usize);
|
||||
let page_indices = crate::Pezpallet::<T>::msp_range_for(T::MinerPages::get() as usize);
|
||||
<T::Verifier as Verifier>::verify_synchronous_multi(
|
||||
paged_solution.solution_pages,
|
||||
page_indices,
|
||||
@@ -180,8 +180,8 @@ mod pallet {
|
||||
}
|
||||
}
|
||||
|
||||
#[pallet::validate_unsigned]
|
||||
impl<T: Config> ValidateUnsigned for Pallet<T> {
|
||||
#[pezpallet::validate_unsigned]
|
||||
impl<T: Config> ValidateUnsigned for Pezpallet<T> {
|
||||
type Call = Call<T>;
|
||||
fn validate_unsigned(source: TransactionSource, call: &Self::Call) -> TransactionValidity {
|
||||
if let Call::submit_unsigned { paged_solution, .. } = call {
|
||||
@@ -232,8 +232,8 @@ mod pallet {
|
||||
}
|
||||
}
|
||||
|
||||
#[pallet::hooks]
|
||||
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
|
||||
#[pezpallet::hooks]
|
||||
impl<T: Config> Hooks<BlockNumberFor<T>> for Pezpallet<T> {
|
||||
fn integrity_test() {
|
||||
assert!(
|
||||
UnsignedWeightsOf::<T>::submit_unsigned().all_lte(T::BlockWeights::get().max_block),
|
||||
@@ -258,7 +258,7 @@ mod pallet {
|
||||
// This should only come useful in an **abrupt** termination of execution, otherwise the
|
||||
// guard will be dropped upon successful execution.
|
||||
let mut lock =
|
||||
StorageLock::<BlockAndTime<pezframe_system::Pallet<T>>>::with_block_deadline(
|
||||
StorageLock::<BlockAndTime<pezframe_system::Pezpallet<T>>>::with_block_deadline(
|
||||
miner::OffchainWorkerMiner::<T>::OFFCHAIN_LOCK,
|
||||
T::UnsignedPhase::get().saturated_into(),
|
||||
);
|
||||
@@ -279,12 +279,12 @@ mod pallet {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Config> Pallet<T> {
|
||||
impl<T: Config> Pezpallet<T> {
|
||||
/// Internal logic of the offchain worker, to be executed only when the offchain lock is
|
||||
/// acquired with success.
|
||||
fn do_synchronized_offchain_worker(now: BlockNumberFor<T>) {
|
||||
use miner::OffchainWorkerMiner;
|
||||
let current_phase = crate::Pallet::<T>::current_phase();
|
||||
let current_phase = crate::Pezpallet::<T>::current_phase();
|
||||
sublog!(
|
||||
trace,
|
||||
"unsigned",
|
||||
@@ -334,18 +334,18 @@ mod pallet {
|
||||
paged_solution: &PagedRawSolution<T::MinerConfig>,
|
||||
) -> Result<(), CommonError> {
|
||||
Self::unsigned_specific_checks(paged_solution)
|
||||
.and(crate::Pallet::<T>::snapshot_independent_checks(paged_solution, None))
|
||||
.and(crate::Pezpallet::<T>::snapshot_independent_checks(paged_solution, None))
|
||||
.map_err(Into::into)
|
||||
}
|
||||
|
||||
/// The checks that are specific to the (this) unsigned pallet.
|
||||
/// The checks that are specific to the (this) unsigned pezpallet.
|
||||
///
|
||||
/// ensure solution has the correct phase, and it has only 1 page.
|
||||
pub fn unsigned_specific_checks(
|
||||
paged_solution: &PagedRawSolution<T::MinerConfig>,
|
||||
) -> Result<(), CommonError> {
|
||||
ensure!(
|
||||
crate::Pallet::<T>::current_phase().is_unsigned(),
|
||||
crate::Pezpallet::<T>::current_phase().is_unsigned(),
|
||||
CommonError::EarlySubmission
|
||||
);
|
||||
ensure!(
|
||||
|
||||
Reference in New Issue
Block a user