mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-18 00:11:01 +00:00
Remove As (#2602)
* Start to remove the `As` bound on `SimpleArtithmetic` This just introduces standard numeric bounds, assuming a minimum of `u32`. Also included is a saturating from/into trait allowing ergonomic infallible conversion when you don't care if it saturates. * Remove As from Balances trait * Remove As from Aura module * Remove As from Babe module * Expunge `As` from contract * Council module * Democracy * Finality tracker * Grandpa * First bit of indices * indices * Line lengths * session * system * Staking * Square up all other uses of As. * RHD update * Fix build/test * Remove As trait * line widths * Remove final As ref * Update srml/staking/src/lib.rs Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com> * Update core/client/src/cht.rs Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com> * Update core/client/db/src/light.rs Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com> * Apply suggestions from code review Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com> * whitespace * Apply suggestions from code review Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com> Co-Authored-By: André Silva <andre.beat@gmail.com> * Bring back u32 check for number on CLI
This commit is contained in:
@@ -13,6 +13,7 @@ primitives = { package = "substrate-primitives", path= "../../primitives" }
|
||||
inherents = { package = "substrate-inherents", path = "../../inherents" }
|
||||
error-chain = "0.12"
|
||||
futures = "0.1"
|
||||
rstd = { package = "sr-std", path = "../../sr-std" }
|
||||
runtime_version = { package = "sr-version", path = "../../sr-version" }
|
||||
runtime_primitives = { package = "sr-primitives", path = "../../sr-primitives" }
|
||||
tokio-timer = "0.2"
|
||||
|
||||
@@ -19,11 +19,13 @@
|
||||
use super::MAX_BLOCK_SIZE;
|
||||
|
||||
use parity_codec::Encode;
|
||||
use runtime_primitives::traits::{Block as BlockT, Header as HeaderT, As};
|
||||
use runtime_primitives::traits::{Block as BlockT, Header as HeaderT, One, CheckedConversion};
|
||||
use error_chain::{error_chain, error_chain_processing, impl_error_chain_processed,
|
||||
impl_extract_backtrace, impl_error_chain_kind, bail};
|
||||
|
||||
type BlockNumber = u64;
|
||||
// This is just a best effort to encode the number. None indicated that it's too big to encode
|
||||
// in a u128.
|
||||
type BlockNumber = Option<u128>;
|
||||
|
||||
error_chain! {
|
||||
errors {
|
||||
@@ -37,7 +39,7 @@ error_chain! {
|
||||
}
|
||||
WrongNumber(expected: BlockNumber, got: BlockNumber) {
|
||||
description("Proposal had wrong number."),
|
||||
display("Proposal had wrong number. Expected {}, got {}", expected, got),
|
||||
display("Proposal had wrong number. Expected {:?}, got {:?}", expected, got),
|
||||
}
|
||||
ProposalTooLarge(size: usize) {
|
||||
description("Proposal exceeded the maximum size."),
|
||||
@@ -72,8 +74,11 @@ pub fn evaluate_initial<Block: BlockT>(
|
||||
));
|
||||
}
|
||||
|
||||
if parent_number.as_() + 1 != proposal.header().number().as_() {
|
||||
bail!(ErrorKind::WrongNumber(parent_number.as_() + 1, proposal.header().number().as_()));
|
||||
if parent_number + One::one() != *proposal.header().number() {
|
||||
bail!(ErrorKind::WrongNumber(
|
||||
parent_number.checked_into::<u128>().map(|x| x + 1),
|
||||
(*proposal.header().number()).checked_into::<u128>()
|
||||
));
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
@@ -45,7 +45,10 @@ use client::{Client as SubstrateClient, CallExecutor};
|
||||
use client::runtime_api::{Core, BlockBuilder as BlockBuilderAPI, OldTxQueue, BlockBuilderError};
|
||||
use runtime_primitives::generic::{BlockId, Era, ImportResult, ImportBlock, BlockOrigin};
|
||||
use runtime_primitives::traits::{Block, Header};
|
||||
use runtime_primitives::traits::{Block as BlockT, Hash as HashT, Header as HeaderT, As, BlockNumberToHash};
|
||||
use runtime_primitives::traits::{
|
||||
Block as BlockT, Hash as HashT, Header as HeaderT,
|
||||
BlockNumberToHash, SaturatedConversion
|
||||
};
|
||||
use runtime_primitives::Justification;
|
||||
use primitives::{AuthorityId, ed25519, Blake2Hasher, ed25519::LocalizedSignature};
|
||||
use srml_system::Trait as SystemT;
|
||||
@@ -1246,7 +1249,7 @@ impl<C, A> LocalProposer<<C as AuthoringApi>::Block> for Proposer<C, A> where
|
||||
for (target, misbehavior) in misbehavior {
|
||||
let report = MisbehaviorReport {
|
||||
parent_hash: self.parent_hash.into(),
|
||||
parent_number: self.parent_number.as_(),
|
||||
parent_number: self.parent_number.saturated_into::<u64>(),
|
||||
target,
|
||||
misbehavior: match misbehavior {
|
||||
GenericMisbehavior::ProposeOutOfTurn(_, _, _) => continue,
|
||||
|
||||
Reference in New Issue
Block a user