Skip to content

Commit

Permalink
Remove unused EngineTypes from p2p messages (ava-labs#2735)
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenButtolph authored Mar 15, 2023
1 parent 109fc3d commit b6c16e1
Show file tree
Hide file tree
Showing 11 changed files with 163 additions and 253 deletions.
6 changes: 1 addition & 5 deletions message/fields.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,12 @@ var (
_ requestIDGetter = (*p2p.AppResponse)(nil)

_ engineTypeGetter = (*p2p.GetAcceptedFrontier)(nil)
_ engineTypeGetter = (*p2p.AcceptedFrontier)(nil)
_ engineTypeGetter = (*p2p.GetAccepted)(nil)
_ engineTypeGetter = (*p2p.Accepted)(nil)
_ engineTypeGetter = (*p2p.GetAncestors)(nil)
_ engineTypeGetter = (*p2p.Ancestors)(nil)
_ engineTypeGetter = (*p2p.Get)(nil)
_ engineTypeGetter = (*p2p.Put)(nil)
_ engineTypeGetter = (*p2p.PushQuery)(nil)
_ engineTypeGetter = (*p2p.PullQuery)(nil)
_ engineTypeGetter = (*p2p.Chits)(nil)

_ deadlineGetter = (*p2p.GetStateSummaryFrontier)(nil)
_ deadlineGetter = (*p2p.GetAcceptedStateSummary)(nil)
Expand Down Expand Up @@ -127,7 +123,7 @@ type engineTypeGetter interface {
func GetEngineType(m any) (p2p.EngineType, bool) {
msg, ok := m.(engineTypeGetter)
if !ok {
return 0, false
return p2p.EngineType_ENGINE_TYPE_UNSPECIFIED, false
}
return msg.GetEngineType(), true
}
Expand Down
6 changes: 0 additions & 6 deletions message/inbound_msg_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ func InboundAcceptedFrontier(
requestID uint32,
containerIDs []ids.ID,
nodeID ids.NodeID,
engineType p2p.EngineType,
) InboundMessage {
containerIDBytes := make([][]byte, len(containerIDs))
encodeIDs(containerIDs, containerIDBytes)
Expand All @@ -148,7 +147,6 @@ func InboundAcceptedFrontier(
ChainId: chainID[:],
RequestId: requestID,
ContainerIds: containerIDBytes,
EngineType: engineType,
},
expiration: mockable.MaxTime,
}
Expand Down Expand Up @@ -183,7 +181,6 @@ func InboundAccepted(
requestID uint32,
containerIDs []ids.ID,
nodeID ids.NodeID,
engineType p2p.EngineType,
) InboundMessage {
containerIDBytes := make([][]byte, len(containerIDs))
encodeIDs(containerIDs, containerIDBytes)
Expand All @@ -194,7 +191,6 @@ func InboundAccepted(
ChainId: chainID[:],
RequestId: requestID,
ContainerIds: containerIDBytes,
EngineType: engineType,
},
expiration: mockable.MaxTime,
}
Expand Down Expand Up @@ -250,7 +246,6 @@ func InboundChits(
preferredContainerIDs []ids.ID,
acceptedContainerIDs []ids.ID,
nodeID ids.NodeID,
engineType p2p.EngineType,
) InboundMessage {
preferredContainerIDBytes := make([][]byte, len(preferredContainerIDs))
encodeIDs(preferredContainerIDs, preferredContainerIDBytes)
Expand All @@ -264,7 +259,6 @@ func InboundChits(
RequestId: requestID,
PreferredContainerIds: preferredContainerIDBytes,
AcceptedContainerIds: acceptedContainerIDBytes,
EngineType: engineType,
},
expiration: mockable.MaxTime,
}
Expand Down
6 changes: 0 additions & 6 deletions message/inbound_msg_builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ func TestInboundMsgBuilder(t *testing.T) {
requestID,
containerIDs,
nodeID,
engineType,
)

require.Equal(AcceptedFrontierOp, msg.Op())
Expand All @@ -201,7 +200,6 @@ func TestInboundMsgBuilder(t *testing.T) {
containerIDsBytes[i] = id[:]
}
require.Equal(containerIDsBytes, innerMsg.ContainerIds)
require.Equal(engineType, innerMsg.EngineType)
},
)

Expand Down Expand Up @@ -243,7 +241,6 @@ func TestInboundMsgBuilder(t *testing.T) {
requestID,
containerIDs,
nodeID,
engineType,
)

require.Equal(AcceptedOp, msg.Op())
Expand All @@ -259,7 +256,6 @@ func TestInboundMsgBuilder(t *testing.T) {
containerIDsBytes[i] = id[:]
}
require.Equal(containerIDsBytes, innerMsg.ContainerIds)
require.Equal(engineType, innerMsg.EngineType)
},
)

Expand Down Expand Up @@ -332,7 +328,6 @@ func TestInboundMsgBuilder(t *testing.T) {
containerIDs,
acceptedContainerIDs,
nodeID,
engineType,
)

require.Equal(ChitsOp, msg.Op())
Expand All @@ -354,7 +349,6 @@ func TestInboundMsgBuilder(t *testing.T) {
acceptedContainerIDsBytes[i] = id[:]
}
require.Equal(acceptedContainerIDsBytes, innerMsg.AcceptedContainerIds)
require.Equal(engineType, innerMsg.EngineType)
},
)

