From b6c2f138edc33e6ab682db901ad0431c4f115257 Mon Sep 17 00:00:00 2001 From: Jayden Lee <41176085+tkxkd0159@users.noreply.github.com> Date: Tue, 7 May 2024 17:22:45 +0900 Subject: [PATCH] check duplicate seq in genesis --- x/fbridge/types/genesis.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/x/fbridge/types/genesis.go b/x/fbridge/types/genesis.go index 71ac6c0cd0..358f64b2fa 100644 --- a/x/fbridge/types/genesis.go +++ b/x/fbridge/types/genesis.go @@ -90,10 +90,18 @@ func validateSendingState(state SendingState) error { if state.NextSeq-1 != uint64(len(state.SeqToBlocknum)) { return errors.New("sequence to blocknum mapping is invalid") } + + chkSeq := make(map[uint64]struct{}) for _, v := range state.SeqToBlocknum { - if v.Blocknum < 1 || v.Seq < 1 { + if v.Blocknum == 0 || v.Seq == 0 { return errors.New("blocknum and seq must be positive") } + + if _, ok := chkSeq[v.Seq]; ok { + return errors.New("duplicate sequence") + } + + chkSeq[v.Seq] = struct{}{} } return nil