Skip to content

Commit

Permalink
add check to not accept headers if proof type is not supported
Browse files Browse the repository at this point in the history
  • Loading branch information
kingpinXD committed Oct 23, 2023
1 parent a5b4718 commit 8c7784d
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion x/observer/keeper/msg_server_add_block_header.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package keeper

import (
"context"
"fmt"

cosmoserrors "cosmossdk.io/errors"

Expand All @@ -20,6 +21,20 @@ func (k msgServer) AddBlockHeader(goCtx context.Context, msg *types.MsgAddBlockH
return nil, types.ErrNotAuthorizedPolicy
}

crosschainFlags, found := k.GetCrosschainFlags(ctx)
if !found {
return nil, fmt.Errorf("crosschain flags not found")
}
if crosschainFlags.BlockHeaderVerificationFlags == nil {
return nil, fmt.Errorf("block header verification flags not found")
}
if common.IsBitcoinChain(msg.ChainId) && !crosschainFlags.BlockHeaderVerificationFlags.IsBtcTypeChainEnabled {
return nil, fmt.Errorf("proof verification not enabled for bitcoin chain")
}
if common.IsEVMChain(msg.ChainId) && !crosschainFlags.BlockHeaderVerificationFlags.IsEthTypeChainEnabled {
return nil, fmt.Errorf("proof verification not enabled for evm chain")
}

// add vote to ballot
ballot, _, err := k.FindBallot(ctx, msg.Digest(), chain, types.ObservationType_InBoundTx)
if err != nil {
Expand All @@ -37,7 +52,7 @@ func (k msgServer) AddBlockHeader(goCtx context.Context, msg *types.MsgAddBlockH
/**
* Vote finalized, add block header to store
*/
_, found := k.GetBlockHeader(ctx, msg.BlockHash)
_, found = k.GetBlockHeader(ctx, msg.BlockHash)
if found {
hashString, err := common.HashToString(msg.ChainId, msg.BlockHash)
if err != nil {
Expand Down

0 comments on commit 8c7784d

Please sign in to comment.