mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-11 23:31:07 +00:00
* Some work * Fixes * Tests builds * Fixes * Fixes * Fixes * Fixes * Fixes * Formatting * Formatting * Fix * Fixes * Fixes * Fixes * Fixes * Update Cargo.lock * Bump * Fixes
This commit is contained in:
Generated
+163
-163
File diff suppressed because it is too large
Load Diff
@@ -195,7 +195,7 @@ fn testnet_genesis(
|
||||
aura: AuraConfig { authorities: Vec::new() },
|
||||
beefy: BeefyConfig { authorities: Vec::new() },
|
||||
grandpa: GrandpaConfig { authorities: Vec::new() },
|
||||
sudo: SudoConfig { key: root_key },
|
||||
sudo: SudoConfig { key: Some(root_key) },
|
||||
session: SessionConfig {
|
||||
keys: initial_authorities
|
||||
.iter()
|
||||
|
||||
@@ -155,7 +155,7 @@ fn testnet_genesis(
|
||||
balances: rialto_parachain_runtime::BalancesConfig {
|
||||
balances: endowed_accounts.iter().cloned().map(|k| (k, 1 << 60)).collect(),
|
||||
},
|
||||
sudo: rialto_parachain_runtime::SudoConfig { key: root_key },
|
||||
sudo: rialto_parachain_runtime::SudoConfig { key: Some(root_key) },
|
||||
parachain_info: rialto_parachain_runtime::ParachainInfoConfig { parachain_id: id },
|
||||
aura: rialto_parachain_runtime::AuraConfig { authorities: initial_authorities },
|
||||
aura_ext: Default::default(),
|
||||
|
||||
@@ -221,7 +221,7 @@ fn testnet_genesis(
|
||||
},
|
||||
beefy: BeefyConfig { authorities: Vec::new() },
|
||||
grandpa: GrandpaConfig { authorities: Vec::new() },
|
||||
sudo: SudoConfig { key: root_key },
|
||||
sudo: SudoConfig { key: Some(root_key) },
|
||||
session: SessionConfig {
|
||||
keys: initial_authorities
|
||||
.iter()
|
||||
|
||||
@@ -145,7 +145,7 @@ fn pay_relayers_rewards<Currency, AccountId>(
|
||||
relayer_fund_account: &AccountId,
|
||||
confirmation_fee: Currency::Balance,
|
||||
) where
|
||||
AccountId: Debug + Default + Encode + PartialEq,
|
||||
AccountId: Debug + Encode + PartialEq,
|
||||
Currency: CurrencyT<AccountId>,
|
||||
Currency::Balance: From<u64>,
|
||||
{
|
||||
|
||||
@@ -136,7 +136,8 @@ fn justification_with_invalid_commit_rejected() {
|
||||
#[test]
|
||||
fn justification_with_invalid_authority_signature_rejected() {
|
||||
let mut justification = make_default_justification::<TestHeader>(&test_header(1));
|
||||
justification.commit.precommits[0].signature = Default::default();
|
||||
justification.commit.precommits[0].signature =
|
||||
sp_core::crypto::UncheckedFrom::unchecked_from([1u8; 64]);
|
||||
|
||||
assert_eq!(
|
||||
verify_justification::<TestHeader>(
|
||||
|
||||
@@ -21,6 +21,7 @@ use bp_runtime::Chain;
|
||||
use frame_support::{
|
||||
dispatch::Dispatchable,
|
||||
parameter_types,
|
||||
unsigned::TransactionValidityError,
|
||||
weights::{
|
||||
constants::{BlockExecutionWeight, WEIGHT_PER_SECOND},
|
||||
DispatchClass, Weight,
|
||||
@@ -33,7 +34,7 @@ use scale_info::{StaticTypeInfo, TypeInfo};
|
||||
use sp_core::Hasher as HasherT;
|
||||
use sp_runtime::{
|
||||
generic,
|
||||
traits::{BlakeTwo256, IdentifyAccount, Verify},
|
||||
traits::{BlakeTwo256, DispatchInfoOf, IdentifyAccount, Verify},
|
||||
MultiAddress, MultiSignature, OpaqueExtrinsic,
|
||||
};
|
||||
use sp_std::prelude::Vec;
|
||||
@@ -343,11 +344,19 @@ where
|
||||
type AdditionalSigned = AdditionalSigned;
|
||||
type Pre = ();
|
||||
|
||||
fn additional_signed(
|
||||
&self,
|
||||
) -> Result<Self::AdditionalSigned, frame_support::unsigned::TransactionValidityError> {
|
||||
fn additional_signed(&self) -> Result<Self::AdditionalSigned, TransactionValidityError> {
|
||||
Ok(self.additional_signed)
|
||||
}
|
||||
|
||||
fn pre_dispatch(
|
||||
self,
|
||||
who: &Self::AccountId,
|
||||
call: &Self::Call,
|
||||
info: &DispatchInfoOf<Self::Call>,
|
||||
len: usize,
|
||||
) -> Result<Self::Pre, TransactionValidityError> {
|
||||
Ok(self.validate(who, call, info, len).map(|_| ())?)
|
||||
}
|
||||
}
|
||||
|
||||
/// Polkadot-like chain.
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
use codec::Encode;
|
||||
use ed25519_dalek::{Keypair, PublicKey, SecretKey, Signature};
|
||||
use finality_grandpa::voter_set::VoterSet;
|
||||
use sp_application_crypto::Public;
|
||||
use sp_finality_grandpa::{AuthorityId, AuthorityList, AuthorityWeight};
|
||||
use sp_runtime::RuntimeDebug;
|
||||
use sp_std::prelude::*;
|
||||
@@ -70,7 +69,7 @@ impl Account {
|
||||
|
||||
impl From<Account> for AuthorityId {
|
||||
fn from(p: Account) -> Self {
|
||||
AuthorityId::from_slice(&p.public().to_bytes())
|
||||
sp_application_crypto::UncheckedFrom::unchecked_from(p.public().to_bytes())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ use polkadot_primitives::v1::{
|
||||
AssignmentId, AssignmentPair, CandidateHash, CoreIndex, GroupIndex, SessionInfo, ValidatorIndex,
|
||||
};
|
||||
use sc_keystore::LocalKeystore;
|
||||
use sp_application_crypto::Public;
|
||||
use sp_application_crypto::ByteArray;
|
||||
|
||||
use merlin::Transcript;
|
||||
use schnorrkel::vrf::VRFInOut;
|
||||
|
||||
@@ -28,6 +28,10 @@ use std::time::Duration;
|
||||
|
||||
type VirtualOverseer = test_helpers::TestSubsystemContextHandle<ApprovalDistributionMessage>;
|
||||
|
||||
fn dummy_signature() -> polkadot_primitives::v1::ValidatorSignature {
|
||||
sp_core::crypto::UncheckedFrom::unchecked_from([1u8; 64])
|
||||
}
|
||||
|
||||
fn test_harness<T: Future<Output = VirtualOverseer>>(
|
||||
mut state: State,
|
||||
test_fn: impl FnOnce(VirtualOverseer) -> T,
|
||||
@@ -470,7 +474,7 @@ fn import_approval_happy_path() {
|
||||
block_hash: hash,
|
||||
candidate_index,
|
||||
validator: validator_index,
|
||||
signature: Default::default(),
|
||||
signature: dummy_signature(),
|
||||
};
|
||||
let msg = protocol_v1::ApprovalDistributionMessage::Approvals(vec![approval.clone()]);
|
||||
send_message_from_peer(overseer, &peer_b, msg).await;
|
||||
@@ -537,7 +541,7 @@ fn import_approval_bad() {
|
||||
block_hash: hash,
|
||||
candidate_index,
|
||||
validator: validator_index,
|
||||
signature: Default::default(),
|
||||
signature: dummy_signature(),
|
||||
};
|
||||
let msg = protocol_v1::ApprovalDistributionMessage::Approvals(vec![approval.clone()]);
|
||||
send_message_from_peer(overseer, &peer_b, msg).await;
|
||||
@@ -867,7 +871,7 @@ fn import_remotely_then_locally() {
|
||||
block_hash: hash,
|
||||
candidate_index,
|
||||
validator: validator_index,
|
||||
signature: Default::default(),
|
||||
signature: dummy_signature(),
|
||||
};
|
||||
let msg = protocol_v1::ApprovalDistributionMessage::Approvals(vec![approval.clone()]);
|
||||
send_message_from_peer(overseer, peer, msg).await;
|
||||
@@ -922,7 +926,7 @@ fn sends_assignments_even_when_state_is_approved() {
|
||||
block_hash: hash,
|
||||
candidate_index,
|
||||
validator: validator_index,
|
||||
signature: Default::default(),
|
||||
signature: dummy_signature(),
|
||||
};
|
||||
|
||||
overseer_send(
|
||||
|
||||
@@ -869,7 +869,7 @@ fn relays_collation_protocol_messages() {
|
||||
let collator_protocol_message = protocol_v1::CollatorProtocolMessage::Declare(
|
||||
Sr25519Keyring::Alice.public().into(),
|
||||
Default::default(),
|
||||
Default::default(),
|
||||
sp_core::crypto::UncheckedFrom::unchecked_from([1u8; 64]),
|
||||
);
|
||||
|
||||
let message =
|
||||
|
||||
@@ -36,7 +36,7 @@ use rand::{seq::SliceRandom as _, SeedableRng};
|
||||
use rand_chacha::ChaCha20Rng;
|
||||
|
||||
use sc_network::Multiaddr;
|
||||
use sp_application_crypto::{AppKey, Public};
|
||||
use sp_application_crypto::{AppKey, ByteArray};
|
||||
use sp_keystore::{CryptoStore, SyncCryptoStorePtr};
|
||||
|
||||
use polkadot_node_network_protocol::{
|
||||
|
||||
@@ -895,12 +895,12 @@ fn test_dispute_distribution_msg() -> DisputeDistributionMessage {
|
||||
session_index: 0,
|
||||
invalid_vote: InvalidDisputeVote {
|
||||
validator_index: ValidatorIndex(0),
|
||||
signature: Default::default(),
|
||||
signature: sp_core::crypto::UncheckedFrom::unchecked_from([1u8; 64]),
|
||||
kind: InvalidDisputeStatementKind::Explicit,
|
||||
},
|
||||
valid_vote: ValidDisputeVote {
|
||||
validator_index: ValidatorIndex(0),
|
||||
signature: Default::default(),
|
||||
signature: sp_core::crypto::UncheckedFrom::unchecked_from([2u8; 64]),
|
||||
kind: ValidDisputeStatementKind::Explicit,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -24,7 +24,7 @@ use polkadot_primitives::v1::{
|
||||
BlockNumber, CandidateHash, CandidateIndex, CoreIndex, Hash, Header, ValidatorIndex,
|
||||
ValidatorSignature,
|
||||
};
|
||||
use sp_application_crypto::Public;
|
||||
use sp_application_crypto::ByteArray;
|
||||
use sp_consensus_babe as babe_primitives;
|
||||
|
||||
/// Validators assigning to check a particular candidate are split up into tranches.
|
||||
|
||||
@@ -541,7 +541,7 @@ fn westend_staging_testnet_config_genesis(wasm_binary: &[u8]) -> westend::Genesi
|
||||
im_online: Default::default(),
|
||||
authority_discovery: westend::AuthorityDiscoveryConfig { keys: vec![] },
|
||||
vesting: westend::VestingConfig { vesting: vec![] },
|
||||
sudo: westend::SudoConfig { key: endowed_accounts[0].clone() },
|
||||
sudo: westend::SudoConfig { key: Some(endowed_accounts[0].clone()) },
|
||||
hrmp: Default::default(),
|
||||
configuration: westend::ConfigurationConfig {
|
||||
config: default_parachains_host_configuration(),
|
||||
@@ -1034,7 +1034,7 @@ fn rococo_staging_testnet_config_genesis(wasm_binary: &[u8]) -> rococo_runtime::
|
||||
collective: Default::default(),
|
||||
membership: Default::default(),
|
||||
authority_discovery: rococo_runtime::AuthorityDiscoveryConfig { keys: vec![] },
|
||||
sudo: rococo_runtime::SudoConfig { key: endowed_accounts[0].clone() },
|
||||
sudo: rococo_runtime::SudoConfig { key: Some(endowed_accounts[0].clone()) },
|
||||
paras: rococo_runtime::ParasConfig { paras: vec![] },
|
||||
hrmp: Default::default(),
|
||||
configuration: rococo_runtime::ConfigurationConfig {
|
||||
@@ -1470,7 +1470,7 @@ pub fn westend_testnet_genesis(
|
||||
im_online: Default::default(),
|
||||
authority_discovery: westend::AuthorityDiscoveryConfig { keys: vec![] },
|
||||
vesting: westend::VestingConfig { vesting: vec![] },
|
||||
sudo: westend::SudoConfig { key: root_key },
|
||||
sudo: westend::SudoConfig { key: Some(root_key) },
|
||||
hrmp: Default::default(),
|
||||
configuration: westend::ConfigurationConfig {
|
||||
config: default_parachains_host_configuration(),
|
||||
@@ -1541,7 +1541,7 @@ pub fn rococo_testnet_genesis(
|
||||
collective: Default::default(),
|
||||
membership: Default::default(),
|
||||
authority_discovery: rococo_runtime::AuthorityDiscoveryConfig { keys: vec![] },
|
||||
sudo: rococo_runtime::SudoConfig { key: root_key.clone() },
|
||||
sudo: rococo_runtime::SudoConfig { key: Some(root_key.clone()) },
|
||||
hrmp: Default::default(),
|
||||
configuration: rococo_runtime::ConfigurationConfig {
|
||||
config: polkadot_runtime_parachains::configuration::HostConfiguration {
|
||||
|
||||
@@ -56,7 +56,7 @@ use polkadot_primitives::v1::{
|
||||
ValidationCodeHash, ValidatorId, ValidatorIndex, ValidatorSignature,
|
||||
};
|
||||
use sp_application_crypto::AppKey;
|
||||
use sp_core::{traits::SpawnNamed, Public};
|
||||
use sp_core::{traits::SpawnNamed, ByteArray};
|
||||
use sp_keystore::{CryptoStore, Error as KeystoreError, SyncCryptoStorePtr};
|
||||
use std::{
|
||||
collections::{hash_map::Entry, HashMap},
|
||||
|
||||
@@ -22,7 +22,7 @@ use lru::LruCache;
|
||||
|
||||
use parity_scale_codec::Encode;
|
||||
use sp_application_crypto::AppKey;
|
||||
use sp_core::crypto::Public;
|
||||
use sp_core::crypto::ByteArray;
|
||||
use sp_keystore::{CryptoStore, SyncCryptoStorePtr};
|
||||
|
||||
use polkadot_node_subsystem::{SubsystemContext, SubsystemSender};
|
||||
|
||||
@@ -158,7 +158,7 @@ fn polkadot_testnet_genesis(
|
||||
authority_discovery: runtime::AuthorityDiscoveryConfig { keys: vec![] },
|
||||
claims: runtime::ClaimsConfig { claims: vec![], vesting: vec![] },
|
||||
vesting: runtime::VestingConfig { vesting: vec![] },
|
||||
sudo: runtime::SudoConfig { key: root_key },
|
||||
sudo: runtime::SudoConfig { key: Some(root_key) },
|
||||
configuration: runtime::ConfigurationConfig {
|
||||
config: polkadot_runtime_parachains::configuration::HostConfiguration {
|
||||
validation_upgrade_frequency: 10u32,
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use polkadot_test_service::*;
|
||||
use sp_keyring::Sr25519Keyring::{Alice, Bob};
|
||||
use sp_keyring::Sr25519Keyring::{Alice, Bob, Charlie};
|
||||
|
||||
#[substrate_test_utils::test]
|
||||
async fn call_function_actually_work() {
|
||||
@@ -23,7 +23,7 @@ async fn call_function_actually_work() {
|
||||
run_validator_node(tokio::runtime::Handle::current(), Alice, || {}, Vec::new(), None);
|
||||
|
||||
let function = polkadot_test_runtime::Call::Balances(pallet_balances::Call::transfer {
|
||||
dest: Default::default(),
|
||||
dest: Charlie.to_account_id().into(),
|
||||
value: 1,
|
||||
});
|
||||
let output = alice.send_extrinsic(function, Bob).await.unwrap();
|
||||
|
||||
@@ -29,7 +29,6 @@ frame-system = { git = "https://github.com/paritytech/substrate", branch = "mast
|
||||
hex-literal = "0.3.4"
|
||||
parity-util-mem = { version = "0.10.0", default-features = false, optional = true }
|
||||
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = [
|
||||
|
||||
@@ -312,7 +312,7 @@ fn check_collator_signature<H: AsRef<[u8]>>(
|
||||
|
||||
/// All data pertaining to the execution of a parachain candidate.
|
||||
#[derive(PartialEq, Eq, Clone, Encode, Decode, TypeInfo)]
|
||||
#[cfg_attr(feature = "std", derive(Debug, Default))]
|
||||
#[cfg_attr(feature = "std", derive(Debug))]
|
||||
pub struct CandidateReceipt<H = Hash, N = BlockNumber> {
|
||||
/// The ID of the parachain this is a candidate for.
|
||||
pub parachain_index: Id,
|
||||
@@ -411,7 +411,7 @@ pub struct OmittedValidationData<N = BlockNumber> {
|
||||
/// When submitting to the relay-chain, this data should be omitted as it can
|
||||
/// be re-generated from relay-chain state.
|
||||
#[derive(PartialEq, Eq, Clone, Encode, Decode, TypeInfo)]
|
||||
#[cfg_attr(feature = "std", derive(Debug, Default))]
|
||||
#[cfg_attr(feature = "std", derive(Debug))]
|
||||
pub struct AbridgedCandidateReceipt<H = Hash> {
|
||||
/// The ID of the parachain this is a candidate for.
|
||||
pub parachain_index: Id,
|
||||
@@ -546,7 +546,7 @@ impl Ord for AbridgedCandidateReceipt {
|
||||
|
||||
/// A unique descriptor of the candidate receipt, in a lightweight format.
|
||||
#[derive(PartialEq, Eq, Clone, Encode, Decode, TypeInfo)]
|
||||
#[cfg_attr(feature = "std", derive(Debug, Default))]
|
||||
#[cfg_attr(feature = "std", derive(Debug))]
|
||||
pub struct CandidateDescriptor<H = Hash> {
|
||||
/// The ID of the para this is a candidate for.
|
||||
pub para_id: Id,
|
||||
@@ -566,7 +566,7 @@ pub struct CandidateDescriptor<H = Hash> {
|
||||
|
||||
/// A collation sent by a collator.
|
||||
#[derive(PartialEq, Eq, Clone, Encode, Decode, TypeInfo)]
|
||||
#[cfg_attr(feature = "std", derive(Debug, Default))]
|
||||
#[cfg_attr(feature = "std", derive(Debug))]
|
||||
pub struct CollationInfo {
|
||||
/// The ID of the parachain this is a candidate for.
|
||||
pub parachain_index: Id,
|
||||
|
||||
@@ -635,16 +635,10 @@ impl<T: Config> Pallet<T> {
|
||||
|
||||
winning_ranges
|
||||
.into_iter()
|
||||
.map(|range| {
|
||||
let mut final_winner = Default::default();
|
||||
swap(
|
||||
&mut final_winner,
|
||||
winning[range as u8 as usize]
|
||||
.as_mut()
|
||||
.expect("none values are filtered out in previous logic; qed"),
|
||||
);
|
||||
let (bidder, para, amount) = final_winner;
|
||||
(bidder, para, amount, range)
|
||||
.filter_map(|range| {
|
||||
winning[range as u8 as usize]
|
||||
.take()
|
||||
.map(|(bidder, para, amount)| (bidder, para, amount, range))
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
}
|
||||
|
||||
@@ -633,6 +633,16 @@ where
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn pre_dispatch(
|
||||
self,
|
||||
who: &Self::AccountId,
|
||||
call: &Self::Call,
|
||||
info: &DispatchInfoOf<Self::Call>,
|
||||
len: usize,
|
||||
) -> Result<Self::Pre, TransactionValidityError> {
|
||||
Ok(self.validate(who, call, info, len).map(|_| ())?)
|
||||
}
|
||||
|
||||
// <weight>
|
||||
// The weight of this logic is included in the `attest` dispatchable.
|
||||
// </weight>
|
||||
|
||||
@@ -858,7 +858,7 @@ mod tests {
|
||||
use sp_keystore::{testing::KeyStore, KeystoreExt};
|
||||
use sp_runtime::{
|
||||
testing::Header,
|
||||
traits::{BlakeTwo256, IdentityLookup},
|
||||
traits::{BlakeTwo256, IdentityLookup, TrailingZeroInput},
|
||||
DispatchResult,
|
||||
};
|
||||
|
||||
@@ -1323,7 +1323,8 @@ mod tests {
|
||||
let payload = (0u32, 1u64, 0u64, 49u64);
|
||||
let valid_signature =
|
||||
crypto::create_ed25519_signature(&payload.encode(), pubkey.clone());
|
||||
let invalid_signature = MultiSignature::default();
|
||||
let invalid_signature =
|
||||
MultiSignature::decode(&mut TrailingZeroInput::zeroes()).unwrap();
|
||||
|
||||
// Invalid signature
|
||||
assert_noop!(
|
||||
@@ -1882,6 +1883,7 @@ mod benchmarking {
|
||||
use super::{Pallet as Crowdloan, *};
|
||||
use frame_support::{assert_ok, traits::OnInitialize};
|
||||
use frame_system::RawOrigin;
|
||||
use sp_core::crypto::UncheckedFrom;
|
||||
use sp_runtime::traits::{Bounded, CheckedSub};
|
||||
use sp_std::prelude::*;
|
||||
|
||||
@@ -1960,7 +1962,7 @@ mod benchmarking {
|
||||
let head_data = T::Registrar::worst_head_data();
|
||||
let validation_code = T::Registrar::worst_validation_code();
|
||||
|
||||
let verifier = account("verifier", 0, 0);
|
||||
let verifier = MultiSigner::unchecked_from(account::<[u8; 32]>("verifier", 0, 0));
|
||||
|
||||
CurrencyOf::<T>::make_free_balance_be(&caller, BalanceOf::<T>::max_value());
|
||||
T::Registrar::register(caller.clone(), para_id, head_data, validation_code)?;
|
||||
@@ -2048,7 +2050,7 @@ mod benchmarking {
|
||||
let head_data = T::Registrar::worst_head_data();
|
||||
let validation_code = T::Registrar::worst_validation_code();
|
||||
|
||||
let verifier: MultiSigner = account("verifier", 0, 0);
|
||||
let verifier = MultiSigner::unchecked_from(account::<[u8; 32]>("verifier", 0, 0));
|
||||
|
||||
CurrencyOf::<T>::make_free_balance_be(&caller, BalanceOf::<T>::max_value());
|
||||
T::Registrar::register(caller.clone(), para_id, head_data, validation_code)?;
|
||||
|
||||
@@ -29,10 +29,9 @@ where
|
||||
<R as frame_system::Config>::Event: From<pallet_balances::Event<R>>,
|
||||
{
|
||||
fn on_nonzero_unbalanced(amount: NegativeImbalance<R>) {
|
||||
<pallet_balances::Pallet<R>>::resolve_creating(
|
||||
&<pallet_authorship::Pallet<R>>::author(),
|
||||
amount,
|
||||
);
|
||||
if let Some(author) = <pallet_authorship::Pallet<R>>::author() {
|
||||
<pallet_balances::Pallet<R>>::resolve_creating(&author, amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -174,7 +174,7 @@ pub mod pallet {
|
||||
|
||||
// The account that will be used to payout participants of the DOT purchase process.
|
||||
#[pallet::storage]
|
||||
pub(super) type PaymentAccount<T: Config> = StorageValue<_, T::AccountId, ValueQuery>;
|
||||
pub(super) type PaymentAccount<T: Config> = StorageValue<_, T::AccountId, OptionQuery>;
|
||||
|
||||
// The statement purchasers will need to sign to participate.
|
||||
#[pallet::storage]
|
||||
@@ -290,12 +290,14 @@ pub mod pallet {
|
||||
///
|
||||
/// We reverify all assumptions about the state of an account, and complete the process.
|
||||
///
|
||||
/// Origin must match the configured `PaymentAccount`.
|
||||
/// Origin must match the configured `PaymentAccount` (if it is not configured then this
|
||||
/// will always fail with `BadOrigin`).
|
||||
#[pallet::weight(T::DbWeight::get().reads_writes(4, 2))]
|
||||
pub fn payout(origin: OriginFor<T>, who: T::AccountId) -> DispatchResult {
|
||||
// Payments must be made directly by the `PaymentAccount`.
|
||||
let payment_account = ensure_signed(origin)?;
|
||||
ensure!(payment_account == PaymentAccount::<T>::get(), DispatchError::BadOrigin);
|
||||
let test_against = PaymentAccount::<T>::get().ok_or(DispatchError::BadOrigin)?;
|
||||
ensure!(payment_account == test_against, DispatchError::BadOrigin);
|
||||
|
||||
// Account should not have a vesting schedule.
|
||||
ensure!(
|
||||
@@ -363,7 +365,7 @@ pub mod pallet {
|
||||
pub fn set_payment_account(origin: OriginFor<T>, who: T::AccountId) -> DispatchResult {
|
||||
T::ConfigurationOrigin::ensure_origin(origin)?;
|
||||
// Possibly this is worse than having the caller account be the payment account?
|
||||
PaymentAccount::<T>::set(who.clone());
|
||||
PaymentAccount::<T>::put(who.clone());
|
||||
Self::deposit_event(Event::<T>::PaymentAccountSet(who));
|
||||
Ok(())
|
||||
}
|
||||
@@ -712,7 +714,7 @@ mod tests {
|
||||
Origin::signed(configuration_origin()),
|
||||
payment_account.clone()
|
||||
));
|
||||
assert_eq!(PaymentAccount::<Test>::get(), payment_account);
|
||||
assert_eq!(PaymentAccount::<Test>::get(), Some(payment_account));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1111,7 +1111,7 @@ mod benchmarking {
|
||||
trigger_onboard {
|
||||
// get a parachain into a bad state where they did not onboard
|
||||
let (para, _) = register_a_parathread::<T>(1);
|
||||
Leases::<T>::insert(para, vec![Some((T::AccountId::default(), BalanceOf::<T>::default()))]);
|
||||
Leases::<T>::insert(para, vec![Some((account::<T::AccountId>("lease_insert", 0, 0), BalanceOf::<T>::default()))]);
|
||||
assert!(T::Registrar::is_parathread(para));
|
||||
let caller = whitelisted_caller();
|
||||
}: _(RawOrigin::Signed(caller), para)
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
use crate::*;
|
||||
use frame_support::weights::{GetDispatchInfo, WeightToFeePolynomial};
|
||||
use keyring::Sr25519Keyring::Charlie;
|
||||
use pallet_transaction_payment::Multiplier;
|
||||
use parity_scale_codec::Encode;
|
||||
use separator::Separatable;
|
||||
@@ -80,7 +81,7 @@ fn block_cost() {
|
||||
fn transfer_cost_min_multiplier() {
|
||||
let min_multiplier = runtime_common::MinimumMultiplier::get();
|
||||
let call = pallet_balances::Call::<Runtime>::transfer_keep_alive {
|
||||
dest: Default::default(),
|
||||
dest: Charlie.to_account_id().into(),
|
||||
value: Default::default(),
|
||||
};
|
||||
let info = call.get_dispatch_info();
|
||||
|
||||
@@ -32,7 +32,7 @@ use primitives::v1::{
|
||||
use sp_core::{sr25519, H256};
|
||||
use sp_runtime::{
|
||||
generic::Digest,
|
||||
traits::{Header as HeaderT, One, Zero},
|
||||
traits::{Header as HeaderT, One, TrailingZeroInput, Zero},
|
||||
RuntimeAppPublic,
|
||||
};
|
||||
use sp_std::{collections::btree_map::BTreeMap, convert::TryInto, prelude::Vec, vec};
|
||||
@@ -45,9 +45,10 @@ fn mock_validation_code() -> ValidationCode {
|
||||
///
|
||||
/// This is directly from frame-benchmarking. Copy/pasted so we can use it when not compiling with
|
||||
/// "features = runtime-benchmarks".
|
||||
fn account<AccountId: Decode + Default>(name: &'static str, index: u32, seed: u32) -> AccountId {
|
||||
fn account<AccountId: Decode>(name: &'static str, index: u32, seed: u32) -> AccountId {
|
||||
let entropy = (name, index, seed).using_encoded(sp_io::hashing::blake2_256);
|
||||
AccountId::decode(&mut &entropy[..]).expect("256 bit input is valid. qed.")
|
||||
AccountId::decode(&mut TrailingZeroInput::new(&entropy[..]))
|
||||
.expect("infinite input; no invalid input; qed")
|
||||
}
|
||||
|
||||
/// Create a 32 byte slice based on the given number.
|
||||
|
||||
@@ -704,6 +704,7 @@ mod sanitizers {
|
||||
AvailabilityBitfield, GroupIndex, Hash, Id as ParaId, SignedAvailabilityBitfield,
|
||||
ValidatorIndex,
|
||||
};
|
||||
use sp_core::crypto::UncheckedFrom;
|
||||
|
||||
use crate::mock::Test;
|
||||
use futures::executor::block_on;
|
||||
@@ -921,14 +922,13 @@ mod sanitizers {
|
||||
|
||||
// check the validators signature
|
||||
{
|
||||
use primitives::v1::ValidatorSignature;
|
||||
let mut unchecked_bitfields = unchecked_bitfields.clone();
|
||||
|
||||
// insert a bad signature for the last bitfield
|
||||
let last_bit_idx = unchecked_bitfields.len() - 1;
|
||||
unchecked_bitfields
|
||||
.get_mut(last_bit_idx)
|
||||
.and_then(|u| Some(u.set_signature(ValidatorSignature::default())))
|
||||
.and_then(|u| Some(u.set_signature(UncheckedFrom::unchecked_from([1u8; 64]))))
|
||||
.expect("we are accessing a valid index");
|
||||
assert_eq!(
|
||||
&sanitize_bitfields::<Test>(
|
||||
|
||||
@@ -2086,8 +2086,8 @@ sp_api::impl_runtime_apis! {
|
||||
mod test_fees {
|
||||
use super::*;
|
||||
use frame_support::weights::{GetDispatchInfo, WeightToFeePolynomial};
|
||||
use keyring::Sr25519Keyring::Charlie;
|
||||
use pallet_transaction_payment::Multiplier;
|
||||
use parity_scale_codec::Encode;
|
||||
use separator::Separatable;
|
||||
use sp_runtime::{assert_eq_error_rate, FixedPointNumber};
|
||||
|
||||
@@ -2127,7 +2127,7 @@ mod test_fees {
|
||||
fn transfer_cost_min_multiplier() {
|
||||
let min_multiplier = runtime_common::MinimumMultiplier::get();
|
||||
let call = pallet_balances::Call::<Runtime>::transfer_keep_alive {
|
||||
dest: Default::default(),
|
||||
dest: Charlie.to_account_id().into(),
|
||||
value: Default::default(),
|
||||
};
|
||||
let info = call.get_dispatch_info();
|
||||
|
||||
@@ -376,7 +376,8 @@ mod tests {
|
||||
use super::*;
|
||||
use bp_messages::{target_chain::ProvedLaneMessages, MessageData, MessageKey};
|
||||
use bridge_runtime_common::messages;
|
||||
use parity_scale_codec::Encode;
|
||||
use parity_scale_codec::{Decode, Encode};
|
||||
use sp_runtime::traits::TrailingZeroInput;
|
||||
|
||||
#[test]
|
||||
fn ensure_rococo_messages_weights_are_correct() {
|
||||
@@ -452,9 +453,10 @@ mod tests {
|
||||
primitives::v1::Balance::MAX,
|
||||
),
|
||||
);
|
||||
let extra_bytes_in_transaction = crate::Address::default().encoded_size() +
|
||||
crate::Signature::default().encoded_size() +
|
||||
signed_extra.encoded_size();
|
||||
let mut zeroes = TrailingZeroInput::zeroes();
|
||||
let extra_bytes_in_transaction = signed_extra.encoded_size() +
|
||||
crate::Address::decode(&mut zeroes).unwrap().encoded_size() +
|
||||
crate::Signature::decode(&mut zeroes).unwrap().encoded_size();
|
||||
assert!(
|
||||
TX_EXTRA_BYTES as usize >= extra_bytes_in_transaction,
|
||||
"Hardcoded number of extra bytes in Rococo transaction {} is lower than actual value: {}",
|
||||
|
||||
Reference in New Issue
Block a user