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

Remove lists from Chits messages #1412

Merged
merged 29 commits into from
Jun 2, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
5a1bdb3
If the network is not fuji or mainnet linearize on init
StephenButtolph Mar 20, 2023
f6d6d18
Loop until stop vertex is accepted
StephenButtolph Mar 20, 2023
3c96f9b
If the stop vertex is accepted, transition to snowman bootstrapping
StephenButtolph Mar 20, 2023
9f1f252
merged
StephenButtolph Mar 20, 2023
af9460a
merged
StephenButtolph Apr 13, 2023
75f42a5
wip removing avalanche consensus engine
StephenButtolph Apr 13, 2023
1be3d27
Use require in Avalanche bootstrapping tests
StephenButtolph Apr 13, 2023
9614cec
Merge branch 'cleanup-avalanche-bootstrap-tests' into linearize-on-start
StephenButtolph Apr 13, 2023
853a70c
merged
StephenButtolph Apr 13, 2023
dd8c14f
remove bootstrapping tests from the consensus engine
StephenButtolph Apr 13, 2023
fff4c15
lint
StephenButtolph Apr 13, 2023
83cb219
wip fix tests
StephenButtolph Apr 14, 2023
c56755a
fix tests
StephenButtolph Apr 14, 2023
395e510
Merge branch 'dev' into cleanup-avalanche-bootstrap-tests
StephenButtolph Apr 14, 2023
1d8904b
Merge branch 'cleanup-avalanche-bootstrap-tests' into linearize-on-start
StephenButtolph Apr 14, 2023
50e9ebd
Update metrics
StephenButtolph Apr 14, 2023
ad9b139
Merge branch 'linearize-on-start' of github.com:ava-labs/avalanchego …
StephenButtolph Apr 14, 2023
708b260
remove whitelist vtx tests
StephenButtolph Apr 14, 2023
caa60ba
Remove avalanche consensus
StephenButtolph Apr 15, 2023
5b8ae87
Remove whitelist interface
StephenButtolph Apr 15, 2023
798d62b
Remove more dead code
StephenButtolph Apr 15, 2023
d56f8da
deadcode
StephenButtolph Apr 15, 2023
b113a2b
merged
StephenButtolph Apr 24, 2023
87d0f99
merged
StephenButtolph Apr 24, 2023
06ee7bf
Remove lists from Chits messages
StephenButtolph Apr 24, 2023
869a04a
merged
StephenButtolph Apr 25, 2023
0abb509
Merge branch 'remove-avalanche-consensus' into simplify-chits-message
StephenButtolph Apr 25, 2023
4991f15
merged
StephenButtolph Jun 1, 2023
c824df4
remove old comment
StephenButtolph Jun 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove lists from Chits messages
  • Loading branch information