Expand Down
5 changes: 0 additions & 5 deletions message/messages_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,6 @@ func TestMessage(t *testing.T) {
ChainId: testID[:],
RequestId: 1,
ContainerIds: [][]byte{testID[:], testID[:]},
EngineType: p2p.EngineType_ENGINE_TYPE_AVALANCHE,
},
},
},
Expand Down Expand Up @@ -360,7 +359,6 @@ func TestMessage(t *testing.T) {
ChainId: testID[:],
RequestId: 1,
ContainerIds: [][]byte{testID[:], testID[:]},
EngineType: p2p.EngineType_ENGINE_TYPE_AVALANCHE,
},
},
},
Expand Down Expand Up @@ -395,7 +393,6 @@ func TestMessage(t *testing.T) {
ChainId: testID[:],
RequestId: 12345,
Containers: compressibleContainers,
EngineType: p2p.EngineType_ENGINE_TYPE_AVALANCHE,
},
},
},
Expand All @@ -412,7 +409,6 @@ func TestMessage(t *testing.T) {
ChainId: testID[:],
RequestId: 12345,
Containers: compressibleContainers,
EngineType: p2p.EngineType_ENGINE_TYPE_AVALANCHE,
},
},
},
Expand Down Expand Up @@ -535,7 +531,6 @@ func TestMessage(t *testing.T) {
ChainId: testID[:],
RequestId: 1,
PreferredContainerIds: [][]byte{testID[:], testID[:]},
EngineType: p2p.EngineType_ENGINE_TYPE_AVALANCHE,
},
},
},
Expand Down
32 changes: 16 additions & 16 deletions message/mock_outbound_message_builder.go

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

12 changes: 0 additions & 12 deletions message/outbound_msg_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ type OutboundMsgBuilder interface {
chainID ids.ID,
requestID uint32,
containerIDs []ids.ID,
engineType p2p.EngineType,
) (OutboundMessage, error)

GetAccepted(
Expand All @@ -94,7 +93,6 @@ type OutboundMsgBuilder interface {
chainID ids.ID,
requestID uint32,
containerIDs []ids.ID,
engineType p2p.EngineType,
) (OutboundMessage, error)

GetAncestors(
Expand All @@ -109,7 +107,6 @@ type OutboundMsgBuilder interface {
chainID ids.ID,
requestID uint32,
containers [][]byte,
engineType p2p.EngineType,
) (OutboundMessage, error)

Get(
Expand Down Expand Up @@ -148,7 +145,6 @@ type OutboundMsgBuilder interface {
requestID uint32,
preferredContainerIDs []ids.ID,
acceptedContainerIDs []ids.ID,
engineType p2p.EngineType,
) (OutboundMessage, error)

AppRequest(
Expand Down Expand Up @@ -395,7 +391,6 @@ func (b *outMsgBuilder) AcceptedFrontier(
chainID ids.ID,
requestID uint32,
containerIDs []ids.ID,
engineType p2p.EngineType,
) (OutboundMessage, error) {
containerIDBytes := make([][]byte, len(containerIDs))
encodeIDs(containerIDs, containerIDBytes)
Expand All @@ -406,7 +401,6 @@ func (b *outMsgBuilder) AcceptedFrontier(
ChainId: chainID[:],
RequestId: requestID,
ContainerIds: containerIDBytes,
EngineType: engineType,
},
},
},
Expand Down Expand Up @@ -445,7 +439,6 @@ func (b *outMsgBuilder) Accepted(
chainID ids.ID,
requestID uint32,
containerIDs []ids.ID,
engineType p2p.EngineType,
) (OutboundMessage, error) {
containerIDBytes := make([][]byte, len(containerIDs))
encodeIDs(containerIDs, containerIDBytes)
Expand All @@ -456,7 +449,6 @@ func (b *outMsgBuilder) Accepted(
ChainId: chainID[:],
RequestId: requestID,
ContainerIds: containerIDBytes,
EngineType: engineType,
},
},
},
Expand Down Expand Up @@ -493,7 +485,6 @@ func (b *outMsgBuilder) Ancestors(
chainID ids.ID,
requestID uint32,
containers [][]byte,
engineType p2p.EngineType,
) (OutboundMessage, error) {
return b.builder.createOutbound(
&p2p.Message{
Expand All @@ -502,7 +493,6 @@ func (b *outMsgBuilder) Ancestors(
ChainId: chainID[:],
RequestId: requestID,
Containers: containers,
EngineType: engineType,
},
},
},
Expand Down Expand Up @@ -610,7 +600,6 @@ func (b *outMsgBuilder) Chits(
requestID uint32,
preferredContainerIDs []ids.ID,
acceptedContainerIDs []ids.ID,
engineType p2p.EngineType,
) (OutboundMessage, error) {
preferredContainerIDBytes := make([][]byte, len(preferredContainerIDs))
encodeIDs(preferredContainerIDs, preferredContainerIDBytes)
Expand All @@ -624,7 +613,6 @@ func (b *outMsgBuilder) Chits(
RequestId: requestID,
PreferredContainerIds: preferredContainerIDBytes,
AcceptedContainerIds: acceptedContainerIDBytes,
EngineType: engineType,
},
},
},
Expand Down
Loading

0 comments on commit b6c16e1

Please sign in to comment.