Skip to content

Commit

Permalink
use error in lightclient
Browse files Browse the repository at this point in the history
  • Loading branch information
lumtis committed Apr 17, 2024
1 parent 60e57f3 commit 5c5bc0d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
1 change: 1 addition & 0 deletions x/lightclient/types/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ var (
ErrBlockHeaderNotFound = errorsmod.Register(ModuleName, 1108, "block header not found")
ErrProofVerificationFailed = errorsmod.Register(ModuleName, 1109, "proof verification failed")
ErrInvalidHeight = errorsmod.Register(ModuleName, 1110, "invalid height")
ErrInvalidBlockHeader = errorsmod.Register(ModuleName, 1111, "invalid block header")
)
3 changes: 2 additions & 1 deletion x/observer/keeper/msg_server_vote_block_header.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

cosmoserrors "cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
lightclienttypes "github.com/zeta-chain/zetacore/x/lightclient/types"
"github.com/zeta-chain/zetacore/x/observer/types"
)

Expand All @@ -26,7 +27,7 @@ func (k msgServer) VoteBlockHeader(goCtx context.Context, msg *types.MsgVoteBloc
// check the new block header is valid
parentHash, err := k.lightclientKeeper.CheckNewBlockHeader(ctx, msg.ChainId, msg.BlockHash, msg.Height, msg.Header)
if err != nil {
return nil, cosmoserrors.Wrap(types.ErrInvalidBlockHeader, err.Error())
return nil, cosmoserrors.Wrap(lightclienttypes.ErrInvalidBlockHeader, err.Error())
}

// add vote to ballot
Expand Down
3 changes: 2 additions & 1 deletion x/observer/keeper/msg_server_vote_block_header_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
keepertest "github.com/zeta-chain/zetacore/testutil/keeper"
mocks "github.com/zeta-chain/zetacore/testutil/keeper/mocks/observer"
"github.com/zeta-chain/zetacore/testutil/sample"
lightclienttypes "github.com/zeta-chain/zetacore/x/lightclient/types"
"github.com/zeta-chain/zetacore/x/observer/keeper"
"github.com/zeta-chain/zetacore/x/observer/types"
)
Expand Down Expand Up @@ -118,7 +119,7 @@ func TestMsgServer_VoteBlockHeader(t *testing.T) {
Header: proofs.HeaderData{},
})

require.ErrorIs(t, err, types.ErrInvalidBlockHeader)
require.ErrorIs(t, err, lightclienttypes.ErrInvalidBlockHeader)
})

t.Run("can create a new ballot, vote and finalize", func(t *testing.T) {
Expand Down
20 changes: 9 additions & 11 deletions x/observer/types/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,17 @@ var (
ErrKeygenBlockTooLow = errorsmod.Register(ModuleName, 1114, "please set a block number at-least 10 blocks higher than the current block number")
ErrKeygenCompleted = errorsmod.Register(ModuleName, 1115, "keygen already completed")

ErrBlockHeaderVerificationDisabled = errorsmod.Register(ModuleName, 1122, "block header verification is disabled")
ErrLastObserverCountNotFound = errorsmod.Register(ModuleName, 1123, "last observer count not found")
ErrUpdateObserver = errorsmod.Register(ModuleName, 1124, "unable to update observer")
ErrNodeAccountNotFound = errorsmod.Register(ModuleName, 1125, "node account not found")
ErrInvalidChainParams = errorsmod.Register(ModuleName, 1126, "invalid chain params")
ErrChainParamsNotFound = errorsmod.Register(ModuleName, 1127, "chain params not found")
ErrParamsMinObserverDelegation = errorsmod.Register(ModuleName, 1128, "min observer delegation cannot be nil")
ErrMinDelegationNotFound = errorsmod.Register(ModuleName, 1129, "min delegation not found")
ErrObserverSetNotFound = errorsmod.Register(ModuleName, 1130, "observer set not found")
ErrTssNotFound = errorsmod.Register(ModuleName, 1131, "tss not found")
ErrLastObserverCountNotFound = errorsmod.Register(ModuleName, 1123, "last observer count not found")
ErrUpdateObserver = errorsmod.Register(ModuleName, 1124, "unable to update observer")
ErrNodeAccountNotFound = errorsmod.Register(ModuleName, 1125, "node account not found")
ErrInvalidChainParams = errorsmod.Register(ModuleName, 1126, "invalid chain params")
ErrChainParamsNotFound = errorsmod.Register(ModuleName, 1127, "chain params not found")
ErrParamsMinObserverDelegation = errorsmod.Register(ModuleName, 1128, "min observer delegation cannot be nil")
ErrMinDelegationNotFound = errorsmod.Register(ModuleName, 1129, "min delegation not found")
ErrObserverSetNotFound = errorsmod.Register(ModuleName, 1130, "observer set not found")
ErrTssNotFound = errorsmod.Register(ModuleName, 1131, "tss not found")

ErrInboundDisabled = errorsmod.Register(ModuleName, 1132, "inbound tx processing is disabled")
ErrInvalidZetaCoinTypes = errorsmod.Register(ModuleName, 1133, "invalid zeta coin types")
ErrNotObserver = errorsmod.Register(ModuleName, 1134, "sender is not an observer")
ErrInvalidBlockHeader = errorsmod.Register(ModuleName, 1135, "invalid block header")
)

0 comments on commit 5c5bc0d

Please sign in to comment.