Skip to content

Commit

Permalink
Remove engine type handling for everything other than GetAncestors (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenButtolph authored Mar 11, 2024
1 parent 6ec6a62 commit f3abe3c
Show file tree
Hide file tree
Showing 18 changed files with 226 additions and 548 deletions.
6 changes: 0 additions & 6 deletions message/fields.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,7 @@ var (
_ requestIDGetter = (*p2p.AppRequest)(nil)
_ requestIDGetter = (*p2p.AppResponse)(nil)

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

_ deadlineGetter = (*p2p.GetStateSummaryFrontier)(nil)
_ deadlineGetter = (*p2p.GetAcceptedStateSummary)(nil)
Expand Down
14 changes: 3 additions & 11 deletions message/inbound_msg_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,14 @@ func InboundGetAcceptedFrontier(
requestID uint32,
deadline time.Duration,
nodeID ids.NodeID,
engineType p2p.EngineType,
) InboundMessage {
return &inboundMessage{
nodeID: nodeID,
op: GetAcceptedFrontierOp,
message: &p2p.GetAcceptedFrontier{
ChainId: chainID[:],
RequestId: requestID,
Deadline: uint64(deadline),
EngineType: engineType,
ChainId: chainID[:],
RequestId: requestID,
Deadline: uint64(deadline),
},
expiration: time.Now().Add(deadline),
}
Expand Down Expand Up @@ -156,7 +154,6 @@ func InboundGetAccepted(
deadline time.Duration,
containerIDs []ids.ID,
nodeID ids.NodeID,
engineType p2p.EngineType,
) InboundMessage {
containerIDBytes := make([][]byte, len(containerIDs))
encodeIDs(containerIDs, containerIDBytes)
Expand All @@ -168,7 +165,6 @@ func InboundGetAccepted(
RequestId: requestID,
Deadline: uint64(deadline),
ContainerIds: containerIDBytes,
EngineType: engineType,
},
expiration: time.Now().Add(deadline),
}
Expand Down Expand Up @@ -201,7 +197,6 @@ func InboundPushQuery(
container []byte,
requestedHeight uint64,
nodeID ids.NodeID,
engineType p2p.EngineType,
) InboundMessage {
return &inboundMessage{
nodeID: nodeID,
Expand All @@ -212,7 +207,6 @@ func InboundPushQuery(
Deadline: uint64(deadline),
Container: container,
RequestedHeight: requestedHeight,
EngineType: engineType,
},
expiration: time.Now().Add(deadline),
}
Expand All @@ -225,7 +219,6 @@ func InboundPullQuery(
containerID ids.ID,
requestedHeight uint64,
nodeID ids.NodeID,
engineType p2p.EngineType,
) InboundMessage {
return &inboundMessage{
nodeID: nodeID,
Expand All @@ -236,7 +229,6 @@ func InboundPullQuery(
Deadline: uint64(deadline),
ContainerId: containerID[:],
RequestedHeight: requestedHeight,
EngineType: engineType,
},
expiration: time.Now().Add(deadline),
}
Expand Down
9 changes: 0 additions & 9 deletions message/inbound_msg_builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ func TestInboundMsgBuilder(t *testing.T) {
acceptedContainerID = ids.GenerateTestID()
summaryIDs = []ids.ID{ids.GenerateTestID(), ids.GenerateTestID()}
heights = []uint64{1000, 2000}
engineType = p2p.EngineType_ENGINE_TYPE_SNOWMAN
)

t.Run(
Expand Down Expand Up @@ -162,7 +161,6 @@ func TestInboundMsgBuilder(t *testing.T) {
requestID,
deadline,
nodeID,
engineType,
)
end := time.Now()

Expand All @@ -174,7 +172,6 @@ func TestInboundMsgBuilder(t *testing.T) {
innerMsg := msg.Message().(*p2p.GetAcceptedFrontier)
require.Equal(chainID[:], innerMsg.ChainId)
require.Equal(requestID, innerMsg.RequestId)
require.Equal(engineType, innerMsg.EngineType)
},
)

Expand Down Expand Up @@ -213,7 +210,6 @@ func TestInboundMsgBuilder(t *testing.T) {
deadline,
containerIDs,
nodeID,
engineType,
)
end := time.Now()

Expand All @@ -225,7 +221,6 @@ func TestInboundMsgBuilder(t *testing.T) {
innerMsg := msg.Message().(*p2p.GetAccepted)
require.Equal(chainID[:], innerMsg.ChainId)
require.Equal(requestID, innerMsg.RequestId)
require.Equal(engineType, innerMsg.EngineType)
},
)

Expand Down Expand Up @@ -270,7 +265,6 @@ func TestInboundMsgBuilder(t *testing.T) {
container,
requestedHeight,
nodeID,
engineType,
)
end := time.Now()

Expand All @@ -284,7 +278,6 @@ func TestInboundMsgBuilder(t *testing.T) {
require.Equal(requestID, innerMsg.RequestId)
require.Equal(container, innerMsg.Container)
require.Equal(requestedHeight, innerMsg.RequestedHeight)
require.Equal(engineType, innerMsg.EngineType)
},
)

Expand All @@ -301,7 +294,6 @@ func TestInboundMsgBuilder(t *testing.T) {
containerIDs[0],
requestedHeight,
nodeID,
engineType,
)
end := time.Now()

Expand All @@ -315,7 +307,6 @@ func TestInboundMsgBuilder(t *testing.T) {
require.Equal(requestID, innerMsg.RequestId)
require.Equal(containerIDs[0][:], innerMsg.ContainerId)
require.Equal(requestedHeight, innerMsg.RequestedHeight)
require.Equal(engineType, innerMsg.EngineType)
},
)

Expand Down
104 changes: 36 additions & 68 deletions message/internal_msg_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,30 +27,26 @@ var (
_ chainIDGetter = (*GetAcceptedStateSummaryFailed)(nil)
_ requestIDGetter = (*GetAcceptedStateSummaryFailed)(nil)

_ fmt.Stringer = (*GetAcceptedFrontierFailed)(nil)
_ chainIDGetter = (*GetAcceptedFrontierFailed)(nil)
_ requestIDGetter = (*GetAcceptedFrontierFailed)(nil)
_ engineTypeGetter = (*GetAcceptedFrontierFailed)(nil)
_ fmt.Stringer = (*GetAcceptedFrontierFailed)(nil)
_ chainIDGetter = (*GetAcceptedFrontierFailed)(nil)
_ requestIDGetter = (*GetAcceptedFrontierFailed)(nil)

_ fmt.Stringer = (*GetAcceptedFailed)(nil)
_ chainIDGetter = (*GetAcceptedFailed)(nil)
_ requestIDGetter = (*GetAcceptedFailed)(nil)
_ engineTypeGetter = (*GetAcceptedFailed)(nil)
_ fmt.Stringer = (*GetAcceptedFailed)(nil)
_ chainIDGetter = (*GetAcceptedFailed)(nil)
_ requestIDGetter = (*GetAcceptedFailed)(nil)

_ fmt.Stringer = (*GetAncestorsFailed)(nil)
_ chainIDGetter = (*GetAncestorsFailed)(nil)
_ requestIDGetter = (*GetAncestorsFailed)(nil)
_ engineTypeGetter = (*GetAncestorsFailed)(nil)

_ fmt.Stringer = (*GetFailed)(nil)
_ chainIDGetter = (*GetFailed)(nil)
_ requestIDGetter = (*GetFailed)(nil)
_ engineTypeGetter = (*GetFailed)(nil)
_ fmt.Stringer = (*GetFailed)(nil)
_ chainIDGetter = (*GetFailed)(nil)
_ requestIDGetter = (*GetFailed)(nil)

_ fmt.Stringer = (*QueryFailed)(nil)
_ chainIDGetter = (*QueryFailed)(nil)
_ requestIDGetter = (*QueryFailed)(nil)
_ engineTypeGetter = (*QueryFailed)(nil)
_ fmt.Stringer = (*QueryFailed)(nil)
_ chainIDGetter = (*QueryFailed)(nil)
_ requestIDGetter = (*QueryFailed)(nil)

_ fmt.Stringer = (*CrossChainAppRequest)(nil)
_ sourceChainIDGetter = (*CrossChainAppRequest)(nil)
Expand Down Expand Up @@ -147,15 +143,14 @@ func InternalGetAcceptedStateSummaryFailed(
}

type GetAcceptedFrontierFailed struct {
ChainID ids.ID `json:"chain_id,omitempty"`
RequestID uint32 `json:"request_id,omitempty"`
EngineType p2p.EngineType `json:"engine_type,omitempty"`
ChainID ids.ID `json:"chain_id,omitempty"`
RequestID uint32 `json:"request_id,omitempty"`
}

func (m *GetAcceptedFrontierFailed) String() string {
return fmt.Sprintf(
"ChainID: %s RequestID: %d EngineType: %s",
m.ChainID, m.RequestID, m.EngineType,
"ChainID: %s RequestID: %d",
m.ChainID, m.RequestID,
)
}

Expand All @@ -167,38 +162,31 @@ func (m *GetAcceptedFrontierFailed) GetRequestId() uint32 {
return m.RequestID
}

func (m *GetAcceptedFrontierFailed) GetEngineType() p2p.EngineType {
return m.EngineType
}

func InternalGetAcceptedFrontierFailed(
nodeID ids.NodeID,
chainID ids.ID,
requestID uint32,
engineType p2p.EngineType,
) InboundMessage {
return &inboundMessage{
nodeID: nodeID,
op: GetAcceptedFrontierFailedOp,
message: &GetAcceptedFrontierFailed{
ChainID: chainID,
RequestID: requestID,
EngineType: engineType,
ChainID: chainID,
RequestID: requestID,
},
expiration: mockable.MaxTime,
}
}

type GetAcceptedFailed struct {
ChainID ids.ID `json:"chain_id,omitempty"`
RequestID uint32 `json:"request_id,omitempty"`
EngineType p2p.EngineType `json:"engine_type,omitempty"`
ChainID ids.ID `json:"chain_id,omitempty"`
RequestID uint32 `json:"request_id,omitempty"`
}

func (m *GetAcceptedFailed) String() string {
return fmt.Sprintf(
"ChainID: %s RequestID: %d EngineType: %s",
m.ChainID, m.RequestID, m.EngineType,
"ChainID: %s RequestID: %d",
m.ChainID, m.RequestID,
)
}

Expand All @@ -210,23 +198,17 @@ func (m *GetAcceptedFailed) GetRequestId() uint32 {
return m.RequestID
}

func (m *GetAcceptedFailed) GetEngineType() p2p.EngineType {
return m.EngineType
}

func InternalGetAcceptedFailed(
nodeID ids.NodeID,
chainID ids.ID,
requestID uint32,
engineType p2p.EngineType,
) InboundMessage {
return &inboundMessage{
nodeID: nodeID,
op: GetAcceptedFailedOp,
message: &GetAcceptedFailed{
ChainID: chainID,
RequestID: requestID,
EngineType: engineType,
ChainID: chainID,
RequestID: requestID,
},
expiration: mockable.MaxTime,
}
Expand Down Expand Up @@ -276,15 +258,14 @@ func InternalGetAncestorsFailed(
}

type GetFailed struct {
ChainID ids.ID `json:"chain_id,omitempty"`
RequestID uint32 `json:"request_id,omitempty"`
EngineType p2p.EngineType `json:"engine_type,omitempty"`
ChainID ids.ID `json:"chain_id,omitempty"`
RequestID uint32 `json:"request_id,omitempty"`
}

func (m *GetFailed) String() string {
return fmt.Sprintf(
"ChainID: %s RequestID: %d EngineType: %s",
m.ChainID, m.RequestID, m.EngineType,
"ChainID: %s RequestID: %d",
m.ChainID, m.RequestID,
)
}

Expand All @@ -296,38 +277,31 @@ func (m *GetFailed) GetRequestId() uint32 {
return m.RequestID
}

func (m *GetFailed) GetEngineType() p2p.EngineType {
return m.EngineType
}

func InternalGetFailed(
nodeID ids.NodeID,
chainID ids.ID,
requestID uint32,
engineType p2p.EngineType,
) InboundMessage {
return &inboundMessage{
nodeID: nodeID,
op: GetFailedOp,
message: &GetFailed{
ChainID: chainID,
RequestID: requestID,
EngineType: engineType,
ChainID: chainID,
RequestID: requestID,
},
expiration: mockable.MaxTime,
}
}

type QueryFailed struct {
ChainID ids.ID `json:"chain_id,omitempty"`
RequestID uint32 `json:"request_id,omitempty"`
EngineType p2p.EngineType `json:"engine_type,omitempty"`
ChainID ids.ID `json:"chain_id,omitempty"`
RequestID uint32 `json:"request_id,omitempty"`
}

func (m *QueryFailed) String() string {
return fmt.Sprintf(
"ChainID: %s RequestID: %d EngineType: %s",
m.ChainID, m.RequestID, m.EngineType,
"ChainID: %s RequestID: %d",
m.ChainID, m.RequestID,
)
}

Expand All @@ -339,23 +313,17 @@ func (m *QueryFailed) GetRequestId() uint32 {
return m.RequestID
}

func (m *QueryFailed) GetEngineType() p2p.EngineType {
return m.EngineType
}

func InternalQueryFailed(
nodeID ids.NodeID,
chainID ids.ID,
requestID uint32,
engineType p2p.EngineType,
) InboundMessage {
return &inboundMessage{
nodeID: nodeID,
op: QueryFailedOp,
message: &QueryFailed{
ChainID: chainID,
RequestID: requestID,
EngineType: engineType,
ChainID: chainID,
RequestID: requestID,
},
expiration: mockable.MaxTime,
}
Expand Down
Loading

0 comments on commit f3abe3c

Please sign in to comment.