diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2a25121..6c8bea1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,7 +15,7 @@ jobs: build-test: strategy: matrix: - go-version: [1.19.x] + go-version: [1.20.x] os: [ubuntu-latest] runs-on: ${{ matrix.os }} env: diff --git a/.github/workflows/gosec.yml b/.github/workflows/gosec.yml index 0a68ea5..8b82c0b 100644 --- a/.github/workflows/gosec.yml +++ b/.github/workflows/gosec.yml @@ -14,7 +14,7 @@ jobs: name: gosec strategy: matrix: - go-version: [1.19.x] + go-version: [1.20.x] os: [ubuntu-latest] runs-on: ${{ matrix.os }} env: diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 21721e6..14d6520 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -19,7 +19,7 @@ jobs: steps: - uses: actions/setup-go@v3 with: - go-version: 1.19 + go-version: [1.20.x] - uses: actions/checkout@v3 - run: go env -w GOPRIVATE="github.com/bnb-chain/*" diff --git a/assembler/bsc_assembler.go b/assembler/bsc_assembler.go index 34279e6..47ba6b8 100644 --- a/assembler/bsc_assembler.go +++ b/assembler/bsc_assembler.go @@ -70,7 +70,11 @@ func (a *BSCAssembler) process(channelId types.ChannelId) error { isInturnRelyer := bytes.Equal(a.blsPubKey, inturnRelayerPubkey) a.metricService.SetGnfdInturnRelayerMetrics(isInturnRelyer, inturnRelayer.RelayInterval.Start, inturnRelayer.RelayInterval.End) - var startSeq uint64 + + var ( + startSeq uint64 + endSequence int64 + ) if isInturnRelyer { if !a.inturnRelayerSequenceStatus.HasRetrieved { @@ -115,13 +119,20 @@ func (a *BSCAssembler) process(channelId types.ChannelId) error { if err != nil { return err } - - endSequence, err := a.daoManager.BSCDao.GetLatestOracleSequenceByStatus(db.AllVoted) - if err != nil { - return err - } - if endSequence == -1 { - return nil + if isInturnRelyer { + endSequence, err = a.daoManager.BSCDao.GetLatestOracleSequenceByStatus(db.AllVoted) + if err != nil { + return err + } + if endSequence == -1 { + return nil + } + } else { + endSeq, err := a.bscExecutor.GetNextSendSequenceForChannelWithRetry() + if err != nil { + return err + } + endSequence = int64(endSeq) } logging.Logger.Debugf("start seq and end enq are %d and %d", startSeq, endSequence) @@ -176,7 +187,6 @@ func (a *BSCAssembler) process(channelId types.ChannelId) error { func (a *BSCAssembler) processPkgs(client *executor.GreenfieldClient, pkgs []*model.BscRelayPackage, channelId uint8, sequence uint64, nonce uint64, isInturnRelyer bool) error { // Get votes result for a packages, which are already validated and qualified to aggregate sig - votes, err := a.daoManager.VoteDao.GetVotesByChannelIdAndSequence(channelId, sequence) if err != nil { logging.Logger.Errorf("failed to get votes result for packages for channel %d and sequence %d", channelId, sequence) diff --git a/assembler/greenfield_assembler.go b/assembler/greenfield_assembler.go index 1bb018d..2c2bbd4 100644 --- a/assembler/greenfield_assembler.go +++ b/assembler/greenfield_assembler.go @@ -97,7 +97,10 @@ func (a *GreenfieldAssembler) assembleTransactionAndSendForChannel(channelId typ } func (a *GreenfieldAssembler) process(channelId types.ChannelId, inturnRelayer *types.InturnRelayer, isInturnRelyer bool) error { - var startSeq uint64 + var ( + startSeq uint64 + endSequence int64 + ) if isInturnRelyer { if !a.inturnRelayerSequenceStatusMap[channelId].HasRetrieved { @@ -136,13 +139,22 @@ func (a *GreenfieldAssembler) process(channelId types.ChannelId, inturnRelayer * return err } - endSequence, err := a.daoManager.GreenfieldDao.GetLatestSequenceByChannelIdAndStatus(channelId, db.AllVoted) - if err != nil { - return err - } - if endSequence == -1 { - return nil + if isInturnRelyer { + endSequence, err = a.daoManager.GreenfieldDao.GetLatestSequenceByChannelIdAndStatus(channelId, db.AllVoted) + if err != nil { + return err + } + if endSequence == -1 { + return nil + } + } else { + endSeq, err := a.greenfieldExecutor.GetNextSendSequenceForChannelWithRetry(channelId) + if err != nil { + return err + } + endSequence = int64(endSeq) } + logging.Logger.Debugf("channel %d start seq and end enq are %d and %d", channelId, startSeq, endSequence) for i := startSeq; i <= uint64(endSequence); i++ { diff --git a/go.mod b/go.mod index 7aa9347..ba8d7e2 100644 --- a/go.mod +++ b/go.mod @@ -6,8 +6,8 @@ require ( cosmossdk.io/errors v1.0.0-beta.7 github.com/avast/retry-go/v4 v4.3.1 github.com/aws/aws-sdk-go v1.40.45 - github.com/bnb-chain/greenfield v0.2.3-alpha.6 - github.com/bnb-chain/greenfield-go-sdk v0.2.3-alpha.3.0.20230724054656-5614440e16f1 + github.com/bnb-chain/greenfield v0.2.3 + github.com/bnb-chain/greenfield-go-sdk v0.2.3 github.com/cometbft/cometbft v0.37.1 github.com/cosmos/cosmos-sdk v0.47.3 github.com/ethereum/go-ethereum v1.10.26 @@ -168,9 +168,9 @@ require ( replace ( cosmossdk.io/api => github.com/bnb-chain/greenfield-cosmos-sdk/api v0.0.0-20230425074444-eb5869b05fe9 cosmossdk.io/math => github.com/bnb-chain/greenfield-cosmos-sdk/math v0.0.0-20230425074444-eb5869b05fe9 - github.com/cometbft/cometbft => github.com/bnb-chain/greenfield-cometbft v0.0.2-alpha.2 + github.com/cometbft/cometbft => github.com/bnb-chain/greenfield-cometbft v0.0.2 github.com/cometbft/cometbft-db => github.com/bnb-chain/greenfield-cometbft-db v0.8.1-alpha.1 - github.com/cosmos/cosmos-sdk => github.com/bnb-chain/greenfield-cosmos-sdk v0.2.3-alpha.4 + github.com/cosmos/cosmos-sdk => github.com/bnb-chain/greenfield-cosmos-sdk v0.2.3 github.com/cosmos/iavl => github.com/bnb-chain/greenfield-iavl v0.20.1-alpha.1 github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 ) diff --git a/go.sum b/go.sum index 0dec28c..39eb37e 100644 --- a/go.sum +++ b/go.sum @@ -157,22 +157,22 @@ github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kB github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 h1:41iFGWnSlI2gVpmOtVTJZNodLdLQLn/KsJqFvXwnd/s= github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/bmizerany/pat v0.0.0-20170815010413-6226ea591a40/go.mod h1:8rLXio+WjiTceGBHIoTvn60HIbs7Hm7bcHjyrSqYB9c= -github.com/bnb-chain/greenfield v0.2.3-alpha.6 h1:kC3L1aKZdG0dFzQf/1+l+uuTGzHUi3ybwLzSqZbzJ28= -github.com/bnb-chain/greenfield v0.2.3-alpha.6/go.mod h1:2sjyOH3z8zH0VaSlu5propRLYt8PvT2Ta01F6sP3Tas= -github.com/bnb-chain/greenfield-cometbft v0.0.2-alpha.2 h1:ys9kmgtRx04wcCextE6CrVmbL1bJDklWr+hWgm1y2k4= -github.com/bnb-chain/greenfield-cometbft v0.0.2-alpha.2/go.mod h1:EBmwmUdaNbGPyGjf1cMuoN3pAeM2tQu7Lfg95813EAw= +github.com/bnb-chain/greenfield v0.2.3 h1:s5KbeTuBiN+VL9i+BJtSFU+UNw6zk45Py9Ee1LY6liU= +github.com/bnb-chain/greenfield v0.2.3/go.mod h1:LnDIEY7G57bs6tjKbJbwpy09zNceNgAsabYMa6t1Nd0= +github.com/bnb-chain/greenfield-cometbft v0.0.2 h1:bRamS8Lq1lA3ttRLZBha22uiNG5tqN+diD3hapdUCYI= +github.com/bnb-chain/greenfield-cometbft v0.0.2/go.mod h1:EBmwmUdaNbGPyGjf1cMuoN3pAeM2tQu7Lfg95813EAw= github.com/bnb-chain/greenfield-cometbft-db v0.8.1-alpha.1 h1:XcWulGacHVRiSCx90Q8Y//ajOrLNBQWR/KDB89dy3cU= github.com/bnb-chain/greenfield-cometbft-db v0.8.1-alpha.1/go.mod h1:ey1CiK4bYo1RBNJLRiVbYr5CMdSxci9S/AZRINLtppI= github.com/bnb-chain/greenfield-common/go v0.0.0-20230720022901-7e7158fd397d h1:G14aW9eW+l7ou10kRPlBiXOZqG+qPk3YYjEXgJid6jk= github.com/bnb-chain/greenfield-common/go v0.0.0-20230720022901-7e7158fd397d/go.mod h1:GEjCahULmz99qx5k8WGWa7cTXIUjoNMNW+J92I+kTWg= -github.com/bnb-chain/greenfield-cosmos-sdk v0.2.3-alpha.4 h1:Q5EzT1r3jKv0BZgVJkYFVvqn+7Ghj6RU7mUM0VkUZ4U= -github.com/bnb-chain/greenfield-cosmos-sdk v0.2.3-alpha.4/go.mod h1:EghjYxFg4NRNMfTJ6g9rVhjImhXQm+tuboknHqeGmJA= +github.com/bnb-chain/greenfield-cosmos-sdk v0.2.3 h1:bpro+qS2jjSi7vQN781gtxebuYNDrLewAye+iGB299c= +github.com/bnb-chain/greenfield-cosmos-sdk v0.2.3/go.mod h1:hpvg93+VGXHAcv/pVVdp24Ik/9miw4uRh8+tD0DDYas= github.com/bnb-chain/greenfield-cosmos-sdk/api v0.0.0-20230425074444-eb5869b05fe9 h1:6fLpmmI0EZvDTfPvI0zy5dBaaTUboHnEkoC5/p/w8TQ= github.com/bnb-chain/greenfield-cosmos-sdk/api v0.0.0-20230425074444-eb5869b05fe9/go.mod h1:rbc4o84RSEvhf09o2+4Qiazsv0snRJLiEZdk17HeIDw= github.com/bnb-chain/greenfield-cosmos-sdk/math v0.0.0-20230425074444-eb5869b05fe9 h1:1ZdK+iR1Up02bOa2YTZCml7PBpP//kcdamOcK6aWO/s= github.com/bnb-chain/greenfield-cosmos-sdk/math v0.0.0-20230425074444-eb5869b05fe9/go.mod h1:Ygz4wBHrgc7g0N+8+MrnTfS9LLn9aaTGa9hKopuym5k= -github.com/bnb-chain/greenfield-go-sdk v0.2.3-alpha.3.0.20230724054656-5614440e16f1 h1:z5LvRtaJdZXky/ZD6uXO6/IICPhSr/+iW8FB/Dk0C5Y= -github.com/bnb-chain/greenfield-go-sdk v0.2.3-alpha.3.0.20230724054656-5614440e16f1/go.mod h1:4qY78+HRV2AQliwEh6JAIW6H2fRg6urNQOy4fkfCvaM= +github.com/bnb-chain/greenfield-go-sdk v0.2.3 h1:j/jQNe7bzWIN69x2Z79YGWx8k1d8b/jsjALOt0P4yZw= +github.com/bnb-chain/greenfield-go-sdk v0.2.3/go.mod h1:nMvYMxPUxTF4FPCfyZdENxhLFWXpwlQ1h8PLpkdGKG0= github.com/bnb-chain/greenfield-iavl v0.20.1-alpha.1 h1:ZnIcvkkQVurg0OaAwmUGn2cK5bZbffjVChFyhh86HMk= github.com/bnb-chain/greenfield-iavl v0.20.1-alpha.1/go.mod h1:oLksTs8dfh7DYIKBro7hbRQ+ewls7ghJ27pIXlbEXyI= github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps=