Skip to content

Commit

Permalink
Merge branch 'vm-app-error' of github.com:ava-labs/avalanchego into v…
Browse files Browse the repository at this point in the history
…m-app-error
  • Loading branch information
StephenButtolph committed Dec 12, 2023
2 parents e626b42 + e70c46e commit 26f28c3
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion message/inbound_msg_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ func InboundAppError(
) InboundMessage {
return &inboundMessage{
nodeID: nodeID,
op: AppRequestFailedOp,
op: AppErrorOp,
message: &p2p.AppError{
ChainId: chainID[:],
RequestId: requestID,
Expand Down
2 changes: 1 addition & 1 deletion message/inbound_msg_builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ func TestAppError(t *testing.T) {
require.NoError(err)

require.Equal(nodeID, got.NodeID())
require.Equal(AppRequestFailedOp, got.Op())
require.Equal(AppErrorOp, got.Op())

msg, ok := got.Message().(*p2p.AppError)
require.True(ok)
Expand Down
2 changes: 1 addition & 1 deletion message/internal_msg_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ func InternalCrossChainAppError(
) InboundMessage {
return &inboundMessage{
nodeID: nodeID,
op: CrossChainAppRequestFailedOp,
op: CrossChainAppErrorOp,
message: &CrossChainAppRequestFailed{
SourceChainID: sourceChainID,
DestinationChainID: destinationChainID,
Expand Down
26 changes: 13 additions & 13 deletions message/ops.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ const (
ChitsOp
// Application:
AppRequestOp
AppRequestFailedOp
AppErrorOp
AppResponseOp
AppGossipOp
// Cross chain:
CrossChainAppRequestOp
CrossChainAppRequestFailedOp
CrossChainAppErrorOp
CrossChainAppResponseOp
// Internal:
ConnectedOp
Expand Down Expand Up @@ -115,9 +115,9 @@ var (
GetAncestorsFailedOp,
GetFailedOp,
QueryFailedOp,
AppRequestFailedOp,
AppErrorOp,
CrossChainAppRequestOp,
CrossChainAppRequestFailedOp,
CrossChainAppErrorOp,
CrossChainAppResponseOp,
ConnectedOp,
ConnectedSubnetOp,
Expand Down Expand Up @@ -165,12 +165,12 @@ var (
AsynchronousOps = []Op{
// Application
AppRequestOp,
AppRequestFailedOp,
AppErrorOp,
AppGossipOp,
AppResponseOp,
// Cross chain
CrossChainAppRequestOp,
CrossChainAppRequestFailedOp,
CrossChainAppErrorOp,
CrossChainAppResponseOp,
}

Expand All @@ -182,8 +182,8 @@ var (
GetAncestorsFailedOp: AncestorsOp,
GetFailedOp: PutOp,
QueryFailedOp: ChitsOp,
AppRequestFailedOp: AppResponseOp,
CrossChainAppRequestFailedOp: CrossChainAppResponseOp,
AppErrorOp: AppResponseOp,
CrossChainAppErrorOp: CrossChainAppResponseOp,
}
UnrequestedOps = set.Of(
GetAcceptedFrontierOp,
Expand Down Expand Up @@ -265,17 +265,17 @@ func (op Op) String() string {
// Application
case AppRequestOp:
return "app_request"
case AppRequestFailedOp:
return "app_request_failed"
case AppErrorOp:
return "app_error"
case AppResponseOp:
return "app_response"
case AppGossipOp:
return "app_gossip"
// Cross chain
case CrossChainAppRequestOp:
return "cross_chain_app_request"
case CrossChainAppRequestFailedOp:
return "cross_chain_app_request_failed"
case CrossChainAppErrorOp:
return "cross_chain_app_error"
case CrossChainAppResponseOp:
return "cross_chain_app_response"
// Internal
Expand Down Expand Up @@ -403,7 +403,7 @@ func ToOp(m *p2p.Message) (Op, error) {
case *p2p.Message_AppResponse:
return AppResponseOp, nil
case *p2p.Message_AppError:
return AppRequestFailedOp, nil
return AppErrorOp, nil
case *p2p.Message_AppGossip:
return AppGossipOp, nil
default:
Expand Down
4 changes: 2 additions & 2 deletions snow/engine/common/no_ops_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ func (nop *noOpAppHandler) CrossChainAppRequest(_ context.Context, chainID ids.I
func (nop *noOpAppHandler) CrossChainAppRequestFailed(_ context.Context, chainID ids.ID, requestID uint32, appErr *AppError) error {
nop.log.Debug("dropping request",
zap.String("reason", "unhandled by this gear"),
zap.Stringer("messageOp", message.CrossChainAppRequestFailedOp),
zap.Stringer("messageOp", message.CrossChainAppErrorOp),
zap.Stringer("chainID", chainID),
zap.Uint32("requestID", requestID),
zap.Error(appErr),
Expand Down Expand Up @@ -322,7 +322,7 @@ func (nop *noOpAppHandler) AppRequest(_ context.Context, nodeID ids.NodeID, requ
func (nop *noOpAppHandler) AppRequestFailed(_ context.Context, nodeID ids.NodeID, requestID uint32, appErr *AppError) error {
nop.log.Debug("dropping request",
zap.String("reason", "unhandled by this gear"),
zap.Stringer("messageOp", message.AppRequestFailedOp),
zap.Stringer("messageOp", message.AppErrorOp),
zap.Stringer("nodeID", nodeID),
zap.Uint32("requestID", requestID),
zap.Error(appErr),
Expand Down
4 changes: 2 additions & 2 deletions snow/networking/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,8 @@ func (h *handler) Start(ctx context.Context, recoverPanic bool) {
// Push the message onto the handler's queue
func (h *handler) Push(ctx context.Context, msg Message) {
switch msg.Op() {
case message.AppRequestOp, message.AppRequestFailedOp, message.AppResponseOp, message.AppGossipOp,
message.CrossChainAppRequestOp, message.CrossChainAppRequestFailedOp, message.CrossChainAppResponseOp:
case message.AppRequestOp, message.AppErrorOp, message.AppResponseOp, message.AppGossipOp,
message.CrossChainAppRequestOp, message.CrossChainAppErrorOp, message.CrossChainAppResponseOp:
h.asyncMessageQueue.Push(ctx, msg)
default:
h.syncMessageQueue.Push(ctx, msg)
Expand Down
4 changes: 2 additions & 2 deletions snow/networking/router/chain_router_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1391,7 +1391,7 @@ func TestAppRequest(t *testing.T) {
chainRouter, engine := newChainRouterTest(t)

wg.Add(1)
if tt.inboundMsg == nil || tt.inboundMsg.Op() == message.AppRequestFailedOp {
if tt.inboundMsg == nil || tt.inboundMsg.Op() == message.AppErrorOp {
engine.AppRequestFailedF = func(_ context.Context, nodeID ids.NodeID, requestID uint32, appErr *common.AppError) error {
defer wg.Done()
require.Zero(chainRouter.timedRequests.Len())
Expand Down Expand Up @@ -1473,7 +1473,7 @@ func TestCrossChainAppRequest(t *testing.T) {
chainRouter, engine := newChainRouterTest(t)

wg.Add(1)
if tt.inboundMsg == nil || tt.inboundMsg.Op() == message.CrossChainAppRequestFailedOp {
if tt.inboundMsg == nil || tt.inboundMsg.Op() == message.CrossChainAppErrorOp {
engine.CrossChainAppRequestFailedF = func(_ context.Context, chainID ids.ID, requestID uint32, appErr *common.AppError) error {
defer wg.Done()
require.Zero(chainRouter.timedRequests.Len())
Expand Down

0 comments on commit 26f28c3

Please sign in to comment.