Skip to content

Commit

Permalink
upgrade to polkadot-v1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
0xbillw committed Nov 28, 2023
1 parent 5bb57ba commit 0794d83
Show file tree
Hide file tree
Showing 72 changed files with 4,176 additions and 3,394 deletions.
1,990 changes: 1,112 additions & 878 deletions Cargo.lock

Large diffs are not rendered by default.

320 changes: 161 additions & 159 deletions Cargo.toml

Large diffs are not rendered by default.

11 changes: 3 additions & 8 deletions crates/bloom-filter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,14 @@ version = "0.1.0"
edition = "2021"

[dependencies]
log = { workspace = true }
codec = { version = "3.2.2", package = "parity-scale-codec", default-features = false, features = ["derive"] }
codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false, features = ["derive", "max-encoded-len"] }
scale-info = { workspace = true, features = ["derive"] }
frame-support = {workspace = true}
sp-std = { workspace = true}
cp-cess-common = { workspace = true }
sp-core = { workspace = true }

[features]
default = ["std"]
std = [
"codec/std",
"scale-info/std",
"frame-support/std",
"sp-std/std",
"cp-cess-common/std",
"sp-core/std",
]
7 changes: 2 additions & 5 deletions crates/bloom-filter/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
#![cfg_attr(not(feature = "std"), no_std)]

use frame_support::{
RuntimeDebug,
dispatch::{Decode, Encode},
};
use codec::{MaxEncodedLen};
use codec::{Decode, Encode, MaxEncodedLen};
use scale_info::TypeInfo;
use sp_core::RuntimeDebug;

#[derive(Copy, Clone, Eq, PartialEq, Encode, Decode, RuntimeDebug, MaxEncodedLen, TypeInfo)]
pub struct BloomFilter(pub [u64; 256]);
Expand Down
2 changes: 1 addition & 1 deletion crates/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ edition = "2021"

[dependencies]
log = { workspace = true }
codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive", "max-encoded-len"] }
codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false, features = ["derive", "max-encoded-len"] }
scale-info = { workspace = true, features = ["derive"] }

frame-support = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion crates/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

use frame_support::{
BoundedVec,
RuntimeDebug,
pallet_prelude::ConstU32,
};
use codec::{MaxEncodedLen, Decode, Encode};
use scale_info::TypeInfo;
use sp_core::RuntimeDebug;
use sp_std::prelude::Box;

#[derive(Copy, Clone, Eq, PartialEq, Encode, Decode, RuntimeDebug, MaxEncodedLen, TypeInfo, PartialOrd, Ord)]
Expand Down
25 changes: 13 additions & 12 deletions crates/rrsc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
async-trait = { workspace = true }
scale-info = { workspace = true, features = ["derive"] }
codec = { package = "parity-scale-codec", version = "3.2.2", features = ["derive"] }
codec = { package = "parity-scale-codec", version = "3.6.1", features = ["derive"] }
futures = { workspace = true }
log = { workspace = true }
num-bigint = { workspace = true }
Expand All @@ -31,17 +31,18 @@ sc-consensus-epochs = { workspace = true }
sc-consensus-slots = { workspace = true }
sc-keystore = { workspace = true }
sc-telemetry = { workspace = true }
sp-api = { workspace = true }
sp-application-crypto = { workspace = true }
sp-block-builder = { workspace = true, features = ["std"]}
sp-blockchain = { workspace = true }
sp-consensus = { workspace = true }
sp-consensus-slots = { workspace = true }
sp-core = { workspace = true }
sp-inherents = { workspace = true }
sp-keystore = { workspace = true }
sp-runtime = { workspace = true }
cessp-consensus-rrsc = { workspace = true, features = ["std"]}
sc-transaction-pool-api = { workspace = true }
sp-api = { workspace = true, default-features = true }
sp-application-crypto = { workspace = true, default-features = true }
sp-block-builder = { workspace = true, default-features = true }
sp-blockchain = { workspace = true, default-features = true }
sp-consensus = { workspace = true, default-features = true }
sp-consensus-slots = { workspace = true, default-features = true }
sp-core = { workspace = true, default-features = true }
sp-inherents = { workspace = true, default-features = true }
sp-keystore = { workspace = true, default-features = true }
sp-runtime = { workspace = true, default-features = true }
cessp-consensus-rrsc = { workspace = true, default-features = true }

[dev-dependencies]
rand_chacha = { workspace = true }
Expand Down
26 changes: 13 additions & 13 deletions crates/rrsc/pallet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,33 @@ readme = "README.md"
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] }
codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false, features = ["derive"] }
log = { workspace = true }
scale-info = { workspace = true, features = ["derive"] }
scale-info = { workspace = true, features = ["derive", "serde"] }
frame-benchmarking = { workspace = true, optional = true }
frame-support = { workspace = true }
frame-system = { workspace = true }
pallet-authorship = { workspace = true }
pallet-session = { workspace = true }
pallet-timestamp = { workspace = true }
sp-application-crypto = { workspace = true }
sp-core = { workspace = true }
sp-application-crypto = { workspace = true, features = ["serde"] }
sp-core = { workspace = true, features = ["serde"] }
sp-io = { workspace = true }
sp-npos-elections = { workspace = true }
sp-runtime = { workspace = true }
sp-runtime = { workspace = true, features = ["serde"] }
sp-session = { workspace = true }
sp-staking = { workspace = true }
sp-staking = { workspace = true, features = ["serde"] }
sp-std = { workspace = true }
frame-election-provider-support = { workspace = true }
cessp-consensus-rrsc = { workspace = true }
cessp-consensus-rrsc = { workspace = true, features = ["serde"] }

