diff --git a/x/oracle/keeper/keeper.go b/x/oracle/keeper/keeper.go index 051ec7c189..c64342b7e7 100644 --- a/x/oracle/keeper/keeper.go +++ b/x/oracle/keeper/keeper.go @@ -83,7 +83,7 @@ func (k Keeper) IsValidatorInturn(ctx sdk.Context, validators []stakingtypes.Val } if validatorIndex < 0 { - return false, sdkerrors.Wrapf(types.ErrNotValidator, fmt.Sprintf("sender is not validator")) + return false, sdkerrors.Wrapf(types.ErrNotRelayer, fmt.Sprintf("sender(%s) is not a relayer", claim.FromAddress)) } // check inturn validator index @@ -105,8 +105,8 @@ func (k Keeper) IsValidatorInturn(ctx sdk.Context, validators []stakingtypes.Val return uint64(validatorIndex) == (inturnValidatorIndex+backoffIndex)%uint64(len(validators)), nil } -// ProcessClaim checks the bls signature -func (k Keeper) ProcessClaim(ctx sdk.Context, claim *types.MsgClaim) error { +// CheckClaim checks the bls signature +func (k Keeper) CheckClaim(ctx sdk.Context, claim *types.MsgClaim) error { historicalInfo, ok := k.StakingKeeper.GetHistoricalInfo(ctx, ctx.BlockHeight()) if !ok { return sdkerrors.Wrapf(types.ErrValidatorSet, fmt.Sprintf("get historical validators failed")) diff --git a/x/oracle/keeper/keeper_test.go b/x/oracle/keeper/keeper_test.go index c54ad6fc54..c668fca5a6 100644 --- a/x/oracle/keeper/keeper_test.go +++ b/x/oracle/keeper/keeper_test.go @@ -105,12 +105,12 @@ func (s *TestSuite) TestProcessClaim() { msgClaim.AggSignature = blsSig s.ctx = s.ctx.WithBlockTime(time.Unix(int64(msgClaim.Timestamp), 0)) - err := s.app.OracleKeeper.ProcessClaim(s.ctx, &msgClaim) + err := s.app.OracleKeeper.CheckClaim(s.ctx, &msgClaim) s.Require().Nil(err, "error should be nil") // not in turn s.ctx = s.ctx.WithBlockTime(time.Unix(int64(msgClaim.Timestamp)+6, 0)) - err = s.app.OracleKeeper.ProcessClaim(s.ctx, &msgClaim) + err = s.app.OracleKeeper.CheckClaim(s.ctx, &msgClaim) s.Require().NotNil(err, "error should not be nil") s.Require().Contains(err.Error(), "validator is not in turn") @@ -121,7 +121,7 @@ func (s *TestSuite) TestProcessClaim() { } msgClaim.VoteAddressSet = wrongValBitSet.Bytes() s.ctx = s.ctx.WithBlockTime(time.Unix(int64(msgClaim.Timestamp), 0)) - err = s.app.OracleKeeper.ProcessClaim(s.ctx, &msgClaim) + err = s.app.OracleKeeper.CheckClaim(s.ctx, &msgClaim) s.Require().NotNil(err, "error should not be nil") s.Require().Contains(err.Error(), "number of validator set is larger than validators") @@ -131,7 +131,7 @@ func (s *TestSuite) TestProcessClaim() { wrongValBitSet.Set(uint(validatorMap[newValidators[1].RelayerAddress])) msgClaim.VoteAddressSet = wrongValBitSet.Bytes() s.ctx = s.ctx.WithBlockTime(time.Unix(int64(msgClaim.Timestamp), 0)) - err = s.app.OracleKeeper.ProcessClaim(s.ctx, &msgClaim) + err = s.app.OracleKeeper.CheckClaim(s.ctx, &msgClaim) s.Require().NotNil(err, "error should not be nil") s.Require().Contains(err.Error(), "not enough validators voted") @@ -140,7 +140,7 @@ func (s *TestSuite) TestProcessClaim() { msgClaim.AggSignature = bytes.Repeat([]byte{2}, 96) s.ctx = s.ctx.WithBlockTime(time.Unix(int64(msgClaim.Timestamp), 0)) - err = s.app.OracleKeeper.ProcessClaim(s.ctx, &msgClaim) + err = s.app.OracleKeeper.CheckClaim(s.ctx, &msgClaim) s.Require().NotNil(err, "error should not be nil") s.Require().Contains(err.Error(), "BLS signature converts failed") } diff --git a/x/oracle/keeper/msg_server.go b/x/oracle/keeper/msg_server.go index c05292ec1e..a82f577563 100644 --- a/x/oracle/keeper/msg_server.go +++ b/x/oracle/keeper/msg_server.go @@ -46,10 +46,11 @@ func (k msgServer) Claim(goCtx context.Context, req *types.MsgClaim) (*types.Msg sequence := k.oracleKeeper.CrossChainKeeper.GetReceiveSequence(ctx, sdk.ChainID(req.SrcChainId), types.RelayPackagesChannelId) if sequence != req.Sequence { - return nil, sdkerrors.Wrapf(types.ErrInvalidReceiveSequence, fmt.Sprintf("current sequence of channel %d is %d", types.RelayPackagesChannelId, sequence)) + logger.Error("wrong sequence") + //return nil, sdkerrors.Wrapf(types.ErrInvalidReceiveSequence, fmt.Sprintf("current sequence of channel %d is %d", types.RelayPackagesChannelId, sequence)) } - err := k.oracleKeeper.ProcessClaim(ctx, req) + err := k.oracleKeeper.CheckClaim(ctx, req) if err != nil { return nil, err } diff --git a/x/oracle/types/errors.go b/x/oracle/types/errors.go index 71aa61c235..ddfe7439d5 100644 --- a/x/oracle/types/errors.go +++ b/x/oracle/types/errors.go @@ -13,7 +13,7 @@ var ( ErrBlsPubKey = sdkerrors.Register(ModuleName, 9, "public key is invalid") ErrBlsVotesNotEnough = sdkerrors.Register(ModuleName, 10, "bls votes is not enough") ErrInvalidBlsSignature = sdkerrors.Register(ModuleName, 11, "bls signature is invalid") - ErrNotValidator = sdkerrors.Register(ModuleName, 12, "sender is not validator") + ErrNotRelayer = sdkerrors.Register(ModuleName, 12, "sender is not a relayer") ErrValidatorNotInTurn = sdkerrors.Register(ModuleName, 13, "validator is not in turn") ErrInvalidDestChainId = sdkerrors.Register(ModuleName, 14, "dest chain id is invalid") ErrInvalidSrcChainId = sdkerrors.Register(ModuleName, 15, "src chain id is invalid")