diff --git a/docs/cli/zetacored/zetacored_tx_lightclient.md b/docs/cli/zetacored/zetacored_tx_lightclient.md index 3bdada0122..befe33201a 100644 --- a/docs/cli/zetacored/zetacored_tx_lightclient.md +++ b/docs/cli/zetacored/zetacored_tx_lightclient.md @@ -25,5 +25,6 @@ zetacored tx lightclient [flags] ### SEE ALSO * [zetacored tx](zetacored_tx.md) - Transactions subcommands -* [zetacored tx lightclient update-verification-flags](zetacored_tx_lightclient_update-verification-flags.md) - Update verification flags +* [zetacored tx lightclient disable-verification-flags](zetacored_tx_lightclient_disable-verification-flags.md) - Disable verification flags for the list of chains separated by comma +* [zetacored tx lightclient enable-verification-flags](zetacored_tx_lightclient_enable-verification-flags.md) - Disable verification flags for the list of chains separated by comma diff --git a/docs/cli/zetacored/zetacored_tx_lightclient_update-verification-flags.md b/docs/cli/zetacored/zetacored_tx_lightclient_update-verification-flags.md deleted file mode 100644 index 08222afc69..0000000000 --- a/docs/cli/zetacored/zetacored_tx_lightclient_update-verification-flags.md +++ /dev/null @@ -1,52 +0,0 @@ -# tx lightclient update-verification-flags - -Update verification flags - -``` -zetacored tx lightclient update-verification-flags [eth-type-chain-enabled] [btc-type-chain-enabled] [flags] -``` - -### Options - -``` - -a, --account-number uint The account number of the signing account (offline mode only) - --aux Generate aux signer data instead of sending a tx - -b, --broadcast-mode string Transaction broadcasting mode (sync|async|block) - --dry-run ignore the --gas flag and perform a simulation of a transaction, but don't broadcast it (when enabled, the local Keybase is not accessible) - --fee-granter string Fee granter grants fees for the transaction - --fee-payer string Fee payer pays fees for the transaction instead of deducting from the signer - --fees string Fees to pay along with transaction; eg: 10uatom - --from string Name or address of private key with which to sign - --gas string gas limit to set per-transaction; set to "auto" to calculate sufficient gas automatically. Note: "auto" option doesn't always report accurate results. Set a valid coin value to adjust the result. Can be used instead of "fees". (default 200000) - --gas-adjustment float adjustment factor to be multiplied against the estimate returned by the tx simulation; if the gas limit is set manually this flag is ignored (default 1) - --gas-prices string Gas prices in decimal format to determine the transaction fee (e.g. 0.1uatom) - --generate-only Build an unsigned transaction and write it to STDOUT (when enabled, the local Keybase only accessed when providing a key name) - -h, --help help for update-verification-flags - --keyring-backend string Select keyring's backend (os|file|kwallet|pass|test|memory) - --keyring-dir string The client Keyring directory; if omitted, the default 'home' directory will be used - --ledger Use a connected Ledger device - --node string [host]:[port] to tendermint rpc interface for this chain - --note string Note to add a description to the transaction (previously --memo) - --offline Offline mode (does not allow any online functionality) - -o, --output string Output format (text|json) - -s, --sequence uint The sequence number of the signing account (offline mode only) - --sign-mode string Choose sign mode (direct|amino-json|direct-aux), this is an advanced feature - --timeout-height uint Set a block timeout height to prevent the tx from being committed past a certain height - --tip string Tip is the amount that is going to be transferred to the fee payer on the target chain. This flag is only valid when used with --aux, and is ignored if the target chain didn't enable the TipDecorator - -y, --yes Skip tx broadcasting prompt confirmation -``` - -### Options inherited from parent commands - -``` - --chain-id string The network chain ID - --home string directory for config and data - --log_format string The logging format (json|plain) - --log_level string The logging level (trace|debug|info|warn|error|fatal|panic) - --trace print out full stack trace on errors -``` - -### SEE ALSO - -* [zetacored tx lightclient](zetacored_tx_lightclient.md) - lightclient transactions subcommands - diff --git a/docs/openapi/openapi.swagger.yaml b/docs/openapi/openapi.swagger.yaml index 2bcfa77836..9c92d44d60 100644 --- a/docs/openapi/openapi.swagger.yaml +++ b/docs/openapi/openapi.swagger.yaml @@ -53602,8 +53602,6 @@ definitions: $ref: '#/definitions/chainsConsensus' is_external: type: boolean - is_header_supported: - type: boolean chainsChainName: type: string enum: @@ -54306,7 +54304,9 @@ definitions: type: string format: byte title: ChainState defines the overall state of the block headers for a given chain - lightclientMsgUpdateVerificationFlagsResponse: + lightclientMsgDisableVerificationFlagsResponse: + type: object + lightclientMsgEnableVerificationFlagsResponse: type: object lightclientQueryAllBlockHeaderResponse: type: object @@ -54347,13 +54347,17 @@ definitions: type: object properties: verification_flags: - $ref: '#/definitions/lightclientVerificationFlags' + type: array + items: + type: object + $ref: '#/definitions/lightclientVerificationFlags' lightclientVerificationFlags: type: object properties: - ethTypeChainEnabled: - type: boolean - btcTypeChainEnabled: + chain_id: + type: string + format: int64 + enabled: type: boolean title: VerificationFlags is a structure containing information which chain types are enabled for block header verification observerAdmin_Policy: diff --git a/docs/spec/lightclient/messages.md b/docs/spec/lightclient/messages.md index 057d90f3b6..269274e011 100644 --- a/docs/spec/lightclient/messages.md +++ b/docs/spec/lightclient/messages.md @@ -1,15 +1,26 @@ # Messages -## MsgUpdateVerificationFlags +## MsgEnableVerificationFlags -UpdateVerificationFlags updates the light client verification flags. -This disables/enables blocks verification of the light client for the specified chain. -Emergency group can disable flags, it requires operational group if at least one flag is being enabled +EnableVerificationFlags enables the verification flags for the given chain IDs +Enabled chains allow the submissions of block headers and using it to verify the correctness of proofs ```proto -message MsgUpdateVerificationFlags { +message MsgEnableVerificationFlags { string creator = 1; - VerificationFlags verification_flags = 2; + int64 chain_id_list = 2; +} +``` + +## MsgDisableVerificationFlags + +DisableVerificationFlags disables the verification flags for the given chain IDs +Disabled chains do not allow the submissions of block headers or using it to verify the correctness of proofs + +```proto +message MsgDisableVerificationFlags { + string creator = 1; + int64 chain_id_list = 2; } ``` diff --git a/pkg/chains/chain.go b/pkg/chains/chain.go index 77adc70119..9d6b57acf2 100644 --- a/pkg/chains/chain.go +++ b/pkg/chains/chain.go @@ -101,8 +101,8 @@ func IsZetaChain(chainID int64) bool { return ChainIDInChainList(chainID, ChainListByNetwork(Network_zeta)) } -// IsHeaderSupportedEvmChain returns true if the chain is an EVM chain supporting block header-based verification -func IsHeaderSupportedEvmChain(chainID int64) bool { +// IsHeaderSupportedChain returns true if the chain is an EVM chain supporting block header-based verification +func IsHeaderSupportedChain(chainID int64) bool { return ChainIDInChainList(chainID, ChainListForHeaderSupport()) } diff --git a/pkg/chains/chain_test.go b/pkg/chains/chain_test.go index 69cc5418db..e66bb6432b 100644 --- a/pkg/chains/chain_test.go +++ b/pkg/chains/chain_test.go @@ -203,7 +203,7 @@ func TestIsHeaderSupportedEVMChain(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - require.Equal(t, tt.want, IsHeaderSupportedEvmChain(tt.chainID)) + require.Equal(t, tt.want, IsHeaderSupportedChain(tt.chainID)) }) } } diff --git a/typescript/lightclient/genesis_pb.d.ts b/typescript/lightclient/genesis_pb.d.ts index 03bdc94b3a..7982115e5b 100644 --- a/typescript/lightclient/genesis_pb.d.ts +++ b/typescript/lightclient/genesis_pb.d.ts @@ -26,9 +26,9 @@ export declare class GenesisState extends Message { chainStates: ChainState[]; /** - * @generated from field: zetachain.zetacore.lightclient.VerificationFlags verification_flags = 3; + * @generated from field: repeated zetachain.zetacore.lightclient.VerificationFlags verification_flags = 3; */ - verificationFlags?: VerificationFlags; + verificationFlags: VerificationFlags[]; constructor(data?: PartialMessage); diff --git a/typescript/lightclient/query_pb.d.ts b/typescript/lightclient/query_pb.d.ts index 50d17f1885..0f38cf60de 100644 --- a/typescript/lightclient/query_pb.d.ts +++ b/typescript/lightclient/query_pb.d.ts @@ -304,9 +304,9 @@ export declare class QueryVerificationFlagsRequest extends Message { /** - * @generated from field: zetachain.zetacore.lightclient.VerificationFlags verification_flags = 1; + * @generated from field: repeated zetachain.zetacore.lightclient.VerificationFlags verification_flags = 1; */ - verificationFlags?: VerificationFlags; + verificationFlags: VerificationFlags[]; constructor(data?: PartialMessage); diff --git a/typescript/lightclient/tx_pb.d.ts b/typescript/lightclient/tx_pb.d.ts index 48e827c654..154e6f7878 100644 --- a/typescript/lightclient/tx_pb.d.ts +++ b/typescript/lightclient/tx_pb.d.ts @@ -5,53 +5,100 @@ import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; import { Message, proto3 } from "@bufbuild/protobuf"; -import type { VerificationFlags } from "./verification_flags_pb.js"; /** - * @generated from message zetachain.zetacore.lightclient.MsgUpdateVerificationFlags + * @generated from message zetachain.zetacore.lightclient.MsgEnableVerificationFlags */ -export declare class MsgUpdateVerificationFlags extends Message { +export declare class MsgEnableVerificationFlags extends Message { /** * @generated from field: string creator = 1; */ creator: string; /** - * @generated from field: zetachain.zetacore.lightclient.VerificationFlags verification_flags = 2; + * @generated from field: repeated int64 chain_id_list = 2; */ - verificationFlags?: VerificationFlags; + chainIdList: bigint[]; - constructor(data?: PartialMessage); + constructor(data?: PartialMessage); static readonly runtime: typeof proto3; - static readonly typeName = "zetachain.zetacore.lightclient.MsgUpdateVerificationFlags"; + static readonly typeName = "zetachain.zetacore.lightclient.MsgEnableVerificationFlags"; static readonly fields: FieldList; - static fromBinary(bytes: Uint8Array, options?: Partial): MsgUpdateVerificationFlags; + static fromBinary(bytes: Uint8Array, options?: Partial): MsgEnableVerificationFlags; - static fromJson(jsonValue: JsonValue, options?: Partial): MsgUpdateVerificationFlags; + static fromJson(jsonValue: JsonValue, options?: Partial): MsgEnableVerificationFlags; - static fromJsonString(jsonString: string, options?: Partial): MsgUpdateVerificationFlags; + static fromJsonString(jsonString: string, options?: Partial): MsgEnableVerificationFlags; - static equals(a: MsgUpdateVerificationFlags | PlainMessage | undefined, b: MsgUpdateVerificationFlags | PlainMessage | undefined): boolean; + static equals(a: MsgEnableVerificationFlags | PlainMessage | undefined, b: MsgEnableVerificationFlags | PlainMessage | undefined): boolean; } /** - * @generated from message zetachain.zetacore.lightclient.MsgUpdateVerificationFlagsResponse + * @generated from message zetachain.zetacore.lightclient.MsgEnableVerificationFlagsResponse */ -export declare class MsgUpdateVerificationFlagsResponse extends Message { - constructor(data?: PartialMessage); +export declare class MsgEnableVerificationFlagsResponse extends Message { + constructor(data?: PartialMessage); static readonly runtime: typeof proto3; - static readonly typeName = "zetachain.zetacore.lightclient.MsgUpdateVerificationFlagsResponse"; + static readonly typeName = "zetachain.zetacore.lightclient.MsgEnableVerificationFlagsResponse"; static readonly fields: FieldList; - static fromBinary(bytes: Uint8Array, options?: Partial): MsgUpdateVerificationFlagsResponse; + static fromBinary(bytes: Uint8Array, options?: Partial): MsgEnableVerificationFlagsResponse; - static fromJson(jsonValue: JsonValue, options?: Partial): MsgUpdateVerificationFlagsResponse; + static fromJson(jsonValue: JsonValue, options?: Partial): MsgEnableVerificationFlagsResponse; - static fromJsonString(jsonString: string, options?: Partial): MsgUpdateVerificationFlagsResponse; + static fromJsonString(jsonString: string, options?: Partial): MsgEnableVerificationFlagsResponse; - static equals(a: MsgUpdateVerificationFlagsResponse | PlainMessage | undefined, b: MsgUpdateVerificationFlagsResponse | PlainMessage | undefined): boolean; + static equals(a: MsgEnableVerificationFlagsResponse | PlainMessage | undefined, b: MsgEnableVerificationFlagsResponse | PlainMessage | undefined): boolean; +} + +/** + * @generated from message zetachain.zetacore.lightclient.MsgDisableVerificationFlags + */ +export declare class MsgDisableVerificationFlags extends Message { + /** + * @generated from field: string creator = 1; + */ + creator: string; + + /** + * @generated from field: repeated int64 chain_id_list = 2; + */ + chainIdList: bigint[]; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "zetachain.zetacore.lightclient.MsgDisableVerificationFlags"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): MsgDisableVerificationFlags; + + static fromJson(jsonValue: JsonValue, options?: Partial): MsgDisableVerificationFlags; + + static fromJsonString(jsonString: string, options?: Partial): MsgDisableVerificationFlags; + + static equals(a: MsgDisableVerificationFlags | PlainMessage | undefined, b: MsgDisableVerificationFlags | PlainMessage | undefined): boolean; +} + +/** + * @generated from message zetachain.zetacore.lightclient.MsgDisableVerificationFlagsResponse + */ +export declare class MsgDisableVerificationFlagsResponse extends Message { + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "zetachain.zetacore.lightclient.MsgDisableVerificationFlagsResponse"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): MsgDisableVerificationFlagsResponse; + + static fromJson(jsonValue: JsonValue, options?: Partial): MsgDisableVerificationFlagsResponse; + + static fromJsonString(jsonString: string, options?: Partial): MsgDisableVerificationFlagsResponse; + + static equals(a: MsgDisableVerificationFlagsResponse | PlainMessage | undefined, b: MsgDisableVerificationFlagsResponse | PlainMessage | undefined): boolean; } diff --git a/typescript/lightclient/verification_flags_pb.d.ts b/typescript/lightclient/verification_flags_pb.d.ts index d2325779b2..9487b13516 100644 --- a/typescript/lightclient/verification_flags_pb.d.ts +++ b/typescript/lightclient/verification_flags_pb.d.ts @@ -13,14 +13,14 @@ import { Message, proto3 } from "@bufbuild/protobuf"; */ export declare class VerificationFlags extends Message { /** - * @generated from field: bool ethTypeChainEnabled = 1; + * @generated from field: int64 chain_id = 1; */ - ethTypeChainEnabled: boolean; + chainId: bigint; /** - * @generated from field: bool btcTypeChainEnabled = 2; + * @generated from field: bool enabled = 2; */ - btcTypeChainEnabled: boolean; + enabled: boolean; constructor(data?: PartialMessage); diff --git a/typescript/pkg/chains/chains_pb.d.ts b/typescript/pkg/chains/chains_pb.d.ts index 9b1262b8ed..15cca4698b 100644 --- a/typescript/pkg/chains/chains_pb.d.ts +++ b/typescript/pkg/chains/chains_pb.d.ts @@ -257,11 +257,6 @@ export declare class Chain extends Message { */ isExternal: boolean; - /** - * @generated from field: bool is_header_supported = 8; - */ - isHeaderSupported: boolean; - constructor(data?: PartialMessage); static readonly runtime: typeof proto3; diff --git a/x/lightclient/client/cli/tx.go b/x/lightclient/client/cli/tx.go index 5b14f7db20..5d73dfa500 100644 --- a/x/lightclient/client/cli/tx.go +++ b/x/lightclient/client/cli/tx.go @@ -19,7 +19,8 @@ func GetTxCmd() *cobra.Command { } cmd.AddCommand( - CmdUpdateVerificationFlags(), + CmdEnableVerificationFlags(), + CmdDisableVerificationFlags(), ) return cmd diff --git a/x/lightclient/client/cli/tx_disable_verification_flags.go b/x/lightclient/client/cli/tx_disable_verification_flags.go index a2b3fe9a3d..136fc14b71 100644 --- a/x/lightclient/client/cli/tx_disable_verification_flags.go +++ b/x/lightclient/client/cli/tx_disable_verification_flags.go @@ -13,8 +13,8 @@ import ( func CmdDisableVerificationFlags() *cobra.Command { cmd := &cobra.Command{ - Use: "disable-verification-flags [list of chainid]", - Short: "Enable verification flags list of chains separated by comma and enabled flag", + Use: "disable-verification-flags [list of chain-id]", + Short: "Disable verification flags for the list of chains separated by comma", Long: `Provide a list of chain ids separated by comma to enable block header verification for the specified chain ids. Example: diff --git a/x/lightclient/client/cli/tx_enable_verification_flags.go b/x/lightclient/client/cli/tx_enable_verification_flags.go index f5ff5fbe2d..6ced87a553 100644 --- a/x/lightclient/client/cli/tx_enable_verification_flags.go +++ b/x/lightclient/client/cli/tx_enable_verification_flags.go @@ -11,10 +11,10 @@ import ( "github.com/zeta-chain/zetacore/x/lightclient/types" ) -func CmdUpdateVerificationFlags() *cobra.Command { +func CmdEnableVerificationFlags() *cobra.Command { cmd := &cobra.Command{ - Use: "enable-verification-flags [list of chainid]", - Short: "Enable verification flags list of chains separated by comma and enabled flag", + Use: "enable-verification-flags [list of chain-id]", + Short: "Disable verification flags for the list of chains separated by comma", Long: `Provide a list of chain ids separated by comma to enable block header verification for the specified chain ids. Example: diff --git a/x/lightclient/keeper/msg_server_disable_verification_flags.go b/x/lightclient/keeper/msg_server_disable_verification_flags.go index 5ac394821d..1950bd716c 100644 --- a/x/lightclient/keeper/msg_server_disable_verification_flags.go +++ b/x/lightclient/keeper/msg_server_disable_verification_flags.go @@ -8,6 +8,8 @@ import ( "github.com/zeta-chain/zetacore/x/lightclient/types" ) +// DisableVerificationFlags disables the verification flags for the given chain IDs +// Disabled chains do not allow the submissions of block headers or using it to verify the correctness of proofs func (k msgServer) DisableVerificationFlags(goCtx context.Context, msg *types.MsgDisableVerificationFlags) (*types.MsgDisableVerificationFlagsResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) diff --git a/x/lightclient/keeper/msg_server_enable_verification_flags.go b/x/lightclient/keeper/msg_server_enable_verification_flags.go index c5c702ade0..4d3c0f2750 100644 --- a/x/lightclient/keeper/msg_server_enable_verification_flags.go +++ b/x/lightclient/keeper/msg_server_enable_verification_flags.go @@ -8,9 +8,8 @@ import ( "github.com/zeta-chain/zetacore/x/lightclient/types" ) -// UpdateVerificationFlags updates the light client verification flags. -// This disables/enables blocks verification of the light client for the specified chain. -// Emergency group can disable flags, it requires operational group if at least one flag is being enabled +// EnableVerificationFlags enables the verification flags for the given chain IDs +// Enabled chains allow the submissions of block headers and using it to verify the correctness of proofs func (k msgServer) EnableVerificationFlags(goCtx context.Context, msg *types.MsgEnableVerificationFlags) ( *types.MsgEnableVerificationFlagsResponse, error, diff --git a/x/observer/types/message_vote_block_header.go b/x/observer/types/message_vote_block_header.go index 974db7d34d..0cc70776da 100644 --- a/x/observer/types/message_vote_block_header.go +++ b/x/observer/types/message_vote_block_header.go @@ -53,7 +53,7 @@ func (msg *MsgVoteBlockHeader) ValidateBasic() error { return cosmoserrors.Wrapf(sdkerrors.ErrInvalidAddress, err.Error()) } - if !chains.IsHeaderSupportedEvmChain(msg.ChainId) && !chains.IsBitcoinChain(msg.ChainId) { + if !chains.IsHeaderSupportedChain(msg.ChainId) { return cosmoserrors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid chain id (%d)", msg.ChainId) } diff --git a/x/observer/types/message_vote_block_header_test.go b/x/observer/types/message_vote_block_header_test.go index 46147c847b..f398617cbf 100644 --- a/x/observer/types/message_vote_block_header_test.go +++ b/x/observer/types/message_vote_block_header_test.go @@ -9,6 +9,7 @@ import ( ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" "github.com/stretchr/testify/require" + "github.com/zeta-chain/zetacore/pkg/chains" "github.com/zeta-chain/zetacore/pkg/proofs" "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" @@ -57,6 +58,17 @@ func TestMsgVoteBlockHeader_ValidateBasic(t *testing.T) { ), error: true, }, + { + name: "bitcoin chain id", + msg: types.NewMsgVoteBlockHeader( + sample.AccAddress(), + chains.BtcMainnetChain.ChainId, + []byte{}, + 6, + proofs.HeaderData{}, + ), + error: true, + }, { name: "invalid header", msg: types.NewMsgVoteBlockHeader( diff --git a/zetaclient/evm/evm_client.go b/zetaclient/evm/evm_client.go index 1ee4a2edf5..fe80c370b3 100644 --- a/zetaclient/evm/evm_client.go +++ b/zetaclient/evm/evm_client.go @@ -840,7 +840,7 @@ func (ob *ChainClient) ObserverTSSReceive(startBlock, toBlock uint64) uint64 { // TODO: consider having a independent ticker(from TSS scaning) for posting block headers // https://github.com/zeta-chain/node/issues/1847 verificationFlags, found := ob.coreContext.GetVerificationFlags(ob.chain.ChainId) - if found && verificationFlags.Enabled && chains.IsHeaderSupportedEvmChain(ob.chain.ChainId) { + if found && verificationFlags.Enabled && chains.IsHeaderSupportedChain(ob.chain.ChainId) { // post block header for supported chains err := ob.postBlockHeader(toBlock) if err != nil {