Skip to content

Commit

Permalink
Problem: event handle method should return error only in case of irre…
Browse files Browse the repository at this point in the history
…coverable errors (#198)
  • Loading branch information
thomas-nguy committed Jan 19, 2023
1 parent b95fba9 commit ce0216d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion module/x/gravity/keeper/ethereum_event_handler.go
Expand Up @@ -23,6 +23,7 @@ func (k Keeper) DetectMaliciousSupply(ctx sdk.Context, denom string, amount sdk.
}

// Handle is the entry point for EthereumEvent processing
// Return error when an irrecoverable error is detected
func (k Keeper) Handle(ctx sdk.Context, eve types.EthereumEvent) (err error) {
switch event := eve.(type) {
case *types.SendToCosmosEvent:
Expand All @@ -33,7 +34,15 @@ func (k Keeper) Handle(ctx sdk.Context, eve types.EthereumEvent) (err error) {

if !isCosmosOriginated {
if err := k.DetectMaliciousSupply(ctx, denom, event.Amount); err != nil {
return err
// log the error and return nil, otherwise the bridge will be desactivated
k.Logger(ctx).Error(
"verify SendToCosmosEvent event failed",
"cause", err.Error(),
"event type", fmt.Sprintf("%T", event),
"id", types.MakeEthereumEventVoteRecordKey(event.GetEventNonce(), event.Hash()),
"nonce", fmt.Sprint(event.GetEventNonce()),
)
return nil
}

// if it is not cosmos originated, mint the coins (aka vouchers)
Expand Down

0 comments on commit ce0216d

Please sign in to comment.