Skip to content

Commit

Permalink
refactor finalized check
Browse files Browse the repository at this point in the history
  • Loading branch information
lumtis committed Feb 4, 2024
1 parent c548c7d commit a37bc8a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 7 additions & 0 deletions x/crosschain/keeper/msg_server_vote_inbound_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package keeper

import (
"context"
errorsmod "cosmossdk.io/errors"
"fmt"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/zeta-chain/zetacore/common"
Expand Down Expand Up @@ -55,6 +57,11 @@ func (k msgServer) VoteOnObservedInboundTx(goCtx context.Context, msg *types.Msg
ctx := sdk.UnwrapSDKContext(goCtx)
index := msg.Digest()

// Check if the inbound has already been processed.
if k.IsFinalizedInbound(ctx, msg.InTxHash, msg.SenderChainId, msg.EventIndex) {
return nil, errorsmod.Wrap(types.ErrObservedTxAlreadyFinalized, fmt.Sprintf("InTxHash:%s, SenderChainID:%d, EventIndex:%d", msg.InTxHash, msg.SenderChainId, msg.EventIndex))
}

// vote on inbound ballot
finalized, err := k.zetaObserverKeeper.VoteOnInboundBallot(
ctx,
Expand Down
4 changes: 0 additions & 4 deletions x/observer/keeper/vote_inbound.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,6 @@ func (k Keeper) VoteOnInboundBallot(
return false, err
}
if isNew {
// Check if the inbound has already been processed.
//if k.IsFinalizedInbound(ctx, msg.InTxHash, msg.SenderChainId, msg.EventIndex) {
// return false, errorsmod.Wrap(types.ErrObservedTxAlreadyFinalized, fmt.Sprintf("InTxHash:%s, SenderChainID:%d, EventIndex:%d", msg.InTxHash, msg.SenderChainId, msg.EventIndex))
//}
EmitEventBallotCreated(ctx, ballot, inTxHash, senderChain.String())
}

Expand Down

0 comments on commit a37bc8a

Please sign in to comment.