mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 11:41:02 +00:00
Update to latest substrate-master and polkadot v0.3 (#195)
* Rebuild runtime * Remove invalid value from chainspec (#68) * service: use grandpa block import for locally sealed aura blocks (#85) * bump version to v0.3.1 * Update lock file. * limit number of transactions when building blocks (#91) * Update to latest Substrate * Bump to 0.3.2 * Actually bump. * v0.3.2 (#98) * bump substrate version * fix polkadot-collator * point to alexander-backports of substrate * bump version * cli: fix node shutdown (#100) * update to latest substrate, change to v0.3.4 * update to latest substrate, bump version to 0.3.5 * v0.3.6 * try to build on every v0.3 commit and update alexander-backports * bump to v0.3.7 * bump to 0.3.8 * Bump to 0.3.9: network and pruning improvements * Bump to 0.3.10: reduce network bandwidth usage * Use libp2p-kad 0.3.2 (#122) * Bump libp2p-identify to 0.3.1 (#123) * Bump to 0.3.12 (#127) * Update Substrate again (#128) * update substrate and bump version to v0.3.13 * bump version to v0.3.14: fix --reserved-nodes * add a manually curated grandpa module (#136) * updating v0.3 to use substrate v0.10 (#146) * updating to latest substrate v0.10 * better handling of outer poll * nit * fix tests * remove comment * reduce indentation * use self.poll * bring oneshot into scope * spaces * wrap * remove match * wrap * Update primitives/Cargo.toml Co-Authored-By: gterzian <2792687+gterzian@users.noreply.github.com> * Update runtime/wasm/Cargo.toml Co-Authored-By: gterzian <2792687+gterzian@users.noreply.github.com> * Update runtime/wasm/Cargo.toml Co-Authored-By: gterzian <2792687+gterzian@users.noreply.github.com> * Update test-parachains/adder/collator/src/main.rs Co-Authored-By: gterzian <2792687+gterzian@users.noreply.github.com> * indent * add paranthese * config: fix wrong ip for alexander bootnode (#161) * fix curated-grandpa and rebuild wasm (#162) * [v0.3] Integrates new gossip system into Polkadot (#166) * new gossip validation in network * integrate new gossip into service * network: guard validation network future under exit signal (#168) * bump version to v0.3.15: substrate v0.10 * [v0.3] update to substrate master (#175) * update to substrate master * fix test * service: fix telemetry endpoints on alexander chainspec (#169) (#178) * Update v0.3 to latest Substrate master (#177) * update substrate v0.3 to latest master * bump spec version * update to latest master: remove fees module * update runtime blobs * bump version to 0.3.16 * replace sr25519 accountid with anysigner * bump version to v0.3.17 * Some PoC-3 GRANDPA tweaks (#181) * call on_finalise after triggering curated_grandpa change * make grandpa rounds shorter for faster finalization * use authorities when calculating duty roster (#185) * [v0.3] Update to substrate master (#183) * update to latest substrate master * bump version to 0.3.18 * update to latest substrate master * bump spec version * update runtime wasm blobs * remove current_offline_slash from chain spec * update to substrate master: bump version to v0.3.19 (#188) * update to substrate master: bump version to v0.3.19 libp2p network improvements * network: replace NodeIndex with PeerId * network: fix tests * polkadot v0.3.20 (#190) * update to substrate master: bump version to 0.3.20 * runtime: add offchain worker trait * runtime: rebuild wasm blobs * bump spec version (#191) * Fix compilation * Update version to 0.4.0 * Switch to use `polkadot-master` branch from substrate * Remove unused struct * Remove `grandpa::SyncedAuthorities` from `OnSessionChange`
This commit is contained in:
committed by
Robert Habermeier
parent
5606afd886
commit
7e2714f843
+28
-28
@@ -55,9 +55,9 @@ pub mod gossip;
|
||||
|
||||
use codec::{Decode, Encode};
|
||||
use futures::sync::oneshot;
|
||||
use polkadot_primitives::{Block, SessionKey, Hash, Header, parachain::CollatorId};
|
||||
use polkadot_primitives::parachain::{Id as ParaId, BlockData, CandidateReceipt, Collation};
|
||||
use substrate_network::{NodeIndex, RequestId, Context, Severity};
|
||||
use polkadot_primitives::{Block, SessionKey, Hash, Header};
|
||||
use polkadot_primitives::parachain::{Id as ParaId, CollatorId, BlockData, CandidateReceipt, Collation};
|
||||
use substrate_network::{PeerId, RequestId, Context, Severity};
|
||||
use substrate_network::{message, generic_message};
|
||||
use substrate_network::specialization::NetworkSpecialization as Specialization;
|
||||
use substrate_network::StatusMessage as GenericFullStatus;
|
||||
@@ -156,7 +156,7 @@ pub enum Message {
|
||||
Collation(Hash, Collation),
|
||||
}
|
||||
|
||||
fn send_polkadot_message(ctx: &mut Context<Block>, to: NodeIndex, message: Message) {
|
||||
fn send_polkadot_message(ctx: &mut Context<Block>, to: PeerId, message: Message) {
|
||||
trace!(target: "p_net", "Sending polkadot message to {}: {:?}", to, message);
|
||||
let encoded = message.encode();
|
||||
ctx.send_message(to, generic_message::Message::ChainSpecific(encoded))
|
||||
@@ -164,13 +164,13 @@ fn send_polkadot_message(ctx: &mut Context<Block>, to: NodeIndex, message: Messa
|
||||
|
||||
/// Polkadot protocol attachment for substrate.
|
||||
pub struct PolkadotProtocol {
|
||||
peers: HashMap<NodeIndex, PeerInfo>,
|
||||
peers: HashMap<PeerId, PeerInfo>,
|
||||
collating_for: Option<(CollatorId, ParaId)>,
|
||||
collators: CollatorPool,
|
||||
validators: HashMap<SessionKey, NodeIndex>,
|
||||
validators: HashMap<SessionKey, PeerId>,
|
||||
local_collations: LocalCollations<Collation>,
|
||||
live_validation_sessions: LiveValidationSessions,
|
||||
in_flight: HashMap<(RequestId, NodeIndex), BlockDataRequest>,
|
||||
in_flight: HashMap<(RequestId, PeerId), BlockDataRequest>,
|
||||
pending: Vec<BlockDataRequest>,
|
||||
extrinsic_store: Option<::av_store::Store>,
|
||||
next_req_id: u64,
|
||||
@@ -225,7 +225,7 @@ impl PolkadotProtocol {
|
||||
{
|
||||
peer_data.collator_state.send_key(new_local.clone(), |msg| send_polkadot_message(
|
||||
ctx,
|
||||
*id,
|
||||
id.clone(),
|
||||
msg
|
||||
));
|
||||
}
|
||||
@@ -257,7 +257,7 @@ impl PolkadotProtocol {
|
||||
}
|
||||
Err(Some(known_keys)) => {
|
||||
let next_peer = known_keys.iter()
|
||||
.filter_map(|x| validator_keys.get(x).map(|id| (x.clone(), *id)))
|
||||
.filter_map(|x| validator_keys.get(x).map(|id| (x.clone(), id.clone())))
|
||||
.find(|&(ref key, _)| pending.attempted_peers.insert(key.clone()))
|
||||
.map(|(_, id)| id);
|
||||
|
||||
@@ -268,7 +268,7 @@ impl PolkadotProtocol {
|
||||
|
||||
send_polkadot_message(
|
||||
ctx,
|
||||
who,
|
||||
who.clone(),
|
||||
Message::RequestBlockData(req_id, parent, c_hash),
|
||||
);
|
||||
|
||||
@@ -290,7 +290,7 @@ impl PolkadotProtocol {
|
||||
self.pending = new_pending;
|
||||
}
|
||||
|
||||
fn on_polkadot_message(&mut self, ctx: &mut Context<Block>, who: NodeIndex, msg: Message) {
|
||||
fn on_polkadot_message(&mut self, ctx: &mut Context<Block>, who: PeerId, msg: Message) {
|
||||
trace!(target: "p_net", "Polkadot message from {}: {:?}", who, msg);
|
||||
match msg {
|
||||
Message::SessionKey(key) => self.on_session_key(ctx, who, key),
|
||||
@@ -313,7 +313,7 @@ impl PolkadotProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
fn on_session_key(&mut self, ctx: &mut Context<Block>, who: NodeIndex, key: SessionKey) {
|
||||
fn on_session_key(&mut self, ctx: &mut Context<Block>, who: PeerId, key: SessionKey) {
|
||||
{
|
||||
let info = match self.peers.get_mut(&who) {
|
||||
Some(peer) => peer,
|
||||
@@ -343,7 +343,7 @@ impl PolkadotProtocol {
|
||||
for (relay_parent, collation) in new_collations {
|
||||
send_polkadot_message(
|
||||
ctx,
|
||||
who,
|
||||
who.clone(),
|
||||
Message::Collation(relay_parent, collation),
|
||||
)
|
||||
}
|
||||
@@ -354,8 +354,8 @@ impl PolkadotProtocol {
|
||||
self.dispatch_pending_requests(ctx);
|
||||
}
|
||||
|
||||
fn on_block_data(&mut self, ctx: &mut Context<Block>, who: NodeIndex, req_id: RequestId, data: Option<BlockData>) {
|
||||
match self.in_flight.remove(&(req_id, who)) {
|
||||
fn on_block_data(&mut self, ctx: &mut Context<Block>, who: PeerId, req_id: RequestId, data: Option<BlockData>) {
|
||||
match self.in_flight.remove(&(req_id, who.clone())) {
|
||||
Some(req) => {
|
||||
if let Some(data) = data {
|
||||
if data.hash() == req.block_data_hash {
|
||||
@@ -372,7 +372,7 @@ impl PolkadotProtocol {
|
||||
}
|
||||
|
||||
// when a validator sends us (a collator) a new role.
|
||||
fn on_new_role(&mut self, ctx: &mut Context<Block>, who: NodeIndex, role: Role) {
|
||||
fn on_new_role(&mut self, ctx: &mut Context<Block>, who: PeerId, role: Role) {
|
||||
let info = match self.peers.get_mut(&who) {
|
||||
Some(peer) => peer,
|
||||
None => {
|
||||
@@ -400,7 +400,7 @@ impl PolkadotProtocol {
|
||||
debug!(target: "p_net", "Broadcasting collation on relay parent {:?}", relay_parent);
|
||||
send_polkadot_message(
|
||||
ctx,
|
||||
who,
|
||||
who.clone(),
|
||||
Message::Collation(relay_parent, collation),
|
||||
)
|
||||
}
|
||||
@@ -413,7 +413,7 @@ impl Specialization<Block> for PolkadotProtocol {
|
||||
Status { collating_for: self.collating_for.clone() }.encode()
|
||||
}
|
||||
|
||||
fn on_connect(&mut self, ctx: &mut Context<Block>, who: NodeIndex, status: FullStatus) {
|
||||
fn on_connect(&mut self, ctx: &mut Context<Block>, who: PeerId, status: FullStatus) {
|
||||
let local_status = match Status::decode(&mut &status.chain_status[..]) {
|
||||
Some(status) => status,
|
||||
None => {
|
||||
@@ -440,7 +440,7 @@ impl Specialization<Block> for PolkadotProtocol {
|
||||
|
||||
peer_info.collator_state.set_role(collator_role, |msg| send_polkadot_message(
|
||||
ctx,
|
||||
who,
|
||||
who.clone(),
|
||||
msg,
|
||||
));
|
||||
}
|
||||
@@ -450,7 +450,7 @@ impl Specialization<Block> for PolkadotProtocol {
|
||||
for local_session_key in self.live_validation_sessions.recent_keys() {
|
||||
peer_info.collator_state.send_key(local_session_key.clone(), |msg| send_polkadot_message(
|
||||
ctx,
|
||||
who,
|
||||
who.clone(),
|
||||
msg,
|
||||
));
|
||||
}
|
||||
@@ -460,7 +460,7 @@ impl Specialization<Block> for PolkadotProtocol {
|
||||
self.dispatch_pending_requests(ctx);
|
||||
}
|
||||
|
||||
fn on_disconnect(&mut self, ctx: &mut Context<Block>, who: NodeIndex) {
|
||||
fn on_disconnect(&mut self, ctx: &mut Context<Block>, who: PeerId) {
|
||||
if let Some(info) = self.peers.remove(&who) {
|
||||
if let Some((acc_id, _)) = info.collating_for {
|
||||
let new_primary = self.collators.on_disconnect(acc_id)
|
||||
@@ -469,7 +469,7 @@ impl Specialization<Block> for PolkadotProtocol {
|
||||
if let Some((new_primary, primary_info)) = new_primary {
|
||||
primary_info.collator_state.set_role(Role::Primary, |msg| send_polkadot_message(
|
||||
ctx,
|
||||
new_primary,
|
||||
new_primary.clone(),
|
||||
msg,
|
||||
));
|
||||
}
|
||||
@@ -502,7 +502,7 @@ impl Specialization<Block> for PolkadotProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
fn on_message(&mut self, ctx: &mut Context<Block>, who: NodeIndex, message: &mut Option<message::Message<Block>>) {
|
||||
fn on_message(&mut self, ctx: &mut Context<Block>, who: PeerId, message: &mut Option<message::Message<Block>>) {
|
||||
match message.take() {
|
||||
Some(generic_message::Message::ChainSpecific(raw)) => {
|
||||
match Message::decode(&mut raw.as_slice()) {
|
||||
@@ -532,7 +532,7 @@ impl Specialization<Block> for PolkadotProtocol {
|
||||
Action::NewRole(account_id, role) => if let Some((collator, info)) = self.collator_peer(account_id) {
|
||||
info.collator_state.set_role(role, |msg| send_polkadot_message(
|
||||
ctx,
|
||||
collator,
|
||||
collator.clone(),
|
||||
msg,
|
||||
))
|
||||
},
|
||||
@@ -548,7 +548,7 @@ impl Specialization<Block> for PolkadotProtocol {
|
||||
|
||||
impl PolkadotProtocol {
|
||||
// we received a collation from a peer
|
||||
fn on_collation(&mut self, ctx: &mut Context<Block>, from: NodeIndex, relay_parent: Hash, collation: Collation) {
|
||||
fn on_collation(&mut self, ctx: &mut Context<Block>, from: PeerId, relay_parent: Hash, collation: Collation) {
|
||||
let collation_para = collation.receipt.parachain_index;
|
||||
let collated_acc = collation.receipt.collator.clone();
|
||||
|
||||
@@ -577,7 +577,7 @@ impl PolkadotProtocol {
|
||||
}
|
||||
|
||||
// get connected peer with given account ID for collation.
|
||||
fn collator_peer(&mut self, collator_id: CollatorId) -> Option<(NodeIndex, &mut PeerInfo)> {
|
||||
fn collator_peer(&mut self, collator_id: CollatorId) -> Option<(PeerId, &mut PeerInfo)> {
|
||||
let check_info = |info: &PeerInfo| info
|
||||
.collating_for
|
||||
.as_ref()
|
||||
@@ -586,7 +586,7 @@ impl PolkadotProtocol {
|
||||
self.peers
|
||||
.iter_mut()
|
||||
.filter(|&(_, ref info)| check_info(&**info))
|
||||
.map(|(who, info)| (*who, info))
|
||||
.map(|(who, info)| (who.clone(), info))
|
||||
.next()
|
||||
}
|
||||
|
||||
@@ -616,7 +616,7 @@ impl PolkadotProtocol {
|
||||
debug!(target: "p_net", "Sending local collation to {:?}", primary);
|
||||
send_polkadot_message(
|
||||
ctx,
|
||||
*who,
|
||||
who.clone(),
|
||||
Message::Collation(relay_parent, cloned_collation),
|
||||
)
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user