[dev-dependencies]
frame-election-provider-support = { workspace = true }
pallet-balances = { workspace = true }
pallet-offences = { workspace = true }
pallet-staking = { workspace = true }
pallet-staking-reward-curve = { workspace = true }
sp-core = { workspace = true }
frame-election-provider-support = { workspace = true, default-features = true }
pallet-balances = { workspace = true, default-features = true }
pallet-offences = { workspace = true, default-features = true }
pallet-staking = { workspace = true, default-features = true }
pallet-staking-reward-curve = { workspace = true, default-features = true }
sp-core = { workspace = true, default-features = true }

[features]
default = ["std"]
Expand Down
2 changes: 1 addition & 1 deletion crates/rrsc/pallet/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#![cfg(feature = "runtime-benchmarks")]

use super::*;
use frame_benchmarking::benchmarks;
use frame_benchmarking::v1::benchmarks;

type Header = sp_runtime::generic::Header<u64, sp_runtime::traits::BlakeTwo256>;

Expand Down
12 changes: 4 additions & 8 deletions crates/rrsc/pallet/src/default_weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,11 @@ impl crate::WeightInfo for () {
DbWeight::get().writes(1)
}

fn report_equivocation(validator_count: u32) -> Weight {
fn report_equivocation(validator_count: u32, max_nominators_per_validator: u32) -> Weight {
// we take the validator set count from the membership proof to
// calculate the weight but we set a floor of 100 validators.
let validator_count = validator_count.max(100) as u64;

// worst case we are considering is that the given offender
// is backed by 200 nominators
const MAX_NOMINATORS: u64 = 200;

// checking membership proof
Weight::from_parts(35u64 * WEIGHT_REF_TIME_PER_MICROS, 0)
.saturating_add(
Expand All @@ -49,10 +45,10 @@ impl crate::WeightInfo for () {
// report offence
.saturating_add(Weight::from_parts(110u64 * WEIGHT_REF_TIME_PER_MICROS, 0))
.saturating_add(Weight::from_parts(
25u64 * WEIGHT_REF_TIME_PER_MICROS * MAX_NOMINATORS,
25u64 * WEIGHT_REF_TIME_PER_MICROS * max_nominators_per_validator as u64,
0,
))
.saturating_add(DbWeight::get().reads(14 + 3 * MAX_NOMINATORS))
.saturating_add(DbWeight::get().writes(10 + 3 * MAX_NOMINATORS))
.saturating_add(DbWeight::get().reads(14 + 3 * max_nominators_per_validator as u64))
.saturating_add(DbWeight::get().writes(10 + 3 * max_nominators_per_validator as u64))
}
}
11 changes: 6 additions & 5 deletions crates/rrsc/pallet/src/equivocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
//! definition.
use frame_support::traits::{Get, KeyOwnerProofSystem};
use frame_system::pallet_prelude::HeaderFor;
use log::{error, info};

use cessp_consensus_rrsc::{AuthorityId, EquivocationProof, Slot, KEY_TYPE};
Expand Down Expand Up @@ -99,14 +100,14 @@ impl<Offender: Clone> Offence<Offender> for EquivocationOffence<Offender> {
///
/// This type implements `OffenceReportSystem` such that:
/// - Equivocation reports are published on-chain as unsigned extrinsic via
/// `offchain::SendTransactioinsTypes`.
/// `offchain::SendTransactionTypes`.
/// - On-chain validity checks and processing are mostly delegated to the user provided generic
/// types implementing `KeyOwnerProofSystem` and `ReportOffence` traits.
/// - Offence reporter for unsigned transactions is fetched via the the authorship pallet.
pub struct EquivocationReportSystem<T, R, P, L>(sp_std::marker::PhantomData<(T, R, P, L)>);

impl<T, R, P, L>
OffenceReportSystem<Option<T::AccountId>, (EquivocationProof<T::Header>, T::KeyOwnerProof)>
OffenceReportSystem<Option<T::AccountId>, (EquivocationProof<HeaderFor<T>>, T::KeyOwnerProof)>
for EquivocationReportSystem<T, R, P, L>
where
T: Config + pallet_authorship::Config + frame_system::offchain::SendTransactionTypes<Call<T>>,
Expand All @@ -122,7 +123,7 @@ where
type Longevity = L;

fn publish_evidence(
evidence: (EquivocationProof<T::Header>, T::KeyOwnerProof),
evidence: (EquivocationProof<HeaderFor<T>>, T::KeyOwnerProof),
) -> Result<(), ()> {
use frame_system::offchain::SubmitTransaction;
let (equivocation_proof, key_owner_proof) = evidence;
Expand All @@ -140,7 +141,7 @@ where
}

fn check_evidence(
evidence: (EquivocationProof<T::Header>, T::KeyOwnerProof),
evidence: (EquivocationProof<HeaderFor<T>>, T::KeyOwnerProof),
) -> Result<(), TransactionValidityError> {
let (equivocation_proof, key_owner_proof) = evidence;

Expand All @@ -159,7 +160,7 @@ where

fn process_evidence(
reporter: Option<T::AccountId>,
evidence: (EquivocationProof<T::Header>, T::KeyOwnerProof),
evidence: (EquivocationProof<HeaderFor<T>>, T::KeyOwnerProof),
) -> Result<(), DispatchError> {
let (equivocation_proof, key_owner_proof) = evidence;
let reporter = reporter.or_else(|| <pallet_authorship::Pallet<T>>::author());
Expand Down
Loading

0 comments on commit 0794d83

Please sign in to comment.