mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-19 00:41:03 +00:00
Implement Substrate Pallet Runtime APIs (#389)
* Implement public helpers for querying header info * Update `best_header` when importing headers * Add BestHeader to GenesisConfig * Define extra types for Millau primitives * Start implementing runtime APIs in Millau runtime * Add helper for getting headers which require a justification * Add runtime API for getting headers requiring a justification * Reword `expect()` proof for valid authority sets * Fix typo * Clean up Hasher comment * Add the Call Dispatch Pallet back to the Millau runtime * Use types from Rialto in bridge pallet config * Use the Rialto runtime APIS in the Millau runtime * Include Millau bridge instance in Rialto runtime * Add missing doc comment * Use one storage function for setting and clearing `RequiresJustification` * Remove TODO comments
This commit is contained in:
committed by
Bastian Köcher
parent
cfe1e43473
commit
86834e2fd6
@@ -414,6 +414,13 @@ impl pallet_session::Trait for Runtime {
|
||||
type WeightInfo = ();
|
||||
}
|
||||
|
||||
impl pallet_substrate_bridge::Trait for Runtime {
|
||||
type BridgedHeader = bp_millau::Header;
|
||||
type BridgedBlockNumber = bp_millau::BlockNumber;
|
||||
type BridgedBlockHash = bp_millau::Hash;
|
||||
type BridgedBlockHasher = bp_millau::Hasher;
|
||||
}
|
||||
|
||||
impl pallet_shift_session_manager::Trait for Runtime {}
|
||||
|
||||
construct_runtime!(
|
||||
@@ -426,6 +433,7 @@ construct_runtime!(
|
||||
BridgeKovan: pallet_bridge_eth_poa::<Instance2>::{Module, Call, Config, Storage, ValidateUnsigned},
|
||||
BridgeRialtoCurrencyExchange: pallet_bridge_currency_exchange::<Instance1>::{Module, Call},
|
||||
BridgeKovanCurrencyExchange: pallet_bridge_currency_exchange::<Instance2>::{Module, Call},
|
||||
BridgeMillau: pallet_substrate_bridge::{Module, Call, Storage},
|
||||
BridgeCallDispatch: pallet_bridge_call_dispatch::{Module, Event<T>},
|
||||
System: frame_system::{Module, Call, Config, Storage, Event<T>},
|
||||
RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage},
|
||||
@@ -562,6 +570,36 @@ impl_runtime_apis! {
|
||||
}
|
||||
}
|
||||
|
||||
impl bp_millau::MillauHeaderApi<Block> for Runtime {
|
||||
fn best_block() -> (bp_millau::BlockNumber, bp_millau::Hash) {
|
||||
let header = BridgeMillau::best_header();
|
||||
(header.number, header.hash())
|
||||
}
|
||||
|
||||
fn finalized_block() -> (bp_millau::BlockNumber, bp_millau::Hash) {
|
||||
let header = BridgeMillau::best_finalized();
|
||||
(header.number, header.hash())
|
||||
}
|
||||
|
||||
fn incomplete_headers() -> Vec<(bp_millau::BlockNumber, bp_millau::Hash)> {
|
||||
// Since the pallet doesn't accept multiple scheduled changes right now
|
||||
// we can only have one header requiring a justification at any time.
|
||||
if let Some(header) = BridgeMillau::requires_justification() {
|
||||
vec![(header.number, header.hash())]
|
||||
} else {
|
||||
vec![]
|
||||
}
|
||||
}
|
||||
|
||||
fn is_known_block(hash: bp_millau::Hash) -> bool {
|
||||
BridgeMillau::is_known_header(hash)
|
||||
}
|
||||
|
||||
fn is_finalized_block(hash: bp_millau::Hash) -> bool {
|
||||
BridgeMillau::is_finalized_header(hash)
|
||||
}
|
||||
}
|
||||
|
||||
impl bp_currency_exchange::RialtoCurrencyExchangeApi<Block, exchange::EthereumTransactionInclusionProof> for Runtime {
|
||||
fn filter_transaction_proof(proof: exchange::EthereumTransactionInclusionProof) -> bool {
|
||||
BridgeRialtoCurrencyExchange::filter_transaction_proof(&proof)
|
||||
@@ -574,24 +612,6 @@ impl_runtime_apis! {
|
||||
}
|
||||
}
|
||||
|
||||
impl bp_millau::MillauHeaderApi<Block> for Runtime {
|
||||
fn best_block() -> (bp_millau::BlockNumber, bp_millau::Hash) {
|
||||
unimplemented!("https://github.com/paritytech/parity-bridges-common/issues/368")
|
||||
}
|
||||
|
||||
fn finalized_block() -> (bp_millau::BlockNumber, bp_millau::Hash) {
|
||||
unimplemented!("https://github.com/paritytech/parity-bridges-common/issues/368")
|
||||
}
|
||||
|
||||
fn incomplete_headers() -> Vec<(bp_millau::BlockNumber, bp_millau::Hash)> {
|
||||
unimplemented!("https://github.com/paritytech/parity-bridges-common/issues/368")
|
||||
}
|
||||
|
||||
fn is_known_block(_hash: bp_millau::Hash) -> bool {
|
||||
unimplemented!("https://github.com/paritytech/parity-bridges-common/issues/368")
|
||||
}
|
||||
}
|
||||
|
||||
impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {
|
||||
fn validate_transaction(
|
||||
source: TransactionSource,
|
||||
|
||||
Reference in New Issue
Block a user