mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 08:11:04 +00:00
Migrate to new substrate (#79)
* new substrate version + actually verify justification * cargo update + fix remaining stuff * add weight=0 comments * cargo fmt --all * fix hash types
This commit is contained in:
committed by
Bastian Köcher
parent
4bbef4d45a
commit
50d6ed186f
@@ -12,33 +12,33 @@ primitives = { package = "sp-bridge-eth-poa", path = "../../primitives/ethereum-
|
||||
|
||||
# Substrate Based Dependencies
|
||||
[dependencies.frame-support]
|
||||
version = "2.0.0-alpha.2"
|
||||
version = "2.0.0-alpha.6"
|
||||
default-features = false
|
||||
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31"
|
||||
rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
|
||||
git = "https://github.com/paritytech/substrate/"
|
||||
|
||||
[dependencies.frame-system]
|
||||
version = "2.0.0-alpha.2"
|
||||
version = "2.0.0-alpha.6"
|
||||
default-features = false
|
||||
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31"
|
||||
rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
|
||||
git = "https://github.com/paritytech/substrate/"
|
||||
|
||||
[dependencies.sp-std]
|
||||
version = "2.0.0-alpha.2"
|
||||
version = "2.0.0-alpha.6"
|
||||
default-features = false
|
||||
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31"
|
||||
rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
|
||||
git = "https://github.com/paritytech/substrate/"
|
||||
|
||||
[dependencies.sp-io]
|
||||
version = "2.0.0-alpha.2"
|
||||
version = "2.0.0-alpha.6"
|
||||
default-features = false
|
||||
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31"
|
||||
rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
|
||||
git = "https://github.com/paritytech/substrate/"
|
||||
|
||||
[dependencies.sp-runtime]
|
||||
version = "2.0.0-alpha.2"
|
||||
version = "2.0.0-alpha.6"
|
||||
default-features = false
|
||||
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31"
|
||||
rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
|
||||
git = "https://github.com/paritytech/substrate/"
|
||||
|
||||
# Dev Dependencies
|
||||
|
||||
@@ -21,8 +21,8 @@ use frame_support::{decl_module, decl_storage};
|
||||
use primitives::{Address, Header, Receipt, H256, U256};
|
||||
use sp_runtime::{
|
||||
transaction_validity::{
|
||||
InvalidTransaction, TransactionLongevity, TransactionPriority, TransactionValidity, UnknownTransaction,
|
||||
ValidTransaction,
|
||||
InvalidTransaction, TransactionLongevity, TransactionPriority, TransactionSource, TransactionValidity,
|
||||
UnknownTransaction, ValidTransaction,
|
||||
},
|
||||
RuntimeDebug,
|
||||
};
|
||||
@@ -293,6 +293,7 @@ pub trait Trait: frame_system::Trait {
|
||||
decl_module! {
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
||||
/// Import single Aura header. Requires transaction to be **UNSIGNED**.
|
||||
#[weight = 0] // TODO: update me (https://github.com/paritytech/parity-bridges-common/issues/78)
|
||||
pub fn import_unsigned_header(origin, header: Header, receipts: Option<Vec<Receipt>>) {
|
||||
frame_system::ensure_none(origin)?;
|
||||
|
||||
@@ -313,6 +314,7 @@ decl_module! {
|
||||
///
|
||||
/// This should be used with caution - passing too many headers could lead to
|
||||
/// enormous block production/import time.
|
||||
#[weight = 0] // TODO: update me (https://github.com/paritytech/parity-bridges-common/issues/78)
|
||||
pub fn import_signed_headers(origin, headers_with_receipts: Vec<(Header, Option<Vec<Receipt>>)>) {
|
||||
let submitter = frame_system::ensure_signed(origin)?;
|
||||
let mut finalized_headers = BTreeMap::new();
|
||||
@@ -359,19 +361,19 @@ decl_storage! {
|
||||
/// Oldest unpruned block(s) number.
|
||||
OldestUnprunedBlock: u64;
|
||||
/// Map of imported headers by hash.
|
||||
Headers: map hasher(blake2_256) H256 => Option<StoredHeader<T::AccountId>>;
|
||||
Headers: map hasher(identity) H256 => Option<StoredHeader<T::AccountId>>;
|
||||
/// Map of imported header hashes by number.
|
||||
HeadersByNumber: map hasher(blake2_256) u64 => Option<Vec<H256>>;
|
||||
HeadersByNumber: map hasher(blake2_128_concat) u64 => Option<Vec<H256>>;
|
||||
/// The ID of next validator set.
|
||||
NextValidatorsSetId: u64;
|
||||
/// Map of validators sets by their id.
|
||||
ValidatorsSets: map hasher(blake2_256) u64 => Option<ValidatorsSet>;
|
||||
ValidatorsSets: map hasher(twox_64_concat) u64 => Option<ValidatorsSet>;
|
||||
/// Validators sets reference count. Each header that is authored by this set increases
|
||||
/// the reference count. When we prune this header, we decrease the reference count.
|
||||
/// When it reaches zero, we are free to prune validator set as well.
|
||||
ValidatorsSetsRc: map hasher(blake2_256) u64 => Option<u64>;
|
||||
ValidatorsSetsRc: map hasher(twox_64_concat) u64 => Option<u64>;
|
||||
/// Map of validators set changes scheduled by given header.
|
||||
ScheduledChanges: map hasher(blake2_256) H256 => Option<ScheduledChange>;
|
||||
ScheduledChanges: map hasher(identity) H256 => Option<ScheduledChange>;
|
||||
}
|
||||
add_extra_genesis {
|
||||
config(initial_header): Header;
|
||||
@@ -434,7 +436,7 @@ impl<T: Trait> Module<T> {
|
||||
impl<T: Trait> frame_support::unsigned::ValidateUnsigned for Module<T> {
|
||||
type Call = Call<T>;
|
||||
|
||||
fn validate_unsigned(call: &Self::Call) -> TransactionValidity {
|
||||
fn validate_unsigned(_source: TransactionSource, call: &Self::Call) -> TransactionValidity {
|
||||
match *call {
|
||||
Self::Call::import_unsigned_header(ref header, ref receipts) => {
|
||||
let accept_result = verification::accept_aura_header_into_pool(
|
||||
|
||||
@@ -13,57 +13,57 @@ hash-db = { version = "0.15.2", default-features = false }
|
||||
|
||||
# Substrate Based Dependencies
|
||||
[dependencies.frame-support]
|
||||
version = "2.0.0-alpha.2"
|
||||
version = "2.0.0-alpha.6"
|
||||
default-features = false
|
||||
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31"
|
||||
rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
|
||||
git = "https://github.com/paritytech/substrate/"
|
||||
|
||||
[dependencies.frame-system]
|
||||
version = "2.0.0-alpha.2"
|
||||
version = "2.0.0-alpha.6"
|
||||
default-features = false
|
||||
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31"
|
||||
rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
|
||||
git = "https://github.com/paritytech/substrate/"
|
||||
|
||||
[dependencies.pallet-session]
|
||||
version = "2.0.0-alpha.2"
|
||||
version = "2.0.0-alpha.6"
|
||||
default-features = false
|
||||
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31"
|
||||
rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
|
||||
git = "https://github.com/paritytech/substrate/"
|
||||
|
||||
[dependencies.sp-core]
|
||||
version = "2.0.0-alpha.2"
|
||||
version = "2.0.0-alpha.6"
|
||||
default-features = false
|
||||
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31"
|
||||
rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
|
||||
git = "https://github.com/paritytech/substrate/"
|
||||
|
||||
[dependencies.sp-finality-grandpa]
|
||||
version = "2.0.0-alpha.2"
|
||||
version = "2.0.0-alpha.6"
|
||||
default-features = false
|
||||
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31"
|
||||
rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
|
||||
git = "https://github.com/paritytech/substrate/"
|
||||
|
||||
[dependencies.sp-runtime]
|
||||
version = "2.0.0-alpha.2"
|
||||
version = "2.0.0-alpha.6"
|
||||
default-features = false
|
||||
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31"
|
||||
rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
|
||||
git = "https://github.com/paritytech/substrate/"
|
||||
|
||||
[dependencies.sp-trie]
|
||||
version = "2.0.0-alpha.2"
|
||||
version = "2.0.0-alpha.6"
|
||||
default-features = false
|
||||
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31"
|
||||
rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
|
||||
git = "https://github.com/paritytech/substrate/"
|
||||
|
||||
# Dev Dependencies
|
||||
[dev-dependencies.sp-io]
|
||||
version = "2.0.0-alpha.2"
|
||||
version = "2.0.0-alpha.6"
|
||||
default-features = false
|
||||
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31"
|
||||
rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
|
||||
git = "https://github.com/paritytech/substrate/"
|
||||
|
||||
[dev-dependencies.sp-state-machine]
|
||||
version = "0.8.0-alpha.2"
|
||||
rev = "2afecf81ee19b8a6edb364b419190ea47c4a4a31"
|
||||
version = "0.8.0-alpha.6"
|
||||
rev = "c13ad41634d0bd7cf07897c2aa062b917d520520"
|
||||
git = "https://github.com/paritytech/substrate/"
|
||||
|
||||
[features]
|
||||
|
||||
@@ -96,11 +96,11 @@ pub trait Trait: system::Trait {}
|
||||
decl_storage! {
|
||||
trait Store for Module<T: Trait> as Bridge {
|
||||
/// The number of current bridges managed by the module.
|
||||
pub NumBridges get(num_bridges) config(): BridgeId;
|
||||
pub NumBridges get(fn num_bridges) config(): BridgeId;
|
||||
|
||||
/// Maps a bridge id to a bridge struct. Allows a single
|
||||
/// `bridge` module to manage multiple bridges.
|
||||
pub TrackedBridges get(tracked_bridges): map hasher(blake2_256) BridgeId => Option<BridgeInfo<T>>;
|
||||
pub TrackedBridges get(fn tracked_bridges): map hasher(blake2_128_concat) BridgeId => Option<BridgeInfo<T>>;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,6 +108,7 @@ decl_module! {
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
||||
type Error = Error<T>;
|
||||
|
||||
#[weight = 0] // TODO: update me
|
||||
fn initialize_bridge(
|
||||
origin,
|
||||
block_header: T::Header,
|
||||
@@ -131,6 +132,7 @@ decl_module! {
|
||||
NumBridges::put(new_bridge_id);
|
||||
}
|
||||
|
||||
#[weight = 0] // TODO: update me
|
||||
fn submit_finalized_headers(origin) {
|
||||
let _sender = ensure_signed(origin)?;
|
||||
}
|
||||
@@ -155,8 +157,7 @@ impl<T: Trait> Module<T> {
|
||||
proof: StorageProof,
|
||||
validator_set: &Vec<(AuthorityId, AuthorityWeight)>,
|
||||
) -> DispatchResult {
|
||||
let checker =
|
||||
<StorageProofChecker<<T::Hashing as sp_runtime::traits::Hash>::Hasher>>::new(*state_root, proof.clone());
|
||||
let checker = <StorageProofChecker<T::Hashing>>::new(*state_root, proof.clone());
|
||||
|
||||
let checker = checker.map_err(Self::map_storage_err)?;
|
||||
|
||||
@@ -259,6 +260,9 @@ mod tests {
|
||||
type Event = ();
|
||||
type BlockHashCount = ();
|
||||
type MaximumBlockWeight = ();
|
||||
type DbWeight = ();
|
||||
type BlockExecutionWeight = ();
|
||||
type ExtrinsicBaseWeight = ();
|
||||
type AvailableBlockRatio = ();
|
||||
type MaximumBlockLength = ();
|
||||
type Version = ();
|
||||
|
||||
Reference in New Issue
Block a user