Skip to content

evidence: p2p refactor#5747

Merged
alexanderbez merged 43 commits intomasterfrom
bez/p2p-refactor-evidence-reactor
Jan 6, 2021
Merged

evidence: p2p refactor#5747
alexanderbez merged 43 commits intomasterfrom
bez/p2p-refactor-evidence-reactor

Conversation

@alexanderbez
Copy link
Contributor

@alexanderbez alexanderbez commented Dec 4, 2020

Description

Prepares the evidence reactor for the newly designed p2p changes per ADR 062.

ref: #5670

Base automatically changed from bez/p2p-refactor-state-sync-reactor to master December 9, 2020 14:31
@alexanderbez alexanderbez force-pushed the bez/p2p-refactor-evidence-reactor branch from 22d70ec to 341893a Compare December 9, 2020 15:52
// down or removed peers, it will check if an evidence broadcasting goroutine
// exists and signal that it should exit.
//
// FIXME: The peer may be behind in which case it would simply ignore the
Copy link
Contributor Author

Choose a reason for hiding this comment

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

/cc @cmwaters :)

@@ -49,10 +49,9 @@ type Pool struct {
// NewPool creates an evidence pool. If using an existing evidence store,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This file diff contains linting updates only.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the heads-up! 😅

@alexanderbez
Copy link
Contributor Author

alexanderbez commented Dec 14, 2020

I've attempted to leave the existing reactor's semantics unchanged as much as possible, however, since we no longer have access to peers directly, only their IDs, we cannot know of their height or if they're caught up or not.

Thus, the main change in semantics this PR introduces currently is that evidence will always be sent to a peer regardless if the recipient peer is able to accept/process that evidence or not. Whereas, the old semantics in this context would just simply not gossip the evidence at all.

This results in the fact that we now send more messages over the wire. This yields the need for discussion around shared state, particularly around peers between reactors. However, this is a topic that should not block this PR and we can revisit it later.

@codecov
Copy link

codecov bot commented Dec 15, 2020

Codecov Report

Merging #5747 (289e848) into master (9b9222f) will increase coverage by 0.21%.
The diff coverage is 69.38%.

@@            Coverage Diff             @@
##           master    #5747      +/-   ##
==========================================
+ Coverage   59.98%   60.20%   +0.21%     
==========================================
  Files         263      263              
  Lines       23858    23938      +80     
==========================================
+ Hits        14312    14411      +99     
+ Misses       8021     8006      -15     
+ Partials     1525     1521       -4     
Impacted Files Coverage Δ
evidence/pool.go 65.16% <51.06%> (+0.87%) ⬆️
evidence/verify.go 67.27% <56.36%> (-1.67%) ⬇️
statesync/reactor.go 56.35% <66.66%> (+1.77%) ⬆️
evidence/reactor.go 72.88% <72.64%> (+18.88%) ⬆️
p2p/key.go 71.42% <75.00%> (-5.32%) ⬇️
libs/protoio/reader.go 85.18% <76.47%> (+0.18%) ⬆️
node/node.go 58.29% <78.12%> (+0.21%) ⬆️
abci/types/messages.go 7.69% <100.00%> (ø)
libs/os/os.go 37.93% <100.00%> (+2.63%) ⬆️
libs/protoio/io.go 44.44% <100.00%> (+3.26%) ⬆️
... and 20 more

@alexanderbez alexanderbez marked this pull request as ready for review December 15, 2020 16:19
@github-actions
Copy link

github-actions bot commented Jan 4, 2021

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale for use by stalebot label Jan 4, 2021
@alexanderbez alexanderbez removed the stale for use by stalebot label Jan 4, 2021
@alexanderbez
Copy link
Contributor Author

bump @erikgrinaker

p2p/key.go Outdated
type NodeID string

// NewNodeID returns a lowercased (normalized) NodeID.
func NewNodeID(nodeID string) NodeID {
Copy link
Contributor

@erikgrinaker erikgrinaker Jan 6, 2021

Choose a reason for hiding this comment

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

This should call Validate() as well, to make sure it's actually valid, and Validate() should check that it's lowercased (since callers may not be using NewNodeID, e.g. if it's received via Protobuf).

We should possibly have a Normalize() method as well, which can be called on already-typed strings received from external sources.

Copy link
Contributor Author

@alexanderbez alexanderbez Jan 6, 2021

Choose a reason for hiding this comment

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

Why would this call Validate if it is doing the normalizing. If anything, we should just have NewNodeID and Normalize, where the former calls the latter. Also, we could have a Validate function too.

Copy link
Contributor

@erikgrinaker erikgrinaker Jan 6, 2021

Choose a reason for hiding this comment

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

Because it needs to e.g. check that it's actually a valid hex string, not just some random garbage.

NodeID can be embedded in structs, and these structs can be received via the network (e.g. from Protobuf handshakes), so we may want to have Validate() and/or Normalize() to handle this. I believe we also have some existing P2P code from the old stack that relies on Validate().

Ideally we should be able to enforce this as an invariant, but the Go type system doesn't allow this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, yeah I think having NewNodeID ensure input is a valid hex-string and then lower-case should suffice. We'll have a validate function as well.

@alexanderbez alexanderbez merged commit e986602 into master Jan 6, 2021
@alexanderbez alexanderbez deleted the bez/p2p-refactor-evidence-reactor branch January 6, 2021 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C:evidence Component: Evidence

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants