Skip to content

Commit

Permalink
Ignore error for vote already exist (#1325)
Browse files Browse the repository at this point in the history
* Ignore error for vote already exist

* Fix go mod

* Add error log
  • Loading branch information
yzang2019 authored Feb 8, 2024
1 parent 7f5f378 commit ea58ea9
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ require (
replace (
github.com/CosmWasm/wasmd => github.com/sei-protocol/sei-wasmd v0.0.4
github.com/confio/ics23/go => github.com/cosmos/cosmos-sdk/ics23/go v0.8.0
github.com/cosmos/cosmos-sdk => github.com/sei-protocol/sei-cosmos v0.2.73-hotfix-1
github.com/cosmos/cosmos-sdk => github.com/sei-protocol/sei-cosmos v0.2.73-hotfix-2
github.com/cosmos/iavl => github.com/sei-protocol/sei-iavl v0.1.9
github.com/cosmos/ibc-go/v3 => github.com/sei-protocol/sei-ibc-go/v3 v3.3.0
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1170,8 +1170,8 @@ github.com/securego/gosec/v2 v2.11.0/go.mod h1:SX8bptShuG8reGC0XS09+a4H2BoWSJi+f
github.com/segmentio/fasthash v1.0.3/go.mod h1:waKX8l2N8yckOgmSsXJi7x1ZfdKZ4x7KRMzBtS3oedY=
github.com/sei-protocol/goutils v0.0.2 h1:Bfa7Sv+4CVLNM20QcpvGb81B8C5HkQC/kW1CQpIbXDA=
github.com/sei-protocol/goutils v0.0.2/go.mod h1:iYE2DuJfEnM+APPehr2gOUXfuLuPsVxorcDO+Tzq9q8=
github.com/sei-protocol/sei-cosmos v0.2.73-hotfix-1 h1:W4/cxW5CtidvGhfu9x7O9LUUK+SPDr7rktGtaiZGTbk=
github.com/sei-protocol/sei-cosmos v0.2.73-hotfix-1/go.mod h1:CykNPmj90YkwBorkvnc05u9k9MBNDHC3h4CIdmq3R98=
github.com/sei-protocol/sei-cosmos v0.2.73-hotfix-2 h1:3AipLPlcAvQyrLCNGM53+EvstzOwhQ2iE4ARyKLsIIw=
github.com/sei-protocol/sei-cosmos v0.2.73-hotfix-2/go.mod h1:CykNPmj90YkwBorkvnc05u9k9MBNDHC3h4CIdmq3R98=
github.com/sei-protocol/sei-db v0.0.30 h1:dlAOTE+7nByzzAD9cb1/DxaHWbxXOHFh58a2ImvcoYs=
github.com/sei-protocol/sei-db v0.0.30/go.mod h1:F/ZKZA8HJPcUzSZPA8yt6pfwlGriJ4RDR4eHKSGLStI=
github.com/sei-protocol/sei-iavl v0.1.9 h1:y4mVYftxLNRs6533zl7N0/Ch+CzRQc04JDfHolIxgBE=
Expand Down
5 changes: 3 additions & 2 deletions oracle/price-feeder/oracle/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
simappparams "github.com/cosmos/cosmos-sdk/simapp/params"
"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/types/tx/signing"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/rs/zerolog"
Expand Down Expand Up @@ -191,8 +192,8 @@ func (oc OracleClient) BroadcastTx(

oc.Logger.Info().Msg(fmt.Sprintf("Sending broadcastTx with account sequence number %d", txf.Sequence()))
resp, err := clientCtx.BroadcastTx(txBytes)
if resp != nil && resp.Code != 0 {
err = fmt.Errorf("received error response code from broadcast tx: %d", resp.Code)
if resp != nil && resp.Code != 0 && resp.Code != sdkerrors.ErrAlreadyExists.ABCICode() {
err = fmt.Errorf("received error response code %d from broadcast tx: %s", resp.Code, resp.Logs.String())
}
if err != nil {
// When error happen, it could be that the sequence number are mismatching
Expand Down
2 changes: 1 addition & 1 deletion x/oracle/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func (spd SpammingPreventionDecorator) CheckOracleSpamming(ctx sdk.Context, msgs
return err
}
if lastSubmittedHeight, ok := spd.oracleVoteMap[msg.Validator]; ok && lastSubmittedHeight == curHeight {
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, fmt.Sprintf("the validator has already submitted a vote at the current height=%d", curHeight))
return sdkerrors.Wrap(sdkerrors.ErrAlreadyExists, fmt.Sprintf("the validator has already submitted a vote at the current height=%d", curHeight))
}

spd.oracleVoteMap[msg.Validator] = curHeight
Expand Down

0 comments on commit ea58ea9

Please sign in to comment.