mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 15:51:12 +00:00
Integrate BEEFY with Rialto & Millau runtimes (#1227)
* Add Beefy pallet to Rialto runtime * Add Beefy gadget to Rialto node * Add MMR pallet to Rialto runtime * Add Beefy pallet to Millau runtime * Add Beefy gadget to Millau node * Add MMR pallet to Millau runtime * Add pallet_beefy_mmr to Millau runtime * Add pallet_beefy_mmr to Rialto runtime * Implement MMR and BEEFY APIs in Rialto * fix unit tests - should_encode_bridge_send_message_call() tests for new runtime encoding resulted from newly added pallets. - runtime size_of::<Call>() slightly increased from newly added pallets. * fix grumbles * tighten clippy allowances * fix more grumbles * Add MMR RPC to Rialto and Millau nodes Also implement MmrApi in Millau runtime. * rialto: use upstream polkadot_client::RuntimeApiCollection
This commit is contained in:
committed by
Bastian Köcher
parent
7b30098a12
commit
1fb70c7ed7
@@ -14,11 +14,12 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use beefy_primitives::crypto::AuthorityId as BeefyId;
|
||||
use bp_millau::derive_account_from_rialto_id;
|
||||
use millau_runtime::{
|
||||
AccountId, AuraConfig, BalancesConfig, BridgeRialtoMessagesConfig, BridgeWestendGrandpaConfig,
|
||||
GenesisConfig, GrandpaConfig, SessionConfig, SessionKeys, Signature, SudoConfig, SystemConfig,
|
||||
WASM_BINARY,
|
||||
AccountId, AuraConfig, BalancesConfig, BeefyConfig, BridgeRialtoMessagesConfig,
|
||||
BridgeWestendGrandpaConfig, GenesisConfig, GrandpaConfig, SessionConfig, SessionKeys,
|
||||
Signature, SudoConfig, SystemConfig, WASM_BINARY,
|
||||
};
|
||||
use sp_consensus_aura::sr25519::AuthorityId as AuraId;
|
||||
use sp_core::{sr25519, Pair, Public};
|
||||
@@ -57,10 +58,11 @@ where
|
||||
}
|
||||
|
||||
/// Helper function to generate an authority key for Aura
|
||||
pub fn get_authority_keys_from_seed(s: &str) -> (AccountId, AuraId, GrandpaId) {
|
||||
pub fn get_authority_keys_from_seed(s: &str) -> (AccountId, AuraId, BeefyId, GrandpaId) {
|
||||
(
|
||||
get_account_id_from_seed::<sr25519::Public>(s),
|
||||
get_from_seed::<AuraId>(s),
|
||||
get_from_seed::<BeefyId>(s),
|
||||
get_from_seed::<GrandpaId>(s),
|
||||
)
|
||||
}
|
||||
@@ -173,12 +175,12 @@ impl Alternative {
|
||||
}
|
||||
}
|
||||
|
||||
fn session_keys(aura: AuraId, grandpa: GrandpaId) -> SessionKeys {
|
||||
SessionKeys { aura, grandpa }
|
||||
fn session_keys(aura: AuraId, beefy: BeefyId, grandpa: GrandpaId) -> SessionKeys {
|
||||
SessionKeys { aura, beefy, grandpa }
|
||||
}
|
||||
|
||||
fn testnet_genesis(
|
||||
initial_authorities: Vec<(AccountId, AuraId, GrandpaId)>,
|
||||
initial_authorities: Vec<(AccountId, AuraId, BeefyId, GrandpaId)>,
|
||||
root_key: AccountId,
|
||||
endowed_accounts: Vec<AccountId>,
|
||||
_enable_println: bool,
|
||||
@@ -191,12 +193,15 @@ fn testnet_genesis(
|
||||
balances: endowed_accounts.iter().cloned().map(|k| (k, 1 << 50)).collect(),
|
||||
},
|
||||
aura: AuraConfig { authorities: Vec::new() },
|
||||
beefy: BeefyConfig { authorities: Vec::new() },
|
||||
grandpa: GrandpaConfig { authorities: Vec::new() },
|
||||
sudo: SudoConfig { key: root_key },
|
||||
session: SessionConfig {
|
||||
keys: initial_authorities
|
||||
.iter()
|
||||
.map(|x| (x.0.clone(), x.0.clone(), session_keys(x.1.clone(), x.2.clone())))
|
||||
.map(|x| {
|
||||
(x.0.clone(), x.0.clone(), session_keys(x.1.clone(), x.2.clone(), x.3.clone()))
|
||||
})
|
||||
.collect::<Vec<_>>(),
|
||||
},
|
||||
bridge_westend_grandpa: BridgeWestendGrandpaConfig {
|
||||
|
||||
@@ -21,9 +21,10 @@
|
||||
// =====================================================================================
|
||||
// UPDATE GUIDE:
|
||||
// 1) replace everything with node-template/src/service.rs contents (found in main Substrate repo);
|
||||
// 2) the only thing to keep from old code, is `rpc_extensions_builder` - we use our own custom
|
||||
// RPCs; 3) fix compilation errors;
|
||||
// 4) test :)
|
||||
// 2) from old code keep `rpc_extensions_builder` - we use our own custom RPCs;
|
||||
// 3) from old code keep the Beefy gadget;
|
||||
// 4) fix compilation errors;
|
||||
// 5) test :)
|
||||
// =====================================================================================
|
||||
// =====================================================================================
|
||||
// =====================================================================================
|
||||
@@ -209,6 +210,7 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
|
||||
}
|
||||
|
||||
config.network.extra_sets.push(sc_finality_grandpa::grandpa_peers_set_config());
|
||||
config.network.extra_sets.push(beefy_gadget::beefy_peers_set_config());
|
||||
let warp_sync = Arc::new(sc_finality_grandpa::warp_proof::NetworkProvider::new(
|
||||
backend.clone(),
|
||||
grandpa_link.shared_authority_set().clone(),
|
||||
@@ -242,6 +244,8 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
|
||||
let enable_grandpa = !config.disable_grandpa;
|
||||
let prometheus_registry = config.prometheus_registry().cloned();
|
||||
let shared_voter_state = SharedVoterState::empty();
|
||||
let (signed_commitment_sender, signed_commitment_stream) =
|
||||
beefy_gadget::notification::BeefySignedCommitmentStream::channel();
|
||||
|
||||
let rpc_extensions_builder = {
|
||||
use sc_finality_grandpa::FinalityProofProvider as GrandpaFinalityProofProvider;
|
||||
@@ -264,7 +268,7 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
|
||||
Some(shared_authority_set.clone()),
|
||||
);
|
||||
|
||||
Box::new(move |_, subscription_executor| {
|
||||
Box::new(move |_, subscription_executor: sc_rpc::SubscriptionTaskExecutor| {
|
||||
let mut io = jsonrpc_core::IoHandler::default();
|
||||
io.extend_with(SystemApi::to_delegate(FullSystem::new(
|
||||
client.clone(),
|
||||
@@ -278,9 +282,18 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
|
||||
shared_authority_set.clone(),
|
||||
shared_voter_state.clone(),
|
||||
justification_stream.clone(),
|
||||
subscription_executor,
|
||||
subscription_executor.clone(),
|
||||
finality_proof_provider.clone(),
|
||||
)));
|
||||
io.extend_with(beefy_gadget_rpc::BeefyApi::to_delegate(
|
||||
beefy_gadget_rpc::BeefyRpcHandler::new(
|
||||
signed_commitment_stream.clone(),
|
||||
subscription_executor,
|
||||
),
|
||||
));
|
||||
io.extend_with(pallet_mmr_rpc::MmrApi::to_delegate(pallet_mmr_rpc::Mmr::new(
|
||||
client.clone(),
|
||||
)));
|
||||
Ok(io)
|
||||
})
|
||||
};
|
||||
@@ -292,7 +305,7 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
|
||||
task_manager: &mut task_manager,
|
||||
transaction_pool: transaction_pool.clone(),
|
||||
rpc_extensions_builder,
|
||||
backend,
|
||||
backend: backend.clone(),
|
||||
system_rpc_tx,
|
||||
config,
|
||||
telemetry: telemetry.as_mut(),
|
||||
@@ -355,6 +368,23 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
|
||||
let keystore =
|
||||
if role.is_authority() { Some(keystore_container.sync_keystore()) } else { None };
|
||||
|
||||
let beefy_params = beefy_gadget::BeefyParams {
|
||||
client,
|
||||
backend,
|
||||
key_store: keystore.clone(),
|
||||
network: network.clone(),
|
||||
signed_commitment_sender,
|
||||
min_block_delta: 4,
|
||||
prometheus_registry: prometheus_registry.clone(),
|
||||
};
|
||||
|
||||
// Start the BEEFY bridge gadget.
|
||||
task_manager.spawn_essential_handle().spawn_blocking(
|
||||
"beefy-gadget",
|
||||
None,
|
||||
beefy_gadget::start_beefy_gadget::<_, _, _, _>(beefy_params),
|
||||
);
|
||||
|
||||
let grandpa_config = sc_finality_grandpa::Config {
|
||||
// FIXME #1578 make this available through chainspec
|
||||
gossip_duration: Duration::from_millis(333),
|
||||
|
||||
Reference in New Issue
Block a user