StephenButtolph committed Apr 24, 2023
commit 06ee7bf40f71fbfd1326b85d43fd38ca446c4361
16 changes: 6 additions & 10 deletions message/inbound_msg_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,22 +243,18 @@ func InboundPullQuery(
func InboundChits(
chainID ids.ID,
requestID uint32,
preferredContainerIDs []ids.ID,
acceptedContainerIDs []ids.ID,
preferredID ids.ID,
acceptedID ids.ID,
nodeID ids.NodeID,
) InboundMessage {
preferredContainerIDBytes := make([][]byte, len(preferredContainerIDs))
encodeIDs(preferredContainerIDs, preferredContainerIDBytes)
acceptedContainerIDBytes := make([][]byte, len(acceptedContainerIDs))
encodeIDs(acceptedContainerIDs, acceptedContainerIDBytes)
return &inboundMessage{
nodeID: nodeID,
op: ChitsOp,
message: &p2p.Chits{
ChainId: chainID[:],
RequestId: requestID,
PreferredContainerIds: preferredContainerIDBytes,
AcceptedContainerIds: acceptedContainerIDBytes,
ChainId: chainID[:],
RequestId: requestID,
PreferredId: preferredID[:],
AcceptedId: acceptedID[:],
},
expiration: mockable.MaxTime,
}
Expand Down
18 changes: 4 additions & 14 deletions message/inbound_msg_builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,8 @@ func TestInboundMsgBuilder(t *testing.T) {
msg := InboundChits(
chainID,
requestID,
containerIDs,
acceptedContainerIDs,
containerIDs[0],
acceptedContainerIDs[0],
nodeID,
)

Expand All @@ -339,18 +339,8 @@ func TestInboundMsgBuilder(t *testing.T) {
require.True(ok)
require.Equal(chainID[:], innerMsg.ChainId)
require.Equal(requestID, innerMsg.RequestId)
containerIDsBytes := make([][]byte, len(containerIDs))
for i, id := range containerIDs {
id := id
containerIDsBytes[i] = id[:]
}
require.Equal(containerIDsBytes, innerMsg.PreferredContainerIds)
acceptedContainerIDsBytes := make([][]byte, len(acceptedContainerIDs))
for i, id := range acceptedContainerIDs {
id := id
acceptedContainerIDsBytes[i] = id[:]
}
require.Equal(acceptedContainerIDsBytes, innerMsg.AcceptedContainerIds)
require.Equal(containerIDs[0][:], innerMsg.PreferredId)
require.Equal(acceptedContainerIDs[0][:], innerMsg.AcceptedId)
},
)

Expand Down
6 changes: 3 additions & 3 deletions message/messages_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -653,9 +653,9 @@ func TestMessage(t *testing.T) {
msg: &p2p.Message{
Message: &p2p.Message_Chits{
Chits: &p2p.Chits{
ChainId: testID[:],
RequestId: 1,
PreferredContainerIds: [][]byte{testID[:], testID[:]},
ChainId: testID[:],
RequestId: 1,
PreferredId: testID[:],
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion message/mock_outbound_message_builder.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 8 additions & 12 deletions message/outbound_msg_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ type OutboundMsgBuilder interface {
Chits(
chainID ids.ID,
requestID uint32,
preferredContainerIDs []ids.ID,
acceptedContainerIDs []ids.ID,
preferredID ids.ID,
acceptedID ids.ID,
) (OutboundMessage, error)

AppRequest(
Expand Down Expand Up @@ -599,21 +599,17 @@ func (b *outMsgBuilder) PullQuery(
func (b *outMsgBuilder) Chits(
chainID ids.ID,
requestID uint32,
preferredContainerIDs []ids.ID,
acceptedContainerIDs []ids.ID,
preferredID ids.ID,
acceptedID ids.ID,
) (OutboundMessage, error) {
preferredContainerIDBytes := make([][]byte, len(preferredContainerIDs))
encodeIDs(preferredContainerIDs, preferredContainerIDBytes)
acceptedContainerIDBytes := make([][]byte, len(acceptedContainerIDs))
encodeIDs(acceptedContainerIDs, acceptedContainerIDBytes)
return b.builder.createOutbound(
&p2p.Message{
Message: &p2p.Message_Chits{
Chits: &p2p.Chits{
ChainId: chainID[:],
RequestId: requestID,
PreferredContainerIds: preferredContainerIDBytes,
AcceptedContainerIds: acceptedContainerIDBytes,
ChainId: chainID[:],
RequestId: requestID,
PreferredId: preferredID[:],
AcceptedId: acceptedID[:],
},
},
},
Expand Down
21 changes: 10 additions & 11 deletions proto/p2p/p2p.proto
Original file line number Diff line number Diff line change
Expand Up @@ -313,23 +313,22 @@ message PullQuery {
EngineType engine_type = 5;
}

// Message that contains the votes/preferences of the local node,
// in response to "push_query" or "pull_query" (e.g., preferred frontier).
// Message that contains the votes/preferences of the node. It is sent in
// response to a "push_query" or "pull_query" request.
//
// On receiving "chits", the engine issues those preferred containers of vertices/blocks
// to the consensus. If the received container is not found, it responds back with
// "get" message to fetch the missing container from the remote peer.
// Upon receiving "chits", the engine will attempt to issue the preferred block
// into consensus. If the referenced block is not locally available, the engine
// will respond with a "get" message to fetch the missing block from the remote
// peer.
message Chits {
reserved 5; // Until Cortina upgrade is activated

bytes chain_id = 1;
uint32 request_id = 2;
// Represents the current preferred frontier.
// TODO: Remove `repeated` once all chains are running Snowman.
repeated bytes preferred_container_ids = 3;
// Represents the current accepted frontier.
// TODO: Remove `repeated` once all chains are running Snowman.
repeated bytes accepted_container_ids = 4;
// Represents the current preferred block.
bytes preferred_id = 3;
// Represents the last accepted block.
bytes accepted_id = 4;
}

message AppRequest {
Expand Down
100 changes: 48 additions & 52 deletions proto/pb/p2p/p2p.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions snow/engine/common/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -390,8 +390,8 @@ type ChitsHandler interface {
ctx context.Context,
validatorID ids.NodeID,
requestID uint32,
preferredContainerIDs []ids.ID,
acceptedContainerIDs []ids.ID,
preferredID ids.ID,
acceptedID ids.ID,
) error

// Notify this engine that a query it issued has failed.
Expand Down
2 changes: 1 addition & 1 deletion snow/engine/common/mock_sender.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion snow/engine/common/no_ops_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,12 +240,14 @@ func NewNoOpChitsHandler(log logging.Logger) ChitsHandler {
return &noOpChitsHandler{log: log}
}

func (nop *noOpChitsHandler) Chits(_ context.Context, nodeID ids.NodeID, requestID uint32, _, _ []ids.ID) error {
func (nop *noOpChitsHandler) Chits(_ context.Context, nodeID ids.NodeID, requestID uint32, preferredID, acceptedID ids.ID) error {
nop.log.Debug("dropping request",
zap.String("reason", "unhandled by this gear"),
zap.Stringer("messageOp", message.ChitsOp),
zap.Stringer("nodeID", nodeID),
zap.Uint32("requestID", requestID),
zap.Stringer("preferredID", preferredID),
zap.Stringer("acceptedID", acceptedID),
)
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion snow/engine/common/sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ type QuerySender interface {
SendPullQuery(ctx context.Context, nodeIDs set.Set[ids.NodeID], requestID uint32, containerID ids.ID)

// Send chits to the specified node
SendChits(ctx context.Context, nodeID ids.NodeID, requestID uint32, votes []ids.ID, accepted []ids.ID)
SendChits(ctx context.Context, nodeID ids.NodeID, requestID uint32, preferredID ids.ID, acceptedID ids.ID)
}

// Gossiper defines how a consensus engine gossips a container on the accepted
Expand Down
6 changes: 3 additions & 3 deletions snow/engine/common/test_engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ type EngineTest struct {
PutF, PushQueryF func(ctx context.Context, nodeID ids.NodeID, requestID uint32, container []byte) error
AncestorsF func(ctx context.Context, nodeID ids.NodeID, requestID uint32, containers [][]byte) error
AcceptedFrontierF, GetAcceptedF, AcceptedF func(ctx context.Context, nodeID ids.NodeID, requestID uint32, preferredIDs []ids.ID) error
ChitsF func(ctx context.Context, nodeID ids.NodeID, requestID uint32, preferredIDs []ids.ID, acceptedIDs []ids.ID) error
ChitsF func(ctx context.Context, nodeID ids.NodeID, requestID uint32, preferredID ids.ID, acceptedID ids.ID) error
GetStateSummaryFrontierF, GetStateSummaryFrontierFailedF, GetAcceptedStateSummaryFailedF,
GetAcceptedFrontierF, GetFailedF, GetAncestorsFailedF,
QueryFailedF, GetAcceptedFrontierFailedF, GetAcceptedFailedF func(ctx context.Context, nodeID ids.NodeID, requestID uint32) error
Expand Down Expand Up @@ -631,9 +631,9 @@ func (e *EngineTest) AppGossip(ctx context.Context, nodeID ids.NodeID, msg []byt
return errAppGossip
}

func (e *EngineTest) Chits(ctx context.Context, nodeID ids.NodeID, requestID uint32, preferredIDs []ids.ID, acceptedIDs []ids.ID) error {
func (e *EngineTest) Chits(ctx context.Context, nodeID ids.NodeID, requestID uint32, preferredID ids.ID, acceptedID ids.ID) error {
if e.ChitsF != nil {
return e.ChitsF(ctx, nodeID, requestID, preferredIDs, acceptedIDs)
return e.ChitsF(ctx, nodeID, requestID, preferredID, acceptedID)
}
if !e.CantChits {
return nil
Expand Down
Loading