Skip to content

Commit

Permalink
node: Call pipe.valid() when adding a flow cancel transfer
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsaigle committed Jan 21, 2025
1 parent 40c4b1e commit 056da16
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions node/pkg/governor/governor.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,8 @@ type (
}
)

// valid checks whether a pipe is valid
// valid checks whether a pipe is valid. A pipe is invalid if both chain IDs are equal.
func (c *pipe) valid() bool {
// The elements must be different
if c.first == c.second {
return false
}
Expand Down Expand Up @@ -963,7 +962,14 @@ func (gov *ChainGovernor) tryAddFlowCancelTransfer(transfer *transfer) (added bo
target := transfer.dbTransfer.TargetChain
emitter := transfer.dbTransfer.EmitterChain

// Validate the pipe to make sure these chains are flow cancel enabled.
pipe := &pipe{emitter, target}
if !pipe.valid() {
gov.logger.Warn("Not adding flow cancel transfer because emitter and target chain are the same",
zap.String("hash", hash),
)
return false, nil
}
if !gov.pipeCanFlowCancel(pipe) {
return false, nil
}
Expand All @@ -976,7 +982,7 @@ func (gov *ChainGovernor) tryAddFlowCancelTransfer(transfer *transfer) (added bo
zap.String("OriginChain", originChain.String()),
zap.String("tokenEntry", originAddr.String()),
zap.String("msgID", transfer.dbTransfer.MsgID),
zap.String("hash", transfer.dbTransfer.Hash),
zap.String("hash", hash),
)
return false, nil
}
Expand Down

0 comments on commit 056da16

Please sign in to comment.