Fix light connection issues (#2499)

* ignore light nodes in ConsensusGossip

* fixed method name

* temporary disabled penalty when block is announced

* remove traces of BLOCK_ANNOUNCE_REPUTATION_CHANGE
This commit is contained in:
Svyatoslav Nikolsky
2019-05-08 13:24:20 +03:00
committed by Gavin Wood
parent d380db706b
commit a63635b952
3 changed files with 6 additions and 6 deletions
@@ -148,7 +148,7 @@ where
}
fn runtime_version(&self, id: &BlockId<Block>) -> ClientResult<RuntimeVersion> {
let call_result = self.call(id, "version", &[], ExecutionStrategy::NativeElseWasm, NeverOffchainExt::new())?;
let call_result = self.call(id, "Core_version", &[], ExecutionStrategy::NativeElseWasm, NeverOffchainExt::new())?;
RuntimeVersion::decode(&mut call_result.as_slice())
.ok_or_else(|| ClientError::VersionInvalid.into())
}
@@ -265,6 +265,11 @@ impl<B: BlockT> ConsensusGossip<B> {
/// Handle new connected peer.
pub fn new_peer(&mut self, protocol: &mut Context<B>, who: PeerId, roles: Roles) {
// light nodes are not valid targets for consensus gossip messages
if !roles.intersects(Roles::FULL | Roles::AUTHORITY) {
return;
}
trace!(target:"gossip", "Registering {:?} {}", roles, who);
self.peers.insert(who.clone(), PeerConsensus {
known_messages: HashSet::new(),
-5
View File
@@ -72,10 +72,6 @@ const UNEXPECTED_STATUS_REPUTATION_CHANGE: i32 = -(1 << 20);
const PEER_BEHIND_US_LIGHT_REPUTATION_CHANGE: i32 = -(1 << 8);
/// Reputation change when a peer sends us an extrinsic that we didn't know about.
const NEW_EXTRINSIC_REPUTATION_CHANGE: i32 = 1 << 7;
/// Reputation change when a peer sends us a block. We don't know whether this block is valid or
/// already known to us. Since this has a small cost, we decrease the reputation of the node, and
/// will increase it back later if the import is successful.
const BLOCK_ANNOUNCE_REPUTATION_CHANGE: i32 = -(1 << 2);
/// We sent an RPC query to the given node, but it failed.
const RPC_FAILED_REPUTATION_CHANGE: i32 = -(1 << 12);
@@ -991,7 +987,6 @@ impl<B: BlockT, S: NetworkSpecialization<B>, H: ExHashT> Protocol<B, S, H> {
hash,
&header,
);
self.network_chan.send(NetworkMsg::ReportPeer(who, BLOCK_ANNOUNCE_REPUTATION_CHANGE));
}
fn on_block_imported(&mut self, hash: B::Hash, header: &B::Header) {