Skip to content
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

Merged
merged 3 commits into from
Oct 3, 2024

Conversation

yacovm
Copy link
Contributor

@yacovm yacovm commented Oct 2, 2024

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 accepted ID.

How this was tested

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.

@yacovm yacovm marked this pull request as draft October 2, 2024 17:52
@yacovm yacovm changed the title Publish last accepted ID through chits Publish last accepted height through chits Oct 2, 2024
@yacovm yacovm force-pushed the accepted_height branch 2 times, most recently from 769e509 to d1c2d4a Compare October 2, 2024 20:07
@yacovm yacovm self-assigned this Oct 2, 2024
@yacovm yacovm marked this pull request as ready for review October 2, 2024 20:12
@yacovm yacovm force-pushed the accepted_height branch 3 times, most recently from 5b80f79 to 04d5dfe Compare October 2, 2024 20:46
snow/engine/common/tracker/accepted.go Outdated Show resolved Hide resolved
snow/engine/snowman/engine_test.go Outdated Show resolved Hide resolved
@@ -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))
Copy link
Collaborator

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.

Copy link
Contributor Author

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]>
Copy link
Collaborator

@aaronbuchwald aaronbuchwald left a 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

@@ -2926,6 +2938,7 @@ func TestEngineRegistersInvalidVoterDependencyRegression(t *testing.T) {
acceptedChain[1].ID(),
acceptedChain[1].ID(),
snowmantest.GenesisID,
acceptedChain[1].Height(),
Copy link
Collaborator

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 ?

@@ -2907,6 +2918,7 @@ func TestEngineRegistersInvalidVoterDependencyRegression(t *testing.T) {
rejectedChain[1].ID(),
rejectedChain[1].ID(),
snowmantest.GenesisID,
rejectedChain[1].Height(),
Copy link
Collaborator

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 ?

@@ -2882,6 +2892,7 @@ func TestEngineRegistersInvalidVoterDependencyRegression(t *testing.T) {
acceptedChain[0].ID(),
acceptedChain[0].ID(),
snowmantest.GenesisID,
acceptedChain[0].Height(),
Copy link
Collaborator

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 ?

Comment on lines 554 to 555
vm.ParseBlockF = func(_ context.Context, _ []byte) (snowman.Block, error) {
return &snowmantest.Block{HeightV: 41}, nil
Copy link
Collaborator

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?

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 modified the test because I thought it would be less trivial than it is now. I reverted it.

Comment on lines 3264 to 3266
blk1 := snowmantest.BuildChild(snowmantest.Genesis)

blk2 := snowmantest.BuildChild(blk1)
Copy link
Collaborator

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]>
@StephenButtolph StephenButtolph added the consensus This involves consensus label Oct 3, 2024
@StephenButtolph StephenButtolph added this to the v1.11.12 milestone Oct 3, 2024
}

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) {
Copy link
Contributor

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?

Copy link
Contributor Author

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]>
@StephenButtolph StephenButtolph added this pull request to the merge queue Oct 3, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Oct 3, 2024
@StephenButtolph StephenButtolph added this pull request to the merge queue Oct 3, 2024
Merged via the queue into ava-labs:master with commit 0e96538 Oct 3, 2024
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
consensus This involves consensus
Projects
Status: Done ✅
Development

Successfully merging this pull request may close these issues.

4 participants