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

More extractions from the Protocol struct#2641

Merged
tomaka merged 10 commits into
paritytech:masterfrom
tomaka:more-protocol-extract
May 23, 2019
Merged

More extractions from the Protocol struct#2641
tomaka merged 10 commits into
paritytech:masterfrom
tomaka:more-protocol-extract

Conversation

@tomaka

@tomaka tomaka commented May 21, 2019

Copy link
Copy Markdown
Contributor

Removes the transaction_pool, finality_proof_provider and connected_peers fields from Protocol.
Same goal as usual: trying to remove everything that's not fully deterministic from Protocol.

@tomaka tomaka added the A0-please_review Pull request needs code review. label May 21, 2019
@tomaka tomaka requested review from arkpar and gterzian May 21, 2019 11:55
@tomaka tomaka force-pushed the more-protocol-extract branch from a181d45 to 597d45c Compare May 21, 2019 12:07
}

match protocol.poll(&mut Ctxt(&mut network_service.lock(), &peerset)) {
while let Ok(Async::Ready(_)) = connected_peers_interval.poll() {

@gterzian gterzian May 22, 2019

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

As noted with the updating of is_offline and is_major_syncing, peers was previously only updated when something changed, now it will be updated every interval, whether something changed or not.

Unlike these other two fields, which are updated at each poll of the future returned by run_thread(I think), the interval could actually introduce some delays in the updating in some cases. I think this potentially could introduce problems, since whoever uses peers could still see peers which would have already been removed from ContextData. This could be made worse if anything ends-up blocking the networking runtime, since the interval could turn out to be longer than intended.

So if you must move this logic out of protocol, perhaps also for now update peers at each turn of run_thread?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ah yeah, I went for this because peers() is only ever used to answer an RPC query for diagnostic purposes, where it really doesn't matter if you're 500ms late.

It's probably worth adding a comment about that, though.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

In the last commit I also renamed peers() to peers_debug_info() in order to make it clearer.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Good idea.

@gterzian gterzian left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks like the tests just need an update in the light of the last commit...

@gterzian

Copy link
Copy Markdown
Contributor

Are the changes to the wasm lock files intentional?

@tomaka

tomaka commented May 23, 2019

Copy link
Copy Markdown
Contributor Author

Running the WASM build scripts updates the Cargo.locks, but since I guess it's out of scope, I reverted that.

@gterzian

Copy link
Copy Markdown
Contributor

Failures on CI appear unrelated, with the tests fixed(and 2 existing approvals), I think it's ready to merge...

@tomaka tomaka merged commit 2fcf061 into paritytech:master May 23, 2019
@tomaka tomaka deleted the more-protocol-extract branch May 23, 2019 10:07
MTDK1 pushed a commit to bdevux/substrate that referenced this pull request Jul 10, 2019
* Pass the TransactionPool explicitly

* Extract finality_proof_provider

* Remove Protocol::connected_peers

* Add note and rename function

* Fix tests

* More test fixing

* Revert the WASM locks, I guess

* Add space

* Remove space
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.

3 participants