mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-08 11:18:01 +00:00
* Remove Call part imports of the offences and authority discovery pallets * Remove non-existent Call enum variants * Move ValidateUnsigned impl to be under #[pallet::validate_unsigned] in claims pallet * Remove unused imports * Remove Call part import for randomness collective flip pallet * update Substrate Co-authored-by: parity-processbot <>
This commit is contained in:
Generated
+155
-155
File diff suppressed because it is too large
Load Diff
@@ -397,7 +397,7 @@ construct_runtime!(
|
||||
BridgeRialtoGrandpa: pallet_bridge_grandpa::{Pallet, Call, Storage},
|
||||
BridgeWestendGrandpa: pallet_bridge_grandpa::<Instance1>::{Pallet, Call, Config<T>, Storage},
|
||||
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
|
||||
RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Call, Storage},
|
||||
RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Storage},
|
||||
Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent},
|
||||
Aura: pallet_aura::{Pallet, Config<T>},
|
||||
Grandpa: pallet_grandpa::{Pallet, Call, Storage, Config, Event},
|
||||
|
||||
@@ -507,7 +507,7 @@ construct_runtime!(
|
||||
BridgeDispatch: pallet_bridge_dispatch::{Pallet, Event<T>},
|
||||
BridgeMillauMessages: pallet_bridge_messages::{Pallet, Call, Storage, Event<T>},
|
||||
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
|
||||
RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Call, Storage},
|
||||
RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Storage},
|
||||
Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent},
|
||||
Aura: pallet_aura::{Pallet, Config<T>},
|
||||
Grandpa: pallet_grandpa::{Pallet, Call, Storage, Config, Event},
|
||||
|
||||
@@ -27,8 +27,7 @@ use sp_runtime::traits::Zero;
|
||||
use sp_runtime::{
|
||||
traits::{CheckedSub, SignedExtension, DispatchInfoOf}, RuntimeDebug,
|
||||
transaction_validity::{
|
||||
TransactionLongevity, TransactionValidity, ValidTransaction, InvalidTransaction,
|
||||
TransactionSource, TransactionValidityError,
|
||||
TransactionValidity, ValidTransaction, InvalidTransaction, TransactionValidityError,
|
||||
},
|
||||
};
|
||||
use primitives::v1::ValidityError;
|
||||
@@ -429,6 +428,53 @@ pub mod pallet {
|
||||
Ok(Pays::No.into())
|
||||
}
|
||||
}
|
||||
|
||||
#[pallet::validate_unsigned]
|
||||
impl<T: Config> ValidateUnsigned for Pallet<T> {
|
||||
type Call = Call<T>;
|
||||
|
||||
fn validate_unsigned(_source: TransactionSource, call: &Self::Call) -> TransactionValidity {
|
||||
const PRIORITY: u64 = 100;
|
||||
|
||||
let (maybe_signer, maybe_statement) = match call {
|
||||
// <weight>
|
||||
// The weight of this logic is included in the `claim` dispatchable.
|
||||
// </weight>
|
||||
Call::claim(account, ethereum_signature) => {
|
||||
let data = account.using_encoded(to_ascii_hex);
|
||||
(Self::eth_recover(ðereum_signature, &data, &[][..]), None)
|
||||
}
|
||||
// <weight>
|
||||
// The weight of this logic is included in the `claim_attest` dispatchable.
|
||||
// </weight>
|
||||
Call::claim_attest(account, ethereum_signature, statement) => {
|
||||
let data = account.using_encoded(to_ascii_hex);
|
||||
(Self::eth_recover(ðereum_signature, &data, &statement), Some(statement.as_slice()))
|
||||
}
|
||||
_ => return Err(InvalidTransaction::Call.into()),
|
||||
};
|
||||
|
||||
let signer = maybe_signer
|
||||
.ok_or(InvalidTransaction::Custom(ValidityError::InvalidEthereumSignature.into()))?;
|
||||
|
||||
let e = InvalidTransaction::Custom(ValidityError::SignerHasNoClaim.into());
|
||||
ensure!(<Claims<T>>::contains_key(&signer), e);
|
||||
|
||||
let e = InvalidTransaction::Custom(ValidityError::InvalidStatement.into());
|
||||
match Signing::<T>::get(signer) {
|
||||
None => ensure!(maybe_statement.is_none(), e),
|
||||
Some(s) => ensure!(Some(s.to_text()) == maybe_statement, e),
|
||||
}
|
||||
|
||||
Ok(ValidTransaction {
|
||||
priority: PRIORITY,
|
||||
requires: vec![],
|
||||
provides: vec![("claims", signer).encode()],
|
||||
longevity: TransactionLongevity::max_value(),
|
||||
propagate: true,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Converts the given binary data into ASCII-encoded hex. It will be twice the length.
|
||||
@@ -503,52 +549,6 @@ impl<T: Config> Pallet<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Config> sp_runtime::traits::ValidateUnsigned for Pallet<T> {
|
||||
type Call = Call<T>;
|
||||
|
||||
fn validate_unsigned(_source: TransactionSource, call: &Self::Call) -> TransactionValidity {
|
||||
const PRIORITY: u64 = 100;
|
||||
|
||||
let (maybe_signer, maybe_statement) = match call {
|
||||
// <weight>
|
||||
// The weight of this logic is included in the `claim` dispatchable.
|
||||
// </weight>
|
||||
Call::claim(account, ethereum_signature) => {
|
||||
let data = account.using_encoded(to_ascii_hex);
|
||||
(Self::eth_recover(ðereum_signature, &data, &[][..]), None)
|
||||
}
|
||||
// <weight>
|
||||
// The weight of this logic is included in the `claim_attest` dispatchable.
|
||||
// </weight>
|
||||
Call::claim_attest(account, ethereum_signature, statement) => {
|
||||
let data = account.using_encoded(to_ascii_hex);
|
||||
(Self::eth_recover(ðereum_signature, &data, &statement), Some(statement.as_slice()))
|
||||
}
|
||||
_ => return Err(InvalidTransaction::Call.into()),
|
||||
};
|
||||
|
||||
let signer = maybe_signer
|
||||
.ok_or(InvalidTransaction::Custom(ValidityError::InvalidEthereumSignature.into()))?;
|
||||
|
||||
let e = InvalidTransaction::Custom(ValidityError::SignerHasNoClaim.into());
|
||||
ensure!(<Claims<T>>::contains_key(&signer), e);
|
||||
|
||||
let e = InvalidTransaction::Custom(ValidityError::InvalidStatement.into());
|
||||
match Signing::<T>::get(signer) {
|
||||
None => ensure!(maybe_statement.is_none(), e),
|
||||
Some(s) => ensure!(Some(s.to_text()) == maybe_statement, e),
|
||||
}
|
||||
|
||||
Ok(ValidTransaction {
|
||||
priority: PRIORITY,
|
||||
requires: vec![],
|
||||
provides: vec![("claims", signer).encode()],
|
||||
longevity: TransactionLongevity::max_value(),
|
||||
propagate: true,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/// Validate `attest` calls prior to execution. Needed to avoid a DoS attack since they are
|
||||
/// otherwise free to place on chain.
|
||||
#[derive(Encode, Decode, Clone, Eq, PartialEq)]
|
||||
@@ -649,7 +649,11 @@ mod tests {
|
||||
use parity_scale_codec::Encode;
|
||||
// The testing primitives are very useful for avoiding having to work with signatures
|
||||
// or public keys. `u64` is used as the `AccountId` and no `Signature`s are required.
|
||||
use sp_runtime::{traits::{BlakeTwo256, IdentityLookup, Identity}, testing::Header};
|
||||
use sp_runtime::{
|
||||
traits::{BlakeTwo256, IdentityLookup, Identity},
|
||||
transaction_validity::TransactionLongevity,
|
||||
testing::Header,
|
||||
};
|
||||
use frame_support::{
|
||||
assert_ok, assert_err, assert_noop, parameter_types,
|
||||
ord_parameter_types, weights::{Pays, GetDispatchInfo}, traits::{ExistenceRequirement, GenesisBuild},
|
||||
|
||||
@@ -451,7 +451,7 @@ mod tests {
|
||||
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
|
||||
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
|
||||
Slots: slots::{Pallet, Call, Storage, Event<T>},
|
||||
RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Call, Storage},
|
||||
RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Storage},
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -965,11 +965,9 @@ impl InstanceFilter<Call> for ProxyType {
|
||||
// Specifically omitting the entire Balances pallet
|
||||
Call::Authorship(..) |
|
||||
Call::Staking(..) |
|
||||
Call::Offences(..) |
|
||||
Call::Session(..) |
|
||||
Call::Grandpa(..) |
|
||||
Call::ImOnline(..) |
|
||||
Call::AuthorityDiscovery(..) |
|
||||
Call::Democracy(..) |
|
||||
Call::Council(..) |
|
||||
Call::TechnicalCommittee(..) |
|
||||
@@ -1401,12 +1399,12 @@ construct_runtime! {
|
||||
// Consensus support.
|
||||
Authorship: pallet_authorship::{Pallet, Call, Storage} = 5,
|
||||
Staking: pallet_staking::{Pallet, Call, Storage, Config<T>, Event<T>} = 6,
|
||||
Offences: pallet_offences::{Pallet, Call, Storage, Event} = 7,
|
||||
Offences: pallet_offences::{Pallet, Storage, Event} = 7,
|
||||
Historical: session_historical::{Pallet} = 34,
|
||||
Session: pallet_session::{Pallet, Call, Storage, Event, Config<T>} = 8,
|
||||
Grandpa: pallet_grandpa::{Pallet, Call, Storage, Config, Event, ValidateUnsigned} = 10,
|
||||
ImOnline: pallet_im_online::{Pallet, Call, Storage, Event<T>, ValidateUnsigned, Config<T>} = 11,
|
||||
AuthorityDiscovery: pallet_authority_discovery::{Pallet, Call, Config} = 12,
|
||||
AuthorityDiscovery: pallet_authority_discovery::{Pallet, Config} = 12,
|
||||
|
||||
// Governance stuff; uncallable initially.
|
||||
Democracy: pallet_democracy::{Pallet, Call, Storage, Config<T>, Event<T>} = 13,
|
||||
|
||||
@@ -129,9 +129,8 @@ impl Filter<Call> for BaseFilter {
|
||||
Call::TechnicalMembership(_) | Call::Treasury(_) | Call::PhragmenElection(_) |
|
||||
Call::System(_) | Call::Scheduler(_) | Call::Indices(_) |
|
||||
Call::Babe(_) | Call::Timestamp(_) | Call::Balances(_) |
|
||||
Call::Authorship(_) | Call::Staking(_) | Call::Offences(_) |
|
||||
Call::Authorship(_) | Call::Staking(_) |
|
||||
Call::Session(_) | Call::Grandpa(_) | Call::ImOnline(_) |
|
||||
Call::AuthorityDiscovery(_) |
|
||||
Call::Utility(_) | Call::Claims(_) | Call::Vesting(_) |
|
||||
Call::Identity(_) | Call::Proxy(_) | Call::Multisig(_) |
|
||||
Call::Bounties(_) | Call::Tips(_) | Call::ElectionProviderMultiPhase(_)
|
||||
@@ -904,11 +903,9 @@ impl InstanceFilter<Call> for ProxyType {
|
||||
// Specifically omitting the entire Balances pallet
|
||||
Call::Authorship(..) |
|
||||
Call::Staking(..) |
|
||||
Call::Offences(..) |
|
||||
Call::Session(..) |
|
||||
Call::Grandpa(..) |
|
||||
Call::ImOnline(..) |
|
||||
Call::AuthorityDiscovery(..) |
|
||||
Call::Democracy(..) |
|
||||
Call::Council(..) |
|
||||
Call::TechnicalCommittee(..) |
|
||||
@@ -998,12 +995,12 @@ construct_runtime! {
|
||||
// Consensus support.
|
||||
Authorship: pallet_authorship::{Pallet, Call, Storage} = 6,
|
||||
Staking: pallet_staking::{Pallet, Call, Storage, Config<T>, Event<T>} = 7,
|
||||
Offences: pallet_offences::{Pallet, Call, Storage, Event} = 8,
|
||||
Offences: pallet_offences::{Pallet, Storage, Event} = 8,
|
||||
Historical: session_historical::{Pallet} = 33,
|
||||
Session: pallet_session::{Pallet, Call, Storage, Event, Config<T>} = 9,
|
||||
Grandpa: pallet_grandpa::{Pallet, Call, Storage, Config, Event, ValidateUnsigned} = 11,
|
||||
ImOnline: pallet_im_online::{Pallet, Call, Storage, Event<T>, ValidateUnsigned, Config<T>} = 12,
|
||||
AuthorityDiscovery: pallet_authority_discovery::{Pallet, Call, Config} = 13,
|
||||
AuthorityDiscovery: pallet_authority_discovery::{Pallet, Config} = 13,
|
||||
|
||||
// Governance stuff.
|
||||
Democracy: pallet_democracy::{Pallet, Call, Storage, Config<T>, Event<T>} = 14,
|
||||
|
||||
@@ -200,12 +200,12 @@ construct_runtime! {
|
||||
|
||||
// Consensus support.
|
||||
Authorship: pallet_authorship::{Pallet, Call, Storage},
|
||||
Offences: pallet_offences::{Pallet, Call, Storage, Event},
|
||||
Offences: pallet_offences::{Pallet, Storage, Event},
|
||||
Historical: session_historical::{Pallet},
|
||||
Session: pallet_session::{Pallet, Call, Storage, Event, Config<T>},
|
||||
Grandpa: pallet_grandpa::{Pallet, Call, Storage, Config, Event, ValidateUnsigned},
|
||||
ImOnline: pallet_im_online::{Pallet, Call, Storage, Event<T>, ValidateUnsigned, Config<T>},
|
||||
AuthorityDiscovery: pallet_authority_discovery::{Pallet, Call, Config},
|
||||
AuthorityDiscovery: pallet_authority_discovery::{Pallet, Config},
|
||||
|
||||
// Parachains modules.
|
||||
ParachainsOrigin: parachains_origin::{Pallet, Origin},
|
||||
|
||||
@@ -517,11 +517,11 @@ construct_runtime! {
|
||||
// Consensus support.
|
||||
Authorship: pallet_authorship::{Pallet, Call, Storage},
|
||||
Staking: pallet_staking::{Pallet, Call, Storage, Config<T>, Event<T>},
|
||||
Offences: pallet_offences::{Pallet, Call, Storage, Event},
|
||||
Offences: pallet_offences::{Pallet, Storage, Event},
|
||||
Historical: session_historical::{Pallet},
|
||||
Session: pallet_session::{Pallet, Call, Storage, Event, Config<T>},
|
||||
Grandpa: pallet_grandpa::{Pallet, Call, Storage, Config, Event},
|
||||
AuthorityDiscovery: pallet_authority_discovery::{Pallet, Call, Config},
|
||||
AuthorityDiscovery: pallet_authority_discovery::{Pallet, Config},
|
||||
|
||||
// Claims. Usable initially.
|
||||
Claims: claims::{Pallet, Call, Storage, Event<T>, Config<T>, ValidateUnsigned},
|
||||
|
||||
@@ -659,11 +659,9 @@ impl InstanceFilter<Call> for ProxyType {
|
||||
// Specifically omitting the entire Balances pallet
|
||||
Call::Authorship(..) |
|
||||
Call::Staking(..) |
|
||||
Call::Offences(..) |
|
||||
Call::Session(..) |
|
||||
Call::Grandpa(..) |
|
||||
Call::ImOnline(..) |
|
||||
Call::AuthorityDiscovery(..) |
|
||||
Call::Utility(..) |
|
||||
Call::Identity(..) |
|
||||
Call::Recovery(pallet_recovery::Call::as_recovered(..)) |
|
||||
@@ -1018,12 +1016,12 @@ construct_runtime! {
|
||||
// Consensus support.
|
||||
Authorship: pallet_authorship::{Pallet, Call, Storage} = 5,
|
||||
Staking: pallet_staking::{Pallet, Call, Storage, Config<T>, Event<T>} = 6,
|
||||
Offences: pallet_offences::{Pallet, Call, Storage, Event} = 7,
|
||||
Offences: pallet_offences::{Pallet, Storage, Event} = 7,
|
||||
Historical: session_historical::{Pallet} = 27,
|
||||
Session: pallet_session::{Pallet, Call, Storage, Event, Config<T>} = 8,
|
||||
Grandpa: pallet_grandpa::{Pallet, Call, Storage, Config, Event, ValidateUnsigned} = 10,
|
||||
ImOnline: pallet_im_online::{Pallet, Call, Storage, Event<T>, ValidateUnsigned, Config<T>} = 11,
|
||||
AuthorityDiscovery: pallet_authority_discovery::{Pallet, Call, Config} = 12,
|
||||
AuthorityDiscovery: pallet_authority_discovery::{Pallet, Config} = 12,
|
||||
|
||||
// Utility module.
|
||||
Utility: pallet_utility::{Pallet, Call, Event} = 16,
|
||||
|
||||
Reference in New Issue
Block a user