Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixes
  • Loading branch information
gavofyork committed Dec 9, 2021
commit be2b10c69591e0991e5a64838ac547aa16758ec5
23 changes: 12 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bridges/modules/messages/src/instant_payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>,
{
Expand Down
3 changes: 1 addition & 2 deletions bridges/primitives/test-utils/src/keyring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down Expand Up @@ -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())
}
}

Expand Down
2 changes: 1 addition & 1 deletion node/core/approval-voting/src/criteria.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion node/network/gossip-support/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down
2 changes: 1 addition & 1 deletion node/primitives/src/approval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion node/subsystem-util/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
2 changes: 1 addition & 1 deletion node/subsystem-util/src/runtime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
20 changes: 16 additions & 4 deletions primitives/src/v0.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -335,6 +335,18 @@ pub struct CandidateReceipt<H = Hash, N = BlockNumber> {
pub commitments: CandidateCommitments<H>,
}

#[allow(dead_code)]
#[cfg(feature = "std")]
fn dummy_collator_id() -> CollatorId {
primitives::crypto::UncheckedFrom::unchecked_from([1u8; 32])
}

#[allow(dead_code)]
#[cfg(feature = "std")]
fn dummy_signature() -> CollatorSignature {
primitives::crypto::UncheckedFrom::unchecked_from([1u8; 64])
}

impl<H: AsRef<[u8]>, N> CandidateReceipt<H, N> {
/// Check integrity vs. provided block data.
pub fn check_signature(&self) -> Result<(), ()> {
Expand Down Expand Up @@ -411,7 +423,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,
Expand Down Expand Up @@ -546,7 +558,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,
Expand All @@ -566,7 +578,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,
Expand Down
14 changes: 4 additions & 10 deletions runtime/common/src/auctions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<_>>()
}
Expand Down
7 changes: 3 additions & 4 deletions runtime/common/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}

Expand Down
8 changes: 5 additions & 3 deletions runtime/common/src/purchase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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!(
Expand Down