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

proposer: wait for a hash to be in the active-leaves set #1616

Merged
11 commits merged into from
Aug 20, 2020

Conversation

ordian
Copy link
Member

@ordian ordian commented Aug 19, 2020

Fixes #1483.

This solution feels hacky to me, so I'd like to hear your thoughts on this.

I don't know why active_leaves was defined as a HashMap<Hash, BlockNumber> and if there are any downsides to making it a HashMap.

@ordian ordian added A3-in_progress Pull request is in progress. No review needed at this stage. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. labels Aug 19, 2020
@ordian ordian requested review from coriolinus and montekki and removed request for coriolinus August 19, 2020 16:48
@ordian ordian changed the title proposer: wait for a hash to be with active leaves set proposer: wait for a hash to be in the active-leaves set Aug 19, 2020
Copy link
Contributor

@coriolinus coriolinus left a comment

Choose a reason for hiding this comment

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

This isn't yet ready, but it seems a plausible direction to take things. My biggest concern right now is ensuring that activaion_external_listeners never experiences unbounded growth, which it currently does.

node/overseer/src/lib.rs Outdated Show resolved Hide resolved
node/overseer/src/lib.rs Outdated Show resolved Hide resolved
node/overseer/src/lib.rs Outdated Show resolved Hide resolved
node/overseer/src/lib.rs Outdated Show resolved Hide resolved
node/overseer/src/lib.rs Outdated Show resolved Hide resolved
}

self.clean_up_external_listeners();
Copy link
Member Author

Choose a reason for hiding this comment

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

the only downside to this is if a lot of hashes are interesting so this is slow, or if block importing stopped for some reason, but both scenarios seem unlikely

Copy link
Contributor

Choose a reason for hiding this comment

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

Agree.

@coriolinus
Copy link
Contributor

coriolinus commented Aug 20, 2020

@ordian I no longer need to request changes, but I note that this hasn't yet been marked as ready for review. Would you like me to approve it now, or did you have further work in mind before calling this complete?

@ordian
Copy link
Member Author

ordian commented Aug 20, 2020

@ordian I no longer need to request changes, but I note that this hasn't yet been marked as ready for review. Would you like me to approve it now, or did you have further work in mind before calling this complete?

I was trying to add a test before making the PR as "ready for review", but it seems tricky w/o the ability to inspect overseer's internal state, so I'll omit it unless you have suggestions.

@ordian ordian marked this pull request as ready for review August 20, 2020 12:47
@ordian ordian added A0-please_review Pull request needs code review. and removed A3-in_progress Pull request is in progress. No review needed at this stage. labels Aug 20, 2020
@coriolinus
Copy link
Contributor

Tests are always nice. One technique I've seen used for unit testing purposes is to write a method like this:

#[cfg(test)]
pub fn activation_external_listeners(&self) -> HashMap<_, _> { ... }

which exposes the internal state, but only when compiled in test mode.

I'll leave it to you whether to write some tests using a feature like that; I am willing to approve the PR in its current state.

@ordian
Copy link
Member Author

ordian commented Aug 20, 2020

Tests are always nice. One technique I've seen used for unit testing purposes is to write a method like this:

#[cfg(test)]
pub fn activation_external_listeners(&self) -> HashMap<_, _> { ... }

which exposes the internal state, but only when compiled in test mode.

I'll leave it to you whether to write some tests using a feature like that; I am willing to approve the PR in its current state.

the problem is that overseer.run consumes overseer, other workarounds are unfortunate, so I'll leave it as is for now

let me know what you think about adding debug_assertions : #1616 (comment)

* master:
  Companion for Substrate #6815 (Dynamic Whitelist) (#1612)
  Candidate backing respects scheduled collator (#1613)
  implementers-guide: in TOC move collators before backing, to match protocol pipeline (#1611)
  Initial guide text for approvals and especially approvals assignments  (#1518)
  Implement validation data refactor (#1585)
  Implementer's Guide: Make HRMP use upward message kinds (#1591)
@ordian
Copy link
Member Author

ordian commented Aug 20, 2020

Thanks for the review and quick replies!

Copy link
Contributor

@rphmeier rphmeier left a comment

Choose a reason for hiding this comment

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

Seems like there would be a memory leak if i requested to wait for a hash of a block that will never be in the active-leaves set.

@ordian
Copy link
Member Author

ordian commented Aug 20, 2020

Seems like there would be a memory leak if i requested to wait for a hash of a block that will never be in the active-leaves set.

this is handled by assuming the caller handles timeouts and will drop the receiver (this is needed also in case the a hash is deactivated before subscription) - this is documented, so we will clean it up on block_imported

@ordian
Copy link
Member Author

ordian commented Aug 20, 2020

bot merge

@ghost
Copy link

ghost commented Aug 20, 2020

Trying merge.

@ghost ghost merged commit 08f4be7 into master Aug 20, 2020
@ghost ghost deleted the ao-sync-proposer-with-active-leaves-set branch August 20, 2020 13:43
This pull request was closed.
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. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ensure the proposer doesn't race against overseer's StartWork message
3 participants