Skip to content

Commit

Permalink
fix: duplicate and missing message ids (#268)
Browse files Browse the repository at this point in the history
  • Loading branch information
mpetrun5 authored Apr 12, 2024
1 parent 347657b commit bdf6519
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
1 change: 1 addition & 0 deletions chains/evm/executor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ func (e *Executor) proposalBatches(proposals []*proposal.Proposal) ([]*Batch, er
Destination: prop.Destination,
Data: prop.Data.(transfer.TransferProposalData),
Type: prop.Type,
MessageID: prop.MessageID,
}

isExecuted, err := e.bridge.IsProposalExecuted(transferProposal)
Expand Down
2 changes: 1 addition & 1 deletion chains/evm/listener/eventHandlers/event-handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func (eh *RetryEventHandler) HandleEvents(
}

for _, d := range deposits {
messageID := fmt.Sprintf("%d-%d-%d-%d", eh.domainID, d.DestinationDomainID, startBlock, endBlock)
messageID := fmt.Sprintf("retry-%d-%d-%d-%d", eh.domainID, d.DestinationDomainID, startBlock, endBlock)
msg, err := eh.depositHandler.HandleDeposit(
eh.domainID, d.DestinationDomainID, d.DepositNonce,
d.ResourceID, d.Data, d.HandlerResponse, messageID,
Expand Down
8 changes: 4 additions & 4 deletions chains/evm/listener/eventHandlers/event-handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (s *RetryEventHandlerTestSuite) Test_FetchDepositFails_ExecutionContinues()
HandlerResponse: []byte{},
Data: []byte{},
}
msgID := fmt.Sprintf("%d-%d-%d-%d", 1, 2, 0, 5)
msgID := fmt.Sprintf("retry-%d-%d-%d-%d", 1, 2, 0, 5)
s.mockEventListener.EXPECT().FetchRetryEvents(
gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(),
).Return([]events.RetryEvent{{TxHash: "event1"}, {TxHash: "event2"}}, nil)
Expand Down Expand Up @@ -104,7 +104,7 @@ func (s *RetryEventHandlerTestSuite) Test_HandleDepositFails_ExecutionContinues(
HandlerResponse: []byte{},
Data: []byte{},
}
msgID := fmt.Sprintf("%d-%d-%d-%d", 1, 2, 0, 5)
msgID := fmt.Sprintf("retry-%d-%d-%d-%d", 1, 2, 0, 5)
s.mockEventListener.EXPECT().FetchRetryEvents(
gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(),
).Return([]events.RetryEvent{{TxHash: "event1"}, {TxHash: "event2"}}, nil)
Expand Down Expand Up @@ -160,7 +160,7 @@ func (s *RetryEventHandlerTestSuite) Test_HandlingRetryPanics_ExecutionContinue(
).Return([]events.RetryEvent{{TxHash: "event1"}, {TxHash: "event2"}}, nil)
s.mockEventListener.EXPECT().FetchRetryDepositEvents(events.RetryEvent{TxHash: "event1"}, gomock.Any(), big.NewInt(5)).Return([]events.Deposit{d1}, nil)
s.mockEventListener.EXPECT().FetchRetryDepositEvents(events.RetryEvent{TxHash: "event2"}, gomock.Any(), big.NewInt(5)).Return([]events.Deposit{d2}, nil)
msgID := fmt.Sprintf("%d-%d-%d-%d", 1, 2, 0, 5)
msgID := fmt.Sprintf("retry-%d-%d-%d-%d", 1, 2, 0, 5)
s.mockDepositHandler.EXPECT().HandleDeposit(
s.domainID,
d1.DestinationDomainID,
Expand Down Expand Up @@ -212,7 +212,7 @@ func (s *RetryEventHandlerTestSuite) Test_MultipleDeposits() {
gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(),
).Return([]events.RetryEvent{{TxHash: "event1"}}, nil)
s.mockEventListener.EXPECT().FetchRetryDepositEvents(events.RetryEvent{TxHash: "event1"}, gomock.Any(), big.NewInt(5)).Return([]events.Deposit{d1, d2}, nil)
msgID := fmt.Sprintf("%d-%d-%d-%d", 1, 2, 0, 5)
msgID := fmt.Sprintf("retry-%d-%d-%d-%d", 1, 2, 0, 5)
s.mockDepositHandler.EXPECT().HandleDeposit(
s.domainID,
d1.DestinationDomainID,
Expand Down
2 changes: 1 addition & 1 deletion chains/substrate/listener/event-handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ func (rh *RetryEventHandler) HandleEvents(startBlock *big.Int, endBlock *big.Int
return err
}

messageID := fmt.Sprintf("%d-%d-%d-%d", rh.domainID, d.DestDomainID, startBlock, endBlock)
messageID := fmt.Sprintf("retry-%d-%d-%d-%d", rh.domainID, d.DestDomainID, startBlock, endBlock)
m, err := rh.depositHandler.HandleDeposit(rh.domainID, d.DestDomainID, d.DepositNonce, d.ResourceID, d.CallData, d.TransferType, messageID)
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions chains/substrate/listener/event-handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ func (s *RetryHandlerTestSuite) Test_ValidEvents() {
},
},
}
msgID := fmt.Sprintf("%d-%d-%d-%d", 1, 2, 0, 1)
msgID := fmt.Sprintf("retry-%d-%d-%d-%d", 1, 2, 0, 1)
s.mockDepositHandler.EXPECT().HandleDeposit(
s.domainID,
d1["dest_domain_id"],
Expand Down Expand Up @@ -614,7 +614,7 @@ func (s *RetryHandlerTestSuite) Test_EventPanics() {
},
}

msgID := fmt.Sprintf("%d-%d-%d-%d", 1, 2, 0, 1)
msgID := fmt.Sprintf("retry-%d-%d-%d-%d", 1, 2, 0, 1)
s.mockDepositHandler.EXPECT().HandleDeposit(
s.domainID,
d1["dest_domain_id"],
Expand Down

0 comments on commit bdf6519

Please sign in to comment.