Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Conversation

@rphmeier
Copy link
Contributor

  1. Allow gossip validators to specify that a message is not currently possible to check. This message will be kept and re-checked when a stream for that topic is requested
  2. gossip validators get a separate function for checking expired messages. this avoids re-doing other validation work like signature verification when collecting garbage
  3. Topic streams are localized to engine ID to avoid collisions.

@rphmeier rphmeier added A0-please_review Pull request needs code review. B0-patchthis labels Feb 27, 2019
#[test]
fn collects_garbage() {

struct AllowAll;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation is off now

@arkpar
Copy link
Member

arkpar commented Feb 27, 2019

Shouldn't GRANDPA validator re-implement message_expired for efficiency?

fn validate(&self, data: &[u8]) -> ValidationResult<H>;

/// Produce a closure for validating messages on a given topic.
fn message_expired<'a>(&'a self) -> Box<FnMut(H, &[u8]) -> bool + 'a> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why return a closure instead of just calling the method directly like we do for validate?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my intuition was that this can get called with a lot of topic messages at once, so the closure lets us hold locks

} else if set_id == self.set_id + 1 {
// allow a few first rounds of future set.
if round > MESSAGE_ROUND_TOLERANCE {
trace!(target: "afg", "Expired: Message too far in the future set, round {} (ours set_id {})", round, self.set_id);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we tag messages within the tolerance as Future?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so, because we have enough information to validate them

}
} else if set_id == self.set_id {
if round < self.min_live_round.saturating_sub(MESSAGE_ROUND_TOLERANCE) {
trace!(target: "afg", "Expired: Message round is out of bounds {} (ours {}-{})", round, self.min_live_round, self.max_round);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

/// Message is valid with this topic.
Valid(H),
/// Message is future with this topic.
Future(H),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not separate this into ValidationResult { Valid, Invalid } and ExpirationResult { Live, Expired, Future }? This would make sure that the interface we provide always starts by checking expiration, and only calls validate once which presumably might do heavier checks.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the current usage of validate in GRANDPA it doesn't make a difference since it always starts by doing the expiration checks, but I think it would make the interface cleaner.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I agree, but could we file a follow-up for that?)

@gavofyork gavofyork merged commit b358f9d into master Feb 28, 2019
@gavofyork gavofyork deleted the rh-gossip-improvements branch February 28, 2019 19:19
rphmeier added a commit that referenced this pull request Feb 28, 2019
* queue messages in future

* use new gossip API in GRANDPA

* implement message_expired for grandpa

* fix indent
rphmeier added a commit that referenced this pull request Feb 28, 2019
* Telemetry improvements (#1886)

* Fix typo

* Support multiple telemetry endpoints and verbosity levels

* Bump substrate-telemetry version

* Telemetrify Aura consensus

* Telemetrify Grandpa

* Fix CI version conflicts

* Implement style remarks

* Fix fixture

* Implement style remarks

* Clone only when necessary

* Get rid of Arc for URL

* Handle connection issues better

* fixed instant finalization of genesis block on light client (#1898)

* Some gossip improvements (#1892)

* queue messages in future

* use new gossip API in GRANDPA

* implement message_expired for grandpa

* fix indent
MTDK1 pushed a commit to bdevux/substrate that referenced this pull request Apr 12, 2019
* queue messages in future

* use new gossip API in GRANDPA

* implement message_expired for grandpa

* fix indent
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

A0-please_review Pull request needs code review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants