-
Notifications
You must be signed in to change notification settings - Fork 2.7k
simplification of peerset api #2123
Conversation
|
|
||
| fn poll(&mut self) -> Poll<Option<Self::Item>, Self::Error> { | ||
| self.rx.poll() | ||
| loop { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do I understand it correctly that the loop is necessary because the various calls to self.message_queue.push_back will not wake-up the current task?
Have you considered instead having the various on_ methods return a Option<Self::Item> directly? Since if let Some(message) immediately returns, I assume there isn't a case where any of the on_ methods will create more than one message?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do I understand it correctly that the
loopis necessary because the various calls toself.message_queue.push_backwill not wake-up the current task?
It's necessary, cause on_ methods may add multiple messages or may not add them at all. In the later case, we need to process next Action.
Have you considered instead having the various
on_methods return aOption<Self::Item>directly? Sinceif let Some(message)immediately returns, I assume there isn't a case where any of theon_methods will create more than one message?
Yes, I considered it, but it's less efficient and may be confusing.
on_methods would require&mut selfeven if they don't touchself.message_queue. So we would have anon_method that mutatesselfand returns the result that should be always appended toself.message_queue. It would be confusing and could lead to incorrect behaviourson_methods would have to returnVec<Self::Item>so we would have an additional allocation of on a heap of something that is rewritten toself.message_queuea second after
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I see, wouldn't it be possible for messsages in message_queue to be stuck there in case nothing new is sent on the receiver? Let's say one of the _on methods adds 2 items to message_queue, the first one get's returned by the if let Some(message) and the second one is still inside message_queue. If nothing wakes up the current task, the second message in message_qeue could never be handled? Maybe schedule a wake-up if the message_queue is non-empty before returning from poll?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I see, wouldn't it be possible for messsages in
message_queueto be stuck there in case nothing new is sent on the receiver?
It's a good question, but no.
Let's say one of the
_onmethods adds 2 items tomessage_queue, the first one get's returned by theif let Some(message)and the second one is still insidemessage_queue. If nothing wakes up the current task, the second message inmessage_qeuecould never be handled? Maybe schedule a wake-up if themessage_queueis non-empty before returning frompoll
If a stream returns a single item, it will be waken up subsequently until it returns Async::NotReady or Async::Ready(None). So if we push multiple messages to message_queue, it will be polled until all the items from message_queue are drained
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I didn't know one could rely on the stream being woken-up later by returning Async::Ready(Some). I thought one had to have another way to register the current task for being awaken, for example in the current case by calling self.rx.poll(), which registers the current task for being woken-up if a message is sent on the corrseponding sender.
tomusdrw
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks nice, a bit of boilerplate code that I think could be replaced by a library (isn't there one?)
| PeerState::DisabledPendingEnable { open, connected_point, timer } => { | ||
| debug!(target: "sub-libp2p", "PSM <= Dropped({:?})", peer_id); | ||
| self.peerset.dropped(peer_id); | ||
| self.peerset.dropped(peer_id.clone()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just out of curiosity, why do you think it's better to clone on the call site? My preference would be to pass a reference and clone only if needed. In that case it doesn't really matter, since we know that current implementation requires ownership anyway, but IMHO passing reference is more future proof (shall the impl change).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just out of curiosity, why do you think it's better to clone on the call site?
No, but we always need a value, cause we send it over the channel. That's why I changed the function signature
|
|
||
| /// Message that can be sent by the peer set manager (PSM). | ||
| #[derive(Debug)] | ||
| enum Action { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds like a good idea for proc-macro library :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
definitely :) if we only have more messages or if we do it in more than one place. Right now proc-macro library would probably require writing more code than this boilerplate does
core/peerset/src/lib.rs
Outdated
| message_queue: VecDeque<Message>, | ||
| } | ||
|
|
||
| impl ops::Deref for Peerset { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it's a good use case for Deref, from the docs:
Deref should only be implemented for smart pointers to avoid confusion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm... I was not aware of this. I added Deref for convenience
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should I remove this ops::Deref?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, if it's ok to use it directly. Alternatively add AsRef if you want to pass it to some generic code.
core/peerset/src/lib.rs
Outdated
| /// Reports an adjustement to the reputation of the given peer. | ||
| pub fn report_peer(&self, _peer_id: &PeerId, _score_diff: i32) { | ||
| fn on_report_peer(&self, _peer_id: PeerId, _score_diff: i32) { | ||
| //unimplemented!(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should most likely be removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it needs implementation, I'm adding it right now
core/peerset/src/lib.rs
Outdated
| *slot = Some(elem.clone()); | ||
| let _ = tx.unbounded_send(Message::Connect(elem)); | ||
| for slot in self.data.out_slots.iter_mut() { | ||
| if slot.is_some() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move into a filter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the implementation here remained unchanged, I just moved the function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still could be placed into a filter :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes! I was supposed to give you thumbs up, not confused emoji :)
core/peerset/src/lib.rs
Outdated
| if let Some(message) = self.message_queue.pop_front() { | ||
| return Ok(Async::Ready(Some(message))); | ||
| } | ||
| match self.rx.poll()? { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| match self.rx.poll()? { | |
| match try_ready!(self.rx.poll()) { |
core/peerset/src/lib.rs
Outdated
| if let Some(pos) = self.data.out_slots.iter().position(|s| s.as_ref().map(|n| !self.data.reserved.contains(n)).unwrap_or(true)) { | ||
| // TODO: override slots that are occupied by not reserved peers | ||
| // send Message::Drop in those cases | ||
| if let Some(pos) = self.data.out_slots.iter().position(Option::is_none) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a bugfix. bootnodes were overwritten by reserved peers, but no message was created
core/peerset/src/lib.rs
Outdated
| /// | ||
| /// Because of concurrency issues, it is acceptable to call `incoming` with a `PeerId` the | ||
| /// peerset is already connected to, in which case it must not answer. | ||
| pub fn incoming(&self, peer_id: PeerId, index: IncomingIndex) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The incoming, dropped and discovered methods were only on the PeersetMut (now Peerset) because it doesn't make sense for them to be accessible from anything else than the networking. If someone calls them you will just crate an inconsistent state in the network layer. If for some reason we have to keep that as is, please put a huge warning that says "don't call these functions".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would anyone want to call this functions? Calling them is a logical error, same as doing
let a = None;
if let Some(value) = a {
// ...
}Peerset is a futures::Stream and I believe it should be responsible only for producing items, nothing else.
If we want to limit how and where the methods are used, I believe we should have 2 different handles. One with incoming, dropped and discovered methods and the second one with everything else
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calling them is a logical error
Yeah, and it would be even better if the type system prevents these logic errors. I don't really want to have to deal with someone calling dropped thinking it disconnects a node, and I'm pretty sure it will happen.
Peerset is a futures::Stream and I believe it should be responsible only for producing items, nothing else.
Why is that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Peerset is a futures::Stream and I believe it should be responsible only for producing items, nothing else.
Why is that?
So we can use combinators (.map, .then) on the stream
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only thing that will use the Peerset is the networking code which already exists and doesn't use combinators. I don't think we should have a weird API and add a performance hit because of usability, especially since usability here is a non-issue.
core/peerset/src/lib.rs
Outdated
| impl Peerset { | ||
| /// Builds a new peerset from the given configuration. | ||
| pub fn from_config(config: PeersetConfig) -> (Arc<Peerset>, PeersetMut) { | ||
| pub fn from_config(config: PeersetConfig) -> Peerset { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Being able to create handles from the Peerset means that we will forever have to keep in the Peerset the building blocks for a PeersetHandler unless we break the API. Whereas if we return a tuple, they can be separate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can always create PeersetHandle by cloning an existing one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not strongly opinionated here. For me, this method could also return a tuple. But I see nothing bad, in Peerset keeping the building blocks for the PeersetHandler
core/peerset/src/lib.rs
Outdated
| let _ = self.tx.unbounded_send(Action::SetReservedOnly(reserved)); | ||
| } | ||
|
|
||
| /// Reports an adjustement to the reputation of the given peer. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| /// Reports an adjustement to the reputation of the given peer. | |
| /// Reports an adjustment to the reputation of the given peer. |
|
done, please review again |
|
Would love to see detailed tracing in the |
tomaka
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lots of comments but only the Accept/Reject need fixing.
core/peerset/src/slots.rs
Outdated
| } | ||
|
|
||
| /// Returns Ok if we successfully connected to a given peer. | ||
| pub fn add_peer(&mut self, peer_id: PeerId, slot_type: SlotType) -> Result<(), SlotError> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From looking at the return values, I'm not sure if this should be a Result. You return Err even in situations that I would consider successful and where you change the state.
That can be improved later, though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough, I'll change the Result
core/peerset/src/slots.rs
Outdated
| self.slots.remove(peer_id); | ||
| } | ||
|
|
||
| pub fn is_reserved(&self, peer_id: &PeerId) -> bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be is_connected_and_reserved maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all peers in slots are connected
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hence the name change to make that explicit.
core/peerset/src/lib.rs
Outdated
| self.data.reserved_only = reserved_only; | ||
| if self.data.reserved_only { | ||
| for peer_id in self.data.in_slots.clear_common_slots().into_iter().chain(self.data.out_slots.clear_common_slots().into_iter()) { | ||
| // peer will be removed from `in_slots` or `out_slots` in `on_dropped` method |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment is obsolete.
core/peerset/src/lib.rs
Outdated
| if self.data.reserved_only { | ||
| for peer_id in self.data.in_slots.clear_common_slots().into_iter().chain(self.data.out_slots.clear_common_slots().into_iter()) { | ||
| // peer will be removed from `in_slots` or `out_slots` in `on_dropped` method | ||
| self.data.in_slots.clear_slot(&peer_id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this line useful? in_slots should be cleared in the for, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch. it's the leftover from previous version of this function :)
core/peerset/src/lib.rs
Outdated
| } | ||
| } | ||
| fn on_report_peer(&mut self, peer_id: PeerId, score_diff: i32) { | ||
| let score = self.data.scores.entry(peer_id.clone()).or_default(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think scores grows forever, right? For long running nodes it will take up a lot of memory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
true, we can use some lru_cache here.
The same problem exists with discovered. Should we limit the number of peers over there as well?
| continue; | ||
| if *score < 0 { | ||
| // peer will be removed from `in_slots` or `out_slots` in `on_dropped` method | ||
| if self.data.in_slots.contains(&peer_id) || self.data.out_slots.contains(&peer_id) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could combine contains and clear_slot into one method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't. We need to know whether we have a connection to this slot to call Message::Drop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I mean is that clear_slot could return an enum indicating whether we cleared something or not.
core/peerset/src/lib.rs
Outdated
| Ok(_) => { | ||
| self.message_queue.push_back(Message::Connect(peer_id)); | ||
| }, | ||
| Err(SlotError::AlreadyConnected(_)) => (), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd print an error here, since there's an obvious problem somewhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point! being here means that we have a logic error somewhere
core/peerset/src/lib.rs
Outdated
|
|
||
| // check if we are already connected to this peer | ||
| if self.data.out_slots.contains(&peer_id) { | ||
| self.message_queue.push_back(Message::Reject(index)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Must not send Reject, see the doc-comment of the function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for pointing this out. May I accept why is it designed like that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't remember, to be honest. There was a long debate about this and this was the outcome.
core/peerset/src/lib.rs
Outdated
| return; | ||
| }, | ||
| Err(SlotError::DemandReroute { disconnect, .. }) => { | ||
| // disconnect not reserved node |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should send back Accept here, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, we are in the loop. Accept will be send on the next loop iteration
|
@tomaka please review again. I applied all suggestions/fixes |
* Introduction of PeersetHandle * integrate PeersetHandle with the rest of the codebase * fix compilation errors * more tests for peerset, fixed overwriting bug in add_reserved_peer * Slots data structure and bugfixes for peerset * bend to pressure * updated lru-cache to 0.1.2 and updated linked-hash-map to 0.5.2 * peerset discovered list is now a LinkedHashMap * fix review suggestions * split back Peerset and PeersetHandle * test for Peerset::discovered * applied review suggestions * fixes to peerset::incoming * peerset disconnects are all instantaneous * instantaneous drop in peerset finished * Peerset::set_reserved_only can also reconnect nodes * Peerset scores cache uses lru-cache * remove redundant function call and comment from Peerset::on_set_reserved_only * add_peer returns SlotState enum * apply review suggestions * is_reserved -> is_connected_and_reserved
* Introduction of PeersetHandle * integrate PeersetHandle with the rest of the codebase * fix compilation errors * more tests for peerset, fixed overwriting bug in add_reserved_peer * Slots data structure and bugfixes for peerset * bend to pressure * updated lru-cache to 0.1.2 and updated linked-hash-map to 0.5.2 * peerset discovered list is now a LinkedHashMap * fix review suggestions * split back Peerset and PeersetHandle * test for Peerset::discovered * applied review suggestions * fixes to peerset::incoming * peerset disconnects are all instantaneous * instantaneous drop in peerset finished * Peerset::set_reserved_only can also reconnect nodes * Peerset scores cache uses lru-cache * remove redundant function call and comment from Peerset::on_set_reserved_only * add_peer returns SlotState enum * apply review suggestions * is_reserved -> is_connected_and_reserved
…y-by-default' Squashed commit of the following: commit 6de583a Author: Xiliang Chen <[email protected]> Date: Wed Apr 10 20:26:29 2019 +1200 update authers for rest of the node-template cargo.toml files (#2242) commit 5240bc1 Author: Bastian Köcher <[email protected]> Date: Tue Apr 9 10:31:18 2019 +0200 Throw a compile error for `on_finalise` and `on_initialise` (#2236) commit 67d2e71 Author: Pierre Krieger <[email protected]> Date: Tue Apr 9 05:30:43 2019 -0300 Add warning when using default protocol ID (#2234) * Add warning when using default protocol ID * Update core/service/src/lib.rs commit 1421fed Author: Xiliang Chen <[email protected]> Date: Tue Apr 9 17:22:20 2019 +1200 update name and authors to placeholder text for node-template (#2222) * update name and authors to placeholder text * revert package name change commit 6617f23 Author: André Silva <[email protected]> Date: Mon Apr 8 12:50:34 2019 +0100 grandpa: Voter persistence and upgrade to finality-grandpa v0.7 (#2139) * core: grandpa: migrate to grandpa 0.7 * core: grandpa: store current round votes and load them on startup * core: grandpa: resend old persisted votes for the current round * core: grandpa: store base and votes for last completed round * core: grandpa: fix latest grandpa 0.7 changes * core: grandpa: update to grandpa 0.7.1 * core: grandpa: persist votes for last two completed rounds * core: grandpa: simplify VoterSetState usage * core: grandpa: use Environment::update_voter_set_state * core: grandpa: fix aux_schema test * core: grandpa: add docs * core: grandpa: add note about environment assumption * core: grandpa: don't update voter set state on ignored votes * core: grandpa: add test for v1 -> v2 aux_schema migration * core: grandpa: add test for voter vote persistence * core: grandpa: use grandpa 0.7.1 from crates.io * core: grandpa: use try_init in test * core: grandpa: add comment about block_import in test * core: grandpa: avoid cloning HasVoted * core: grandpa: add missing docs * core: grandpa: cleanup up can_propose/prevote/precommit commit 21e0877 Author: Gregory Terzian <[email protected]> Date: Mon Apr 8 13:17:00 2019 +0200 remove clone bound on specialization in testnet factory (#2157) commit 7c64746 Author: Andrew Jones <[email protected]> Date: Sat Apr 6 12:23:56 2019 +0100 Contract import/export validation (#2203) * Reject validation of contract with unknown exports * Validate imports eagerly * Increment spec version commit 12718fa Author: Pierre Krieger <[email protected]> Date: Fri Apr 5 14:07:09 2019 -0300 Fix state inconsistency between handler and behaviour (#2220) * Fix state inconsistency between handler and behaviour * Fix the error! being in the wrong place commit f917d12 Author: Bastian Köcher <[email protected]> Date: Fri Apr 5 18:50:38 2019 +0200 Use `storage_root` of newly calculated header (#2216) Instead of calculating the `storage_root` a second time, we just can take the `storage_root` from the new header. commit 3359ce0 Author: Marek Kotewicz <[email protected]> Date: Fri Apr 5 14:44:46 2019 +0200 Peerset::discovered accepts many peer ids (#2213) * Peerset::discovered accepts many peer ids * Improve tracing in peerset commit dd82e0e Author: Marek Kotewicz <[email protected]> Date: Thu Apr 4 19:40:40 2019 +0200 simplification of peerset api (#2123) * Introduction of PeersetHandle * integrate PeersetHandle with the rest of the codebase * fix compilation errors * more tests for peerset, fixed overwriting bug in add_reserved_peer * Slots data structure and bugfixes for peerset * bend to pressure * updated lru-cache to 0.1.2 and updated linked-hash-map to 0.5.2 * peerset discovered list is now a LinkedHashMap * fix review suggestions * split back Peerset and PeersetHandle * test for Peerset::discovered * applied review suggestions * fixes to peerset::incoming * peerset disconnects are all instantaneous * instantaneous drop in peerset finished * Peerset::set_reserved_only can also reconnect nodes * Peerset scores cache uses lru-cache * remove redundant function call and comment from Peerset::on_set_reserved_only * add_peer returns SlotState enum * apply review suggestions * is_reserved -> is_connected_and_reserved commit d90833d Author: Arkadiy Paronyan <[email protected]> Date: Thu Apr 4 18:01:28 2019 +0200 Disconnect on protocol timeout (#2212) commit c0a46b5 Author: André Silva <[email protected]> Date: Thu Apr 4 15:56:49 2019 +0100 core: grandpa: verify commit target in justification (#2201) commit 3a4901a Author: Bastian Köcher <[email protected]> Date: Thu Apr 4 16:56:16 2019 +0200 Introduce `original_storage` and `original_storage_hash` (#2211) Both functions will ignore any overlayed changes and access the backend directly. commit a7a469f Author: Xiliang Chen <[email protected]> Date: Fri Apr 5 03:55:55 2019 +1300 code cleanup (#2206) commit 26c7b44 Author: Arkadiy Paronyan <[email protected]> Date: Wed Apr 3 15:52:46 2019 +0200 Emberic elm testnet (#2197)
* Introduction of PeersetHandle * integrate PeersetHandle with the rest of the codebase * fix compilation errors * more tests for peerset, fixed overwriting bug in add_reserved_peer * Slots data structure and bugfixes for peerset * bend to pressure * updated lru-cache to 0.1.2 and updated linked-hash-map to 0.5.2 * peerset discovered list is now a LinkedHashMap * fix review suggestions * split back Peerset and PeersetHandle * test for Peerset::discovered * applied review suggestions * fixes to peerset::incoming * peerset disconnects are all instantaneous * instantaneous drop in peerset finished * Peerset::set_reserved_only can also reconnect nodes * Peerset scores cache uses lru-cache * remove redundant function call and comment from Peerset::on_set_reserved_only * add_peer returns SlotState enum * apply review suggestions * is_reserved -> is_connected_and_reserved
* Introduction of PeersetHandle * integrate PeersetHandle with the rest of the codebase * fix compilation errors * more tests for peerset, fixed overwriting bug in add_reserved_peer * Slots data structure and bugfixes for peerset * bend to pressure * updated lru-cache to 0.1.2 and updated linked-hash-map to 0.5.2 * peerset discovered list is now a LinkedHashMap * fix review suggestions * split back Peerset and PeersetHandle * test for Peerset::discovered * applied review suggestions * fixes to peerset::incoming * peerset disconnects are all instantaneous * instantaneous drop in peerset finished * Peerset::set_reserved_only can also reconnect nodes * Peerset scores cache uses lru-cache * remove redundant function call and comment from Peerset::on_set_reserved_only * add_peer returns SlotState enum * apply review suggestions * is_reserved -> is_connected_and_reserved
* Introduction of PeersetHandle * integrate PeersetHandle with the rest of the codebase * fix compilation errors * more tests for peerset, fixed overwriting bug in add_reserved_peer * Slots data structure and bugfixes for peerset * bend to pressure * updated lru-cache to 0.1.2 and updated linked-hash-map to 0.5.2 * peerset discovered list is now a LinkedHashMap * fix review suggestions * split back Peerset and PeersetHandle * test for Peerset::discovered * applied review suggestions * fixes to peerset::incoming * peerset disconnects are all instantaneous * instantaneous drop in peerset finished * Peerset::set_reserved_only can also reconnect nodes * Peerset scores cache uses lru-cache * remove redundant function call and comment from Peerset::on_set_reserved_only * add_peer returns SlotState enum * apply review suggestions * is_reserved -> is_connected_and_reserved
* simplification of peerset api (#2123) * Introduction of PeersetHandle * integrate PeersetHandle with the rest of the codebase * fix compilation errors * more tests for peerset, fixed overwriting bug in add_reserved_peer * Slots data structure and bugfixes for peerset * bend to pressure * updated lru-cache to 0.1.2 and updated linked-hash-map to 0.5.2 * peerset discovered list is now a LinkedHashMap * fix review suggestions * split back Peerset and PeersetHandle * test for Peerset::discovered * applied review suggestions * fixes to peerset::incoming * peerset disconnects are all instantaneous * instantaneous drop in peerset finished * Peerset::set_reserved_only can also reconnect nodes * Peerset scores cache uses lru-cache * remove redundant function call and comment from Peerset::on_set_reserved_only * add_peer returns SlotState enum * apply review suggestions * is_reserved -> is_connected_and_reserved * Fix state inconsistency between handler and behaviour (#2220) * Fix state inconsistency between handler and behaviour * Fix the error! being in the wrong place * Apply negative rating on explicit ban (#2247) * Apply negative rating on explicit ban * Update core/network/src/service.rs Co-Authored-By: arkpar <[email protected]>
* Send high-level consensus telemetry by default * Notify telemetry on finalized * Send used authority set to telemetry * Do not send commit message telemetry by default * Fix typo * Allow for notifications on telemetry connect ...and send the current authority set on each connect. * Send authority set to telemetry on change * Revert "Send used authority set to telemetry" This reverts commit 1deceea. * Merge branch 'master' into 'cmichi-send-high-level-consensus-telemetry-by-default' Squashed commit of the following: commit 6de583a Author: Xiliang Chen <[email protected]> Date: Wed Apr 10 20:26:29 2019 +1200 update authers for rest of the node-template cargo.toml files (#2242) commit 5240bc1 Author: Bastian Köcher <[email protected]> Date: Tue Apr 9 10:31:18 2019 +0200 Throw a compile error for `on_finalise` and `on_initialise` (#2236) commit 67d2e71 Author: Pierre Krieger <[email protected]> Date: Tue Apr 9 05:30:43 2019 -0300 Add warning when using default protocol ID (#2234) * Add warning when using default protocol ID * Update core/service/src/lib.rs commit 1421fed Author: Xiliang Chen <[email protected]> Date: Tue Apr 9 17:22:20 2019 +1200 update name and authors to placeholder text for node-template (#2222) * update name and authors to placeholder text * revert package name change commit 6617f23 Author: André Silva <[email protected]> Date: Mon Apr 8 12:50:34 2019 +0100 grandpa: Voter persistence and upgrade to finality-grandpa v0.7 (#2139) * core: grandpa: migrate to grandpa 0.7 * core: grandpa: store current round votes and load them on startup * core: grandpa: resend old persisted votes for the current round * core: grandpa: store base and votes for last completed round * core: grandpa: fix latest grandpa 0.7 changes * core: grandpa: update to grandpa 0.7.1 * core: grandpa: persist votes for last two completed rounds * core: grandpa: simplify VoterSetState usage * core: grandpa: use Environment::update_voter_set_state * core: grandpa: fix aux_schema test * core: grandpa: add docs * core: grandpa: add note about environment assumption * core: grandpa: don't update voter set state on ignored votes * core: grandpa: add test for v1 -> v2 aux_schema migration * core: grandpa: add test for voter vote persistence * core: grandpa: use grandpa 0.7.1 from crates.io * core: grandpa: use try_init in test * core: grandpa: add comment about block_import in test * core: grandpa: avoid cloning HasVoted * core: grandpa: add missing docs * core: grandpa: cleanup up can_propose/prevote/precommit commit 21e0877 Author: Gregory Terzian <[email protected]> Date: Mon Apr 8 13:17:00 2019 +0200 remove clone bound on specialization in testnet factory (#2157) commit 7c64746 Author: Andrew Jones <[email protected]> Date: Sat Apr 6 12:23:56 2019 +0100 Contract import/export validation (#2203) * Reject validation of contract with unknown exports * Validate imports eagerly * Increment spec version commit 12718fa Author: Pierre Krieger <[email protected]> Date: Fri Apr 5 14:07:09 2019 -0300 Fix state inconsistency between handler and behaviour (#2220) * Fix state inconsistency between handler and behaviour * Fix the error! being in the wrong place commit f917d12 Author: Bastian Köcher <[email protected]> Date: Fri Apr 5 18:50:38 2019 +0200 Use `storage_root` of newly calculated header (#2216) Instead of calculating the `storage_root` a second time, we just can take the `storage_root` from the new header. commit 3359ce0 Author: Marek Kotewicz <[email protected]> Date: Fri Apr 5 14:44:46 2019 +0200 Peerset::discovered accepts many peer ids (#2213) * Peerset::discovered accepts many peer ids * Improve tracing in peerset commit dd82e0e Author: Marek Kotewicz <[email protected]> Date: Thu Apr 4 19:40:40 2019 +0200 simplification of peerset api (#2123) * Introduction of PeersetHandle * integrate PeersetHandle with the rest of the codebase * fix compilation errors * more tests for peerset, fixed overwriting bug in add_reserved_peer * Slots data structure and bugfixes for peerset * bend to pressure * updated lru-cache to 0.1.2 and updated linked-hash-map to 0.5.2 * peerset discovered list is now a LinkedHashMap * fix review suggestions * split back Peerset and PeersetHandle * test for Peerset::discovered * applied review suggestions * fixes to peerset::incoming * peerset disconnects are all instantaneous * instantaneous drop in peerset finished * Peerset::set_reserved_only can also reconnect nodes * Peerset scores cache uses lru-cache * remove redundant function call and comment from Peerset::on_set_reserved_only * add_peer returns SlotState enum * apply review suggestions * is_reserved -> is_connected_and_reserved commit d90833d Author: Arkadiy Paronyan <[email protected]> Date: Thu Apr 4 18:01:28 2019 +0200 Disconnect on protocol timeout (#2212) commit c0a46b5 Author: André Silva <[email protected]> Date: Thu Apr 4 15:56:49 2019 +0100 core: grandpa: verify commit target in justification (#2201) commit 3a4901a Author: Bastian Köcher <[email protected]> Date: Thu Apr 4 16:56:16 2019 +0200 Introduce `original_storage` and `original_storage_hash` (#2211) Both functions will ignore any overlayed changes and access the backend directly. commit a7a469f Author: Xiliang Chen <[email protected]> Date: Fri Apr 5 03:55:55 2019 +1300 code cleanup (#2206) commit 26c7b44 Author: Arkadiy Paronyan <[email protected]> Date: Wed Apr 3 15:52:46 2019 +0200 Emberic elm testnet (#2197) * Make telemetry onconnect hoook optional * Merge branch 'master' into 'cmichi-send-high-level-consensus-telemetry-by-default' * Introduce GrandpaParams struct to condense parameters * Remove debug statement * Fix tests * Rename parameter * Fix tests * Rename struct * Do not send verbosity level * Combine imports * Implement comments * Run cargo build --all * Remove noisy telemetry * Add docs for public items * Unbox and support Clone trait * Fix merge * Fix merge * Update core/finality-grandpa/src/lib.rs Co-Authored-By: cmichi <[email protected]>
* Send high-level consensus telemetry by default * Notify telemetry on finalized * Send used authority set to telemetry * Do not send commit message telemetry by default * Fix typo * Allow for notifications on telemetry connect ...and send the current authority set on each connect. * Send authority set to telemetry on change * Revert "Send used authority set to telemetry" This reverts commit 1deceea. * Merge branch 'master' into 'cmichi-send-high-level-consensus-telemetry-by-default' Squashed commit of the following: commit 6de583a Author: Xiliang Chen <[email protected]> Date: Wed Apr 10 20:26:29 2019 +1200 update authers for rest of the node-template cargo.toml files (paritytech#2242) commit 5240bc1 Author: Bastian Köcher <[email protected]> Date: Tue Apr 9 10:31:18 2019 +0200 Throw a compile error for `on_finalise` and `on_initialise` (paritytech#2236) commit 67d2e71 Author: Pierre Krieger <[email protected]> Date: Tue Apr 9 05:30:43 2019 -0300 Add warning when using default protocol ID (paritytech#2234) * Add warning when using default protocol ID * Update core/service/src/lib.rs commit 1421fed Author: Xiliang Chen <[email protected]> Date: Tue Apr 9 17:22:20 2019 +1200 update name and authors to placeholder text for node-template (paritytech#2222) * update name and authors to placeholder text * revert package name change commit 6617f23 Author: André Silva <[email protected]> Date: Mon Apr 8 12:50:34 2019 +0100 grandpa: Voter persistence and upgrade to finality-grandpa v0.7 (paritytech#2139) * core: grandpa: migrate to grandpa 0.7 * core: grandpa: store current round votes and load them on startup * core: grandpa: resend old persisted votes for the current round * core: grandpa: store base and votes for last completed round * core: grandpa: fix latest grandpa 0.7 changes * core: grandpa: update to grandpa 0.7.1 * core: grandpa: persist votes for last two completed rounds * core: grandpa: simplify VoterSetState usage * core: grandpa: use Environment::update_voter_set_state * core: grandpa: fix aux_schema test * core: grandpa: add docs * core: grandpa: add note about environment assumption * core: grandpa: don't update voter set state on ignored votes * core: grandpa: add test for v1 -> v2 aux_schema migration * core: grandpa: add test for voter vote persistence * core: grandpa: use grandpa 0.7.1 from crates.io * core: grandpa: use try_init in test * core: grandpa: add comment about block_import in test * core: grandpa: avoid cloning HasVoted * core: grandpa: add missing docs * core: grandpa: cleanup up can_propose/prevote/precommit commit 21e0877 Author: Gregory Terzian <[email protected]> Date: Mon Apr 8 13:17:00 2019 +0200 remove clone bound on specialization in testnet factory (paritytech#2157) commit 7c64746 Author: Andrew Jones <[email protected]> Date: Sat Apr 6 12:23:56 2019 +0100 Contract import/export validation (paritytech#2203) * Reject validation of contract with unknown exports * Validate imports eagerly * Increment spec version commit 12718fa Author: Pierre Krieger <[email protected]> Date: Fri Apr 5 14:07:09 2019 -0300 Fix state inconsistency between handler and behaviour (paritytech#2220) * Fix state inconsistency between handler and behaviour * Fix the error! being in the wrong place commit f917d12 Author: Bastian Köcher <[email protected]> Date: Fri Apr 5 18:50:38 2019 +0200 Use `storage_root` of newly calculated header (paritytech#2216) Instead of calculating the `storage_root` a second time, we just can take the `storage_root` from the new header. commit 3359ce0 Author: Marek Kotewicz <[email protected]> Date: Fri Apr 5 14:44:46 2019 +0200 Peerset::discovered accepts many peer ids (paritytech#2213) * Peerset::discovered accepts many peer ids * Improve tracing in peerset commit dd82e0e Author: Marek Kotewicz <[email protected]> Date: Thu Apr 4 19:40:40 2019 +0200 simplification of peerset api (paritytech#2123) * Introduction of PeersetHandle * integrate PeersetHandle with the rest of the codebase * fix compilation errors * more tests for peerset, fixed overwriting bug in add_reserved_peer * Slots data structure and bugfixes for peerset * bend to pressure * updated lru-cache to 0.1.2 and updated linked-hash-map to 0.5.2 * peerset discovered list is now a LinkedHashMap * fix review suggestions * split back Peerset and PeersetHandle * test for Peerset::discovered * applied review suggestions * fixes to peerset::incoming * peerset disconnects are all instantaneous * instantaneous drop in peerset finished * Peerset::set_reserved_only can also reconnect nodes * Peerset scores cache uses lru-cache * remove redundant function call and comment from Peerset::on_set_reserved_only * add_peer returns SlotState enum * apply review suggestions * is_reserved -> is_connected_and_reserved commit d90833d Author: Arkadiy Paronyan <[email protected]> Date: Thu Apr 4 18:01:28 2019 +0200 Disconnect on protocol timeout (paritytech#2212) commit c0a46b5 Author: André Silva <[email protected]> Date: Thu Apr 4 15:56:49 2019 +0100 core: grandpa: verify commit target in justification (paritytech#2201) commit 3a4901a Author: Bastian Köcher <[email protected]> Date: Thu Apr 4 16:56:16 2019 +0200 Introduce `original_storage` and `original_storage_hash` (paritytech#2211) Both functions will ignore any overlayed changes and access the backend directly. commit a7a469f Author: Xiliang Chen <[email protected]> Date: Fri Apr 5 03:55:55 2019 +1300 code cleanup (paritytech#2206) commit 26c7b44 Author: Arkadiy Paronyan <[email protected]> Date: Wed Apr 3 15:52:46 2019 +0200 Emberic elm testnet (paritytech#2197) * Make telemetry onconnect hoook optional * Merge branch 'master' into 'cmichi-send-high-level-consensus-telemetry-by-default' * Introduce GrandpaParams struct to condense parameters * Remove debug statement * Fix tests * Rename parameter * Fix tests * Rename struct * Do not send verbosity level * Combine imports * Implement comments * Run cargo build --all * Remove noisy telemetry * Add docs for public items * Unbox and support Clone trait * Fix merge * Fix merge * Update core/finality-grandpa/src/lib.rs Co-Authored-By: cmichi <[email protected]>
ArcorMutexin apeersetmodulePeersettoPeersetHandlePeersetMuttoPeersetlinked_hash_mapcrate to0.5.2add_reserved_peeralloc_slotsifreserved_onlyis setset_reserved_only(false)tries to reconnect us to not reserved nodesremove_reserved_peerdisconnects us from the peer ifreserved_only = trueincomingaccepts connections only fromreserved peersin discovered queue inreserved_only = true