-
Notifications
You must be signed in to change notification settings - Fork 721
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Publish last accepted height through chits #3441
Conversation
d43011a
to
9dcbac5
Compare
769e509
to
d1c2d4a
Compare
5b80f79
to
04d5dfe
Compare
04d5dfe
to
f84c5a2
Compare
snow/engine/snowman/engine_test.go
Outdated
@@ -444,7 +445,7 @@ func TestEngineMultipleQuery(t *testing.T) { | |||
require.NoError(te.Put(context.Background(), vdr0, *getRequestID, blk1.Bytes())) | |||
|
|||
// Should be dropped because the query was already filled | |||
require.NoError(te.Chits(context.Background(), vdr2, *queryRequestID, blk0.ID(), blk0.ID(), blk0.ID())) | |||
require.NoError(te.Chits(context.Background(), vdr2, *queryRequestID, blk0.ID(), blk0.ID(), blk0.ID(), 42)) |
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 we use blk0.Height()
here since we expect the blkID and height to come from the same block? We should handle a malicious response, but I'd prefer that we use the expected response unless the test is meant to test a malicious response.
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.
done
This commit adds the last accepted height to the Chits message. The intention is that by receiving the latest accepted height of each node, a node can know whether it is straggling behind the majority of the nodes in the chain. I ran a build with the commit on a Fuji testnet node and verified the log matches the commit. ``` [10-02|19:59:48.312] VERBO <P Chain> snowman/engine.go:362 called Chits for the block {"nodeID": "NodeID-1AFBjE7UUM1AWWA1HtMGreRrvKwTh9Su", "requestID": 335, "preferredID": "zmoZ2RPy2mkx1ozSbhen9Ggh9boTewBCa6bgc5FnQu7d2umrf", "preferredIDAtHeight": "zmoZ2RPy2mkx1ozSbhen9Ggh9boTewBCa6bgc5FnQu7d2umrf", "acceptedID": "zmoZ2RPy2mkx1ozSbhen9Ggh9boTewBCa6bgc5FnQu7d2umrf", "acceptedHeight": 0} ``` Also verified on its grafana dashboard that it participates in consensus and that there are no failing health checks. Signed-off-by: Yacov Manevich <[email protected]>
f84c5a2
to
f499876
Compare
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.
Few nits and then this LGTM
snow/engine/snowman/engine_test.go
Outdated
@@ -2926,6 +2938,7 @@ func TestEngineRegistersInvalidVoterDependencyRegression(t *testing.T) { | |||
acceptedChain[1].ID(), | |||
acceptedChain[1].ID(), | |||
snowmantest.GenesisID, | |||
acceptedChain[1].Height(), |
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 this be 0
to match snowmantest.GenesisID
?
snow/engine/snowman/engine_test.go
Outdated
@@ -2907,6 +2918,7 @@ func TestEngineRegistersInvalidVoterDependencyRegression(t *testing.T) { | |||
rejectedChain[1].ID(), | |||
rejectedChain[1].ID(), | |||
snowmantest.GenesisID, | |||
rejectedChain[1].Height(), |
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 this be 0
to match snowmantest.GenesisID
?
snow/engine/snowman/engine_test.go
Outdated
@@ -2882,6 +2892,7 @@ func TestEngineRegistersInvalidVoterDependencyRegression(t *testing.T) { | |||
acceptedChain[0].ID(), | |||
acceptedChain[0].ID(), | |||
snowmantest.GenesisID, | |||
acceptedChain[0].Height(), |
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 this be 0
to match snowmantest.GenesisID
?
snow/engine/snowman/engine_test.go
Outdated
vm.ParseBlockF = func(_ context.Context, _ []byte) (snowman.Block, error) { | ||
return &snowmantest.Block{HeightV: 41}, nil |
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 are we overriding ParseBlockF
to return a mocked block w/ height 41 instead of the genesis' child block as in the previous version of this test?
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 modified the test because I thought it would be less trivial than it is now. I reverted it.
snow/engine/snowman/engine_test.go
Outdated
blk1 := snowmantest.BuildChild(snowmantest.Genesis) | ||
|
||
blk2 := snowmantest.BuildChild(blk1) |
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.
Can we use snowmantest.BuildDescendants
instead of calling BuildChild
twice?
Signed-off-by: Yacov Manevich <[email protected]>
} | ||
|
||
func (*accepted) OnValidatorWeightChanged(_ ids.NodeID, _, _ uint64) {} | ||
|
||
func (a *accepted) SetLastAccepted(nodeID ids.NodeID, frontier ids.ID) { | ||
func (a *accepted) SetLastAccepted(nodeID ids.NodeID, frontier ids.ID, height uint64) { |
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.
nit: should we rename frontier
to blockID
or just 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.
id
it is!
Signed-off-by: Yacov Manevich <[email protected]>
Why this should be merged
In order for a node to know whether it's straggling behind the majority of the chain validator nodes,
the simplest and most effective way is for nodes to publish their latest accepted height as part of the p2p protocol.
How this works
This commit adds the last accepted height to the Chits message. Then, the
acceptedFrontiers
indexes this information alongside the latest acceptedID
.How this was tested
I ran a build with the commit on a Fuji testnet node and verified the log matches the commit.
Also verified on its grafana dashboard that it participates in consensus and that there are no failing health checks.