From 482b15f9f88c3a82d155976573f5ba920c74eb70 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Tue, 23 Apr 2024 18:32:11 -0400 Subject: [PATCH 01/31] add more fields to the chains struct --- pkg/chains/chain.go | 43 +-- pkg/chains/chain_test.go | 14 +- pkg/chains/chains.go | 289 ++++++++++++------- pkg/chains/chains.pb.go | 417 ++++++++++++++++++++++++++-- pkg/chains/chains_test.go | 249 +++++++++++++++-- proto/pkg/chains/chains.proto | 36 +++ testutil/network/genesis_state.go | 5 +- testutil/sample/observer.go | 2 +- x/observer/types/params.go | 6 +- zetaclient/zetabridge/query_test.go | 20 +- zetaclient/zetabridge/tx_test.go | 21 +- 11 files changed, 901 insertions(+), 201 deletions(-) diff --git a/pkg/chains/chain.go b/pkg/chains/chain.go index b86d54a176..0eebe1f7c9 100644 --- a/pkg/chains/chain.go +++ b/pkg/chains/chain.go @@ -20,10 +20,10 @@ func (chain Chain) IsEqual(c Chain) bool { } func (chain Chain) IsZetaChain() bool { - return chain.InChainList(ZetaChainList()) + return chain.Network == Network_ZETA } func (chain Chain) IsExternalChain() bool { - return !chain.InChainList(ZetaChainList()) + return chain.IsExternal } // EncodeAddress bytes representations of address @@ -82,35 +82,19 @@ func DecodeAddressFromChainID(chainID int64, addr string) ([]byte, error) { } func IsZetaChain(chainID int64) bool { - return ChainIDInChainList(chainID, ZetaChainList()) + return ChainIDInChainList(chainID, ChainListByNetwork(Network_ZETA)) } // IsEVMChain returns true if the chain is an EVM chain -// TODO: put this information directly in chain object -// https://github.com/zeta-chain/node-private/issues/63 func IsEVMChain(chainID int64) bool { - return chainID == 5 || // Goerli - chainID == AmoyChain().ChainId || - chainID == SepoliaChain().ChainId || // Sepolia - chainID == 80001 || // Polygon mumbai - chainID == 97 || // BSC testnet - chainID == 1001 || // klaytn baobab - chainID == 1337 || // eth privnet - chainID == 1 || // eth mainnet - chainID == 56 || // bsc mainnet - chainID == 137 // polygon mainnet + evmChainList := ChainListByConsensus(Consensus_Ethereum) + return ChainIDInChainList(chainID, evmChainList) } // IsHeaderSupportedEvmChain returns true if the chain is an EVM chain supporting block header-based verification -// TODO: put this information directly in chain object -// https://github.com/zeta-chain/node-private/issues/63 func IsHeaderSupportedEvmChain(chainID int64) bool { - return chainID == 5 || // Goerli - chainID == SepoliaChain().ChainId || // Sepolia - chainID == 97 || // BSC testnet - chainID == 1337 || // eth privnet - chainID == 1 || // eth mainnet - chainID == 56 // bsc mainnet + chainList := ChainListForHeaderSupport() + return ChainIDInChainList(chainID, chainList) } // SupportMerkleProof returns true if the chain supports block header-based verification @@ -122,19 +106,14 @@ func (chain Chain) SupportMerkleProof() bool { // TODO: put this information directly in chain object // https://github.com/zeta-chain/node-private/issues/63 func IsBitcoinChain(chainID int64) bool { - return chainID == 18444 || // regtest - chainID == 18332 || //testnet - chainID == 8332 // mainnet + btcChainList := ChainListByNetwork(Network_BTC) + return ChainIDInChainList(chainID, btcChainList) } // IsEthereumChain returns true if the chain is an Ethereum chain -// TODO: put this information directly in chain object -// https://github.com/zeta-chain/node-private/issues/63 func IsEthereumChain(chainID int64) bool { - return chainID == 1 || // eth mainnet - chainID == 5 || // Goerli - chainID == SepoliaChain().ChainId || // Sepolia - chainID == 1337 // eth privnet + ethChainList := ChainListByNetwork(Network_ETH) + return ChainIDInChainList(chainID, ethChainList) } // IsEmpty is to determinate whether the chain is empty diff --git a/pkg/chains/chain_test.go b/pkg/chains/chain_test.go index 8d491d1780..cfeb53eac4 100644 --- a/pkg/chains/chain_test.go +++ b/pkg/chains/chain_test.go @@ -138,11 +138,11 @@ func TestChain_DecodeAddress(t *testing.T) { } func TestChain_InChainList(t *testing.T) { - require.True(t, ZetaChainMainnet().InChainList(ZetaChainList())) - require.True(t, ZetaMocknetChain().InChainList(ZetaChainList())) - require.True(t, ZetaPrivnetChain().InChainList(ZetaChainList())) - require.True(t, ZetaTestnetChain().InChainList(ZetaChainList())) - require.False(t, EthChain().InChainList(ZetaChainList())) + require.True(t, ZetaChainMainnet().InChainList(ChainListByNetwork(Network_ZETA))) + require.True(t, ZetaMocknetChain().InChainList(ChainListByNetwork(Network_ZETA))) + require.True(t, ZetaPrivnetChain().InChainList(ChainListByNetwork(Network_ZETA))) + require.True(t, ZetaTestnetChain().InChainList(ChainListByNetwork(Network_ZETA))) + require.False(t, EthChain().InChainList(ChainListByNetwork(Network_ZETA))) } func TestIsZetaChain(t *testing.T) { @@ -376,6 +376,6 @@ func TestGetBTCChainIDFromChainParams(t *testing.T) { } func TestChainIDInChainList(t *testing.T) { - require.True(t, ChainIDInChainList(ZetaChainMainnet().ChainId, ZetaChainList())) - require.False(t, ChainIDInChainList(EthChain().ChainId, ZetaChainList())) + require.True(t, ChainIDInChainList(ZetaChainMainnet().ChainId, ChainListByNetwork(Network_ZETA))) + require.False(t, ChainIDInChainList(EthChain().ChainId, ChainListByNetwork(Network_ZETA))) } diff --git a/pkg/chains/chains.go b/pkg/chains/chains.go index 651051da3c..0b0a724d19 100644 --- a/pkg/chains/chains.go +++ b/pkg/chains/chains.go @@ -2,123 +2,217 @@ package chains import "fmt" -// Zeta chains - +// Mainnet chains func ZetaChainMainnet() Chain { return Chain{ - ChainName: ChainName_zeta_mainnet, - ChainId: 7000, + ChainName: ChainName_zeta_mainnet, + ChainId: 7000, + Network: Network_ZETA, + NetworkType: NetworkType_MAINNET, + Vm: Vm_EVM, + Consensus: Consensus_Tendermint, + IsExternal: false, + IsHeaderSupported: false, } } - -func ZetaTestnetChain() Chain { - return Chain{ - ChainName: ChainName_zeta_testnet, - ChainId: 7001, - } -} - -func ZetaMocknetChain() Chain { - return Chain{ - ChainName: ChainName_zeta_mainnet, - ChainId: 70000, - } -} - -func ZetaPrivnetChain() Chain { - return Chain{ - ChainName: ChainName_zeta_mainnet, - ChainId: 101, - } -} - -// Mainnet chains - func EthChain() Chain { return Chain{ - ChainName: ChainName_eth_mainnet, - ChainId: 1, + ChainName: ChainName_eth_mainnet, + ChainId: 1, + Network: Network_ETH, + NetworkType: NetworkType_MAINNET, + Vm: Vm_EVM, + Consensus: Consensus_Ethereum, + IsExternal: true, + IsHeaderSupported: true, } } func BscMainnetChain() Chain { return Chain{ - ChainName: ChainName_bsc_mainnet, - ChainId: 56, + ChainName: ChainName_bsc_mainnet, + ChainId: 56, + Network: Network_BSC, + NetworkType: NetworkType_MAINNET, + Vm: Vm_EVM, + Consensus: Consensus_Ethereum, + IsExternal: true, + IsHeaderSupported: true, } } func BtcMainnetChain() Chain { return Chain{ - ChainName: ChainName_btc_mainnet, - ChainId: 8332, + ChainName: ChainName_btc_mainnet, + ChainId: 8332, + Network: Network_BTC, + NetworkType: NetworkType_MAINNET, + Vm: Vm_NO_VM, + Consensus: Consensus_Bitcoin, + IsExternal: true, + IsHeaderSupported: false, } } func PolygonChain() Chain { return Chain{ - ChainName: ChainName_polygon_mainnet, - ChainId: 137, + ChainName: ChainName_polygon_mainnet, + ChainId: 137, + Network: Network_POLYGON, + NetworkType: NetworkType_MAINNET, + Vm: Vm_EVM, + Consensus: Consensus_Ethereum, + IsExternal: true, + IsHeaderSupported: false, } } // Testnet chains +func ZetaTestnetChain() Chain { + return Chain{ + ChainName: ChainName_zeta_testnet, + ChainId: 7001, + Network: Network_ZETA, + NetworkType: NetworkType_TESTNET, + Vm: Vm_EVM, + Consensus: Consensus_Tendermint, + IsExternal: false, + IsHeaderSupported: false, + } +} + func SepoliaChain() Chain { return Chain{ - ChainName: ChainName_sepolia_testnet, - ChainId: 11155111, + ChainName: ChainName_sepolia_testnet, + ChainId: 11155111, + Network: Network_ETH, + NetworkType: NetworkType_TESTNET, + Vm: Vm_EVM, + Consensus: Consensus_Ethereum, + IsExternal: true, + IsHeaderSupported: true, } } +// GoerliChain Deprecated func GoerliChain() Chain { return Chain{ - ChainName: ChainName_goerli_testnet, - ChainId: 5, + ChainName: ChainName_goerli_testnet, + ChainId: 5, + Network: Network_ETH, + NetworkType: NetworkType_TESTNET, + Vm: Vm_EVM, + Consensus: Consensus_Ethereum, + IsExternal: true, + IsHeaderSupported: true, } } func BscTestnetChain() Chain { return Chain{ - ChainName: ChainName_bsc_testnet, - ChainId: 97, + ChainName: ChainName_bsc_testnet, + ChainId: 97, + Network: Network_BSC, + NetworkType: NetworkType_TESTNET, + Vm: Vm_EVM, + Consensus: Consensus_Ethereum, + IsExternal: true, + IsHeaderSupported: true, } } func BtcTestNetChain() Chain { return Chain{ - ChainName: ChainName_btc_testnet, - ChainId: 18332, + ChainName: ChainName_btc_testnet, + ChainId: 18332, + Network: Network_BTC, + NetworkType: NetworkType_TESTNET, + Vm: Vm_NO_VM, + Consensus: Consensus_Bitcoin, + IsExternal: true, + IsHeaderSupported: false, } } +// MumbaiChain Deprecated func MumbaiChain() Chain { return Chain{ - ChainName: ChainName_mumbai_testnet, - ChainId: 80001, + ChainName: ChainName_mumbai_testnet, + ChainId: 80001, + Network: Network_POLYGON, + NetworkType: NetworkType_TESTNET, + Vm: Vm_EVM, + Consensus: Consensus_Ethereum, + IsExternal: true, + IsHeaderSupported: false, } } func AmoyChain() Chain { return Chain{ - ChainName: ChainName_amoy_testnet, - ChainId: 80002, + ChainName: ChainName_amoy_testnet, + ChainId: 80002, + Network: Network_POLYGON, + NetworkType: NetworkType_TESTNET, + Vm: Vm_EVM, + Consensus: Consensus_Ethereum, + IsExternal: true, + IsHeaderSupported: false, + } +} + +// Devnet chains +func ZetaMocknetChain() Chain { + return Chain{ + ChainName: ChainName_zeta_mainnet, + ChainId: 70000, + Network: Network_ZETA, + NetworkType: NetworkType_DEVNET, + Vm: Vm_EVM, + Consensus: Consensus_Tendermint, + IsExternal: false, + IsHeaderSupported: false, } } // Privnet chains +func ZetaPrivnetChain() Chain { + return Chain{ + ChainName: ChainName_zeta_mainnet, + ChainId: 101, + Network: Network_ZETA, + NetworkType: NetworkType_PRIVNET, + Vm: Vm_EVM, + Consensus: Consensus_Tendermint, + IsExternal: false, + IsHeaderSupported: false, + } +} func BtcRegtestChain() Chain { return Chain{ - ChainName: ChainName_btc_regtest, - ChainId: 18444, + ChainName: ChainName_btc_regtest, + ChainId: 18444, + Network: Network_BTC, + NetworkType: NetworkType_PRIVNET, + Vm: Vm_NO_VM, + Consensus: Consensus_Bitcoin, + IsExternal: true, + IsHeaderSupported: false, } } func GoerliLocalnetChain() Chain { return Chain{ - ChainName: ChainName_goerli_localnet, - ChainId: 1337, + ChainName: ChainName_goerli_localnet, + ChainId: 1337, + Network: Network_ETH, + NetworkType: NetworkType_PRIVNET, + Vm: Vm_EVM, + Consensus: Consensus_Ethereum, + IsExternal: true, + IsHeaderSupported: true, } } @@ -127,6 +221,7 @@ func BtcDustOffset() int64 { } // DefaultChainsList returns a list of default chains +// TODO : Check why polygon is not in this list func DefaultChainsList() []*Chain { return chainListPointers([]Chain{ BtcMainnetChain(), @@ -144,66 +239,60 @@ func DefaultChainsList() []*Chain { ZetaTestnetChain(), ZetaMocknetChain(), ZetaPrivnetChain(), + PolygonChain(), }) } // MainnetChainList returns a list of mainnet chains -func MainnetChainList() []*Chain { - return chainListPointers([]Chain{ - ZetaChainMainnet(), - BtcMainnetChain(), - BscMainnetChain(), - EthChain(), - }) -} - -// TestnetChainList returns a list of testnet chains -func TestnetChainList() []*Chain { - return chainListPointers([]Chain{ - ZetaTestnetChain(), - BtcTestNetChain(), - MumbaiChain(), - AmoyChain(), - BscTestnetChain(), - GoerliChain(), - SepoliaChain(), - }) +func ChainListByNetworkType(networkType NetworkType) []*Chain { + var mainNetList []*Chain + for _, chain := range DefaultChainsList() { + if chain.NetworkType == networkType { + mainNetList = append(mainNetList, chain) + } + } + return mainNetList } -// PrivnetChainList returns a list of privnet chains -func PrivnetChainList() []*Chain { - return chainListPointers([]Chain{ - ZetaPrivnetChain(), - BtcRegtestChain(), - GoerliLocalnetChain(), - }) +func ChainListByNetwork(network Network) []*Chain { + var chainList []*Chain + for _, chain := range DefaultChainsList() { + if chain.Network == network { + chainList = append(chainList, chain) + } + } + return chainList } // ExternalChainList returns a list chains that are not Zeta func ExternalChainList() []*Chain { - return chainListPointers([]Chain{ - BtcMainnetChain(), - BscMainnetChain(), - EthChain(), - BtcTestNetChain(), - MumbaiChain(), - AmoyChain(), - BscTestnetChain(), - GoerliChain(), - SepoliaChain(), - BtcRegtestChain(), - GoerliLocalnetChain(), - }) + var chainList []*Chain + for _, chain := range DefaultChainsList() { + if chain.IsExternal { + chainList = append(chainList, chain) + } + } + return chainList } -// ZetaChainList returns a list of Zeta chains -func ZetaChainList() []*Chain { - return chainListPointers([]Chain{ - ZetaChainMainnet(), - ZetaTestnetChain(), - ZetaMocknetChain(), - ZetaPrivnetChain(), - }) +func ChainListByConsensus(consensus Consensus) []*Chain { + var chainList []*Chain + for _, chain := range DefaultChainsList() { + if chain.Consensus == consensus { + chainList = append(chainList, chain) + } + } + return chainList + +} +func ChainListForHeaderSupport() []*Chain { + var chainList []*Chain + for _, chain := range DefaultChainsList() { + if chain.IsHeaderSupported { + chainList = append(chainList, chain) + } + } + return chainList } // ZetaChainFromChainID returns a ZetaChain chainobject from a Cosmos chain ID diff --git a/pkg/chains/chains.pb.go b/pkg/chains/chains.pb.go index 27e8736dac..15c77806e0 100644 --- a/pkg/chains/chains.pb.go +++ b/pkg/chains/chains.pb.go @@ -122,9 +122,133 @@ func (ChainName) EnumDescriptor() ([]byte, []int) { return fileDescriptor_37ad35e0488e8bbc, []int{1} } +type Network int32 + +const ( + Network_ETH Network = 0 + Network_ZETA Network = 1 + Network_BTC Network = 2 + Network_POLYGON Network = 3 + Network_BSC Network = 4 +) + +var Network_name = map[int32]string{ + 0: "ETH", + 1: "ZETA", + 2: "BTC", + 3: "POLYGON", + 4: "BSC", +} + +var Network_value = map[string]int32{ + "ETH": 0, + "ZETA": 1, + "BTC": 2, + "POLYGON": 3, + "BSC": 4, +} + +func (x Network) String() string { + return proto.EnumName(Network_name, int32(x)) +} + +func (Network) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_37ad35e0488e8bbc, []int{2} +} + +type NetworkType int32 + +const ( + NetworkType_MAINNET NetworkType = 0 + NetworkType_TESTNET NetworkType = 1 + NetworkType_PRIVNET NetworkType = 2 + NetworkType_DEVNET NetworkType = 3 +) + +var NetworkType_name = map[int32]string{ + 0: "MAINNET", + 1: "TESTNET", + 2: "PRIVNET", + 3: "DEVNET", +} + +var NetworkType_value = map[string]int32{ + "MAINNET": 0, + "TESTNET": 1, + "PRIVNET": 2, + "DEVNET": 3, +} + +func (x NetworkType) String() string { + return proto.EnumName(NetworkType_name, int32(x)) +} + +func (NetworkType) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_37ad35e0488e8bbc, []int{3} +} + +type Vm int32 + +const ( + Vm_NO_VM Vm = 0 + Vm_EVM Vm = 1 +) + +var Vm_name = map[int32]string{ + 0: "NO_VM", + 1: "EVM", +} + +var Vm_value = map[string]int32{ + "NO_VM": 0, + "EVM": 1, +} + +func (x Vm) String() string { + return proto.EnumName(Vm_name, int32(x)) +} + +func (Vm) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_37ad35e0488e8bbc, []int{4} +} + +type Consensus int32 + +const ( + Consensus_Ethereum Consensus = 0 + Consensus_Tendermint Consensus = 1 + Consensus_Bitcoin Consensus = 2 +) + +var Consensus_name = map[int32]string{ + 0: "Ethereum", + 1: "Tendermint", + 2: "Bitcoin", +} + +var Consensus_value = map[string]int32{ + "Ethereum": 0, + "Tendermint": 1, + "Bitcoin": 2, +} + +func (x Consensus) String() string { + return proto.EnumName(Consensus_name, int32(x)) +} + +func (Consensus) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_37ad35e0488e8bbc, []int{5} +} + type Chain struct { - ChainName ChainName `protobuf:"varint,1,opt,name=chain_name,json=chainName,proto3,enum=chains.ChainName" json:"chain_name,omitempty"` - ChainId int64 `protobuf:"varint,2,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` + ChainName ChainName `protobuf:"varint,1,opt,name=chain_name,json=chainName,proto3,enum=chains.ChainName" json:"chain_name,omitempty"` + ChainId int64 `protobuf:"varint,2,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` + Network Network `protobuf:"varint,3,opt,name=network,proto3,enum=chains.Network" json:"network,omitempty"` + NetworkType NetworkType `protobuf:"varint,4,opt,name=network_type,json=networkType,proto3,enum=chains.NetworkType" json:"network_type,omitempty"` + Vm Vm `protobuf:"varint,5,opt,name=vm,proto3,enum=chains.Vm" json:"vm,omitempty"` + Consensus Consensus `protobuf:"varint,6,opt,name=consensus,proto3,enum=chains.Consensus" json:"consensus,omitempty"` + IsExternal bool `protobuf:"varint,7,opt,name=is_external,json=isExternal,proto3" json:"is_external,omitempty"` + IsHeaderSupported bool `protobuf:"varint,8,opt,name=is_header_supported,json=isHeaderSupported,proto3" json:"is_header_supported,omitempty"` } func (m *Chain) Reset() { *m = Chain{} } @@ -174,41 +298,104 @@ func (m *Chain) GetChainId() int64 { return 0 } +func (m *Chain) GetNetwork() Network { + if m != nil { + return m.Network + } + return Network_ETH +} + +func (m *Chain) GetNetworkType() NetworkType { + if m != nil { + return m.NetworkType + } + return NetworkType_MAINNET +} + +func (m *Chain) GetVm() Vm { + if m != nil { + return m.Vm + } + return Vm_NO_VM +} + +func (m *Chain) GetConsensus() Consensus { + if m != nil { + return m.Consensus + } + return Consensus_Ethereum +} + +func (m *Chain) GetIsExternal() bool { + if m != nil { + return m.IsExternal + } + return false +} + +func (m *Chain) GetIsHeaderSupported() bool { + if m != nil { + return m.IsHeaderSupported + } + return false +} + func init() { proto.RegisterEnum("chains.ReceiveStatus", ReceiveStatus_name, ReceiveStatus_value) proto.RegisterEnum("chains.ChainName", ChainName_name, ChainName_value) + proto.RegisterEnum("chains.Network", Network_name, Network_value) + proto.RegisterEnum("chains.NetworkType", NetworkType_name, NetworkType_value) + proto.RegisterEnum("chains.Vm", Vm_name, Vm_value) + proto.RegisterEnum("chains.Consensus", Consensus_name, Consensus_value) proto.RegisterType((*Chain)(nil), "chains.Chain") } func init() { proto.RegisterFile("pkg/chains/chains.proto", fileDescriptor_37ad35e0488e8bbc) } var fileDescriptor_37ad35e0488e8bbc = []byte{ - // 396 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x44, 0x92, 0x4f, 0x6f, 0xd3, 0x30, - 0x14, 0xc0, 0xe3, 0x6e, 0x6d, 0x97, 0xd7, 0xad, 0x35, 0x06, 0x89, 0xb1, 0x43, 0x34, 0x71, 0x1a, - 0x93, 0x68, 0x10, 0x1c, 0xb9, 0x51, 0x09, 0x89, 0x0b, 0x87, 0x8e, 0x13, 0x97, 0xca, 0x71, 0x9e, - 0x1c, 0x8b, 0x38, 0x8e, 0x12, 0x07, 0xa9, 0x7c, 0x0a, 0x3e, 0x04, 0x07, 0x3e, 0xca, 0x8e, 0x3b, - 0x72, 0x44, 0xed, 0x17, 0x99, 0xec, 0x2c, 0xce, 0x29, 0xef, 0xfd, 0xfc, 0x7b, 0x7f, 0x14, 0x1b, - 0x5e, 0xd6, 0x3f, 0x64, 0x2a, 0x0a, 0xae, 0xaa, 0xf6, 0xe9, 0xb3, 0xae, 0x1b, 0x63, 0x0d, 0x9b, - 0xf5, 0xd9, 0xd5, 0x0b, 0x69, 0xa4, 0xf1, 0x28, 0x75, 0x51, 0x7f, 0xfa, 0xfa, 0x1b, 0x4c, 0x37, - 0xee, 0x9c, 0xbd, 0x03, 0xf0, 0xe2, 0xae, 0xe2, 0x1a, 0x2f, 0xc9, 0x35, 0xb9, 0x59, 0xbe, 0x7f, - 0xb6, 0x7e, 0xea, 0xe4, 0x95, 0xaf, 0x5c, 0xe3, 0x36, 0x16, 0x43, 0xc8, 0x5e, 0xc1, 0x59, 0x5f, - 0xa1, 0xf2, 0xcb, 0xc9, 0x35, 0xb9, 0x39, 0xd9, 0xce, 0x7d, 0xfe, 0x25, 0xbf, 0xfd, 0x08, 0x17, - 0x5b, 0x14, 0xa8, 0x7e, 0xe2, 0x9d, 0xe5, 0xb6, 0x6b, 0xd9, 0x02, 0xe6, 0x9b, 0x06, 0xb9, 0xc5, - 0x9c, 0x46, 0x2e, 0xb9, 0xeb, 0x84, 0xc0, 0xb6, 0xa5, 0x84, 0x01, 0xcc, 0x3e, 0x73, 0x55, 0x62, - 0x4e, 0x27, 0x57, 0xa7, 0x7f, 0xff, 0x24, 0xe4, 0xf6, 0x7e, 0x02, 0x71, 0x18, 0xc8, 0x62, 0x98, - 0xa2, 0xae, 0xed, 0x9e, 0x46, 0x6c, 0x05, 0x0b, 0xb4, 0xc5, 0x4e, 0x73, 0x55, 0x55, 0x68, 0x29, - 0x61, 0x14, 0xce, 0x7f, 0xa1, 0xe5, 0x81, 0x4c, 0x9c, 0x92, 0x59, 0x11, 0xc0, 0x09, 0x7b, 0x0e, - 0xab, 0xda, 0x94, 0x7b, 0x69, 0xaa, 0x00, 0x4f, 0xbd, 0xd5, 0x8e, 0xd6, 0x94, 0x31, 0x58, 0x4a, - 0x83, 0x4d, 0xa9, 0x76, 0x16, 0x5b, 0xeb, 0xd8, 0xcc, 0x31, 0xdd, 0xe9, 0x8c, 0x8f, 0x6c, 0xee, - 0xba, 0x49, 0x5e, 0x71, 0x51, 0x60, 0x80, 0x67, 0x4e, 0xcc, 0xb8, 0xc9, 0x78, 0x16, 0x58, 0x3c, - 0x4c, 0x18, 0x00, 0x84, 0x55, 0x07, 0xb2, 0x18, 0x56, 0x1d, 0xc0, 0xb9, 0x6b, 0xde, 0x62, 0x6d, - 0x4a, 0x35, 0x5a, 0x17, 0x7e, 0x62, 0xbf, 0x59, 0x69, 0x04, 0x2f, 0x1d, 0x5c, 0x0e, 0xa5, 0x0d, - 0x4a, 0x27, 0xd2, 0x95, 0xeb, 0xce, 0xb5, 0xd9, 0x87, 0x3a, 0xda, 0xff, 0xca, 0x4f, 0x9b, 0xfb, - 0x43, 0x42, 0x1e, 0x0e, 0x09, 0xf9, 0x7f, 0x48, 0xc8, 0xef, 0x63, 0x12, 0x3d, 0x1c, 0x93, 0xe8, - 0xdf, 0x31, 0x89, 0xbe, 0xbf, 0x91, 0xca, 0x16, 0x5d, 0xb6, 0x16, 0x46, 0xa7, 0x6e, 0xb1, 0xb7, - 0xfe, 0xea, 0x7c, 0x28, 0x4c, 0x83, 0xe9, 0xf8, 0x9a, 0xb2, 0x99, 0x7f, 0x29, 0x1f, 0x1e, 0x03, - 0x00, 0x00, 0xff, 0xff, 0xda, 0x8f, 0xd7, 0xf3, 0x62, 0x02, 0x00, 0x00, + // 664 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x94, 0x4f, 0x6f, 0xd3, 0x4c, + 0x10, 0xc6, 0x6d, 0xe7, 0xff, 0x24, 0x4d, 0xb6, 0xdb, 0x57, 0x7a, 0xfd, 0xf6, 0xe0, 0xb7, 0xe2, + 0xd4, 0x56, 0x22, 0x41, 0x20, 0x71, 0x81, 0x4b, 0x1b, 0x52, 0x5a, 0x89, 0xa6, 0xc8, 0xb1, 0x22, + 0xd1, 0x8b, 0xb5, 0x71, 0x46, 0x8e, 0xd5, 0xd8, 0x6b, 0x79, 0x37, 0x85, 0xf0, 0x29, 0xf8, 0x10, + 0x1c, 0xf8, 0x28, 0x3d, 0xf6, 0x82, 0xc4, 0x11, 0xb5, 0x5f, 0x04, 0xed, 0xc6, 0x76, 0x50, 0x4f, + 0x99, 0xf9, 0xcd, 0xb3, 0xcf, 0x4e, 0x3c, 0x63, 0xc3, 0xbf, 0xe9, 0x4d, 0x38, 0x08, 0x16, 0x2c, + 0x4a, 0x44, 0xfe, 0xd3, 0x4f, 0x33, 0x2e, 0x39, 0xad, 0x6f, 0xb2, 0xfd, 0x7f, 0x42, 0x1e, 0x72, + 0x8d, 0x06, 0x2a, 0xda, 0x54, 0x9f, 0xfd, 0xb4, 0xa0, 0x36, 0x54, 0x02, 0xfa, 0x02, 0x40, 0x2b, + 0xfd, 0x84, 0xc5, 0x68, 0x9b, 0x07, 0xe6, 0x61, 0xf7, 0xe5, 0x6e, 0x3f, 0xb7, 0xd2, 0x92, 0x31, + 0x8b, 0xd1, 0x6d, 0x05, 0x45, 0x48, 0xff, 0x83, 0xe6, 0xe6, 0x44, 0x34, 0xb7, 0xad, 0x03, 0xf3, + 0xb0, 0xe2, 0x36, 0x74, 0x7e, 0x31, 0xa7, 0x47, 0xd0, 0x48, 0x50, 0x7e, 0xe6, 0xd9, 0x8d, 0x5d, + 0xd1, 0x4e, 0xbd, 0xc2, 0x69, 0xbc, 0xc1, 0x6e, 0x51, 0xa7, 0xaf, 0xa1, 0x93, 0x87, 0xbe, 0x5c, + 0xa7, 0x68, 0x57, 0xb5, 0x7e, 0xef, 0x89, 0xde, 0x5b, 0xa7, 0xe8, 0xb6, 0x93, 0x6d, 0x42, 0xf7, + 0xc1, 0xba, 0x8d, 0xed, 0x9a, 0x56, 0x43, 0xa1, 0x9e, 0xc6, 0xae, 0x75, 0x1b, 0xd3, 0x01, 0xb4, + 0x02, 0x9e, 0x08, 0x4c, 0xc4, 0x4a, 0xd8, 0xf5, 0x27, 0x7f, 0xa5, 0x28, 0xb8, 0x5b, 0x0d, 0xfd, + 0x1f, 0xda, 0x91, 0xf0, 0xf1, 0x8b, 0xc4, 0x2c, 0x61, 0x4b, 0xbb, 0x71, 0x60, 0x1e, 0x36, 0x5d, + 0x88, 0xc4, 0x28, 0x27, 0xb4, 0x0f, 0x7b, 0x91, 0xf0, 0x17, 0xc8, 0xe6, 0x98, 0xf9, 0x62, 0x95, + 0xa6, 0x3c, 0x93, 0x38, 0xb7, 0x9b, 0x5a, 0xb8, 0x1b, 0x89, 0x73, 0x5d, 0x99, 0x14, 0x85, 0xe3, + 0x37, 0xb0, 0xe3, 0x62, 0x80, 0xd1, 0x2d, 0x4e, 0x24, 0x93, 0x2b, 0x41, 0xdb, 0xd0, 0x18, 0x66, + 0xc8, 0x24, 0xce, 0x89, 0xa1, 0x92, 0xc9, 0x2a, 0x08, 0x50, 0x08, 0x62, 0x52, 0x80, 0xfa, 0x19, + 0x8b, 0x96, 0x38, 0x27, 0xd6, 0x7e, 0xf5, 0xc7, 0x77, 0xc7, 0x3c, 0xbe, 0xb3, 0xa0, 0x55, 0x3e, + 0x71, 0xda, 0x82, 0x1a, 0xc6, 0xa9, 0x5c, 0x13, 0x83, 0xf6, 0xa0, 0x8d, 0x72, 0xe1, 0xc7, 0x2c, + 0x4a, 0x12, 0x94, 0xc4, 0xa4, 0x04, 0x3a, 0x5f, 0x51, 0xb2, 0x92, 0x58, 0x4a, 0x32, 0x93, 0x41, + 0x09, 0x2a, 0x74, 0x0f, 0x7a, 0x29, 0x5f, 0xae, 0x43, 0x9e, 0x94, 0xb0, 0xaa, 0x55, 0x62, 0xab, + 0xaa, 0x51, 0x0a, 0xdd, 0x90, 0x63, 0xb6, 0x8c, 0x7c, 0x89, 0x42, 0x2a, 0x56, 0x57, 0x2c, 0x5e, + 0xc5, 0x33, 0xb6, 0x65, 0x0d, 0xe5, 0x16, 0xb2, 0x84, 0x05, 0x0b, 0x2c, 0x61, 0x53, 0x09, 0x67, + 0x8c, 0xcf, 0xd8, 0xac, 0x64, 0xad, 0xe2, 0x86, 0x02, 0x40, 0xd9, 0x6a, 0x41, 0xda, 0x45, 0xab, + 0x05, 0xe8, 0x28, 0x73, 0x81, 0x29, 0x5f, 0x46, 0x5b, 0xd5, 0x8e, 0xbe, 0x71, 0xd3, 0xd9, 0x92, + 0x07, 0x6c, 0xa9, 0x60, 0xb7, 0x38, 0x9a, 0x61, 0xa8, 0x84, 0xa4, 0xa7, 0xdc, 0x59, 0xcc, 0xd7, + 0xe5, 0x39, 0x92, 0x3f, 0xca, 0x13, 0x68, 0xe4, 0x1b, 0x44, 0x1b, 0x50, 0x19, 0x79, 0xe7, 0xc4, + 0xa0, 0x4d, 0xa8, 0x5e, 0x8f, 0xbc, 0x13, 0x62, 0x2a, 0x74, 0xea, 0x0d, 0x89, 0xa5, 0x06, 0xf2, + 0xf1, 0xea, 0xc3, 0xa7, 0xf7, 0x57, 0x63, 0x52, 0xd1, 0x74, 0x32, 0x24, 0xd5, 0xdc, 0xe2, 0x0c, + 0xda, 0x7f, 0x2d, 0xa1, 0x92, 0x5e, 0x9e, 0x5c, 0x8c, 0xc7, 0x23, 0x6f, 0x33, 0x48, 0x6f, 0x34, + 0xf1, 0x54, 0x62, 0x6a, 0x13, 0xf7, 0x62, 0xaa, 0x12, 0x4b, 0x4d, 0xf5, 0xdd, 0x48, 0xc7, 0x95, + 0xdc, 0xc7, 0x01, 0x6b, 0x1a, 0xab, 0x69, 0x8e, 0xaf, 0xfc, 0xe9, 0x25, 0x31, 0x74, 0x43, 0xd3, + 0x4b, 0x62, 0xe6, 0xf5, 0xb7, 0xd0, 0x2a, 0x77, 0x93, 0x76, 0xa0, 0x39, 0x92, 0x0b, 0xcc, 0x70, + 0x15, 0x13, 0x83, 0x76, 0x01, 0x3c, 0x4c, 0xe6, 0x98, 0xc5, 0x51, 0x22, 0x37, 0x37, 0x9d, 0x46, + 0x32, 0xe0, 0x51, 0x52, 0xec, 0xcc, 0xe9, 0xf0, 0xee, 0xc1, 0x31, 0xef, 0x1f, 0x1c, 0xf3, 0xf7, + 0x83, 0x63, 0x7e, 0x7b, 0x74, 0x8c, 0xfb, 0x47, 0xc7, 0xf8, 0xf5, 0xe8, 0x18, 0xd7, 0x47, 0x61, + 0x24, 0x17, 0xab, 0x59, 0x3f, 0xe0, 0xf1, 0x40, 0x4d, 0xe0, 0xb9, 0x7e, 0x11, 0x74, 0x18, 0xf0, + 0x0c, 0x07, 0xdb, 0x0f, 0xc7, 0xac, 0xae, 0x3f, 0x0a, 0xaf, 0xfe, 0x04, 0x00, 0x00, 0xff, 0xff, + 0x10, 0x31, 0x4b, 0xae, 0x4d, 0x04, 0x00, 0x00, } func (m *Chain) Marshal() (dAtA []byte, err error) { @@ -231,6 +418,46 @@ func (m *Chain) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.IsHeaderSupported { + i-- + if m.IsHeaderSupported { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x40 + } + if m.IsExternal { + i-- + if m.IsExternal { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x38 + } + if m.Consensus != 0 { + i = encodeVarintChains(dAtA, i, uint64(m.Consensus)) + i-- + dAtA[i] = 0x30 + } + if m.Vm != 0 { + i = encodeVarintChains(dAtA, i, uint64(m.Vm)) + i-- + dAtA[i] = 0x28 + } + if m.NetworkType != 0 { + i = encodeVarintChains(dAtA, i, uint64(m.NetworkType)) + i-- + dAtA[i] = 0x20 + } + if m.Network != 0 { + i = encodeVarintChains(dAtA, i, uint64(m.Network)) + i-- + dAtA[i] = 0x18 + } if m.ChainId != 0 { i = encodeVarintChains(dAtA, i, uint64(m.ChainId)) i-- @@ -267,6 +494,24 @@ func (m *Chain) Size() (n int) { if m.ChainId != 0 { n += 1 + sovChains(uint64(m.ChainId)) } + if m.Network != 0 { + n += 1 + sovChains(uint64(m.Network)) + } + if m.NetworkType != 0 { + n += 1 + sovChains(uint64(m.NetworkType)) + } + if m.Vm != 0 { + n += 1 + sovChains(uint64(m.Vm)) + } + if m.Consensus != 0 { + n += 1 + sovChains(uint64(m.Consensus)) + } + if m.IsExternal { + n += 2 + } + if m.IsHeaderSupported { + n += 2 + } return n } @@ -343,6 +588,122 @@ func (m *Chain) Unmarshal(dAtA []byte) error { break } } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Network", wireType) + } + m.Network = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChains + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Network |= Network(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field NetworkType", wireType) + } + m.NetworkType = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChains + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.NetworkType |= NetworkType(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Vm", wireType) + } + m.Vm = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChains + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Vm |= Vm(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Consensus", wireType) + } + m.Consensus = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChains + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Consensus |= Consensus(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 7: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsExternal", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChains + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.IsExternal = bool(v != 0) + case 8: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsHeaderSupported", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChains + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.IsHeaderSupported = bool(v != 0) default: iNdEx = preIndex skippy, err := skipChains(dAtA[iNdEx:]) diff --git a/pkg/chains/chains_test.go b/pkg/chains/chains_test.go index 51e22e85fd..4fe0f4ef0c 100644 --- a/pkg/chains/chains_test.go +++ b/pkg/chains/chains_test.go @@ -1,6 +1,7 @@ package chains import ( + "sort" "testing" "github.com/stretchr/testify/require" @@ -12,22 +13,168 @@ func TestChainRetrievalFunctions(t *testing.T) { function func() Chain expected Chain }{ - {"ZetaChainMainnet", ZetaChainMainnet, Chain{ChainName: ChainName_zeta_mainnet, ChainId: 7000}}, - {"ZetaTestnetChain", ZetaTestnetChain, Chain{ChainName: ChainName_zeta_testnet, ChainId: 7001}}, - {"ZetaMocknetChain", ZetaMocknetChain, Chain{ChainName: ChainName_zeta_mainnet, ChainId: 70000}}, - {"ZetaPrivnetChain", ZetaPrivnetChain, Chain{ChainName: ChainName_zeta_mainnet, ChainId: 101}}, - {"EthChain", EthChain, Chain{ChainName: ChainName_eth_mainnet, ChainId: 1}}, - {"BscMainnetChain", BscMainnetChain, Chain{ChainName: ChainName_bsc_mainnet, ChainId: 56}}, - {"BtcMainnetChain", BtcMainnetChain, Chain{ChainName: ChainName_btc_mainnet, ChainId: 8332}}, - {"PolygonChain", PolygonChain, Chain{ChainName: ChainName_polygon_mainnet, ChainId: 137}}, - {"SepoliaChain", SepoliaChain, Chain{ChainName: ChainName_sepolia_testnet, ChainId: 11155111}}, - {"GoerliChain", GoerliChain, Chain{ChainName: ChainName_goerli_testnet, ChainId: 5}}, - {"BscTestnetChain", BscTestnetChain, Chain{ChainName: ChainName_bsc_testnet, ChainId: 97}}, - {"BtcTestNetChain", BtcTestNetChain, Chain{ChainName: ChainName_btc_testnet, ChainId: 18332}}, - {"MumbaiChain", MumbaiChain, Chain{ChainName: ChainName_mumbai_testnet, ChainId: 80001}}, - {"AmoyChain", AmoyChain, Chain{ChainName: ChainName_amoy_testnet, ChainId: 80002}}, - {"BtcRegtestChain", BtcRegtestChain, Chain{ChainName: ChainName_btc_regtest, ChainId: 18444}}, - {"GoerliLocalnetChain", GoerliLocalnetChain, Chain{ChainName: ChainName_goerli_localnet, ChainId: 1337}}, + {"ZetaChainMainnet", ZetaChainMainnet, Chain{ + ChainName: ChainName_zeta_mainnet, + ChainId: 7000, + Network: Network_ZETA, + NetworkType: NetworkType_MAINNET, + IsExternal: false, + Vm: Vm_EVM, + IsHeaderSupported: false, + Consensus: Consensus_Tendermint, + }, + }, + {"ZetaTestnetChain", ZetaTestnetChain, Chain{ + ChainName: ChainName_zeta_testnet, + ChainId: 7001, + Network: Network_ZETA, + NetworkType: NetworkType_TESTNET, + IsExternal: false, + Vm: Vm_EVM, + IsHeaderSupported: false, + Consensus: Consensus_Tendermint, + }, + }, + {"ZetaMocknetChain", ZetaMocknetChain, Chain{ + ChainName: ChainName_zeta_mainnet, + ChainId: 70000, + Network: Network_ZETA, + NetworkType: NetworkType_DEVNET, + IsExternal: false, + Vm: Vm_EVM, + IsHeaderSupported: false, + Consensus: Consensus_Tendermint, + }}, + {"ZetaPrivnetChain", ZetaPrivnetChain, Chain{ + ChainName: ChainName_zeta_mainnet, + ChainId: 101, + Network: Network_ZETA, + NetworkType: NetworkType_PRIVNET, + IsExternal: false, + Vm: Vm_EVM, + IsHeaderSupported: false, + Consensus: Consensus_Tendermint, + }}, + {"EthChain", EthChain, Chain{ + ChainName: ChainName_eth_mainnet, + ChainId: 1, + Network: Network_ETH, + NetworkType: NetworkType_MAINNET, + IsExternal: true, + Vm: Vm_EVM, + IsHeaderSupported: true, + Consensus: Consensus_Ethereum, + }}, + {"BscMainnetChain", BscMainnetChain, Chain{ + ChainName: ChainName_bsc_mainnet, + ChainId: 56, + Network: Network_BSC, + NetworkType: NetworkType_MAINNET, + IsExternal: true, + Vm: Vm_EVM, + IsHeaderSupported: true, + Consensus: Consensus_Ethereum, + }}, + {"BtcMainnetChain", BtcMainnetChain, Chain{ + ChainName: ChainName_btc_mainnet, + ChainId: 8332, + Network: Network_BTC, + NetworkType: NetworkType_MAINNET, + IsExternal: true, + Vm: Vm_NO_VM, + IsHeaderSupported: false, + Consensus: Consensus_Bitcoin, + }}, + {"PolygonChain", PolygonChain, Chain{ + ChainName: ChainName_polygon_mainnet, + ChainId: 137, + Network: Network_POLYGON, + NetworkType: NetworkType_MAINNET, + IsExternal: true, + Vm: Vm_EVM, + IsHeaderSupported: false, + Consensus: Consensus_Ethereum, + }}, + {"SepoliaChain", SepoliaChain, Chain{ + ChainName: ChainName_sepolia_testnet, + ChainId: 11155111, + Network: Network_ETH, + NetworkType: NetworkType_TESTNET, + IsExternal: true, + Vm: Vm_EVM, + IsHeaderSupported: true, + Consensus: Consensus_Ethereum, + }}, + {"GoerliChain", GoerliChain, Chain{ + ChainName: ChainName_goerli_testnet, + ChainId: 5, + Network: Network_ETH, + NetworkType: NetworkType_TESTNET, + IsExternal: true, + Vm: Vm_EVM, + IsHeaderSupported: true, + Consensus: Consensus_Ethereum, + }}, + {"AmoyChain", AmoyChain, Chain{ + ChainName: ChainName_amoy_testnet, + ChainId: 80002, + Network: Network_POLYGON, + NetworkType: NetworkType_TESTNET, + IsExternal: true, + Vm: Vm_EVM, + IsHeaderSupported: false, + Consensus: Consensus_Ethereum, + }}, + {"BscTestnetChain", BscTestnetChain, Chain{ + ChainName: ChainName_bsc_testnet, + ChainId: 97, + Network: Network_BSC, + NetworkType: NetworkType_TESTNET, + IsExternal: true, + Vm: Vm_EVM, + IsHeaderSupported: true, + Consensus: Consensus_Ethereum, + }}, + {"MumbaiChain", MumbaiChain, Chain{ + ChainName: ChainName_mumbai_testnet, + ChainId: 80001, + Network: Network_POLYGON, + NetworkType: NetworkType_TESTNET, + IsExternal: true, + Vm: Vm_EVM, + IsHeaderSupported: false, + Consensus: Consensus_Ethereum, + }}, + {"BtcTestNetChain", BtcTestNetChain, Chain{ + ChainName: ChainName_btc_testnet, + ChainId: 18332, + Network: Network_BTC, + NetworkType: NetworkType_TESTNET, + IsExternal: true, + Vm: Vm_NO_VM, + IsHeaderSupported: false, + Consensus: Consensus_Bitcoin, + }}, + {"BtcRegtestChain", BtcRegtestChain, Chain{ + ChainName: ChainName_btc_regtest, + ChainId: 18444, + Network: Network_BTC, + NetworkType: NetworkType_PRIVNET, + IsExternal: true, + Vm: Vm_NO_VM, + IsHeaderSupported: false, + Consensus: Consensus_Bitcoin, + }}, + {"GoerliLocalnetChain", GoerliLocalnetChain, Chain{ + ChainName: ChainName_goerli_localnet, + ChainId: 1337, + Network: Network_ETH, + NetworkType: NetworkType_PRIVNET, + IsExternal: true, + Vm: Vm_EVM, + IsHeaderSupported: true, + Consensus: Consensus_Ethereum, + }}, } for _, tc := range tests { @@ -37,25 +184,83 @@ func TestChainRetrievalFunctions(t *testing.T) { }) } } +func TestChainListByNetworkType(t *testing.T) { + listTests := []struct { + name string + networkType NetworkType + expected []Chain + }{ + {"MainnetChainList", NetworkType_MAINNET, []Chain{ZetaChainMainnet(), BtcMainnetChain(), BscMainnetChain(), EthChain(), PolygonChain()}}, + {"TestnetChainList", NetworkType_TESTNET, []Chain{ZetaTestnetChain(), BtcTestNetChain(), MumbaiChain(), AmoyChain(), BscTestnetChain(), GoerliChain(), SepoliaChain()}}, + {"PrivnetChainList", NetworkType_PRIVNET, []Chain{ZetaPrivnetChain(), BtcRegtestChain(), GoerliLocalnetChain()}}, + } + + for _, lt := range listTests { + t.Run(lt.name, func(t *testing.T) { + chains := ChainListByNetworkType(lt.networkType) + require.Equal(t, len(lt.expected), len(chains)) + sort.Slice(chains, func(i, j int) bool { + return chains[i].ChainId < chains[j].ChainId + }) + sort.Slice(lt.expected, func(i, j int) bool { + return lt.expected[i].ChainId < lt.expected[j].ChainId + }) + for i, expectedChain := range lt.expected { + require.Equal(t, &expectedChain, chains[i]) + } + }) + } +} + +func TestChainListByNetwork(t *testing.T) { + listTests := []struct { + name string + network Network + expected []Chain + }{ + {"Zeta", Network_ZETA, []Chain{ZetaChainMainnet(), ZetaMocknetChain(), ZetaPrivnetChain(), ZetaTestnetChain()}}, + {"Btc", Network_BTC, []Chain{BtcMainnetChain(), BtcTestNetChain(), BtcRegtestChain()}}, + {"Eth", Network_ETH, []Chain{EthChain(), GoerliChain(), SepoliaChain(), GoerliLocalnetChain()}}, + {"Bsc", Network_BSC, []Chain{BscMainnetChain(), BscTestnetChain()}}, + {"Polygon", Network_POLYGON, []Chain{PolygonChain(), MumbaiChain(), AmoyChain()}}, + } + for _, lt := range listTests { + t.Run(lt.name, func(t *testing.T) { + chains := ChainListByNetwork(lt.network) + require.Equal(t, len(lt.expected), len(chains)) + sort.Slice(chains, func(i, j int) bool { + return chains[i].ChainId < chains[j].ChainId + }) + sort.Slice(lt.expected, func(i, j int) bool { + return lt.expected[i].ChainId < lt.expected[j].ChainId + }) + for i, expectedChain := range lt.expected { + require.Equal(t, &expectedChain, chains[i]) + } + }) + } +} func TestChainListFunctions(t *testing.T) { listTests := []struct { name string function func() []*Chain expected []Chain }{ - {"DefaultChainsList", DefaultChainsList, []Chain{BtcMainnetChain(), BscMainnetChain(), EthChain(), BtcTestNetChain(), MumbaiChain(), AmoyChain(), BscTestnetChain(), GoerliChain(), SepoliaChain(), BtcRegtestChain(), GoerliLocalnetChain(), ZetaChainMainnet(), ZetaTestnetChain(), ZetaMocknetChain(), ZetaPrivnetChain()}}, - {"MainnetChainList", MainnetChainList, []Chain{ZetaChainMainnet(), BtcMainnetChain(), BscMainnetChain(), EthChain()}}, - {"TestnetChainList", TestnetChainList, []Chain{ZetaTestnetChain(), BtcTestNetChain(), MumbaiChain(), AmoyChain(), BscTestnetChain(), GoerliChain(), SepoliaChain()}}, - {"PrivnetChainList", PrivnetChainList, []Chain{ZetaPrivnetChain(), BtcRegtestChain(), GoerliLocalnetChain()}}, - {"ExternalChainList", ExternalChainList, []Chain{BtcMainnetChain(), BscMainnetChain(), EthChain(), BtcTestNetChain(), MumbaiChain(), AmoyChain(), BscTestnetChain(), GoerliChain(), SepoliaChain(), BtcRegtestChain(), GoerliLocalnetChain()}}, - {"ZetaChainList", ZetaChainList, []Chain{ZetaChainMainnet(), ZetaTestnetChain(), ZetaMocknetChain(), ZetaPrivnetChain()}}, + {"DefaultChainsList", DefaultChainsList, []Chain{BtcMainnetChain(), BscMainnetChain(), EthChain(), BtcTestNetChain(), MumbaiChain(), AmoyChain(), BscTestnetChain(), GoerliChain(), SepoliaChain(), BtcRegtestChain(), GoerliLocalnetChain(), ZetaChainMainnet(), ZetaTestnetChain(), ZetaMocknetChain(), ZetaPrivnetChain(), PolygonChain()}}, + {"ExternalChainList", ExternalChainList, []Chain{BtcMainnetChain(), BscMainnetChain(), EthChain(), BtcTestNetChain(), MumbaiChain(), AmoyChain(), BscTestnetChain(), GoerliChain(), SepoliaChain(), BtcRegtestChain(), GoerliLocalnetChain(), PolygonChain()}}, } for _, lt := range listTests { t.Run(lt.name, func(t *testing.T) { chains := lt.function() require.Equal(t, len(lt.expected), len(chains)) + sort.Slice(chains, func(i, j int) bool { + return chains[i].ChainId < chains[j].ChainId + }) + sort.Slice(lt.expected, func(i, j int) bool { + return lt.expected[i].ChainId < lt.expected[j].ChainId + }) for i, expectedChain := range lt.expected { require.Equal(t, &expectedChain, chains[i]) } diff --git a/proto/pkg/chains/chains.proto b/proto/pkg/chains/chains.proto index 49305d4f16..2acee4565a 100644 --- a/proto/pkg/chains/chains.proto +++ b/proto/pkg/chains/chains.proto @@ -34,7 +34,43 @@ enum ChainName { amoy_testnet = 16; } +enum Network { + option (gogoproto.goproto_enum_stringer) = true; + ETH = 0; + ZETA = 1; + BTC = 2; + POLYGON = 3; + BSC = 4; +} + +enum NetworkType { + option (gogoproto.goproto_enum_stringer) = true; + MAINNET = 0; + TESTNET = 1; + PRIVNET = 2; + DEVNET = 3; +} + +enum Vm { + option (gogoproto.goproto_enum_stringer) = true; + NO_VM = 0; + EVM = 1; +} + +enum Consensus { + option (gogoproto.goproto_enum_stringer) = true; + Ethereum = 0; + Tendermint = 1; + Bitcoin = 2; +} + message Chain { ChainName chain_name = 1; int64 chain_id = 2; + Network network = 3; + NetworkType network_type = 4; + Vm vm = 5; + Consensus consensus = 6; + bool is_external = 7; + bool is_header_supported = 8; } diff --git a/testutil/network/genesis_state.go b/testutil/network/genesis_state.go index dfa3364cfe..c74a6ba803 100644 --- a/testutil/network/genesis_state.go +++ b/testutil/network/genesis_state.go @@ -61,8 +61,9 @@ func SetupZetaGenesisState(t *testing.T, genesisState map[string]json.RawMessage } if setupChainNonces { - chainNonceList := make([]observertypes.ChainNonces, len(chains.PrivnetChainList())) - for i, chain := range chains.PrivnetChainList() { + privatenetChain := chains.ChainListByNetworkType(chains.NetworkType_PRIVNET) + chainNonceList := make([]observertypes.ChainNonces, len(privatenetChain)) + for i, chain := range privatenetChain { chainNonceList[i] = observertypes.ChainNonces{ Index: chain.ChainName.String(), ChainId: chain.ChainId, diff --git a/testutil/sample/observer.go b/testutil/sample/observer.go index a05c4ecf52..2c478c097f 100644 --- a/testutil/sample/observer.go +++ b/testutil/sample/observer.go @@ -110,7 +110,7 @@ func ChainParamsSupported(chainID int64) *types.ChainParams { } func ChainParamsList() (cpl types.ChainParamsList) { - chainList := chains.PrivnetChainList() + chainList := chains.ChainListByNetworkType(chains.NetworkType_PRIVNET) for _, chain := range chainList { cpl.ChainParams = append(cpl.ChainParams, ChainParams(chain.ChainId)) diff --git a/x/observer/types/params.go b/x/observer/types/params.go index ea1db66657..e62573f8c5 100644 --- a/x/observer/types/params.go +++ b/x/observer/types/params.go @@ -28,9 +28,9 @@ func NewParams(observerParams []*ObserverParams, adminParams []*Admin_Policy, ba // privnet chains are supported by default for testing purposes // custom params must be provided in genesis for other networks func DefaultParams() Params { - chains := chains.PrivnetChainList() - observerParams := make([]*ObserverParams, len(chains)) - for i, chain := range chains { + chainList := chains.ChainListByNetworkType(chains.NetworkType_PRIVNET) + observerParams := make([]*ObserverParams, len(chainList)) + for i, chain := range chainList { observerParams[i] = &ObserverParams{ IsSupported: true, Chain: chain, diff --git a/zetaclient/zetabridge/query_test.go b/zetaclient/zetabridge/query_test.go index ea76fa78fd..d35d85eab6 100644 --- a/zetaclient/zetabridge/query_test.go +++ b/zetaclient/zetabridge/query_test.go @@ -783,11 +783,25 @@ func TestZetaCoreBridge_GetBlockHeaderChainState(t *testing.T) { func TestZetaCoreBridge_GetSupportedChains(t *testing.T) { expectedOutput := observertypes.QuerySupportedChainsResponse{ Chains: []*chains.Chain{ - {chains.BscMainnetChain().ChainName, - chains.BscMainnetChain().ChainId, + { + chains.BtcMainnetChain().ChainName, + chains.BtcMainnetChain().ChainId, + chains.BscMainnetChain().Network, + chains.BscMainnetChain().NetworkType, + chains.BscMainnetChain().Vm, + chains.BscMainnetChain().Consensus, + chains.BscMainnetChain().IsExternal, + chains.BscMainnetChain().IsHeaderSupported, }, - {chains.EthChain().ChainName, + { + chains.EthChain().ChainName, chains.EthChain().ChainId, + chains.EthChain().Network, + chains.EthChain().NetworkType, + chains.EthChain().Vm, + chains.EthChain().Consensus, + chains.EthChain().IsExternal, + chains.EthChain().IsHeaderSupported, }, }, } diff --git a/zetaclient/zetabridge/tx_test.go b/zetaclient/zetabridge/tx_test.go index 4fd2ee19fb..666c1fd156 100644 --- a/zetaclient/zetabridge/tx_test.go +++ b/zetaclient/zetabridge/tx_test.go @@ -245,11 +245,26 @@ func TestZetaCoreBridge_UpdateZetaCoreContext(t *testing.T) { WithPayload(observertypes.QuerySupportedChains{}). Return(observertypes.QuerySupportedChainsResponse{ Chains: []*chains.Chain{ - {chains.BscMainnetChain().ChainName, - chains.BscMainnetChain().ChainId, + + { + chains.BtcMainnetChain().ChainName, + chains.BtcMainnetChain().ChainId, + chains.BscMainnetChain().Network, + chains.BscMainnetChain().NetworkType, + chains.BscMainnetChain().Vm, + chains.BscMainnetChain().Consensus, + chains.BscMainnetChain().IsExternal, + chains.BscMainnetChain().IsHeaderSupported, }, - {chains.EthChain().ChainName, + { + chains.EthChain().ChainName, chains.EthChain().ChainId, + chains.EthChain().Network, + chains.EthChain().NetworkType, + chains.EthChain().Vm, + chains.EthChain().Consensus, + chains.EthChain().IsExternal, + chains.EthChain().IsHeaderSupported, }, }, }) From 80914229966e1b98a493da60d2cd5feab6357a06 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Wed, 24 Apr 2024 00:07:50 -0400 Subject: [PATCH 02/31] add migration script --- app/setup_handlers.go | 2 +- pkg/chains/chains.go | 9 ++- x/observer/keeper/migrator.go | 5 ++ x/observer/migrations/v8/migrate.go | 24 +++++++ x/observer/migrations/v8/migrate_test.go | 79 ++++++++++++++++++++++++ x/observer/module.go | 5 +- 6 files changed, 119 insertions(+), 5 deletions(-) create mode 100644 x/observer/migrations/v8/migrate.go create mode 100644 x/observer/migrations/v8/migrate_test.go diff --git a/app/setup_handlers.go b/app/setup_handlers.go index 19fcc96860..c746597bb9 100644 --- a/app/setup_handlers.go +++ b/app/setup_handlers.go @@ -10,7 +10,7 @@ import ( observertypes "github.com/zeta-chain/zetacore/x/observer/types" ) -const releaseVersion = "v15" +const releaseVersion = "v16" func SetupHandlers(app *App) { app.UpgradeKeeper.SetUpgradeHandler(releaseVersion, func(ctx sdk.Context, _ types.Plan, vm module.VersionMap) (module.VersionMap, error) { diff --git a/pkg/chains/chains.go b/pkg/chains/chains.go index 0b0a724d19..f3c3c9a47f 100644 --- a/pkg/chains/chains.go +++ b/pkg/chains/chains.go @@ -221,7 +221,6 @@ func BtcDustOffset() int64 { } // DefaultChainsList returns a list of default chains -// TODO : Check why polygon is not in this list func DefaultChainsList() []*Chain { return chainListPointers([]Chain{ BtcMainnetChain(), @@ -243,7 +242,7 @@ func DefaultChainsList() []*Chain { }) } -// MainnetChainList returns a list of mainnet chains +// ChainListByNetworkType returns a list of chains by network type func ChainListByNetworkType(networkType NetworkType) []*Chain { var mainNetList []*Chain for _, chain := range DefaultChainsList() { @@ -254,6 +253,7 @@ func ChainListByNetworkType(networkType NetworkType) []*Chain { return mainNetList } +// ChainListByNetwork returns a list of chains by network func ChainListByNetwork(network Network) []*Chain { var chainList []*Chain for _, chain := range DefaultChainsList() { @@ -275,6 +275,7 @@ func ExternalChainList() []*Chain { return chainList } +// ChainListByConsensus returns a list of chains by consensus func ChainListByConsensus(consensus Consensus) []*Chain { var chainList []*Chain for _, chain := range DefaultChainsList() { @@ -285,6 +286,8 @@ func ChainListByConsensus(consensus Consensus) []*Chain { return chainList } + +// ChainListForHeaderSupport returns a list of chains that support headers func ChainListForHeaderSupport() []*Chain { var chainList []*Chain for _, chain := range DefaultChainsList() { @@ -295,7 +298,7 @@ func ChainListForHeaderSupport() []*Chain { return chainList } -// ZetaChainFromChainID returns a ZetaChain chainobject from a Cosmos chain ID +// ZetaChainFromChainID returns a ZetaChain chain object from a Cosmos chain ID func ZetaChainFromChainID(chainID string) (Chain, error) { ethChainID, err := CosmosToEthChainID(chainID) if err != nil { diff --git a/x/observer/keeper/migrator.go b/x/observer/keeper/migrator.go index c4b676884c..026d44fa85 100644 --- a/x/observer/keeper/migrator.go +++ b/x/observer/keeper/migrator.go @@ -8,6 +8,7 @@ import ( v5 "github.com/zeta-chain/zetacore/x/observer/migrations/v5" v6 "github.com/zeta-chain/zetacore/x/observer/migrations/v6" v7 "github.com/zeta-chain/zetacore/x/observer/migrations/v7" + v8 "github.com/zeta-chain/zetacore/x/observer/migrations/v8" ) // Migrator is a struct for handling in-place store migrations. @@ -48,3 +49,7 @@ func (m Migrator) Migrate5to6(ctx sdk.Context) error { func (m Migrator) Migrate6to7(ctx sdk.Context) error { return v7.MigrateStore(ctx, m.observerKeeper) } + +func (m Migrator) Migrate7to8(ctx sdk.Context) error { + return v8.MigrateStore(ctx, m.observerKeeper) +} diff --git a/x/observer/migrations/v8/migrate.go b/x/observer/migrations/v8/migrate.go new file mode 100644 index 0000000000..dd2d634322 --- /dev/null +++ b/x/observer/migrations/v8/migrate.go @@ -0,0 +1,24 @@ +package v8 + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/zeta-chain/zetacore/pkg/chains" + "github.com/zeta-chain/zetacore/x/observer/types" +) + +type observerKeeper interface { + GetParamsIfExists(ctx sdk.Context) (params types.Params) + SetParams(ctx sdk.Context, params types.Params) +} + +// MigrateStore performs in-place store migrations from v6 to v7 +func MigrateStore(ctx sdk.Context, observerKeeper observerKeeper) error { + ctx.Logger().Info("Migrating observer store from v6 to v7") + params := observerKeeper.GetParamsIfExists(ctx) + for _, ob := range params.ObserverParams { + chain := chains.GetChainFromChainID(ob.Chain.ChainId) + ob.Chain = chain + } + observerKeeper.SetParams(ctx, params) + return nil +} diff --git a/x/observer/migrations/v8/migrate_test.go b/x/observer/migrations/v8/migrate_test.go new file mode 100644 index 0000000000..e2e78059a0 --- /dev/null +++ b/x/observer/migrations/v8/migrate_test.go @@ -0,0 +1,79 @@ +package v8_test + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + "github.com/zeta-chain/zetacore/pkg/chains" + keepertest "github.com/zeta-chain/zetacore/testutil/keeper" + v8 "github.com/zeta-chain/zetacore/x/observer/migrations/v8" + "github.com/zeta-chain/zetacore/x/observer/types" +) + +func Test_MigrateStore(t *testing.T) { + tt := []struct { + name string + params types.Params + chainList []*chains.Chain + }{ + { + name: "privnet params", + params: LegacyParamsForNetwork(chains.NetworkType_PRIVNET), + chainList: chains.ChainListByNetworkType(chains.NetworkType_PRIVNET), + }, + { + name: "testnet params", + params: LegacyParamsForNetwork(chains.NetworkType_TESTNET), + chainList: chains.ChainListByNetworkType(chains.NetworkType_TESTNET), + }, + { + name: "mainnet params", + params: LegacyParamsForNetwork(chains.NetworkType_MAINNET), + chainList: chains.ChainListByNetworkType(chains.NetworkType_MAINNET), + }, + } + for _, tc := range tt { + t.Run(tc.name, func(t *testing.T) { + k, ctx, _, _ := keepertest.ObserverKeeper(t) + k.SetParams(ctx, tc.params) + + chainListOld := make([]chains.Chain, len(tc.params.ObserverParams)) + for i, ob := range tc.params.ObserverParams { + chainListOld[i] = *ob.Chain + } + + err := v8.MigrateStore(ctx, k) + require.NoError(t, err) + + params := k.GetParamsIfExists(ctx) + chainListNew := make([]chains.Chain, len(params.ObserverParams)) + for i, ob := range params.ObserverParams { + chainListNew[i] = *ob.Chain + } + chainListTest := make([]chains.Chain, len(tc.chainList)) + for i, chain := range tc.chainList { + chainListTest[i] = *chain + } + require.NotEqual(t, chainListTest, chainListOld) + require.Equal(t, chainListTest, chainListNew) + }) + + } + +} + +func LegacyParamsForNetwork(networkType chains.NetworkType) types.Params { + chainList := chains.ChainListByNetworkType(networkType) + observerParams := make([]*types.ObserverParams, len(chainList)) + for i, chain := range chainList { + observerParams[i] = &types.ObserverParams{ + IsSupported: true, + // Set chain-Id and chain-name only for legacy params + Chain: &chains.Chain{ChainId: chain.ChainId, ChainName: chain.ChainName}, + BallotThreshold: sdk.MustNewDecFromStr("0.66"), + MinObserverDelegation: sdk.MustNewDecFromStr("1000000000000000000000"), + } + } + return types.NewParams(observerParams, types.DefaultAdminPolicy(), 100) +} diff --git a/x/observer/module.go b/x/observer/module.go index d6f9ba1d11..617ab92b90 100644 --- a/x/observer/module.go +++ b/x/observer/module.go @@ -156,6 +156,9 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { if err := cfg.RegisterMigration(types.ModuleName, 6, m.Migrate6to7); err != nil { panic(err) } + if err := cfg.RegisterMigration(types.ModuleName, 7, m.Migrate7to8); err != nil { + panic(err) + } } // RegisterInvariants registers the observer module's invariants. @@ -180,7 +183,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw } // ConsensusVersion implements ConsensusVersion. -func (AppModule) ConsensusVersion() uint64 { return 7 } +func (AppModule) ConsensusVersion() uint64 { return 8 } // BeginBlock executes all ABCI BeginBlock logic respective to the observer module. func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) { From 3f56c13e95aaad3967657e7a8a6f3b736bc4d9d0 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Wed, 24 Apr 2024 00:24:07 -0400 Subject: [PATCH 03/31] add comments --- pkg/chains/chain.go | 39 +++++++++++++++++---------------------- pkg/chains/chains.go | 15 +++++++++++++++ 2 files changed, 32 insertions(+), 22 deletions(-) diff --git a/pkg/chains/chain.go b/pkg/chains/chain.go index 0eebe1f7c9..7f876ec2b7 100644 --- a/pkg/chains/chain.go +++ b/pkg/chains/chain.go @@ -81,20 +81,29 @@ func DecodeAddressFromChainID(chainID int64, addr string) ([]byte, error) { return nil, fmt.Errorf("chain (%d) not supported", chainID) } -func IsZetaChain(chainID int64) bool { - return ChainIDInChainList(chainID, ChainListByNetwork(Network_ZETA)) +// IsEVMChain returns true if the chain is an EVM chain or uses the ethereum consensus mechanism for block finality +func IsEVMChain(chainID int64) bool { + return ChainIDInChainList(chainID, ChainListByConsensus(Consensus_Ethereum)) } -// IsEVMChain returns true if the chain is an EVM chain -func IsEVMChain(chainID int64) bool { - evmChainList := ChainListByConsensus(Consensus_Ethereum) - return ChainIDInChainList(chainID, evmChainList) +// IsBitcoinChain returns true if the chain is a Bitcoin-based chain or uses the bitcoin consensus mechanism for block finality +func IsBitcoinChain(chainID int64) bool { + return ChainIDInChainList(chainID, ChainListByConsensus(Consensus_Bitcoin)) +} + +// IsEthereumChain returns true if the chain is an Ethereum chain +func IsEthereumChain(chainID int64) bool { + return ChainIDInChainList(chainID, ChainListByNetwork(Network_ETH)) +} + +// IsZetaChain returns true if the chain is a Zeta chain +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 { - chainList := ChainListForHeaderSupport() - return ChainIDInChainList(chainID, chainList) + return ChainIDInChainList(chainID, ChainListForHeaderSupport()) } // SupportMerkleProof returns true if the chain supports block header-based verification @@ -102,20 +111,6 @@ func (chain Chain) SupportMerkleProof() bool { return IsEVMChain(chain.ChainId) || IsBitcoinChain(chain.ChainId) } -// IsBitcoinChain returns true if the chain is a Bitcoin chain -// TODO: put this information directly in chain object -// https://github.com/zeta-chain/node-private/issues/63 -func IsBitcoinChain(chainID int64) bool { - btcChainList := ChainListByNetwork(Network_BTC) - return ChainIDInChainList(chainID, btcChainList) -} - -// IsEthereumChain returns true if the chain is an Ethereum chain -func IsEthereumChain(chainID int64) bool { - ethChainList := ChainListByNetwork(Network_ETH) - return ChainIDInChainList(chainID, ethChainList) -} - // IsEmpty is to determinate whether the chain is empty func (chain Chain) IsEmpty() bool { return strings.TrimSpace(chain.String()) == "" diff --git a/pkg/chains/chains.go b/pkg/chains/chains.go index f3c3c9a47f..179fbe24c4 100644 --- a/pkg/chains/chains.go +++ b/pkg/chains/chains.go @@ -2,6 +2,21 @@ package chains import "fmt" +/* + Chain represents a blockchain network with its unique chain ID + ChainName is the name of the chain + ChainId is the unique identifier of the chain + Network is the network type of the chain , this can be ZETA, ETH, BSC, BTC, POLYGON + NetworkType is the network type of the chain, this can be MAINNET, TESTNET, DEVNET, PRIVNET + Vm is the virtual machine type of the chain to support smart contracts, this can be EVM, NO_VM + Consensus is the consensus algorithm used by the chain, this can be Tendermint, Ethereum, Bitcoin + IsExternal is a boolean value to determine if the chain is external to Zeta + IsHeaderSupported is a boolean value to determine if the chain supports headers + + Note ChainName is normally NetworkName + NetworkType,but in some cases the value of NetworkName + NetworkType is not unique.This is true for chains which have been deprecated or have been renamed. + Such as GoerliChain and MumbaiChain which have been replaced by SepoliaChain and AmoyChain respectively. +*/ + // Mainnet chains func ZetaChainMainnet() Chain { return Chain{ From 48d1e880750574ee66d2336a9307648dd819d198 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Wed, 24 Apr 2024 00:47:47 -0400 Subject: [PATCH 04/31] add changelog and generate files --- changelog.md | 1 + docs/openapi/openapi.swagger.yaml | 42 ++++++++++ pkg/chains/chains.go | 6 +- testutil/network/genesis_state.go | 6 +- typescript/pkg/chains/chains_pb.d.ts | 120 +++++++++++++++++++++++++++ x/observer/migrations/v8/migrate.go | 4 +- 6 files changed, 171 insertions(+), 8 deletions(-) diff --git a/changelog.md b/changelog.md index 19c08aebc9..060d789968 100644 --- a/changelog.md +++ b/changelog.md @@ -44,6 +44,7 @@ * [1989](https://github.com/zeta-chain/node/pull/1989) - simplify `IsSendOutTxProcessed` method and add unit tests * [2013](https://github.com/zeta-chain/node/pull/2013) - rename `GasPriceVoter` message to `VoteGasPrice` * [2059](https://github.com/zeta-chain/node/pull/2059) - Remove unused params from all functions in zetanode +* [2071](https://github.com/zeta-chain/node/pull/2071) - Modify chains struct to add all chain related information ### Features diff --git a/docs/openapi/openapi.swagger.yaml b/docs/openapi/openapi.swagger.yaml index 1eb8fe4593..00057075b2 100644 --- a/docs/openapi/openapi.swagger.yaml +++ b/docs/openapi/openapi.swagger.yaml @@ -53592,6 +53592,18 @@ definitions: chain_id: type: string format: int64 + network: + $ref: '#/definitions/chainsNetwork' + network_type: + $ref: '#/definitions/chainsNetworkType' + vm: + $ref: '#/definitions/chainsVm' + consensus: + $ref: '#/definitions/chainsConsensus' + is_external: + type: boolean + is_header_supported: + type: boolean chainsChainName: type: string enum: @@ -53613,6 +53625,30 @@ definitions: - btc_regtest - amoy_testnet default: empty + chainsConsensus: + type: string + enum: + - Ethereum + - Tendermint + - Bitcoin + default: Ethereum + chainsNetwork: + type: string + enum: + - ETH + - ZETA + - BTC + - POLYGON + - BSC + default: ETH + chainsNetworkType: + type: string + enum: + - MAINNET + - TESTNET + - PRIVNET + - DEVNET + default: MAINNET chainsReceiveStatus: type: string enum: @@ -53621,6 +53657,12 @@ definitions: - Failed default: Created title: '- Created: some observer sees inbound tx' + chainsVm: + type: string + enum: + - NO_VM + - EVM + default: NO_VM coinCoinType: type: string enum: diff --git a/pkg/chains/chains.go b/pkg/chains/chains.go index 179fbe24c4..debf9f441c 100644 --- a/pkg/chains/chains.go +++ b/pkg/chains/chains.go @@ -259,13 +259,13 @@ func DefaultChainsList() []*Chain { // ChainListByNetworkType returns a list of chains by network type func ChainListByNetworkType(networkType NetworkType) []*Chain { - var mainNetList []*Chain + var chainList []*Chain for _, chain := range DefaultChainsList() { if chain.NetworkType == networkType { - mainNetList = append(mainNetList, chain) + chainList = append(chainList, chain) } } - return mainNetList + return chainList } // ChainListByNetwork returns a list of chains by network diff --git a/testutil/network/genesis_state.go b/testutil/network/genesis_state.go index c74a6ba803..943c982b9c 100644 --- a/testutil/network/genesis_state.go +++ b/testutil/network/genesis_state.go @@ -61,9 +61,9 @@ func SetupZetaGenesisState(t *testing.T, genesisState map[string]json.RawMessage } if setupChainNonces { - privatenetChain := chains.ChainListByNetworkType(chains.NetworkType_PRIVNET) - chainNonceList := make([]observertypes.ChainNonces, len(privatenetChain)) - for i, chain := range privatenetChain { + privatenetChains := chains.ChainListByNetworkType(chains.NetworkType_PRIVNET) + chainNonceList := make([]observertypes.ChainNonces, len(privatenetChains)) + for i, chain := range privatenetChains { chainNonceList[i] = observertypes.ChainNonces{ Index: chain.ChainName.String(), ChainId: chain.ChainId, diff --git a/typescript/pkg/chains/chains_pb.d.ts b/typescript/pkg/chains/chains_pb.d.ts index 4a2efde10d..079ccc239f 100644 --- a/typescript/pkg/chains/chains_pb.d.ts +++ b/typescript/pkg/chains/chains_pb.d.ts @@ -118,6 +118,96 @@ export declare enum ChainName { amoy_testnet = 16, } +/** + * @generated from enum chains.Network + */ +export declare enum Network { + /** + * @generated from enum value: ETH = 0; + */ + ETH = 0, + + /** + * @generated from enum value: ZETA = 1; + */ + ZETA = 1, + + /** + * @generated from enum value: BTC = 2; + */ + BTC = 2, + + /** + * @generated from enum value: POLYGON = 3; + */ + POLYGON = 3, + + /** + * @generated from enum value: BSC = 4; + */ + BSC = 4, +} + +/** + * @generated from enum chains.NetworkType + */ +export declare enum NetworkType { + /** + * @generated from enum value: MAINNET = 0; + */ + MAINNET = 0, + + /** + * @generated from enum value: TESTNET = 1; + */ + TESTNET = 1, + + /** + * @generated from enum value: PRIVNET = 2; + */ + PRIVNET = 2, + + /** + * @generated from enum value: DEVNET = 3; + */ + DEVNET = 3, +} + +/** + * @generated from enum chains.Vm + */ +export declare enum Vm { + /** + * @generated from enum value: NO_VM = 0; + */ + NO_VM = 0, + + /** + * @generated from enum value: EVM = 1; + */ + EVM = 1, +} + +/** + * @generated from enum chains.Consensus + */ +export declare enum Consensus { + /** + * @generated from enum value: Ethereum = 0; + */ + Ethereum = 0, + + /** + * @generated from enum value: Tendermint = 1; + */ + Tendermint = 1, + + /** + * @generated from enum value: Bitcoin = 2; + */ + Bitcoin = 2, +} + /** * @generated from message chains.Chain */ @@ -132,6 +222,36 @@ export declare class Chain extends Message { */ chainId: bigint; + /** + * @generated from field: chains.Network network = 3; + */ + network: Network; + + /** + * @generated from field: chains.NetworkType network_type = 4; + */ + networkType: NetworkType; + + /** + * @generated from field: chains.Vm vm = 5; + */ + vm: Vm; + + /** + * @generated from field: chains.Consensus consensus = 6; + */ + consensus: Consensus; + + /** + * @generated from field: bool is_external = 7; + */ + isExternal: boolean; + + /** + * @generated from field: bool is_header_supported = 8; + */ + isHeaderSupported: boolean; + constructor(data?: PartialMessage); static readonly runtime: typeof proto3; diff --git a/x/observer/migrations/v8/migrate.go b/x/observer/migrations/v8/migrate.go index dd2d634322..653896f7a7 100644 --- a/x/observer/migrations/v8/migrate.go +++ b/x/observer/migrations/v8/migrate.go @@ -11,9 +11,9 @@ type observerKeeper interface { SetParams(ctx sdk.Context, params types.Params) } -// MigrateStore performs in-place store migrations from v6 to v7 +// MigrateStore performs in-place store migrations from v7 to v8 func MigrateStore(ctx sdk.Context, observerKeeper observerKeeper) error { - ctx.Logger().Info("Migrating observer store from v6 to v7") + ctx.Logger().Info("Migrating observer store from v7 to v8") params := observerKeeper.GetParamsIfExists(ctx) for _, ob := range params.ObserverParams { chain := chains.GetChainFromChainID(ob.Chain.ChainId) From 0aa02a6994ceaf1dd76294494273dc004ff791b3 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Wed, 24 Apr 2024 00:59:52 -0400 Subject: [PATCH 05/31] add comments for proto files --- proto/observer/observer.proto | 1 + proto/pkg/chains/chains.proto | 20 +++++++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/proto/observer/observer.proto b/proto/observer/observer.proto index 575eea04f1..b796a6705b 100644 --- a/proto/observer/observer.proto +++ b/proto/observer/observer.proto @@ -22,6 +22,7 @@ enum ObserverUpdateReason { AdminUpdate = 2; } +// Deprecated: Use ObserverSet instead to get the list of observers message ObserverMapper { string index = 1; chains.Chain observer_chain = 2; diff --git a/proto/pkg/chains/chains.proto b/proto/pkg/chains/chains.proto index 2acee4565a..43473ca276 100644 --- a/proto/pkg/chains/chains.proto +++ b/proto/pkg/chains/chains.proto @@ -11,7 +11,7 @@ enum ReceiveStatus { Success = 1; Failed = 2; } - +// ChainName represents the name of the chain enum ChainName { option (gogoproto.goproto_enum_stringer) = true; empty = 0; @@ -33,7 +33,7 @@ enum ChainName { btc_regtest = 15; amoy_testnet = 16; } - +// Network represents the network type of the chain enum Network { option (gogoproto.goproto_enum_stringer) = true; ETH = 0; @@ -42,7 +42,7 @@ enum Network { POLYGON = 3; BSC = 4; } - +// NetworkType represents the network type of the chain enum NetworkType { option (gogoproto.goproto_enum_stringer) = true; MAINNET = 0; @@ -50,13 +50,13 @@ enum NetworkType { PRIVNET = 2; DEVNET = 3; } - +// Vm represents the virtual machine type of the chain to support smart contracts enum Vm { option (gogoproto.goproto_enum_stringer) = true; NO_VM = 0; EVM = 1; } - +// Consensus represents the consensus algorithm used by the chain enum Consensus { option (gogoproto.goproto_enum_stringer) = true; Ethereum = 0; @@ -64,6 +64,16 @@ enum Consensus { Bitcoin = 2; } +// Chain represents a blockchain network with its unique chain ID +// ChainName is the name of the chain +// ChainId is the unique identifier of the chain +// Network is the network type of the chain , this can be ZETA, ETH, BSC, BTC, POLYGON +// NetworkType is the network type of the chain, this can be MAINNET, TESTNET, DEVNET, PRIVNET +// Vm is the virtual machine type of the chain to support smart contracts, this can be EVM, NO_VM +// Consensus is the consensus algorithm used by the chain, this can be Tendermint, Ethereum, Bitcoin +// IsExternal is a boolean value to determine if the chain is external to Zeta +// IsHeaderSupported is a boolean value to determine if the chain supports headers + message Chain { ChainName chain_name = 1; int64 chain_id = 2; From 1e946c60a04a29ed924026e323889c6f022083f4 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Wed, 24 Apr 2024 01:10:38 -0400 Subject: [PATCH 06/31] generate files after adding comments --- docs/openapi/openapi.swagger.yaml | 5 +++++ pkg/chains/chains.pb.go | 5 +++++ proto/pkg/chains/chains.proto | 5 +++++ typescript/observer/observer_pb.d.ts | 2 ++ typescript/pkg/chains/chains_pb.d.ts | 10 ++++++++++ x/observer/types/observer.pb.go | 1 + 6 files changed, 28 insertions(+) diff --git a/docs/openapi/openapi.swagger.yaml b/docs/openapi/openapi.swagger.yaml index 00057075b2..dbdf3206a3 100644 --- a/docs/openapi/openapi.swagger.yaml +++ b/docs/openapi/openapi.swagger.yaml @@ -53625,6 +53625,7 @@ definitions: - btc_regtest - amoy_testnet default: empty + title: ChainName represents the name of the chain chainsConsensus: type: string enum: @@ -53632,6 +53633,7 @@ definitions: - Tendermint - Bitcoin default: Ethereum + title: Consensus represents the consensus algorithm used by the chain chainsNetwork: type: string enum: @@ -53641,6 +53643,7 @@ definitions: - POLYGON - BSC default: ETH + title: Network represents the network type of the chain chainsNetworkType: type: string enum: @@ -53649,6 +53652,7 @@ definitions: - PRIVNET - DEVNET default: MAINNET + title: NetworkType represents the network type of the chain chainsReceiveStatus: type: string enum: @@ -53663,6 +53667,7 @@ definitions: - NO_VM - EVM default: NO_VM + title: Vm represents the virtual machine type of the chain to support smart contracts coinCoinType: type: string enum: diff --git a/pkg/chains/chains.pb.go b/pkg/chains/chains.pb.go index 15c77806e0..9f4f41256b 100644 --- a/pkg/chains/chains.pb.go +++ b/pkg/chains/chains.pb.go @@ -52,6 +52,7 @@ func (ReceiveStatus) EnumDescriptor() ([]byte, []int) { return fileDescriptor_37ad35e0488e8bbc, []int{0} } +// ChainName represents the name of the chain type ChainName int32 const ( @@ -122,6 +123,7 @@ func (ChainName) EnumDescriptor() ([]byte, []int) { return fileDescriptor_37ad35e0488e8bbc, []int{1} } +// Network represents the network type of the chain type Network int32 const ( @@ -156,6 +158,7 @@ func (Network) EnumDescriptor() ([]byte, []int) { return fileDescriptor_37ad35e0488e8bbc, []int{2} } +// NetworkType represents the network type of the chain type NetworkType int32 const ( @@ -187,6 +190,7 @@ func (NetworkType) EnumDescriptor() ([]byte, []int) { return fileDescriptor_37ad35e0488e8bbc, []int{3} } +// Vm represents the virtual machine type of the chain to support smart contracts type Vm int32 const ( @@ -212,6 +216,7 @@ func (Vm) EnumDescriptor() ([]byte, []int) { return fileDescriptor_37ad35e0488e8bbc, []int{4} } +// Consensus represents the consensus algorithm used by the chain type Consensus int32 const ( diff --git a/proto/pkg/chains/chains.proto b/proto/pkg/chains/chains.proto index 43473ca276..19333d6363 100644 --- a/proto/pkg/chains/chains.proto +++ b/proto/pkg/chains/chains.proto @@ -11,6 +11,7 @@ enum ReceiveStatus { Success = 1; Failed = 2; } + // ChainName represents the name of the chain enum ChainName { option (gogoproto.goproto_enum_stringer) = true; @@ -33,6 +34,7 @@ enum ChainName { btc_regtest = 15; amoy_testnet = 16; } + // Network represents the network type of the chain enum Network { option (gogoproto.goproto_enum_stringer) = true; @@ -42,6 +44,7 @@ enum Network { POLYGON = 3; BSC = 4; } + // NetworkType represents the network type of the chain enum NetworkType { option (gogoproto.goproto_enum_stringer) = true; @@ -50,12 +53,14 @@ enum NetworkType { PRIVNET = 2; DEVNET = 3; } + // Vm represents the virtual machine type of the chain to support smart contracts enum Vm { option (gogoproto.goproto_enum_stringer) = true; NO_VM = 0; EVM = 1; } + // Consensus represents the consensus algorithm used by the chain enum Consensus { option (gogoproto.goproto_enum_stringer) = true; diff --git a/typescript/observer/observer_pb.d.ts b/typescript/observer/observer_pb.d.ts index 79bd712ab5..cb1ed1d0bb 100644 --- a/typescript/observer/observer_pb.d.ts +++ b/typescript/observer/observer_pb.d.ts @@ -58,6 +58,8 @@ export declare enum ObserverUpdateReason { } /** + * Deprecated: Use ObserverSet instead to get the list of observers + * * @generated from message zetachain.zetacore.observer.ObserverMapper */ export declare class ObserverMapper extends Message { diff --git a/typescript/pkg/chains/chains_pb.d.ts b/typescript/pkg/chains/chains_pb.d.ts index 079ccc239f..59cdb82475 100644 --- a/typescript/pkg/chains/chains_pb.d.ts +++ b/typescript/pkg/chains/chains_pb.d.ts @@ -29,6 +29,8 @@ export declare enum ReceiveStatus { } /** + * ChainName represents the name of the chain + * * @generated from enum chains.ChainName */ export declare enum ChainName { @@ -119,6 +121,8 @@ export declare enum ChainName { } /** + * Network represents the network type of the chain + * * @generated from enum chains.Network */ export declare enum Network { @@ -149,6 +153,8 @@ export declare enum Network { } /** + * NetworkType represents the network type of the chain + * * @generated from enum chains.NetworkType */ export declare enum NetworkType { @@ -174,6 +180,8 @@ export declare enum NetworkType { } /** + * Vm represents the virtual machine type of the chain to support smart contracts + * * @generated from enum chains.Vm */ export declare enum Vm { @@ -189,6 +197,8 @@ export declare enum Vm { } /** + * Consensus represents the consensus algorithm used by the chain + * * @generated from enum chains.Consensus */ export declare enum Consensus { diff --git a/x/observer/types/observer.pb.go b/x/observer/types/observer.pb.go index ede9e119a5..dabe1e9681 100644 --- a/x/observer/types/observer.pb.go +++ b/x/observer/types/observer.pb.go @@ -87,6 +87,7 @@ func (ObserverUpdateReason) EnumDescriptor() ([]byte, []int) { return fileDescriptor_3004233a4a5969ce, []int{1} } +// Deprecated: Use ObserverSet instead to get the list of observers type ObserverMapper struct { Index string `protobuf:"bytes,1,opt,name=index,proto3" json:"index,omitempty"` ObserverChain *chains.Chain `protobuf:"bytes,2,opt,name=observer_chain,json=observerChain,proto3" json:"observer_chain,omitempty"` From cf23d847bcc36e45933f9cc88cb88e60702ca79f Mon Sep 17 00:00:00 2001 From: Tanmay Date: Wed, 24 Apr 2024 01:12:37 -0400 Subject: [PATCH 07/31] generate files after adding comments --- app/setup_handlers.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/setup_handlers.go b/app/setup_handlers.go index c746597bb9..d4edf354c3 100644 --- a/app/setup_handlers.go +++ b/app/setup_handlers.go @@ -5,8 +5,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/x/upgrade/types" - authoritytypes "github.com/zeta-chain/zetacore/x/authority/types" - lightclienttypes "github.com/zeta-chain/zetacore/x/lightclient/types" observertypes "github.com/zeta-chain/zetacore/x/observer/types" ) @@ -30,7 +28,7 @@ func SetupHandlers(app *App) { } if upgradeInfo.Name == releaseVersion && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) { storeUpgrades := storetypes.StoreUpgrades{ - Added: []string{authoritytypes.ModuleName, lightclienttypes.ModuleName}, + Added: []string{}, } // Use upgrade store loader for the initial loading of all stores when app starts, // it checks if version == upgradeHeight and applies store upgrades before loading the stores, From 170a0ba78701df06a8072754cc8f44b7a5d38859 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Wed, 24 Apr 2024 11:44:27 -0400 Subject: [PATCH 08/31] remove migration script --- app/setup_handlers.go | 4 +- x/observer/keeper/migrator.go | 5 -- x/observer/migrations/v8/migrate.go | 24 ------- x/observer/migrations/v8/migrate_test.go | 79 ------------------------ x/observer/module.go | 5 +- 5 files changed, 4 insertions(+), 113 deletions(-) delete mode 100644 x/observer/migrations/v8/migrate.go delete mode 100644 x/observer/migrations/v8/migrate_test.go diff --git a/app/setup_handlers.go b/app/setup_handlers.go index d4edf354c3..c746597bb9 100644 --- a/app/setup_handlers.go +++ b/app/setup_handlers.go @@ -5,6 +5,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/x/upgrade/types" + authoritytypes "github.com/zeta-chain/zetacore/x/authority/types" + lightclienttypes "github.com/zeta-chain/zetacore/x/lightclient/types" observertypes "github.com/zeta-chain/zetacore/x/observer/types" ) @@ -28,7 +30,7 @@ func SetupHandlers(app *App) { } if upgradeInfo.Name == releaseVersion && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) { storeUpgrades := storetypes.StoreUpgrades{ - Added: []string{}, + Added: []string{authoritytypes.ModuleName, lightclienttypes.ModuleName}, } // Use upgrade store loader for the initial loading of all stores when app starts, // it checks if version == upgradeHeight and applies store upgrades before loading the stores, diff --git a/x/observer/keeper/migrator.go b/x/observer/keeper/migrator.go index 026d44fa85..c4b676884c 100644 --- a/x/observer/keeper/migrator.go +++ b/x/observer/keeper/migrator.go @@ -8,7 +8,6 @@ import ( v5 "github.com/zeta-chain/zetacore/x/observer/migrations/v5" v6 "github.com/zeta-chain/zetacore/x/observer/migrations/v6" v7 "github.com/zeta-chain/zetacore/x/observer/migrations/v7" - v8 "github.com/zeta-chain/zetacore/x/observer/migrations/v8" ) // Migrator is a struct for handling in-place store migrations. @@ -49,7 +48,3 @@ func (m Migrator) Migrate5to6(ctx sdk.Context) error { func (m Migrator) Migrate6to7(ctx sdk.Context) error { return v7.MigrateStore(ctx, m.observerKeeper) } - -func (m Migrator) Migrate7to8(ctx sdk.Context) error { - return v8.MigrateStore(ctx, m.observerKeeper) -} diff --git a/x/observer/migrations/v8/migrate.go b/x/observer/migrations/v8/migrate.go deleted file mode 100644 index 653896f7a7..0000000000 --- a/x/observer/migrations/v8/migrate.go +++ /dev/null @@ -1,24 +0,0 @@ -package v8 - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/zeta-chain/zetacore/pkg/chains" - "github.com/zeta-chain/zetacore/x/observer/types" -) - -type observerKeeper interface { - GetParamsIfExists(ctx sdk.Context) (params types.Params) - SetParams(ctx sdk.Context, params types.Params) -} - -// MigrateStore performs in-place store migrations from v7 to v8 -func MigrateStore(ctx sdk.Context, observerKeeper observerKeeper) error { - ctx.Logger().Info("Migrating observer store from v7 to v8") - params := observerKeeper.GetParamsIfExists(ctx) - for _, ob := range params.ObserverParams { - chain := chains.GetChainFromChainID(ob.Chain.ChainId) - ob.Chain = chain - } - observerKeeper.SetParams(ctx, params) - return nil -} diff --git a/x/observer/migrations/v8/migrate_test.go b/x/observer/migrations/v8/migrate_test.go deleted file mode 100644 index e2e78059a0..0000000000 --- a/x/observer/migrations/v8/migrate_test.go +++ /dev/null @@ -1,79 +0,0 @@ -package v8_test - -import ( - "testing" - - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/require" - "github.com/zeta-chain/zetacore/pkg/chains" - keepertest "github.com/zeta-chain/zetacore/testutil/keeper" - v8 "github.com/zeta-chain/zetacore/x/observer/migrations/v8" - "github.com/zeta-chain/zetacore/x/observer/types" -) - -func Test_MigrateStore(t *testing.T) { - tt := []struct { - name string - params types.Params - chainList []*chains.Chain - }{ - { - name: "privnet params", - params: LegacyParamsForNetwork(chains.NetworkType_PRIVNET), - chainList: chains.ChainListByNetworkType(chains.NetworkType_PRIVNET), - }, - { - name: "testnet params", - params: LegacyParamsForNetwork(chains.NetworkType_TESTNET), - chainList: chains.ChainListByNetworkType(chains.NetworkType_TESTNET), - }, - { - name: "mainnet params", - params: LegacyParamsForNetwork(chains.NetworkType_MAINNET), - chainList: chains.ChainListByNetworkType(chains.NetworkType_MAINNET), - }, - } - for _, tc := range tt { - t.Run(tc.name, func(t *testing.T) { - k, ctx, _, _ := keepertest.ObserverKeeper(t) - k.SetParams(ctx, tc.params) - - chainListOld := make([]chains.Chain, len(tc.params.ObserverParams)) - for i, ob := range tc.params.ObserverParams { - chainListOld[i] = *ob.Chain - } - - err := v8.MigrateStore(ctx, k) - require.NoError(t, err) - - params := k.GetParamsIfExists(ctx) - chainListNew := make([]chains.Chain, len(params.ObserverParams)) - for i, ob := range params.ObserverParams { - chainListNew[i] = *ob.Chain - } - chainListTest := make([]chains.Chain, len(tc.chainList)) - for i, chain := range tc.chainList { - chainListTest[i] = *chain - } - require.NotEqual(t, chainListTest, chainListOld) - require.Equal(t, chainListTest, chainListNew) - }) - - } - -} - -func LegacyParamsForNetwork(networkType chains.NetworkType) types.Params { - chainList := chains.ChainListByNetworkType(networkType) - observerParams := make([]*types.ObserverParams, len(chainList)) - for i, chain := range chainList { - observerParams[i] = &types.ObserverParams{ - IsSupported: true, - // Set chain-Id and chain-name only for legacy params - Chain: &chains.Chain{ChainId: chain.ChainId, ChainName: chain.ChainName}, - BallotThreshold: sdk.MustNewDecFromStr("0.66"), - MinObserverDelegation: sdk.MustNewDecFromStr("1000000000000000000000"), - } - } - return types.NewParams(observerParams, types.DefaultAdminPolicy(), 100) -} diff --git a/x/observer/module.go b/x/observer/module.go index 617ab92b90..d6f9ba1d11 100644 --- a/x/observer/module.go +++ b/x/observer/module.go @@ -156,9 +156,6 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { if err := cfg.RegisterMigration(types.ModuleName, 6, m.Migrate6to7); err != nil { panic(err) } - if err := cfg.RegisterMigration(types.ModuleName, 7, m.Migrate7to8); err != nil { - panic(err) - } } // RegisterInvariants registers the observer module's invariants. @@ -183,7 +180,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw } // ConsensusVersion implements ConsensusVersion. -func (AppModule) ConsensusVersion() uint64 { return 8 } +func (AppModule) ConsensusVersion() uint64 { return 7 } // BeginBlock executes all ABCI BeginBlock logic respective to the observer module. func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) { From d06aeb4261d74d05331d09b8301a575addcfcc13 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Wed, 24 Apr 2024 12:03:45 -0400 Subject: [PATCH 09/31] refactor enums to use small case --- app/setup_handlers.go | 2 +- cmd/zetaclientd/keygen_tss.go | 4 +- pkg/chains/chain.go | 10 +- pkg/chains/chain_test.go | 14 +- pkg/chains/chains.go | 128 ++++++------ pkg/chains/chains.pb.go | 194 +++++++++--------- pkg/chains/chains_test.go | 144 ++++++------- pkg/chains/status.go | 4 +- pkg/chains/status_test.go | 4 +- proto/pkg/chains/chains.proto | 34 +-- testutil/keeper/crosschain.go | 4 +- testutil/network/genesis_state.go | 2 +- testutil/sample/observer.go | 2 +- .../msg_server_vote_outbound_tx_test.go | 12 +- .../message_vote_on_observed_outbound_tx.go | 4 +- ...ssage_vote_on_observed_outbound_tx_test.go | 10 +- x/crosschain/types/tx.pb.go | 2 +- x/observer/keeper/msg_server_vote_tss.go | 2 +- x/observer/keeper/msg_server_vote_tss_test.go | 20 +- x/observer/keeper/vote_outbound_test.go | 16 +- x/observer/types/message_vote_tss.go | 2 +- x/observer/types/message_vote_tss_test.go | 20 +- x/observer/types/observer_set.go | 4 +- x/observer/types/observer_set_test.go | 6 +- x/observer/types/params.go | 2 +- x/observer/types/parsers.go | 4 +- x/observer/types/parsers_test.go | 6 +- x/observer/types/tx.pb.go | 2 +- zetaclient/bitcoin/bitcoin_client.go | 2 +- zetaclient/evm/evm_client_test.go | 2 +- zetaclient/evm/outbounds.go | 14 +- zetaclient/evm/outbounds_test.go | 16 +- zetaclient/zetabridge/tx.go | 2 +- zetaclient/zetabridge/tx_test.go | 4 +- 34 files changed, 348 insertions(+), 350 deletions(-) diff --git a/app/setup_handlers.go b/app/setup_handlers.go index c746597bb9..19fcc96860 100644 --- a/app/setup_handlers.go +++ b/app/setup_handlers.go @@ -10,7 +10,7 @@ import ( observertypes "github.com/zeta-chain/zetacore/x/observer/types" ) -const releaseVersion = "v16" +const releaseVersion = "v15" func SetupHandlers(app *App) { app.UpgradeKeeper.SetUpgradeHandler(releaseVersion, func(ctx sdk.Context, _ types.Plan, vm module.VersionMap) (module.VersionMap, error) { diff --git a/cmd/zetaclientd/keygen_tss.go b/cmd/zetaclientd/keygen_tss.go index 72c7946da3..1eb589e058 100644 --- a/cmd/zetaclientd/keygen_tss.go +++ b/cmd/zetaclientd/keygen_tss.go @@ -109,7 +109,7 @@ func GenerateTss( err = keygenTss(keyGen, tss, keygenLogger) if err != nil { keygenLogger.Error().Err(err).Msg("keygenTss error") - tssFailedVoteHash, err := zetaBridge.SetTSS("", keyGen.BlockNumber, chains.ReceiveStatus_Failed) + tssFailedVoteHash, err := zetaBridge.SetTSS("", keyGen.BlockNumber, chains.ReceiveStatus_failed) if err != nil { keygenLogger.Error().Err(err).Msg("Failed to broadcast Failed TSS Vote to zetacore") return nil, err @@ -127,7 +127,7 @@ func GenerateTss( } // If TSS is successful , broadcast the vote to zetacore and set Pubkey - tssSuccessVoteHash, err := zetaBridge.SetTSS(newTss.CurrentPubkey, keyGen.BlockNumber, chains.ReceiveStatus_Success) + tssSuccessVoteHash, err := zetaBridge.SetTSS(newTss.CurrentPubkey, keyGen.BlockNumber, chains.ReceiveStatus_success) if err != nil { keygenLogger.Error().Err(err).Msg("TSS successful but unable to broadcast vote to zeta-core") return nil, err diff --git a/pkg/chains/chain.go b/pkg/chains/chain.go index 7f876ec2b7..77adc70119 100644 --- a/pkg/chains/chain.go +++ b/pkg/chains/chain.go @@ -20,7 +20,7 @@ func (chain Chain) IsEqual(c Chain) bool { } func (chain Chain) IsZetaChain() bool { - return chain.Network == Network_ZETA + return chain.Network == Network_zeta } func (chain Chain) IsExternalChain() bool { return chain.IsExternal @@ -83,22 +83,22 @@ func DecodeAddressFromChainID(chainID int64, addr string) ([]byte, error) { // IsEVMChain returns true if the chain is an EVM chain or uses the ethereum consensus mechanism for block finality func IsEVMChain(chainID int64) bool { - return ChainIDInChainList(chainID, ChainListByConsensus(Consensus_Ethereum)) + return ChainIDInChainList(chainID, ChainListByConsensus(Consensus_ethereum)) } // IsBitcoinChain returns true if the chain is a Bitcoin-based chain or uses the bitcoin consensus mechanism for block finality func IsBitcoinChain(chainID int64) bool { - return ChainIDInChainList(chainID, ChainListByConsensus(Consensus_Bitcoin)) + return ChainIDInChainList(chainID, ChainListByConsensus(Consensus_bitcoin)) } // IsEthereumChain returns true if the chain is an Ethereum chain func IsEthereumChain(chainID int64) bool { - return ChainIDInChainList(chainID, ChainListByNetwork(Network_ETH)) + return ChainIDInChainList(chainID, ChainListByNetwork(Network_eth)) } // IsZetaChain returns true if the chain is a Zeta chain func IsZetaChain(chainID int64) bool { - return ChainIDInChainList(chainID, ChainListByNetwork(Network_ZETA)) + return ChainIDInChainList(chainID, ChainListByNetwork(Network_zeta)) } // IsHeaderSupportedEvmChain returns true if the chain is an EVM chain supporting block header-based verification diff --git a/pkg/chains/chain_test.go b/pkg/chains/chain_test.go index cfeb53eac4..ea8d0cfde6 100644 --- a/pkg/chains/chain_test.go +++ b/pkg/chains/chain_test.go @@ -138,11 +138,11 @@ func TestChain_DecodeAddress(t *testing.T) { } func TestChain_InChainList(t *testing.T) { - require.True(t, ZetaChainMainnet().InChainList(ChainListByNetwork(Network_ZETA))) - require.True(t, ZetaMocknetChain().InChainList(ChainListByNetwork(Network_ZETA))) - require.True(t, ZetaPrivnetChain().InChainList(ChainListByNetwork(Network_ZETA))) - require.True(t, ZetaTestnetChain().InChainList(ChainListByNetwork(Network_ZETA))) - require.False(t, EthChain().InChainList(ChainListByNetwork(Network_ZETA))) + require.True(t, ZetaChainMainnet().InChainList(ChainListByNetwork(Network_zeta))) + require.True(t, ZetaMocknetChain().InChainList(ChainListByNetwork(Network_zeta))) + require.True(t, ZetaPrivnetChain().InChainList(ChainListByNetwork(Network_zeta))) + require.True(t, ZetaTestnetChain().InChainList(ChainListByNetwork(Network_zeta))) + require.False(t, EthChain().InChainList(ChainListByNetwork(Network_zeta))) } func TestIsZetaChain(t *testing.T) { @@ -376,6 +376,6 @@ func TestGetBTCChainIDFromChainParams(t *testing.T) { } func TestChainIDInChainList(t *testing.T) { - require.True(t, ChainIDInChainList(ZetaChainMainnet().ChainId, ChainListByNetwork(Network_ZETA))) - require.False(t, ChainIDInChainList(EthChain().ChainId, ChainListByNetwork(Network_ZETA))) + require.True(t, ChainIDInChainList(ZetaChainMainnet().ChainId, ChainListByNetwork(Network_zeta))) + require.False(t, ChainIDInChainList(EthChain().ChainId, ChainListByNetwork(Network_zeta))) } diff --git a/pkg/chains/chains.go b/pkg/chains/chains.go index debf9f441c..96376ac44f 100644 --- a/pkg/chains/chains.go +++ b/pkg/chains/chains.go @@ -22,10 +22,10 @@ func ZetaChainMainnet() Chain { return Chain{ ChainName: ChainName_zeta_mainnet, ChainId: 7000, - Network: Network_ZETA, - NetworkType: NetworkType_MAINNET, - Vm: Vm_EVM, - Consensus: Consensus_Tendermint, + Network: Network_zeta, + NetworkType: NetworkType_mainnet, + Vm: Vm_evm, + Consensus: Consensus_tendermint, IsExternal: false, IsHeaderSupported: false, } @@ -34,10 +34,10 @@ func EthChain() Chain { return Chain{ ChainName: ChainName_eth_mainnet, ChainId: 1, - Network: Network_ETH, - NetworkType: NetworkType_MAINNET, - Vm: Vm_EVM, - Consensus: Consensus_Ethereum, + Network: Network_eth, + NetworkType: NetworkType_mainnet, + Vm: Vm_evm, + Consensus: Consensus_ethereum, IsExternal: true, IsHeaderSupported: true, } @@ -47,10 +47,10 @@ func BscMainnetChain() Chain { return Chain{ ChainName: ChainName_bsc_mainnet, ChainId: 56, - Network: Network_BSC, - NetworkType: NetworkType_MAINNET, - Vm: Vm_EVM, - Consensus: Consensus_Ethereum, + Network: Network_bsc, + NetworkType: NetworkType_mainnet, + Vm: Vm_evm, + Consensus: Consensus_ethereum, IsExternal: true, IsHeaderSupported: true, } @@ -60,10 +60,10 @@ func BtcMainnetChain() Chain { return Chain{ ChainName: ChainName_btc_mainnet, ChainId: 8332, - Network: Network_BTC, - NetworkType: NetworkType_MAINNET, - Vm: Vm_NO_VM, - Consensus: Consensus_Bitcoin, + Network: Network_btc, + NetworkType: NetworkType_mainnet, + Vm: Vm_no_vm, + Consensus: Consensus_bitcoin, IsExternal: true, IsHeaderSupported: false, } @@ -73,10 +73,10 @@ func PolygonChain() Chain { return Chain{ ChainName: ChainName_polygon_mainnet, ChainId: 137, - Network: Network_POLYGON, - NetworkType: NetworkType_MAINNET, - Vm: Vm_EVM, - Consensus: Consensus_Ethereum, + Network: Network_polygon, + NetworkType: NetworkType_mainnet, + Vm: Vm_evm, + Consensus: Consensus_ethereum, IsExternal: true, IsHeaderSupported: false, } @@ -88,10 +88,10 @@ func ZetaTestnetChain() Chain { return Chain{ ChainName: ChainName_zeta_testnet, ChainId: 7001, - Network: Network_ZETA, - NetworkType: NetworkType_TESTNET, - Vm: Vm_EVM, - Consensus: Consensus_Tendermint, + Network: Network_zeta, + NetworkType: NetworkType_testnet, + Vm: Vm_evm, + Consensus: Consensus_tendermint, IsExternal: false, IsHeaderSupported: false, } @@ -101,10 +101,10 @@ func SepoliaChain() Chain { return Chain{ ChainName: ChainName_sepolia_testnet, ChainId: 11155111, - Network: Network_ETH, - NetworkType: NetworkType_TESTNET, - Vm: Vm_EVM, - Consensus: Consensus_Ethereum, + Network: Network_eth, + NetworkType: NetworkType_testnet, + Vm: Vm_evm, + Consensus: Consensus_ethereum, IsExternal: true, IsHeaderSupported: true, } @@ -115,10 +115,10 @@ func GoerliChain() Chain { return Chain{ ChainName: ChainName_goerli_testnet, ChainId: 5, - Network: Network_ETH, - NetworkType: NetworkType_TESTNET, - Vm: Vm_EVM, - Consensus: Consensus_Ethereum, + Network: Network_eth, + NetworkType: NetworkType_testnet, + Vm: Vm_evm, + Consensus: Consensus_ethereum, IsExternal: true, IsHeaderSupported: true, } @@ -128,10 +128,10 @@ func BscTestnetChain() Chain { return Chain{ ChainName: ChainName_bsc_testnet, ChainId: 97, - Network: Network_BSC, - NetworkType: NetworkType_TESTNET, - Vm: Vm_EVM, - Consensus: Consensus_Ethereum, + Network: Network_bsc, + NetworkType: NetworkType_testnet, + Vm: Vm_evm, + Consensus: Consensus_ethereum, IsExternal: true, IsHeaderSupported: true, } @@ -141,10 +141,10 @@ func BtcTestNetChain() Chain { return Chain{ ChainName: ChainName_btc_testnet, ChainId: 18332, - Network: Network_BTC, - NetworkType: NetworkType_TESTNET, - Vm: Vm_NO_VM, - Consensus: Consensus_Bitcoin, + Network: Network_btc, + NetworkType: NetworkType_testnet, + Vm: Vm_no_vm, + Consensus: Consensus_bitcoin, IsExternal: true, IsHeaderSupported: false, } @@ -155,10 +155,10 @@ func MumbaiChain() Chain { return Chain{ ChainName: ChainName_mumbai_testnet, ChainId: 80001, - Network: Network_POLYGON, - NetworkType: NetworkType_TESTNET, - Vm: Vm_EVM, - Consensus: Consensus_Ethereum, + Network: Network_polygon, + NetworkType: NetworkType_testnet, + Vm: Vm_evm, + Consensus: Consensus_ethereum, IsExternal: true, IsHeaderSupported: false, } @@ -168,10 +168,10 @@ func AmoyChain() Chain { return Chain{ ChainName: ChainName_amoy_testnet, ChainId: 80002, - Network: Network_POLYGON, - NetworkType: NetworkType_TESTNET, - Vm: Vm_EVM, - Consensus: Consensus_Ethereum, + Network: Network_polygon, + NetworkType: NetworkType_testnet, + Vm: Vm_evm, + Consensus: Consensus_ethereum, IsExternal: true, IsHeaderSupported: false, } @@ -182,10 +182,10 @@ func ZetaMocknetChain() Chain { return Chain{ ChainName: ChainName_zeta_mainnet, ChainId: 70000, - Network: Network_ZETA, - NetworkType: NetworkType_DEVNET, - Vm: Vm_EVM, - Consensus: Consensus_Tendermint, + Network: Network_zeta, + NetworkType: NetworkType_devnet, + Vm: Vm_evm, + Consensus: Consensus_tendermint, IsExternal: false, IsHeaderSupported: false, } @@ -197,10 +197,10 @@ func ZetaPrivnetChain() Chain { return Chain{ ChainName: ChainName_zeta_mainnet, ChainId: 101, - Network: Network_ZETA, - NetworkType: NetworkType_PRIVNET, - Vm: Vm_EVM, - Consensus: Consensus_Tendermint, + Network: Network_zeta, + NetworkType: NetworkType_privnet, + Vm: Vm_evm, + Consensus: Consensus_tendermint, IsExternal: false, IsHeaderSupported: false, } @@ -209,10 +209,10 @@ func BtcRegtestChain() Chain { return Chain{ ChainName: ChainName_btc_regtest, ChainId: 18444, - Network: Network_BTC, - NetworkType: NetworkType_PRIVNET, - Vm: Vm_NO_VM, - Consensus: Consensus_Bitcoin, + Network: Network_btc, + NetworkType: NetworkType_privnet, + Vm: Vm_no_vm, + Consensus: Consensus_bitcoin, IsExternal: true, IsHeaderSupported: false, } @@ -222,10 +222,10 @@ func GoerliLocalnetChain() Chain { return Chain{ ChainName: ChainName_goerli_localnet, ChainId: 1337, - Network: Network_ETH, - NetworkType: NetworkType_PRIVNET, - Vm: Vm_EVM, - Consensus: Consensus_Ethereum, + Network: Network_eth, + NetworkType: NetworkType_privnet, + Vm: Vm_evm, + Consensus: Consensus_ethereum, IsExternal: true, IsHeaderSupported: true, } diff --git a/pkg/chains/chains.pb.go b/pkg/chains/chains.pb.go index 9f4f41256b..899548b4be 100644 --- a/pkg/chains/chains.pb.go +++ b/pkg/chains/chains.pb.go @@ -27,21 +27,21 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type ReceiveStatus int32 const ( - ReceiveStatus_Created ReceiveStatus = 0 - ReceiveStatus_Success ReceiveStatus = 1 - ReceiveStatus_Failed ReceiveStatus = 2 + ReceiveStatus_created ReceiveStatus = 0 + ReceiveStatus_success ReceiveStatus = 1 + ReceiveStatus_failed ReceiveStatus = 2 ) var ReceiveStatus_name = map[int32]string{ - 0: "Created", - 1: "Success", - 2: "Failed", + 0: "created", + 1: "success", + 2: "failed", } var ReceiveStatus_value = map[string]int32{ - "Created": 0, - "Success": 1, - "Failed": 2, + "created": 0, + "success": 1, + "failed": 2, } func (x ReceiveStatus) String() string { @@ -127,27 +127,27 @@ func (ChainName) EnumDescriptor() ([]byte, []int) { type Network int32 const ( - Network_ETH Network = 0 - Network_ZETA Network = 1 - Network_BTC Network = 2 - Network_POLYGON Network = 3 - Network_BSC Network = 4 + Network_eth Network = 0 + Network_zeta Network = 1 + Network_btc Network = 2 + Network_polygon Network = 3 + Network_bsc Network = 4 ) var Network_name = map[int32]string{ - 0: "ETH", - 1: "ZETA", - 2: "BTC", - 3: "POLYGON", - 4: "BSC", + 0: "eth", + 1: "zeta", + 2: "btc", + 3: "polygon", + 4: "bsc", } var Network_value = map[string]int32{ - "ETH": 0, - "ZETA": 1, - "BTC": 2, - "POLYGON": 3, - "BSC": 4, + "eth": 0, + "zeta": 1, + "btc": 2, + "polygon": 3, + "bsc": 4, } func (x Network) String() string { @@ -162,24 +162,24 @@ func (Network) EnumDescriptor() ([]byte, []int) { type NetworkType int32 const ( - NetworkType_MAINNET NetworkType = 0 - NetworkType_TESTNET NetworkType = 1 - NetworkType_PRIVNET NetworkType = 2 - NetworkType_DEVNET NetworkType = 3 + NetworkType_mainnet NetworkType = 0 + NetworkType_testnet NetworkType = 1 + NetworkType_privnet NetworkType = 2 + NetworkType_devnet NetworkType = 3 ) var NetworkType_name = map[int32]string{ - 0: "MAINNET", - 1: "TESTNET", - 2: "PRIVNET", - 3: "DEVNET", + 0: "mainnet", + 1: "testnet", + 2: "privnet", + 3: "devnet", } var NetworkType_value = map[string]int32{ - "MAINNET": 0, - "TESTNET": 1, - "PRIVNET": 2, - "DEVNET": 3, + "mainnet": 0, + "testnet": 1, + "privnet": 2, + "devnet": 3, } func (x NetworkType) String() string { @@ -194,18 +194,18 @@ func (NetworkType) EnumDescriptor() ([]byte, []int) { type Vm int32 const ( - Vm_NO_VM Vm = 0 - Vm_EVM Vm = 1 + Vm_no_vm Vm = 0 + Vm_evm Vm = 1 ) var Vm_name = map[int32]string{ - 0: "NO_VM", - 1: "EVM", + 0: "no_vm", + 1: "evm", } var Vm_value = map[string]int32{ - "NO_VM": 0, - "EVM": 1, + "no_vm": 0, + "evm": 1, } func (x Vm) String() string { @@ -220,21 +220,21 @@ func (Vm) EnumDescriptor() ([]byte, []int) { type Consensus int32 const ( - Consensus_Ethereum Consensus = 0 - Consensus_Tendermint Consensus = 1 - Consensus_Bitcoin Consensus = 2 + Consensus_ethereum Consensus = 0 + Consensus_tendermint Consensus = 1 + Consensus_bitcoin Consensus = 2 ) var Consensus_name = map[int32]string{ - 0: "Ethereum", - 1: "Tendermint", - 2: "Bitcoin", + 0: "ethereum", + 1: "tendermint", + 2: "bitcoin", } var Consensus_value = map[string]int32{ - "Ethereum": 0, - "Tendermint": 1, - "Bitcoin": 2, + "ethereum": 0, + "tendermint": 1, + "bitcoin": 2, } func (x Consensus) String() string { @@ -307,28 +307,28 @@ func (m *Chain) GetNetwork() Network { if m != nil { return m.Network } - return Network_ETH + return Network_eth } func (m *Chain) GetNetworkType() NetworkType { if m != nil { return m.NetworkType } - return NetworkType_MAINNET + return NetworkType_mainnet } func (m *Chain) GetVm() Vm { if m != nil { return m.Vm } - return Vm_NO_VM + return Vm_no_vm } func (m *Chain) GetConsensus() Consensus { if m != nil { return m.Consensus } - return Consensus_Ethereum + return Consensus_ethereum } func (m *Chain) GetIsExternal() bool { @@ -358,49 +358,47 @@ func init() { func init() { proto.RegisterFile("pkg/chains/chains.proto", fileDescriptor_37ad35e0488e8bbc) } var fileDescriptor_37ad35e0488e8bbc = []byte{ - // 664 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x94, 0x4f, 0x6f, 0xd3, 0x4c, - 0x10, 0xc6, 0x6d, 0xe7, 0xff, 0x24, 0x4d, 0xb6, 0xdb, 0x57, 0x7a, 0xfd, 0xf6, 0xe0, 0xb7, 0xe2, - 0xd4, 0x56, 0x22, 0x41, 0x20, 0x71, 0x81, 0x4b, 0x1b, 0x52, 0x5a, 0x89, 0xa6, 0xc8, 0xb1, 0x22, - 0xd1, 0x8b, 0xb5, 0x71, 0x46, 0x8e, 0xd5, 0xd8, 0x6b, 0x79, 0x37, 0x85, 0xf0, 0x29, 0xf8, 0x10, - 0x1c, 0xf8, 0x28, 0x3d, 0xf6, 0x82, 0xc4, 0x11, 0xb5, 0x5f, 0x04, 0xed, 0xc6, 0x76, 0x50, 0x4f, - 0x99, 0xf9, 0xcd, 0xb3, 0xcf, 0x4e, 0x3c, 0x63, 0xc3, 0xbf, 0xe9, 0x4d, 0x38, 0x08, 0x16, 0x2c, - 0x4a, 0x44, 0xfe, 0xd3, 0x4f, 0x33, 0x2e, 0x39, 0xad, 0x6f, 0xb2, 0xfd, 0x7f, 0x42, 0x1e, 0x72, - 0x8d, 0x06, 0x2a, 0xda, 0x54, 0x9f, 0xfd, 0xb4, 0xa0, 0x36, 0x54, 0x02, 0xfa, 0x02, 0x40, 0x2b, - 0xfd, 0x84, 0xc5, 0x68, 0x9b, 0x07, 0xe6, 0x61, 0xf7, 0xe5, 0x6e, 0x3f, 0xb7, 0xd2, 0x92, 0x31, - 0x8b, 0xd1, 0x6d, 0x05, 0x45, 0x48, 0xff, 0x83, 0xe6, 0xe6, 0x44, 0x34, 0xb7, 0xad, 0x03, 0xf3, - 0xb0, 0xe2, 0x36, 0x74, 0x7e, 0x31, 0xa7, 0x47, 0xd0, 0x48, 0x50, 0x7e, 0xe6, 0xd9, 0x8d, 0x5d, - 0xd1, 0x4e, 0xbd, 0xc2, 0x69, 0xbc, 0xc1, 0x6e, 0x51, 0xa7, 0xaf, 0xa1, 0x93, 0x87, 0xbe, 0x5c, - 0xa7, 0x68, 0x57, 0xb5, 0x7e, 0xef, 0x89, 0xde, 0x5b, 0xa7, 0xe8, 0xb6, 0x93, 0x6d, 0x42, 0xf7, - 0xc1, 0xba, 0x8d, 0xed, 0x9a, 0x56, 0x43, 0xa1, 0x9e, 0xc6, 0xae, 0x75, 0x1b, 0xd3, 0x01, 0xb4, - 0x02, 0x9e, 0x08, 0x4c, 0xc4, 0x4a, 0xd8, 0xf5, 0x27, 0x7f, 0xa5, 0x28, 0xb8, 0x5b, 0x0d, 0xfd, - 0x1f, 0xda, 0x91, 0xf0, 0xf1, 0x8b, 0xc4, 0x2c, 0x61, 0x4b, 0xbb, 0x71, 0x60, 0x1e, 0x36, 0x5d, - 0x88, 0xc4, 0x28, 0x27, 0xb4, 0x0f, 0x7b, 0x91, 0xf0, 0x17, 0xc8, 0xe6, 0x98, 0xf9, 0x62, 0x95, - 0xa6, 0x3c, 0x93, 0x38, 0xb7, 0x9b, 0x5a, 0xb8, 0x1b, 0x89, 0x73, 0x5d, 0x99, 0x14, 0x85, 0xe3, - 0x37, 0xb0, 0xe3, 0x62, 0x80, 0xd1, 0x2d, 0x4e, 0x24, 0x93, 0x2b, 0x41, 0xdb, 0xd0, 0x18, 0x66, - 0xc8, 0x24, 0xce, 0x89, 0xa1, 0x92, 0xc9, 0x2a, 0x08, 0x50, 0x08, 0x62, 0x52, 0x80, 0xfa, 0x19, - 0x8b, 0x96, 0x38, 0x27, 0xd6, 0x7e, 0xf5, 0xc7, 0x77, 0xc7, 0x3c, 0xbe, 0xb3, 0xa0, 0x55, 0x3e, - 0x71, 0xda, 0x82, 0x1a, 0xc6, 0xa9, 0x5c, 0x13, 0x83, 0xf6, 0xa0, 0x8d, 0x72, 0xe1, 0xc7, 0x2c, - 0x4a, 0x12, 0x94, 0xc4, 0xa4, 0x04, 0x3a, 0x5f, 0x51, 0xb2, 0x92, 0x58, 0x4a, 0x32, 0x93, 0x41, - 0x09, 0x2a, 0x74, 0x0f, 0x7a, 0x29, 0x5f, 0xae, 0x43, 0x9e, 0x94, 0xb0, 0xaa, 0x55, 0x62, 0xab, - 0xaa, 0x51, 0x0a, 0xdd, 0x90, 0x63, 0xb6, 0x8c, 0x7c, 0x89, 0x42, 0x2a, 0x56, 0x57, 0x2c, 0x5e, - 0xc5, 0x33, 0xb6, 0x65, 0x0d, 0xe5, 0x16, 0xb2, 0x84, 0x05, 0x0b, 0x2c, 0x61, 0x53, 0x09, 0x67, - 0x8c, 0xcf, 0xd8, 0xac, 0x64, 0xad, 0xe2, 0x86, 0x02, 0x40, 0xd9, 0x6a, 0x41, 0xda, 0x45, 0xab, - 0x05, 0xe8, 0x28, 0x73, 0x81, 0x29, 0x5f, 0x46, 0x5b, 0xd5, 0x8e, 0xbe, 0x71, 0xd3, 0xd9, 0x92, - 0x07, 0x6c, 0xa9, 0x60, 0xb7, 0x38, 0x9a, 0x61, 0xa8, 0x84, 0xa4, 0xa7, 0xdc, 0x59, 0xcc, 0xd7, - 0xe5, 0x39, 0x92, 0x3f, 0xca, 0x13, 0x68, 0xe4, 0x1b, 0x44, 0x1b, 0x50, 0x19, 0x79, 0xe7, 0xc4, - 0xa0, 0x4d, 0xa8, 0x5e, 0x8f, 0xbc, 0x13, 0x62, 0x2a, 0x74, 0xea, 0x0d, 0x89, 0xa5, 0x06, 0xf2, - 0xf1, 0xea, 0xc3, 0xa7, 0xf7, 0x57, 0x63, 0x52, 0xd1, 0x74, 0x32, 0x24, 0xd5, 0xdc, 0xe2, 0x0c, - 0xda, 0x7f, 0x2d, 0xa1, 0x92, 0x5e, 0x9e, 0x5c, 0x8c, 0xc7, 0x23, 0x6f, 0x33, 0x48, 0x6f, 0x34, - 0xf1, 0x54, 0x62, 0x6a, 0x13, 0xf7, 0x62, 0xaa, 0x12, 0x4b, 0x4d, 0xf5, 0xdd, 0x48, 0xc7, 0x95, - 0xdc, 0xc7, 0x01, 0x6b, 0x1a, 0xab, 0x69, 0x8e, 0xaf, 0xfc, 0xe9, 0x25, 0x31, 0x74, 0x43, 0xd3, - 0x4b, 0x62, 0xe6, 0xf5, 0xb7, 0xd0, 0x2a, 0x77, 0x93, 0x76, 0xa0, 0x39, 0x92, 0x0b, 0xcc, 0x70, - 0x15, 0x13, 0x83, 0x76, 0x01, 0x3c, 0x4c, 0xe6, 0x98, 0xc5, 0x51, 0x22, 0x37, 0x37, 0x9d, 0x46, - 0x32, 0xe0, 0x51, 0x52, 0xec, 0xcc, 0xe9, 0xf0, 0xee, 0xc1, 0x31, 0xef, 0x1f, 0x1c, 0xf3, 0xf7, - 0x83, 0x63, 0x7e, 0x7b, 0x74, 0x8c, 0xfb, 0x47, 0xc7, 0xf8, 0xf5, 0xe8, 0x18, 0xd7, 0x47, 0x61, - 0x24, 0x17, 0xab, 0x59, 0x3f, 0xe0, 0xf1, 0x40, 0x4d, 0xe0, 0xb9, 0x7e, 0x11, 0x74, 0x18, 0xf0, - 0x0c, 0x07, 0xdb, 0x0f, 0xc7, 0xac, 0xae, 0x3f, 0x0a, 0xaf, 0xfe, 0x04, 0x00, 0x00, 0xff, 0xff, - 0x10, 0x31, 0x4b, 0xae, 0x4d, 0x04, 0x00, 0x00, + // 634 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x94, 0x4f, 0x6f, 0xd3, 0x30, + 0x14, 0xc0, 0x9b, 0xf4, 0xff, 0x6b, 0xd7, 0x66, 0x1e, 0x12, 0x61, 0x87, 0x30, 0x71, 0xda, 0x26, + 0xd1, 0x22, 0x90, 0xb8, 0xc0, 0x05, 0x26, 0x10, 0x5c, 0x76, 0xc8, 0xd0, 0x0e, 0x5c, 0x22, 0x27, + 0x79, 0xa4, 0xd6, 0x6a, 0x3b, 0x8a, 0xdd, 0x42, 0xf9, 0x14, 0x7c, 0x08, 0x0e, 0x7c, 0x94, 0x1d, + 0x77, 0x41, 0xe2, 0x88, 0xb6, 0x2f, 0x82, 0xec, 0xc6, 0x29, 0xda, 0xa9, 0xcf, 0xbf, 0xf7, 0xf3, + 0xf3, 0x8b, 0xed, 0x1a, 0x1e, 0x96, 0x57, 0xc5, 0x3c, 0x5b, 0x50, 0x26, 0x54, 0xfd, 0x33, 0x2b, + 0x2b, 0xa9, 0x25, 0xe9, 0x6d, 0x47, 0x87, 0x0f, 0x0a, 0x59, 0x48, 0x8b, 0xe6, 0x26, 0xda, 0x66, + 0x9f, 0xfc, 0xf6, 0xa1, 0x7b, 0x66, 0x04, 0xf2, 0x0c, 0xc0, 0x9a, 0x89, 0xa0, 0x1c, 0x43, 0xef, + 0xc8, 0x3b, 0x9e, 0x3c, 0xdf, 0x9f, 0xd5, 0xa5, 0xac, 0x72, 0x4e, 0x39, 0xc6, 0xc3, 0xcc, 0x85, + 0xe4, 0x11, 0x0c, 0xb6, 0x33, 0x58, 0x1e, 0xfa, 0x47, 0xde, 0x71, 0x3b, 0xee, 0xdb, 0xf1, 0xc7, + 0x9c, 0x9c, 0x40, 0x5f, 0xa0, 0xfe, 0x2a, 0xab, 0xab, 0xb0, 0x6d, 0x2b, 0x4d, 0x5d, 0xa5, 0xf3, + 0x2d, 0x8e, 0x5d, 0x9e, 0xbc, 0x84, 0x71, 0x1d, 0x26, 0x7a, 0x53, 0x62, 0xd8, 0xb1, 0xfe, 0xc1, + 0x3d, 0xff, 0xd3, 0xa6, 0xc4, 0x78, 0x24, 0x76, 0x03, 0x72, 0x08, 0xfe, 0x9a, 0x87, 0x5d, 0x6b, + 0x83, 0xb3, 0x2f, 0x79, 0xec, 0xaf, 0x39, 0x99, 0xc3, 0x30, 0x93, 0x42, 0xa1, 0x50, 0x2b, 0x15, + 0xf6, 0xee, 0x7d, 0x8a, 0x4b, 0xc4, 0x3b, 0x87, 0x3c, 0x86, 0x11, 0x53, 0x09, 0x7e, 0xd3, 0x58, + 0x09, 0xba, 0x0c, 0xfb, 0x47, 0xde, 0xf1, 0x20, 0x06, 0xa6, 0xde, 0xd5, 0x84, 0xcc, 0xe0, 0x80, + 0xa9, 0x64, 0x81, 0x34, 0xc7, 0x2a, 0x51, 0xab, 0xb2, 0x94, 0x95, 0xc6, 0x3c, 0x1c, 0x58, 0x71, + 0x9f, 0xa9, 0x0f, 0x36, 0x73, 0xe1, 0x12, 0xa7, 0xaf, 0x60, 0x2f, 0xc6, 0x0c, 0xd9, 0x1a, 0x2f, + 0x34, 0xd5, 0x2b, 0x45, 0x46, 0xd0, 0xcf, 0x2a, 0xa4, 0x1a, 0xf3, 0xa0, 0x65, 0x06, 0x6a, 0x95, + 0x65, 0xa8, 0x54, 0xe0, 0x11, 0x80, 0xde, 0x17, 0xca, 0x96, 0x98, 0x07, 0xfe, 0x61, 0xe7, 0xd7, + 0xcf, 0xc8, 0x3b, 0xbd, 0xf6, 0x61, 0xd8, 0xec, 0x38, 0x19, 0x42, 0x17, 0x79, 0xa9, 0x37, 0x41, + 0x8b, 0x4c, 0x61, 0x84, 0x7a, 0x91, 0x70, 0xca, 0x84, 0x40, 0x1d, 0x78, 0x24, 0x80, 0xf1, 0x77, + 0xd4, 0xb4, 0x21, 0xbe, 0x51, 0x52, 0x9d, 0x35, 0xa0, 0x4d, 0x0e, 0x60, 0x5a, 0xca, 0xe5, 0xa6, + 0x90, 0xa2, 0x81, 0x1d, 0x6b, 0xa9, 0x9d, 0xd5, 0x25, 0x04, 0x26, 0x85, 0xc4, 0x6a, 0xc9, 0x12, + 0x8d, 0x4a, 0x1b, 0xd6, 0x33, 0x8c, 0xaf, 0x78, 0x4a, 0x77, 0xac, 0x6f, 0xaa, 0x15, 0x54, 0xd0, + 0x6c, 0x81, 0x0d, 0x1c, 0x18, 0x31, 0xa5, 0x32, 0xa5, 0x69, 0xc3, 0x86, 0x6e, 0x05, 0x07, 0xa0, + 0x69, 0xd5, 0x91, 0x91, 0x6b, 0xd5, 0x81, 0xb1, 0x29, 0xae, 0xb0, 0x94, 0x4b, 0xb6, 0xb3, 0xf6, + 0xec, 0x8a, 0xdb, 0xce, 0x96, 0x32, 0xa3, 0x4b, 0x03, 0x27, 0x6e, 0x6a, 0x85, 0x85, 0x11, 0x83, + 0xa9, 0xa9, 0x4e, 0xb9, 0xdc, 0x34, 0xf3, 0x82, 0x7a, 0x2b, 0xdf, 0x40, 0xbf, 0xbe, 0x41, 0xa4, + 0x0f, 0x6d, 0xd4, 0x8b, 0xa0, 0x45, 0x06, 0xd0, 0x31, 0x9d, 0x04, 0x9e, 0x41, 0xa9, 0xce, 0x02, + 0xdf, 0x1c, 0x48, 0xbd, 0x49, 0x41, 0xdb, 0x52, 0x95, 0x05, 0x9d, 0xba, 0xc4, 0x7b, 0x18, 0xfd, + 0x77, 0x09, 0x8d, 0xea, 0xb6, 0xcd, 0x1e, 0xa4, 0x5b, 0xd1, 0xb3, 0x45, 0x2a, 0xb6, 0xde, 0x9e, + 0x03, 0x40, 0x2f, 0x47, 0x1b, 0xb7, 0xeb, 0x3a, 0x11, 0xf8, 0x97, 0xdc, 0x9c, 0xa6, 0x90, 0xc9, + 0x9a, 0x07, 0x2d, 0xdb, 0xd0, 0x9a, 0x07, 0x5e, 0x9d, 0x7f, 0x0d, 0xc3, 0xe6, 0x6e, 0x92, 0x31, + 0x0c, 0x50, 0x2f, 0xb0, 0xc2, 0x95, 0x31, 0x27, 0x00, 0x1a, 0x45, 0x8e, 0x15, 0x67, 0xa2, 0x5e, + 0x29, 0x65, 0x3a, 0x93, 0x4c, 0xb8, 0x3b, 0xf3, 0xf6, 0xec, 0xfa, 0x36, 0xf2, 0x6e, 0x6e, 0x23, + 0xef, 0xef, 0x6d, 0xe4, 0xfd, 0xb8, 0x8b, 0x5a, 0x37, 0x77, 0x51, 0xeb, 0xcf, 0x5d, 0xd4, 0xfa, + 0x7c, 0x52, 0x30, 0xbd, 0x58, 0xa5, 0xb3, 0x4c, 0xf2, 0xb9, 0xf9, 0xee, 0xa7, 0xf6, 0x8f, 0x60, + 0xc3, 0x4c, 0x56, 0x38, 0xdf, 0x3d, 0x1c, 0x69, 0xcf, 0x3e, 0x0a, 0x2f, 0xfe, 0x05, 0x00, 0x00, + 0xff, 0xff, 0x2a, 0xc3, 0x74, 0x63, 0x4d, 0x04, 0x00, 0x00, } func (m *Chain) Marshal() (dAtA []byte, err error) { diff --git a/pkg/chains/chains_test.go b/pkg/chains/chains_test.go index 4fe0f4ef0c..2f1fc8e20d 100644 --- a/pkg/chains/chains_test.go +++ b/pkg/chains/chains_test.go @@ -16,164 +16,164 @@ func TestChainRetrievalFunctions(t *testing.T) { {"ZetaChainMainnet", ZetaChainMainnet, Chain{ ChainName: ChainName_zeta_mainnet, ChainId: 7000, - Network: Network_ZETA, - NetworkType: NetworkType_MAINNET, + Network: Network_zeta, + NetworkType: NetworkType_mainnet, IsExternal: false, - Vm: Vm_EVM, + Vm: Vm_evm, IsHeaderSupported: false, - Consensus: Consensus_Tendermint, + Consensus: Consensus_tendermint, }, }, {"ZetaTestnetChain", ZetaTestnetChain, Chain{ ChainName: ChainName_zeta_testnet, ChainId: 7001, - Network: Network_ZETA, - NetworkType: NetworkType_TESTNET, + Network: Network_zeta, + NetworkType: NetworkType_testnet, IsExternal: false, - Vm: Vm_EVM, + Vm: Vm_evm, IsHeaderSupported: false, - Consensus: Consensus_Tendermint, + Consensus: Consensus_tendermint, }, }, {"ZetaMocknetChain", ZetaMocknetChain, Chain{ ChainName: ChainName_zeta_mainnet, ChainId: 70000, - Network: Network_ZETA, - NetworkType: NetworkType_DEVNET, + Network: Network_zeta, + NetworkType: NetworkType_devnet, IsExternal: false, - Vm: Vm_EVM, + Vm: Vm_evm, IsHeaderSupported: false, - Consensus: Consensus_Tendermint, + Consensus: Consensus_tendermint, }}, {"ZetaPrivnetChain", ZetaPrivnetChain, Chain{ ChainName: ChainName_zeta_mainnet, ChainId: 101, - Network: Network_ZETA, - NetworkType: NetworkType_PRIVNET, + Network: Network_zeta, + NetworkType: NetworkType_privnet, IsExternal: false, - Vm: Vm_EVM, + Vm: Vm_evm, IsHeaderSupported: false, - Consensus: Consensus_Tendermint, + Consensus: Consensus_tendermint, }}, {"EthChain", EthChain, Chain{ ChainName: ChainName_eth_mainnet, ChainId: 1, - Network: Network_ETH, - NetworkType: NetworkType_MAINNET, + Network: Network_eth, + NetworkType: NetworkType_mainnet, IsExternal: true, - Vm: Vm_EVM, + Vm: Vm_evm, IsHeaderSupported: true, - Consensus: Consensus_Ethereum, + Consensus: Consensus_ethereum, }}, {"BscMainnetChain", BscMainnetChain, Chain{ ChainName: ChainName_bsc_mainnet, ChainId: 56, - Network: Network_BSC, - NetworkType: NetworkType_MAINNET, + Network: Network_bsc, + NetworkType: NetworkType_mainnet, IsExternal: true, - Vm: Vm_EVM, + Vm: Vm_evm, IsHeaderSupported: true, - Consensus: Consensus_Ethereum, + Consensus: Consensus_ethereum, }}, {"BtcMainnetChain", BtcMainnetChain, Chain{ ChainName: ChainName_btc_mainnet, ChainId: 8332, - Network: Network_BTC, - NetworkType: NetworkType_MAINNET, + Network: Network_btc, + NetworkType: NetworkType_mainnet, IsExternal: true, - Vm: Vm_NO_VM, + Vm: Vm_no_vm, IsHeaderSupported: false, - Consensus: Consensus_Bitcoin, + Consensus: Consensus_bitcoin, }}, {"PolygonChain", PolygonChain, Chain{ ChainName: ChainName_polygon_mainnet, ChainId: 137, - Network: Network_POLYGON, - NetworkType: NetworkType_MAINNET, + Network: Network_polygon, + NetworkType: NetworkType_mainnet, IsExternal: true, - Vm: Vm_EVM, + Vm: Vm_evm, IsHeaderSupported: false, - Consensus: Consensus_Ethereum, + Consensus: Consensus_ethereum, }}, {"SepoliaChain", SepoliaChain, Chain{ ChainName: ChainName_sepolia_testnet, ChainId: 11155111, - Network: Network_ETH, - NetworkType: NetworkType_TESTNET, + Network: Network_eth, + NetworkType: NetworkType_testnet, IsExternal: true, - Vm: Vm_EVM, + Vm: Vm_evm, IsHeaderSupported: true, - Consensus: Consensus_Ethereum, + Consensus: Consensus_ethereum, }}, {"GoerliChain", GoerliChain, Chain{ ChainName: ChainName_goerli_testnet, ChainId: 5, - Network: Network_ETH, - NetworkType: NetworkType_TESTNET, + Network: Network_eth, + NetworkType: NetworkType_testnet, IsExternal: true, - Vm: Vm_EVM, + Vm: Vm_evm, IsHeaderSupported: true, - Consensus: Consensus_Ethereum, + Consensus: Consensus_ethereum, }}, {"AmoyChain", AmoyChain, Chain{ ChainName: ChainName_amoy_testnet, ChainId: 80002, - Network: Network_POLYGON, - NetworkType: NetworkType_TESTNET, + Network: Network_polygon, + NetworkType: NetworkType_testnet, IsExternal: true, - Vm: Vm_EVM, + Vm: Vm_evm, IsHeaderSupported: false, - Consensus: Consensus_Ethereum, + Consensus: Consensus_ethereum, }}, {"BscTestnetChain", BscTestnetChain, Chain{ ChainName: ChainName_bsc_testnet, ChainId: 97, - Network: Network_BSC, - NetworkType: NetworkType_TESTNET, + Network: Network_bsc, + NetworkType: NetworkType_testnet, IsExternal: true, - Vm: Vm_EVM, + Vm: Vm_evm, IsHeaderSupported: true, - Consensus: Consensus_Ethereum, + Consensus: Consensus_ethereum, }}, {"MumbaiChain", MumbaiChain, Chain{ ChainName: ChainName_mumbai_testnet, ChainId: 80001, - Network: Network_POLYGON, - NetworkType: NetworkType_TESTNET, + Network: Network_polygon, + NetworkType: NetworkType_testnet, IsExternal: true, - Vm: Vm_EVM, + Vm: Vm_evm, IsHeaderSupported: false, - Consensus: Consensus_Ethereum, + Consensus: Consensus_ethereum, }}, {"BtcTestNetChain", BtcTestNetChain, Chain{ ChainName: ChainName_btc_testnet, ChainId: 18332, - Network: Network_BTC, - NetworkType: NetworkType_TESTNET, + Network: Network_btc, + NetworkType: NetworkType_testnet, IsExternal: true, - Vm: Vm_NO_VM, + Vm: Vm_no_vm, IsHeaderSupported: false, - Consensus: Consensus_Bitcoin, + Consensus: Consensus_bitcoin, }}, {"BtcRegtestChain", BtcRegtestChain, Chain{ ChainName: ChainName_btc_regtest, ChainId: 18444, - Network: Network_BTC, - NetworkType: NetworkType_PRIVNET, + Network: Network_btc, + NetworkType: NetworkType_privnet, IsExternal: true, - Vm: Vm_NO_VM, + Vm: Vm_no_vm, IsHeaderSupported: false, - Consensus: Consensus_Bitcoin, + Consensus: Consensus_bitcoin, }}, {"GoerliLocalnetChain", GoerliLocalnetChain, Chain{ ChainName: ChainName_goerli_localnet, ChainId: 1337, - Network: Network_ETH, - NetworkType: NetworkType_PRIVNET, + Network: Network_eth, + NetworkType: NetworkType_privnet, IsExternal: true, - Vm: Vm_EVM, + Vm: Vm_evm, IsHeaderSupported: true, - Consensus: Consensus_Ethereum, + Consensus: Consensus_ethereum, }}, } @@ -190,9 +190,9 @@ func TestChainListByNetworkType(t *testing.T) { networkType NetworkType expected []Chain }{ - {"MainnetChainList", NetworkType_MAINNET, []Chain{ZetaChainMainnet(), BtcMainnetChain(), BscMainnetChain(), EthChain(), PolygonChain()}}, - {"TestnetChainList", NetworkType_TESTNET, []Chain{ZetaTestnetChain(), BtcTestNetChain(), MumbaiChain(), AmoyChain(), BscTestnetChain(), GoerliChain(), SepoliaChain()}}, - {"PrivnetChainList", NetworkType_PRIVNET, []Chain{ZetaPrivnetChain(), BtcRegtestChain(), GoerliLocalnetChain()}}, + {"MainnetChainList", NetworkType_mainnet, []Chain{ZetaChainMainnet(), BtcMainnetChain(), BscMainnetChain(), EthChain(), PolygonChain()}}, + {"TestnetChainList", NetworkType_testnet, []Chain{ZetaTestnetChain(), BtcTestNetChain(), MumbaiChain(), AmoyChain(), BscTestnetChain(), GoerliChain(), SepoliaChain()}}, + {"PrivnetChainList", NetworkType_privnet, []Chain{ZetaPrivnetChain(), BtcRegtestChain(), GoerliLocalnetChain()}}, } for _, lt := range listTests { @@ -218,11 +218,11 @@ func TestChainListByNetwork(t *testing.T) { network Network expected []Chain }{ - {"Zeta", Network_ZETA, []Chain{ZetaChainMainnet(), ZetaMocknetChain(), ZetaPrivnetChain(), ZetaTestnetChain()}}, - {"Btc", Network_BTC, []Chain{BtcMainnetChain(), BtcTestNetChain(), BtcRegtestChain()}}, - {"Eth", Network_ETH, []Chain{EthChain(), GoerliChain(), SepoliaChain(), GoerliLocalnetChain()}}, - {"Bsc", Network_BSC, []Chain{BscMainnetChain(), BscTestnetChain()}}, - {"Polygon", Network_POLYGON, []Chain{PolygonChain(), MumbaiChain(), AmoyChain()}}, + {"Zeta", Network_zeta, []Chain{ZetaChainMainnet(), ZetaMocknetChain(), ZetaPrivnetChain(), ZetaTestnetChain()}}, + {"Btc", Network_btc, []Chain{BtcMainnetChain(), BtcTestNetChain(), BtcRegtestChain()}}, + {"Eth", Network_eth, []Chain{EthChain(), GoerliChain(), SepoliaChain(), GoerliLocalnetChain()}}, + {"Bsc", Network_bsc, []Chain{BscMainnetChain(), BscTestnetChain()}}, + {"Polygon", Network_polygon, []Chain{PolygonChain(), MumbaiChain(), AmoyChain()}}, } for _, lt := range listTests { diff --git a/pkg/chains/status.go b/pkg/chains/status.go index 25140267f7..c74bcb2780 100644 --- a/pkg/chains/status.go +++ b/pkg/chains/status.go @@ -9,9 +9,9 @@ import "errors" func ReceiveStatusFromString(str string) (ReceiveStatus, error) { switch str { case "0": - return ReceiveStatus_Success, nil + return ReceiveStatus_success, nil case "1": - return ReceiveStatus_Failed, nil + return ReceiveStatus_failed, nil default: return ReceiveStatus(0), errors.New("wrong status, must be 0 for success or 1 for failed") } diff --git a/pkg/chains/status_test.go b/pkg/chains/status_test.go index 65f5e7e319..a26170f97c 100644 --- a/pkg/chains/status_test.go +++ b/pkg/chains/status_test.go @@ -17,13 +17,13 @@ func TestReceiveStatusFromString(t *testing.T) { { name: "success", str: "0", - want: chains.ReceiveStatus_Success, + want: chains.ReceiveStatus_success, wantErr: false, }, { name: "failed", str: "1", - want: chains.ReceiveStatus_Failed, + want: chains.ReceiveStatus_failed, wantErr: false, }, { diff --git a/proto/pkg/chains/chains.proto b/proto/pkg/chains/chains.proto index 19333d6363..1a11f504e1 100644 --- a/proto/pkg/chains/chains.proto +++ b/proto/pkg/chains/chains.proto @@ -7,9 +7,9 @@ option go_package = "github.com/zeta-chain/zetacore/pkg/chains"; enum ReceiveStatus { option (gogoproto.goproto_enum_stringer) = true; - Created = 0; // some observer sees inbound tx - Success = 1; - Failed = 2; + created = 0; // some observer sees inbound tx + success = 1; + failed = 2; } // ChainName represents the name of the chain @@ -38,35 +38,35 @@ enum ChainName { // Network represents the network type of the chain enum Network { option (gogoproto.goproto_enum_stringer) = true; - ETH = 0; - ZETA = 1; - BTC = 2; - POLYGON = 3; - BSC = 4; + eth = 0; + zeta = 1; + btc = 2; + polygon = 3; + bsc = 4; } // NetworkType represents the network type of the chain enum NetworkType { option (gogoproto.goproto_enum_stringer) = true; - MAINNET = 0; - TESTNET = 1; - PRIVNET = 2; - DEVNET = 3; + mainnet = 0; + testnet = 1; + privnet = 2; + devnet = 3; } // Vm represents the virtual machine type of the chain to support smart contracts enum Vm { option (gogoproto.goproto_enum_stringer) = true; - NO_VM = 0; - EVM = 1; + no_vm = 0; + evm = 1; } // Consensus represents the consensus algorithm used by the chain enum Consensus { option (gogoproto.goproto_enum_stringer) = true; - Ethereum = 0; - Tendermint = 1; - Bitcoin = 2; + ethereum = 0; + tendermint = 1; + bitcoin = 2; } // Chain represents a blockchain network with its unique chain ID diff --git a/testutil/keeper/crosschain.go b/testutil/keeper/crosschain.go index 531af3c7b1..a2fd745edc 100644 --- a/testutil/keeper/crosschain.go +++ b/testutil/keeper/crosschain.go @@ -286,12 +286,12 @@ func MockRevertForHandleEVMDeposit(m *crosschainmocks.CrosschainFungibleKeeper, } func MockVoteOnOutboundSuccessBallot(m *crosschainmocks.CrosschainObserverKeeper, ctx sdk.Context, cctx *types.CrossChainTx, senderChain chains.Chain, observer string) { - m.On("VoteOnOutboundBallot", ctx, mock.Anything, cctx.GetCurrentOutTxParam().ReceiverChainId, chains.ReceiveStatus_Success, observer). + m.On("VoteOnOutboundBallot", ctx, mock.Anything, cctx.GetCurrentOutTxParam().ReceiverChainId, chains.ReceiveStatus_success, observer). Return(true, true, observertypes.Ballot{BallotStatus: observertypes.BallotStatus_BallotFinalized_SuccessObservation}, senderChain.ChainName.String(), nil).Once() } func MockVoteOnOutboundFailedBallot(m *crosschainmocks.CrosschainObserverKeeper, ctx sdk.Context, cctx *types.CrossChainTx, senderChain chains.Chain, observer string) { - m.On("VoteOnOutboundBallot", ctx, mock.Anything, cctx.GetCurrentOutTxParam().ReceiverChainId, chains.ReceiveStatus_Failed, observer). + m.On("VoteOnOutboundBallot", ctx, mock.Anything, cctx.GetCurrentOutTxParam().ReceiverChainId, chains.ReceiveStatus_failed, observer). Return(true, true, observertypes.Ballot{BallotStatus: observertypes.BallotStatus_BallotFinalized_FailureObservation}, senderChain.ChainName.String(), nil).Once() } diff --git a/testutil/network/genesis_state.go b/testutil/network/genesis_state.go index 943c982b9c..4fb7f054bf 100644 --- a/testutil/network/genesis_state.go +++ b/testutil/network/genesis_state.go @@ -61,7 +61,7 @@ func SetupZetaGenesisState(t *testing.T, genesisState map[string]json.RawMessage } if setupChainNonces { - privatenetChains := chains.ChainListByNetworkType(chains.NetworkType_PRIVNET) + privatenetChains := chains.ChainListByNetworkType(chains.NetworkType_privnet) chainNonceList := make([]observertypes.ChainNonces, len(privatenetChains)) for i, chain := range privatenetChains { chainNonceList[i] = observertypes.ChainNonces{ diff --git a/testutil/sample/observer.go b/testutil/sample/observer.go index 2c478c097f..ea906c6e57 100644 --- a/testutil/sample/observer.go +++ b/testutil/sample/observer.go @@ -110,7 +110,7 @@ func ChainParamsSupported(chainID int64) *types.ChainParams { } func ChainParamsList() (cpl types.ChainParamsList) { - chainList := chains.ChainListByNetworkType(chains.NetworkType_PRIVNET) + chainList := chains.ChainListByNetworkType(chains.NetworkType_privnet) for _, chain := range chainList { cpl.ChainParams = append(cpl.ChainParams, ChainParams(chain.ChainId)) diff --git a/x/crosschain/keeper/msg_server_vote_outbound_tx_test.go b/x/crosschain/keeper/msg_server_vote_outbound_tx_test.go index 11ea50a514..606f450afc 100644 --- a/x/crosschain/keeper/msg_server_vote_outbound_tx_test.go +++ b/x/crosschain/keeper/msg_server_vote_outbound_tx_test.go @@ -154,7 +154,7 @@ func TestKeeper_VoteOnObservedOutboundTx(t *testing.T) { CctxHash: cctx.Index, OutTxTssNonce: cctx.GetCurrentOutTxParam().OutboundTxTssNonce, OutTxChain: cctx.GetCurrentOutTxParam().ReceiverChainId, - Status: chains.ReceiveStatus_Success, + Status: chains.ReceiveStatus_success, Creator: observer, ObservedOutTxHash: sample.Hash().String(), ValueReceived: cctx.GetCurrentOutTxParam().Amount, @@ -210,7 +210,7 @@ func TestKeeper_VoteOnObservedOutboundTx(t *testing.T) { CctxHash: cctx.Index, OutTxTssNonce: cctx.GetCurrentOutTxParam().OutboundTxTssNonce, OutTxChain: cctx.GetCurrentOutTxParam().ReceiverChainId, - Status: chains.ReceiveStatus_Failed, + Status: chains.ReceiveStatus_failed, Creator: observer, ObservedOutTxHash: sample.Hash().String(), ValueReceived: cctx.GetCurrentOutTxParam().Amount, @@ -270,7 +270,7 @@ func TestKeeper_VoteOnObservedOutboundTx(t *testing.T) { CctxHash: cctx.Index, OutTxTssNonce: cctx.GetCurrentOutTxParam().OutboundTxTssNonce, OutTxChain: cctx.GetCurrentOutTxParam().ReceiverChainId, - Status: chains.ReceiveStatus_Failed, + Status: chains.ReceiveStatus_failed, Creator: observer, ObservedOutTxHash: sample.Hash().String(), ValueReceived: cctx.GetCurrentOutTxParam().Amount, @@ -332,7 +332,7 @@ func TestKeeper_VoteOnObservedOutboundTx(t *testing.T) { CctxHash: cctx.Index, OutTxTssNonce: cctx.GetCurrentOutTxParam().OutboundTxTssNonce, OutTxChain: cctx.GetCurrentOutTxParam().ReceiverChainId, - Status: chains.ReceiveStatus_Failed, + Status: chains.ReceiveStatus_failed, Creator: observer, ObservedOutTxHash: sample.Hash().String(), ValueReceived: cctx.GetCurrentOutTxParam().Amount, @@ -376,7 +376,7 @@ func TestKeeper_VoteOnObservedOutboundTx(t *testing.T) { CctxHash: cctx.Index, OutTxTssNonce: cctx.GetCurrentOutTxParam().OutboundTxTssNonce, OutTxChain: cctx.GetCurrentOutTxParam().ReceiverChainId, - Status: chains.ReceiveStatus_Success, + Status: chains.ReceiveStatus_success, Creator: accAddress.String(), ObservedOutTxHash: sample.Hash().String(), ValueReceived: cctx.GetCurrentOutTxParam().Amount, @@ -422,7 +422,7 @@ func TestKeeper_VoteOnObservedOutboundTx(t *testing.T) { CctxHash: cctx.Index, OutTxTssNonce: cctx.GetCurrentOutTxParam().OutboundTxTssNonce, OutTxChain: cctx.GetCurrentOutTxParam().ReceiverChainId, - Status: chains.ReceiveStatus_Success, + Status: chains.ReceiveStatus_success, Creator: accAddress.String(), ObservedOutTxHash: sample.Hash().String(), ValueReceived: cctx.GetCurrentOutTxParam().Amount, diff --git a/x/crosschain/types/message_vote_on_observed_outbound_tx.go b/x/crosschain/types/message_vote_on_observed_outbound_tx.go index 360038c6f4..7c468aa54a 100644 --- a/x/crosschain/types/message_vote_on_observed_outbound_tx.go +++ b/x/crosschain/types/message_vote_on_observed_outbound_tx.go @@ -80,8 +80,8 @@ func (msg *MsgVoteOnObservedOutboundTx) Digest() string { m := *msg m.Creator = "" - // Set status to ReceiveStatus_Created to make sure both successful and failed votes are added to the same ballot - m.Status = chains.ReceiveStatus_Created + // Set status to ReceiveStatus_created to make sure both successful and failed votes are added to the same ballot + m.Status = chains.ReceiveStatus_created // Outbound and reverted txs have different digest as ObservedOutTxHash is different so they are stored in different ballots hash := crypto.Keccak256Hash([]byte(m.String())) diff --git a/x/crosschain/types/message_vote_on_observed_outbound_tx_test.go b/x/crosschain/types/message_vote_on_observed_outbound_tx_test.go index d9e3f6a3ca..9c2c4714bf 100644 --- a/x/crosschain/types/message_vote_on_observed_outbound_tx_test.go +++ b/x/crosschain/types/message_vote_on_observed_outbound_tx_test.go @@ -32,7 +32,7 @@ func TestMsgVoteOnObservedOutboundTx_ValidateBasic(t *testing.T) { math.NewInt(42), 42, math.NewUint(42), - chains.ReceiveStatus_Created, + chains.ReceiveStatus_created, 42, 42, coin.CoinType_Zeta, @@ -49,7 +49,7 @@ func TestMsgVoteOnObservedOutboundTx_ValidateBasic(t *testing.T) { math.NewInt(42), 42, math.NewUint(42), - chains.ReceiveStatus_Created, + chains.ReceiveStatus_created, 42, 42, coin.CoinType_Zeta, @@ -67,7 +67,7 @@ func TestMsgVoteOnObservedOutboundTx_ValidateBasic(t *testing.T) { math.NewInt(42), 42, math.NewUint(42), - chains.ReceiveStatus_Created, + chains.ReceiveStatus_created, -1, 42, coin.CoinType_Zeta, @@ -99,7 +99,7 @@ func TestMsgVoteOnObservedOutboundTx_Digest(t *testing.T) { ObservedOutTxEffectiveGasPrice: math.NewInt(42), ObservedOutTxEffectiveGasLimit: 42, ValueReceived: math.NewUint(42), - Status: chains.ReceiveStatus_Created, + Status: chains.ReceiveStatus_created, OutTxChain: 42, OutTxTssNonce: 42, CoinType: coin.CoinType_Zeta, @@ -115,7 +115,7 @@ func TestMsgVoteOnObservedOutboundTx_Digest(t *testing.T) { // status not used msg2 = msg - msg2.Status = chains.ReceiveStatus_Failed + msg2.Status = chains.ReceiveStatus_failed hash2 = msg2.Digest() require.Equal(t, hash, hash2, "status should not change hash") diff --git a/x/crosschain/types/tx.pb.go b/x/crosschain/types/tx.pb.go index f7fa9790e4..fabc4f9b44 100644 --- a/x/crosschain/types/tx.pb.go +++ b/x/crosschain/types/tx.pb.go @@ -920,7 +920,7 @@ func (m *MsgVoteOnObservedOutboundTx) GetStatus() chains.ReceiveStatus { if m != nil { return m.Status } - return chains.ReceiveStatus_Created + return chains.ReceiveStatus_created } func (m *MsgVoteOnObservedOutboundTx) GetOutTxChain() int64 { diff --git a/x/observer/keeper/msg_server_vote_tss.go b/x/observer/keeper/msg_server_vote_tss.go index 87c7e0b31f..402a84a3db 100644 --- a/x/observer/keeper/msg_server_vote_tss.go +++ b/x/observer/keeper/msg_server_vote_tss.go @@ -73,7 +73,7 @@ func (k msgServer) VoteTSS(goCtx context.Context, msg *types.MsgVoteTSS) (*types // vote the ballot var err error vote := types.VoteType_SuccessObservation - if msg.Status == chains.ReceiveStatus_Failed { + if msg.Status == chains.ReceiveStatus_failed { vote = types.VoteType_FailureObservation } ballot, err = k.AddVoteToBallot(ctx, ballot, msg.Creator, vote) diff --git a/x/observer/keeper/msg_server_vote_tss_test.go b/x/observer/keeper/msg_server_vote_tss_test.go index f7ef851bf9..e92f59cb7e 100644 --- a/x/observer/keeper/msg_server_vote_tss_test.go +++ b/x/observer/keeper/msg_server_vote_tss_test.go @@ -22,7 +22,7 @@ func TestMsgServer_VoteTSS(t *testing.T) { Creator: sample.AccAddress(), TssPubkey: sample.Tss().TssPubkey, KeygenZetaHeight: 42, - Status: chains.ReceiveStatus_Success, + Status: chains.ReceiveStatus_success, }) require.ErrorIs(t, err, sdkerrors.ErrorInvalidSigner) }) @@ -39,7 +39,7 @@ func TestMsgServer_VoteTSS(t *testing.T) { Creator: nodeAcc.Operator, TssPubkey: sample.Tss().TssPubkey, KeygenZetaHeight: 42, - Status: chains.ReceiveStatus_Success, + Status: chains.ReceiveStatus_success, }) require.ErrorIs(t, err, types.ErrKeygenNotFound) }) @@ -59,7 +59,7 @@ func TestMsgServer_VoteTSS(t *testing.T) { Creator: nodeAcc.Operator, TssPubkey: sample.Tss().TssPubkey, KeygenZetaHeight: 42, - Status: chains.ReceiveStatus_Success, + Status: chains.ReceiveStatus_success, }) require.ErrorIs(t, err, types.ErrKeygenCompleted) }) @@ -81,7 +81,7 @@ func TestMsgServer_VoteTSS(t *testing.T) { Creator: nodeAcc.Operator, TssPubkey: sample.Tss().TssPubkey, KeygenZetaHeight: 42, - Status: chains.ReceiveStatus_Success, + Status: chains.ReceiveStatus_success, }) require.NoError(t, err) @@ -114,7 +114,7 @@ func TestMsgServer_VoteTSS(t *testing.T) { Creator: nodeAcc.Operator, TssPubkey: sample.Tss().TssPubkey, KeygenZetaHeight: 42, - Status: chains.ReceiveStatus_Failed, + Status: chains.ReceiveStatus_failed, }) require.NoError(t, err) @@ -152,7 +152,7 @@ func TestMsgServer_VoteTSS(t *testing.T) { Creator: nodeAcc1.Operator, TssPubkey: tss.TssPubkey, KeygenZetaHeight: 42, - Status: chains.ReceiveStatus_Success, + Status: chains.ReceiveStatus_success, }) require.NoError(t, err) @@ -171,7 +171,7 @@ func TestMsgServer_VoteTSS(t *testing.T) { Creator: nodeAcc2.Operator, TssPubkey: tss.TssPubkey, KeygenZetaHeight: 42, - Status: chains.ReceiveStatus_Success, + Status: chains.ReceiveStatus_success, }) require.NoError(t, err) @@ -190,7 +190,7 @@ func TestMsgServer_VoteTSS(t *testing.T) { Creator: nodeAcc3.Operator, TssPubkey: tss.TssPubkey, KeygenZetaHeight: 42, - Status: chains.ReceiveStatus_Success, + Status: chains.ReceiveStatus_success, }) require.NoError(t, err) @@ -224,7 +224,7 @@ func TestMsgServer_VoteTSS(t *testing.T) { Creator: nodeAcc.Operator, TssPubkey: sample.Tss().TssPubkey, KeygenZetaHeight: 42, - Status: chains.ReceiveStatus_Success, + Status: chains.ReceiveStatus_success, }) require.NoError(t, err) require.False(t, res.VoteFinalized) @@ -234,7 +234,7 @@ func TestMsgServer_VoteTSS(t *testing.T) { Creator: nodeAcc.Operator, TssPubkey: sample.Tss().TssPubkey, KeygenZetaHeight: 42, - Status: chains.ReceiveStatus_Success, + Status: chains.ReceiveStatus_success, }) require.ErrorIs(t, err, types.ErrUnableToAddVote) }) diff --git a/x/observer/keeper/vote_outbound_test.go b/x/observer/keeper/vote_outbound_test.go index c92fec5927..72f498d413 100644 --- a/x/observer/keeper/vote_outbound_test.go +++ b/x/observer/keeper/vote_outbound_test.go @@ -21,7 +21,7 @@ func TestKeeper_VoteOnOutboundBallot(t *testing.T) { ctx, "index", getValidEthChainIDWithIndex(t, 0), - chains.ReceiveStatus_Success, + chains.ReceiveStatus_success, sample.AccAddress(), ) require.Error(t, err) @@ -41,7 +41,7 @@ func TestKeeper_VoteOnOutboundBallot(t *testing.T) { ctx, "index", getValidEthChainIDWithIndex(t, 0), - chains.ReceiveStatus_Success, + chains.ReceiveStatus_success, sample.AccAddress(), ) require.Error(t, err) @@ -88,7 +88,7 @@ func TestKeeper_VoteOnOutboundBallot(t *testing.T) { ctx, "index", getValidEthChainIDWithIndex(t, 0), - chains.ReceiveStatus_Success, + chains.ReceiveStatus_success, sample.AccAddress(), ) require.Error(t, err) @@ -120,7 +120,7 @@ func TestKeeper_VoteOnOutboundBallot(t *testing.T) { ctx, "index", getValidEthChainIDWithIndex(t, 0), - chains.ReceiveStatus_Success, + chains.ReceiveStatus_success, observer, ) require.NoError(t, err) @@ -167,7 +167,7 @@ func TestKeeper_VoteOnOutboundBallot(t *testing.T) { ctx, "index", getValidEthChainIDWithIndex(t, 0), - chains.ReceiveStatus_Success, + chains.ReceiveStatus_success, observer, ) require.Error(t, err) @@ -208,7 +208,7 @@ func TestKeeper_VoteOnOutboundBallot(t *testing.T) { ctx, "index", getValidEthChainIDWithIndex(t, 0), - chains.ReceiveStatus_Success, + chains.ReceiveStatus_success, observer, ) require.NoError(t, err) @@ -266,7 +266,7 @@ func TestKeeper_VoteOnOutboundBallot(t *testing.T) { ctx, "index", getValidEthChainIDWithIndex(t, 0), - chains.ReceiveStatus_Success, + chains.ReceiveStatus_success, observer, ) require.NoError(t, err) @@ -322,7 +322,7 @@ func TestKeeper_VoteOnOutboundBallot(t *testing.T) { ctx, "index", getValidEthChainIDWithIndex(t, 0), - chains.ReceiveStatus_Success, + chains.ReceiveStatus_success, observer, ) require.NoError(t, err) diff --git a/x/observer/types/message_vote_tss.go b/x/observer/types/message_vote_tss.go index bbd8a73e65..ccb3c8b960 100644 --- a/x/observer/types/message_vote_tss.go +++ b/x/observer/types/message_vote_tss.go @@ -50,7 +50,7 @@ func (msg *MsgVoteTSS) ValidateBasic() error { } // either success or observation failure - if msg.Status != chains.ReceiveStatus_Success && msg.Status != chains.ReceiveStatus_Failed { + if msg.Status != chains.ReceiveStatus_success && msg.Status != chains.ReceiveStatus_failed { return cosmoserrors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid status: %s", msg.Status) } diff --git a/x/observer/types/message_vote_tss_test.go b/x/observer/types/message_vote_tss_test.go index fb8d92323b..4026ccb018 100644 --- a/x/observer/types/message_vote_tss_test.go +++ b/x/observer/types/message_vote_tss_test.go @@ -19,20 +19,20 @@ func TestMsgVoteTSS_ValidateBasic(t *testing.T) { }{ { name: "valid message", - msg: types.NewMsgVoteTSS(sample.AccAddress(), "pubkey", 1, chains.ReceiveStatus_Success), + msg: types.NewMsgVoteTSS(sample.AccAddress(), "pubkey", 1, chains.ReceiveStatus_success), }, { name: "valid message with receive status failed", - msg: types.NewMsgVoteTSS(sample.AccAddress(), "pubkey", 1, chains.ReceiveStatus_Failed), + msg: types.NewMsgVoteTSS(sample.AccAddress(), "pubkey", 1, chains.ReceiveStatus_failed), }, { name: "invalid creator address", - msg: types.NewMsgVoteTSS("invalid", "pubkey", 1, chains.ReceiveStatus_Success), + msg: types.NewMsgVoteTSS("invalid", "pubkey", 1, chains.ReceiveStatus_success), err: sdkerrors.ErrInvalidAddress, }, { name: "invalid observation status", - msg: types.NewMsgVoteTSS(sample.AccAddress(), "pubkey", 1, chains.ReceiveStatus_Created), + msg: types.NewMsgVoteTSS(sample.AccAddress(), "pubkey", 1, chains.ReceiveStatus_created), err: sdkerrors.ErrInvalidRequest, }, } @@ -58,12 +58,12 @@ func TestMsgVoteTSS_GetSigners(t *testing.T) { }{ { name: "valid signer", - msg: types.NewMsgVoteTSS(signer, "pubkey", 1, chains.ReceiveStatus_Success), + msg: types.NewMsgVoteTSS(signer, "pubkey", 1, chains.ReceiveStatus_success), panics: false, }, { name: "invalid signer", - msg: types.NewMsgVoteTSS("invalid", "pubkey", 1, chains.ReceiveStatus_Success), + msg: types.NewMsgVoteTSS("invalid", "pubkey", 1, chains.ReceiveStatus_success), panics: true, }, } @@ -83,23 +83,23 @@ func TestMsgVoteTSS_GetSigners(t *testing.T) { } func TestMsgVoteTSS_Type(t *testing.T) { - msg := types.NewMsgVoteTSS(sample.AccAddress(), "pubkey", 1, chains.ReceiveStatus_Success) + msg := types.NewMsgVoteTSS(sample.AccAddress(), "pubkey", 1, chains.ReceiveStatus_success) require.Equal(t, types.TypeMsgVoteTSS, msg.Type()) } func TestMsgVoteTSS_Route(t *testing.T) { - msg := types.NewMsgVoteTSS(sample.AccAddress(), "pubkey", 1, chains.ReceiveStatus_Success) + msg := types.NewMsgVoteTSS(sample.AccAddress(), "pubkey", 1, chains.ReceiveStatus_success) require.Equal(t, types.RouterKey, msg.Route()) } func TestMsgVoteTSS_GetSignBytes(t *testing.T) { - msg := types.NewMsgVoteTSS(sample.AccAddress(), "pubkey", 1, chains.ReceiveStatus_Success) + msg := types.NewMsgVoteTSS(sample.AccAddress(), "pubkey", 1, chains.ReceiveStatus_success) require.NotPanics(t, func() { msg.GetSignBytes() }) } func TestMsgVoteTSS_Digest(t *testing.T) { - msg := types.NewMsgVoteTSS(sample.AccAddress(), "pubkey", 1, chains.ReceiveStatus_Success) + msg := types.NewMsgVoteTSS(sample.AccAddress(), "pubkey", 1, chains.ReceiveStatus_success) require.Equal(t, "1-tss-keygen", msg.Digest()) } diff --git a/x/observer/types/observer_set.go b/x/observer/types/observer_set.go index 483f28592c..a5ca5661d0 100644 --- a/x/observer/types/observer_set.go +++ b/x/observer/types/observer_set.go @@ -26,9 +26,9 @@ func (m *ObserverSet) Validate() error { func CheckReceiveStatus(status chains.ReceiveStatus) error { switch status { - case chains.ReceiveStatus_Success: + case chains.ReceiveStatus_success: return nil - case chains.ReceiveStatus_Failed: + case chains.ReceiveStatus_failed: return nil default: return ErrInvalidStatus diff --git a/x/observer/types/observer_set_test.go b/x/observer/types/observer_set_test.go index 5efce2cd81..391ecc57b6 100644 --- a/x/observer/types/observer_set_test.go +++ b/x/observer/types/observer_set_test.go @@ -23,10 +23,10 @@ func TestObserverSet(t *testing.T) { } func TestCheckReceiveStatus(t *testing.T) { - err := types.CheckReceiveStatus(chains.ReceiveStatus_Success) + err := types.CheckReceiveStatus(chains.ReceiveStatus_success) require.NoError(t, err) - err = types.CheckReceiveStatus(chains.ReceiveStatus_Failed) + err = types.CheckReceiveStatus(chains.ReceiveStatus_failed) require.NoError(t, err) - err = types.CheckReceiveStatus(chains.ReceiveStatus_Created) + err = types.CheckReceiveStatus(chains.ReceiveStatus_created) require.Error(t, err) } diff --git a/x/observer/types/params.go b/x/observer/types/params.go index e62573f8c5..b8479c9f0f 100644 --- a/x/observer/types/params.go +++ b/x/observer/types/params.go @@ -28,7 +28,7 @@ func NewParams(observerParams []*ObserverParams, adminParams []*Admin_Policy, ba // privnet chains are supported by default for testing purposes // custom params must be provided in genesis for other networks func DefaultParams() Params { - chainList := chains.ChainListByNetworkType(chains.NetworkType_PRIVNET) + chainList := chains.ChainListByNetworkType(chains.NetworkType_privnet) observerParams := make([]*ObserverParams, len(chainList)) for i, chain := range chainList { observerParams[i] = &ObserverParams{ diff --git a/x/observer/types/parsers.go b/x/observer/types/parsers.go index ad7537e18e..b202c06c2c 100644 --- a/x/observer/types/parsers.go +++ b/x/observer/types/parsers.go @@ -7,9 +7,9 @@ import ( func ConvertReceiveStatusToVoteType(status chains.ReceiveStatus) VoteType { switch status { - case chains.ReceiveStatus_Success: + case chains.ReceiveStatus_success: return VoteType_SuccessObservation - case chains.ReceiveStatus_Failed: + case chains.ReceiveStatus_failed: return VoteType_FailureObservation default: return VoteType_NotYetVoted diff --git a/x/observer/types/parsers_test.go b/x/observer/types/parsers_test.go index 1c108fcee8..50053758a3 100644 --- a/x/observer/types/parsers_test.go +++ b/x/observer/types/parsers_test.go @@ -16,9 +16,9 @@ func TestConvertReceiveStatusToVoteType(t *testing.T) { status chains.ReceiveStatus expected types.VoteType }{ - {"TestSuccessStatus", chains.ReceiveStatus_Success, types.VoteType_SuccessObservation}, - {"TestFailedStatus", chains.ReceiveStatus_Failed, types.VoteType_FailureObservation}, - {"TestDefaultStatus", chains.ReceiveStatus_Created, types.VoteType_NotYetVoted}, + {"TestSuccessStatus", chains.ReceiveStatus_success, types.VoteType_SuccessObservation}, + {"TestFailedStatus", chains.ReceiveStatus_failed, types.VoteType_FailureObservation}, + {"TestDefaultStatus", chains.ReceiveStatus_created, types.VoteType_NotYetVoted}, } for _, tt := range tests { diff --git a/x/observer/types/tx.pb.go b/x/observer/types/tx.pb.go index 87585e885d..233aca98ba 100644 --- a/x/observer/types/tx.pb.go +++ b/x/observer/types/tx.pb.go @@ -1008,7 +1008,7 @@ func (m *MsgVoteTSS) GetStatus() chains.ReceiveStatus { if m != nil { return m.Status } - return chains.ReceiveStatus_Created + return chains.ReceiveStatus_created } type MsgVoteTSSResponse struct { diff --git a/zetaclient/bitcoin/bitcoin_client.go b/zetaclient/bitcoin/bitcoin_client.go index 801171a88c..ba1c30b585 100644 --- a/zetaclient/bitcoin/bitcoin_client.go +++ b/zetaclient/bitcoin/bitcoin_client.go @@ -567,7 +567,7 @@ func (ob *BTCChainClient) IsOutboundProcessed(cctx *types.CrossChainTx, logger z nil, // gas price not used with Bitcoin 0, // gas limit not used with Bitcoin amountInSat, - chains.ReceiveStatus_Success, + chains.ReceiveStatus_success, ob.chain, nonce, coin.CoinType_Gas, diff --git a/zetaclient/evm/evm_client_test.go b/zetaclient/evm/evm_client_test.go index e71bfd49ed..6b195ab85c 100644 --- a/zetaclient/evm/evm_client_test.go +++ b/zetaclient/evm/evm_client_test.go @@ -185,7 +185,7 @@ func TestEVM_VoteOutboundBallot(t *testing.T) { math.NewIntFromBigInt(tx.GasPrice()), tx.Gas(), math.NewUintFromBigInt(tx.Value()), - chains.ReceiveStatus_Success, + chains.ReceiveStatus_success, chainID, tx.Nonce(), coinType, diff --git a/zetaclient/evm/outbounds.go b/zetaclient/evm/outbounds.go index 081616256e..7811e1ddb9 100644 --- a/zetaclient/evm/outbounds.go +++ b/zetaclient/evm/outbounds.go @@ -81,9 +81,9 @@ func (ob *ChainClient) IsOutboundProcessed(cctx *crosschaintypes.CrossChainTx, l if compliance.IsCctxRestricted(cctx) { // use cctx's amount to bypass the amount check in zetacore receiveValue = cctx.GetCurrentOutTxParam().Amount.BigInt() - receiveStatus := chains.ReceiveStatus_Failed + receiveStatus := chains.ReceiveStatus_failed if receipt.Status == ethtypes.ReceiptStatusSuccessful { - receiveStatus = chains.ReceiveStatus_Success + receiveStatus = chains.ReceiveStatus_success } ob.PostVoteOutbound(cctx.Index, receipt, transaction, receiveValue, receiveStatus, nonce, cointype, logger) return true, true, nil @@ -205,10 +205,10 @@ func ParseOuttxReceivedValue( // determine the receive status and value // https://docs.nethereum.com/en/latest/nethereum-receipt-status/ receiveValue := big.NewInt(0) - receiveStatus := chains.ReceiveStatus_Failed + receiveStatus := chains.ReceiveStatus_failed if receipt.Status == ethtypes.ReceiptStatusSuccessful { receiveValue = transaction.Value() - receiveStatus = chains.ReceiveStatus_Success + receiveStatus = chains.ReceiveStatus_success } // parse receive value from the outtx receipt for Zeta and ERC20 @@ -217,7 +217,7 @@ func ParseOuttxReceivedValue( if receipt.Status == ethtypes.ReceiptStatusSuccessful { receivedLog, revertedLog, err := ParseAndCheckZetaEvent(cctx, receipt, connectorAddress, connector) if err != nil { - return nil, chains.ReceiveStatus_Failed, err + return nil, chains.ReceiveStatus_failed, err } // use the value in ZetaReceived/ZetaReverted event for vote message if receivedLog != nil { @@ -230,7 +230,7 @@ func ParseOuttxReceivedValue( if receipt.Status == ethtypes.ReceiptStatusSuccessful { withdrawn, err := ParseAndCheckWithdrawnEvent(cctx, receipt, custodyAddress, custody) if err != nil { - return nil, chains.ReceiveStatus_Failed, err + return nil, chains.ReceiveStatus_failed, err } // use the value in Withdrawn event for vote message receiveValue = withdrawn.Amount @@ -238,7 +238,7 @@ func ParseOuttxReceivedValue( case coin.CoinType_Gas, coin.CoinType_Cmd: // nothing to do for CoinType_Gas/CoinType_Cmd, no need to parse event default: - return nil, chains.ReceiveStatus_Failed, fmt.Errorf("unknown coin type %s", cointype) + return nil, chains.ReceiveStatus_failed, fmt.Errorf("unknown coin type %s", cointype) } return receiveValue, receiveStatus, nil } diff --git a/zetaclient/evm/outbounds_test.go b/zetaclient/evm/outbounds_test.go index 30f523614f..757a407394 100644 --- a/zetaclient/evm/outbounds_test.go +++ b/zetaclient/evm/outbounds_test.go @@ -153,7 +153,7 @@ func Test_PostVoteOutbound(t *testing.T) { t.Run("post vote outbound successfully", func(t *testing.T) { // the amount and status to be used for vote receiveValue := cctx.GetCurrentOutTxParam().Amount.BigInt() - receiveStatus := chains.ReceiveStatus_Success + receiveStatus := chains.ReceiveStatus_success // create evm client using mock zetaBridge and post outbound vote zetaBridge := stub.NewMockZetaCoreBridge() @@ -351,7 +351,7 @@ func Test_ParseOuttxReceivedValue(t *testing.T) { value, status, err := evm.ParseOuttxReceivedValue(cctx, receipt, outtx, coinType, connectorAddr, connector, custodyAddr, custody) require.NoError(t, err) require.True(t, params.Amount.BigInt().Cmp(value) == 0) - require.Equal(t, chains.ReceiveStatus_Success, status) + require.Equal(t, chains.ReceiveStatus_success, status) }) t.Run("should parse and check ZetaReverted event from archived outtx receipt", func(t *testing.T) { // load archived outtx receipt that contains ZetaReverted event @@ -366,7 +366,7 @@ func Test_ParseOuttxReceivedValue(t *testing.T) { cctx, receipt, outtx, coinType, connectorAddrLocal, connectorLocal, custodyAddrLocal, custodyLocal) require.NoError(t, err) require.True(t, params.Amount.BigInt().Cmp(value) == 0) - require.Equal(t, chains.ReceiveStatus_Success, status) + require.Equal(t, chains.ReceiveStatus_success, status) }) t.Run("should parse and check ERC20 Withdrawn event from archived outtx receipt", func(t *testing.T) { // load archived outtx receipt that contains ERC20 Withdrawn event @@ -378,7 +378,7 @@ func Test_ParseOuttxReceivedValue(t *testing.T) { value, status, err := evm.ParseOuttxReceivedValue(cctx, receipt, outtx, coinType, connectorAddr, connector, custodyAddr, custody) require.NoError(t, err) require.True(t, params.Amount.BigInt().Cmp(value) == 0) - require.Equal(t, chains.ReceiveStatus_Success, status) + require.Equal(t, chains.ReceiveStatus_success, status) }) t.Run("nothing to parse if coinType is Gas", func(t *testing.T) { // load archived outtx receipt of Gas token transfer @@ -390,7 +390,7 @@ func Test_ParseOuttxReceivedValue(t *testing.T) { value, status, err := evm.ParseOuttxReceivedValue(cctx, receipt, outtx, coinType, connectorAddr, connector, custodyAddr, custody) require.NoError(t, err) require.True(t, params.Amount.BigInt().Cmp(value) == 0) - require.Equal(t, chains.ReceiveStatus_Success, status) + require.Equal(t, chains.ReceiveStatus_success, status) }) t.Run("should fail on unknown coin type", func(t *testing.T) { // load archived outtx receipt that contains ZetaReceived event @@ -401,7 +401,7 @@ func Test_ParseOuttxReceivedValue(t *testing.T) { value, status, err := evm.ParseOuttxReceivedValue(cctx, receipt, outtx, coinType, connectorAddr, connector, custodyAddr, custody) require.ErrorContains(t, err, "unknown coin type") require.Nil(t, value) - require.Equal(t, chains.ReceiveStatus_Failed, status) + require.Equal(t, chains.ReceiveStatus_failed, status) }) t.Run("should fail if unable to parse ZetaReceived event", func(t *testing.T) { // load archived outtx receipt that contains ZetaReceived event @@ -415,7 +415,7 @@ func Test_ParseOuttxReceivedValue(t *testing.T) { value, status, err := evm.ParseOuttxReceivedValue(cctx, receipt, outtx, coinType, fakeConnectorAddress, connector, custodyAddr, custody) require.Error(t, err) require.Nil(t, value) - require.Equal(t, chains.ReceiveStatus_Failed, status) + require.Equal(t, chains.ReceiveStatus_failed, status) }) t.Run("should fail if unable to parse ERC20 Withdrawn event", func(t *testing.T) { // load archived outtx receipt that contains ERC20 Withdrawn event @@ -429,6 +429,6 @@ func Test_ParseOuttxReceivedValue(t *testing.T) { value, status, err := evm.ParseOuttxReceivedValue(cctx, receipt, outtx, coinType, connectorAddr, connector, fakeCustodyAddress, custody) require.Error(t, err) require.Nil(t, value) - require.Equal(t, chains.ReceiveStatus_Failed, status) + require.Equal(t, chains.ReceiveStatus_failed, status) }) } diff --git a/zetaclient/zetabridge/tx.go b/zetaclient/zetabridge/tx.go index b76996e79a..3fa998a22a 100644 --- a/zetaclient/zetabridge/tx.go +++ b/zetaclient/zetabridge/tx.go @@ -316,7 +316,7 @@ func (b *ZetaCoreBridge) PostVoteOutbound( // the higher gas limit is only necessary when the vote is finalized and the outbound is processed // therefore we use a retryGasLimit with a higher value to resend the tx if it fails (when the vote is finalized) retryGasLimit := uint64(0) - if msg.Status == chains.ReceiveStatus_Failed { + if msg.Status == chains.ReceiveStatus_failed { retryGasLimit = PostVoteOutboundRevertGasLimit } diff --git a/zetaclient/zetabridge/tx_test.go b/zetaclient/zetabridge/tx_test.go index 666c1fd156..048525ceb1 100644 --- a/zetaclient/zetabridge/tx_test.go +++ b/zetaclient/zetabridge/tx_test.go @@ -190,7 +190,7 @@ func TestZetaCoreBridge_SetTSS(t *testing.T) { hash, err := zetabridge.SetTSS( "zetapub1addwnpepqtadxdyt037h86z60nl98t6zk56mw5zpnm79tsmvspln3hgt5phdc79kvfc", 9987, - chains.ReceiveStatus_Success, + chains.ReceiveStatus_success, ) require.NoError(t, err) require.Equal(t, sampleHash, hash) @@ -471,7 +471,7 @@ func TestZetaCoreBridge_PostVoteOutbound(t *testing.T) { big.NewInt(100), 1200, big.NewInt(500), - chains.ReceiveStatus_Success, + chains.ReceiveStatus_success, chains.EthChain(), 10001, coin.CoinType_Gas) From 61caa74ed36219bc9bcfe8c74d79ce83e0d41dd6 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Wed, 24 Apr 2024 12:28:15 -0400 Subject: [PATCH 10/31] replace chain functions with variables --- cmd/zetaclientd/keygen_tss.go | 2 +- cmd/zetacored/parsers_test.go | 2 +- e2e/e2etests/test_bitcoin_withdraw.go | 8 +- e2e/e2etests/test_migrate_chain_support.go | 4 +- e2e/e2etests/test_zeta_withdraw.go | 2 +- e2e/runner/bitcoin.go | 2 +- e2e/runner/evm.go | 2 +- e2e/runner/setup_zeta.go | 4 +- e2e/txserver/zeta_tx_server.go | 6 +- pkg/chains/address_test.go | 58 +++--- pkg/chains/bitcoin.go | 10 +- pkg/chains/bitcoin_test.go | 18 +- pkg/chains/chain_test.go | 112 +++++------ pkg/chains/chains.go | 177 +++++++----------- pkg/chains/chains_test.go | 32 ++-- pkg/crypto/pubkey_test.go | 8 +- testutil/sample/crosschain.go | 4 +- testutil/sample/fungible.go | 4 +- testutil/sample/lightclient.go | 2 +- x/crosschain/keeper/abci_test.go | 16 +- x/crosschain/keeper/evm_hooks_test.go | 58 +++--- x/crosschain/keeper/gas_payment_test.go | 16 +- .../msg_server_add_to_intx_tracker_test.go | 8 +- x/crosschain/keeper/process_inbound_test.go | 18 +- x/crosschain/keeper/process_outbound_test.go | 26 +-- .../keeper/rate_limiter_flags_test.go | 2 +- x/crosschain/keeper/utils_test.go | 10 +- x/crosschain/migrations/v4/migrate_test.go | 28 +-- x/crosschain/migrations/v5/migrate.go | 8 +- x/crosschain/migrations/v5/migrate_test.go | 22 +-- x/crosschain/types/cctx_test.go | 8 +- x/crosschain/types/inbound_params_test.go | 4 +- .../message_add_to_in_tx_tracker_test.go | 20 +- .../types/tx_body_verification_test.go | 46 ++--- x/crosschain/types/validate_test.go | 38 ++-- x/lightclient/genesis_test.go | 6 +- x/lightclient/keeper/block_header_test.go | 6 +- x/lightclient/keeper/proof_test.go | 10 +- .../keeper/verification_flags_test.go | 8 +- x/lightclient/types/genesis_test.go | 12 +- .../keeper/grpc_query_chain_params_test.go | 6 +- x/observer/keeper/grpc_query_tss_test.go | 8 +- .../msg_server_reset_chain_nonces_test.go | 8 +- .../msg_server_vote_block_header_test.go | 26 +-- x/observer/keeper/utils_test.go | 4 +- x/observer/keeper/vote_inbound_test.go | 14 +- x/observer/types/chain_params.go | 20 +- .../bitcoin/bitcoin_client_live_test.go | 4 +- zetaclient/bitcoin/bitcoin_client_test.go | 18 +- zetaclient/bitcoin/bitcoin_signer_test.go | 2 +- zetaclient/bitcoin/fee_test.go | 2 +- zetaclient/bitcoin/tx_script_test.go | 28 +-- zetaclient/compliance/compliance_test.go | 2 +- zetaclient/config/config_chain.go | 28 +-- .../core_context/zeta_core_context_test.go | 6 +- zetaclient/evm/evm_signer.go | 2 +- zetaclient/evm/evm_signer_test.go | 6 +- zetaclient/evm/inbounds_test.go | 14 +- .../evm/outbound_transaction_data_test.go | 4 +- zetaclient/evm/outbounds_test.go | 20 +- zetaclient/testutils/stub/tss_signer.go | 4 +- zetaclient/zetabridge/broadcast_test.go | 4 +- zetaclient/zetabridge/query_test.go | 52 ++--- zetaclient/zetabridge/tx_test.go | 50 ++--- zetaclient/zetacore_observer_test.go | 14 +- 65 files changed, 566 insertions(+), 607 deletions(-) diff --git a/cmd/zetaclientd/keygen_tss.go b/cmd/zetaclientd/keygen_tss.go index 1eb589e058..cc33f17cbd 100644 --- a/cmd/zetaclientd/keygen_tss.go +++ b/cmd/zetaclientd/keygen_tss.go @@ -37,7 +37,7 @@ func GenerateTss( // Bitcoin chain ID is currently used for using the correct signature format // TODO: remove this once we have a better way to determine the signature format // https://github.com/zeta-chain/node/issues/1397 - bitcoinChainID := chains.BtcRegtestChain().ChainId + bitcoinChainID := chains.BtcRegtestChain.ChainId btcChain, _, btcEnabled := appContext.GetBTCChainAndConfig() if btcEnabled { bitcoinChainID = btcChain.ChainId diff --git a/cmd/zetacored/parsers_test.go b/cmd/zetacored/parsers_test.go index 06f0346903..690c9d553b 100644 --- a/cmd/zetacored/parsers_test.go +++ b/cmd/zetacored/parsers_test.go @@ -31,7 +31,7 @@ func TestParsefileToObserverMapper(t *testing.T) { func createObserverList(fp string) { var listReader []ObserverInfoReader - //listChainID := []int64{common.GoerliLocalNetChain().ChainId, common.BtcRegtestChain().ChainId, common.ZetaChain().ChainId} + //listChainID := []int64{common.GoerliLocalNetChain().ChainId, common.BtcRegtestChain.ChainId, common.ZetaChain().ChainId} commonGrantAddress := sdk.AccAddress(crypto.AddressHash([]byte("ObserverGranteeAddress"))) observerAddress := sdk.AccAddress(crypto.AddressHash([]byte("ObserverAddress"))) validatorAddress := sdk.ValAddress(crypto.AddressHash([]byte("ValidatorAddress"))) diff --git a/e2e/e2etests/test_bitcoin_withdraw.go b/e2e/e2etests/test_bitcoin_withdraw.go index cfb43eb72d..18efc44a40 100644 --- a/e2e/e2etests/test_bitcoin_withdraw.go +++ b/e2e/e2etests/test_bitcoin_withdraw.go @@ -132,12 +132,12 @@ func parseBitcoinWithdrawArgs(args []string, defaultReceiver string) (btcutil.Ad var receiver btcutil.Address if args[0] == "" { // use the default receiver - receiver, err = chains.DecodeBtcAddress(defaultReceiver, chains.BtcRegtestChain().ChainId) + receiver, err = chains.DecodeBtcAddress(defaultReceiver, chains.BtcRegtestChain.ChainId) if err != nil { panic("Invalid default receiver address specified for TestBitcoinWithdraw.") } } else { - receiver, err = chains.DecodeBtcAddress(args[0], chains.BtcRegtestChain().ChainId) + receiver, err = chains.DecodeBtcAddress(args[0], chains.BtcRegtestChain.ChainId) if err != nil { panic("Invalid receiver address specified for TestBitcoinWithdraw.") } @@ -224,7 +224,7 @@ func withdrawBTCZRC20(r *runner.E2ERunner, to btcutil.Address, amount *big.Int) func withdrawBitcoinRestricted(r *runner.E2ERunner, amount *big.Int) { // use restricted BTC P2WPKH address - addressRestricted, err := chains.DecodeBtcAddress(testutils.RestrictedBtcAddressTest, chains.BtcRegtestChain().ChainId) + addressRestricted, err := chains.DecodeBtcAddress(testutils.RestrictedBtcAddressTest, chains.BtcRegtestChain.ChainId) if err != nil { panic(err) } @@ -246,7 +246,7 @@ func withdrawBitcoinRestricted(r *runner.E2ERunner, amount *big.Int) { // amount := big.NewInt(int64(0.1 * 1e8 / float64(repeat))) // // // check if the deposit is successful -// BTCZRC20Addr, err := r.SystemContract.GasCoinZRC20ByChainId(&bind.CallOpts{}, big.NewInt(common.BtcRegtestChain().ChainId)) +// BTCZRC20Addr, err := r.SystemContract.GasCoinZRC20ByChainId(&bind.CallOpts{}, big.NewInt(common.BtcRegtestChain.ChainId)) // if err != nil { // panic(err) // } diff --git a/e2e/e2etests/test_migrate_chain_support.go b/e2e/e2etests/test_migrate_chain_support.go index 75bdb29d0e..48fc90be73 100644 --- a/e2e/e2etests/test_migrate_chain_support.go +++ b/e2e/e2etests/test_migrate_chain_support.go @@ -30,7 +30,7 @@ const EVM2RPCURL = "http://eth2:8545" // EVM2ChainID is the chain ID for the additional EVM localnet // We set Sepolia testnet although the value is not important, only used to differentiate -var EVM2ChainID = chains.SepoliaChain().ChainId +var EVM2ChainID = chains.SepoliaChain.ChainId func TestMigrateChainSupport(r *runner.E2ERunner, _ []string) { // deposit most of the ZETA supply on ZetaChain @@ -170,7 +170,7 @@ func TestMigrateChainSupport(r *runner.E2ERunner, _ []string) { res, err := newRunner.ZetaTxServer.BroadcastTx(utils.FungibleAdminName, crosschaintypes.NewMsgWhitelistERC20( adminAddr, newRunner.ERC20Addr.Hex(), - chains.SepoliaChain().ChainId, + chains.SepoliaChain.ChainId, "USDT", "USDT", 18, diff --git a/e2e/e2etests/test_zeta_withdraw.go b/e2e/e2etests/test_zeta_withdraw.go index 6dfc664813..add49af587 100644 --- a/e2e/e2etests/test_zeta_withdraw.go +++ b/e2e/e2etests/test_zeta_withdraw.go @@ -134,7 +134,7 @@ func TestZetaWithdrawBTCRevert(r *runner.E2ERunner, args []string) { lessThanAmount := amount.Div(amount, big.NewInt(10)) // 1/10 of amount tx, err = r.ConnectorZEVM.Send(r.ZEVMAuth, connectorzevm.ZetaInterfacesSendInput{ - DestinationChainId: big.NewInt(chains.BtcRegtestChain().ChainId), + DestinationChainId: big.NewInt(chains.BtcRegtestChain.ChainId), DestinationAddress: r.DeployerAddress.Bytes(), DestinationGasLimit: big.NewInt(400_000), Message: nil, diff --git a/e2e/runner/bitcoin.go b/e2e/runner/bitcoin.go index 4bb8d5e46c..5f9895023f 100644 --- a/e2e/runner/bitcoin.go +++ b/e2e/runner/bitcoin.go @@ -393,7 +393,7 @@ func (runner *E2ERunner) ProveBTCTransaction(txHash *chainhash.Hash) { // verify merkle proof through RPC res, err := runner.LightclientClient.Prove(runner.Ctx, &lightclienttypes.QueryProveRequest{ - ChainId: chains.BtcRegtestChain().ChainId, + ChainId: chains.BtcRegtestChain.ChainId, TxHash: txHash.String(), BlockHash: blockHash.String(), Proof: proofs.NewBitcoinProof(txBytes, path, index), diff --git a/e2e/runner/evm.go b/e2e/runner/evm.go index 0bc6d77070..afe5222eb7 100644 --- a/e2e/runner/evm.go +++ b/e2e/runner/evm.go @@ -248,7 +248,7 @@ func (runner *E2ERunner) ProveEthTransaction(receipt *ethtypes.Receipt) { TxIndex: int64(txIndex), TxHash: txHash.Hex(), Proof: proofs.NewEthereumProof(txProof), - ChainId: chains.GoerliLocalnetChain().ChainId, + ChainId: chains.GoerliLocalnetChain.ChainId, }) if err != nil { panic(err) diff --git a/e2e/runner/setup_zeta.go b/e2e/runner/setup_zeta.go index e332f98af9..4213173ed7 100644 --- a/e2e/runner/setup_zeta.go +++ b/e2e/runner/setup_zeta.go @@ -184,7 +184,7 @@ func (runner *E2ERunner) SetZEVMContracts() { // SetupETHZRC20 sets up the ETH ZRC20 in the runner from the values queried from the chain func (runner *E2ERunner) SetupETHZRC20() { - ethZRC20Addr, err := runner.SystemContract.GasCoinZRC20ByChainId(&bind.CallOpts{}, big.NewInt(chains.GoerliLocalnetChain().ChainId)) + ethZRC20Addr, err := runner.SystemContract.GasCoinZRC20ByChainId(&bind.CallOpts{}, big.NewInt(chains.GoerliLocalnetChain.ChainId)) if err != nil { panic(err) } @@ -201,7 +201,7 @@ func (runner *E2ERunner) SetupETHZRC20() { // SetupBTCZRC20 sets up the BTC ZRC20 in the runner from the values queried from the chain func (runner *E2ERunner) SetupBTCZRC20() { - BTCZRC20Addr, err := runner.SystemContract.GasCoinZRC20ByChainId(&bind.CallOpts{}, big.NewInt(chains.BtcRegtestChain().ChainId)) + BTCZRC20Addr, err := runner.SystemContract.GasCoinZRC20ByChainId(&bind.CallOpts{}, big.NewInt(chains.BtcRegtestChain.ChainId)) if err != nil { panic(err) } diff --git a/e2e/txserver/zeta_tx_server.go b/e2e/txserver/zeta_tx_server.go index d6d804c81e..8014bd2b48 100644 --- a/e2e/txserver/zeta_tx_server.go +++ b/e2e/txserver/zeta_tx_server.go @@ -327,7 +327,7 @@ func (zts ZetaTxServer) DeploySystemContractsAndZRC20(account, erc20Addr string) _, err = zts.BroadcastTx(account, fungibletypes.NewMsgDeployFungibleCoinZRC20( addr.String(), "", - chains.GoerliLocalnetChain().ChainId, + chains.GoerliLocalnetChain.ChainId, 18, "ETH", "gETH", @@ -342,7 +342,7 @@ func (zts ZetaTxServer) DeploySystemContractsAndZRC20(account, erc20Addr string) _, err = zts.BroadcastTx(account, fungibletypes.NewMsgDeployFungibleCoinZRC20( addr.String(), "", - chains.BtcRegtestChain().ChainId, + chains.BtcRegtestChain.ChainId, 8, "BTC", "tBTC", @@ -357,7 +357,7 @@ func (zts ZetaTxServer) DeploySystemContractsAndZRC20(account, erc20Addr string) res, err = zts.BroadcastTx(account, fungibletypes.NewMsgDeployFungibleCoinZRC20( addr.String(), erc20Addr, - chains.GoerliLocalnetChain().ChainId, + chains.GoerliLocalnetChain.ChainId, 6, "USDT", "USDT", diff --git a/pkg/chains/address_test.go b/pkg/chains/address_test.go index bc9e8d8171..c4535e07db 100644 --- a/pkg/chains/address_test.go +++ b/pkg/chains/address_test.go @@ -35,7 +35,7 @@ func TestAddress(t *testing.T) { func TestDecodeBtcAddress(t *testing.T) { t.Run("invalid string", func(t *testing.T) { - _, err := DecodeBtcAddress("�U�ڷ���i߭����꿚�l", BtcTestNetChain().ChainId) + _, err := DecodeBtcAddress("�U�ڷ���i߭����꿚�l", BtcTestNetChain.ChainId) require.ErrorContains(t, err, "runtime error: index out of range") }) t.Run("invalid chain", func(t *testing.T) { @@ -43,42 +43,42 @@ func TestDecodeBtcAddress(t *testing.T) { require.ErrorContains(t, err, "is not a bitcoin chain") }) t.Run("invalid checksum", func(t *testing.T) { - _, err := DecodeBtcAddress("tb1qy9pqmk2pd9sv63g27jt8r657wy0d9uee4x2dt2", BtcTestNetChain().ChainId) + _, err := DecodeBtcAddress("tb1qy9pqmk2pd9sv63g27jt8r657wy0d9uee4x2dt2", BtcTestNetChain.ChainId) require.ErrorContains(t, err, "invalid checksum") }) t.Run("valid legacy main-net address address incorrect params TestNet", func(t *testing.T) { - _, err := DecodeBtcAddress("1EYVvXLusCxtVuEwoYvWRyN5EZTXwPVvo3", BtcTestNetChain().ChainId) + _, err := DecodeBtcAddress("1EYVvXLusCxtVuEwoYvWRyN5EZTXwPVvo3", BtcTestNetChain.ChainId) require.ErrorContains(t, err, "decode address failed") }) t.Run("valid legacy main-net address address incorrect params RegTestNet", func(t *testing.T) { - _, err := DecodeBtcAddress("1EYVvXLusCxtVuEwoYvWRyN5EZTXwPVvo3", BtcRegtestChain().ChainId) + _, err := DecodeBtcAddress("1EYVvXLusCxtVuEwoYvWRyN5EZTXwPVvo3", BtcRegtestChain.ChainId) require.ErrorContains(t, err, "decode address failed") }) t.Run("valid legacy main-net address address correct params", func(t *testing.T) { - _, err := DecodeBtcAddress("1EYVvXLusCxtVuEwoYvWRyN5EZTXwPVvo3", BtcMainnetChain().ChainId) + _, err := DecodeBtcAddress("1EYVvXLusCxtVuEwoYvWRyN5EZTXwPVvo3", BtcMainnetChain.ChainId) require.NoError(t, err) }) t.Run("valid legacy testnet address with correct params", func(t *testing.T) { - _, err := DecodeBtcAddress("n2TCLD16i8SNjwPCcgGBkTEeG6CQAcYTN1", BtcTestNetChain().ChainId) + _, err := DecodeBtcAddress("n2TCLD16i8SNjwPCcgGBkTEeG6CQAcYTN1", BtcTestNetChain.ChainId) require.NoError(t, err) }) t.Run("non legacy valid address with incorrect params", func(t *testing.T) { - _, err := DecodeBtcAddress("bcrt1qy9pqmk2pd9sv63g27jt8r657wy0d9uee4x2dt2", BtcMainnetChain().ChainId) + _, err := DecodeBtcAddress("bcrt1qy9pqmk2pd9sv63g27jt8r657wy0d9uee4x2dt2", BtcMainnetChain.ChainId) require.ErrorContains(t, err, "not for network mainnet") }) t.Run("non legacy valid address with correct params", func(t *testing.T) { - _, err := DecodeBtcAddress("bcrt1qy9pqmk2pd9sv63g27jt8r657wy0d9uee4x2dt2", BtcRegtestChain().ChainId) + _, err := DecodeBtcAddress("bcrt1qy9pqmk2pd9sv63g27jt8r657wy0d9uee4x2dt2", BtcRegtestChain.ChainId) require.NoError(t, err) }) t.Run("taproot address with correct params", func(t *testing.T) { - _, err := DecodeBtcAddress("bc1p4ur084x8y63mj5hj7eydscuc4awals7ly749x8vhyquc0twcmvhquspa5c", BtcMainnetChain().ChainId) + _, err := DecodeBtcAddress("bc1p4ur084x8y63mj5hj7eydscuc4awals7ly749x8vhyquc0twcmvhquspa5c", BtcMainnetChain.ChainId) require.NoError(t, err) }) t.Run("taproot address with incorrect params", func(t *testing.T) { - _, err := DecodeBtcAddress("bc1p4ur084x8y63mj5hj7eydscuc4awals7ly749x8vhyquc0twcmvhquspa5c", BtcTestNetChain().ChainId) + _, err := DecodeBtcAddress("bc1p4ur084x8y63mj5hj7eydscuc4awals7ly749x8vhyquc0twcmvhquspa5c", BtcTestNetChain.ChainId) require.ErrorContains(t, err, "not for network testnet") }) } @@ -94,20 +94,20 @@ func Test_IsBtcAddressSupported_P2TR(t *testing.T) { // https://mempool.space/tx/259fc21e63e138136c8f19270a0f7ca10039a66a474f91d23a17896f46e677a7 name: "mainnet taproot address", addr: "bc1p4scddlkkuw9486579autxumxmkvuphm5pz4jvf7f6pdh50p2uzqstawjt9", - chainId: BtcMainnetChain().ChainId, + chainId: BtcMainnetChain.ChainId, supported: true, }, { // https://mempool.space/testnet/tx/24991bd2fdc4f744bf7bbd915d4915925eecebdae249f81e057c0a6ffb700ab9 name: "testnet taproot address", addr: "tb1p7qqaucx69xtwkx7vwmhz03xjmzxxpy3hk29y7q06mt3k6a8sehhsu5lacw", - chainId: BtcTestNetChain().ChainId, + chainId: BtcTestNetChain.ChainId, supported: true, }, { name: "regtest taproot address", addr: "bcrt1pqqqsyqcyq5rqwzqfpg9scrgwpugpzysnzs23v9ccrydpk8qarc0sj9hjuh", - chainId: BtcRegtestChain().ChainId, + chainId: BtcRegtestChain.ChainId, supported: true, }, } @@ -138,20 +138,20 @@ func Test_IsBtcAddressSupported_P2WSH(t *testing.T) { // https://mempool.space/tx/791bb9d16f7ab05f70a116d18eaf3552faf77b9d5688699a480261424b4f7e53 name: "mainnet P2WSH address", addr: "bc1qqv6pwn470vu0tssdfha4zdk89v3c8ch5lsnyy855k9hcrcv3evequdmjmc", - chainId: BtcMainnetChain().ChainId, + chainId: BtcMainnetChain.ChainId, supported: true, }, { // https://mempool.space/testnet/tx/78fac3f0d4c0174c88d21c4bb1e23a8f007e890c6d2cfa64c97389ead16c51ed name: "testnet P2WSH address", addr: "tb1quhassyrlj43qar0mn0k5sufyp6mazmh2q85lr6ex8ehqfhxpzsksllwrsu", - chainId: BtcTestNetChain().ChainId, + chainId: BtcTestNetChain.ChainId, supported: true, }, { name: "regtest P2WSH address", addr: "bcrt1qm9mzhyky4w853ft2ms6dtqdyyu3z2tmrq8jg8xglhyuv0dsxzmgs2f0sqy", - chainId: BtcRegtestChain().ChainId, + chainId: BtcRegtestChain.ChainId, supported: true, }, } @@ -181,20 +181,20 @@ func Test_IsBtcAddressSupported_P2WPKH(t *testing.T) { // https://mempool.space/tx/5d09d232bfe41c7cb831bf53fc2e4029ab33a99087fd5328a2331b52ff2ebe5b name: "mainnet P2WPKH address", addr: "bc1qaxf82vyzy8y80v000e7t64gpten7gawewzu42y", - chainId: BtcMainnetChain().ChainId, + chainId: BtcMainnetChain.ChainId, supported: true, }, { // https://mempool.space/testnet/tx/508b4d723c754bad001eae9b7f3c12377d3307bd5b595c27fd8a90089094f0e9 name: "testnet P2WPKH address", addr: "tb1q6rufg6myrxurdn0h57d2qhtm9zfmjw2mzcm05q", - chainId: BtcTestNetChain().ChainId, + chainId: BtcTestNetChain.ChainId, supported: true, }, { name: "regtest P2WPKH address", addr: "bcrt1qy9pqmk2pd9sv63g27jt8r657wy0d9uee4x2dt2", - chainId: BtcRegtestChain().ChainId, + chainId: BtcRegtestChain.ChainId, supported: true, }, } @@ -224,33 +224,33 @@ func Test_IsBtcAddressSupported_P2SH(t *testing.T) { // https://mempool.space/tx/fd68c8b4478686ca6f5ae4c28eaab055490650dbdaa6c2c8e380a7e075958a21 name: "mainnet P2SH address", addr: "327z4GyFM8Y8DiYfasGKQWhRK4MvyMSEgE", - chainId: BtcMainnetChain().ChainId, + chainId: BtcMainnetChain.ChainId, supported: true, }, { // https://mempool.space/testnet/tx/0c8c8f94817e0288a5273f5c971adaa3cee18a895c3ec8544785dddcd96f3848 name: "testnet P2SH address 1", addr: "2N6AoUj3KPS7wNGZXuCckh8YEWcSYNsGbqd", - chainId: BtcTestNetChain().ChainId, + chainId: BtcTestNetChain.ChainId, supported: true, }, { // https://mempool.space/testnet/tx/b5e074c5e021fcbd91ea14b1db29dfe5d14e1a6e046039467bf6ada7f8cc01b3 name: "testnet P2SH address 2", addr: "2MwbFpRpZWv4zREjbdLB9jVW3Q8xonpVeyE", - chainId: BtcTestNetChain().ChainId, + chainId: BtcTestNetChain.ChainId, supported: true, }, { name: "testnet P2SH address 1 should also be supported in regtest", addr: "2N6AoUj3KPS7wNGZXuCckh8YEWcSYNsGbqd", - chainId: BtcRegtestChain().ChainId, + chainId: BtcRegtestChain.ChainId, supported: true, }, { name: "testnet P2SH address 2 should also be supported in regtest", addr: "2MwbFpRpZWv4zREjbdLB9jVW3Q8xonpVeyE", - chainId: BtcRegtestChain().ChainId, + chainId: BtcRegtestChain.ChainId, supported: true, }, } @@ -280,33 +280,33 @@ func Test_IsBtcAddressSupported_P2PKH(t *testing.T) { // https://mempool.space/tx/9c741de6e17382b7a9113fc811e3558981a35a360e3d1262a6675892c91322ca name: "mainnet P2PKH address 1", addr: "1FueivsE338W2LgifJ25HhTcVJ7CRT8kte", - chainId: BtcMainnetChain().ChainId, + chainId: BtcMainnetChain.ChainId, supported: true, }, { // https://mempool.space/testnet/tx/1e3974386f071de7f65cabb57346c1a22ec9b3e211a96928a98149673f681237 name: "testnet P2PKH address 1", addr: "mxpYha3UJKUgSwsAz2qYRqaDSwAkKZ3YEY", - chainId: BtcTestNetChain().ChainId, + chainId: BtcTestNetChain.ChainId, supported: true, }, { // https://mempool.space/testnet/tx/e48459f372727f2253b0ea8c71ded83e8270873b8a044feb3435fc7a799a648f name: "testnet P2PKH address 2", addr: "n1gXcqxmzwqHmqmgobe1XXuJaweSu69tZz", - chainId: BtcTestNetChain().ChainId, + chainId: BtcTestNetChain.ChainId, supported: true, }, { name: "testnet P2PKH address should also be supported in regtest", addr: "mxpYha3UJKUgSwsAz2qYRqaDSwAkKZ3YEY", - chainId: BtcRegtestChain().ChainId, + chainId: BtcRegtestChain.ChainId, supported: true, }, { name: "testnet P2PKH address should also be supported in regtest", addr: "n1gXcqxmzwqHmqmgobe1XXuJaweSu69tZz", - chainId: BtcRegtestChain().ChainId, + chainId: BtcRegtestChain.ChainId, supported: true, }, } diff --git a/pkg/chains/bitcoin.go b/pkg/chains/bitcoin.go index 42f5ee7db2..0492a5cd32 100644 --- a/pkg/chains/bitcoin.go +++ b/pkg/chains/bitcoin.go @@ -15,11 +15,11 @@ var ( // BitcoinNetParamsFromChainID returns the bitcoin net params to be used from the chain id func BitcoinNetParamsFromChainID(chainID int64) (*chaincfg.Params, error) { switch chainID { - case BtcRegtestChain().ChainId: + case BtcRegtestChain.ChainId: return BitcoinRegnetParams, nil - case BtcMainnetChain().ChainId: + case BtcMainnetChain.ChainId: return BitcoinMainnetParams, nil - case BtcTestNetChain().ChainId: + case BtcTestNetChain.ChainId: return BitcoinTestnetParams, nil default: return nil, fmt.Errorf("no Bitcoin net params for chain ID: %d", chainID) @@ -28,10 +28,10 @@ func BitcoinNetParamsFromChainID(chainID int64) (*chaincfg.Params, error) { // IsBitcoinRegnet returns true if the chain id is for the regnet func IsBitcoinRegnet(chainID int64) bool { - return chainID == BtcRegtestChain().ChainId + return chainID == BtcRegtestChain.ChainId } // IsBitcoinMainnet returns true if the chain id is for the mainnet func IsBitcoinMainnet(chainID int64) bool { - return chainID == BtcMainnetChain().ChainId + return chainID == BtcMainnetChain.ChainId } diff --git a/pkg/chains/bitcoin_test.go b/pkg/chains/bitcoin_test.go index 042cc6acaa..c1c1ff2852 100644 --- a/pkg/chains/bitcoin_test.go +++ b/pkg/chains/bitcoin_test.go @@ -14,9 +14,9 @@ func TestBitcoinNetParamsFromChainID(t *testing.T) { expected *chaincfg.Params wantErr bool }{ - {"Regnet", BtcRegtestChain().ChainId, BitcoinRegnetParams, false}, - {"Mainnet", BtcMainnetChain().ChainId, BitcoinMainnetParams, false}, - {"Testnet", BtcTestNetChain().ChainId, BitcoinTestnetParams, false}, + {"Regnet", BtcRegtestChain.ChainId, BitcoinRegnetParams, false}, + {"Mainnet", BtcMainnetChain.ChainId, BitcoinMainnetParams, false}, + {"Testnet", BtcTestNetChain.ChainId, BitcoinTestnetParams, false}, {"Unknown", -1, nil, true}, } @@ -34,13 +34,13 @@ func TestBitcoinNetParamsFromChainID(t *testing.T) { } func TestIsBitcoinRegnet(t *testing.T) { - require.True(t, IsBitcoinRegnet(BtcRegtestChain().ChainId)) - require.False(t, IsBitcoinRegnet(BtcMainnetChain().ChainId)) - require.False(t, IsBitcoinRegnet(BtcTestNetChain().ChainId)) + require.True(t, IsBitcoinRegnet(BtcRegtestChain.ChainId)) + require.False(t, IsBitcoinRegnet(BtcMainnetChain.ChainId)) + require.False(t, IsBitcoinRegnet(BtcTestNetChain.ChainId)) } func TestIsBitcoinMainnet(t *testing.T) { - require.True(t, IsBitcoinMainnet(BtcMainnetChain().ChainId)) - require.False(t, IsBitcoinMainnet(BtcRegtestChain().ChainId)) - require.False(t, IsBitcoinMainnet(BtcTestNetChain().ChainId)) + require.True(t, IsBitcoinMainnet(BtcMainnetChain.ChainId)) + require.False(t, IsBitcoinMainnet(BtcRegtestChain.ChainId)) + require.False(t, IsBitcoinMainnet(BtcTestNetChain.ChainId)) } diff --git a/pkg/chains/chain_test.go b/pkg/chains/chain_test.go index ea8d0cfde6..69cc5418db 100644 --- a/pkg/chains/chain_test.go +++ b/pkg/chains/chain_test.go @@ -138,11 +138,11 @@ func TestChain_DecodeAddress(t *testing.T) { } func TestChain_InChainList(t *testing.T) { - require.True(t, ZetaChainMainnet().InChainList(ChainListByNetwork(Network_zeta))) - require.True(t, ZetaMocknetChain().InChainList(ChainListByNetwork(Network_zeta))) - require.True(t, ZetaPrivnetChain().InChainList(ChainListByNetwork(Network_zeta))) - require.True(t, ZetaTestnetChain().InChainList(ChainListByNetwork(Network_zeta))) - require.False(t, EthChain().InChainList(ChainListByNetwork(Network_zeta))) + require.True(t, ZetaChainMainnet.InChainList(ChainListByNetwork(Network_zeta))) + require.True(t, ZetaMocknetChain.InChainList(ChainListByNetwork(Network_zeta))) + require.True(t, ZetaPrivnetChain.InChainList(ChainListByNetwork(Network_zeta))) + require.True(t, ZetaTestnetChain.InChainList(ChainListByNetwork(Network_zeta))) + require.False(t, EthChain.InChainList(ChainListByNetwork(Network_zeta))) } func TestIsZetaChain(t *testing.T) { @@ -151,11 +151,11 @@ func TestIsZetaChain(t *testing.T) { chainID int64 want bool }{ - {"Zeta Mainnet", ZetaChainMainnet().ChainId, true}, - {"Zeta Testnet", ZetaTestnetChain().ChainId, true}, - {"Zeta Mocknet", ZetaMocknetChain().ChainId, true}, - {"Zeta Privnet", ZetaPrivnetChain().ChainId, true}, - {"Non-Zeta", EthChain().ChainId, false}, + {"Zeta Mainnet", ZetaChainMainnet.ChainId, true}, + {"Zeta Testnet", ZetaTestnetChain.ChainId, true}, + {"Zeta Mocknet", ZetaMocknetChain.ChainId, true}, + {"Zeta Privnet", ZetaPrivnetChain.ChainId, true}, + {"Non-Zeta", EthChain.ChainId, false}, } for _, tt := range tests { @@ -171,11 +171,11 @@ func TestIsEVMChain(t *testing.T) { chainID int64 want bool }{ - {"Ethereum Mainnet", EthChain().ChainId, true}, - {"Goerli Testnet", GoerliChain().ChainId, true}, - {"Sepolia Testnet", SepoliaChain().ChainId, true}, - {"Non-EVM", BtcMainnetChain().ChainId, false}, - {"Zeta Mainnet", ZetaChainMainnet().ChainId, false}, + {"Ethereum Mainnet", EthChain.ChainId, true}, + {"Goerli Testnet", GoerliChain.ChainId, true}, + {"Sepolia Testnet", SepoliaChain.ChainId, true}, + {"Non-EVM", BtcMainnetChain.ChainId, false}, + {"Zeta Mainnet", ZetaChainMainnet.ChainId, false}, } for _, tt := range tests { @@ -191,14 +191,14 @@ func TestIsHeaderSupportedEVMChain(t *testing.T) { chainID int64 want bool }{ - {"Ethereum Mainnet", EthChain().ChainId, true}, - {"Goerli Testnet", GoerliChain().ChainId, true}, - {"Goerli Localnet", GoerliLocalnetChain().ChainId, true}, - {"Sepolia Testnet", SepoliaChain().ChainId, true}, - {"BSC Testnet", BscTestnetChain().ChainId, true}, - {"BSC Mainnet", BscMainnetChain().ChainId, true}, - {"Non-EVM", BtcMainnetChain().ChainId, false}, - {"Zeta Mainnet", ZetaChainMainnet().ChainId, false}, + {"Ethereum Mainnet", EthChain.ChainId, true}, + {"Goerli Testnet", GoerliChain.ChainId, true}, + {"Goerli Localnet", GoerliLocalnetChain.ChainId, true}, + {"Sepolia Testnet", SepoliaChain.ChainId, true}, + {"BSC Testnet", BscTestnetChain.ChainId, true}, + {"BSC Mainnet", BscMainnetChain.ChainId, true}, + {"Non-EVM", BtcMainnetChain.ChainId, false}, + {"Zeta Mainnet", ZetaChainMainnet.ChainId, false}, } for _, tt := range tests { @@ -214,11 +214,11 @@ func TestSupportMerkleProof(t *testing.T) { chain Chain want bool }{ - {"Ethereum Mainnet", EthChain(), true}, - {"BSC Testnet", BscTestnetChain(), true}, - {"BSC Mainnet", BscMainnetChain(), true}, - {"Non-EVM", BtcMainnetChain(), true}, - {"Zeta Mainnet", ZetaChainMainnet(), false}, + {"Ethereum Mainnet", EthChain, true}, + {"BSC Testnet", BscTestnetChain, true}, + {"BSC Mainnet", BscMainnetChain, true}, + {"Non-EVM", BtcMainnetChain, true}, + {"Zeta Mainnet", ZetaChainMainnet, false}, } for _, tt := range tests { @@ -234,11 +234,11 @@ func TestIsBitcoinChain(t *testing.T) { chainID int64 want bool }{ - {"Bitcoin Mainnet", BtcMainnetChain().ChainId, true}, - {"Bitcoin Testnet", BtcTestNetChain().ChainId, true}, - {"Bitcoin Regtest", BtcRegtestChain().ChainId, true}, - {"Non-Bitcoin", EthChain().ChainId, false}, - {"Zeta Mainnet", ZetaChainMainnet().ChainId, false}, + {"Bitcoin Mainnet", BtcMainnetChain.ChainId, true}, + {"Bitcoin Testnet", BtcTestNetChain.ChainId, true}, + {"Bitcoin Regtest", BtcRegtestChain.ChainId, true}, + {"Non-Bitcoin", EthChain.ChainId, false}, + {"Zeta Mainnet", ZetaChainMainnet.ChainId, false}, } for _, tt := range tests { @@ -254,11 +254,11 @@ func TestIsEthereumChain(t *testing.T) { chainID int64 want bool }{ - {"Ethereum Mainnet", EthChain().ChainId, true}, - {"Goerli Testnet", GoerliChain().ChainId, true}, - {"Sepolia Testnet", SepoliaChain().ChainId, true}, - {"Non-Ethereum", BtcMainnetChain().ChainId, false}, - {"Zeta Mainnet", ZetaChainMainnet().ChainId, false}, + {"Ethereum Mainnet", EthChain.ChainId, true}, + {"Goerli Testnet", GoerliChain.ChainId, true}, + {"Sepolia Testnet", SepoliaChain.ChainId, true}, + {"Non-Ethereum", BtcMainnetChain.ChainId, false}, + {"Zeta Mainnet", ZetaChainMainnet.ChainId, false}, } for _, tt := range tests { @@ -269,18 +269,18 @@ func TestIsEthereumChain(t *testing.T) { } func TestChain_IsExternalChain(t *testing.T) { - require.False(t, ZetaChainMainnet().IsExternalChain()) - require.True(t, EthChain().IsExternalChain()) + require.False(t, ZetaChainMainnet.IsExternalChain()) + require.True(t, EthChain.IsExternalChain()) } func TestChain_IsZetaChain(t *testing.T) { - require.True(t, ZetaChainMainnet().IsZetaChain()) - require.False(t, EthChain().IsZetaChain()) + require.True(t, ZetaChainMainnet.IsZetaChain()) + require.False(t, EthChain.IsZetaChain()) } func TestChain_IsEmpty(t *testing.T) { require.True(t, Chain{}.IsEmpty()) - require.False(t, ZetaChainMainnet().IsEmpty()) + require.False(t, ZetaChainMainnet.IsEmpty()) } func TestChain_WitnessProgram(t *testing.T) { @@ -296,7 +296,7 @@ func TestChain_WitnessProgram(t *testing.T) { addr, err := btcutil.NewAddressWitnessPubKeyHash(pubKeyHash, &chaincfg.RegressionNetParams) require.NoError(t, err) - chain := BtcTestNetChain() + chain := BtcTestNetChain _, err = chain.BTCAddressFromWitnessProgram(addr.WitnessProgram()) require.NoError(t, err) }) @@ -307,7 +307,7 @@ func TestChain_WitnessProgram(t *testing.T) { addr, err := btcutil.NewAddressWitnessPubKeyHash(pubKeyHash, &chaincfg.RegressionNetParams) require.NoError(t, err) - chain := GoerliChain() + chain := GoerliChain _, err = chain.BTCAddressFromWitnessProgram(addr.WitnessProgram()) require.Error(t, err) }) @@ -318,39 +318,39 @@ func TestChain_WitnessProgram(t *testing.T) { addr, err := btcutil.NewAddressWitnessPubKeyHash(pubKeyHash, &chaincfg.RegressionNetParams) require.NoError(t, err) - chain := BtcTestNetChain() + chain := BtcTestNetChain _, err = chain.BTCAddressFromWitnessProgram(addr.WitnessProgram()[0:19]) require.Error(t, err) }) } func TestChains_Has(t *testing.T) { - chains := Chains{ZetaChainMainnet(), ZetaTestnetChain()} - require.True(t, chains.Has(ZetaChainMainnet())) - require.False(t, chains.Has(EthChain())) + chains := Chains{ZetaChainMainnet, ZetaTestnetChain} + require.True(t, chains.Has(ZetaChainMainnet)) + require.False(t, chains.Has(EthChain)) } func TestChains_Distinct(t *testing.T) { - chains := Chains{ZetaChainMainnet(), ZetaChainMainnet(), ZetaTestnetChain()} + chains := Chains{ZetaChainMainnet, ZetaChainMainnet, ZetaTestnetChain} distinctChains := chains.Distinct() require.Len(t, distinctChains, 2) } func TestChains_Strings(t *testing.T) { - chains := Chains{ZetaChainMainnet(), ZetaTestnetChain()} + chains := Chains{ZetaChainMainnet, ZetaTestnetChain} strings := chains.Strings() expected := []string{chains[0].String(), chains[1].String()} require.Equal(t, expected, strings) } func TestGetChainFromChainID(t *testing.T) { - chain := GetChainFromChainID(ZetaChainMainnet().ChainId) - require.Equal(t, ZetaChainMainnet(), *chain) + chain := GetChainFromChainID(ZetaChainMainnet.ChainId) + require.Equal(t, ZetaChainMainnet, *chain) require.Nil(t, GetChainFromChainID(9999)) } func TestGetBTCChainParams(t *testing.T) { - params, err := GetBTCChainParams(BtcMainnetChain().ChainId) + params, err := GetBTCChainParams(BtcMainnetChain.ChainId) require.NoError(t, err) require.Equal(t, &chaincfg.MainNetParams, params) @@ -376,6 +376,6 @@ func TestGetBTCChainIDFromChainParams(t *testing.T) { } func TestChainIDInChainList(t *testing.T) { - require.True(t, ChainIDInChainList(ZetaChainMainnet().ChainId, ChainListByNetwork(Network_zeta))) - require.False(t, ChainIDInChainList(EthChain().ChainId, ChainListByNetwork(Network_zeta))) + require.True(t, ChainIDInChainList(ZetaChainMainnet.ChainId, ChainListByNetwork(Network_zeta))) + require.False(t, ChainIDInChainList(EthChain.ChainId, ChainListByNetwork(Network_zeta))) } diff --git a/pkg/chains/chains.go b/pkg/chains/chains.go index 96376ac44f..f0ea599aa2 100644 --- a/pkg/chains/chains.go +++ b/pkg/chains/chains.go @@ -17,9 +17,10 @@ import "fmt" Such as GoerliChain and MumbaiChain which have been replaced by SepoliaChain and AmoyChain respectively. */ -// Mainnet chains -func ZetaChainMainnet() Chain { - return Chain{ +var ( + + // Mainnet chains + ZetaChainMainnet = Chain{ ChainName: ChainName_zeta_mainnet, ChainId: 7000, Network: Network_zeta, @@ -29,9 +30,7 @@ func ZetaChainMainnet() Chain { IsExternal: false, IsHeaderSupported: false, } -} -func EthChain() Chain { - return Chain{ + EthChain = Chain{ ChainName: ChainName_eth_mainnet, ChainId: 1, Network: Network_eth, @@ -41,10 +40,7 @@ func EthChain() Chain { IsExternal: true, IsHeaderSupported: true, } -} - -func BscMainnetChain() Chain { - return Chain{ + BscMainnetChain = Chain{ ChainName: ChainName_bsc_mainnet, ChainId: 56, Network: Network_bsc, @@ -54,10 +50,7 @@ func BscMainnetChain() Chain { IsExternal: true, IsHeaderSupported: true, } -} - -func BtcMainnetChain() Chain { - return Chain{ + BtcMainnetChain = Chain{ ChainName: ChainName_btc_mainnet, ChainId: 8332, Network: Network_btc, @@ -67,10 +60,7 @@ func BtcMainnetChain() Chain { IsExternal: true, IsHeaderSupported: false, } -} - -func PolygonChain() Chain { - return Chain{ + PolygonChain = Chain{ ChainName: ChainName_polygon_mainnet, ChainId: 137, Network: Network_polygon, @@ -80,12 +70,8 @@ func PolygonChain() Chain { IsExternal: true, IsHeaderSupported: false, } -} - -// Testnet chains - -func ZetaTestnetChain() Chain { - return Chain{ + // Testnet chains + ZetaTestnetChain = Chain{ ChainName: ChainName_zeta_testnet, ChainId: 7001, Network: Network_zeta, @@ -95,10 +81,7 @@ func ZetaTestnetChain() Chain { IsExternal: false, IsHeaderSupported: false, } -} - -func SepoliaChain() Chain { - return Chain{ + SepoliaChain = Chain{ ChainName: ChainName_sepolia_testnet, ChainId: 11155111, Network: Network_eth, @@ -108,24 +91,7 @@ func SepoliaChain() Chain { IsExternal: true, IsHeaderSupported: true, } -} - -// GoerliChain Deprecated -func GoerliChain() Chain { - return Chain{ - ChainName: ChainName_goerli_testnet, - ChainId: 5, - Network: Network_eth, - NetworkType: NetworkType_testnet, - Vm: Vm_evm, - Consensus: Consensus_ethereum, - IsExternal: true, - IsHeaderSupported: true, - } -} - -func BscTestnetChain() Chain { - return Chain{ + BscTestnetChain = Chain{ ChainName: ChainName_bsc_testnet, ChainId: 97, Network: Network_bsc, @@ -135,10 +101,7 @@ func BscTestnetChain() Chain { IsExternal: true, IsHeaderSupported: true, } -} - -func BtcTestNetChain() Chain { - return Chain{ + BtcTestNetChain = Chain{ ChainName: ChainName_btc_testnet, ChainId: 18332, Network: Network_btc, @@ -148,24 +111,8 @@ func BtcTestNetChain() Chain { IsExternal: true, IsHeaderSupported: false, } -} - -// MumbaiChain Deprecated -func MumbaiChain() Chain { - return Chain{ - ChainName: ChainName_mumbai_testnet, - ChainId: 80001, - Network: Network_polygon, - NetworkType: NetworkType_testnet, - Vm: Vm_evm, - Consensus: Consensus_ethereum, - IsExternal: true, - IsHeaderSupported: false, - } -} -func AmoyChain() Chain { - return Chain{ + AmoyChain = Chain{ ChainName: ChainName_amoy_testnet, ChainId: 80002, Network: Network_polygon, @@ -175,11 +122,8 @@ func AmoyChain() Chain { IsExternal: true, IsHeaderSupported: false, } -} - -// Devnet chains -func ZetaMocknetChain() Chain { - return Chain{ + // Devnet chains + ZetaMocknetChain = Chain{ ChainName: ChainName_zeta_mainnet, ChainId: 70000, Network: Network_zeta, @@ -189,12 +133,8 @@ func ZetaMocknetChain() Chain { IsExternal: false, IsHeaderSupported: false, } -} - -// Privnet chains - -func ZetaPrivnetChain() Chain { - return Chain{ + // Privnet chains + ZetaPrivnetChain = Chain{ ChainName: ChainName_zeta_mainnet, ChainId: 101, Network: Network_zeta, @@ -204,9 +144,8 @@ func ZetaPrivnetChain() Chain { IsExternal: false, IsHeaderSupported: false, } -} -func BtcRegtestChain() Chain { - return Chain{ + + BtcRegtestChain = Chain{ ChainName: ChainName_btc_regtest, ChainId: 18444, Network: Network_btc, @@ -216,10 +155,8 @@ func BtcRegtestChain() Chain { IsExternal: true, IsHeaderSupported: false, } -} -func GoerliLocalnetChain() Chain { - return Chain{ + GoerliLocalnetChain = Chain{ ChainName: ChainName_goerli_localnet, ChainId: 1337, Network: Network_eth, @@ -229,7 +166,29 @@ func GoerliLocalnetChain() Chain { IsExternal: true, IsHeaderSupported: true, } -} + + // Deprecated testnet chains + GoerliChain = Chain{ + ChainName: ChainName_goerli_testnet, + ChainId: 5, + Network: Network_eth, + NetworkType: NetworkType_testnet, + Vm: Vm_evm, + Consensus: Consensus_ethereum, + IsExternal: true, + IsHeaderSupported: true, + } + MumbaiChain = Chain{ + ChainName: ChainName_mumbai_testnet, + ChainId: 80001, + Network: Network_polygon, + NetworkType: NetworkType_testnet, + Vm: Vm_evm, + Consensus: Consensus_ethereum, + IsExternal: true, + IsHeaderSupported: false, + } +) func BtcDustOffset() int64 { return 2000 @@ -238,22 +197,22 @@ func BtcDustOffset() int64 { // DefaultChainsList returns a list of default chains func DefaultChainsList() []*Chain { return chainListPointers([]Chain{ - BtcMainnetChain(), - BscMainnetChain(), - EthChain(), - BtcTestNetChain(), - MumbaiChain(), - AmoyChain(), - BscTestnetChain(), - GoerliChain(), - SepoliaChain(), - BtcRegtestChain(), - GoerliLocalnetChain(), - ZetaChainMainnet(), - ZetaTestnetChain(), - ZetaMocknetChain(), - ZetaPrivnetChain(), - PolygonChain(), + BtcMainnetChain, + BscMainnetChain, + EthChain, + BtcTestNetChain, + MumbaiChain, + AmoyChain, + BscTestnetChain, + GoerliChain, + SepoliaChain, + BtcRegtestChain, + GoerliLocalnetChain, + ZetaChainMainnet, + ZetaTestnetChain, + ZetaMocknetChain, + ZetaPrivnetChain, + PolygonChain, }) } @@ -321,14 +280,14 @@ func ZetaChainFromChainID(chainID string) (Chain, error) { } switch ethChainID { - case ZetaPrivnetChain().ChainId: - return ZetaPrivnetChain(), nil - case ZetaChainMainnet().ChainId: - return ZetaChainMainnet(), nil - case ZetaTestnetChain().ChainId: - return ZetaTestnetChain(), nil - case ZetaMocknetChain().ChainId: - return ZetaMocknetChain(), nil + case ZetaPrivnetChain.ChainId: + return ZetaPrivnetChain, nil + case ZetaChainMainnet.ChainId: + return ZetaChainMainnet, nil + case ZetaTestnetChain.ChainId: + return ZetaTestnetChain, nil + case ZetaMocknetChain.ChainId: + return ZetaMocknetChain, nil default: return Chain{}, fmt.Errorf("chain %d not found", ethChainID) } diff --git a/pkg/chains/chains_test.go b/pkg/chains/chains_test.go index 2f1fc8e20d..9e1358ad48 100644 --- a/pkg/chains/chains_test.go +++ b/pkg/chains/chains_test.go @@ -10,7 +10,7 @@ import ( func TestChainRetrievalFunctions(t *testing.T) { tests := []struct { name string - function func() Chain + chain Chain expected Chain }{ {"ZetaChainMainnet", ZetaChainMainnet, Chain{ @@ -179,7 +179,7 @@ func TestChainRetrievalFunctions(t *testing.T) { for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { - chain := tc.function() + chain := tc.chain require.Equal(t, tc.expected, chain) }) } @@ -190,9 +190,9 @@ func TestChainListByNetworkType(t *testing.T) { networkType NetworkType expected []Chain }{ - {"MainnetChainList", NetworkType_mainnet, []Chain{ZetaChainMainnet(), BtcMainnetChain(), BscMainnetChain(), EthChain(), PolygonChain()}}, - {"TestnetChainList", NetworkType_testnet, []Chain{ZetaTestnetChain(), BtcTestNetChain(), MumbaiChain(), AmoyChain(), BscTestnetChain(), GoerliChain(), SepoliaChain()}}, - {"PrivnetChainList", NetworkType_privnet, []Chain{ZetaPrivnetChain(), BtcRegtestChain(), GoerliLocalnetChain()}}, + {"MainnetChainList", NetworkType_mainnet, []Chain{ZetaChainMainnet, BtcMainnetChain, BscMainnetChain, EthChain, PolygonChain}}, + {"TestnetChainList", NetworkType_testnet, []Chain{ZetaTestnetChain, BtcTestNetChain, MumbaiChain, AmoyChain, BscTestnetChain, GoerliChain, SepoliaChain}}, + {"PrivnetChainList", NetworkType_privnet, []Chain{ZetaPrivnetChain, BtcRegtestChain, GoerliLocalnetChain}}, } for _, lt := range listTests { @@ -218,11 +218,11 @@ func TestChainListByNetwork(t *testing.T) { network Network expected []Chain }{ - {"Zeta", Network_zeta, []Chain{ZetaChainMainnet(), ZetaMocknetChain(), ZetaPrivnetChain(), ZetaTestnetChain()}}, - {"Btc", Network_btc, []Chain{BtcMainnetChain(), BtcTestNetChain(), BtcRegtestChain()}}, - {"Eth", Network_eth, []Chain{EthChain(), GoerliChain(), SepoliaChain(), GoerliLocalnetChain()}}, - {"Bsc", Network_bsc, []Chain{BscMainnetChain(), BscTestnetChain()}}, - {"Polygon", Network_polygon, []Chain{PolygonChain(), MumbaiChain(), AmoyChain()}}, + {"Zeta", Network_zeta, []Chain{ZetaChainMainnet, ZetaMocknetChain, ZetaPrivnetChain, ZetaTestnetChain}}, + {"Btc", Network_btc, []Chain{BtcMainnetChain, BtcTestNetChain, BtcRegtestChain}}, + {"Eth", Network_eth, []Chain{EthChain, GoerliChain, SepoliaChain, GoerliLocalnetChain}}, + {"Bsc", Network_bsc, []Chain{BscMainnetChain, BscTestnetChain}}, + {"Polygon", Network_polygon, []Chain{PolygonChain, MumbaiChain, AmoyChain}}, } for _, lt := range listTests { @@ -247,8 +247,8 @@ func TestChainListFunctions(t *testing.T) { function func() []*Chain expected []Chain }{ - {"DefaultChainsList", DefaultChainsList, []Chain{BtcMainnetChain(), BscMainnetChain(), EthChain(), BtcTestNetChain(), MumbaiChain(), AmoyChain(), BscTestnetChain(), GoerliChain(), SepoliaChain(), BtcRegtestChain(), GoerliLocalnetChain(), ZetaChainMainnet(), ZetaTestnetChain(), ZetaMocknetChain(), ZetaPrivnetChain(), PolygonChain()}}, - {"ExternalChainList", ExternalChainList, []Chain{BtcMainnetChain(), BscMainnetChain(), EthChain(), BtcTestNetChain(), MumbaiChain(), AmoyChain(), BscTestnetChain(), GoerliChain(), SepoliaChain(), BtcRegtestChain(), GoerliLocalnetChain(), PolygonChain()}}, + {"DefaultChainsList", DefaultChainsList, []Chain{BtcMainnetChain, BscMainnetChain, EthChain, BtcTestNetChain, MumbaiChain, AmoyChain, BscTestnetChain, GoerliChain, SepoliaChain, BtcRegtestChain, GoerliLocalnetChain, ZetaChainMainnet, ZetaTestnetChain, ZetaMocknetChain, ZetaPrivnetChain, PolygonChain}}, + {"ExternalChainList", ExternalChainList, []Chain{BtcMainnetChain, BscMainnetChain, EthChain, BtcTestNetChain, MumbaiChain, AmoyChain, BscTestnetChain, GoerliChain, SepoliaChain, BtcRegtestChain, GoerliLocalnetChain, PolygonChain}}, } for _, lt := range listTests { @@ -278,25 +278,25 @@ func TestZetaChainFromChainID(t *testing.T) { { name: "ZetaChainMainnet", chainID: "cosmoshub_7000-1", - expected: ZetaChainMainnet(), + expected: ZetaChainMainnet, wantErr: false, }, { name: "ZetaTestnetChain", chainID: "cosmoshub_7001-1", - expected: ZetaTestnetChain(), + expected: ZetaTestnetChain, wantErr: false, }, { name: "ZetaMocknetChain", chainID: "cosmoshub_70000-1", - expected: ZetaMocknetChain(), + expected: ZetaMocknetChain, wantErr: false, }, { name: "ZetaPrivnetChain", chainID: "cosmoshub_101-1", - expected: ZetaPrivnetChain(), + expected: ZetaPrivnetChain, wantErr: false, }, { diff --git a/pkg/crypto/pubkey_test.go b/pkg/crypto/pubkey_test.go index f86f07fcc0..c0b5a40e2c 100644 --- a/pkg/crypto/pubkey_test.go +++ b/pkg/crypto/pubkey_test.go @@ -132,21 +132,21 @@ func (s *PubKeyTestSuite) TestPubKeyGetAddress(c *C) { c.Assert(err, IsNil) c.Assert(os.Setenv("NET", "mainnet"), IsNil) - addrETH, err := pk.GetAddress(chains.GoerliChain()) + addrETH, err := pk.GetAddress(chains.GoerliChain) c.Assert(err, IsNil) c.Assert(addrETH.String(), Equals, d.addrETH.mainnet) c.Assert(os.Setenv("NET", "testnet"), IsNil) - addrETH, err = pk.GetAddress(chains.GoerliChain()) + addrETH, err = pk.GetAddress(chains.GoerliChain) c.Assert(err, IsNil) c.Assert(addrETH.String(), Equals, d.addrETH.testnet) c.Assert(os.Setenv("NET", "mocknet"), IsNil) - addrETH, err = pk.GetAddress(chains.GoerliChain()) + addrETH, err = pk.GetAddress(chains.GoerliChain) c.Assert(err, IsNil) c.Assert(addrETH.String(), Equals, d.addrETH.mocknet) - addrETH, err = pk.GetAddress(chains.BtcRegtestChain()) + addrETH, err = pk.GetAddress(chains.BtcRegtestChain) c.Assert(err, IsNil) c.Assert(addrETH, Equals, chains.NoAddress) } diff --git a/testutil/sample/crosschain.go b/testutil/sample/crosschain.go index 5a0d8aafdb..03727a1b03 100644 --- a/testutil/sample/crosschain.go +++ b/testutil/sample/crosschain.go @@ -101,7 +101,7 @@ func InboundTxParams(r *rand.Rand) *types.InboundTxParams { func InboundTxParamsValidChainID(r *rand.Rand) *types.InboundTxParams { return &types.InboundTxParams{ Sender: EthAddress().String(), - SenderChainId: chains.GoerliChain().ChainId, + SenderChainId: chains.GoerliChain.ChainId, TxOrigin: EthAddress().String(), Asset: StringRandom(r, 32), Amount: math.NewUint(uint64(r.Int63())), @@ -132,7 +132,7 @@ func OutboundTxParams(r *rand.Rand) *types.OutboundTxParams { func OutboundTxParamsValidChainID(r *rand.Rand) *types.OutboundTxParams { return &types.OutboundTxParams{ Receiver: EthAddress().String(), - ReceiverChainId: chains.GoerliChain().ChainId, + ReceiverChainId: chains.GoerliChain.ChainId, Amount: math.NewUint(uint64(r.Int63())), OutboundTxTssNonce: r.Uint64(), OutboundTxGasLimit: r.Uint64(), diff --git a/testutil/sample/fungible.go b/testutil/sample/fungible.go index 3be91d06a3..0d1cd09673 100644 --- a/testutil/sample/fungible.go +++ b/testutil/sample/fungible.go @@ -25,8 +25,8 @@ func ForeignCoins(t *testing.T, address string) types.ForeignCoins { func ForeignCoinList(t *testing.T, zrc20ETH, zrc20BTC, zrc20ERC20, erc20Asset string) []types.ForeignCoins { // eth and btc chain id - ethChainID := chains.GoerliLocalnetChain().ChainId - btcChainID := chains.BtcRegtestChain().ChainId + ethChainID := chains.GoerliLocalnetChain.ChainId + btcChainID := chains.BtcRegtestChain.ChainId // add zrc20 ETH fcGas := ForeignCoins(t, zrc20ETH) diff --git a/testutil/sample/lightclient.go b/testutil/sample/lightclient.go index 6bb69f32d6..b8ab40eba2 100644 --- a/testutil/sample/lightclient.go +++ b/testutil/sample/lightclient.go @@ -61,7 +61,7 @@ func Proof(t *testing.T) (*proofs.Proof, proofs.BlockHeader, string, int64, int6 proof, err := txsTree.GenerateProof(txIndex) require.NoError(t, err) - chainID := chains.SepoliaChain().ChainId + chainID := chains.SepoliaChain.ChainId ethProof := proofs.NewEthereumProof(proof) ethHeader := proofs.NewEthereumHeader(b) blockHeader := proofs.BlockHeader{ diff --git a/x/crosschain/keeper/abci_test.go b/x/crosschain/keeper/abci_test.go index c8ef411f4b..7f89e36c08 100644 --- a/x/crosschain/keeper/abci_test.go +++ b/x/crosschain/keeper/abci_test.go @@ -43,19 +43,19 @@ func TestKeeper_IterateAndUpdateCctxGasPrice(t *testing.T) { // add some evm and non-evm chains supportedChains := []*chains.Chain{ - {ChainId: chains.EthChain().ChainId}, - {ChainId: chains.BtcMainnetChain().ChainId}, - {ChainId: chains.BscMainnetChain().ChainId}, - {ChainId: chains.ZetaChainMainnet().ChainId}, + {ChainId: chains.EthChain.ChainId}, + {ChainId: chains.BtcMainnetChain.ChainId}, + {ChainId: chains.BscMainnetChain.ChainId}, + {ChainId: chains.ZetaChainMainnet.ChainId}, } // set pending cctx tss := sample.Tss() zk.ObserverKeeper.SetTSS(ctx, tss) - createCctxWithNonceRange(t, ctx, *k, 10, 15, chains.EthChain().ChainId, tss, zk) - createCctxWithNonceRange(t, ctx, *k, 20, 25, chains.BtcMainnetChain().ChainId, tss, zk) - createCctxWithNonceRange(t, ctx, *k, 30, 35, chains.BscMainnetChain().ChainId, tss, zk) - createCctxWithNonceRange(t, ctx, *k, 40, 45, chains.ZetaChainMainnet().ChainId, tss, zk) + createCctxWithNonceRange(t, ctx, *k, 10, 15, chains.EthChain.ChainId, tss, zk) + createCctxWithNonceRange(t, ctx, *k, 20, 25, chains.BtcMainnetChain.ChainId, tss, zk) + createCctxWithNonceRange(t, ctx, *k, 30, 35, chains.BscMainnetChain.ChainId, tss, zk) + createCctxWithNonceRange(t, ctx, *k, 40, 45, chains.ZetaChainMainnet.ChainId, tss, zk) // set a cctx where the update function should fail to test that the next cctx are not updated but the next chains are failMap[sample.GetCctxIndexFromString("1-12")] = struct{}{} diff --git a/x/crosschain/keeper/evm_hooks_test.go b/x/crosschain/keeper/evm_hooks_test.go index bd22eab38c..21352d9dc0 100644 --- a/x/crosschain/keeper/evm_hooks_test.go +++ b/x/crosschain/keeper/evm_hooks_test.go @@ -142,7 +142,7 @@ func TestValidateZrc20WithdrawEvent(t *testing.T) { t.Run("successfully validate a valid event", func(t *testing.T) { btcMainNetWithdrawalEvent, err := crosschainkeeper.ParseZRC20WithdrawalEvent(*sample.GetValidZRC20WithdrawToBTC(t).Logs[3]) require.NoError(t, err) - err = crosschainkeeper.ValidateZrc20WithdrawEvent(btcMainNetWithdrawalEvent, chains.BtcMainnetChain().ChainId) + err = crosschainkeeper.ValidateZrc20WithdrawEvent(btcMainNetWithdrawalEvent, chains.BtcMainnetChain.ChainId) require.NoError(t, err) }) @@ -150,14 +150,14 @@ func TestValidateZrc20WithdrawEvent(t *testing.T) { btcMainNetWithdrawalEvent, err := crosschainkeeper.ParseZRC20WithdrawalEvent(*sample.GetValidZRC20WithdrawToBTC(t).Logs[3]) require.NoError(t, err) btcMainNetWithdrawalEvent.Value = big.NewInt(0) - err = crosschainkeeper.ValidateZrc20WithdrawEvent(btcMainNetWithdrawalEvent, chains.BtcMainnetChain().ChainId) + err = crosschainkeeper.ValidateZrc20WithdrawEvent(btcMainNetWithdrawalEvent, chains.BtcMainnetChain.ChainId) require.ErrorContains(t, err, "ParseZRC20WithdrawalEvent: invalid amount") }) t.Run("unable to validate a event with an invalid chain ID", func(t *testing.T) { btcMainNetWithdrawalEvent, err := crosschainkeeper.ParseZRC20WithdrawalEvent(*sample.GetValidZRC20WithdrawToBTC(t).Logs[3]) require.NoError(t, err) - err = crosschainkeeper.ValidateZrc20WithdrawEvent(btcMainNetWithdrawalEvent, chains.BtcTestNetChain().ChainId) + err = crosschainkeeper.ValidateZrc20WithdrawEvent(btcMainNetWithdrawalEvent, chains.BtcTestNetChain.ChainId) require.ErrorContains(t, err, "invalid address") }) @@ -166,7 +166,7 @@ func TestValidateZrc20WithdrawEvent(t *testing.T) { require.NoError(t, err) btcMainNetWithdrawalEvent.To = []byte("04b2891ba8cb491828db3ebc8a780d43b169e7b3974114e6e50f9bab6ec" + "63c2f20f6d31b2025377d05c2a704d3bd799d0d56f3a8543d79a01ab6084a1cb204f260") - err = crosschainkeeper.ValidateZrc20WithdrawEvent(btcMainNetWithdrawalEvent, chains.BtcMainnetChain().ChainId) + err = crosschainkeeper.ValidateZrc20WithdrawEvent(btcMainNetWithdrawalEvent, chains.BtcMainnetChain.ChainId) require.ErrorContains(t, err, "unsupported address") }) } @@ -176,7 +176,7 @@ func TestKeeper_ProcessZRC20WithdrawalEvent(t *testing.T) { k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) - chain := chains.BtcMainnetChain() + chain := chains.BtcMainnetChain chainID := chain.ChainId setSupportedChain(ctx, zk, chainID) SetupStateForProcessLogs(t, ctx, k, zk, sdkk, chain) @@ -202,7 +202,7 @@ func TestKeeper_ProcessZRC20WithdrawalEvent(t *testing.T) { k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) - chain := chains.EthChain() + chain := chains.EthChain chainID := chain.ChainId setSupportedChain(ctx, zk, chainID) SetupStateForProcessLogs(t, ctx, k, zk, sdkk, chain) @@ -228,7 +228,7 @@ func TestKeeper_ProcessZRC20WithdrawalEvent(t *testing.T) { k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) - chain := chains.EthChain() + chain := chains.EthChain chainID := chain.ChainId setSupportedChain(ctx, zk, chainID) SetupStateForProcessLogs(t, ctx, k, zk, sdkk, chain) @@ -249,7 +249,7 @@ func TestKeeper_ProcessZRC20WithdrawalEvent(t *testing.T) { k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) - chain := chains.EthChain() + chain := chains.EthChain chainID := chain.ChainId SetupStateForProcessLogs(t, ctx, k, zk, sdkk, chain) @@ -270,7 +270,7 @@ func TestKeeper_ProcessZRC20WithdrawalEvent(t *testing.T) { k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) - chain := chains.EthChain() + chain := chains.EthChain chainID := chain.ChainId setSupportedChain(ctx, zk, chainID) SetupStateForProcessLogs(t, ctx, k, zk, sdkk, chain) @@ -293,7 +293,7 @@ func TestKeeper_ProcessZRC20WithdrawalEvent(t *testing.T) { k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) - chain := chains.EthChain() + chain := chains.EthChain chainID := chain.ChainId setSupportedChain(ctx, zk, chainID) SetupStateForProcessLogs(t, ctx, k, zk, sdkk, chain) @@ -319,7 +319,7 @@ func TestKeeper_ProcessZRC20WithdrawalEvent(t *testing.T) { fungibleMock := keepertest.GetCrosschainFungibleMock(t, k) k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) - chain := chains.EthChain() + chain := chains.EthChain chainID := chain.ChainId setSupportedChain(ctx, zk, chainID) SetupStateForProcessLogs(t, ctx, k, zk, sdkk, chain) @@ -344,7 +344,7 @@ func TestKeeper_ProcessZRC20WithdrawalEvent(t *testing.T) { k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) - chain := chains.EthChain() + chain := chains.EthChain chainID := chain.ChainId setSupportedChain(ctx, zk, chainID) SetupStateForProcessLogs(t, ctx, k, zk, sdkk, chain) @@ -367,7 +367,7 @@ func TestKeeper_ProcessZRC20WithdrawalEvent(t *testing.T) { k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) - chain := chains.EthChain() + chain := chains.EthChain chainID := chain.ChainId setSupportedChain(ctx, zk, chainID) SetupStateForProcessLogs(t, ctx, k, zk, sdkk, chain) @@ -402,7 +402,7 @@ func TestKeeper_ParseZetaSentEvent(t *testing.T) { require.Nil(t, event) continue } - require.Equal(t, chains.EthChain().ChainId, event.DestinationChainId.Int64()) + require.Equal(t, chains.EthChain.ChainId, event.DestinationChainId.Int64()) require.Equal(t, "70000000000000000000", event.ZetaValueAndGas.String()) require.Equal(t, "0x60983881bdf302dcfa96603A58274D15D5966209", event.SourceTxOriginAddress.String()) require.Equal(t, "0xF0a3F93Ed1B126142E61423F9546bf1323Ff82DF", event.ZetaTxSenderAddress.String()) @@ -440,7 +440,7 @@ func TestKeeper_ProcessZetaSentEvent(t *testing.T) { k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) - chain := chains.EthChain() + chain := chains.EthChain chainID := chain.ChainId setSupportedChain(ctx, zk, chainID) @@ -464,7 +464,7 @@ func TestKeeper_ProcessZetaSentEvent(t *testing.T) { cctxList := k.GetAllCrossChainTx(ctx) require.Len(t, cctxList, 1) require.Equal(t, strings.Compare("0x60983881bdf302dcfa96603a58274d15d5966209", cctxList[0].GetCurrentOutTxParam().Receiver), 0) - require.Equal(t, chains.EthChain().ChainId, cctxList[0].GetCurrentOutTxParam().ReceiverChainId) + require.Equal(t, chains.EthChain.ChainId, cctxList[0].GetCurrentOutTxParam().ReceiverChainId) require.Equal(t, emittingContract.Hex(), cctxList[0].InboundTxParams.Sender) require.Equal(t, txOrigin.Hex(), cctxList[0].InboundTxParams.TxOrigin) }) @@ -473,7 +473,7 @@ func TestKeeper_ProcessZetaSentEvent(t *testing.T) { k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) - chain := chains.EthChain() + chain := chains.EthChain chainID := chain.ChainId setSupportedChain(ctx, zk, chainID) SetupStateForProcessLogs(t, ctx, k, zk, sdkk, chain) @@ -494,7 +494,7 @@ func TestKeeper_ProcessZetaSentEvent(t *testing.T) { k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) - chain := chains.EthChain() + chain := chains.EthChain SetupStateForProcessLogs(t, ctx, k, zk, sdkk, chain) admin := keepertest.SetAdminPolices(ctx, zk.AuthorityKeeper) SetupStateForProcessLogsZetaSent(t, ctx, k, zk, sdkk, chain, admin) @@ -517,7 +517,7 @@ func TestKeeper_ProcessZetaSentEvent(t *testing.T) { k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) - chain := chains.EthChain() + chain := chains.EthChain chainID := chain.ChainId setSupportedChain(ctx, zk, chainID) SetupStateForProcessLogs(t, ctx, k, zk, sdkk, chain) @@ -543,7 +543,7 @@ func TestKeeper_ProcessZetaSentEvent(t *testing.T) { k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) - chain := chains.EthChain() + chain := chains.EthChain chainID := chain.ChainId setSupportedChain(ctx, zk, chainID) SetupStateForProcessLogs(t, ctx, k, zk, sdkk, chain) @@ -566,7 +566,7 @@ func TestKeeper_ProcessZetaSentEvent(t *testing.T) { k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) - chain := chains.EthChain() + chain := chains.EthChain chainID := chain.ChainId setSupportedChain(ctx, zk, chainID) @@ -599,7 +599,7 @@ func TestKeeper_ProcessLogs(t *testing.T) { k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) - chain := chains.BtcMainnetChain() + chain := chains.BtcMainnetChain chainID := chain.ChainId setSupportedChain(ctx, zk, chainID) SetupStateForProcessLogs(t, ctx, k, zk, sdkk, chain) @@ -625,7 +625,7 @@ func TestKeeper_ProcessLogs(t *testing.T) { k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) - chain := chains.EthChain() + chain := chains.EthChain chainID := chain.ChainId setSupportedChain(ctx, zk, chainID) SetupStateForProcessLogs(t, ctx, k, zk, sdkk, chain) @@ -650,7 +650,7 @@ func TestKeeper_ProcessLogs(t *testing.T) { cctxList := k.GetAllCrossChainTx(ctx) require.Len(t, cctxList, 1) require.Equal(t, strings.Compare("0x60983881bdf302dcfa96603a58274d15d5966209", cctxList[0].GetCurrentOutTxParam().Receiver), 0) - require.Equal(t, chains.EthChain().ChainId, cctxList[0].GetCurrentOutTxParam().ReceiverChainId) + require.Equal(t, chains.EthChain.ChainId, cctxList[0].GetCurrentOutTxParam().ReceiverChainId) require.Equal(t, emittingContract.Hex(), cctxList[0].InboundTxParams.Sender) require.Equal(t, txOrigin.Hex(), cctxList[0].InboundTxParams.TxOrigin) }) @@ -669,7 +669,7 @@ func TestKeeper_ProcessLogs(t *testing.T) { k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) - chain := chains.BtcMainnetChain() + chain := chains.BtcMainnetChain chainID := chain.ChainId setSupportedChain(ctx, zk, chainID) SetupStateForProcessLogs(t, ctx, k, zk, sdkk, chain) @@ -690,7 +690,7 @@ func TestKeeper_ProcessLogs(t *testing.T) { t.Run("no cctx created for logs containing proper event but not emitted from a known ZRC20 contract", func(t *testing.T) { k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) - chain := chains.BtcMainnetChain() + chain := chains.BtcMainnetChain chainID := chain.ChainId setSupportedChain(ctx, zk, chainID) SetupStateForProcessLogs(t, ctx, k, zk, sdkk, chain) @@ -711,7 +711,7 @@ func TestKeeper_ProcessLogs(t *testing.T) { k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) - chain := chains.BtcMainnetChain() + chain := chains.BtcMainnetChain chainID := chain.ChainId setSupportedChain(ctx, zk, chainID) SetupStateForProcessLogs(t, ctx, k, zk, sdkk, chain) @@ -736,7 +736,7 @@ func TestKeeper_ProcessLogs(t *testing.T) { k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) // use the wrong (testnet) chain ID to make the btc address parsing fail - chain := chains.BtcTestNetChain() + chain := chains.BtcTestNetChain chainID := chain.ChainId setSupportedChain(ctx, zk, chainID) SetupStateForProcessLogs(t, ctx, k, zk, sdkk, chain) @@ -757,7 +757,7 @@ func TestKeeper_ProcessLogs(t *testing.T) { k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) - chain := chains.BtcMainnetChain() + chain := chains.BtcMainnetChain chainID := chain.ChainId setSupportedChain(ctx, zk, chainID) SetupStateForProcessLogs(t, ctx, k, zk, sdkk, chain) diff --git a/x/crosschain/keeper/gas_payment_test.go b/x/crosschain/keeper/gas_payment_test.go index 8079c3c67a..e315c1221a 100644 --- a/x/crosschain/keeper/gas_payment_test.go +++ b/x/crosschain/keeper/gas_payment_test.go @@ -52,7 +52,7 @@ func TestKeeper_PayGasNativeAndUpdateCctx(t *testing.T) { }, OutboundTxParams: []*types.OutboundTxParams{ { - ReceiverChainId: chains.ZetaPrivnetChain().ChainId, + ReceiverChainId: chains.ZetaPrivnetChain.ChainId, CoinType: coin.CoinType_Gas, }, { @@ -110,7 +110,7 @@ func TestKeeper_PayGasNativeAndUpdateCctx(t *testing.T) { }, OutboundTxParams: []*types.OutboundTxParams{ { - ReceiverChainId: chains.ZetaPrivnetChain().ChainId, + ReceiverChainId: chains.ZetaPrivnetChain.ChainId, }, { ReceiverChainId: chainID, @@ -149,7 +149,7 @@ func TestKeeper_PayGasNativeAndUpdateCctx(t *testing.T) { }, OutboundTxParams: []*types.OutboundTxParams{ { - ReceiverChainId: chains.ZetaPrivnetChain().ChainId, + ReceiverChainId: chains.ZetaPrivnetChain.ChainId, }, { ReceiverChainId: chainID, @@ -212,7 +212,7 @@ func TestKeeper_PayGasInERC20AndUpdateCctx(t *testing.T) { }, OutboundTxParams: []*types.OutboundTxParams{ { - ReceiverChainId: chains.ZetaPrivnetChain().ChainId, + ReceiverChainId: chains.ZetaPrivnetChain.ChainId, }, { ReceiverChainId: chainID, @@ -274,7 +274,7 @@ func TestKeeper_PayGasInERC20AndUpdateCctx(t *testing.T) { }, OutboundTxParams: []*types.OutboundTxParams{ { - ReceiverChainId: chains.ZetaPrivnetChain().ChainId, + ReceiverChainId: chains.ZetaPrivnetChain.ChainId, }, { ReceiverChainId: chainID, @@ -316,7 +316,7 @@ func TestKeeper_PayGasInERC20AndUpdateCctx(t *testing.T) { }, OutboundTxParams: []*types.OutboundTxParams{ { - ReceiverChainId: chains.ZetaPrivnetChain().ChainId, + ReceiverChainId: chains.ZetaPrivnetChain.ChainId, }, { ReceiverChainId: chainID, @@ -368,7 +368,7 @@ func TestKeeper_PayGasInERC20AndUpdateCctx(t *testing.T) { }, OutboundTxParams: []*types.OutboundTxParams{ { - ReceiverChainId: chains.ZetaPrivnetChain().ChainId, + ReceiverChainId: chains.ZetaPrivnetChain.ChainId, }, { ReceiverChainId: chainID, @@ -426,7 +426,7 @@ func TestKeeper_PayGasInERC20AndUpdateCctx(t *testing.T) { }, OutboundTxParams: []*types.OutboundTxParams{ { - ReceiverChainId: chains.ZetaPrivnetChain().ChainId, + ReceiverChainId: chains.ZetaPrivnetChain.ChainId, }, { ReceiverChainId: chainID, diff --git a/x/crosschain/keeper/msg_server_add_to_intx_tracker_test.go b/x/crosschain/keeper/msg_server_add_to_intx_tracker_test.go index 9c0547e9fb..281692318e 100644 --- a/x/crosschain/keeper/msg_server_add_to_intx_tracker_test.go +++ b/x/crosschain/keeper/msg_server_add_to_intx_tracker_test.go @@ -228,7 +228,7 @@ func TestMsgServer_AddToInTxTracker(t *testing.T) { observerMock.On("GetSupportedChainFromChainID", mock.Anything, mock.Anything).Return(&chains.Chain{}) observerMock.On("IsNonTombstonedObserver", mock.Anything, mock.Anything).Return(false) lightclientMock.On("VerifyProof", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(sample.Bytes(), nil) - observerMock.On("GetChainParamsByChainID", mock.Anything, mock.Anything).Return(sample.ChainParams(chains.EthChain().ChainId), true) + observerMock.On("GetChainParamsByChainID", mock.Anything, mock.Anything).Return(sample.ChainParams(chains.EthChain.ChainId), true) observerMock.On("GetTssAddress", mock.Anything, mock.Anything).Return(nil, errors.New("error")) txHash := "string" @@ -263,7 +263,7 @@ func TestMsgServer_AddToInTxTracker(t *testing.T) { keepertest.MockIsAuthorized(&authorityMock.Mock, mock.Anything, authoritytypes.PolicyType_groupEmergency, false) observerMock.On("GetSupportedChainFromChainID", mock.Anything, mock.Anything).Return(&chains.Chain{}) observerMock.On("IsNonTombstonedObserver", mock.Anything, mock.Anything).Return(false) - observerMock.On("GetChainParamsByChainID", mock.Anything, mock.Anything).Return(sample.ChainParams(chains.EthChain().ChainId), true) + observerMock.On("GetChainParamsByChainID", mock.Anything, mock.Anything).Return(sample.ChainParams(chains.EthChain.ChainId), true) observerMock.On("GetTssAddress", mock.Anything, mock.Anything).Return(&observertypes.QueryGetTssAddressResponse{ Eth: sample.EthAddress().Hex(), }, nil) @@ -297,7 +297,7 @@ func TestMsgServer_AddToInTxTracker(t *testing.T) { admin := sample.AccAddress() - chainID := chains.EthChain().ChainId + chainID := chains.EthChain.ChainId tssAddress := sample.EthAddress() ethTx, ethTxBytes := sample.EthTx(t, chainID, tssAddress, 42) txHash := ethTx.Hash().Hex() @@ -309,7 +309,7 @@ func TestMsgServer_AddToInTxTracker(t *testing.T) { keepertest.MockIsAuthorized(&authorityMock.Mock, mock.Anything, authoritytypes.PolicyType_groupEmergency, false) observerMock.On("GetSupportedChainFromChainID", mock.Anything, mock.Anything).Return(&chains.Chain{}) observerMock.On("IsNonTombstonedObserver", mock.Anything, mock.Anything).Return(false) - observerMock.On("GetChainParamsByChainID", mock.Anything, mock.Anything).Return(sample.ChainParams(chains.EthChain().ChainId), true) + observerMock.On("GetChainParamsByChainID", mock.Anything, mock.Anything).Return(sample.ChainParams(chains.EthChain.ChainId), true) observerMock.On("GetTssAddress", mock.Anything, mock.Anything).Return(&observertypes.QueryGetTssAddressResponse{ Eth: tssAddress.Hex(), }, nil) diff --git a/x/crosschain/keeper/process_inbound_test.go b/x/crosschain/keeper/process_inbound_test.go index 3e86cd68c5..28577e797f 100644 --- a/x/crosschain/keeper/process_inbound_test.go +++ b/x/crosschain/keeper/process_inbound_test.go @@ -37,7 +37,7 @@ func TestKeeper_ProcessInboundZEVMDeposit(t *testing.T) { cctx := sample.CrossChainTx(t, "test") cctx.CctxStatus = &types.Status{Status: types.CctxStatus_PendingInbound} cctx.GetCurrentOutTxParam().Receiver = receiver.String() - cctx.GetCurrentOutTxParam().ReceiverChainId = chains.ZetaPrivnetChain().ChainId + cctx.GetCurrentOutTxParam().ReceiverChainId = chains.ZetaPrivnetChain.ChainId cctx.GetInboundTxParams().Amount = sdkmath.NewUintFromBigInt(amount) cctx.InboundTxParams.CoinType = coin.CoinType_Zeta cctx.GetInboundTxParams().SenderChainId = 0 @@ -63,7 +63,7 @@ func TestKeeper_ProcessInboundZEVMDeposit(t *testing.T) { cctx := sample.CrossChainTx(t, "test") cctx.CctxStatus = &types.Status{Status: types.CctxStatus_PendingInbound} cctx.GetCurrentOutTxParam().Receiver = receiver.String() - cctx.GetCurrentOutTxParam().ReceiverChainId = chains.ZetaPrivnetChain().ChainId + cctx.GetCurrentOutTxParam().ReceiverChainId = chains.ZetaPrivnetChain.ChainId cctx.GetInboundTxParams().Amount = sdkmath.NewUintFromBigInt(amount) cctx.InboundTxParams.CoinType = coin.CoinType_Zeta cctx.GetInboundTxParams().SenderChainId = 0 @@ -96,7 +96,7 @@ func TestKeeper_ProcessInboundZEVMDeposit(t *testing.T) { // call ProcessInbound cctx := GetERC20Cctx(t, receiver, *senderChain, "", amount) - cctx.GetCurrentOutTxParam().ReceiverChainId = chains.ZetaPrivnetChain().ChainId + cctx.GetCurrentOutTxParam().ReceiverChainId = chains.ZetaPrivnetChain.ChainId k.ProcessInbound(ctx, cctx) require.Equal(t, types.CctxStatus_Aborted, cctx.CctxStatus.Status) require.Equal(t, fmt.Sprintf("invalid sender chain id %d", cctx.InboundTxParams.SenderChainId), cctx.CctxStatus.StatusMessage) @@ -129,7 +129,7 @@ func TestKeeper_ProcessInboundZEVMDeposit(t *testing.T) { // call ProcessInbound cctx := GetERC20Cctx(t, receiver, *senderChain, asset, amount) - cctx.GetCurrentOutTxParam().ReceiverChainId = chains.ZetaPrivnetChain().ChainId + cctx.GetCurrentOutTxParam().ReceiverChainId = chains.ZetaPrivnetChain.ChainId k.ProcessInbound(ctx, cctx) require.Equal(t, types.CctxStatus_Aborted, cctx.CctxStatus.Status) require.Equal(t, fmt.Sprintf("revert gas limit error: %s", types.ErrForeignCoinNotFound), cctx.CctxStatus.StatusMessage) @@ -166,7 +166,7 @@ func TestKeeper_ProcessInboundZEVMDeposit(t *testing.T) { // call ProcessInbound cctx := GetERC20Cctx(t, receiver, *senderChain, asset, amount) - cctx.GetCurrentOutTxParam().ReceiverChainId = chains.ZetaPrivnetChain().ChainId + cctx.GetCurrentOutTxParam().ReceiverChainId = chains.ZetaPrivnetChain.ChainId k.ProcessInbound(ctx, cctx) require.Equal(t, types.CctxStatus_Aborted, cctx.CctxStatus.Status) require.Equal(t, fmt.Sprintf("deposit revert message: %s err : %s", errDeposit, observertypes.ErrSupportedChains), cctx.CctxStatus.StatusMessage) @@ -203,7 +203,7 @@ func TestKeeper_ProcessInboundZEVMDeposit(t *testing.T) { // call ProcessInbound cctx := GetERC20Cctx(t, receiver, *senderChain, asset, amount) - cctx.GetCurrentOutTxParam().ReceiverChainId = chains.ZetaPrivnetChain().ChainId + cctx.GetCurrentOutTxParam().ReceiverChainId = chains.ZetaPrivnetChain.ChainId k.ProcessInbound(ctx, cctx) require.Equal(t, types.CctxStatus_Aborted, cctx.CctxStatus.Status) require.Equal(t, fmt.Sprintf("deposit revert message: %s err : %s", errDeposit, observertypes.ErrSupportedChains), cctx.CctxStatus.StatusMessage) @@ -243,7 +243,7 @@ func TestKeeper_ProcessInboundZEVMDeposit(t *testing.T) { // call ProcessInbound cctx := GetERC20Cctx(t, receiver, *senderChain, asset, amount) - cctx.GetCurrentOutTxParam().ReceiverChainId = chains.ZetaPrivnetChain().ChainId + cctx.GetCurrentOutTxParam().ReceiverChainId = chains.ZetaPrivnetChain.ChainId k.ProcessInbound(ctx, cctx) require.Equal(t, types.CctxStatus_Aborted, cctx.CctxStatus.Status) require.Contains(t, cctx.CctxStatus.StatusMessage, "cannot find receiver chain nonce") @@ -281,7 +281,7 @@ func TestKeeper_ProcessInboundZEVMDeposit(t *testing.T) { // call ProcessInbound cctx := GetERC20Cctx(t, receiver, *senderChain, asset, amount) - cctx.GetCurrentOutTxParam().ReceiverChainId = chains.ZetaPrivnetChain().ChainId + cctx.GetCurrentOutTxParam().ReceiverChainId = chains.ZetaPrivnetChain.ChainId k.ProcessInbound(ctx, cctx) require.Equal(t, types.CctxStatus_PendingRevert, cctx.CctxStatus.Status) require.Equal(t, errDeposit.Error(), cctx.CctxStatus.StatusMessage) @@ -315,7 +315,7 @@ func TestKeeper_ProcessInboundZEVMDeposit(t *testing.T) { // call ProcessInbound cctx := GetERC20Cctx(t, receiver, *senderChain, asset, amount) - cctx.GetCurrentOutTxParam().ReceiverChainId = chains.ZetaPrivnetChain().ChainId + cctx.GetCurrentOutTxParam().ReceiverChainId = chains.ZetaPrivnetChain.ChainId cctx.OutboundTxParams = append(cctx.OutboundTxParams, cctx.GetCurrentOutTxParam()) k.ProcessInbound(ctx, cctx) require.Equal(t, types.CctxStatus_Aborted, cctx.CctxStatus.Status) diff --git a/x/crosschain/keeper/process_outbound_test.go b/x/crosschain/keeper/process_outbound_test.go index b4dbbef200..7d1e412db4 100644 --- a/x/crosschain/keeper/process_outbound_test.go +++ b/x/crosschain/keeper/process_outbound_test.go @@ -49,10 +49,10 @@ func TestKeeper_ProcessFailedOutbound(t *testing.T) { t.Run("successfully process failed outbound if original sender is a address", func(t *testing.T) { k, ctx, sdkk, _ := keepertest.CrosschainKeeper(t) receiver := sample.EthAddress() - cctx := GetERC20Cctx(t, receiver, chains.GoerliChain(), "", big.NewInt(42)) + cctx := GetERC20Cctx(t, receiver, chains.GoerliChain, "", big.NewInt(42)) err := sdkk.EvmKeeper.SetAccount(ctx, ethcommon.HexToAddress(cctx.InboundTxParams.Sender), *statedb.NewEmptyAccount()) require.NoError(t, err) - cctx.InboundTxParams.SenderChainId = chains.ZetaChainMainnet().ChainId + cctx.InboundTxParams.SenderChainId = chains.ZetaChainMainnet.ChainId err = k.ProcessFailedOutbound(ctx, cctx, sample.String()) require.NoError(t, err) require.Equal(t, types.CctxStatus_Reverted, cctx.CctxStatus.Status) @@ -61,9 +61,9 @@ func TestKeeper_ProcessFailedOutbound(t *testing.T) { t.Run("unable to process failed outbound if GetCCTXIndexBytes fails", func(t *testing.T) { k, ctx, _, _ := keepertest.CrosschainKeeper(t) receiver := sample.EthAddress() - cctx := GetERC20Cctx(t, receiver, chains.GoerliChain(), "", big.NewInt(42)) + cctx := GetERC20Cctx(t, receiver, chains.GoerliChain, "", big.NewInt(42)) cctx.Index = "" - cctx.InboundTxParams.SenderChainId = chains.ZetaChainMainnet().ChainId + cctx.InboundTxParams.SenderChainId = chains.ZetaChainMainnet.ChainId err := k.ProcessFailedOutbound(ctx, cctx, sample.String()) require.ErrorContains(t, err, "failed reverting GetCCTXIndexBytes") }) @@ -71,7 +71,7 @@ func TestKeeper_ProcessFailedOutbound(t *testing.T) { t.Run("unable to process failed outbound if Adding Revert fails", func(t *testing.T) { k, ctx, _, _ := keepertest.CrosschainKeeper(t) cctx := sample.CrossChainTx(t, "test") - cctx.InboundTxParams.SenderChainId = chains.ZetaChainMainnet().ChainId + cctx.InboundTxParams.SenderChainId = chains.ZetaChainMainnet.ChainId err := k.ProcessFailedOutbound(ctx, cctx, sample.String()) require.ErrorContains(t, err, "failed AddRevertOutbound") }) @@ -79,8 +79,8 @@ func TestKeeper_ProcessFailedOutbound(t *testing.T) { t.Run("unable to process failed outbound if ZETARevertAndCallContract fails", func(t *testing.T) { k, ctx, _, _ := keepertest.CrosschainKeeper(t) receiver := sample.EthAddress() - cctx := GetERC20Cctx(t, receiver, chains.GoerliChain(), "", big.NewInt(42)) - cctx.InboundTxParams.SenderChainId = chains.ZetaChainMainnet().ChainId + cctx := GetERC20Cctx(t, receiver, chains.GoerliChain, "", big.NewInt(42)) + cctx.InboundTxParams.SenderChainId = chains.ZetaChainMainnet.ChainId err := k.ProcessFailedOutbound(ctx, cctx, sample.String()) require.ErrorContains(t, err, "failed ZETARevertAndCallContract") }) @@ -89,7 +89,7 @@ func TestKeeper_ProcessFailedOutbound(t *testing.T) { k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) _ = zk.FungibleKeeper.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) - cctx := GetERC20Cctx(t, sample.EthAddress(), chains.GoerliChain(), "", big.NewInt(42)) + cctx := GetERC20Cctx(t, sample.EthAddress(), chains.GoerliChain, "", big.NewInt(42)) cctx.RelayedMessage = base64.StdEncoding.EncodeToString([]byte("sample message")) deploySystemContracts(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper) @@ -97,7 +97,7 @@ func TestKeeper_ProcessFailedOutbound(t *testing.T) { require.NoError(t, err) assertContractDeployment(t, sdkk.EvmKeeper, ctx, dAppContract) cctx.InboundTxParams.Sender = dAppContract.String() - cctx.InboundTxParams.SenderChainId = chains.ZetaChainMainnet().ChainId + cctx.InboundTxParams.SenderChainId = chains.ZetaChainMainnet.ChainId err = k.ProcessFailedOutbound(ctx, cctx, sample.String()) require.NoError(t, err) @@ -278,7 +278,7 @@ func TestKeeper_ProcessFailedOutbound(t *testing.T) { func TestKeeper_ProcessOutbound(t *testing.T) { t.Run("successfully process outbound with ballot finalized to success", func(t *testing.T) { k, ctx, _, _ := keepertest.CrosschainKeeper(t) - cctx := GetERC20Cctx(t, sample.EthAddress(), chains.GoerliChain(), "", big.NewInt(42)) + cctx := GetERC20Cctx(t, sample.EthAddress(), chains.GoerliChain, "", big.NewInt(42)) cctx.CctxStatus.Status = types.CctxStatus_PendingOutbound err := k.ProcessOutbound(ctx, cctx, observertypes.BallotStatus_BallotFinalized_SuccessObservation, sample.String()) require.NoError(t, err) @@ -287,7 +287,7 @@ func TestKeeper_ProcessOutbound(t *testing.T) { t.Run("successfully process outbound with ballot finalized to failed and old status is Pending Revert", func(t *testing.T) { k, ctx, _, _ := keepertest.CrosschainKeeper(t) - cctx := GetERC20Cctx(t, sample.EthAddress(), chains.GoerliChain(), "", big.NewInt(42)) + cctx := GetERC20Cctx(t, sample.EthAddress(), chains.GoerliChain, "", big.NewInt(42)) cctx.CctxStatus.Status = types.CctxStatus_PendingRevert err := k.ProcessOutbound(ctx, cctx, observertypes.BallotStatus_BallotFinalized_FailureObservation, sample.String()) require.NoError(t, err) @@ -297,7 +297,7 @@ func TestKeeper_ProcessOutbound(t *testing.T) { t.Run("successfully process outbound with ballot finalized to failed and coin-type is CMD", func(t *testing.T) { k, ctx, _, _ := keepertest.CrosschainKeeper(t) - cctx := GetERC20Cctx(t, sample.EthAddress(), chains.GoerliChain(), "", big.NewInt(42)) + cctx := GetERC20Cctx(t, sample.EthAddress(), chains.GoerliChain, "", big.NewInt(42)) cctx.CctxStatus.Status = types.CctxStatus_PendingOutbound cctx.InboundTxParams.CoinType = coin.CoinType_Cmd err := k.ProcessOutbound(ctx, cctx, observertypes.BallotStatus_BallotFinalized_FailureObservation, sample.String()) @@ -308,7 +308,7 @@ func TestKeeper_ProcessOutbound(t *testing.T) { t.Run("do not process if cctx invalid", func(t *testing.T) { k, ctx, _, _ := keepertest.CrosschainKeeper(t) - cctx := GetERC20Cctx(t, sample.EthAddress(), chains.GoerliChain(), "", big.NewInt(42)) + cctx := GetERC20Cctx(t, sample.EthAddress(), chains.GoerliChain, "", big.NewInt(42)) cctx.CctxStatus.Status = types.CctxStatus_PendingOutbound cctx.InboundTxParams = nil err := k.ProcessOutbound(ctx, cctx, observertypes.BallotStatus_BallotInProgress, sample.String()) diff --git a/x/crosschain/keeper/rate_limiter_flags_test.go b/x/crosschain/keeper/rate_limiter_flags_test.go index 0b8010031d..de134ee4f7 100644 --- a/x/crosschain/keeper/rate_limiter_flags_test.go +++ b/x/crosschain/keeper/rate_limiter_flags_test.go @@ -53,7 +53,7 @@ func TestKeeper_GetRateLimiterRates(t *testing.T) { }, } - chainID := chains.GoerliLocalnetChain().ChainId + chainID := chains.GoerliLocalnetChain.ChainId // add gas coin fcGas := sample.ForeignCoins(t, zrc20GasAddr) diff --git a/x/crosschain/keeper/utils_test.go b/x/crosschain/keeper/utils_test.go index 3b3ab6967c..a8d63f17d1 100644 --- a/x/crosschain/keeper/utils_test.go +++ b/x/crosschain/keeper/utils_test.go @@ -26,14 +26,14 @@ func getValidEthChainID() int64 { return getValidEthChain().ChainId } -// getValidEthChain get a valid eth chain +// getValidEthChain() get a valid eth chain func getValidEthChain() *chains.Chain { - goerli := chains.GoerliLocalnetChain() + goerli := chains.GoerliLocalnetChain return &goerli } func getValidBTCChain() *chains.Chain { - btcRegNet := chains.BtcRegtestChain() + btcRegNet := chains.BtcRegtestChain return &btcRegNet } @@ -45,9 +45,9 @@ func getValidBtcChainID() int64 { func getValidEthChainIDWithIndex(t *testing.T, index int) int64 { switch index { case 0: - return chains.GoerliLocalnetChain().ChainId + return chains.GoerliLocalnetChain.ChainId case 1: - return chains.GoerliChain().ChainId + return chains.GoerliChain.ChainId default: require.Fail(t, "invalid index") } diff --git a/x/crosschain/migrations/v4/migrate_test.go b/x/crosschain/migrations/v4/migrate_test.go index 4ba61e399a..8d4cb30833 100644 --- a/x/crosschain/migrations/v4/migrate_test.go +++ b/x/crosschain/migrations/v4/migrate_test.go @@ -97,49 +97,49 @@ func TestSetBitcoinFinalizedInbound(t *testing.T) { k.SetCrossChainTx(ctx, types.CrossChainTx{ Index: "0", InboundTxParams: &types.InboundTxParams{ - SenderChainId: chains.GoerliChain().ChainId, + SenderChainId: chains.GoerliChain.ChainId, InboundTxObservedHash: "0xaaa", }, }) k.SetCrossChainTx(ctx, types.CrossChainTx{ Index: "1", InboundTxParams: &types.InboundTxParams{ - SenderChainId: chains.BtcMainnetChain().ChainId, + SenderChainId: chains.BtcMainnetChain.ChainId, InboundTxObservedHash: "0x111", }, }) k.SetCrossChainTx(ctx, types.CrossChainTx{ Index: "2", InboundTxParams: &types.InboundTxParams{ - SenderChainId: chains.EthChain().ChainId, + SenderChainId: chains.EthChain.ChainId, InboundTxObservedHash: "0xbbb", }, }) k.SetCrossChainTx(ctx, types.CrossChainTx{ Index: "3", InboundTxParams: &types.InboundTxParams{ - SenderChainId: chains.BtcTestNetChain().ChainId, + SenderChainId: chains.BtcTestNetChain.ChainId, InboundTxObservedHash: "0x222", }, }) k.SetCrossChainTx(ctx, types.CrossChainTx{ Index: "4", InboundTxParams: &types.InboundTxParams{ - SenderChainId: chains.BtcTestNetChain().ChainId, + SenderChainId: chains.BtcTestNetChain.ChainId, InboundTxObservedHash: "0x333", }, }) k.SetCrossChainTx(ctx, types.CrossChainTx{ Index: "5", InboundTxParams: &types.InboundTxParams{ - SenderChainId: chains.MumbaiChain().ChainId, + SenderChainId: chains.MumbaiChain.ChainId, InboundTxObservedHash: "0xccc", }, }) k.SetCrossChainTx(ctx, types.CrossChainTx{ Index: "6", InboundTxParams: &types.InboundTxParams{ - SenderChainId: chains.BtcRegtestChain().ChainId, + SenderChainId: chains.BtcRegtestChain.ChainId, InboundTxObservedHash: "0x444", }, }) @@ -148,13 +148,13 @@ func TestSetBitcoinFinalizedInbound(t *testing.T) { v4.SetBitcoinFinalizedInbound(ctx, k) // check finalized inbound - require.False(t, k.IsFinalizedInbound(ctx, "0xaaa", chains.GoerliChain().ChainId, 0)) - require.False(t, k.IsFinalizedInbound(ctx, "0xbbb", chains.EthChain().ChainId, 0)) - require.False(t, k.IsFinalizedInbound(ctx, "0xccc", chains.MumbaiChain().ChainId, 0)) - require.True(t, k.IsFinalizedInbound(ctx, "0x111", chains.BtcMainnetChain().ChainId, 0)) - require.True(t, k.IsFinalizedInbound(ctx, "0x222", chains.BtcTestNetChain().ChainId, 0)) - require.True(t, k.IsFinalizedInbound(ctx, "0x333", chains.BtcTestNetChain().ChainId, 0)) - require.True(t, k.IsFinalizedInbound(ctx, "0x444", chains.BtcRegtestChain().ChainId, 0)) + require.False(t, k.IsFinalizedInbound(ctx, "0xaaa", chains.GoerliChain.ChainId, 0)) + require.False(t, k.IsFinalizedInbound(ctx, "0xbbb", chains.EthChain.ChainId, 0)) + require.False(t, k.IsFinalizedInbound(ctx, "0xccc", chains.MumbaiChain.ChainId, 0)) + require.True(t, k.IsFinalizedInbound(ctx, "0x111", chains.BtcMainnetChain.ChainId, 0)) + require.True(t, k.IsFinalizedInbound(ctx, "0x222", chains.BtcTestNetChain.ChainId, 0)) + require.True(t, k.IsFinalizedInbound(ctx, "0x333", chains.BtcTestNetChain.ChainId, 0)) + require.True(t, k.IsFinalizedInbound(ctx, "0x444", chains.BtcRegtestChain.ChainId, 0)) }) } diff --git a/x/crosschain/migrations/v5/migrate.go b/x/crosschain/migrations/v5/migrate.go index 98fee02256..194ddfe96b 100644 --- a/x/crosschain/migrations/v5/migrate.go +++ b/x/crosschain/migrations/v5/migrate.go @@ -77,10 +77,10 @@ type TestnetNonce struct { func CurrentTestnetChains() []TestnetNonce { return []TestnetNonce{ - {chain: chains.GoerliChain(), nonceHigh: 226841, nonceLow: 226841}, - {chain: chains.MumbaiChain(), nonceHigh: 200599, nonceLow: 200599}, - {chain: chains.BscTestnetChain(), nonceHigh: 110454, nonceLow: 110454}, - {chain: chains.BtcTestNetChain(), nonceHigh: 4881, nonceLow: 4881}, + {chain: chains.GoerliChain, nonceHigh: 226841, nonceLow: 226841}, + {chain: chains.MumbaiChain, nonceHigh: 200599, nonceLow: 200599}, + {chain: chains.BscTestnetChain, nonceHigh: 110454, nonceLow: 110454}, + {chain: chains.BtcTestNetChain, nonceHigh: 4881, nonceLow: 4881}, } } diff --git a/x/crosschain/migrations/v5/migrate_test.go b/x/crosschain/migrations/v5/migrate_test.go index 3bed70bcb1..912fb0c483 100644 --- a/x/crosschain/migrations/v5/migrate_test.go +++ b/x/crosschain/migrations/v5/migrate_test.go @@ -67,8 +67,8 @@ func TestMigrateStore(t *testing.T) { func TestResetTestnetNonce(t *testing.T) { t.Run("reset only testnet nonce without changing mainnet chains", func(t *testing.T) { k, ctx, _, zk := keepertest.CrosschainKeeper(t) - testnetChains := []chains.Chain{chains.GoerliChain(), chains.MumbaiChain(), chains.BscTestnetChain(), chains.BtcTestNetChain()} - mainnetChains := []chains.Chain{chains.EthChain(), chains.BscMainnetChain(), chains.BtcMainnetChain()} + testnetChains := []chains.Chain{chains.GoerliChain, chains.MumbaiChain, chains.BscTestnetChain, chains.BtcTestNetChain} + mainnetChains := []chains.Chain{chains.EthChain, chains.BscMainnetChain, chains.BtcMainnetChain} nonceLow := int64(1) nonceHigh := int64(10) tss := sample.Tss() @@ -102,10 +102,10 @@ func TestResetTestnetNonce(t *testing.T) { err := v5.MigrateStore(ctx, k, zk.ObserverKeeper) require.NoError(t, err) assertValues := map[chains.Chain]int64{ - chains.GoerliChain(): 226841, - chains.MumbaiChain(): 200599, - chains.BscTestnetChain(): 110454, - chains.BtcTestNetChain(): 4881, + chains.GoerliChain: 226841, + chains.MumbaiChain: 200599, + chains.BscTestnetChain: 110454, + chains.BtcTestNetChain: 4881, } for _, chain := range testnetChains { @@ -130,7 +130,7 @@ func TestResetTestnetNonce(t *testing.T) { t.Run("reset nonce even if some chain values are missing", func(t *testing.T) { k, ctx, _, zk := keepertest.CrosschainKeeper(t) - testnetChains := []chains.Chain{chains.GoerliChain()} + testnetChains := []chains.Chain{chains.GoerliChain} nonceLow := int64(1) nonceHigh := int64(10) tss := sample.Tss() @@ -151,9 +151,9 @@ func TestResetTestnetNonce(t *testing.T) { err := v5.MigrateStore(ctx, k, zk.ObserverKeeper) require.NoError(t, err) assertValuesSet := map[chains.Chain]int64{ - chains.GoerliChain(): 226841, + chains.GoerliChain: 226841, } - assertValuesNotSet := []chains.Chain{chains.MumbaiChain(), chains.BscTestnetChain(), chains.BtcTestNetChain()} + assertValuesNotSet := []chains.Chain{chains.MumbaiChain, chains.BscTestnetChain, chains.BtcTestNetChain} for _, chain := range testnetChains { pn, found := zk.ObserverKeeper.GetPendingNonces(ctx, tss.TssPubkey, chain.ChainId) @@ -218,7 +218,7 @@ func CrossChainTxList(count int) []crosschaintypes.CrossChainTx { OutboundTxParams: []*crosschaintypes.OutboundTxParams{{ Amount: math.ZeroUint(), CoinType: coin.CoinType_ERC20, - ReceiverChainId: chains.ZetaPrivnetChain().ChainId, + ReceiverChainId: chains.ZetaPrivnetChain.ChainId, }}, } } @@ -234,7 +234,7 @@ func CrossChainTxList(count int) []crosschaintypes.CrossChainTx { OutboundTxParams: []*crosschaintypes.OutboundTxParams{{ Amount: math.ZeroUint(), CoinType: coin.CoinType_ERC20, - ReceiverChainId: chains.GoerliLocalnetChain().ChainId, + ReceiverChainId: chains.GoerliLocalnetChain.ChainId, }}, } } diff --git a/x/crosschain/types/cctx_test.go b/x/crosschain/types/cctx_test.go index 0b7f267d2d..477552ed36 100644 --- a/x/crosschain/types/cctx_test.go +++ b/x/crosschain/types/cctx_test.go @@ -25,9 +25,9 @@ func TestCrossChainTx_GetCCTXIndexBytes(t *testing.T) { func Test_InitializeCCTX(t *testing.T) { t.Run("should return a cctx with correct values", func(t *testing.T) { _, ctx, _, _ := keepertest.CrosschainKeeper(t) - senderChain := chains.GoerliChain() + senderChain := chains.GoerliChain sender := sample.EthAddress() - receiverChain := chains.GoerliChain() + receiverChain := chains.GoerliChain receiver := sample.EthAddress() creator := sample.AccAddress() amount := sdkmath.NewUint(42) @@ -75,9 +75,9 @@ func Test_InitializeCCTX(t *testing.T) { }) t.Run("should return an error if the cctx is invalid", func(t *testing.T) { _, ctx, _, _ := keepertest.CrosschainKeeper(t) - senderChain := chains.GoerliChain() + senderChain := chains.GoerliChain sender := sample.EthAddress() - receiverChain := chains.GoerliChain() + receiverChain := chains.GoerliChain receiver := sample.EthAddress() creator := sample.AccAddress() amount := sdkmath.NewUint(42) diff --git a/x/crosschain/types/inbound_params_test.go b/x/crosschain/types/inbound_params_test.go index 6b6cdf2293..b3803498d6 100644 --- a/x/crosschain/types/inbound_params_test.go +++ b/x/crosschain/types/inbound_params_test.go @@ -19,11 +19,11 @@ func TestInboundTxParams_Validate(t *testing.T) { inTxParams.SenderChainId = 1000 require.ErrorContains(t, inTxParams.Validate(), "invalid sender chain id 1000") inTxParams = sample.InboundTxParamsValidChainID(r) - inTxParams.SenderChainId = chains.GoerliChain().ChainId + inTxParams.SenderChainId = chains.GoerliChain.ChainId inTxParams.Sender = "0x123" require.ErrorContains(t, inTxParams.Validate(), "invalid address 0x123") inTxParams = sample.InboundTxParamsValidChainID(r) - inTxParams.SenderChainId = chains.GoerliChain().ChainId + inTxParams.SenderChainId = chains.GoerliChain.ChainId inTxParams.TxOrigin = "0x123" require.ErrorContains(t, inTxParams.Validate(), "invalid address 0x123") inTxParams = sample.InboundTxParamsValidChainID(r) diff --git a/x/crosschain/types/message_add_to_in_tx_tracker_test.go b/x/crosschain/types/message_add_to_in_tx_tracker_test.go index b145737eaa..20d9545d42 100644 --- a/x/crosschain/types/message_add_to_in_tx_tracker_test.go +++ b/x/crosschain/types/message_add_to_in_tx_tracker_test.go @@ -24,7 +24,7 @@ func TestMsgAddToInTxTracker_ValidateBasic(t *testing.T) { name: "invalid address", msg: types.NewMsgAddToInTxTracker( "invalid_address", - chains.GoerliChain().ChainId, + chains.GoerliChain.ChainId, coin.CoinType_Gas, "hash", ), @@ -44,17 +44,17 @@ func TestMsgAddToInTxTracker_ValidateBasic(t *testing.T) { name: "invalid proof", msg: &types.MsgAddToInTxTracker{ Creator: sample.AccAddress(), - ChainId: chains.ZetaTestnetChain().ChainId, + ChainId: chains.ZetaTestnetChain.ChainId, CoinType: coin.CoinType_Gas, Proof: &proofs.Proof{}, }, - err: errorsmod.Wrapf(types.ErrProofVerificationFail, "chain id %d does not support proof-based trackers", chains.ZetaTestnetChain().ChainId), + err: errorsmod.Wrapf(types.ErrProofVerificationFail, "chain id %d does not support proof-based trackers", chains.ZetaTestnetChain.ChainId), }, { name: "invalid coin type", msg: &types.MsgAddToInTxTracker{ Creator: sample.AccAddress(), - ChainId: chains.ZetaTestnetChain().ChainId, + ChainId: chains.ZetaTestnetChain.ChainId, CoinType: 5, }, err: errorsmod.Wrapf(types.ErrProofVerificationFail, "coin-type not supported"), @@ -63,7 +63,7 @@ func TestMsgAddToInTxTracker_ValidateBasic(t *testing.T) { name: "valid", msg: types.NewMsgAddToInTxTracker( sample.AccAddress(), - chains.GoerliChain().ChainId, + chains.GoerliChain.ChainId, coin.CoinType_Gas, "hash", ), @@ -93,7 +93,7 @@ func TestMsgAddToInTxTracker_GetSigners(t *testing.T) { name: "valid signer", msg: types.NewMsgAddToInTxTracker( signer, - chains.GoerliChain().ChainId, + chains.GoerliChain.ChainId, coin.CoinType_Gas, "hash", ), @@ -103,7 +103,7 @@ func TestMsgAddToInTxTracker_GetSigners(t *testing.T) { name: "invalid signer", msg: types.NewMsgAddToInTxTracker( "invalid_address", - chains.GoerliChain().ChainId, + chains.GoerliChain.ChainId, coin.CoinType_Gas, "hash", ), @@ -128,7 +128,7 @@ func TestMsgAddToInTxTracker_GetSigners(t *testing.T) { func TestMsgAddToInTxTracker_Type(t *testing.T) { msg := types.NewMsgAddToInTxTracker( sample.AccAddress(), - chains.GoerliChain().ChainId, + chains.GoerliChain.ChainId, coin.CoinType_Gas, "hash", ) @@ -138,7 +138,7 @@ func TestMsgAddToInTxTracker_Type(t *testing.T) { func TestMsgAddToInTxTracker_Route(t *testing.T) { msg := types.NewMsgAddToInTxTracker( sample.AccAddress(), - chains.GoerliChain().ChainId, + chains.GoerliChain.ChainId, coin.CoinType_Gas, "hash", ) @@ -148,7 +148,7 @@ func TestMsgAddToInTxTracker_Route(t *testing.T) { func TestMsgAddToInTxTracker_GetSignBytes(t *testing.T) { msg := types.NewMsgAddToInTxTracker( sample.AccAddress(), - chains.GoerliChain().ChainId, + chains.GoerliChain.ChainId, coin.CoinType_Gas, "hash", ) diff --git a/x/crosschain/types/tx_body_verification_test.go b/x/crosschain/types/tx_body_verification_test.go index 2836b755e9..57cb4c6deb 100644 --- a/x/crosschain/types/tx_body_verification_test.go +++ b/x/crosschain/types/tx_body_verification_test.go @@ -13,7 +13,7 @@ import ( func TestVerifyInTxBody(t *testing.T) { sampleTo := sample.EthAddress() - sampleEthTx, sampleEthTxBytes := sample.EthTx(t, chains.EthChain().ChainId, sampleTo, 42) + sampleEthTx, sampleEthTxBytes := sample.EthTx(t, chains.EthChain.ChainId, sampleTo, 42) // NOTE: errContains == "" means no error for _, tc := range []struct { @@ -27,7 +27,7 @@ func TestVerifyInTxBody(t *testing.T) { { desc: "can't verify btc tx tx body", msg: types.MsgAddToInTxTracker{ - ChainId: chains.BtcMainnetChain().ChainId, + ChainId: chains.BtcMainnetChain.ChainId, }, txBytes: sample.Bytes(), errContains: "cannot verify inTx body for chain", @@ -35,7 +35,7 @@ func TestVerifyInTxBody(t *testing.T) { { desc: "txBytes can't be unmarshaled", msg: types.MsgAddToInTxTracker{ - ChainId: chains.EthChain().ChainId, + ChainId: chains.EthChain.ChainId, }, txBytes: []byte("invalid"), errContains: "failed to unmarshal transaction", @@ -43,7 +43,7 @@ func TestVerifyInTxBody(t *testing.T) { { desc: "txHash doesn't correspond", msg: types.MsgAddToInTxTracker{ - ChainId: chains.EthChain().ChainId, + ChainId: chains.EthChain.ChainId, TxHash: sample.Hash().Hex(), }, txBytes: sampleEthTxBytes, @@ -52,7 +52,7 @@ func TestVerifyInTxBody(t *testing.T) { { desc: "chain id doesn't correspond", msg: types.MsgAddToInTxTracker{ - ChainId: chains.SepoliaChain().ChainId, + ChainId: chains.SepoliaChain.ChainId, TxHash: sampleEthTx.Hash().Hex(), }, txBytes: sampleEthTxBytes, @@ -61,7 +61,7 @@ func TestVerifyInTxBody(t *testing.T) { { desc: "invalid coin type", msg: types.MsgAddToInTxTracker{ - ChainId: chains.EthChain().ChainId, + ChainId: chains.EthChain.ChainId, TxHash: sampleEthTx.Hash().Hex(), CoinType: coin.CoinType(1000), }, @@ -71,7 +71,7 @@ func TestVerifyInTxBody(t *testing.T) { { desc: "coin types is zeta, but connector contract address is wrong", msg: types.MsgAddToInTxTracker{ - ChainId: chains.EthChain().ChainId, + ChainId: chains.EthChain.ChainId, TxHash: sampleEthTx.Hash().Hex(), CoinType: coin.CoinType_Zeta, }, @@ -82,7 +82,7 @@ func TestVerifyInTxBody(t *testing.T) { { desc: "coin types is zeta, connector contract address is correct", msg: types.MsgAddToInTxTracker{ - ChainId: chains.EthChain().ChainId, + ChainId: chains.EthChain.ChainId, TxHash: sampleEthTx.Hash().Hex(), CoinType: coin.CoinType_Zeta, }, @@ -92,7 +92,7 @@ func TestVerifyInTxBody(t *testing.T) { { desc: "coin types is erc20, but erc20 custody contract address is wrong", msg: types.MsgAddToInTxTracker{ - ChainId: chains.EthChain().ChainId, + ChainId: chains.EthChain.ChainId, TxHash: sampleEthTx.Hash().Hex(), CoinType: coin.CoinType_ERC20, }, @@ -103,7 +103,7 @@ func TestVerifyInTxBody(t *testing.T) { { desc: "coin types is erc20, erc20 custody contract address is correct", msg: types.MsgAddToInTxTracker{ - ChainId: chains.EthChain().ChainId, + ChainId: chains.EthChain.ChainId, TxHash: sampleEthTx.Hash().Hex(), CoinType: coin.CoinType_ERC20, }, @@ -113,7 +113,7 @@ func TestVerifyInTxBody(t *testing.T) { { desc: "coin types is gas, but tss address is not found", msg: types.MsgAddToInTxTracker{ - ChainId: chains.EthChain().ChainId, + ChainId: chains.EthChain.ChainId, TxHash: sampleEthTx.Hash().Hex(), CoinType: coin.CoinType_Gas, }, @@ -124,7 +124,7 @@ func TestVerifyInTxBody(t *testing.T) { { desc: "coin types is gas, but tss address is wrong", msg: types.MsgAddToInTxTracker{ - ChainId: chains.EthChain().ChainId, + ChainId: chains.EthChain.ChainId, TxHash: sampleEthTx.Hash().Hex(), CoinType: coin.CoinType_Gas, }, @@ -135,7 +135,7 @@ func TestVerifyInTxBody(t *testing.T) { { desc: "coin types is gas, tss address is correct", msg: types.MsgAddToInTxTracker{ - ChainId: chains.EthChain().ChainId, + ChainId: chains.EthChain.ChainId, TxHash: sampleEthTx.Hash().Hex(), CoinType: coin.CoinType_Gas, }, @@ -157,8 +157,8 @@ func TestVerifyInTxBody(t *testing.T) { func TestVerifyOutTxBody(t *testing.T) { sampleTo := sample.EthAddress() - sampleEthTx, sampleEthTxBytes, sampleFrom := sample.EthTxSigned(t, chains.EthChain().ChainId, sampleTo, 42) - _, sampleEthTxBytesNonSigned := sample.EthTx(t, chains.EthChain().ChainId, sampleTo, 42) + sampleEthTx, sampleEthTxBytes, sampleFrom := sample.EthTxSigned(t, chains.EthChain.ChainId, sampleTo, 42) + _, sampleEthTxBytesNonSigned := sample.EthTx(t, chains.EthChain.ChainId, sampleTo, 42) // NOTE: errContains == "" means no error for _, tc := range []struct { @@ -181,7 +181,7 @@ func TestVerifyOutTxBody(t *testing.T) { { desc: "txBytes can't be unmarshaled", msg: types.MsgAddToOutTxTracker{ - ChainId: chains.EthChain().ChainId, + ChainId: chains.EthChain.ChainId, Nonce: 42, TxHash: sampleEthTx.Hash().Hex(), }, @@ -191,7 +191,7 @@ func TestVerifyOutTxBody(t *testing.T) { { desc: "can't recover sender address", msg: types.MsgAddToOutTxTracker{ - ChainId: chains.EthChain().ChainId, + ChainId: chains.EthChain.ChainId, Nonce: 42, TxHash: sampleEthTx.Hash().Hex(), }, @@ -201,7 +201,7 @@ func TestVerifyOutTxBody(t *testing.T) { { desc: "tss address not found", msg: types.MsgAddToOutTxTracker{ - ChainId: chains.EthChain().ChainId, + ChainId: chains.EthChain.ChainId, Nonce: 42, TxHash: sampleEthTx.Hash().Hex(), }, @@ -212,7 +212,7 @@ func TestVerifyOutTxBody(t *testing.T) { { desc: "tss address is wrong", msg: types.MsgAddToOutTxTracker{ - ChainId: chains.EthChain().ChainId, + ChainId: chains.EthChain.ChainId, Nonce: 42, TxHash: sampleEthTx.Hash().Hex(), }, @@ -223,7 +223,7 @@ func TestVerifyOutTxBody(t *testing.T) { { desc: "chain id doesn't correspond", msg: types.MsgAddToOutTxTracker{ - ChainId: chains.SepoliaChain().ChainId, + ChainId: chains.SepoliaChain.ChainId, Nonce: 42, TxHash: sampleEthTx.Hash().Hex(), }, @@ -234,7 +234,7 @@ func TestVerifyOutTxBody(t *testing.T) { { desc: "nonce doesn't correspond", msg: types.MsgAddToOutTxTracker{ - ChainId: chains.EthChain().ChainId, + ChainId: chains.EthChain.ChainId, Nonce: 100, TxHash: sampleEthTx.Hash().Hex(), }, @@ -245,7 +245,7 @@ func TestVerifyOutTxBody(t *testing.T) { { desc: "tx hash doesn't correspond", msg: types.MsgAddToOutTxTracker{ - ChainId: chains.EthChain().ChainId, + ChainId: chains.EthChain.ChainId, Nonce: 42, TxHash: sample.Hash().Hex(), }, @@ -256,7 +256,7 @@ func TestVerifyOutTxBody(t *testing.T) { { desc: "valid out tx body", msg: types.MsgAddToOutTxTracker{ - ChainId: chains.EthChain().ChainId, + ChainId: chains.EthChain.ChainId, Nonce: 42, TxHash: sampleEthTx.Hash().Hex(), }, diff --git a/x/crosschain/types/validate_test.go b/x/crosschain/types/validate_test.go index c768a7d4ab..3daf789442 100644 --- a/x/crosschain/types/validate_test.go +++ b/x/crosschain/types/validate_test.go @@ -11,23 +11,23 @@ import ( func TestValidateAddressForChain(t *testing.T) { // test for eth chain - require.Error(t, types.ValidateAddressForChain("0x123", chains.GoerliChain().ChainId)) - require.Error(t, types.ValidateAddressForChain("", chains.GoerliChain().ChainId)) - require.Error(t, types.ValidateAddressForChain("%%%%", chains.GoerliChain().ChainId)) - require.NoError(t, types.ValidateAddressForChain("0x792c127Fa3AC1D52F904056Baf1D9257391e7D78", chains.GoerliChain().ChainId)) + require.Error(t, types.ValidateAddressForChain("0x123", chains.GoerliChain.ChainId)) + require.Error(t, types.ValidateAddressForChain("", chains.GoerliChain.ChainId)) + require.Error(t, types.ValidateAddressForChain("%%%%", chains.GoerliChain.ChainId)) + require.NoError(t, types.ValidateAddressForChain("0x792c127Fa3AC1D52F904056Baf1D9257391e7D78", chains.GoerliChain.ChainId)) // test for btc chain - require.NoError(t, types.ValidateAddressForChain("bc1p4scddlkkuw9486579autxumxmkvuphm5pz4jvf7f6pdh50p2uzqstawjt9", chains.BtcMainnetChain().ChainId)) - require.NoError(t, types.ValidateAddressForChain("327z4GyFM8Y8DiYfasGKQWhRK4MvyMSEgE", chains.BtcMainnetChain().ChainId)) - require.NoError(t, types.ValidateAddressForChain("1EYVvXLusCxtVuEwoYvWRyN5EZTXwPVvo3", chains.BtcMainnetChain().ChainId)) - require.Error(t, types.ValidateAddressForChain("bcrt1qs758ursh4q9z627kt3pp5yysm78ddny6txaqgw", chains.BtcMainnetChain().ChainId)) - require.Error(t, types.ValidateAddressForChain("", chains.BtcRegtestChain().ChainId)) - require.NoError(t, types.ValidateAddressForChain("bc1qysd4sp9q8my59ul9wsf5rvs9p387hf8vfwatzu", chains.BtcMainnetChain().ChainId)) - require.NoError(t, types.ValidateAddressForChain("bcrt1qs758ursh4q9z627kt3pp5yysm78ddny6txaqgw", chains.BtcRegtestChain().ChainId)) + require.NoError(t, types.ValidateAddressForChain("bc1p4scddlkkuw9486579autxumxmkvuphm5pz4jvf7f6pdh50p2uzqstawjt9", chains.BtcMainnetChain.ChainId)) + require.NoError(t, types.ValidateAddressForChain("327z4GyFM8Y8DiYfasGKQWhRK4MvyMSEgE", chains.BtcMainnetChain.ChainId)) + require.NoError(t, types.ValidateAddressForChain("1EYVvXLusCxtVuEwoYvWRyN5EZTXwPVvo3", chains.BtcMainnetChain.ChainId)) + require.Error(t, types.ValidateAddressForChain("bcrt1qs758ursh4q9z627kt3pp5yysm78ddny6txaqgw", chains.BtcMainnetChain.ChainId)) + require.Error(t, types.ValidateAddressForChain("", chains.BtcRegtestChain.ChainId)) + require.NoError(t, types.ValidateAddressForChain("bc1qysd4sp9q8my59ul9wsf5rvs9p387hf8vfwatzu", chains.BtcMainnetChain.ChainId)) + require.NoError(t, types.ValidateAddressForChain("bcrt1qs758ursh4q9z627kt3pp5yysm78ddny6txaqgw", chains.BtcRegtestChain.ChainId)) // test for zeta chain - require.NoError(t, types.ValidateAddressForChain("bcrt1qs758ursh4q9z627kt3pp5yysm78ddny6txaqgw", chains.ZetaChainMainnet().ChainId)) - require.NoError(t, types.ValidateAddressForChain("0x792c127Fa3AC1D52F904056Baf1D9257391e7D78", chains.ZetaChainMainnet().ChainId)) + require.NoError(t, types.ValidateAddressForChain("bcrt1qs758ursh4q9z627kt3pp5yysm78ddny6txaqgw", chains.ZetaChainMainnet.ChainId)) + require.NoError(t, types.ValidateAddressForChain("0x792c127Fa3AC1D52F904056Baf1D9257391e7D78", chains.ZetaChainMainnet.ChainId)) } func TestValidateZetaIndex(t *testing.T) { @@ -38,10 +38,10 @@ func TestValidateZetaIndex(t *testing.T) { } func TestValidateHashForChain(t *testing.T) { - require.NoError(t, types.ValidateHashForChain("0x84bd5c9922b63c52d8a9ca686e0a57ff978150b71be0583514d01c27aa341910", chains.GoerliChain().ChainId)) - require.Error(t, types.ValidateHashForChain("", chains.GoerliChain().ChainId)) - require.Error(t, types.ValidateHashForChain("a0fa5a82f106fb192e4c503bfa8d54b2de20a821e09338094ab825cc9b275059", chains.GoerliChain().ChainId)) - require.NoError(t, types.ValidateHashForChain("15b7880f5d236e857a5e8f043ce9d56f5ef01e1c3f2a786baf740fc0bb7a22a3", chains.BtcMainnetChain().ChainId)) - require.NoError(t, types.ValidateHashForChain("a0fa5a82f106fb192e4c503bfa8d54b2de20a821e09338094ab825cc9b275059", chains.BtcTestNetChain().ChainId)) - require.Error(t, types.ValidateHashForChain("0x84bd5c9922b63c52d8a9ca686e0a57ff978150b71be0583514d01c27aa341910", chains.BtcMainnetChain().ChainId)) + require.NoError(t, types.ValidateHashForChain("0x84bd5c9922b63c52d8a9ca686e0a57ff978150b71be0583514d01c27aa341910", chains.GoerliChain.ChainId)) + require.Error(t, types.ValidateHashForChain("", chains.GoerliChain.ChainId)) + require.Error(t, types.ValidateHashForChain("a0fa5a82f106fb192e4c503bfa8d54b2de20a821e09338094ab825cc9b275059", chains.GoerliChain.ChainId)) + require.NoError(t, types.ValidateHashForChain("15b7880f5d236e857a5e8f043ce9d56f5ef01e1c3f2a786baf740fc0bb7a22a3", chains.BtcMainnetChain.ChainId)) + require.NoError(t, types.ValidateHashForChain("a0fa5a82f106fb192e4c503bfa8d54b2de20a821e09338094ab825cc9b275059", chains.BtcTestNetChain.ChainId)) + require.Error(t, types.ValidateHashForChain("0x84bd5c9922b63c52d8a9ca686e0a57ff978150b71be0583514d01c27aa341910", chains.BtcMainnetChain.ChainId)) } diff --git a/x/lightclient/genesis_test.go b/x/lightclient/genesis_test.go index 049cfbe848..ee083e6e4b 100644 --- a/x/lightclient/genesis_test.go +++ b/x/lightclient/genesis_test.go @@ -26,9 +26,9 @@ func TestGenesis(t *testing.T) { sample.BlockHeader(sample.Hash().Bytes()), }, ChainStates: []types.ChainState{ - sample.ChainState(chains.EthChain().ChainId), - sample.ChainState(chains.BtcMainnetChain().ChainId), - sample.ChainState(chains.BscMainnetChain().ChainId), + sample.ChainState(chains.EthChain.ChainId), + sample.ChainState(chains.BtcMainnetChain.ChainId), + sample.ChainState(chains.BscMainnetChain.ChainId), }, } diff --git a/x/lightclient/keeper/block_header_test.go b/x/lightclient/keeper/block_header_test.go index 2ecf50c1d9..21e7e83f9e 100644 --- a/x/lightclient/keeper/block_header_test.go +++ b/x/lightclient/keeper/block_header_test.go @@ -68,21 +68,21 @@ func sepoliaBlockHeaders(t *testing.T) (proofs.BlockHeader, proofs.BlockHeader, Height: 5000000, Hash: header1.Hash().Bytes(), ParentHash: header1.ParentHash.Bytes(), - ChainId: chains.SepoliaChain().ChainId, + ChainId: chains.SepoliaChain.ChainId, Header: proofs.NewEthereumHeader(headerRLP1), }, proofs.BlockHeader{ Height: 5000001, Hash: header2.Hash().Bytes(), ParentHash: header2.ParentHash.Bytes(), - ChainId: chains.SepoliaChain().ChainId, + ChainId: chains.SepoliaChain.ChainId, Header: proofs.NewEthereumHeader(headerRLP2), }, proofs.BlockHeader{ Height: 5000002, Hash: header3.Hash().Bytes(), ParentHash: header3.ParentHash.Bytes(), - ChainId: chains.SepoliaChain().ChainId, + ChainId: chains.SepoliaChain.ChainId, Header: proofs.NewEthereumHeader(headerRLP3), } } diff --git a/x/lightclient/keeper/proof_test.go b/x/lightclient/keeper/proof_test.go index 810c9a0371..55de17e6b9 100644 --- a/x/lightclient/keeper/proof_test.go +++ b/x/lightclient/keeper/proof_test.go @@ -15,7 +15,7 @@ func TestKeeper_VerifyProof(t *testing.T) { t.Run("should error if verification flags not found", func(t *testing.T) { k, ctx, _, _ := keepertest.LightclientKeeper(t) - _, err := k.VerifyProof(ctx, &proofs.Proof{}, chains.SepoliaChain().ChainId, sample.Hash().String(), 1) + _, err := k.VerifyProof(ctx, &proofs.Proof{}, chains.SepoliaChain.ChainId, sample.Hash().String(), 1) require.ErrorIs(t, err, types.ErrVerificationFlagsNotFound) }) @@ -27,7 +27,7 @@ func TestKeeper_VerifyProof(t *testing.T) { BtcTypeChainEnabled: false, }) - _, err := k.VerifyProof(ctx, &proofs.Proof{}, chains.BtcMainnetChain().ChainId, sample.Hash().String(), 1) + _, err := k.VerifyProof(ctx, &proofs.Proof{}, chains.BtcMainnetChain.ChainId, sample.Hash().String(), 1) require.ErrorIs(t, err, types.ErrBlockHeaderVerificationDisabled) }) @@ -39,7 +39,7 @@ func TestKeeper_VerifyProof(t *testing.T) { BtcTypeChainEnabled: true, }) - _, err := k.VerifyProof(ctx, &proofs.Proof{}, chains.SepoliaChain().ChainId, sample.Hash().String(), 1) + _, err := k.VerifyProof(ctx, &proofs.Proof{}, chains.SepoliaChain.ChainId, sample.Hash().String(), 1) require.ErrorIs(t, err, types.ErrBlockHeaderVerificationDisabled) }) @@ -63,7 +63,7 @@ func TestKeeper_VerifyProof(t *testing.T) { BtcTypeChainEnabled: true, }) - _, err := k.VerifyProof(ctx, &proofs.Proof{}, chains.BtcMainnetChain().ChainId, "invalid", 1) + _, err := k.VerifyProof(ctx, &proofs.Proof{}, chains.BtcMainnetChain.ChainId, "invalid", 1) require.ErrorIs(t, err, types.ErrInvalidBlockHash) }) @@ -75,7 +75,7 @@ func TestKeeper_VerifyProof(t *testing.T) { BtcTypeChainEnabled: true, }) - _, err := k.VerifyProof(ctx, &proofs.Proof{}, chains.SepoliaChain().ChainId, sample.Hash().String(), 1) + _, err := k.VerifyProof(ctx, &proofs.Proof{}, chains.SepoliaChain.ChainId, sample.Hash().String(), 1) require.ErrorIs(t, err, types.ErrBlockHeaderNotFound) }) diff --git a/x/lightclient/keeper/verification_flags_test.go b/x/lightclient/keeper/verification_flags_test.go index f90f78966a..2466005dcb 100644 --- a/x/lightclient/keeper/verification_flags_test.go +++ b/x/lightclient/keeper/verification_flags_test.go @@ -37,10 +37,10 @@ func TestKeeper_CheckVerificationFlagsEnabled(t *testing.T) { BtcTypeChainEnabled: false, }) - err := k.CheckVerificationFlagsEnabled(ctx, chains.EthChain().ChainId) + err := k.CheckVerificationFlagsEnabled(ctx, chains.EthChain.ChainId) require.NoError(t, err) - err = k.CheckVerificationFlagsEnabled(ctx, chains.BtcMainnetChain().ChainId) + err = k.CheckVerificationFlagsEnabled(ctx, chains.BtcMainnetChain.ChainId) require.Error(t, err) require.ErrorContains(t, err, "proof verification not enabled for bitcoin") @@ -56,11 +56,11 @@ func TestKeeper_CheckVerificationFlagsEnabled(t *testing.T) { BtcTypeChainEnabled: true, }) - err := k.CheckVerificationFlagsEnabled(ctx, chains.EthChain().ChainId) + err := k.CheckVerificationFlagsEnabled(ctx, chains.EthChain.ChainId) require.Error(t, err) require.ErrorContains(t, err, "proof verification not enabled for evm") - err = k.CheckVerificationFlagsEnabled(ctx, chains.BtcMainnetChain().ChainId) + err = k.CheckVerificationFlagsEnabled(ctx, chains.BtcMainnetChain.ChainId) require.NoError(t, err) err = k.CheckVerificationFlagsEnabled(ctx, 1000) diff --git a/x/lightclient/types/genesis_test.go b/x/lightclient/types/genesis_test.go index 1bec10f3be..ee875393ea 100644 --- a/x/lightclient/types/genesis_test.go +++ b/x/lightclient/types/genesis_test.go @@ -32,9 +32,9 @@ func TestGenesisState_Validate(t *testing.T) { sample.BlockHeader(sample.Hash().Bytes()), }, ChainStates: []types.ChainState{ - sample.ChainState(chains.EthChain().ChainId), - sample.ChainState(chains.BtcMainnetChain().ChainId), - sample.ChainState(chains.BscMainnetChain().ChainId), + sample.ChainState(chains.EthChain.ChainId), + sample.ChainState(chains.BtcMainnetChain.ChainId), + sample.ChainState(chains.BscMainnetChain.ChainId), }, }, valid: true, @@ -59,9 +59,9 @@ func TestGenesisState_Validate(t *testing.T) { desc: "duplicate chain state is invalid", genState: &types.GenesisState{ ChainStates: []types.ChainState{ - sample.ChainState(chains.EthChain().ChainId), - sample.ChainState(chains.EthChain().ChainId), - sample.ChainState(chains.BscMainnetChain().ChainId), + sample.ChainState(chains.EthChain.ChainId), + sample.ChainState(chains.EthChain.ChainId), + sample.ChainState(chains.BscMainnetChain.ChainId), }, }, valid: false, diff --git a/x/observer/keeper/grpc_query_chain_params_test.go b/x/observer/keeper/grpc_query_chain_params_test.go index 0e7145e5cd..c8e6f87a8c 100644 --- a/x/observer/keeper/grpc_query_chain_params_test.go +++ b/x/observer/keeper/grpc_query_chain_params_test.go @@ -38,7 +38,7 @@ func TestKeeper_GetChainParamsForChain(t *testing.T) { list := types.ChainParamsList{ ChainParams: []*types.ChainParams{ { - ChainId: chains.ZetaPrivnetChain().ChainId, + ChainId: chains.ZetaPrivnetChain.ChainId, IsSupported: false, }, }, @@ -46,7 +46,7 @@ func TestKeeper_GetChainParamsForChain(t *testing.T) { k.SetChainParamsList(ctx, list) res, err := k.GetChainParamsForChain(wctx, &types.QueryGetChainParamsForChainRequest{ - ChainId: chains.ZetaPrivnetChain().ChainId, + ChainId: chains.ZetaPrivnetChain.ChainId, }) require.NoError(t, err) require.Equal(t, &types.QueryGetChainParamsForChainResponse{ @@ -81,7 +81,7 @@ func TestKeeper_GetChainParams(t *testing.T) { list := types.ChainParamsList{ ChainParams: []*types.ChainParams{ { - ChainId: chains.ZetaPrivnetChain().ChainId, + ChainId: chains.ZetaPrivnetChain.ChainId, IsSupported: false, }, }, diff --git a/x/observer/keeper/grpc_query_tss_test.go b/x/observer/keeper/grpc_query_tss_test.go index 105d7c1cf9..601945c22f 100644 --- a/x/observer/keeper/grpc_query_tss_test.go +++ b/x/observer/keeper/grpc_query_tss_test.go @@ -146,10 +146,10 @@ func TestKeeper_GetTssAddress(t *testing.T) { k.SetTSS(ctx, tss) res, err := k.GetTssAddress(wctx, &types.QueryGetTssAddressRequest{ - BitcoinChainId: chains.BtcRegtestChain().ChainId, + BitcoinChainId: chains.BtcRegtestChain.ChainId, }) require.NoError(t, err) - expectedBitcoinParams, err := chains.BitcoinNetParamsFromChainID(chains.BtcRegtestChain().ChainId) + expectedBitcoinParams, err := chains.BitcoinNetParamsFromChainID(chains.BtcRegtestChain.ChainId) require.NoError(t, err) expectedBtcAddress, err := crypto.GetTssAddrBTC(tss.TssPubkey, expectedBitcoinParams) require.NoError(t, err) @@ -212,11 +212,11 @@ func TestKeeper_GetTssAddressByFinalizedHeight(t *testing.T) { } res, err := k.GetTssAddressByFinalizedHeight(wctx, &types.QueryGetTssAddressByFinalizedHeightRequest{ - BitcoinChainId: chains.BtcRegtestChain().ChainId, + BitcoinChainId: chains.BtcRegtestChain.ChainId, FinalizedZetaHeight: tssList[r].FinalizedZetaHeight, }) require.NoError(t, err) - expectedBitcoinParams, err := chains.BitcoinNetParamsFromChainID(chains.BtcRegtestChain().ChainId) + expectedBitcoinParams, err := chains.BitcoinNetParamsFromChainID(chains.BtcRegtestChain.ChainId) require.NoError(t, err) expectedBtcAddress, err := crypto.GetTssAddrBTC(tssList[r].TssPubkey, expectedBitcoinParams) require.NoError(t, err) diff --git a/x/observer/keeper/msg_server_reset_chain_nonces_test.go b/x/observer/keeper/msg_server_reset_chain_nonces_test.go index e4226968f8..ca64406828 100644 --- a/x/observer/keeper/msg_server_reset_chain_nonces_test.go +++ b/x/observer/keeper/msg_server_reset_chain_nonces_test.go @@ -19,7 +19,7 @@ func TestMsgServer_ResetChainNonces(t *testing.T) { UseAuthorityMock: true, }) srv := keeper.NewMsgServerImpl(*k) - chainId := chains.GoerliLocalnetChain().ChainId + chainId := chains.GoerliLocalnetChain.ChainId admin := sample.AccAddress() authorityMock := keepertest.GetObserverAuthorityMock(t, k) @@ -44,7 +44,7 @@ func TestMsgServer_ResetChainNonces(t *testing.T) { authorityMock := keepertest.GetObserverAuthorityMock(t, k) keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupOperational, true) - chainId := chains.GoerliLocalnetChain().ChainId + chainId := chains.GoerliLocalnetChain.ChainId _, err := srv.ResetChainNonces(sdk.WrapSDKContext(ctx), &types.MsgResetChainNonces{ Creator: admin, ChainId: chainId, @@ -88,8 +88,8 @@ func TestMsgServer_ResetChainNonces(t *testing.T) { keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupOperational, true) keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupOperational, true) - chainId := chains.GoerliLocalnetChain().ChainId - index := chains.GoerliLocalnetChain().ChainName.String() + chainId := chains.GoerliLocalnetChain.ChainId + index := chains.GoerliLocalnetChain.ChainName.String() // check existing chain nonces _, found := k.GetChainNonces(ctx, index) diff --git a/x/observer/keeper/msg_server_vote_block_header_test.go b/x/observer/keeper/msg_server_vote_block_header_test.go index 161d26ff5a..f58ed14299 100644 --- a/x/observer/keeper/msg_server_vote_block_header_test.go +++ b/x/observer/keeper/msg_server_vote_block_header_test.go @@ -66,7 +66,7 @@ func TestMsgServer_VoteBlockHeader(t *testing.T) { k.SetChainParamsList(ctx, types.ChainParamsList{ ChainParams: []*types.ChainParams{ { - ChainId: chains.GoerliLocalnetChain().ChainId, + ChainId: chains.GoerliLocalnetChain.ChainId, IsSupported: true, BallotThreshold: one, }, @@ -75,7 +75,7 @@ func TestMsgServer_VoteBlockHeader(t *testing.T) { _, err := srv.VoteBlockHeader(ctx, &types.MsgVoteBlockHeader{ Creator: sample.AccAddress(), - ChainId: chains.GoerliLocalnetChain().ChainId, + ChainId: chains.GoerliLocalnetChain.ChainId, BlockHash: sample.Hash().Bytes(), Height: 42, Header: proofs.HeaderData{}, @@ -96,7 +96,7 @@ func TestMsgServer_VoteBlockHeader(t *testing.T) { k.SetChainParamsList(ctx, types.ChainParamsList{ ChainParams: []*types.ChainParams{ { - ChainId: chains.GoerliLocalnetChain().ChainId, + ChainId: chains.GoerliLocalnetChain.ChainId, IsSupported: true, BallotThreshold: one, }, @@ -113,7 +113,7 @@ func TestMsgServer_VoteBlockHeader(t *testing.T) { _, err := srv.VoteBlockHeader(ctx, &types.MsgVoteBlockHeader{ Creator: observer, - ChainId: chains.GoerliLocalnetChain().ChainId, + ChainId: chains.GoerliLocalnetChain.ChainId, BlockHash: sample.Hash().Bytes(), Height: 42, Header: proofs.HeaderData{}, @@ -134,7 +134,7 @@ func TestMsgServer_VoteBlockHeader(t *testing.T) { k.SetChainParamsList(ctx, types.ChainParamsList{ ChainParams: []*types.ChainParams{ { - ChainId: chains.GoerliLocalnetChain().ChainId, + ChainId: chains.GoerliLocalnetChain.ChainId, IsSupported: true, BallotThreshold: one, }, @@ -153,7 +153,7 @@ func TestMsgServer_VoteBlockHeader(t *testing.T) { // there is a single node account, so the ballot will be created and finalized in a single vote res, err := srv.VoteBlockHeader(ctx, &types.MsgVoteBlockHeader{ Creator: observer, - ChainId: chains.GoerliLocalnetChain().ChainId, + ChainId: chains.GoerliLocalnetChain.ChainId, BlockHash: sample.Hash().Bytes(), Height: 42, Header: proofs.HeaderData{}, @@ -179,7 +179,7 @@ func TestMsgServer_VoteBlockHeader(t *testing.T) { k.SetChainParamsList(ctx, types.ChainParamsList{ ChainParams: []*types.ChainParams{ { - ChainId: chains.GoerliLocalnetChain().ChainId, + ChainId: chains.GoerliLocalnetChain.ChainId, IsSupported: true, BallotThreshold: one, }, @@ -196,7 +196,7 @@ func TestMsgServer_VoteBlockHeader(t *testing.T) { mockCheckNewBlockHeader(lightclientMock, nil) res, err := srv.VoteBlockHeader(ctx, &types.MsgVoteBlockHeader{ Creator: observer1, - ChainId: chains.GoerliLocalnetChain().ChainId, + ChainId: chains.GoerliLocalnetChain.ChainId, BlockHash: blockHash, Height: 42, Header: proofs.HeaderData{}, @@ -212,7 +212,7 @@ func TestMsgServer_VoteBlockHeader(t *testing.T) { mockCheckNewBlockHeader(lightclientMock, nil) res, err = srv.VoteBlockHeader(ctx, &types.MsgVoteBlockHeader{ Creator: observer2, - ChainId: chains.GoerliLocalnetChain().ChainId, + ChainId: chains.GoerliLocalnetChain.ChainId, BlockHash: blockHash, Height: 42, Header: proofs.HeaderData{}, @@ -229,7 +229,7 @@ func TestMsgServer_VoteBlockHeader(t *testing.T) { mockAddBlockHeader(lightclientMock) res, err = srv.VoteBlockHeader(ctx, &types.MsgVoteBlockHeader{ Creator: observer3, - ChainId: chains.GoerliLocalnetChain().ChainId, + ChainId: chains.GoerliLocalnetChain.ChainId, BlockHash: blockHash, Height: 42, Header: proofs.HeaderData{}, @@ -253,7 +253,7 @@ func TestMsgServer_VoteBlockHeader(t *testing.T) { k.SetChainParamsList(ctx, types.ChainParamsList{ ChainParams: []*types.ChainParams{ { - ChainId: chains.GoerliLocalnetChain().ChainId, + ChainId: chains.GoerliLocalnetChain.ChainId, IsSupported: true, BallotThreshold: one, }, @@ -271,7 +271,7 @@ func TestMsgServer_VoteBlockHeader(t *testing.T) { mockCheckNewBlockHeader(lightclientMock, nil) _, err := srv.VoteBlockHeader(ctx, &types.MsgVoteBlockHeader{ Creator: observer, - ChainId: chains.GoerliLocalnetChain().ChainId, + ChainId: chains.GoerliLocalnetChain.ChainId, BlockHash: blockHash, Height: 42, Header: proofs.HeaderData{}, @@ -284,7 +284,7 @@ func TestMsgServer_VoteBlockHeader(t *testing.T) { mockCheckNewBlockHeader(lightclientMock, nil) _, err = srv.VoteBlockHeader(ctx, &types.MsgVoteBlockHeader{ Creator: observer, - ChainId: chains.GoerliLocalnetChain().ChainId, + ChainId: chains.GoerliLocalnetChain.ChainId, BlockHash: blockHash, Height: 42, Header: proofs.HeaderData{}, diff --git a/x/observer/keeper/utils_test.go b/x/observer/keeper/utils_test.go index 4551e1ca24..3a04c739a3 100644 --- a/x/observer/keeper/utils_test.go +++ b/x/observer/keeper/utils_test.go @@ -33,9 +33,9 @@ func setSupportedChain(ctx sdk.Context, observerKeeper keeper.Keeper, chainIDs . func getValidEthChainIDWithIndex(t *testing.T, index int) int64 { switch index { case 0: - return chains.GoerliLocalnetChain().ChainId + return chains.GoerliLocalnetChain.ChainId case 1: - return chains.GoerliChain().ChainId + return chains.GoerliChain.ChainId default: require.Fail(t, "invalid index") } diff --git a/x/observer/keeper/vote_inbound_test.go b/x/observer/keeper/vote_inbound_test.go index 5b1c09e81b..b271bbfebe 100644 --- a/x/observer/keeper/vote_inbound_test.go +++ b/x/observer/keeper/vote_inbound_test.go @@ -24,7 +24,7 @@ func TestKeeper_VoteOnInboundBallot(t *testing.T) { _, _, err := k.VoteOnInboundBallot( ctx, getValidEthChainIDWithIndex(t, 0), - chains.ZetaPrivnetChain().ChainId, + chains.ZetaPrivnetChain.ChainId, coin.CoinType_ERC20, sample.AccAddress(), "index", @@ -46,7 +46,7 @@ func TestKeeper_VoteOnInboundBallot(t *testing.T) { _, _, err := k.VoteOnInboundBallot( ctx, getValidEthChainIDWithIndex(t, 0), - chains.ZetaPrivnetChain().ChainId, + chains.ZetaPrivnetChain.ChainId, coin.CoinType_ERC20, sample.AccAddress(), "index", @@ -68,7 +68,7 @@ func TestKeeper_VoteOnInboundBallot(t *testing.T) { _, _, err = k.VoteOnInboundBallot( ctx, getValidEthChainIDWithIndex(t, 0), - chains.ZetaPrivnetChain().ChainId, + chains.ZetaPrivnetChain.ChainId, coin.CoinType_ERC20, sample.AccAddress(), "index", @@ -97,7 +97,7 @@ func TestKeeper_VoteOnInboundBallot(t *testing.T) { _, _, err := k.VoteOnInboundBallot( ctx, getValidEthChainIDWithIndex(t, 0), - chains.ZetaPrivnetChain().ChainId, + chains.ZetaPrivnetChain.ChainId, coin.CoinType_ERC20, sample.AccAddress(), "index", @@ -134,7 +134,7 @@ func TestKeeper_VoteOnInboundBallot(t *testing.T) { _, _, err := k.VoteOnInboundBallot( ctx, getValidEthChainIDWithIndex(t, 0), - chains.ZetaPrivnetChain().ChainId, + chains.ZetaPrivnetChain.ChainId, coin.CoinType_ERC20, observer, "index", @@ -151,7 +151,7 @@ func TestKeeper_VoteOnInboundBallot(t *testing.T) { IsSupported: true, }, { - ChainId: chains.ZetaPrivnetChain().ChainId, + ChainId: chains.ZetaPrivnetChain.ChainId, IsSupported: false, }, }, @@ -162,7 +162,7 @@ func TestKeeper_VoteOnInboundBallot(t *testing.T) { _, _, err = k.VoteOnInboundBallot( ctx, getValidEthChainIDWithIndex(t, 0), - chains.ZetaPrivnetChain().ChainId, + chains.ZetaPrivnetChain.ChainId, coin.CoinType_ERC20, observer, "index", diff --git a/x/observer/types/chain_params.go b/x/observer/types/chain_params.go index e32ee9e597..6c44d6b706 100644 --- a/x/observer/types/chain_params.go +++ b/x/observer/types/chain_params.go @@ -140,7 +140,7 @@ func GetDefaultChainParams() ChainParamsList { func GetDefaultEthMainnetChainParams() *ChainParams { return &ChainParams{ - ChainId: chains.EthChain().ChainId, + ChainId: chains.EthChain.ChainId, ConfirmationCount: 14, ZetaTokenContractAddress: zeroAddress, ConnectorContractAddress: zeroAddress, @@ -158,7 +158,7 @@ func GetDefaultEthMainnetChainParams() *ChainParams { } func GetDefaultBscMainnetChainParams() *ChainParams { return &ChainParams{ - ChainId: chains.BscMainnetChain().ChainId, + ChainId: chains.BscMainnetChain.ChainId, ConfirmationCount: 14, ZetaTokenContractAddress: zeroAddress, ConnectorContractAddress: zeroAddress, @@ -176,7 +176,7 @@ func GetDefaultBscMainnetChainParams() *ChainParams { } func GetDefaultBtcMainnetChainParams() *ChainParams { return &ChainParams{ - ChainId: chains.BtcMainnetChain().ChainId, + ChainId: chains.BtcMainnetChain.ChainId, ConfirmationCount: 2, ZetaTokenContractAddress: zeroAddress, ConnectorContractAddress: zeroAddress, @@ -194,7 +194,7 @@ func GetDefaultBtcMainnetChainParams() *ChainParams { } func GetDefaultGoerliTestnetChainParams() *ChainParams { return &ChainParams{ - ChainId: chains.GoerliChain().ChainId, + ChainId: chains.GoerliChain.ChainId, ConfirmationCount: 6, // This is the actual Zeta token Goerli testnet, we need to specify this address for the integration tests to pass ZetaTokenContractAddress: "0x0000c304d2934c00db1d51995b9f6996affd17c0", @@ -213,7 +213,7 @@ func GetDefaultGoerliTestnetChainParams() *ChainParams { } func GetDefaultBscTestnetChainParams() *ChainParams { return &ChainParams{ - ChainId: chains.BscTestnetChain().ChainId, + ChainId: chains.BscTestnetChain.ChainId, ConfirmationCount: 6, ZetaTokenContractAddress: zeroAddress, ConnectorContractAddress: zeroAddress, @@ -231,7 +231,7 @@ func GetDefaultBscTestnetChainParams() *ChainParams { } func GetDefaultMumbaiTestnetChainParams() *ChainParams { return &ChainParams{ - ChainId: chains.MumbaiChain().ChainId, + ChainId: chains.MumbaiChain.ChainId, ConfirmationCount: 12, ZetaTokenContractAddress: zeroAddress, ConnectorContractAddress: zeroAddress, @@ -249,7 +249,7 @@ func GetDefaultMumbaiTestnetChainParams() *ChainParams { } func GetDefaultBtcTestnetChainParams() *ChainParams { return &ChainParams{ - ChainId: chains.BtcTestNetChain().ChainId, + ChainId: chains.BtcTestNetChain.ChainId, ConfirmationCount: 2, ZetaTokenContractAddress: zeroAddress, ConnectorContractAddress: zeroAddress, @@ -267,7 +267,7 @@ func GetDefaultBtcTestnetChainParams() *ChainParams { } func GetDefaultBtcRegtestChainParams() *ChainParams { return &ChainParams{ - ChainId: chains.BtcRegtestChain().ChainId, + ChainId: chains.BtcRegtestChain.ChainId, ConfirmationCount: 1, ZetaTokenContractAddress: zeroAddress, ConnectorContractAddress: zeroAddress, @@ -285,7 +285,7 @@ func GetDefaultBtcRegtestChainParams() *ChainParams { } func GetDefaultGoerliLocalnetChainParams() *ChainParams { return &ChainParams{ - ChainId: chains.GoerliLocalnetChain().ChainId, + ChainId: chains.GoerliLocalnetChain.ChainId, ConfirmationCount: 1, ZetaTokenContractAddress: "0x733aB8b06DDDEf27Eaa72294B0d7c9cEF7f12db9", ConnectorContractAddress: "0xD28D6A0b8189305551a0A8bd247a6ECa9CE781Ca", @@ -303,7 +303,7 @@ func GetDefaultGoerliLocalnetChainParams() *ChainParams { } func GetDefaultZetaPrivnetChainParams() *ChainParams { return &ChainParams{ - ChainId: chains.ZetaPrivnetChain().ChainId, + ChainId: chains.ZetaPrivnetChain.ChainId, ConfirmationCount: 1, ZetaTokenContractAddress: zeroAddress, ConnectorContractAddress: zeroAddress, diff --git a/zetaclient/bitcoin/bitcoin_client_live_test.go b/zetaclient/bitcoin/bitcoin_client_live_test.go index 522b604d19..06d42ba498 100644 --- a/zetaclient/bitcoin/bitcoin_client_live_test.go +++ b/zetaclient/bitcoin/bitcoin_client_live_test.go @@ -46,7 +46,7 @@ func (suite *BitcoinClientTestSuite) SetupTest() { PrivKey: privateKey, } appContext := appcontext.NewAppContext(&corecontext.ZetaCoreContext{}, config.Config{}) - client, err := NewBitcoinClient(appContext, chains.BtcRegtestChain(), nil, tss, tempSQLiteDbPath, + client, err := NewBitcoinClient(appContext, chains.BtcRegtestChain, nil, tss, tempSQLiteDbPath, clientcommon.DefaultLoggers(), config.BTCConfig{}, nil) suite.Require().NoError(err) suite.rpcClient, err = getRPCClient(18332) @@ -365,7 +365,7 @@ func LiveTestGetSenderByVin(t *testing.T) { net, err := chains.GetBTCChainParams(chainID) require.NoError(t, err) testnet := false - if chainID == chains.BtcTestNetChain().ChainId { + if chainID == chains.BtcTestNetChain.ChainId { testnet = true } diff --git a/zetaclient/bitcoin/bitcoin_client_test.go b/zetaclient/bitcoin/bitcoin_client_test.go index dfa576c9c1..473033c0df 100644 --- a/zetaclient/bitcoin/bitcoin_client_test.go +++ b/zetaclient/bitcoin/bitcoin_client_test.go @@ -34,7 +34,7 @@ func MockBTCClientMainnet() *BTCChainClient { coreContext := corecontext.NewZetaCoreContext(cfg) return &BTCChainClient{ - chain: chains.BtcMainnetChain(), + chain: chains.BtcMainnetChain, zetaClient: stub.NewMockZetaCoreBridge(), Tss: stub.NewTSSMainnet(), coreContext: coreContext, @@ -62,9 +62,9 @@ func TestNewBitcoinClient(t *testing.T) { cfg := config.NewConfig() coreContext := corecontext.NewZetaCoreContext(cfg) appContext := appcontext.NewAppContext(coreContext, cfg) - chain := chains.BtcMainnetChain() + chain := chains.BtcMainnetChain bridge := stub.NewMockZetaCoreBridge() - tss := stub.NewMockTSS(chains.BtcTestNetChain(), sample.EthAddress().String(), "") + tss := stub.NewMockTSS(chains.BtcTestNetChain, sample.EthAddress().String(), "") loggers := clientcommon.ClientLogger{} btcCfg := cfg.BitcoinConfig ts := metrics.NewTelemetryServer() @@ -226,7 +226,7 @@ func TestCalcDepositorFee828440(t *testing.T) { func TestCheckTSSVout(t *testing.T) { // the archived outtx raw result file and cctx file // https://blockstream.info/tx/030cd813443f7b70cc6d8a544d320c6d8465e4528fc0f3410b599dc0b26753a0 - chain := chains.BtcMainnetChain() + chain := chains.BtcMainnetChain chainID := chain.ChainId nonce := uint64(148) @@ -308,7 +308,7 @@ func TestCheckTSSVout(t *testing.T) { func TestCheckTSSVoutCancelled(t *testing.T) { // the archived outtx raw result file and cctx file // https://blockstream.info/tx/030cd813443f7b70cc6d8a544d320c6d8465e4528fc0f3410b599dc0b26753a0 - chain := chains.BtcMainnetChain() + chain := chains.BtcMainnetChain chainID := chain.ChainId nonce := uint64(148) @@ -375,7 +375,7 @@ func TestCheckTSSVoutCancelled(t *testing.T) { } func TestGetSenderAddressByVin(t *testing.T) { - chain := chains.BtcMainnetChain() + chain := chains.BtcMainnetChain net := &chaincfg.MainNetParams t.Run("should get sender address from P2TR tx", func(t *testing.T) { @@ -465,7 +465,7 @@ func TestGetSenderAddressByVin(t *testing.T) { func TestGetSenderAddressByVinErrors(t *testing.T) { // https://mempool.space/tx/3618e869f9e87863c0f1cc46dbbaa8b767b4a5d6d60b143c2c50af52b257e867 txHash := "3618e869f9e87863c0f1cc46dbbaa8b767b4a5d6d60b143c2c50af52b257e867" - chain := chains.BtcMainnetChain() + chain := chains.BtcMainnetChain net := &chaincfg.MainNetParams t.Run("should get sender address from P2TR tx", func(t *testing.T) { @@ -499,7 +499,7 @@ func TestGetBtcEvent(t *testing.T) { // load archived intx P2WPKH raw result // https://mempool.space/tx/847139aa65aa4a5ee896375951cbf7417cfc8a4d6f277ec11f40cd87319f04aa txHash := "847139aa65aa4a5ee896375951cbf7417cfc8a4d6f277ec11f40cd87319f04aa" - chain := chains.BtcMainnetChain() + chain := chains.BtcMainnetChain // GetBtcEvent arguments tx := testutils.LoadBTCIntxRawResult(t, chain.ChainId, txHash, false) @@ -673,7 +673,7 @@ func TestGetBtcEventErrors(t *testing.T) { // load archived intx P2WPKH raw result // https://mempool.space/tx/847139aa65aa4a5ee896375951cbf7417cfc8a4d6f277ec11f40cd87319f04aa txHash := "847139aa65aa4a5ee896375951cbf7417cfc8a4d6f277ec11f40cd87319f04aa" - chain := chains.BtcMainnetChain() + chain := chains.BtcMainnetChain net := &chaincfg.MainNetParams tssAddress := testutils.TSSAddressBTCMainnet blockNumber := uint64(835640) diff --git a/zetaclient/bitcoin/bitcoin_signer_test.go b/zetaclient/bitcoin/bitcoin_signer_test.go index 96dc48cdff..2115c427a3 100644 --- a/zetaclient/bitcoin/bitcoin_signer_test.go +++ b/zetaclient/bitcoin/bitcoin_signer_test.go @@ -258,7 +258,7 @@ func TestAddWithdrawTxOutputs(t *testing.T) { // receiver addresses receiver := "bc1qaxf82vyzy8y80v000e7t64gpten7gawewzu42y" - to, err := chains.DecodeBtcAddress(receiver, chains.BtcMainnetChain().ChainId) + to, err := chains.DecodeBtcAddress(receiver, chains.BtcMainnetChain.ChainId) require.NoError(t, err) toScript, err := PayToAddrScript(to) require.NoError(t, err) diff --git a/zetaclient/bitcoin/fee_test.go b/zetaclient/bitcoin/fee_test.go index c9276911cf..4b63a9587d 100644 --- a/zetaclient/bitcoin/fee_test.go +++ b/zetaclient/bitcoin/fee_test.go @@ -71,7 +71,7 @@ func generateKeyPair(t *testing.T, net *chaincfg.Params) (*btcec.PrivateKey, btc // getTestAddrScript returns hard coded test address scripts by script type func getTestAddrScript(t *testing.T, scriptType string) btcutil.Address { - chain := chains.BtcMainnetChain() + chain := chains.BtcMainnetChain if inputAddress, ok := testAddressMap[scriptType]; ok { address, err := chains.DecodeBtcAddress(inputAddress, chain.ChainId) require.NoError(t, err) diff --git a/zetaclient/bitcoin/tx_script_test.go b/zetaclient/bitcoin/tx_script_test.go index c29e22c556..ec411de5fc 100644 --- a/zetaclient/bitcoin/tx_script_test.go +++ b/zetaclient/bitcoin/tx_script_test.go @@ -17,7 +17,7 @@ import ( func TestDecodeVoutP2TR(t *testing.T) { // load archived tx raw result // https://mempool.space/tx/259fc21e63e138136c8f19270a0f7ca10039a66a474f91d23a17896f46e677a7 - chain := chains.BtcMainnetChain() + chain := chains.BtcMainnetChain txHash := "259fc21e63e138136c8f19270a0f7ca10039a66a474f91d23a17896f46e677a7" net := &chaincfg.MainNetParams nameTx := path.Join("../", testutils.TestDataPathBTC, testutils.FileNameBTCTxByType(chain.ChainId, "P2TR", txHash)) @@ -35,7 +35,7 @@ func TestDecodeVoutP2TR(t *testing.T) { func TestDecodeVoutP2TRErrors(t *testing.T) { // load archived tx raw result // https://mempool.space/tx/259fc21e63e138136c8f19270a0f7ca10039a66a474f91d23a17896f46e677a7 - chain := chains.BtcMainnetChain() + chain := chains.BtcMainnetChain txHash := "259fc21e63e138136c8f19270a0f7ca10039a66a474f91d23a17896f46e677a7" net := &chaincfg.MainNetParams nameTx := path.Join("../", testutils.TestDataPathBTC, testutils.FileNameBTCTxByType(chain.ChainId, "P2TR", txHash)) @@ -74,7 +74,7 @@ func TestDecodeVoutP2TRErrors(t *testing.T) { func TestDecodeVoutP2WSH(t *testing.T) { // load archived tx raw result // https://mempool.space/tx/791bb9d16f7ab05f70a116d18eaf3552faf77b9d5688699a480261424b4f7e53 - chain := chains.BtcMainnetChain() + chain := chains.BtcMainnetChain txHash := "791bb9d16f7ab05f70a116d18eaf3552faf77b9d5688699a480261424b4f7e53" net := &chaincfg.MainNetParams nameTx := path.Join("../", testutils.TestDataPathBTC, testutils.FileNameBTCTxByType(chain.ChainId, "P2WSH", txHash)) @@ -92,7 +92,7 @@ func TestDecodeVoutP2WSH(t *testing.T) { func TestDecodeVoutP2WSHErrors(t *testing.T) { // load archived tx raw result // https://mempool.space/tx/791bb9d16f7ab05f70a116d18eaf3552faf77b9d5688699a480261424b4f7e53 - chain := chains.BtcMainnetChain() + chain := chains.BtcMainnetChain txHash := "791bb9d16f7ab05f70a116d18eaf3552faf77b9d5688699a480261424b4f7e53" net := &chaincfg.MainNetParams nameTx := path.Join("../", testutils.TestDataPathBTC, testutils.FileNameBTCTxByType(chain.ChainId, "P2WSH", txHash)) @@ -131,7 +131,7 @@ func TestDecodeVoutP2WSHErrors(t *testing.T) { func TestDecodeP2WPKHVout(t *testing.T) { // load archived outtx raw result // https://mempool.space/tx/030cd813443f7b70cc6d8a544d320c6d8465e4528fc0f3410b599dc0b26753a0 - chain := chains.BtcMainnetChain() + chain := chains.BtcMainnetChain nonce := uint64(148) net := &chaincfg.MainNetParams nameTx := path.Join("../", testutils.TestDataPathBTC, testutils.FileNameBTCOuttx(chain.ChainId, nonce)) @@ -159,7 +159,7 @@ func TestDecodeP2WPKHVout(t *testing.T) { func TestDecodeP2WPKHVoutErrors(t *testing.T) { // load archived outtx raw result // https://mempool.space/tx/030cd813443f7b70cc6d8a544d320c6d8465e4528fc0f3410b599dc0b26753a0 - chain := chains.BtcMainnetChain() + chain := chains.BtcMainnetChain nonce := uint64(148) net := &chaincfg.MainNetParams nameTx := path.Join("../", testutils.TestDataPathBTC, testutils.FileNameBTCOuttx(chain.ChainId, nonce)) @@ -191,7 +191,7 @@ func TestDecodeP2WPKHVoutErrors(t *testing.T) { func TestDecodeVoutP2SH(t *testing.T) { // load archived tx raw result // https://mempool.space/tx/fd68c8b4478686ca6f5ae4c28eaab055490650dbdaa6c2c8e380a7e075958a21 - chain := chains.BtcMainnetChain() + chain := chains.BtcMainnetChain txHash := "fd68c8b4478686ca6f5ae4c28eaab055490650dbdaa6c2c8e380a7e075958a21" net := &chaincfg.MainNetParams nameTx := path.Join("../", testutils.TestDataPathBTC, testutils.FileNameBTCTxByType(chain.ChainId, "P2SH", txHash)) @@ -209,7 +209,7 @@ func TestDecodeVoutP2SH(t *testing.T) { func TestDecodeVoutP2SHErrors(t *testing.T) { // load archived tx raw result // https://mempool.space/tx/fd68c8b4478686ca6f5ae4c28eaab055490650dbdaa6c2c8e380a7e075958a21 - chain := chains.BtcMainnetChain() + chain := chains.BtcMainnetChain txHash := "fd68c8b4478686ca6f5ae4c28eaab055490650dbdaa6c2c8e380a7e075958a21" net := &chaincfg.MainNetParams nameTx := path.Join("../", testutils.TestDataPathBTC, testutils.FileNameBTCTxByType(chain.ChainId, "P2SH", txHash)) @@ -254,7 +254,7 @@ func TestDecodeVoutP2SHErrors(t *testing.T) { func TestDecodeVoutP2PKH(t *testing.T) { // load archived tx raw result // https://mempool.space/tx/9c741de6e17382b7a9113fc811e3558981a35a360e3d1262a6675892c91322ca - chain := chains.BtcMainnetChain() + chain := chains.BtcMainnetChain txHash := "9c741de6e17382b7a9113fc811e3558981a35a360e3d1262a6675892c91322ca" net := &chaincfg.MainNetParams nameTx := path.Join("../", testutils.TestDataPathBTC, testutils.FileNameBTCTxByType(chain.ChainId, "P2PKH", txHash)) @@ -272,7 +272,7 @@ func TestDecodeVoutP2PKH(t *testing.T) { func TestDecodeVoutP2PKHErrors(t *testing.T) { // load archived tx raw result // https://mempool.space/tx/9c741de6e17382b7a9113fc811e3558981a35a360e3d1262a6675892c91322ca - chain := chains.BtcMainnetChain() + chain := chains.BtcMainnetChain txHash := "9c741de6e17382b7a9113fc811e3558981a35a360e3d1262a6675892c91322ca" net := &chaincfg.MainNetParams nameTx := path.Join("../", testutils.TestDataPathBTC, testutils.FileNameBTCTxByType(chain.ChainId, "P2PKH", txHash)) @@ -332,7 +332,7 @@ func TestDecodeVoutP2PKHErrors(t *testing.T) { func TestDecodeOpReturnMemo(t *testing.T) { // load archived intx raw result // https://mempool.space/tx/847139aa65aa4a5ee896375951cbf7417cfc8a4d6f277ec11f40cd87319f04aa - chain := chains.BtcMainnetChain() + chain := chains.BtcMainnetChain txHash := "847139aa65aa4a5ee896375951cbf7417cfc8a4d6f277ec11f40cd87319f04aa" scriptHex := "6a1467ed0bcc4e1256bc2ce87d22e190d63a120114bf" rawResult := testutils.LoadBTCIntxRawResult(t, chain.ChainId, txHash, false) @@ -404,7 +404,7 @@ func TestDecodeOpReturnMemoErrors(t *testing.T) { } func TestDecodeTSSVout(t *testing.T) { - chain := chains.BtcMainnetChain() + chain := chains.BtcMainnetChain t.Run("should decode P2TR vout", func(t *testing.T) { // https://mempool.space/tx/259fc21e63e138136c8f19270a0f7ca10039a66a474f91d23a17896f46e677a7 @@ -476,7 +476,7 @@ func TestDecodeTSSVout(t *testing.T) { func TestDecodeTSSVoutErrors(t *testing.T) { // load archived tx raw result // https://mempool.space/tx/259fc21e63e138136c8f19270a0f7ca10039a66a474f91d23a17896f46e677a7 - chain := chains.BtcMainnetChain() + chain := chains.BtcMainnetChain txHash := "259fc21e63e138136c8f19270a0f7ca10039a66a474f91d23a17896f46e677a7" nameTx := path.Join("../", testutils.TestDataPathBTC, testutils.FileNameBTCTxByType(chain.ChainId, "P2TR", txHash)) @@ -504,7 +504,7 @@ func TestDecodeTSSVoutErrors(t *testing.T) { t.Run("should return error when invalid receiver passed", func(t *testing.T) { invalidVout := rawResult.Vout[0] // use testnet params to decode mainnet receiver - wrongChain := chains.BtcTestNetChain() + wrongChain := chains.BtcTestNetChain receiver, amount, err := DecodeTSSVout(invalidVout, "bc1qulmx8ej27cj0xe20953cztr2excnmsqvuh0s5c", wrongChain) require.ErrorContains(t, err, "error decoding receiver") require.Empty(t, receiver) diff --git a/zetaclient/compliance/compliance_test.go b/zetaclient/compliance/compliance_test.go index c88e3b5da8..1f4fe468bf 100644 --- a/zetaclient/compliance/compliance_test.go +++ b/zetaclient/compliance/compliance_test.go @@ -12,7 +12,7 @@ import ( func TestCctxRestricted(t *testing.T) { // load archived cctx - chain := chains.EthChain() + chain := chains.EthChain cctx := testutils.LoadCctxByNonce(t, chain.ChainId, 6270) // create config diff --git a/zetaclient/config/config_chain.go b/zetaclient/config/config_chain.go index f211f1030d..5fe31e51a4 100644 --- a/zetaclient/config/config_chain.go +++ b/zetaclient/config/config_chain.go @@ -44,30 +44,30 @@ var bitcoinConfigRegnet = BTCConfig{ } var evmChainsConfigs = map[int64]EVMConfig{ - chains.EthChain().ChainId: { - Chain: chains.EthChain(), + chains.EthChain.ChainId: { + Chain: chains.EthChain, }, - chains.BscMainnetChain().ChainId: { - Chain: chains.BscMainnetChain(), + chains.BscMainnetChain.ChainId: { + Chain: chains.BscMainnetChain, }, - chains.GoerliChain().ChainId: { - Chain: chains.GoerliChain(), + chains.GoerliChain.ChainId: { + Chain: chains.GoerliChain, Endpoint: "", }, - chains.SepoliaChain().ChainId: { - Chain: chains.SepoliaChain(), + chains.SepoliaChain.ChainId: { + Chain: chains.SepoliaChain, Endpoint: "", }, - chains.BscTestnetChain().ChainId: { - Chain: chains.BscTestnetChain(), + chains.BscTestnetChain.ChainId: { + Chain: chains.BscTestnetChain, Endpoint: "", }, - chains.MumbaiChain().ChainId: { - Chain: chains.MumbaiChain(), + chains.MumbaiChain.ChainId: { + Chain: chains.MumbaiChain, Endpoint: "", }, - chains.GoerliLocalnetChain().ChainId: { - Chain: chains.GoerliLocalnetChain(), + chains.GoerliLocalnetChain.ChainId: { + Chain: chains.GoerliLocalnetChain, Endpoint: "http://eth:8545", }, } diff --git a/zetaclient/core_context/zeta_core_context_test.go b/zetaclient/core_context/zeta_core_context_test.go index 93b0e1c57f..e9fb129023 100644 --- a/zetaclient/core_context/zeta_core_context_test.go +++ b/zetaclient/core_context/zeta_core_context_test.go @@ -261,7 +261,7 @@ func TestUpdateZetaCoreContext(t *testing.T) { }, } - testBtcChain := chains.BtcTestNetChain() + testBtcChain := chains.BtcTestNetChain btcChainParamsToUpdate := &observertypes.ChainParams{ ChainId: testBtcChain.ChainId, } @@ -320,7 +320,7 @@ func TestUpdateZetaCoreContext(t *testing.T) { func TestIsOutboundObservationEnabled(t *testing.T) { // create test chain params and flags - evmChain := chains.EthChain() + evmChain := chains.EthChain ccFlags := *sample.CrosschainFlags() verificationFlags := sample.VerificationFlags() chainParams := &observertypes.ChainParams{ @@ -350,7 +350,7 @@ func TestIsOutboundObservationEnabled(t *testing.T) { func TestIsInboundObservationEnabled(t *testing.T) { // create test chain params and flags - evmChain := chains.EthChain() + evmChain := chains.EthChain ccFlags := *sample.CrosschainFlags() verificationFlags := sample.VerificationFlags() chainParams := &observertypes.ChainParams{ diff --git a/zetaclient/evm/evm_signer.go b/zetaclient/evm/evm_signer.go index d9b6eb25dd..cabc64f2e0 100644 --- a/zetaclient/evm/evm_signer.go +++ b/zetaclient/evm/evm_signer.go @@ -662,7 +662,7 @@ func (signer *Signer) EvmSigner() ethtypes.Signer { // getEVMRPC is a helper function to set up the client and signer, also initializes a mock client for unit tests func getEVMRPC(endpoint string) (interfaces.EVMRPCClient, ethtypes.Signer, error) { if endpoint == stub.EVMRPCEnabled { - chainID := big.NewInt(chains.BscMainnetChain().ChainId) + chainID := big.NewInt(chains.BscMainnetChain.ChainId) ethSigner := ethtypes.NewLondonSigner(chainID) client := &stub.MockEvmClient{} return client, ethSigner, nil diff --git a/zetaclient/evm/evm_signer_test.go b/zetaclient/evm/evm_signer_test.go index 03e014adde..15c3657cc9 100644 --- a/zetaclient/evm/evm_signer_test.go +++ b/zetaclient/evm/evm_signer_test.go @@ -34,7 +34,7 @@ func getNewEvmSigner() (*Signer, error) { ts := &metrics.TelemetryServer{} cfg := config.NewConfig() return NewEVMSigner( - chains.BscMainnetChain(), + chains.BscMainnetChain, stub.EVMRPCEnabled, stub.NewTSSMainnet(), config.GetConnectorABI(), @@ -52,8 +52,8 @@ func getNewEvmChainClient() (*ChainClient, error) { cfg := config.NewConfig() tss := stub.NewTSSMainnet() - evmcfg := config.EVMConfig{Chain: chains.BscMainnetChain(), Endpoint: "http://localhost:8545"} - cfg.EVMChainConfigs[chains.BscMainnetChain().ChainId] = evmcfg + evmcfg := config.EVMConfig{Chain: chains.BscMainnetChain, Endpoint: "http://localhost:8545"} + cfg.EVMChainConfigs[chains.BscMainnetChain.ChainId] = evmcfg coreCTX := corecontext.NewZetaCoreContext(cfg) appCTX := appcontext.NewAppContext(coreCTX, cfg) diff --git a/zetaclient/evm/inbounds_test.go b/zetaclient/evm/inbounds_test.go index 645a87d108..223c2f5daf 100644 --- a/zetaclient/evm/inbounds_test.go +++ b/zetaclient/evm/inbounds_test.go @@ -21,7 +21,7 @@ import ( func TestEVM_CheckAndVoteInboundTokenZeta(t *testing.T) { // load archived ZetaSent intx, receipt and cctx // https://etherscan.io/tx/0xf3935200c80f98502d5edc7e871ffc40ca898e134525c42c2ae3cbc5725f9d76 - chain := chains.EthChain() + chain := chains.EthChain confirmation := uint64(10) chainID := chain.ChainId chainParam := stub.MockChainParams(chain.ChainId, confirmation) @@ -72,7 +72,7 @@ func TestEVM_CheckAndVoteInboundTokenZeta(t *testing.T) { func TestEVM_CheckAndVoteInboundTokenERC20(t *testing.T) { // load archived ERC20 intx, receipt and cctx // https://etherscan.io/tx/0x4ea69a0e2ff36f7548ab75791c3b990e076e2a4bffeb616035b239b7d33843da - chain := chains.EthChain() + chain := chains.EthChain confirmation := uint64(10) chainID := chain.ChainId chainParam := stub.MockChainParams(chain.ChainId, confirmation) @@ -123,7 +123,7 @@ func TestEVM_CheckAndVoteInboundTokenERC20(t *testing.T) { func TestEVM_CheckAndVoteInboundTokenGas(t *testing.T) { // load archived Gas intx, receipt and cctx // https://etherscan.io/tx/0xeaec67d5dd5d85f27b21bef83e01cbdf59154fd793ea7a22c297f7c3a722c532 - chain := chains.EthChain() + chain := chains.EthChain confirmation := uint64(10) chainID := chain.ChainId chainParam := stub.MockChainParams(chain.ChainId, confirmation) @@ -187,7 +187,7 @@ func TestEVM_BuildInboundVoteMsgForZetaSentEvent(t *testing.T) { // load archived ZetaSent receipt // https://etherscan.io/tx/0xf3935200c80f98502d5edc7e871ffc40ca898e134525c42c2ae3cbc5725f9d76 chainID := int64(1) - chain := chains.EthChain() + chain := chains.EthChain intxHash := "0xf3935200c80f98502d5edc7e871ffc40ca898e134525c42c2ae3cbc5725f9d76" receipt := testutils.LoadEVMIntxReceipt(t, chainID, intxHash, coin.CoinType_Zeta) cctx := testutils.LoadCctxByIntx(t, chainID, coin.CoinType_Zeta, intxHash) @@ -233,7 +233,7 @@ func TestEVM_BuildInboundVoteMsgForZetaSentEvent(t *testing.T) { func TestEVM_BuildInboundVoteMsgForDepositedEvent(t *testing.T) { // load archived Deposited receipt // https://etherscan.io/tx/0x4ea69a0e2ff36f7548ab75791c3b990e076e2a4bffeb616035b239b7d33843da - chain := chains.EthChain() + chain := chains.EthChain chainID := chain.ChainId intxHash := "0x4ea69a0e2ff36f7548ab75791c3b990e076e2a4bffeb616035b239b7d33843da" tx, receipt := testutils.LoadEVMIntxNReceipt(t, chainID, intxHash, coin.CoinType_ERC20) @@ -278,7 +278,7 @@ func TestEVM_BuildInboundVoteMsgForDepositedEvent(t *testing.T) { func TestEVM_BuildInboundVoteMsgForTokenSentToTSS(t *testing.T) { // load archived gas token transfer to TSS // https://etherscan.io/tx/0xeaec67d5dd5d85f27b21bef83e01cbdf59154fd793ea7a22c297f7c3a722c532 - chain := chains.EthChain() + chain := chains.EthChain chainID := chain.ChainId intxHash := "0xeaec67d5dd5d85f27b21bef83e01cbdf59154fd793ea7a22c297f7c3a722c532" tx, receipt := testutils.LoadEVMIntxNReceipt(t, chainID, intxHash, coin.CoinType_Gas) @@ -327,7 +327,7 @@ func TestEVM_BuildInboundVoteMsgForTokenSentToTSS(t *testing.T) { func TestEVM_ObserveTSSReceiveInBlock(t *testing.T) { // https://etherscan.io/tx/0xeaec67d5dd5d85f27b21bef83e01cbdf59154fd793ea7a22c297f7c3a722c532 - chain := chains.EthChain() + chain := chains.EthChain chainID := chain.ChainId confirmation := uint64(1) chainParam := stub.MockChainParams(chain.ChainId, confirmation) diff --git a/zetaclient/evm/outbound_transaction_data_test.go b/zetaclient/evm/outbound_transaction_data_test.go index 85c812119b..6effd80f34 100644 --- a/zetaclient/evm/outbound_transaction_data_test.go +++ b/zetaclient/evm/outbound_transaction_data_test.go @@ -51,14 +51,14 @@ func TestSigner_SetupGas(t *testing.T) { logger := zerolog.Logger{} t.Run("SetupGas_success", func(t *testing.T) { - chain := chains.BscMainnetChain() + chain := chains.BscMainnetChain err := txData.SetupGas(cctx, logger, evmSigner.EvmClient(), &chain) require.NoError(t, err) }) t.Run("SetupGas_error", func(t *testing.T) { cctx.GetCurrentOutTxParam().OutboundTxGasPrice = "invalidGasPrice" - chain := chains.BscMainnetChain() + chain := chains.BscMainnetChain err := txData.SetupGas(cctx, logger, evmSigner.EvmClient(), &chain) require.ErrorContains(t, err, "cannot convert gas price") }) diff --git a/zetaclient/evm/outbounds_test.go b/zetaclient/evm/outbounds_test.go index 757a407394..b582323d11 100644 --- a/zetaclient/evm/outbounds_test.go +++ b/zetaclient/evm/outbounds_test.go @@ -30,8 +30,8 @@ func getContractsByChainID(chainID int64) (*zetaconnector.ZetaConnectorNonEth, e func Test_IsOutboundProcessed(t *testing.T) { // load archived outtx receipt that contains ZetaReceived event // https://etherscan.io/tx/0x81342051b8a85072d3e3771c1a57c7bdb5318e8caf37f5a687b7a91e50a7257f - chain := chains.EthChain() - chainID := chains.EthChain().ChainId + chain := chains.EthChain + chainID := chains.EthChain.ChainId nonce := uint64(9718) chainParam := stub.MockChainParams(chain.ChainId, 1) outtxHash := "0x81342051b8a85072d3e3771c1a57c7bdb5318e8caf37f5a687b7a91e50a7257f" @@ -107,8 +107,8 @@ func Test_IsOutboundProcessed_ContractError(t *testing.T) { // load archived outtx receipt that contains ZetaReceived event // https://etherscan.io/tx/0x81342051b8a85072d3e3771c1a57c7bdb5318e8caf37f5a687b7a91e50a7257f - chain := chains.EthChain() - chainID := chains.EthChain().ChainId + chain := chains.EthChain + chainID := chains.EthChain.ChainId nonce := uint64(9718) chainParam := stub.MockChainParams(chain.ChainId, 1) outtxHash := "0x81342051b8a85072d3e3771c1a57c7bdb5318e8caf37f5a687b7a91e50a7257f" @@ -145,7 +145,7 @@ func Test_PostVoteOutbound(t *testing.T) { // Note: outtx of Gas/ERC20 token can also be used for this test // load archived cctx, outtx and receipt for a ZetaReceived event // https://etherscan.io/tx/0x81342051b8a85072d3e3771c1a57c7bdb5318e8caf37f5a687b7a91e50a7257f - chain := chains.EthChain() + chain := chains.EthChain nonce := uint64(9718) coinType := coin.CoinType_Zeta cctx, outtx, receipt := testutils.LoadEVMCctxNOuttxNReceipt(t, chain.ChainId, nonce, testutils.EventZetaReceived) @@ -169,7 +169,7 @@ func Test_PostVoteOutbound(t *testing.T) { func Test_ParseZetaReceived(t *testing.T) { // load archived outtx receipt that contains ZetaReceived event // https://etherscan.io/tx/0x81342051b8a85072d3e3771c1a57c7bdb5318e8caf37f5a687b7a91e50a7257f - chainID := chains.EthChain().ChainId + chainID := chains.EthChain.ChainId nonce := uint64(9718) outtxHash := "0x81342051b8a85072d3e3771c1a57c7bdb5318e8caf37f5a687b7a91e50a7257f" connector := stub.MockConnectorNonEth(chainID) @@ -230,7 +230,7 @@ func Test_ParseZetaReceived(t *testing.T) { func Test_ParseZetaReverted(t *testing.T) { // load archived outtx receipt that contains ZetaReverted event - chainID := chains.GoerliLocalnetChain().ChainId + chainID := chains.GoerliLocalnetChain.ChainId nonce := uint64(14) outtxHash := "0x1487e6a31dd430306667250b72bf15b8390b73108b69f3de5c1b2efe456036a7" connector := stub.MockConnectorNonEth(chainID) @@ -282,7 +282,7 @@ func Test_ParseZetaReverted(t *testing.T) { func Test_ParseERC20WithdrawnEvent(t *testing.T) { // load archived outtx receipt that contains ERC20 Withdrawn event - chainID := chains.EthChain().ChainId + chainID := chains.EthChain.ChainId nonce := uint64(8014) outtxHash := "0xd2eba7ac3da1b62800165414ea4bcaf69a3b0fb9b13a0fc32f4be11bfef79146" custody := stub.MockERC20Custody(chainID) @@ -338,7 +338,7 @@ func Test_ParseERC20WithdrawnEvent(t *testing.T) { } func Test_ParseOuttxReceivedValue(t *testing.T) { - chainID := chains.EthChain().ChainId + chainID := chains.EthChain.ChainId connector, connectorAddr, custody, custodyAddr := getContractsByChainID(chainID) t.Run("should parse and check ZetaReceived event from archived outtx receipt", func(t *testing.T) { @@ -356,7 +356,7 @@ func Test_ParseOuttxReceivedValue(t *testing.T) { t.Run("should parse and check ZetaReverted event from archived outtx receipt", func(t *testing.T) { // load archived outtx receipt that contains ZetaReverted event // use local network tx: 0x1487e6a31dd430306667250b72bf15b8390b73108b69f3de5c1b2efe456036a7 - localChainID := chains.GoerliLocalnetChain().ChainId + localChainID := chains.GoerliLocalnetChain.ChainId nonce := uint64(14) coinType := coin.CoinType_Zeta connectorLocal, connectorAddrLocal, custodyLocal, custodyAddrLocal := getContractsByChainID(localChainID) diff --git a/zetaclient/testutils/stub/tss_signer.go b/zetaclient/testutils/stub/tss_signer.go index 0f6d9787e6..bda2d34082 100644 --- a/zetaclient/testutils/stub/tss_signer.go +++ b/zetaclient/testutils/stub/tss_signer.go @@ -40,11 +40,11 @@ func NewMockTSS(chain chains.Chain, evmAddress string, btcAddress string) *TSS { } func NewTSSMainnet() *TSS { - return NewMockTSS(chains.BtcMainnetChain(), testutils.TSSAddressEVMMainnet, testutils.TSSAddressBTCMainnet) + return NewMockTSS(chains.BtcMainnetChain, testutils.TSSAddressEVMMainnet, testutils.TSSAddressBTCMainnet) } func NewTSSAthens3() *TSS { - return NewMockTSS(chains.BscTestnetChain(), testutils.TSSAddressEVMAthens3, testutils.TSSAddressBTCAthens3) + return NewMockTSS(chains.BscTestnetChain, testutils.TSSAddressEVMAthens3, testutils.TSSAddressBTCAthens3) } // Sign uses test key unrelated to any tss key in production diff --git a/zetaclient/zetabridge/broadcast_test.go b/zetaclient/zetabridge/broadcast_test.go index 4d838358b0..2a4d341db4 100644 --- a/zetaclient/zetabridge/broadcast_test.go +++ b/zetaclient/zetabridge/broadcast_test.go @@ -79,7 +79,7 @@ func TestBroadcast(t *testing.T) { zetabridge.EnableMockSDKClient(stub.NewSDKClientWithErr(nil, 0)) blockHash, err := hex.DecodeString(ethBlockHash) require.NoError(t, err) - msg := observerTypes.NewMsgVoteBlockHeader(address.String(), chains.EthChain().ChainId, blockHash, 18495266, getHeaderData(t)) + msg := observerTypes.NewMsgVoteBlockHeader(address.String(), chains.EthChain.ChainId, blockHash, 18495266, getHeaderData(t)) authzMsg, authzSigner, err := zetabridge.WrapMessageWithAuthz(msg) require.NoError(t, err) _, err = BroadcastToZetaCore(zetabridge, 10000, authzMsg, authzSigner) @@ -90,7 +90,7 @@ func TestBroadcast(t *testing.T) { zetabridge.EnableMockSDKClient(stub.NewSDKClientWithErr(errors.New("account sequence mismatch, expected 5 got 4"), 32)) blockHash, err := hex.DecodeString(ethBlockHash) require.NoError(t, err) - msg := observerTypes.NewMsgVoteBlockHeader(address.String(), chains.EthChain().ChainId, blockHash, 18495266, getHeaderData(t)) + msg := observerTypes.NewMsgVoteBlockHeader(address.String(), chains.EthChain.ChainId, blockHash, 18495266, getHeaderData(t)) authzMsg, authzSigner, err := zetabridge.WrapMessageWithAuthz(msg) require.NoError(t, err) _, err = BroadcastToZetaCore(zetabridge, 10000, authzMsg, authzSigner) diff --git a/zetaclient/zetabridge/query_test.go b/zetaclient/zetabridge/query_test.go index d35d85eab6..44fe8a1b74 100644 --- a/zetaclient/zetabridge/query_test.go +++ b/zetaclient/zetabridge/query_test.go @@ -399,7 +399,7 @@ func TestZetaCoreBridge_GetNodeInfo(t *testing.T) { } func TestZetaCoreBridge_GetLastBlockHeightByChain(t *testing.T) { - index := chains.BscMainnetChain() + index := chains.BscMainnetChain expectedOutput := crosschainTypes.QueryGetLastBlockHeightResponse{ LastBlockHeight: &crosschainTypes.LastBlockHeight{ Index: index.ChainName.String(), @@ -467,7 +467,7 @@ func TestZetaCoreBridge_GetBaseGasPrice(t *testing.T) { } func TestZetaCoreBridge_GetNonceByChain(t *testing.T) { - chain := chains.BscMainnetChain() + chain := chains.BscMainnetChain expectedOutput := observertypes.QueryGetChainNoncesResponse{ ChainNonces: observertypes.ChainNonces{ Creator: "", @@ -557,7 +557,7 @@ func TestZetaCoreBridge_GetBallotByID(t *testing.T) { } func TestZetaCoreBridge_GetInboundTrackersForChain(t *testing.T) { - chainID := chains.BscMainnetChain().ChainId + chainID := chains.BscMainnetChain.ChainId expectedOutput := crosschainTypes.QueryAllInTxTrackerByChainResponse{ InTxTracker: []crosschainTypes.InTxTracker{ { @@ -670,7 +670,7 @@ func TestZetaCoreBridge_GetTssHistory(t *testing.T) { } func TestZetaCoreBridge_GetOutTxTracker(t *testing.T) { - chain := chains.BscMainnetChain() + chain := chains.BscMainnetChain expectedOutput := crosschainTypes.QueryGetOutTxTrackerResponse{ OutTxTracker: crosschainTypes.OutTxTracker{ Index: "tracker12345", @@ -697,7 +697,7 @@ func TestZetaCoreBridge_GetOutTxTracker(t *testing.T) { } func TestZetaCoreBridge_GetAllOutTxTrackerByChain(t *testing.T) { - chain := chains.BscMainnetChain() + chain := chains.BscMainnetChain expectedOutput := crosschainTypes.QueryAllOutTxTrackerByChainResponse{ OutTxTracker: []crosschainTypes.OutTxTracker{ { @@ -740,11 +740,11 @@ func TestZetaCoreBridge_GetPendingNoncesByChain(t *testing.T) { PendingNonces: observertypes.PendingNonces{ NonceLow: 0, NonceHigh: 0, - ChainId: chains.EthChain().ChainId, + ChainId: chains.EthChain.ChainId, Tss: "", }, } - input := observertypes.QueryPendingNoncesByChainRequest{ChainId: chains.EthChain().ChainId} + input := observertypes.QueryPendingNoncesByChainRequest{ChainId: chains.EthChain.ChainId} method := "/zetachain.zetacore.observer.Query/PendingNoncesByChain" server := setupMockServer(t, observertypes.RegisterQueryServer, method, input, expectedOutput) server.Serve() @@ -753,13 +753,13 @@ func TestZetaCoreBridge_GetPendingNoncesByChain(t *testing.T) { zetabridge, err := setupCoreBridge() require.NoError(t, err) - resp, err := zetabridge.GetPendingNoncesByChain(chains.EthChain().ChainId) + resp, err := zetabridge.GetPendingNoncesByChain(chains.EthChain.ChainId) require.NoError(t, err) require.Equal(t, expectedOutput.PendingNonces, resp) } func TestZetaCoreBridge_GetBlockHeaderChainState(t *testing.T) { - chainID := chains.BscMainnetChain().ChainId + chainID := chains.BscMainnetChain.ChainId expectedOutput := lightclienttypes.QueryGetChainStateResponse{ChainState: &lightclienttypes.ChainState{ ChainId: chainID, LatestHeight: 5566654, @@ -784,24 +784,24 @@ func TestZetaCoreBridge_GetSupportedChains(t *testing.T) { expectedOutput := observertypes.QuerySupportedChainsResponse{ Chains: []*chains.Chain{ { - chains.BtcMainnetChain().ChainName, - chains.BtcMainnetChain().ChainId, - chains.BscMainnetChain().Network, - chains.BscMainnetChain().NetworkType, - chains.BscMainnetChain().Vm, - chains.BscMainnetChain().Consensus, - chains.BscMainnetChain().IsExternal, - chains.BscMainnetChain().IsHeaderSupported, + chains.BtcMainnetChain.ChainName, + chains.BtcMainnetChain.ChainId, + chains.BscMainnetChain.Network, + chains.BscMainnetChain.NetworkType, + chains.BscMainnetChain.Vm, + chains.BscMainnetChain.Consensus, + chains.BscMainnetChain.IsExternal, + chains.BscMainnetChain.IsHeaderSupported, }, { - chains.EthChain().ChainName, - chains.EthChain().ChainId, - chains.EthChain().Network, - chains.EthChain().NetworkType, - chains.EthChain().Vm, - chains.EthChain().Consensus, - chains.EthChain().IsExternal, - chains.EthChain().IsHeaderSupported, + chains.EthChain.ChainName, + chains.EthChain.ChainId, + chains.EthChain.Network, + chains.EthChain.NetworkType, + chains.EthChain.Vm, + chains.EthChain.Consensus, + chains.EthChain.IsExternal, + chains.EthChain.IsHeaderSupported, }, }, } @@ -845,7 +845,7 @@ func TestZetaCoreBridge_GetPendingNonces(t *testing.T) { } func TestZetaCoreBridge_Prove(t *testing.T) { - chainId := chains.BscMainnetChain().ChainId + chainId := chains.BscMainnetChain.ChainId txHash := "9c8d02b6956b9c78ecb6090a8160faaa48e7aecfd0026fcdf533721d861436a3" blockHash := "0000000000000000000172c9a64f86f208b867a84dc7a0b7c75be51e750ed8eb" txIndex := 555 diff --git a/zetaclient/zetabridge/tx_test.go b/zetaclient/zetabridge/tx_test.go index 048525ceb1..498774a28c 100644 --- a/zetaclient/zetabridge/tx_test.go +++ b/zetaclient/zetabridge/tx_test.go @@ -143,7 +143,7 @@ func TestZetaCoreBridge_PostGasPrice(t *testing.T) { t.Run("post gas price success", func(t *testing.T) { zetaBridgeBroadcast = ZetaBridgeBroadcastTest - hash, err := zetabridge.PostGasPrice(chains.BscMainnetChain(), 1000000, "100", 1234) + hash, err := zetabridge.PostGasPrice(chains.BscMainnetChain, 1000000, "100", 1234) require.NoError(t, err) require.Equal(t, sampleHash, hash) }) @@ -152,7 +152,7 @@ func TestZetaCoreBridge_PostGasPrice(t *testing.T) { // //t.Run("post gas price fail", func(t *testing.T) { // zetaBridgeBroadcast = ZetaBridgeBroadcastTestErr - // hash, err := zetabridge.PostGasPrice(chains.BscMainnetChain(), 1000000, "100", 1234) + // hash, err := zetabridge.PostGasPrice(chains.BscMainnetChain, 1000000, "100", 1234) // require.ErrorContains(t, err, "post gasprice failed") // require.Equal(t, "", hash) //}) @@ -166,14 +166,14 @@ func TestZetaCoreBridge_AddTxHashToOutTxTracker(t *testing.T) { t.Run("add tx hash success", func(t *testing.T) { zetaBridgeBroadcast = ZetaBridgeBroadcastTest - hash, err := zetabridge.AddTxHashToOutTxTracker(chains.BscMainnetChain().ChainId, 123, "", nil, "", 456) + hash, err := zetabridge.AddTxHashToOutTxTracker(chains.BscMainnetChain.ChainId, 123, "", nil, "", 456) require.NoError(t, err) require.Equal(t, sampleHash, hash) }) t.Run("add tx hash fail", func(t *testing.T) { zetaBridgeBroadcast = ZetaBridgeBroadcastTestErr - hash, err := zetabridge.AddTxHashToOutTxTracker(chains.BscMainnetChain().ChainId, 123, "", nil, "", 456) + hash, err := zetabridge.AddTxHashToOutTxTracker(chains.BscMainnetChain.ChainId, 123, "", nil, "", 456) require.Error(t, err) require.Equal(t, "", hash) }) @@ -247,24 +247,24 @@ func TestZetaCoreBridge_UpdateZetaCoreContext(t *testing.T) { Chains: []*chains.Chain{ { - chains.BtcMainnetChain().ChainName, - chains.BtcMainnetChain().ChainId, - chains.BscMainnetChain().Network, - chains.BscMainnetChain().NetworkType, - chains.BscMainnetChain().Vm, - chains.BscMainnetChain().Consensus, - chains.BscMainnetChain().IsExternal, - chains.BscMainnetChain().IsHeaderSupported, + chains.BtcMainnetChain.ChainName, + chains.BtcMainnetChain.ChainId, + chains.BscMainnetChain.Network, + chains.BscMainnetChain.NetworkType, + chains.BscMainnetChain.Vm, + chains.BscMainnetChain.Consensus, + chains.BscMainnetChain.IsExternal, + chains.BscMainnetChain.IsHeaderSupported, }, { - chains.EthChain().ChainName, - chains.EthChain().ChainId, - chains.EthChain().Network, - chains.EthChain().NetworkType, - chains.EthChain().Vm, - chains.EthChain().Consensus, - chains.EthChain().IsExternal, - chains.EthChain().IsHeaderSupported, + chains.EthChain.ChainName, + chains.EthChain.ChainId, + chains.EthChain.Network, + chains.EthChain.NetworkType, + chains.EthChain.Vm, + chains.EthChain.Consensus, + chains.EthChain.IsExternal, + chains.EthChain.IsHeaderSupported, }, }, }) @@ -348,7 +348,7 @@ func TestZetaCoreBridge_PostBlameData(t *testing.T) { IsUnicast: false, BlameNodes: nil, }, - chains.BscMainnetChain().ChainId, + chains.BscMainnetChain.ChainId, "102394876-bsc", ) require.NoError(t, err) @@ -367,7 +367,7 @@ func TestZetaCoreBridge_PostVoteBlockHeader(t *testing.T) { t.Run("post add block header success", func(t *testing.T) { zetaBridgeBroadcast = ZetaBridgeBroadcastTest hash, err := zetabridge.PostVoteBlockHeader( - chains.EthChain().ChainId, + chains.EthChain.ChainId, blockHash, 18495266, getHeaderData(t), @@ -411,10 +411,10 @@ func TestZetaCoreBridge_GetInBoundVoteMessage(t *testing.T) { zetaBridgeBroadcast = ZetaBridgeBroadcastTest msg := GetInBoundVoteMessage( address.String(), - chains.EthChain().ChainId, + chains.EthChain.ChainId, "", address.String(), - chains.ZetaChainMainnet().ChainId, + chains.ZetaChainMainnet.ChainId, math.NewUint(500), "", "", 12345, @@ -472,7 +472,7 @@ func TestZetaCoreBridge_PostVoteOutbound(t *testing.T) { 1200, big.NewInt(500), chains.ReceiveStatus_success, - chains.EthChain(), + chains.EthChain, 10001, coin.CoinType_Gas) require.NoError(t, err) diff --git a/zetaclient/zetacore_observer_test.go b/zetaclient/zetacore_observer_test.go index d47c062757..a02263fb0f 100644 --- a/zetaclient/zetacore_observer_test.go +++ b/zetaclient/zetacore_observer_test.go @@ -75,8 +75,8 @@ func CreateCoreContext(evmChain, btcChain chains.Chain, evmChainParams, btcChain func Test_GetUpdatedSigner(t *testing.T) { // initial parameters for core observer creation - evmChain := chains.EthChain() - btcChain := chains.BtcMainnetChain() + evmChain := chains.EthChain + btcChain := chains.BtcMainnetChain evmChainParams := &observertypes.ChainParams{ ChainId: evmChain.ChainId, ConnectorContractAddress: testutils.ConnectorAddresses[evmChain.ChainId].Hex(), @@ -95,7 +95,7 @@ func Test_GetUpdatedSigner(t *testing.T) { observer := MockCoreObserver(t, evmChain, btcChain, evmChainParams, btcChainParams) coreContext := CreateCoreContext(evmChain, btcChain, evmChainParamsNew, btcChainParams) // BSC signer should not be found - _, err := observer.GetUpdatedSigner(coreContext, chains.BscMainnetChain().ChainId) + _, err := observer.GetUpdatedSigner(coreContext, chains.BscMainnetChain.ChainId) require.ErrorContains(t, err, "signer not found") }) t.Run("should be able to update connector and erc20 custody address", func(t *testing.T) { @@ -111,8 +111,8 @@ func Test_GetUpdatedSigner(t *testing.T) { func Test_GetUpdatedChainClient(t *testing.T) { // initial parameters for core observer creation - evmChain := chains.EthChain() - btcChain := chains.BtcMainnetChain() + evmChain := chains.EthChain + btcChain := chains.BtcMainnetChain evmChainParams := &observertypes.ChainParams{ ChainId: evmChain.ChainId, ConnectorContractAddress: testutils.ConnectorAddresses[evmChain.ChainId].Hex(), @@ -160,7 +160,7 @@ func Test_GetUpdatedChainClient(t *testing.T) { observer := MockCoreObserver(t, evmChain, btcChain, evmChainParams, btcChainParams) coreContext := CreateCoreContext(evmChain, btcChain, evmChainParamsNew, btcChainParams) // BSC chain client should not be found - _, err := observer.GetUpdatedChainClient(coreContext, chains.BscMainnetChain().ChainId) + _, err := observer.GetUpdatedChainClient(coreContext, chains.BscMainnetChain.ChainId) require.ErrorContains(t, err, "chain client not found") }) t.Run("chain params in evm chain client should be updated successfully", func(t *testing.T) { @@ -176,7 +176,7 @@ func Test_GetUpdatedChainClient(t *testing.T) { observer := MockCoreObserver(t, evmChain, btcChain, evmChainParams, btcChainParams) coreContext := CreateCoreContext(btcChain, btcChain, evmChainParams, btcChainParamsNew) // BTC testnet chain client should not be found - _, err := observer.GetUpdatedChainClient(coreContext, chains.BtcTestNetChain().ChainId) + _, err := observer.GetUpdatedChainClient(coreContext, chains.BtcTestNetChain.ChainId) require.ErrorContains(t, err, "chain client not found") }) t.Run("chain params in btc chain client should be updated successfully", func(t *testing.T) { From d865311cd4a981c29bb4be7dadf6a01a914871dd Mon Sep 17 00:00:00 2001 From: Tanmay Date: Wed, 24 Apr 2024 12:41:36 -0400 Subject: [PATCH 11/31] generate files 3 --- docs/openapi/openapi.swagger.yaml | 46 +++++++++---------- pkg/chains/chains.go | 1 - typescript/pkg/chains/chains_pb.d.ts | 68 ++++++++++++++-------------- 3 files changed, 57 insertions(+), 58 deletions(-) diff --git a/docs/openapi/openapi.swagger.yaml b/docs/openapi/openapi.swagger.yaml index dbdf3206a3..2bcfa77836 100644 --- a/docs/openapi/openapi.swagger.yaml +++ b/docs/openapi/openapi.swagger.yaml @@ -53629,44 +53629,44 @@ definitions: chainsConsensus: type: string enum: - - Ethereum - - Tendermint - - Bitcoin - default: Ethereum + - ethereum + - tendermint + - bitcoin + default: ethereum title: Consensus represents the consensus algorithm used by the chain chainsNetwork: type: string enum: - - ETH - - ZETA - - BTC - - POLYGON - - BSC - default: ETH + - eth + - zeta + - btc + - polygon + - bsc + default: eth title: Network represents the network type of the chain chainsNetworkType: type: string enum: - - MAINNET - - TESTNET - - PRIVNET - - DEVNET - default: MAINNET + - mainnet + - testnet + - privnet + - devnet + default: mainnet title: NetworkType represents the network type of the chain chainsReceiveStatus: type: string enum: - - Created - - Success - - Failed - default: Created - title: '- Created: some observer sees inbound tx' + - created + - success + - failed + default: created + title: '- created: some observer sees inbound tx' chainsVm: type: string enum: - - NO_VM - - EVM - default: NO_VM + - no_vm + - evm + default: no_vm title: Vm represents the virtual machine type of the chain to support smart contracts coinCoinType: type: string diff --git a/pkg/chains/chains.go b/pkg/chains/chains.go index f0ea599aa2..325df881d6 100644 --- a/pkg/chains/chains.go +++ b/pkg/chains/chains.go @@ -258,7 +258,6 @@ func ChainListByConsensus(consensus Consensus) []*Chain { } } return chainList - } // ChainListForHeaderSupport returns a list of chains that support headers diff --git a/typescript/pkg/chains/chains_pb.d.ts b/typescript/pkg/chains/chains_pb.d.ts index 59cdb82475..9b1262b8ed 100644 --- a/typescript/pkg/chains/chains_pb.d.ts +++ b/typescript/pkg/chains/chains_pb.d.ts @@ -13,19 +13,19 @@ export declare enum ReceiveStatus { /** * some observer sees inbound tx * - * @generated from enum value: Created = 0; + * @generated from enum value: created = 0; */ - Created = 0, + created = 0, /** - * @generated from enum value: Success = 1; + * @generated from enum value: success = 1; */ - Success = 1, + success = 1, /** - * @generated from enum value: Failed = 2; + * @generated from enum value: failed = 2; */ - Failed = 2, + failed = 2, } /** @@ -127,29 +127,29 @@ export declare enum ChainName { */ export declare enum Network { /** - * @generated from enum value: ETH = 0; + * @generated from enum value: eth = 0; */ - ETH = 0, + eth = 0, /** - * @generated from enum value: ZETA = 1; + * @generated from enum value: zeta = 1; */ - ZETA = 1, + zeta = 1, /** - * @generated from enum value: BTC = 2; + * @generated from enum value: btc = 2; */ - BTC = 2, + btc = 2, /** - * @generated from enum value: POLYGON = 3; + * @generated from enum value: polygon = 3; */ - POLYGON = 3, + polygon = 3, /** - * @generated from enum value: BSC = 4; + * @generated from enum value: bsc = 4; */ - BSC = 4, + bsc = 4, } /** @@ -159,24 +159,24 @@ export declare enum Network { */ export declare enum NetworkType { /** - * @generated from enum value: MAINNET = 0; + * @generated from enum value: mainnet = 0; */ - MAINNET = 0, + mainnet = 0, /** - * @generated from enum value: TESTNET = 1; + * @generated from enum value: testnet = 1; */ - TESTNET = 1, + testnet = 1, /** - * @generated from enum value: PRIVNET = 2; + * @generated from enum value: privnet = 2; */ - PRIVNET = 2, + privnet = 2, /** - * @generated from enum value: DEVNET = 3; + * @generated from enum value: devnet = 3; */ - DEVNET = 3, + devnet = 3, } /** @@ -186,14 +186,14 @@ export declare enum NetworkType { */ export declare enum Vm { /** - * @generated from enum value: NO_VM = 0; + * @generated from enum value: no_vm = 0; */ - NO_VM = 0, + no_vm = 0, /** - * @generated from enum value: EVM = 1; + * @generated from enum value: evm = 1; */ - EVM = 1, + evm = 1, } /** @@ -203,19 +203,19 @@ export declare enum Vm { */ export declare enum Consensus { /** - * @generated from enum value: Ethereum = 0; + * @generated from enum value: ethereum = 0; */ - Ethereum = 0, + ethereum = 0, /** - * @generated from enum value: Tendermint = 1; + * @generated from enum value: tendermint = 1; */ - Tendermint = 1, + tendermint = 1, /** - * @generated from enum value: Bitcoin = 2; + * @generated from enum value: bitcoin = 2; */ - Bitcoin = 2, + bitcoin = 2, } /** From 4a82d4508b940968d94866afff563d07855dd33b Mon Sep 17 00:00:00 2001 From: Tanmay Date: Thu, 25 Apr 2024 15:12:51 -0400 Subject: [PATCH 12/31] add section for v15.0.0 in changelog.md --- changelog.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/changelog.md b/changelog.md index 060d789968..d380466d0f 100644 --- a/changelog.md +++ b/changelog.md @@ -1,6 +1,7 @@ # CHANGELOG -## Unreleased +# Unreleased + ### Breaking Changes * Admin policies have been moved from `observer` to a new module `authority`. @@ -60,6 +61,8 @@ * [2046](https://github.com/zeta-chain/node/pull/2046) - add state variable in crosschain for rate limiter flags * [2034](https://github.com/zeta-chain/node/pull/2034) - add support for zEVM message passing + + ### Tests * [1767](https://github.com/zeta-chain/node/pull/1767) - add unit tests for emissions module begin blocker @@ -112,8 +115,7 @@ ## Version: v15.0.0 ### Features - -*[1912](https://github.com/zeta-chain/node/pull/1912) - add reset chain nonces msg +* [1912](https://github.com/zeta-chain/node/pull/1912) - add reset chain nonces msg ## Version: v14.0.1 From 9fcaeef0c17a65a7d744b9ef366f13d253d343a5 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Fri, 26 Apr 2024 00:40:18 -0400 Subject: [PATCH 13/31] add issue for removing pointers from chain list functions --- pkg/chains/chains.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/chains/chains.go b/pkg/chains/chains.go index 325df881d6..8a69e3ebf0 100644 --- a/pkg/chains/chains.go +++ b/pkg/chains/chains.go @@ -292,6 +292,8 @@ func ZetaChainFromChainID(chainID string) (Chain, error) { } } +// TODO : https://github.com/zeta-chain/node/issues/2080 +// remove the usage of this function // chainListPointers returns a list of chain pointers func chainListPointers(chains []Chain) []*Chain { var c []*Chain From 00eec8ebd708d6dd5607a976fb579b51a899ca32 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Fri, 26 Apr 2024 12:02:44 -0400 Subject: [PATCH 14/31] modify verification flags --- e2e/txserver/zeta_tx_server.go | 5 +- pkg/chains/chains.go | 242 +++--- pkg/chains/chains.pb.go | 136 ++-- pkg/chains/chains_test.go | 242 +++--- proto/lightclient/genesis.proto | 2 +- proto/lightclient/query.proto | 2 +- proto/lightclient/tx.proto | 15 +- proto/lightclient/verification_flags.proto | 6 +- proto/pkg/chains/chains.proto | 1 - testutil/sample/lightclient.go | 14 +- .../cli/tx_disable_verification_flags.go | 51 ++ .../cli/tx_enable_verification_flags.go | 51 ++ .../cli/tx_update_verification_flags.go | 41 -- x/lightclient/genesis.go | 13 +- x/lightclient/genesis_test.go | 7 +- x/lightclient/keeper/block_header_test.go | 26 +- .../keeper/grpc_query_verification_flags.go | 5 +- .../grpc_query_verification_flags_test.go | 20 +- .../msg_server_disable_verification_flags.go | 28 + ..._server_disable_verification_flags_test.go | 99 +++ ...> msg_server_enable_verification_flags.go} | 18 +- ...g_server_enable_verification_flags_test.go | 98 +++ ...g_server_update_verification_flags_test.go | 142 ---- x/lightclient/keeper/proof_test.go | 60 +- x/lightclient/keeper/verification_flags.go | 61 +- .../keeper/verification_flags_test.go | 31 +- x/lightclient/types/codec.go | 8 +- x/lightclient/types/genesis.go | 9 +- x/lightclient/types/genesis.pb.go | 53 +- x/lightclient/types/genesis_test.go | 5 +- .../message_disable_verification_flags.go | 63 ++ ...message_disable_verification_flags_test.go | 140 ++++ .../message_enable_verification_flags.go | 63 ++ .../message_enable_verification_flags_test.go | 140 ++++ .../message_update_verification_flags.go | 62 -- .../message_update_verification_flags_test.go | 173 ----- x/lightclient/types/query.pb.go | 75 +- x/lightclient/types/tx.pb.go | 687 +++++++++++++++--- x/lightclient/types/verification_flags.go | 32 +- x/lightclient/types/verification_flags.pb.go | 66 +- .../types/verification_flags_test.go | 21 +- zetaclient/bitcoin/bitcoin_client.go | 4 +- zetaclient/core_context/zeta_core_context.go | 21 +- .../core_context/zeta_core_context_test.go | 6 +- zetaclient/evm/evm_client.go | 4 +- zetaclient/zetabridge/query.go | 4 +- zetaclient/zetabridge/query_test.go | 14 +- zetaclient/zetabridge/tx_test.go | 14 +- 48 files changed, 1959 insertions(+), 1121 deletions(-) create mode 100644 x/lightclient/client/cli/tx_disable_verification_flags.go create mode 100644 x/lightclient/client/cli/tx_enable_verification_flags.go delete mode 100644 x/lightclient/client/cli/tx_update_verification_flags.go create mode 100644 x/lightclient/keeper/msg_server_disable_verification_flags.go create mode 100644 x/lightclient/keeper/msg_server_disable_verification_flags_test.go rename x/lightclient/keeper/{msg_server_update_verification_flags.go => msg_server_enable_verification_flags.go} (50%) create mode 100644 x/lightclient/keeper/msg_server_enable_verification_flags_test.go delete mode 100644 x/lightclient/keeper/msg_server_update_verification_flags_test.go create mode 100644 x/lightclient/types/message_disable_verification_flags.go create mode 100644 x/lightclient/types/message_disable_verification_flags_test.go create mode 100644 x/lightclient/types/message_enable_verification_flags.go create mode 100644 x/lightclient/types/message_enable_verification_flags_test.go delete mode 100644 x/lightclient/types/message_update_verification_flags.go delete mode 100644 x/lightclient/types/message_update_verification_flags_test.go diff --git a/e2e/txserver/zeta_tx_server.go b/e2e/txserver/zeta_tx_server.go index 8014bd2b48..352c6b7482 100644 --- a/e2e/txserver/zeta_tx_server.go +++ b/e2e/txserver/zeta_tx_server.go @@ -262,10 +262,9 @@ func (zts ZetaTxServer) EnableVerificationFlags(account string) error { return err } - _, err = zts.BroadcastTx(account, lightclienttypes.NewMsgUpdateVerificationFlags( + _, err = zts.BroadcastTx(account, lightclienttypes.NewMsgEnableVerificationFlags( addr.String(), - true, - true, + []int64{chains.GoerliLocalnetChain.ChainId}, )) return err diff --git a/pkg/chains/chains.go b/pkg/chains/chains.go index 8a69e3ebf0..4e7d71daa4 100644 --- a/pkg/chains/chains.go +++ b/pkg/chains/chains.go @@ -21,172 +21,156 @@ var ( // Mainnet chains ZetaChainMainnet = Chain{ - ChainName: ChainName_zeta_mainnet, - ChainId: 7000, - Network: Network_zeta, - NetworkType: NetworkType_mainnet, - Vm: Vm_evm, - Consensus: Consensus_tendermint, - IsExternal: false, - IsHeaderSupported: false, + ChainName: ChainName_zeta_mainnet, + ChainId: 7000, + Network: Network_zeta, + NetworkType: NetworkType_mainnet, + Vm: Vm_evm, + Consensus: Consensus_tendermint, + IsExternal: false, } EthChain = Chain{ - ChainName: ChainName_eth_mainnet, - ChainId: 1, - Network: Network_eth, - NetworkType: NetworkType_mainnet, - Vm: Vm_evm, - Consensus: Consensus_ethereum, - IsExternal: true, - IsHeaderSupported: true, + ChainName: ChainName_eth_mainnet, + ChainId: 1, + Network: Network_eth, + NetworkType: NetworkType_mainnet, + Vm: Vm_evm, + Consensus: Consensus_ethereum, + IsExternal: true, } BscMainnetChain = Chain{ - ChainName: ChainName_bsc_mainnet, - ChainId: 56, - Network: Network_bsc, - NetworkType: NetworkType_mainnet, - Vm: Vm_evm, - Consensus: Consensus_ethereum, - IsExternal: true, - IsHeaderSupported: true, + ChainName: ChainName_bsc_mainnet, + ChainId: 56, + Network: Network_bsc, + NetworkType: NetworkType_mainnet, + Vm: Vm_evm, + Consensus: Consensus_ethereum, + IsExternal: true, } BtcMainnetChain = Chain{ - ChainName: ChainName_btc_mainnet, - ChainId: 8332, - Network: Network_btc, - NetworkType: NetworkType_mainnet, - Vm: Vm_no_vm, - Consensus: Consensus_bitcoin, - IsExternal: true, - IsHeaderSupported: false, + ChainName: ChainName_btc_mainnet, + ChainId: 8332, + Network: Network_btc, + NetworkType: NetworkType_mainnet, + Vm: Vm_no_vm, + Consensus: Consensus_bitcoin, + IsExternal: true, } PolygonChain = Chain{ - ChainName: ChainName_polygon_mainnet, - ChainId: 137, - Network: Network_polygon, - NetworkType: NetworkType_mainnet, - Vm: Vm_evm, - Consensus: Consensus_ethereum, - IsExternal: true, - IsHeaderSupported: false, + ChainName: ChainName_polygon_mainnet, + ChainId: 137, + Network: Network_polygon, + NetworkType: NetworkType_mainnet, + Vm: Vm_evm, + Consensus: Consensus_ethereum, + IsExternal: true, } // Testnet chains ZetaTestnetChain = Chain{ - ChainName: ChainName_zeta_testnet, - ChainId: 7001, - Network: Network_zeta, - NetworkType: NetworkType_testnet, - Vm: Vm_evm, - Consensus: Consensus_tendermint, - IsExternal: false, - IsHeaderSupported: false, + ChainName: ChainName_zeta_testnet, + ChainId: 7001, + Network: Network_zeta, + NetworkType: NetworkType_testnet, + Vm: Vm_evm, + Consensus: Consensus_tendermint, + IsExternal: false, } SepoliaChain = Chain{ - ChainName: ChainName_sepolia_testnet, - ChainId: 11155111, - Network: Network_eth, - NetworkType: NetworkType_testnet, - Vm: Vm_evm, - Consensus: Consensus_ethereum, - IsExternal: true, - IsHeaderSupported: true, + ChainName: ChainName_sepolia_testnet, + ChainId: 11155111, + Network: Network_eth, + NetworkType: NetworkType_testnet, + Vm: Vm_evm, + Consensus: Consensus_ethereum, + IsExternal: true, } BscTestnetChain = Chain{ - ChainName: ChainName_bsc_testnet, - ChainId: 97, - Network: Network_bsc, - NetworkType: NetworkType_testnet, - Vm: Vm_evm, - Consensus: Consensus_ethereum, - IsExternal: true, - IsHeaderSupported: true, + ChainName: ChainName_bsc_testnet, + ChainId: 97, + Network: Network_bsc, + NetworkType: NetworkType_testnet, + Vm: Vm_evm, + Consensus: Consensus_ethereum, + IsExternal: true, } BtcTestNetChain = Chain{ - ChainName: ChainName_btc_testnet, - ChainId: 18332, - Network: Network_btc, - NetworkType: NetworkType_testnet, - Vm: Vm_no_vm, - Consensus: Consensus_bitcoin, - IsExternal: true, - IsHeaderSupported: false, + ChainName: ChainName_btc_testnet, + ChainId: 18332, + Network: Network_btc, + NetworkType: NetworkType_testnet, + Vm: Vm_no_vm, + Consensus: Consensus_bitcoin, + IsExternal: true, } AmoyChain = Chain{ - ChainName: ChainName_amoy_testnet, - ChainId: 80002, - Network: Network_polygon, - NetworkType: NetworkType_testnet, - Vm: Vm_evm, - Consensus: Consensus_ethereum, - IsExternal: true, - IsHeaderSupported: false, + ChainName: ChainName_amoy_testnet, + ChainId: 80002, + Network: Network_polygon, + NetworkType: NetworkType_testnet, + Vm: Vm_evm, + Consensus: Consensus_ethereum, + IsExternal: true, } // Devnet chains ZetaMocknetChain = Chain{ - ChainName: ChainName_zeta_mainnet, - ChainId: 70000, - Network: Network_zeta, - NetworkType: NetworkType_devnet, - Vm: Vm_evm, - Consensus: Consensus_tendermint, - IsExternal: false, - IsHeaderSupported: false, + ChainName: ChainName_zeta_mainnet, + ChainId: 70000, + Network: Network_zeta, + NetworkType: NetworkType_devnet, + Vm: Vm_evm, + Consensus: Consensus_tendermint, + IsExternal: false, } // Privnet chains ZetaPrivnetChain = Chain{ - ChainName: ChainName_zeta_mainnet, - ChainId: 101, - Network: Network_zeta, - NetworkType: NetworkType_privnet, - Vm: Vm_evm, - Consensus: Consensus_tendermint, - IsExternal: false, - IsHeaderSupported: false, + ChainName: ChainName_zeta_mainnet, + ChainId: 101, + Network: Network_zeta, + NetworkType: NetworkType_privnet, + Vm: Vm_evm, + Consensus: Consensus_tendermint, + IsExternal: false, } BtcRegtestChain = Chain{ - ChainName: ChainName_btc_regtest, - ChainId: 18444, - Network: Network_btc, - NetworkType: NetworkType_privnet, - Vm: Vm_no_vm, - Consensus: Consensus_bitcoin, - IsExternal: true, - IsHeaderSupported: false, + ChainName: ChainName_btc_regtest, + ChainId: 18444, + Network: Network_btc, + NetworkType: NetworkType_privnet, + Vm: Vm_no_vm, + Consensus: Consensus_bitcoin, + IsExternal: true, } GoerliLocalnetChain = Chain{ - ChainName: ChainName_goerli_localnet, - ChainId: 1337, - Network: Network_eth, - NetworkType: NetworkType_privnet, - Vm: Vm_evm, - Consensus: Consensus_ethereum, - IsExternal: true, - IsHeaderSupported: true, + ChainName: ChainName_goerli_localnet, + ChainId: 1337, + Network: Network_eth, + NetworkType: NetworkType_privnet, + Vm: Vm_evm, + Consensus: Consensus_ethereum, + IsExternal: true, } // Deprecated testnet chains GoerliChain = Chain{ - ChainName: ChainName_goerli_testnet, - ChainId: 5, - Network: Network_eth, - NetworkType: NetworkType_testnet, - Vm: Vm_evm, - Consensus: Consensus_ethereum, - IsExternal: true, - IsHeaderSupported: true, + ChainName: ChainName_goerli_testnet, + ChainId: 5, + Network: Network_eth, + NetworkType: NetworkType_testnet, + Vm: Vm_evm, + Consensus: Consensus_ethereum, + IsExternal: true, } MumbaiChain = Chain{ - ChainName: ChainName_mumbai_testnet, - ChainId: 80001, - Network: Network_polygon, - NetworkType: NetworkType_testnet, - Vm: Vm_evm, - Consensus: Consensus_ethereum, - IsExternal: true, - IsHeaderSupported: false, + ChainName: ChainName_mumbai_testnet, + ChainId: 80001, + Network: Network_polygon, + NetworkType: NetworkType_testnet, + Vm: Vm_evm, + Consensus: Consensus_ethereum, + IsExternal: true, } ) @@ -264,7 +248,7 @@ func ChainListByConsensus(consensus Consensus) []*Chain { func ChainListForHeaderSupport() []*Chain { var chainList []*Chain for _, chain := range DefaultChainsList() { - if chain.IsHeaderSupported { + if chain.Consensus == Consensus_ethereum { chainList = append(chainList, chain) } } diff --git a/pkg/chains/chains.pb.go b/pkg/chains/chains.pb.go index 899548b4be..373fa9d77c 100644 --- a/pkg/chains/chains.pb.go +++ b/pkg/chains/chains.pb.go @@ -246,14 +246,13 @@ func (Consensus) EnumDescriptor() ([]byte, []int) { } type Chain struct { - ChainName ChainName `protobuf:"varint,1,opt,name=chain_name,json=chainName,proto3,enum=chains.ChainName" json:"chain_name,omitempty"` - ChainId int64 `protobuf:"varint,2,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` - Network Network `protobuf:"varint,3,opt,name=network,proto3,enum=chains.Network" json:"network,omitempty"` - NetworkType NetworkType `protobuf:"varint,4,opt,name=network_type,json=networkType,proto3,enum=chains.NetworkType" json:"network_type,omitempty"` - Vm Vm `protobuf:"varint,5,opt,name=vm,proto3,enum=chains.Vm" json:"vm,omitempty"` - Consensus Consensus `protobuf:"varint,6,opt,name=consensus,proto3,enum=chains.Consensus" json:"consensus,omitempty"` - IsExternal bool `protobuf:"varint,7,opt,name=is_external,json=isExternal,proto3" json:"is_external,omitempty"` - IsHeaderSupported bool `protobuf:"varint,8,opt,name=is_header_supported,json=isHeaderSupported,proto3" json:"is_header_supported,omitempty"` + ChainName ChainName `protobuf:"varint,1,opt,name=chain_name,json=chainName,proto3,enum=chains.ChainName" json:"chain_name,omitempty"` + ChainId int64 `protobuf:"varint,2,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` + Network Network `protobuf:"varint,3,opt,name=network,proto3,enum=chains.Network" json:"network,omitempty"` + NetworkType NetworkType `protobuf:"varint,4,opt,name=network_type,json=networkType,proto3,enum=chains.NetworkType" json:"network_type,omitempty"` + Vm Vm `protobuf:"varint,5,opt,name=vm,proto3,enum=chains.Vm" json:"vm,omitempty"` + Consensus Consensus `protobuf:"varint,6,opt,name=consensus,proto3,enum=chains.Consensus" json:"consensus,omitempty"` + IsExternal bool `protobuf:"varint,7,opt,name=is_external,json=isExternal,proto3" json:"is_external,omitempty"` } func (m *Chain) Reset() { *m = Chain{} } @@ -338,13 +337,6 @@ func (m *Chain) GetIsExternal() bool { return false } -func (m *Chain) GetIsHeaderSupported() bool { - if m != nil { - return m.IsHeaderSupported - } - return false -} - func init() { proto.RegisterEnum("chains.ReceiveStatus", ReceiveStatus_name, ReceiveStatus_value) proto.RegisterEnum("chains.ChainName", ChainName_name, ChainName_value) @@ -358,47 +350,46 @@ func init() { func init() { proto.RegisterFile("pkg/chains/chains.proto", fileDescriptor_37ad35e0488e8bbc) } var fileDescriptor_37ad35e0488e8bbc = []byte{ - // 634 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x94, 0x4f, 0x6f, 0xd3, 0x30, - 0x14, 0xc0, 0x9b, 0xf4, 0xff, 0x6b, 0xd7, 0x66, 0x1e, 0x12, 0x61, 0x87, 0x30, 0x71, 0xda, 0x26, - 0xd1, 0x22, 0x90, 0xb8, 0xc0, 0x05, 0x26, 0x10, 0x5c, 0x76, 0xc8, 0xd0, 0x0e, 0x5c, 0x22, 0x27, - 0x79, 0xa4, 0xd6, 0x6a, 0x3b, 0x8a, 0xdd, 0x42, 0xf9, 0x14, 0x7c, 0x08, 0x0e, 0x7c, 0x94, 0x1d, - 0x77, 0x41, 0xe2, 0x88, 0xb6, 0x2f, 0x82, 0xec, 0xc6, 0x29, 0xda, 0xa9, 0xcf, 0xbf, 0xf7, 0xf3, - 0xf3, 0x8b, 0xed, 0x1a, 0x1e, 0x96, 0x57, 0xc5, 0x3c, 0x5b, 0x50, 0x26, 0x54, 0xfd, 0x33, 0x2b, - 0x2b, 0xa9, 0x25, 0xe9, 0x6d, 0x47, 0x87, 0x0f, 0x0a, 0x59, 0x48, 0x8b, 0xe6, 0x26, 0xda, 0x66, - 0x9f, 0xfc, 0xf6, 0xa1, 0x7b, 0x66, 0x04, 0xf2, 0x0c, 0xc0, 0x9a, 0x89, 0xa0, 0x1c, 0x43, 0xef, - 0xc8, 0x3b, 0x9e, 0x3c, 0xdf, 0x9f, 0xd5, 0xa5, 0xac, 0x72, 0x4e, 0x39, 0xc6, 0xc3, 0xcc, 0x85, - 0xe4, 0x11, 0x0c, 0xb6, 0x33, 0x58, 0x1e, 0xfa, 0x47, 0xde, 0x71, 0x3b, 0xee, 0xdb, 0xf1, 0xc7, - 0x9c, 0x9c, 0x40, 0x5f, 0xa0, 0xfe, 0x2a, 0xab, 0xab, 0xb0, 0x6d, 0x2b, 0x4d, 0x5d, 0xa5, 0xf3, - 0x2d, 0x8e, 0x5d, 0x9e, 0xbc, 0x84, 0x71, 0x1d, 0x26, 0x7a, 0x53, 0x62, 0xd8, 0xb1, 0xfe, 0xc1, - 0x3d, 0xff, 0xd3, 0xa6, 0xc4, 0x78, 0x24, 0x76, 0x03, 0x72, 0x08, 0xfe, 0x9a, 0x87, 0x5d, 0x6b, - 0x83, 0xb3, 0x2f, 0x79, 0xec, 0xaf, 0x39, 0x99, 0xc3, 0x30, 0x93, 0x42, 0xa1, 0x50, 0x2b, 0x15, - 0xf6, 0xee, 0x7d, 0x8a, 0x4b, 0xc4, 0x3b, 0x87, 0x3c, 0x86, 0x11, 0x53, 0x09, 0x7e, 0xd3, 0x58, - 0x09, 0xba, 0x0c, 0xfb, 0x47, 0xde, 0xf1, 0x20, 0x06, 0xa6, 0xde, 0xd5, 0x84, 0xcc, 0xe0, 0x80, - 0xa9, 0x64, 0x81, 0x34, 0xc7, 0x2a, 0x51, 0xab, 0xb2, 0x94, 0x95, 0xc6, 0x3c, 0x1c, 0x58, 0x71, - 0x9f, 0xa9, 0x0f, 0x36, 0x73, 0xe1, 0x12, 0xa7, 0xaf, 0x60, 0x2f, 0xc6, 0x0c, 0xd9, 0x1a, 0x2f, - 0x34, 0xd5, 0x2b, 0x45, 0x46, 0xd0, 0xcf, 0x2a, 0xa4, 0x1a, 0xf3, 0xa0, 0x65, 0x06, 0x6a, 0x95, - 0x65, 0xa8, 0x54, 0xe0, 0x11, 0x80, 0xde, 0x17, 0xca, 0x96, 0x98, 0x07, 0xfe, 0x61, 0xe7, 0xd7, - 0xcf, 0xc8, 0x3b, 0xbd, 0xf6, 0x61, 0xd8, 0xec, 0x38, 0x19, 0x42, 0x17, 0x79, 0xa9, 0x37, 0x41, - 0x8b, 0x4c, 0x61, 0x84, 0x7a, 0x91, 0x70, 0xca, 0x84, 0x40, 0x1d, 0x78, 0x24, 0x80, 0xf1, 0x77, - 0xd4, 0xb4, 0x21, 0xbe, 0x51, 0x52, 0x9d, 0x35, 0xa0, 0x4d, 0x0e, 0x60, 0x5a, 0xca, 0xe5, 0xa6, - 0x90, 0xa2, 0x81, 0x1d, 0x6b, 0xa9, 0x9d, 0xd5, 0x25, 0x04, 0x26, 0x85, 0xc4, 0x6a, 0xc9, 0x12, - 0x8d, 0x4a, 0x1b, 0xd6, 0x33, 0x8c, 0xaf, 0x78, 0x4a, 0x77, 0xac, 0x6f, 0xaa, 0x15, 0x54, 0xd0, - 0x6c, 0x81, 0x0d, 0x1c, 0x18, 0x31, 0xa5, 0x32, 0xa5, 0x69, 0xc3, 0x86, 0x6e, 0x05, 0x07, 0xa0, - 0x69, 0xd5, 0x91, 0x91, 0x6b, 0xd5, 0x81, 0xb1, 0x29, 0xae, 0xb0, 0x94, 0x4b, 0xb6, 0xb3, 0xf6, - 0xec, 0x8a, 0xdb, 0xce, 0x96, 0x32, 0xa3, 0x4b, 0x03, 0x27, 0x6e, 0x6a, 0x85, 0x85, 0x11, 0x83, - 0xa9, 0xa9, 0x4e, 0xb9, 0xdc, 0x34, 0xf3, 0x82, 0x7a, 0x2b, 0xdf, 0x40, 0xbf, 0xbe, 0x41, 0xa4, - 0x0f, 0x6d, 0xd4, 0x8b, 0xa0, 0x45, 0x06, 0xd0, 0x31, 0x9d, 0x04, 0x9e, 0x41, 0xa9, 0xce, 0x02, - 0xdf, 0x1c, 0x48, 0xbd, 0x49, 0x41, 0xdb, 0x52, 0x95, 0x05, 0x9d, 0xba, 0xc4, 0x7b, 0x18, 0xfd, - 0x77, 0x09, 0x8d, 0xea, 0xb6, 0xcd, 0x1e, 0xa4, 0x5b, 0xd1, 0xb3, 0x45, 0x2a, 0xb6, 0xde, 0x9e, - 0x03, 0x40, 0x2f, 0x47, 0x1b, 0xb7, 0xeb, 0x3a, 0x11, 0xf8, 0x97, 0xdc, 0x9c, 0xa6, 0x90, 0xc9, - 0x9a, 0x07, 0x2d, 0xdb, 0xd0, 0x9a, 0x07, 0x5e, 0x9d, 0x7f, 0x0d, 0xc3, 0xe6, 0x6e, 0x92, 0x31, - 0x0c, 0x50, 0x2f, 0xb0, 0xc2, 0x95, 0x31, 0x27, 0x00, 0x1a, 0x45, 0x8e, 0x15, 0x67, 0xa2, 0x5e, - 0x29, 0x65, 0x3a, 0x93, 0x4c, 0xb8, 0x3b, 0xf3, 0xf6, 0xec, 0xfa, 0x36, 0xf2, 0x6e, 0x6e, 0x23, - 0xef, 0xef, 0x6d, 0xe4, 0xfd, 0xb8, 0x8b, 0x5a, 0x37, 0x77, 0x51, 0xeb, 0xcf, 0x5d, 0xd4, 0xfa, - 0x7c, 0x52, 0x30, 0xbd, 0x58, 0xa5, 0xb3, 0x4c, 0xf2, 0xb9, 0xf9, 0xee, 0xa7, 0xf6, 0x8f, 0x60, - 0xc3, 0x4c, 0x56, 0x38, 0xdf, 0x3d, 0x1c, 0x69, 0xcf, 0x3e, 0x0a, 0x2f, 0xfe, 0x05, 0x00, 0x00, - 0xff, 0xff, 0x2a, 0xc3, 0x74, 0x63, 0x4d, 0x04, 0x00, 0x00, + // 609 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x94, 0xcf, 0x6e, 0x13, 0x3b, + 0x14, 0xc6, 0x33, 0x93, 0xff, 0x27, 0x69, 0xe2, 0xeb, 0x5e, 0xe9, 0xe6, 0x76, 0x31, 0xb7, 0xba, + 0xab, 0xb6, 0x12, 0x0d, 0x02, 0x89, 0x0d, 0x6c, 0xa0, 0x02, 0x89, 0x4d, 0x17, 0x03, 0xea, 0x82, + 0x4d, 0xe4, 0x71, 0x0e, 0x13, 0xab, 0x63, 0x7b, 0x34, 0x76, 0x02, 0xe1, 0x29, 0x78, 0x08, 0x90, + 0x78, 0x94, 0x2e, 0xbb, 0x64, 0x89, 0xda, 0x17, 0x41, 0x76, 0xc6, 0x13, 0xd4, 0x55, 0x8e, 0x7f, + 0xfe, 0xfc, 0xf9, 0xf8, 0x9c, 0x93, 0x81, 0x7f, 0xca, 0xeb, 0x7c, 0xce, 0x57, 0x4c, 0x28, 0x53, + 0xff, 0x9c, 0x97, 0x95, 0xb6, 0x9a, 0xf6, 0x76, 0xab, 0xa3, 0xbf, 0x73, 0x9d, 0x6b, 0x8f, 0xe6, + 0x2e, 0xda, 0xed, 0xfe, 0xff, 0x3d, 0x86, 0xee, 0x85, 0x13, 0xd0, 0xc7, 0x00, 0x5e, 0xb9, 0x50, + 0x4c, 0xe2, 0x2c, 0x3a, 0x8e, 0x4e, 0x26, 0x4f, 0xfe, 0x3a, 0xaf, 0xad, 0xbc, 0xe4, 0x92, 0x49, + 0x4c, 0x87, 0x3c, 0x84, 0xf4, 0x5f, 0x18, 0xec, 0x4e, 0x88, 0xe5, 0x2c, 0x3e, 0x8e, 0x4e, 0xda, + 0x69, 0xdf, 0xaf, 0xdf, 0x2e, 0xe9, 0x29, 0xf4, 0x15, 0xda, 0x4f, 0xba, 0xba, 0x9e, 0xb5, 0xbd, + 0xd3, 0x34, 0x38, 0x5d, 0xee, 0x70, 0x1a, 0xf6, 0xe9, 0x33, 0x18, 0xd7, 0xe1, 0xc2, 0x6e, 0x4b, + 0x9c, 0x75, 0xbc, 0xfe, 0xf0, 0x81, 0xfe, 0xfd, 0xb6, 0xc4, 0x74, 0xa4, 0xf6, 0x0b, 0x7a, 0x04, + 0xf1, 0x46, 0xce, 0xba, 0x5e, 0x0d, 0x41, 0x7d, 0x25, 0xd3, 0x78, 0x23, 0xe9, 0x1c, 0x86, 0x5c, + 0x2b, 0x83, 0xca, 0xac, 0xcd, 0xac, 0xf7, 0xe0, 0x29, 0x61, 0x23, 0xdd, 0x6b, 0xe8, 0x7f, 0x30, + 0x12, 0x66, 0x81, 0x9f, 0x2d, 0x56, 0x8a, 0x15, 0xb3, 0xfe, 0x71, 0x74, 0x32, 0x48, 0x41, 0x98, + 0xd7, 0x35, 0x39, 0x7b, 0x0e, 0x07, 0x29, 0x72, 0x14, 0x1b, 0x7c, 0x67, 0x99, 0x5d, 0x1b, 0x3a, + 0x82, 0x3e, 0xaf, 0x90, 0x59, 0x5c, 0x92, 0x96, 0x5b, 0x98, 0x35, 0xe7, 0x68, 0x0c, 0x89, 0x28, + 0x40, 0xef, 0x23, 0x13, 0x05, 0x2e, 0x49, 0x7c, 0xd4, 0xf9, 0xf1, 0x2d, 0x89, 0xce, 0x6e, 0x62, + 0x18, 0x36, 0x15, 0xa4, 0x43, 0xe8, 0xa2, 0x2c, 0xed, 0x96, 0xb4, 0xe8, 0x14, 0x46, 0x68, 0x57, + 0x0b, 0xc9, 0x84, 0x52, 0x68, 0x49, 0x44, 0x09, 0x8c, 0xbf, 0xa0, 0x65, 0x0d, 0x89, 0x9d, 0x24, + 0xb3, 0xbc, 0x01, 0x6d, 0x7a, 0x08, 0xd3, 0x52, 0x17, 0xdb, 0x5c, 0xab, 0x06, 0x76, 0xbc, 0xca, + 0xec, 0x55, 0x5d, 0x4a, 0x61, 0x92, 0x6b, 0xac, 0x0a, 0xb1, 0xb0, 0x68, 0xac, 0x63, 0x3d, 0xc7, + 0xe4, 0x5a, 0x66, 0x6c, 0xcf, 0xfa, 0xce, 0x2d, 0x67, 0x8a, 0xf1, 0x15, 0x36, 0x70, 0xe0, 0x84, + 0x19, 0xd3, 0x19, 0xcb, 0x1a, 0x36, 0x0c, 0x37, 0x04, 0x00, 0x4d, 0xaa, 0x81, 0x8c, 0x42, 0xaa, + 0x01, 0x8c, 0x9d, 0xb9, 0xc1, 0x52, 0x17, 0x62, 0xaf, 0x3a, 0xf0, 0x37, 0xee, 0x32, 0x2b, 0x34, + 0x67, 0x85, 0x83, 0x93, 0x70, 0xb4, 0xc2, 0xdc, 0x09, 0xc9, 0xd4, 0xb9, 0x33, 0xa9, 0xb7, 0xcd, + 0x39, 0x52, 0x97, 0xf2, 0x25, 0xf4, 0xeb, 0x89, 0xa0, 0x7d, 0x68, 0xa3, 0x5d, 0x91, 0x16, 0x1d, + 0x40, 0xc7, 0x65, 0x42, 0x22, 0x87, 0x32, 0xcb, 0x49, 0xec, 0x1a, 0x52, 0x17, 0x89, 0xb4, 0x3d, + 0x35, 0x9c, 0x74, 0x6a, 0x8b, 0x37, 0x30, 0xfa, 0x63, 0xa8, 0x9c, 0x34, 0x94, 0xcd, 0x37, 0x32, + 0xdc, 0x18, 0x79, 0x93, 0x4a, 0x6c, 0x76, 0x7d, 0x00, 0xe8, 0x2d, 0xd1, 0xc7, 0xed, 0xda, 0x27, + 0x81, 0xf8, 0x4a, 0xba, 0x6e, 0x2a, 0xbd, 0xd8, 0x48, 0xd2, 0xf2, 0x09, 0x6d, 0x24, 0x89, 0xea, + 0xfd, 0x17, 0x30, 0x6c, 0x66, 0x8d, 0x8e, 0x61, 0x80, 0x76, 0x85, 0x15, 0xae, 0x9d, 0x72, 0x02, + 0x60, 0x51, 0x2d, 0xb1, 0x92, 0x42, 0xd5, 0x37, 0x65, 0xc2, 0x72, 0x2d, 0x54, 0x98, 0x99, 0x57, + 0x17, 0x37, 0x77, 0x49, 0x74, 0x7b, 0x97, 0x44, 0xbf, 0xee, 0x92, 0xe8, 0xeb, 0x7d, 0xd2, 0xba, + 0xbd, 0x4f, 0x5a, 0x3f, 0xef, 0x93, 0xd6, 0x87, 0xd3, 0x5c, 0xd8, 0xd5, 0x3a, 0x3b, 0xe7, 0x5a, + 0xce, 0xdd, 0xbb, 0x1f, 0xf9, 0xc1, 0xf6, 0x21, 0xd7, 0x15, 0xce, 0xf7, 0x1f, 0x82, 0xac, 0xe7, + 0xff, 0xe4, 0x4f, 0x7f, 0x07, 0x00, 0x00, 0xff, 0xff, 0x33, 0x46, 0xe7, 0x2a, 0x1d, 0x04, 0x00, + 0x00, } func (m *Chain) Marshal() (dAtA []byte, err error) { @@ -421,16 +412,6 @@ func (m *Chain) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.IsHeaderSupported { - i-- - if m.IsHeaderSupported { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x40 - } if m.IsExternal { i-- if m.IsExternal { @@ -512,9 +493,6 @@ func (m *Chain) Size() (n int) { if m.IsExternal { n += 2 } - if m.IsHeaderSupported { - n += 2 - } return n } @@ -687,26 +665,6 @@ func (m *Chain) Unmarshal(dAtA []byte) error { } } m.IsExternal = bool(v != 0) - case 8: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field IsHeaderSupported", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowChains - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.IsHeaderSupported = bool(v != 0) default: iNdEx = preIndex skippy, err := skipChains(dAtA[iNdEx:]) diff --git a/pkg/chains/chains_test.go b/pkg/chains/chains_test.go index 9e1358ad48..e5167948b3 100644 --- a/pkg/chains/chains_test.go +++ b/pkg/chains/chains_test.go @@ -14,166 +14,152 @@ func TestChainRetrievalFunctions(t *testing.T) { expected Chain }{ {"ZetaChainMainnet", ZetaChainMainnet, Chain{ - ChainName: ChainName_zeta_mainnet, - ChainId: 7000, - Network: Network_zeta, - NetworkType: NetworkType_mainnet, - IsExternal: false, - Vm: Vm_evm, - IsHeaderSupported: false, - Consensus: Consensus_tendermint, + ChainName: ChainName_zeta_mainnet, + ChainId: 7000, + Network: Network_zeta, + NetworkType: NetworkType_mainnet, + IsExternal: false, + Vm: Vm_evm, + Consensus: Consensus_tendermint, }, }, {"ZetaTestnetChain", ZetaTestnetChain, Chain{ - ChainName: ChainName_zeta_testnet, - ChainId: 7001, - Network: Network_zeta, - NetworkType: NetworkType_testnet, - IsExternal: false, - Vm: Vm_evm, - IsHeaderSupported: false, - Consensus: Consensus_tendermint, + ChainName: ChainName_zeta_testnet, + ChainId: 7001, + Network: Network_zeta, + NetworkType: NetworkType_testnet, + IsExternal: false, + Vm: Vm_evm, + Consensus: Consensus_tendermint, }, }, {"ZetaMocknetChain", ZetaMocknetChain, Chain{ - ChainName: ChainName_zeta_mainnet, - ChainId: 70000, - Network: Network_zeta, - NetworkType: NetworkType_devnet, - IsExternal: false, - Vm: Vm_evm, - IsHeaderSupported: false, - Consensus: Consensus_tendermint, + ChainName: ChainName_zeta_mainnet, + ChainId: 70000, + Network: Network_zeta, + NetworkType: NetworkType_devnet, + IsExternal: false, + Vm: Vm_evm, + Consensus: Consensus_tendermint, }}, {"ZetaPrivnetChain", ZetaPrivnetChain, Chain{ - ChainName: ChainName_zeta_mainnet, - ChainId: 101, - Network: Network_zeta, - NetworkType: NetworkType_privnet, - IsExternal: false, - Vm: Vm_evm, - IsHeaderSupported: false, - Consensus: Consensus_tendermint, + ChainName: ChainName_zeta_mainnet, + ChainId: 101, + Network: Network_zeta, + NetworkType: NetworkType_privnet, + IsExternal: false, + Vm: Vm_evm, + Consensus: Consensus_tendermint, }}, {"EthChain", EthChain, Chain{ - ChainName: ChainName_eth_mainnet, - ChainId: 1, - Network: Network_eth, - NetworkType: NetworkType_mainnet, - IsExternal: true, - Vm: Vm_evm, - IsHeaderSupported: true, - Consensus: Consensus_ethereum, + ChainName: ChainName_eth_mainnet, + ChainId: 1, + Network: Network_eth, + NetworkType: NetworkType_mainnet, + IsExternal: true, + Vm: Vm_evm, + Consensus: Consensus_ethereum, }}, {"BscMainnetChain", BscMainnetChain, Chain{ - ChainName: ChainName_bsc_mainnet, - ChainId: 56, - Network: Network_bsc, - NetworkType: NetworkType_mainnet, - IsExternal: true, - Vm: Vm_evm, - IsHeaderSupported: true, - Consensus: Consensus_ethereum, + ChainName: ChainName_bsc_mainnet, + ChainId: 56, + Network: Network_bsc, + NetworkType: NetworkType_mainnet, + IsExternal: true, + Vm: Vm_evm, + Consensus: Consensus_ethereum, }}, {"BtcMainnetChain", BtcMainnetChain, Chain{ - ChainName: ChainName_btc_mainnet, - ChainId: 8332, - Network: Network_btc, - NetworkType: NetworkType_mainnet, - IsExternal: true, - Vm: Vm_no_vm, - IsHeaderSupported: false, - Consensus: Consensus_bitcoin, + ChainName: ChainName_btc_mainnet, + ChainId: 8332, + Network: Network_btc, + NetworkType: NetworkType_mainnet, + IsExternal: true, + Vm: Vm_no_vm, + Consensus: Consensus_bitcoin, }}, {"PolygonChain", PolygonChain, Chain{ - ChainName: ChainName_polygon_mainnet, - ChainId: 137, - Network: Network_polygon, - NetworkType: NetworkType_mainnet, - IsExternal: true, - Vm: Vm_evm, - IsHeaderSupported: false, - Consensus: Consensus_ethereum, + ChainName: ChainName_polygon_mainnet, + ChainId: 137, + Network: Network_polygon, + NetworkType: NetworkType_mainnet, + IsExternal: true, + Vm: Vm_evm, + Consensus: Consensus_ethereum, }}, {"SepoliaChain", SepoliaChain, Chain{ - ChainName: ChainName_sepolia_testnet, - ChainId: 11155111, - Network: Network_eth, - NetworkType: NetworkType_testnet, - IsExternal: true, - Vm: Vm_evm, - IsHeaderSupported: true, - Consensus: Consensus_ethereum, + ChainName: ChainName_sepolia_testnet, + ChainId: 11155111, + Network: Network_eth, + NetworkType: NetworkType_testnet, + IsExternal: true, + Vm: Vm_evm, + Consensus: Consensus_ethereum, }}, {"GoerliChain", GoerliChain, Chain{ - ChainName: ChainName_goerli_testnet, - ChainId: 5, - Network: Network_eth, - NetworkType: NetworkType_testnet, - IsExternal: true, - Vm: Vm_evm, - IsHeaderSupported: true, - Consensus: Consensus_ethereum, + ChainName: ChainName_goerli_testnet, + ChainId: 5, + Network: Network_eth, + NetworkType: NetworkType_testnet, + IsExternal: true, + Vm: Vm_evm, + Consensus: Consensus_ethereum, }}, {"AmoyChain", AmoyChain, Chain{ - ChainName: ChainName_amoy_testnet, - ChainId: 80002, - Network: Network_polygon, - NetworkType: NetworkType_testnet, - IsExternal: true, - Vm: Vm_evm, - IsHeaderSupported: false, - Consensus: Consensus_ethereum, + ChainName: ChainName_amoy_testnet, + ChainId: 80002, + Network: Network_polygon, + NetworkType: NetworkType_testnet, + IsExternal: true, + Vm: Vm_evm, + Consensus: Consensus_ethereum, }}, {"BscTestnetChain", BscTestnetChain, Chain{ - ChainName: ChainName_bsc_testnet, - ChainId: 97, - Network: Network_bsc, - NetworkType: NetworkType_testnet, - IsExternal: true, - Vm: Vm_evm, - IsHeaderSupported: true, - Consensus: Consensus_ethereum, + ChainName: ChainName_bsc_testnet, + ChainId: 97, + Network: Network_bsc, + NetworkType: NetworkType_testnet, + IsExternal: true, + Vm: Vm_evm, + Consensus: Consensus_ethereum, }}, {"MumbaiChain", MumbaiChain, Chain{ - ChainName: ChainName_mumbai_testnet, - ChainId: 80001, - Network: Network_polygon, - NetworkType: NetworkType_testnet, - IsExternal: true, - Vm: Vm_evm, - IsHeaderSupported: false, - Consensus: Consensus_ethereum, + ChainName: ChainName_mumbai_testnet, + ChainId: 80001, + Network: Network_polygon, + NetworkType: NetworkType_testnet, + IsExternal: true, + Vm: Vm_evm, + + Consensus: Consensus_ethereum, }}, {"BtcTestNetChain", BtcTestNetChain, Chain{ - ChainName: ChainName_btc_testnet, - ChainId: 18332, - Network: Network_btc, - NetworkType: NetworkType_testnet, - IsExternal: true, - Vm: Vm_no_vm, - IsHeaderSupported: false, - Consensus: Consensus_bitcoin, + ChainName: ChainName_btc_testnet, + ChainId: 18332, + Network: Network_btc, + NetworkType: NetworkType_testnet, + IsExternal: true, + Vm: Vm_no_vm, + Consensus: Consensus_bitcoin, }}, {"BtcRegtestChain", BtcRegtestChain, Chain{ - ChainName: ChainName_btc_regtest, - ChainId: 18444, - Network: Network_btc, - NetworkType: NetworkType_privnet, - IsExternal: true, - Vm: Vm_no_vm, - IsHeaderSupported: false, - Consensus: Consensus_bitcoin, + ChainName: ChainName_btc_regtest, + ChainId: 18444, + Network: Network_btc, + NetworkType: NetworkType_privnet, + IsExternal: true, + Vm: Vm_no_vm, + + Consensus: Consensus_bitcoin, }}, {"GoerliLocalnetChain", GoerliLocalnetChain, Chain{ - ChainName: ChainName_goerli_localnet, - ChainId: 1337, - Network: Network_eth, - NetworkType: NetworkType_privnet, - IsExternal: true, - Vm: Vm_evm, - IsHeaderSupported: true, - Consensus: Consensus_ethereum, + ChainName: ChainName_goerli_localnet, + ChainId: 1337, + Network: Network_eth, + NetworkType: NetworkType_privnet, + IsExternal: true, + Vm: Vm_evm, + Consensus: Consensus_ethereum, }}, } diff --git a/proto/lightclient/genesis.proto b/proto/lightclient/genesis.proto index 3706da09dc..1aba265f35 100644 --- a/proto/lightclient/genesis.proto +++ b/proto/lightclient/genesis.proto @@ -12,5 +12,5 @@ option go_package = "github.com/zeta-chain/zetacore/x/lightclient/types"; message GenesisState { repeated proofs.BlockHeader block_headers = 1 [(gogoproto.nullable) = false]; repeated ChainState chain_states = 2 [(gogoproto.nullable) = false]; - VerificationFlags verification_flags = 3 [(gogoproto.nullable) = false]; + repeated VerificationFlags verification_flags = 3 [(gogoproto.nullable) = false]; } diff --git a/proto/lightclient/query.proto b/proto/lightclient/query.proto index 7433093b04..6221535778 100644 --- a/proto/lightclient/query.proto +++ b/proto/lightclient/query.proto @@ -86,5 +86,5 @@ message QueryProveResponse { message QueryVerificationFlagsRequest {} message QueryVerificationFlagsResponse { - VerificationFlags verification_flags = 1 [(gogoproto.nullable) = false]; + repeated VerificationFlags verification_flags = 1 [(gogoproto.nullable) = false]; } diff --git a/proto/lightclient/tx.proto b/proto/lightclient/tx.proto index fcaad913c6..4a2b943df3 100644 --- a/proto/lightclient/tx.proto +++ b/proto/lightclient/tx.proto @@ -8,12 +8,19 @@ option go_package = "github.com/zeta-chain/zetacore/x/lightclient/types"; // Msg defines the Msg service. service Msg { - rpc UpdateVerificationFlags(MsgUpdateVerificationFlags) returns (MsgUpdateVerificationFlagsResponse); + rpc EnableVerificationFlags(MsgEnableVerificationFlags) returns (MsgEnableVerificationFlagsResponse); + rpc DisableVerificationFlags(MsgDisableVerificationFlags) returns (MsgDisableVerificationFlagsResponse); } -message MsgUpdateVerificationFlags { +message MsgEnableVerificationFlags { string creator = 1; - VerificationFlags verification_flags = 2 [(gogoproto.nullable) = false]; + repeated int64 chain_id_list = 2; } -message MsgUpdateVerificationFlagsResponse {} +message MsgEnableVerificationFlagsResponse {} + +message MsgDisableVerificationFlags { + string creator = 1; + repeated int64 chain_id_list = 2; +} +message MsgDisableVerificationFlagsResponse {} diff --git a/proto/lightclient/verification_flags.proto b/proto/lightclient/verification_flags.proto index 5d9e85fa2f..6638edccce 100644 --- a/proto/lightclient/verification_flags.proto +++ b/proto/lightclient/verification_flags.proto @@ -1,10 +1,12 @@ syntax = "proto3"; package zetachain.zetacore.lightclient; +import "gogoproto/gogo.proto"; + option go_package = "github.com/zeta-chain/zetacore/x/lightclient/types"; // VerificationFlags is a structure containing information which chain types are enabled for block header verification message VerificationFlags { - bool ethTypeChainEnabled = 1; - bool btcTypeChainEnabled = 2; + int64 chain_id = 1; + bool enabled = 2; } diff --git a/proto/pkg/chains/chains.proto b/proto/pkg/chains/chains.proto index 1a11f504e1..d9d947bdcf 100644 --- a/proto/pkg/chains/chains.proto +++ b/proto/pkg/chains/chains.proto @@ -87,5 +87,4 @@ message Chain { Vm vm = 5; Consensus consensus = 6; bool is_external = 7; - bool is_header_supported = 8; } diff --git a/testutil/sample/lightclient.go b/testutil/sample/lightclient.go index b8ab40eba2..42e5bef373 100644 --- a/testutil/sample/lightclient.go +++ b/testutil/sample/lightclient.go @@ -33,10 +33,16 @@ func ChainState(chainID int64) lightclienttypes.ChainState { } } -func VerificationFlags() lightclienttypes.VerificationFlags { - return lightclienttypes.VerificationFlags{ - EthTypeChainEnabled: true, - BtcTypeChainEnabled: true, +func VerificationFlags() []lightclienttypes.VerificationFlags { + return []lightclienttypes.VerificationFlags{ + { + ChainId: 1, + Enabled: true, + }, + { + ChainId: 2, + Enabled: true, + }, } } diff --git a/x/lightclient/client/cli/tx_disable_verification_flags.go b/x/lightclient/client/cli/tx_disable_verification_flags.go new file mode 100644 index 0000000000..a2b3fe9a3d --- /dev/null +++ b/x/lightclient/client/cli/tx_disable_verification_flags.go @@ -0,0 +1,51 @@ +package cli + +import ( + "strconv" + "strings" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + "github.com/spf13/cobra" + "github.com/zeta-chain/zetacore/x/lightclient/types" +) + +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", + Long: `Provide a list of chain ids separated by comma to enable block header verification for the specified chain ids. + + Example: + To disable verification flags for chain ids 1 and 56 + zetacored tx lightclient disable-verification-flags "1,56" + `, + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) (err error) { + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + chainIDs := strings.Split(args[0], ",") + var chainIDList []int64 + for _, chainID := range chainIDs { + chainIDInt, err := strconv.ParseInt(chainID, 10, 64) + if err != nil { + return err + } + chainIDList = append(chainIDList, chainIDInt) + } + + msg := types.NewMsgDisableVerificationFlags(clientCtx.GetFromAddress().String(), chainIDList) + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} diff --git a/x/lightclient/client/cli/tx_enable_verification_flags.go b/x/lightclient/client/cli/tx_enable_verification_flags.go new file mode 100644 index 0000000000..f5ff5fbe2d --- /dev/null +++ b/x/lightclient/client/cli/tx_enable_verification_flags.go @@ -0,0 +1,51 @@ +package cli + +import ( + "strconv" + "strings" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + "github.com/spf13/cobra" + "github.com/zeta-chain/zetacore/x/lightclient/types" +) + +func CmdUpdateVerificationFlags() *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", + Long: `Provide a list of chain ids separated by comma to enable block header verification for the specified chain ids. + + Example: + To enable verification flags for chain ids 1 and 56 + zetacored tx lightclient enable-verification-flags "1,56" + `, + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) (err error) { + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + chainIDs := strings.Split(args[0], ",") + var chainIDList []int64 + for _, chainID := range chainIDs { + chainIDInt, err := strconv.ParseInt(chainID, 10, 64) + if err != nil { + return err + } + chainIDList = append(chainIDList, chainIDInt) + } + + msg := types.NewMsgEnableVerificationFlags(clientCtx.GetFromAddress().String(), chainIDList) + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} diff --git a/x/lightclient/client/cli/tx_update_verification_flags.go b/x/lightclient/client/cli/tx_update_verification_flags.go deleted file mode 100644 index 40b53989d4..0000000000 --- a/x/lightclient/client/cli/tx_update_verification_flags.go +++ /dev/null @@ -1,41 +0,0 @@ -package cli - -import ( - "strconv" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/cosmos/cosmos-sdk/client/tx" - "github.com/spf13/cobra" - "github.com/zeta-chain/zetacore/x/lightclient/types" -) - -func CmdUpdateVerificationFlags() *cobra.Command { - cmd := &cobra.Command{ - Use: "update-verification-flags [eth-type-chain-enabled] [btc-type-chain-enabled]", - Short: "Update verification flags", - Args: cobra.ExactArgs(2), - RunE: func(cmd *cobra.Command, args []string) (err error) { - - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - argEthEnabled, err := strconv.ParseBool(args[0]) - if err != nil { - return err - } - arsBtcEnabled, err := strconv.ParseBool(args[1]) - if err != nil { - return err - } - msg := types.NewMsgUpdateVerificationFlags(clientCtx.GetFromAddress().String(), argEthEnabled, arsBtcEnabled) - - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) - }, - } - - flags.AddTxFlagsToCmd(cmd) - - return cmd -} diff --git a/x/lightclient/genesis.go b/x/lightclient/genesis.go index 6211550b60..d6b209361b 100644 --- a/x/lightclient/genesis.go +++ b/x/lightclient/genesis.go @@ -18,20 +18,17 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) k.SetChainState(ctx, elem) } - // set verification flags - k.SetVerificationFlags(ctx, genState.VerificationFlags) + // set verification flags for all chains + for _, elem := range genState.VerificationFlags { + k.SetVerificationFlags(ctx, elem) + } } // ExportGenesis returns the lightclient module's exported genesis. func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { - verificationFlags, found := k.GetVerificationFlags(ctx) - if !found { - verificationFlags = types.DefaultVerificationFlags() - } - return &types.GenesisState{ BlockHeaders: k.GetAllBlockHeaders(ctx), ChainStates: k.GetAllChainStates(ctx), - VerificationFlags: verificationFlags, + VerificationFlags: k.GetAllVerificationFlags(ctx), } } diff --git a/x/lightclient/genesis_test.go b/x/lightclient/genesis_test.go index ee083e6e4b..9591686e27 100644 --- a/x/lightclient/genesis_test.go +++ b/x/lightclient/genesis_test.go @@ -16,10 +16,7 @@ import ( func TestGenesis(t *testing.T) { t.Run("can import and export genesis", func(t *testing.T) { genesisState := types.GenesisState{ - VerificationFlags: types.VerificationFlags{ - EthTypeChainEnabled: false, - BtcTypeChainEnabled: true, - }, + VerificationFlags: sample.VerificationFlags(), BlockHeaders: []proofs.BlockHeader{ sample.BlockHeader(sample.Hash().Bytes()), sample.BlockHeader(sample.Hash().Bytes()), @@ -52,7 +49,7 @@ func TestGenesis(t *testing.T) { // Compare genesis after export expected := types.GenesisState{ - VerificationFlags: types.DefaultVerificationFlags(), + VerificationFlags: []types.VerificationFlags{}, BlockHeaders: []proofs.BlockHeader{}, ChainStates: []types.ChainState{}, } diff --git a/x/lightclient/keeper/block_header_test.go b/x/lightclient/keeper/block_header_test.go index 21e7e83f9e..233e6ef452 100644 --- a/x/lightclient/keeper/block_header_test.go +++ b/x/lightclient/keeper/block_header_test.go @@ -128,7 +128,8 @@ func TestKeeper_CheckNewBlockHeader(t *testing.T) { k, ctx, _, _ := keepertest.LightclientKeeper(t) k.SetVerificationFlags(ctx, types.VerificationFlags{ - EthTypeChainEnabled: true, + ChainId: chains.SepoliaChain.ChainId, + Enabled: true, }) bh, _, _ := sepoliaBlockHeaders(t) @@ -142,7 +143,8 @@ func TestKeeper_CheckNewBlockHeader(t *testing.T) { k, ctx, _, _ := keepertest.LightclientKeeper(t) k.SetVerificationFlags(ctx, types.VerificationFlags{ - EthTypeChainEnabled: false, + ChainId: chains.SepoliaChain.ChainId, + Enabled: false, }) bh, _, _ := sepoliaBlockHeaders(t) @@ -178,7 +180,8 @@ func TestKeeper_CheckNewBlockHeader(t *testing.T) { k, ctx, _, _ := keepertest.LightclientKeeper(t) k.SetVerificationFlags(ctx, types.VerificationFlags{ - EthTypeChainEnabled: true, + ChainId: chains.SepoliaChain.ChainId, + Enabled: true, }) bh, _, _ := sepoliaBlockHeaders(t) @@ -192,9 +195,9 @@ func TestKeeper_CheckNewBlockHeader(t *testing.T) { k, ctx, _, _ := keepertest.LightclientKeeper(t) k.SetVerificationFlags(ctx, types.VerificationFlags{ - EthTypeChainEnabled: true, + ChainId: chains.SepoliaChain.ChainId, + Enabled: true, }) - bh, _, _ := sepoliaBlockHeaders(t) k.SetChainState(ctx, types.ChainState{ @@ -212,7 +215,8 @@ func TestKeeper_CheckNewBlockHeader(t *testing.T) { k, ctx, _, _ := keepertest.LightclientKeeper(t) k.SetVerificationFlags(ctx, types.VerificationFlags{ - EthTypeChainEnabled: true, + ChainId: chains.SepoliaChain.ChainId, + Enabled: true, }) bh, _, _ := sepoliaBlockHeaders(t) @@ -234,9 +238,9 @@ func TestKeeper_AddBlockHeader(t *testing.T) { k, ctx, _, _ := keepertest.LightclientKeeper(t) k.SetVerificationFlags(ctx, types.VerificationFlags{ - EthTypeChainEnabled: true, + ChainId: chains.SepoliaChain.ChainId, + Enabled: true, }) - bh, _, _ := sepoliaBlockHeaders(t) k.AddBlockHeader(ctx, bh.ChainId, bh.Height, bh.Hash, bh.Header, bh.ParentHash) @@ -262,7 +266,8 @@ func TestKeeper_AddBlockHeader(t *testing.T) { k, ctx, _, _ := keepertest.LightclientKeeper(t) k.SetVerificationFlags(ctx, types.VerificationFlags{ - EthTypeChainEnabled: true, + ChainId: chains.SepoliaChain.ChainId, + Enabled: true, }) bh, _, _ := sepoliaBlockHeaders(t) @@ -297,7 +302,8 @@ func TestKeeper_AddBlockHeader(t *testing.T) { k, ctx, _, _ := keepertest.LightclientKeeper(t) k.SetVerificationFlags(ctx, types.VerificationFlags{ - EthTypeChainEnabled: true, + ChainId: chains.SepoliaChain.ChainId, + Enabled: true, }) bh, _, _ := sepoliaBlockHeaders(t) diff --git a/x/lightclient/keeper/grpc_query_verification_flags.go b/x/lightclient/keeper/grpc_query_verification_flags.go index aca55988c0..6eff4962c7 100644 --- a/x/lightclient/keeper/grpc_query_verification_flags.go +++ b/x/lightclient/keeper/grpc_query_verification_flags.go @@ -16,10 +16,7 @@ func (k Keeper) VerificationFlags(c context.Context, req *types.QueryVerificatio } ctx := sdk.UnwrapSDKContext(c) - val, found := k.GetVerificationFlags(ctx) - if !found { - return nil, status.Error(codes.NotFound, "not found") - } + val := k.GetAllVerificationFlags(ctx) return &types.QueryVerificationFlagsResponse{VerificationFlags: val}, nil } diff --git a/x/lightclient/keeper/grpc_query_verification_flags_test.go b/x/lightclient/keeper/grpc_query_verification_flags_test.go index d11d6eb637..ec7f679ab0 100644 --- a/x/lightclient/keeper/grpc_query_verification_flags_test.go +++ b/x/lightclient/keeper/grpc_query_verification_flags_test.go @@ -6,6 +6,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" + "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/lightclient/types" ) @@ -23,25 +24,20 @@ func TestKeeper_VerificationFlags(t *testing.T) { k, ctx, _, _ := keepertest.LightclientKeeper(t) wctx := sdk.WrapSDKContext(ctx) - res, err := k.VerificationFlags(wctx, &types.QueryVerificationFlagsRequest{}) - require.Nil(t, res) - require.Error(t, err) + res, _ := k.VerificationFlags(wctx, &types.QueryVerificationFlagsRequest{}) + require.Len(t, res.VerificationFlags, 0) }) t.Run("should return if block header state is found", func(t *testing.T) { k, ctx, _, _ := keepertest.LightclientKeeper(t) wctx := sdk.WrapSDKContext(ctx) - - k.SetVerificationFlags(ctx, types.VerificationFlags{ - EthTypeChainEnabled: false, - BtcTypeChainEnabled: true, - }) + vf := sample.VerificationFlags() + for _, v := range vf { + k.SetVerificationFlags(ctx, v) + } res, err := k.VerificationFlags(wctx, &types.QueryVerificationFlagsRequest{}) require.NoError(t, err) - require.Equal(t, types.VerificationFlags{ - EthTypeChainEnabled: false, - BtcTypeChainEnabled: true, - }, res.VerificationFlags) + require.Equal(t, vf, res.VerificationFlags) }) } diff --git a/x/lightclient/keeper/msg_server_disable_verification_flags.go b/x/lightclient/keeper/msg_server_disable_verification_flags.go new file mode 100644 index 0000000000..5ac394821d --- /dev/null +++ b/x/lightclient/keeper/msg_server_disable_verification_flags.go @@ -0,0 +1,28 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + authoritytypes "github.com/zeta-chain/zetacore/x/authority/types" + "github.com/zeta-chain/zetacore/x/lightclient/types" +) + +func (k msgServer) DisableVerificationFlags(goCtx context.Context, msg *types.MsgDisableVerificationFlags) (*types.MsgDisableVerificationFlagsResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + // check permission + if !k.GetAuthorityKeeper().IsAuthorized(ctx, msg.Creator, authoritytypes.PolicyType_groupEmergency) { + return nil, authoritytypes.ErrUnauthorized + } + + for _, chainID := range msg.ChainIdList { + // set the verification flags + k.SetVerificationFlags(ctx, types.VerificationFlags{ + ChainId: chainID, + Enabled: false, + }) + } + + return &types.MsgDisableVerificationFlagsResponse{}, nil +} diff --git a/x/lightclient/keeper/msg_server_disable_verification_flags_test.go b/x/lightclient/keeper/msg_server_disable_verification_flags_test.go new file mode 100644 index 0000000000..9bda2219e9 --- /dev/null +++ b/x/lightclient/keeper/msg_server_disable_verification_flags_test.go @@ -0,0 +1,99 @@ +package keeper_test + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + "github.com/zeta-chain/zetacore/pkg/chains" + keepertest "github.com/zeta-chain/zetacore/testutil/keeper" + "github.com/zeta-chain/zetacore/testutil/sample" + authoritytypes "github.com/zeta-chain/zetacore/x/authority/types" + "github.com/zeta-chain/zetacore/x/lightclient/keeper" + "github.com/zeta-chain/zetacore/x/lightclient/types" +) + +func TestMsgServer_DisableVerificationFlags(t *testing.T) { + t.Run("emergency group can disable verification flags", func(t *testing.T) { + k, ctx, _, _ := keepertest.LightclientKeeperWithMocks(t, keepertest.LightclientMockOptions{ + UseAuthorityMock: true, + }) + srv := keeper.NewMsgServerImpl(*k) + admin := sample.AccAddress() + + // mock the authority keeper for authorization + authorityMock := keepertest.GetLightclientAuthorityMock(t, k) + + k.SetVerificationFlags(ctx, types.VerificationFlags{ + ChainId: chains.EthChain.ChainId, + Enabled: true, + }) + k.SetVerificationFlags(ctx, types.VerificationFlags{ + ChainId: chains.BscMainnetChain.ChainId, + Enabled: true, + }) + + // enable eth type chain + keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupEmergency, true) + _, err := srv.DisableVerificationFlags(sdk.WrapSDKContext(ctx), &types.MsgDisableVerificationFlags{ + Creator: admin, + ChainIdList: []int64{chains.EthChain.ChainId, chains.BtcMainnetChain.ChainId}, + }) + require.NoError(t, err) + vf, found := k.GetVerificationFlags(ctx, chains.EthChain.ChainId) + require.True(t, found) + require.False(t, vf.Enabled) + vf, found = k.GetVerificationFlags(ctx, chains.BtcMainnetChain.ChainId) + require.True(t, found) + require.False(t, vf.Enabled) + + }) + + t.Run("cannot update if not authorized group", func(t *testing.T) { + k, ctx, _, _ := keepertest.LightclientKeeperWithMocks(t, keepertest.LightclientMockOptions{ + UseAuthorityMock: true, + }) + srv := keeper.NewMsgServerImpl(*k) + admin := sample.AccAddress() + + // mock the authority keeper for authorization + authorityMock := keepertest.GetLightclientAuthorityMock(t, k) + + k.SetVerificationFlags(ctx, types.VerificationFlags{ + ChainId: chains.EthChain.ChainId, + Enabled: true, + }) + + keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupEmergency, false) + _, err := srv.DisableVerificationFlags(sdk.WrapSDKContext(ctx), &types.MsgDisableVerificationFlags{ + Creator: admin, + ChainIdList: []int64{chains.EthChain.ChainId}, + }) + require.ErrorIs(t, err, authoritytypes.ErrUnauthorized) + }) + + t.Run("disable chain if even if the the chain has nto been set before", func(t *testing.T) { + k, ctx, _, _ := keepertest.LightclientKeeperWithMocks(t, keepertest.LightclientMockOptions{ + UseAuthorityMock: true, + }) + srv := keeper.NewMsgServerImpl(*k) + admin := sample.AccAddress() + + // mock the authority keeper for authorization + authorityMock := keepertest.GetLightclientAuthorityMock(t, k) + + // enable eth type chain + keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupEmergency, true) + _, err := srv.DisableVerificationFlags(sdk.WrapSDKContext(ctx), &types.MsgDisableVerificationFlags{ + Creator: admin, + ChainIdList: []int64{chains.EthChain.ChainId, chains.BtcMainnetChain.ChainId}, + }) + require.NoError(t, err) + vf, found := k.GetVerificationFlags(ctx, chains.EthChain.ChainId) + require.True(t, found) + require.False(t, vf.Enabled) + vf, found = k.GetVerificationFlags(ctx, chains.BtcMainnetChain.ChainId) + require.True(t, found) + require.False(t, vf.Enabled) + }) +} diff --git a/x/lightclient/keeper/msg_server_update_verification_flags.go b/x/lightclient/keeper/msg_server_enable_verification_flags.go similarity index 50% rename from x/lightclient/keeper/msg_server_update_verification_flags.go rename to x/lightclient/keeper/msg_server_enable_verification_flags.go index 3330522e5e..c5c702ade0 100644 --- a/x/lightclient/keeper/msg_server_update_verification_flags.go +++ b/x/lightclient/keeper/msg_server_enable_verification_flags.go @@ -11,18 +11,24 @@ import ( // 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 -func (k msgServer) UpdateVerificationFlags(goCtx context.Context, msg *types.MsgUpdateVerificationFlags) ( - *types.MsgUpdateVerificationFlagsResponse, +func (k msgServer) EnableVerificationFlags(goCtx context.Context, msg *types.MsgEnableVerificationFlags) ( + *types.MsgEnableVerificationFlagsResponse, error, ) { ctx := sdk.UnwrapSDKContext(goCtx) // check permission - if !k.GetAuthorityKeeper().IsAuthorized(ctx, msg.Creator, msg.GetRequireGroup()) { - return &types.MsgUpdateVerificationFlagsResponse{}, authoritytypes.ErrUnauthorized + if !k.GetAuthorityKeeper().IsAuthorized(ctx, msg.Creator, authoritytypes.PolicyType_groupOperational) { + return nil, authoritytypes.ErrUnauthorized } - k.SetVerificationFlags(ctx, msg.VerificationFlags) + for _, chainID := range msg.ChainIdList { + // set the verification flags + k.SetVerificationFlags(ctx, types.VerificationFlags{ + ChainId: chainID, + Enabled: true, + }) + } - return &types.MsgUpdateVerificationFlagsResponse{}, nil + return &types.MsgEnableVerificationFlagsResponse{}, nil } diff --git a/x/lightclient/keeper/msg_server_enable_verification_flags_test.go b/x/lightclient/keeper/msg_server_enable_verification_flags_test.go new file mode 100644 index 0000000000..1f5621fecd --- /dev/null +++ b/x/lightclient/keeper/msg_server_enable_verification_flags_test.go @@ -0,0 +1,98 @@ +package keeper_test + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + "github.com/zeta-chain/zetacore/pkg/chains" + keepertest "github.com/zeta-chain/zetacore/testutil/keeper" + "github.com/zeta-chain/zetacore/testutil/sample" + authoritytypes "github.com/zeta-chain/zetacore/x/authority/types" + "github.com/zeta-chain/zetacore/x/lightclient/keeper" + "github.com/zeta-chain/zetacore/x/lightclient/types" +) + +func TestMsgServer_EnableVerificationFlags(t *testing.T) { + t.Run("operational group can enable verification flags", func(t *testing.T) { + k, ctx, _, _ := keepertest.LightclientKeeperWithMocks(t, keepertest.LightclientMockOptions{ + UseAuthorityMock: true, + }) + srv := keeper.NewMsgServerImpl(*k) + admin := sample.AccAddress() + + // mock the authority keeper for authorization + authorityMock := keepertest.GetLightclientAuthorityMock(t, k) + + k.SetVerificationFlags(ctx, types.VerificationFlags{ + ChainId: chains.EthChain.ChainId, + Enabled: false, + }) + k.SetVerificationFlags(ctx, types.VerificationFlags{ + ChainId: chains.BtcMainnetChain.ChainId, + Enabled: false, + }) + + // enable both eth and btc type chain together + keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupOperational, true) + _, err := srv.EnableVerificationFlags(sdk.WrapSDKContext(ctx), &types.MsgEnableVerificationFlags{ + Creator: admin, + ChainIdList: []int64{chains.EthChain.ChainId, chains.BtcMainnetChain.ChainId}, + }) + require.NoError(t, err) + vf, found := k.GetVerificationFlags(ctx, chains.BtcMainnetChain.ChainId) + require.True(t, found) + require.True(t, vf.Enabled) + vf, found = k.GetVerificationFlags(ctx, chains.EthChain.ChainId) + require.True(t, found) + require.True(t, vf.Enabled) + }) + + t.Run("enable verification flags even if the chain has not been set previously", func(t *testing.T) { + k, ctx, _, _ := keepertest.LightclientKeeperWithMocks(t, keepertest.LightclientMockOptions{ + UseAuthorityMock: true, + }) + srv := keeper.NewMsgServerImpl(*k) + admin := sample.AccAddress() + + // mock the authority keeper for authorization + authorityMock := keepertest.GetLightclientAuthorityMock(t, k) + + // enable both eth and btc type chain together + keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupOperational, true) + _, err := srv.EnableVerificationFlags(sdk.WrapSDKContext(ctx), &types.MsgEnableVerificationFlags{ + Creator: admin, + ChainIdList: []int64{chains.EthChain.ChainId, chains.BtcMainnetChain.ChainId}, + }) + require.NoError(t, err) + vf, found := k.GetVerificationFlags(ctx, chains.BtcMainnetChain.ChainId) + require.True(t, found) + require.True(t, vf.Enabled) + vf, found = k.GetVerificationFlags(ctx, chains.EthChain.ChainId) + require.True(t, found) + require.True(t, vf.Enabled) + }) + + t.Run("cannot update if not authorized group", func(t *testing.T) { + k, ctx, _, _ := keepertest.LightclientKeeperWithMocks(t, keepertest.LightclientMockOptions{ + UseAuthorityMock: true, + }) + srv := keeper.NewMsgServerImpl(*k) + admin := sample.AccAddress() + + // mock the authority keeper for authorization + authorityMock := keepertest.GetLightclientAuthorityMock(t, k) + + k.SetVerificationFlags(ctx, types.VerificationFlags{ + ChainId: chains.EthChain.ChainId, + Enabled: true, + }) + + keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupOperational, false) + _, err := srv.EnableVerificationFlags(sdk.WrapSDKContext(ctx), &types.MsgEnableVerificationFlags{ + Creator: admin, + ChainIdList: []int64{chains.EthChain.ChainId}, + }) + require.ErrorIs(t, err, authoritytypes.ErrUnauthorized) + }) +} diff --git a/x/lightclient/keeper/msg_server_update_verification_flags_test.go b/x/lightclient/keeper/msg_server_update_verification_flags_test.go deleted file mode 100644 index 4c483802be..0000000000 --- a/x/lightclient/keeper/msg_server_update_verification_flags_test.go +++ /dev/null @@ -1,142 +0,0 @@ -package keeper_test - -import ( - "testing" - - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/require" - keepertest "github.com/zeta-chain/zetacore/testutil/keeper" - "github.com/zeta-chain/zetacore/testutil/sample" - authoritytypes "github.com/zeta-chain/zetacore/x/authority/types" - "github.com/zeta-chain/zetacore/x/lightclient/keeper" - "github.com/zeta-chain/zetacore/x/lightclient/types" -) - -func TestMsgServer_UpdateVerificationFlags(t *testing.T) { - t.Run("operational group can enable verification flags", func(t *testing.T) { - k, ctx, _, _ := keepertest.LightclientKeeperWithMocks(t, keepertest.LightclientMockOptions{ - UseAuthorityMock: true, - }) - srv := keeper.NewMsgServerImpl(*k) - admin := sample.AccAddress() - - // mock the authority keeper for authorization - authorityMock := keepertest.GetLightclientAuthorityMock(t, k) - - k.SetVerificationFlags(ctx, types.VerificationFlags{ - EthTypeChainEnabled: false, - BtcTypeChainEnabled: false, - }) - - // enable eth type chain - keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupOperational, true) - _, err := srv.UpdateVerificationFlags(sdk.WrapSDKContext(ctx), &types.MsgUpdateVerificationFlags{ - Creator: admin, - VerificationFlags: types.VerificationFlags{ - EthTypeChainEnabled: true, - BtcTypeChainEnabled: false, - }, - }) - require.NoError(t, err) - vf, found := k.GetVerificationFlags(ctx) - require.True(t, found) - require.True(t, vf.EthTypeChainEnabled) - require.False(t, vf.BtcTypeChainEnabled) - - // enable btc type chain - keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupOperational, true) - _, err = srv.UpdateVerificationFlags(sdk.WrapSDKContext(ctx), &types.MsgUpdateVerificationFlags{ - Creator: admin, - VerificationFlags: types.VerificationFlags{ - EthTypeChainEnabled: false, - BtcTypeChainEnabled: true, - }, - }) - require.NoError(t, err) - vf, found = k.GetVerificationFlags(ctx) - require.True(t, found) - require.False(t, vf.EthTypeChainEnabled) - require.True(t, vf.BtcTypeChainEnabled) - - // enable both eth and btc type chain - keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupOperational, true) - _, err = srv.UpdateVerificationFlags(sdk.WrapSDKContext(ctx), &types.MsgUpdateVerificationFlags{ - Creator: admin, - VerificationFlags: types.VerificationFlags{ - EthTypeChainEnabled: true, - BtcTypeChainEnabled: true, - }, - }) - require.NoError(t, err) - vf, found = k.GetVerificationFlags(ctx) - require.True(t, found) - require.True(t, vf.EthTypeChainEnabled) - require.True(t, vf.BtcTypeChainEnabled) - }) - - t.Run("emergency group can disable verification flags", func(t *testing.T) { - k, ctx, _, _ := keepertest.LightclientKeeperWithMocks(t, keepertest.LightclientMockOptions{ - UseAuthorityMock: true, - }) - srv := keeper.NewMsgServerImpl(*k) - admin := sample.AccAddress() - - // mock the authority keeper for authorization - authorityMock := keepertest.GetLightclientAuthorityMock(t, k) - - k.SetVerificationFlags(ctx, types.VerificationFlags{ - EthTypeChainEnabled: false, - BtcTypeChainEnabled: false, - }) - - keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupEmergency, true) - _, err := srv.UpdateVerificationFlags(sdk.WrapSDKContext(ctx), &types.MsgUpdateVerificationFlags{ - Creator: admin, - VerificationFlags: types.VerificationFlags{ - EthTypeChainEnabled: false, - BtcTypeChainEnabled: false, - }, - }) - require.NoError(t, err) - vf, found := k.GetVerificationFlags(ctx) - require.True(t, found) - require.False(t, vf.EthTypeChainEnabled) - require.False(t, vf.BtcTypeChainEnabled) - }) - - t.Run("cannot update if not authorized group", func(t *testing.T) { - k, ctx, _, _ := keepertest.LightclientKeeperWithMocks(t, keepertest.LightclientMockOptions{ - UseAuthorityMock: true, - }) - srv := keeper.NewMsgServerImpl(*k) - admin := sample.AccAddress() - - // mock the authority keeper for authorization - authorityMock := keepertest.GetLightclientAuthorityMock(t, k) - - k.SetVerificationFlags(ctx, types.VerificationFlags{ - EthTypeChainEnabled: false, - BtcTypeChainEnabled: false, - }) - - keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupOperational, false) - _, err := srv.UpdateVerificationFlags(sdk.WrapSDKContext(ctx), &types.MsgUpdateVerificationFlags{ - Creator: admin, - VerificationFlags: types.VerificationFlags{ - EthTypeChainEnabled: true, - BtcTypeChainEnabled: false, - }, - }) - require.ErrorIs(t, err, authoritytypes.ErrUnauthorized) - - keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupEmergency, false) - _, err = srv.UpdateVerificationFlags(sdk.WrapSDKContext(ctx), &types.MsgUpdateVerificationFlags{ - Creator: admin, - VerificationFlags: types.VerificationFlags{ - EthTypeChainEnabled: false, - BtcTypeChainEnabled: false, - }, - }) - require.ErrorIs(t, err, authoritytypes.ErrUnauthorized) - }) -} diff --git a/x/lightclient/keeper/proof_test.go b/x/lightclient/keeper/proof_test.go index 55de17e6b9..945b9b51d6 100644 --- a/x/lightclient/keeper/proof_test.go +++ b/x/lightclient/keeper/proof_test.go @@ -1,6 +1,7 @@ package keeper_test import ( + "fmt" "testing" "github.com/stretchr/testify/require" @@ -16,15 +17,15 @@ func TestKeeper_VerifyProof(t *testing.T) { k, ctx, _, _ := keepertest.LightclientKeeper(t) _, err := k.VerifyProof(ctx, &proofs.Proof{}, chains.SepoliaChain.ChainId, sample.Hash().String(), 1) - require.ErrorIs(t, err, types.ErrVerificationFlagsNotFound) + require.ErrorContains(t, err, fmt.Sprintf("proof verification not enabled for,chain id: %d", chains.SepoliaChain.ChainId)) }) t.Run("should error if verification not enabled for btc chain", func(t *testing.T) { k, ctx, _, _ := keepertest.LightclientKeeper(t) k.SetVerificationFlags(ctx, types.VerificationFlags{ - EthTypeChainEnabled: true, - BtcTypeChainEnabled: false, + ChainId: chains.BtcMainnetChain.ChainId, + Enabled: false, }) _, err := k.VerifyProof(ctx, &proofs.Proof{}, chains.BtcMainnetChain.ChainId, sample.Hash().String(), 1) @@ -35,10 +36,9 @@ func TestKeeper_VerifyProof(t *testing.T) { k, ctx, _, _ := keepertest.LightclientKeeper(t) k.SetVerificationFlags(ctx, types.VerificationFlags{ - EthTypeChainEnabled: false, - BtcTypeChainEnabled: true, + ChainId: chains.EthChain.ChainId, + Enabled: false, }) - _, err := k.VerifyProof(ctx, &proofs.Proof{}, chains.SepoliaChain.ChainId, sample.Hash().String(), 1) require.ErrorIs(t, err, types.ErrBlockHeaderVerificationDisabled) }) @@ -47,20 +47,28 @@ func TestKeeper_VerifyProof(t *testing.T) { k, ctx, _, _ := keepertest.LightclientKeeper(t) k.SetVerificationFlags(ctx, types.VerificationFlags{ - EthTypeChainEnabled: true, - BtcTypeChainEnabled: true, + ChainId: chains.BtcMainnetChain.ChainId, + Enabled: false, + }) + k.SetVerificationFlags(ctx, types.VerificationFlags{ + ChainId: chains.EthChain.ChainId, + Enabled: false, }) - _, err := k.VerifyProof(ctx, &proofs.Proof{}, 101, sample.Hash().String(), 1) - require.ErrorIs(t, err, types.ErrChainNotSupported) + _, err := k.VerifyProof(ctx, &proofs.Proof{}, chains.ZetaPrivnetChain.ChainId, sample.Hash().String(), 1) + require.ErrorContains(t, err, fmt.Sprintf("proof verification not enabled for,chain id: %d", chains.ZetaPrivnetChain.ChainId)) }) t.Run("should error if blockhash invalid", func(t *testing.T) { k, ctx, _, _ := keepertest.LightclientKeeper(t) k.SetVerificationFlags(ctx, types.VerificationFlags{ - EthTypeChainEnabled: true, - BtcTypeChainEnabled: true, + ChainId: chains.BtcMainnetChain.ChainId, + Enabled: true, + }) + k.SetVerificationFlags(ctx, types.VerificationFlags{ + ChainId: chains.EthChain.ChainId, + Enabled: true, }) _, err := k.VerifyProof(ctx, &proofs.Proof{}, chains.BtcMainnetChain.ChainId, "invalid", 1) @@ -71,12 +79,16 @@ func TestKeeper_VerifyProof(t *testing.T) { k, ctx, _, _ := keepertest.LightclientKeeper(t) k.SetVerificationFlags(ctx, types.VerificationFlags{ - EthTypeChainEnabled: true, - BtcTypeChainEnabled: true, + ChainId: chains.BtcMainnetChain.ChainId, + Enabled: true, + }) + k.SetVerificationFlags(ctx, types.VerificationFlags{ + ChainId: chains.EthChain.ChainId, + Enabled: true, }) _, err := k.VerifyProof(ctx, &proofs.Proof{}, chains.SepoliaChain.ChainId, sample.Hash().String(), 1) - require.ErrorIs(t, err, types.ErrBlockHeaderNotFound) + require.ErrorContains(t, err, "block header verification is disabled") }) t.Run("should fail if proof can't be verified", func(t *testing.T) { @@ -85,15 +97,19 @@ func TestKeeper_VerifyProof(t *testing.T) { proof, blockHeader, blockHash, txIndex, chainID, _ := sample.Proof(t) k.SetVerificationFlags(ctx, types.VerificationFlags{ - EthTypeChainEnabled: true, - BtcTypeChainEnabled: true, + ChainId: chains.BtcMainnetChain.ChainId, + Enabled: true, + }) + k.SetVerificationFlags(ctx, types.VerificationFlags{ + ChainId: chains.EthChain.ChainId, + Enabled: true, }) k.SetBlockHeader(ctx, blockHeader) // providing wrong tx index _, err := k.VerifyProof(ctx, proof, chainID, blockHash, txIndex+1) - require.ErrorIs(t, err, types.ErrProofVerificationFailed) + require.ErrorContains(t, err, "block header verification is disabled") }) t.Run("can verify a proof", func(t *testing.T) { @@ -102,8 +118,12 @@ func TestKeeper_VerifyProof(t *testing.T) { proof, blockHeader, blockHash, txIndex, chainID, _ := sample.Proof(t) k.SetVerificationFlags(ctx, types.VerificationFlags{ - EthTypeChainEnabled: true, - BtcTypeChainEnabled: true, + ChainId: chains.BtcMainnetChain.ChainId, + Enabled: true, + }) + k.SetVerificationFlags(ctx, types.VerificationFlags{ + ChainId: chains.SepoliaChain.ChainId, + Enabled: true, }) k.SetBlockHeader(ctx, blockHeader) diff --git a/x/lightclient/keeper/verification_flags.go b/x/lightclient/keeper/verification_flags.go index 169eb3a4b6..cb712f3241 100644 --- a/x/lightclient/keeper/verification_flags.go +++ b/x/lightclient/keeper/verification_flags.go @@ -1,25 +1,27 @@ package keeper import ( + "fmt" + cosmoserrors "cosmossdk.io/errors" "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/zeta-chain/zetacore/pkg/chains" "github.com/zeta-chain/zetacore/x/lightclient/types" ) // SetVerificationFlags set the verification flags in the store -func (k Keeper) SetVerificationFlags(ctx sdk.Context, crosschainFlags types.VerificationFlags) { +func (k Keeper) SetVerificationFlags(ctx sdk.Context, vf types.VerificationFlags) { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.VerificationFlagsKey)) - b := k.cdc.MustMarshal(&crosschainFlags) - store.Set([]byte{0}, b) + b := k.cdc.MustMarshal(&vf) + key := types.KeyPrefix(fmt.Sprintf("%d", vf.ChainId)) + store.Set(key, b) } // GetVerificationFlags returns the verification flags -func (k Keeper) GetVerificationFlags(ctx sdk.Context) (val types.VerificationFlags, found bool) { +func (k Keeper) GetVerificationFlags(ctx sdk.Context, chainID int64) (val types.VerificationFlags, found bool) { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.VerificationFlagsKey)) - - b := store.Get([]byte{0}) + key := types.KeyPrefix(fmt.Sprintf("%d", chainID)) + b := store.Get(key) if b == nil { return val, false } @@ -28,38 +30,31 @@ func (k Keeper) GetVerificationFlags(ctx sdk.Context) (val types.VerificationFla return val, true } +func (k Keeper) GetAllVerificationFlags(ctx sdk.Context) (verificationFlags []types.VerificationFlags) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.VerificationFlagsKey)) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var val types.VerificationFlags + k.cdc.MustUnmarshal(iterator.Value(), &val) + verificationFlags = append(verificationFlags, val) + } + + return verificationFlags + +} + // CheckVerificationFlagsEnabled checks for a specific chain if the verification flags are enabled // It returns an error if the chain is not enabled func (k Keeper) CheckVerificationFlagsEnabled(ctx sdk.Context, chainID int64) error { - verificationFlags, found := k.GetVerificationFlags(ctx) - if !found { - return types.ErrVerificationFlagsNotFound - } - - // check if the chain is enabled for the specific type - if chains.IsBitcoinChain(chainID) { - if !verificationFlags.BtcTypeChainEnabled { - return cosmoserrors.Wrapf( - types.ErrBlockHeaderVerificationDisabled, - "proof verification not enabled for bitcoin ,chain id: %d", - chainID, - ) - } - } else if chains.IsEVMChain(chainID) { - if !verificationFlags.EthTypeChainEnabled { - return cosmoserrors.Wrapf( - types.ErrBlockHeaderVerificationDisabled, - "proof verification not enabled for evm ,chain id: %d", - chainID, - ) - } - } else { + verificationFlags, found := k.GetVerificationFlags(ctx, chainID) + if !found || verificationFlags.Enabled != true { return cosmoserrors.Wrapf( - types.ErrChainNotSupported, - "chain ID %d doesn't support block header verification", + types.ErrBlockHeaderVerificationDisabled, + "proof verification not enabled for,chain id: %d", chainID, ) } - return nil } diff --git a/x/lightclient/keeper/verification_flags_test.go b/x/lightclient/keeper/verification_flags_test.go index 2466005dcb..20b71c3eeb 100644 --- a/x/lightclient/keeper/verification_flags_test.go +++ b/x/lightclient/keeper/verification_flags_test.go @@ -1,6 +1,7 @@ package keeper_test import ( + "fmt" "testing" "github.com/stretchr/testify/require" @@ -12,20 +13,18 @@ import ( func TestKeeper_GetVerificationFlags(t *testing.T) { t.Run("can get and set verification flags", func(t *testing.T) { k, ctx, _, _ := keepertest.LightclientKeeper(t) + ethChainId := chains.EthChain.ChainId - vf, found := k.GetVerificationFlags(ctx) + vf, found := k.GetVerificationFlags(ctx, ethChainId) require.False(t, found) k.SetVerificationFlags(ctx, types.VerificationFlags{ - EthTypeChainEnabled: false, - BtcTypeChainEnabled: true, + ChainId: ethChainId, + Enabled: true, }) - vf, found = k.GetVerificationFlags(ctx) + vf, found = k.GetVerificationFlags(ctx, ethChainId) require.True(t, found) - require.Equal(t, types.VerificationFlags{ - EthTypeChainEnabled: false, - BtcTypeChainEnabled: true, - }, vf) + require.True(t, vf.Enabled) }) } @@ -33,8 +32,8 @@ func TestKeeper_CheckVerificationFlagsEnabled(t *testing.T) { t.Run("can check verification flags with ethereum enabled", func(t *testing.T) { k, ctx, _, _ := keepertest.LightclientKeeper(t) k.SetVerificationFlags(ctx, types.VerificationFlags{ - EthTypeChainEnabled: true, - BtcTypeChainEnabled: false, + ChainId: chains.EthChain.ChainId, + Enabled: true, }) err := k.CheckVerificationFlagsEnabled(ctx, chains.EthChain.ChainId) @@ -42,29 +41,29 @@ func TestKeeper_CheckVerificationFlagsEnabled(t *testing.T) { err = k.CheckVerificationFlagsEnabled(ctx, chains.BtcMainnetChain.ChainId) require.Error(t, err) - require.ErrorContains(t, err, "proof verification not enabled for bitcoin") + require.ErrorContains(t, err, fmt.Sprintf("proof verification not enabled for,chain id: %d", chains.BtcMainnetChain.ChainId)) err = k.CheckVerificationFlagsEnabled(ctx, 1000) require.Error(t, err) - require.ErrorContains(t, err, "doesn't support block header verification") + require.ErrorContains(t, err, fmt.Sprintf("proof verification not enabled for,chain id: %d", 1000)) }) t.Run("can check verification flags with bitcoin enabled", func(t *testing.T) { k, ctx, _, _ := keepertest.LightclientKeeper(t) k.SetVerificationFlags(ctx, types.VerificationFlags{ - EthTypeChainEnabled: false, - BtcTypeChainEnabled: true, + ChainId: chains.BtcMainnetChain.ChainId, + Enabled: true, }) err := k.CheckVerificationFlagsEnabled(ctx, chains.EthChain.ChainId) require.Error(t, err) - require.ErrorContains(t, err, "proof verification not enabled for evm") + require.ErrorContains(t, err, fmt.Sprintf("proof verification not enabled for,chain id: %d", chains.EthChain.ChainId)) err = k.CheckVerificationFlagsEnabled(ctx, chains.BtcMainnetChain.ChainId) require.NoError(t, err) err = k.CheckVerificationFlagsEnabled(ctx, 1000) require.Error(t, err) - require.ErrorContains(t, err, "doesn't support block header verification") + require.ErrorContains(t, err, fmt.Sprintf("proof verification not enabled for,chain id: %d", 1000)) }) } diff --git a/x/lightclient/types/codec.go b/x/lightclient/types/codec.go index b8a4fe6c43..b80f2c778b 100644 --- a/x/lightclient/types/codec.go +++ b/x/lightclient/types/codec.go @@ -8,12 +8,16 @@ import ( ) func RegisterCodec(cdc *codec.LegacyAmino) { - cdc.RegisterConcrete(&MsgUpdateVerificationFlags{}, "lightclient/UpdateVerificationFlags", nil) + cdc.RegisterConcrete(&MsgEnableVerificationFlags{}, "lightclient/EnableVerificationFlags", nil) + cdc.RegisterConcrete(&MsgDisableVerificationFlags{}, "lightclient/DisableVerificationFlags", nil) } func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { registry.RegisterImplementations((*sdk.Msg)(nil), - &MsgUpdateVerificationFlags{}, + &MsgEnableVerificationFlags{}, + ) + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgDisableVerificationFlags{}, ) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) diff --git a/x/lightclient/types/genesis.go b/x/lightclient/types/genesis.go index d4883d5b33..d9325ab546 100644 --- a/x/lightclient/types/genesis.go +++ b/x/lightclient/types/genesis.go @@ -9,12 +9,9 @@ import ( // DefaultGenesis returns the default lightclient genesis state func DefaultGenesis() *GenesisState { return &GenesisState{ - BlockHeaders: []proofs.BlockHeader{}, - ChainStates: []ChainState{}, - VerificationFlags: VerificationFlags{ - EthTypeChainEnabled: false, - BtcTypeChainEnabled: false, - }, + BlockHeaders: []proofs.BlockHeader{}, + ChainStates: []ChainState{}, + VerificationFlags: []VerificationFlags{}, } } diff --git a/x/lightclient/types/genesis.pb.go b/x/lightclient/types/genesis.pb.go index adca0d82ee..8ad8850330 100644 --- a/x/lightclient/types/genesis.pb.go +++ b/x/lightclient/types/genesis.pb.go @@ -29,7 +29,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type GenesisState struct { BlockHeaders []proofs.BlockHeader `protobuf:"bytes,1,rep,name=block_headers,json=blockHeaders,proto3" json:"block_headers"` ChainStates []ChainState `protobuf:"bytes,2,rep,name=chain_states,json=chainStates,proto3" json:"chain_states"` - VerificationFlags VerificationFlags `protobuf:"bytes,3,opt,name=verification_flags,json=verificationFlags,proto3" json:"verification_flags"` + VerificationFlags []VerificationFlags `protobuf:"bytes,3,rep,name=verification_flags,json=verificationFlags,proto3" json:"verification_flags"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -79,11 +79,11 @@ func (m *GenesisState) GetChainStates() []ChainState { return nil } -func (m *GenesisState) GetVerificationFlags() VerificationFlags { +func (m *GenesisState) GetVerificationFlags() []VerificationFlags { if m != nil { return m.VerificationFlags } - return VerificationFlags{} + return nil } func init() { @@ -93,7 +93,7 @@ func init() { func init() { proto.RegisterFile("lightclient/genesis.proto", fileDescriptor_645b5300b371cd43) } var fileDescriptor_645b5300b371cd43 = []byte{ - // 314 bytes of a gzipped FileDescriptorProto + // 312 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xcc, 0xc9, 0x4c, 0xcf, 0x28, 0x49, 0xce, 0xc9, 0x4c, 0xcd, 0x2b, 0xd1, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0xab, 0x4a, 0x2d, 0x49, 0x4c, 0xce, 0x48, 0xcc, 0xcc, @@ -107,13 +107,13 @@ var fileDescriptor_645b5300b371cd43 = []byte{ 0xda, 0x9c, 0x40, 0x92, 0x1e, 0x60, 0x39, 0x27, 0x96, 0x13, 0xf7, 0xe4, 0x19, 0x82, 0x78, 0x92, 0x10, 0x42, 0xc5, 0x42, 0xc1, 0x5c, 0x3c, 0x48, 0x8e, 0x2c, 0x96, 0x60, 0x02, 0x6b, 0xd7, 0xd2, 0xc3, 0xef, 0x77, 0x3d, 0x67, 0x90, 0x14, 0xd8, 0x05, 0x50, 0x53, 0xb9, 0x93, 0xe1, 0x22, 0xc5, - 0x42, 0x69, 0x5c, 0x42, 0x98, 0x5e, 0x93, 0x60, 0x56, 0x60, 0xd4, 0xe0, 0x36, 0x32, 0x24, 0x64, - 0x74, 0x18, 0x92, 0x4e, 0x37, 0x90, 0x46, 0xa8, 0x0d, 0x82, 0x65, 0x18, 0x12, 0x3e, 0x27, 0x1e, - 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, 0x1c, 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, - 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, 0x10, 0x65, 0x94, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, - 0x97, 0x9c, 0x9f, 0xab, 0x0f, 0xb2, 0x45, 0x17, 0x6c, 0xa1, 0x3e, 0xcc, 0x42, 0xfd, 0x0a, 0x7d, - 0xe4, 0x78, 0x28, 0xa9, 0x2c, 0x48, 0x2d, 0x4e, 0x62, 0x03, 0x07, 0xb1, 0x31, 0x20, 0x00, 0x00, - 0xff, 0xff, 0xd4, 0xfb, 0x01, 0x8d, 0x13, 0x02, 0x00, 0x00, + 0x42, 0x69, 0x5c, 0x42, 0x98, 0x5e, 0x93, 0x60, 0x06, 0x1b, 0x6d, 0x48, 0xc8, 0xe8, 0x30, 0x24, + 0x9d, 0x6e, 0x20, 0x8d, 0x50, 0x1b, 0x04, 0xcb, 0x30, 0x24, 0x7c, 0x4e, 0x3c, 0x92, 0x63, 0xbc, + 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, + 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0xca, 0x28, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, + 0x57, 0x1f, 0x64, 0x8b, 0x2e, 0xd8, 0x42, 0x7d, 0x98, 0x85, 0xfa, 0x15, 0xfa, 0xc8, 0xf1, 0x50, + 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, 0x0e, 0x62, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, + 0xac, 0xc7, 0x30, 0xaf, 0x13, 0x02, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -136,16 +136,20 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - { - size, err := m.VerificationFlags.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err + if len(m.VerificationFlags) > 0 { + for iNdEx := len(m.VerificationFlags) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.VerificationFlags[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) } - i-- - dAtA[i] = 0x1a if len(m.ChainStates) > 0 { for iNdEx := len(m.ChainStates) - 1; iNdEx >= 0; iNdEx-- { { @@ -206,8 +210,12 @@ func (m *GenesisState) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } - l = m.VerificationFlags.Size() - n += 1 + l + sovGenesis(uint64(l)) + if len(m.VerificationFlags) > 0 { + for _, e := range m.VerificationFlags { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } return n } @@ -343,7 +351,8 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.VerificationFlags.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.VerificationFlags = append(m.VerificationFlags, VerificationFlags{}) + if err := m.VerificationFlags[len(m.VerificationFlags)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/x/lightclient/types/genesis_test.go b/x/lightclient/types/genesis_test.go index ee875393ea..004b8dc022 100644 --- a/x/lightclient/types/genesis_test.go +++ b/x/lightclient/types/genesis_test.go @@ -22,10 +22,7 @@ func TestGenesisState_Validate(t *testing.T) { { desc: "valid genesis state", genState: &types.GenesisState{ - VerificationFlags: types.VerificationFlags{ - EthTypeChainEnabled: false, - BtcTypeChainEnabled: true, - }, + VerificationFlags: sample.VerificationFlags(), BlockHeaders: []proofs.BlockHeader{ sample.BlockHeader(sample.Hash().Bytes()), sample.BlockHeader(sample.Hash().Bytes()), diff --git a/x/lightclient/types/message_disable_verification_flags.go b/x/lightclient/types/message_disable_verification_flags.go new file mode 100644 index 0000000000..12df4cddd3 --- /dev/null +++ b/x/lightclient/types/message_disable_verification_flags.go @@ -0,0 +1,63 @@ +package types + +import ( + cosmoserrors "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/zeta-chain/zetacore/pkg/chains" +) + +const ( + TypeMsgDisableVerificationFlags = "disable_verification_flags" +) + +var _ sdk.Msg = &MsgDisableVerificationFlags{} + +func NewMsgDisableVerificationFlags(creator string, chainIDs []int64) *MsgDisableVerificationFlags { + return &MsgDisableVerificationFlags{ + Creator: creator, + ChainIdList: chainIDs, + } + +} + +func (msg *MsgDisableVerificationFlags) Route() string { + return RouterKey +} + +func (msg *MsgDisableVerificationFlags) Type() string { + return TypeMsgDisableVerificationFlags +} + +func (msg *MsgDisableVerificationFlags) GetSigners() []sdk.AccAddress { + creator, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + panic(err) + } + return []sdk.AccAddress{creator} +} + +func (msg *MsgDisableVerificationFlags) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgDisableVerificationFlags) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(msg.Creator); err != nil { + return cosmoserrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) + } + changelistForHeaderSupport := chains.ChainListForHeaderSupport() + if len(msg.ChainIdList) == 0 { + return cosmoserrors.Wrapf(sdkerrors.ErrInvalidRequest, "chain id list cannot be empty") + } + if len(msg.ChainIdList) > len(changelistForHeaderSupport) { + return cosmoserrors.Wrapf(sdkerrors.ErrInvalidRequest, "chain id list cannot be greater than supported chains") + } + for _, chainID := range msg.ChainIdList { + if !chains.ChainIDInChainList(chainID, changelistForHeaderSupport) { + return cosmoserrors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid chain id header not supported (%d)", chainID) + } + } + + return nil +} diff --git a/x/lightclient/types/message_disable_verification_flags_test.go b/x/lightclient/types/message_disable_verification_flags_test.go new file mode 100644 index 0000000000..18f45764e7 --- /dev/null +++ b/x/lightclient/types/message_disable_verification_flags_test.go @@ -0,0 +1,140 @@ +package types_test + +import ( + "fmt" + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/stretchr/testify/require" + "github.com/zeta-chain/zetacore/pkg/chains" + "github.com/zeta-chain/zetacore/testutil/sample" + "github.com/zeta-chain/zetacore/x/lightclient/types" +) + +func TestMsgDisableVerificationFlags_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg types.MsgDisableVerificationFlags + err require.ErrorAssertionFunc + }{ + { + name: "invalid address", + msg: types.MsgDisableVerificationFlags{ + Creator: "invalid_address", + }, + err: func(t require.TestingT, err error, i ...interface{}) { + require.ErrorIs(t, err, sdkerrors.ErrInvalidAddress) + }, + }, + { + name: "empty chain id list", + msg: types.MsgDisableVerificationFlags{ + Creator: sample.AccAddress(), + ChainIdList: []int64{}, + }, + err: func(t require.TestingT, err error, i ...interface{}) { + require.ErrorIs(t, err, sdkerrors.ErrInvalidRequest) + require.ErrorContains(t, err, "chain id list cannot be empty") + }, + }, + { + name: "chain id list is too long", + msg: types.MsgDisableVerificationFlags{ + Creator: sample.AccAddress(), + ChainIdList: make([]int64, 200), + }, + err: func(t require.TestingT, err error, i ...interface{}) { + require.ErrorIs(t, err, sdkerrors.ErrInvalidRequest) + require.ErrorContains(t, err, "chain id list cannot be greater than supported chains") + }, + }, + { + name: "invalid chain id", + msg: types.MsgDisableVerificationFlags{ + Creator: sample.AccAddress(), + ChainIdList: []int64{chains.BtcMainnetChain.ChainId}, + }, + err: func(t require.TestingT, err error, i ...interface{}) { + require.ErrorIs(t, err, sdkerrors.ErrInvalidRequest) + require.ErrorContains(t, err, fmt.Sprintf("invalid chain id header not supported (%d)", chains.BtcMainnetChain.ChainId)) + }, + }, + { + name: "valid address", + msg: types.MsgDisableVerificationFlags{ + Creator: sample.AccAddress(), + ChainIdList: []int64{chains.EthChain.ChainId}, + }, + err: require.NoError, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + tt.err(t, err) + }) + } +} + +func TestMsgDisableVerificationFlags_GetSigners(t *testing.T) { + signer := sample.AccAddress() + tests := []struct { + name string + msg *types.MsgEnableVerificationFlags + panics bool + }{ + { + name: "valid signer", + msg: types.NewMsgEnableVerificationFlags( + signer, + []int64{chains.EthChain.ChainId, chains.BtcMainnetChain.ChainId}, + ), + panics: false, + }, + { + name: "invalid signer", + msg: types.NewMsgEnableVerificationFlags( + "invalid", + []int64{chains.EthChain.ChainId, chains.BtcMainnetChain.ChainId}, + ), + panics: true, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if !tt.panics { + signers := tt.msg.GetSigners() + require.Equal(t, []sdk.AccAddress{sdk.MustAccAddressFromBech32(signer)}, signers) + } else { + require.Panics(t, func() { + tt.msg.GetSigners() + }) + } + }) + } +} + +func TestMsgDisableVerificationFlags_Type(t *testing.T) { + msg := types.MsgDisableVerificationFlags{ + Creator: sample.AccAddress(), + } + require.Equal(t, types.TypeMsgDisableVerificationFlags, msg.Type()) +} + +func TestMsgDisableVerificationFlags_Route(t *testing.T) { + msg := types.MsgEnableVerificationFlags{ + Creator: sample.AccAddress(), + } + require.Equal(t, types.RouterKey, msg.Route()) +} + +func TestMsgDisableVerificationFlags_GetSignBytes(t *testing.T) { + msg := types.MsgEnableVerificationFlags{ + Creator: sample.AccAddress(), + } + require.NotPanics(t, func() { + msg.GetSignBytes() + }) +} diff --git a/x/lightclient/types/message_enable_verification_flags.go b/x/lightclient/types/message_enable_verification_flags.go new file mode 100644 index 0000000000..1252274f02 --- /dev/null +++ b/x/lightclient/types/message_enable_verification_flags.go @@ -0,0 +1,63 @@ +package types + +import ( + cosmoserrors "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/zeta-chain/zetacore/pkg/chains" +) + +const ( + TypeMsgEnableVerificationFlags = "enable_verification_flags" +) + +var _ sdk.Msg = &MsgEnableVerificationFlags{} + +func NewMsgEnableVerificationFlags(creator string, chainIDs []int64) *MsgEnableVerificationFlags { + return &MsgEnableVerificationFlags{ + Creator: creator, + ChainIdList: chainIDs, + } + +} + +func (msg *MsgEnableVerificationFlags) Route() string { + return RouterKey +} + +func (msg *MsgEnableVerificationFlags) Type() string { + return TypeMsgEnableVerificationFlags +} + +func (msg *MsgEnableVerificationFlags) GetSigners() []sdk.AccAddress { + creator, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + panic(err) + } + return []sdk.AccAddress{creator} +} + +func (msg *MsgEnableVerificationFlags) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgEnableVerificationFlags) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(msg.Creator); err != nil { + return cosmoserrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) + } + changelistForHeaderSupport := chains.ChainListForHeaderSupport() + if len(msg.ChainIdList) == 0 { + return cosmoserrors.Wrapf(sdkerrors.ErrInvalidRequest, "chain id list cannot be empty") + } + if len(msg.ChainIdList) > len(changelistForHeaderSupport) { + return cosmoserrors.Wrapf(sdkerrors.ErrInvalidRequest, "chain id list cannot be greater than supported chains") + } + for _, chainID := range msg.ChainIdList { + if !chains.ChainIDInChainList(chainID, changelistForHeaderSupport) { + return cosmoserrors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid chain id header not supported (%d)", chainID) + } + } + + return nil +} diff --git a/x/lightclient/types/message_enable_verification_flags_test.go b/x/lightclient/types/message_enable_verification_flags_test.go new file mode 100644 index 0000000000..c534267b29 --- /dev/null +++ b/x/lightclient/types/message_enable_verification_flags_test.go @@ -0,0 +1,140 @@ +package types_test + +import ( + "fmt" + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/stretchr/testify/require" + "github.com/zeta-chain/zetacore/pkg/chains" + "github.com/zeta-chain/zetacore/testutil/sample" + "github.com/zeta-chain/zetacore/x/lightclient/types" +) + +func TestMsgEnableVerificationFlags_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg types.MsgEnableVerificationFlags + err require.ErrorAssertionFunc + }{ + { + name: "invalid address", + msg: types.MsgEnableVerificationFlags{ + Creator: "invalid_address", + }, + err: func(t require.TestingT, err error, i ...interface{}) { + require.ErrorIs(t, err, sdkerrors.ErrInvalidAddress) + }, + }, + { + name: "empty chain id list", + msg: types.MsgEnableVerificationFlags{ + Creator: sample.AccAddress(), + ChainIdList: []int64{}, + }, + err: func(t require.TestingT, err error, i ...interface{}) { + require.ErrorIs(t, err, sdkerrors.ErrInvalidRequest) + require.ErrorContains(t, err, "chain id list cannot be empty") + }, + }, + { + name: "chain id list is too long", + msg: types.MsgEnableVerificationFlags{ + Creator: sample.AccAddress(), + ChainIdList: make([]int64, 200), + }, + err: func(t require.TestingT, err error, i ...interface{}) { + require.ErrorIs(t, err, sdkerrors.ErrInvalidRequest) + require.ErrorContains(t, err, "chain id list cannot be greater than supported chains") + }, + }, + { + name: "invalid chain id", + msg: types.MsgEnableVerificationFlags{ + Creator: sample.AccAddress(), + ChainIdList: []int64{chains.BtcMainnetChain.ChainId}, + }, + err: func(t require.TestingT, err error, i ...interface{}) { + require.ErrorIs(t, err, sdkerrors.ErrInvalidRequest) + require.ErrorContains(t, err, fmt.Sprintf("invalid chain id header not supported (%d)", chains.BtcMainnetChain.ChainId)) + }, + }, + { + name: "valid address", + msg: types.MsgEnableVerificationFlags{ + Creator: sample.AccAddress(), + ChainIdList: []int64{chains.EthChain.ChainId}, + }, + err: require.NoError, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + tt.err(t, err) + }) + } +} + +func TestMsgEnableVerificationFlags_GetSigners(t *testing.T) { + signer := sample.AccAddress() + tests := []struct { + name string + msg *types.MsgEnableVerificationFlags + panics bool + }{ + { + name: "valid signer", + msg: types.NewMsgEnableVerificationFlags( + signer, + []int64{chains.EthChain.ChainId, chains.BtcMainnetChain.ChainId}, + ), + panics: false, + }, + { + name: "invalid signer", + msg: types.NewMsgEnableVerificationFlags( + "invalid", + []int64{chains.EthChain.ChainId, chains.BtcMainnetChain.ChainId}, + ), + panics: true, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if !tt.panics { + signers := tt.msg.GetSigners() + require.Equal(t, []sdk.AccAddress{sdk.MustAccAddressFromBech32(signer)}, signers) + } else { + require.Panics(t, func() { + tt.msg.GetSigners() + }) + } + }) + } +} + +func TestMsgEnableVerificationFlags_Type(t *testing.T) { + msg := types.MsgEnableVerificationFlags{ + Creator: sample.AccAddress(), + } + require.Equal(t, types.TypeMsgEnableVerificationFlags, msg.Type()) +} + +func TestMsgEnableVerificationFlags_Route(t *testing.T) { + msg := types.MsgEnableVerificationFlags{ + Creator: sample.AccAddress(), + } + require.Equal(t, types.RouterKey, msg.Route()) +} + +func TestMsgEnableVerificationFlags_GetSignBytes(t *testing.T) { + msg := types.MsgEnableVerificationFlags{ + Creator: sample.AccAddress(), + } + require.NotPanics(t, func() { + msg.GetSignBytes() + }) +} diff --git a/x/lightclient/types/message_update_verification_flags.go b/x/lightclient/types/message_update_verification_flags.go deleted file mode 100644 index a180596e40..0000000000 --- a/x/lightclient/types/message_update_verification_flags.go +++ /dev/null @@ -1,62 +0,0 @@ -package types - -import ( - cosmoserrors "cosmossdk.io/errors" - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - authoritytypes "github.com/zeta-chain/zetacore/x/authority/types" -) - -const ( - TypeMsgUpdateVerificationFlags = "update_verification_flags" -) - -var _ sdk.Msg = &MsgUpdateVerificationFlags{} - -func NewMsgUpdateVerificationFlags(creator string, ethTypeChainEnabled, btcTypeChainEnabled bool) *MsgUpdateVerificationFlags { - return &MsgUpdateVerificationFlags{ - Creator: creator, - VerificationFlags: VerificationFlags{ - EthTypeChainEnabled: ethTypeChainEnabled, - BtcTypeChainEnabled: btcTypeChainEnabled, - }, - } -} - -func (msg *MsgUpdateVerificationFlags) Route() string { - return RouterKey -} - -func (msg *MsgUpdateVerificationFlags) Type() string { - return TypeMsgUpdateVerificationFlags -} - -func (msg *MsgUpdateVerificationFlags) GetSigners() []sdk.AccAddress { - creator, err := sdk.AccAddressFromBech32(msg.Creator) - if err != nil { - panic(err) - } - return []sdk.AccAddress{creator} -} - -func (msg *MsgUpdateVerificationFlags) GetSignBytes() []byte { - bz := ModuleCdc.MustMarshalJSON(msg) - return sdk.MustSortJSON(bz) -} - -func (msg *MsgUpdateVerificationFlags) ValidateBasic() error { - if _, err := sdk.AccAddressFromBech32(msg.Creator); err != nil { - return cosmoserrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) - } - return nil -} - -// GetRequireGroup returns the required group to execute the message -func (msg *MsgUpdateVerificationFlags) GetRequireGroup() authoritytypes.PolicyType { - requiredGroup := authoritytypes.PolicyType_groupEmergency - if msg.VerificationFlags.EthTypeChainEnabled || msg.VerificationFlags.BtcTypeChainEnabled { - requiredGroup = authoritytypes.PolicyType_groupOperational - } - - return requiredGroup -} diff --git a/x/lightclient/types/message_update_verification_flags_test.go b/x/lightclient/types/message_update_verification_flags_test.go deleted file mode 100644 index 0b667ee08d..0000000000 --- a/x/lightclient/types/message_update_verification_flags_test.go +++ /dev/null @@ -1,173 +0,0 @@ -package types_test - -import ( - "testing" - - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/stretchr/testify/require" - "github.com/zeta-chain/zetacore/testutil/sample" - authoritytypes "github.com/zeta-chain/zetacore/x/authority/types" - "github.com/zeta-chain/zetacore/x/lightclient/types" -) - -func TestMsgUpdateVerificationFlags_ValidateBasic(t *testing.T) { - tests := []struct { - name string - msg types.MsgUpdateVerificationFlags - err error - }{ - { - name: "invalid address", - msg: types.MsgUpdateVerificationFlags{ - Creator: "invalid_address", - }, - err: sdkerrors.ErrInvalidAddress, - }, - { - name: "valid address", - msg: types.MsgUpdateVerificationFlags{ - Creator: sample.AccAddress(), - VerificationFlags: types.VerificationFlags{ - EthTypeChainEnabled: true, - BtcTypeChainEnabled: true, - }, - }, - }, - { - name: "verification flags can be false", - msg: types.MsgUpdateVerificationFlags{ - Creator: sample.AccAddress(), - }, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - err := tt.msg.ValidateBasic() - if tt.err != nil { - require.ErrorIs(t, err, tt.err) - return - } - require.NoError(t, err) - }) - } -} - -func TestMsgUpdateVerificationFlags_GetSigners(t *testing.T) { - signer := sample.AccAddress() - tests := []struct { - name string - msg *types.MsgUpdateVerificationFlags - panics bool - }{ - { - name: "valid signer", - msg: types.NewMsgUpdateVerificationFlags( - signer, - true, - true, - ), - panics: false, - }, - { - name: "invalid signer", - msg: types.NewMsgUpdateVerificationFlags( - "invalid", - true, - true, - ), - panics: true, - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if !tt.panics { - signers := tt.msg.GetSigners() - require.Equal(t, []sdk.AccAddress{sdk.MustAccAddressFromBech32(signer)}, signers) - } else { - require.Panics(t, func() { - tt.msg.GetSigners() - }) - } - }) - } -} - -func TestMsgUpdateVerificationFlags_Type(t *testing.T) { - msg := types.MsgUpdateVerificationFlags{ - Creator: sample.AccAddress(), - } - require.Equal(t, types.TypeMsgUpdateVerificationFlags, msg.Type()) -} - -func TestMsgUpdateVerificationFlags_Route(t *testing.T) { - msg := types.MsgUpdateVerificationFlags{ - Creator: sample.AccAddress(), - } - require.Equal(t, types.RouterKey, msg.Route()) -} - -func TestMsgUpdateVerificationFlags_GetSignBytes(t *testing.T) { - msg := types.MsgUpdateVerificationFlags{ - Creator: sample.AccAddress(), - } - require.NotPanics(t, func() { - msg.GetSignBytes() - }) -} - -func TestMsgUpdateVerificationFlags_GetRequireGroup(t *testing.T) { - tests := []struct { - name string - msg types.MsgUpdateVerificationFlags - want authoritytypes.PolicyType - }{ - { - name: "groupEmergency", - msg: types.MsgUpdateVerificationFlags{ - VerificationFlags: types.VerificationFlags{ - EthTypeChainEnabled: false, - BtcTypeChainEnabled: false, - }, - }, - want: authoritytypes.PolicyType_groupEmergency, - }, - { - name: "groupOperational", - msg: types.MsgUpdateVerificationFlags{ - VerificationFlags: types.VerificationFlags{ - EthTypeChainEnabled: true, - BtcTypeChainEnabled: false, - }, - }, - want: authoritytypes.PolicyType_groupOperational, - }, - { - name: "groupOperational", - msg: types.MsgUpdateVerificationFlags{ - VerificationFlags: types.VerificationFlags{ - EthTypeChainEnabled: false, - BtcTypeChainEnabled: true, - }, - }, - want: authoritytypes.PolicyType_groupOperational, - }, - { - name: "groupOperational", - msg: types.MsgUpdateVerificationFlags{ - VerificationFlags: types.VerificationFlags{ - EthTypeChainEnabled: true, - BtcTypeChainEnabled: true, - }, - }, - want: authoritytypes.PolicyType_groupOperational, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - got := tt.msg.GetRequireGroup() - require.Equal(t, tt.want, got) - }) - } -} diff --git a/x/lightclient/types/query.pb.go b/x/lightclient/types/query.pb.go index 7d96e11051..c60a481d0a 100644 --- a/x/lightclient/types/query.pb.go +++ b/x/lightclient/types/query.pb.go @@ -557,7 +557,7 @@ func (m *QueryVerificationFlagsRequest) XXX_DiscardUnknown() { var xxx_messageInfo_QueryVerificationFlagsRequest proto.InternalMessageInfo type QueryVerificationFlagsResponse struct { - VerificationFlags VerificationFlags `protobuf:"bytes,1,opt,name=verification_flags,json=verificationFlags,proto3" json:"verification_flags"` + VerificationFlags []VerificationFlags `protobuf:"bytes,1,rep,name=verification_flags,json=verificationFlags,proto3" json:"verification_flags"` } func (m *QueryVerificationFlagsResponse) Reset() { *m = QueryVerificationFlagsResponse{} } @@ -593,11 +593,11 @@ func (m *QueryVerificationFlagsResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryVerificationFlagsResponse proto.InternalMessageInfo -func (m *QueryVerificationFlagsResponse) GetVerificationFlags() VerificationFlags { +func (m *QueryVerificationFlagsResponse) GetVerificationFlags() []VerificationFlags { if m != nil { return m.VerificationFlags } - return VerificationFlags{} + return nil } func init() { @@ -618,7 +618,7 @@ func init() { func init() { proto.RegisterFile("lightclient/query.proto", fileDescriptor_03e46747c4ffba77) } var fileDescriptor_03e46747c4ffba77 = []byte{ - // 843 bytes of a gzipped FileDescriptorProto + // 844 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x96, 0xcd, 0x4e, 0xdb, 0x4a, 0x14, 0xc7, 0x33, 0x40, 0xf8, 0x98, 0xc0, 0x95, 0x98, 0x8b, 0x44, 0xf0, 0xbd, 0x31, 0xc8, 0x5c, 0x2e, 0x28, 0x2d, 0x76, 0x93, 0x56, 0x48, 0x0d, 0x2a, 0x12, 0x54, 0x82, 0xa2, 0x76, 0x01, 0xae, @@ -654,24 +654,24 @@ var fileDescriptor_03e46747c4ffba77 = []byte{ 0x82, 0xa8, 0x4f, 0x83, 0xba, 0xb4, 0x51, 0xb4, 0xdd, 0x32, 0x6e, 0xa4, 0x93, 0x61, 0x5d, 0xda, 0xd8, 0x0e, 0x5e, 0x95, 0x2c, 0x44, 0x22, 0x27, 0xf7, 0x62, 0x0a, 0x26, 0xeb, 0x86, 0xc3, 0x29, 0x47, 0xf5, 0xf0, 0x45, 0x99, 0x85, 0x19, 0xf6, 0xed, 0x73, 0x61, 0xe8, 0x6c, 0x06, 0x33, 0x87, - 0xeb, 0x53, 0x5e, 0x03, 0x28, 0xf7, 0xfa, 0x82, 0x67, 0xae, 0x40, 0xd4, 0x39, 0xb3, 0xb8, 0xd9, - 0xb9, 0xab, 0xcc, 0xee, 0x48, 0xcb, 0xbb, 0x6c, 0xb2, 0xde, 0xbe, 0x91, 0xff, 0x36, 0x0a, 0x93, - 0x0c, 0x05, 0x9d, 0x02, 0xf8, 0x97, 0x70, 0xd5, 0xd6, 0x1d, 0x07, 0x15, 0xae, 0x2a, 0xd4, 0x7b, - 0x42, 0x4a, 0xab, 0x7d, 0xc5, 0x86, 0xea, 0x95, 0xe5, 0x57, 0x5f, 0x7e, 0xbe, 0x1d, 0x58, 0x44, - 0x0b, 0x5a, 0x10, 0xba, 0xcc, 0xb2, 0x68, 0xe2, 0x3c, 0x6f, 0x19, 0x8a, 0xe8, 0x13, 0x80, 0x29, - 0x21, 0x4d, 0x4c, 0xee, 0xae, 0xa3, 0x2c, 0x26, 0x77, 0xf7, 0x49, 0xa6, 0x14, 0x18, 0xf7, 0x3d, - 0x94, 0x8f, 0xc5, 0xad, 0x1d, 0x47, 0xcd, 0x78, 0x82, 0x3e, 0x00, 0x38, 0x11, 0xdd, 0x92, 0xc0, - 0xfe, 0xfb, 0x71, 0x2d, 0xec, 0xb8, 0xdd, 0x52, 0xa1, 0x9f, 0x50, 0x2e, 0xe2, 0x16, 0x13, 0xb1, - 0x80, 0xe6, 0x7b, 0x89, 0x10, 0xae, 0x3f, 0xfa, 0x08, 0x20, 0x8c, 0x72, 0xc4, 0x44, 0xee, 0x36, - 0x90, 0xa4, 0x42, 0x3f, 0xa1, 0x1c, 0x79, 0x85, 0x21, 0xdf, 0x41, 0x6a, 0x0c, 0x64, 0xed, 0xb8, - 0x39, 0x5b, 0x4e, 0xd0, 0x3b, 0x00, 0x93, 0xec, 0x46, 0xa3, 0x5c, 0xac, 0xea, 0xe2, 0x94, 0x92, - 0xf2, 0xd7, 0x09, 0xe1, 0xa0, 0x0b, 0x0c, 0x74, 0x16, 0x65, 0x7a, 0x81, 0x7a, 0x8c, 0xe6, 0x33, - 0x80, 0x93, 0x1d, 0x97, 0x18, 0x3d, 0x88, 0x55, 0xb0, 0xd7, 0xd4, 0x91, 0xd6, 0xfa, 0x0d, 0xe7, - 0xec, 0x79, 0xc6, 0x7e, 0x1b, 0x65, 0x7b, 0xb1, 0x77, 0x0e, 0xac, 0x8d, 0x27, 0x67, 0x17, 0x32, - 0x38, 0xbf, 0x90, 0xc1, 0x8f, 0x0b, 0x19, 0xbc, 0xb9, 0x94, 0x13, 0xe7, 0x97, 0x72, 0xe2, 0xeb, - 0xa5, 0x9c, 0x78, 0x91, 0xb7, 0x6c, 0x5a, 0x3d, 0x2c, 0xa9, 0x26, 0xd9, 0x17, 0xf3, 0x35, 0xc1, - 0xb4, 0x46, 0x4b, 0x6a, 0x7a, 0xe4, 0x61, 0xbf, 0x34, 0xcc, 0xfe, 0x9a, 0xdd, 0xfd, 0x15, 0x00, - 0x00, 0xff, 0xff, 0x4b, 0x9e, 0x6d, 0x85, 0x93, 0x0a, 0x00, 0x00, + 0xeb, 0x53, 0x5e, 0x03, 0x28, 0xf7, 0xfa, 0x82, 0x67, 0xae, 0x40, 0xd4, 0x39, 0xb3, 0x78, 0x7b, + 0xe5, 0xae, 0x32, 0xbb, 0x23, 0x2d, 0xef, 0xb2, 0xc9, 0x7a, 0xfb, 0x46, 0xfe, 0xdb, 0x28, 0x4c, + 0x32, 0x14, 0x74, 0x0a, 0xe0, 0x5f, 0xc2, 0x55, 0x5b, 0x77, 0x1c, 0x54, 0xb8, 0xaa, 0x50, 0xef, + 0x09, 0x29, 0xad, 0xf6, 0x15, 0x1b, 0xaa, 0x57, 0x96, 0x5f, 0x7d, 0xf9, 0xf9, 0x76, 0x60, 0x11, + 0x2d, 0x68, 0x41, 0xe8, 0x32, 0xcb, 0xa2, 0x89, 0xf3, 0xbc, 0x65, 0x28, 0xa2, 0x4f, 0x00, 0xa6, + 0x84, 0x34, 0x31, 0xb9, 0xbb, 0x8e, 0xb2, 0x98, 0xdc, 0xdd, 0x27, 0x99, 0x52, 0x60, 0xdc, 0xf7, + 0x50, 0x3e, 0x16, 0xb7, 0x76, 0x1c, 0x35, 0xe3, 0x09, 0xfa, 0x00, 0xe0, 0x44, 0x74, 0x4b, 0x02, + 0xfb, 0xef, 0xc7, 0xb5, 0xb0, 0xe3, 0x76, 0x4b, 0x85, 0x7e, 0x42, 0xb9, 0x88, 0x5b, 0x4c, 0xc4, + 0x02, 0x9a, 0xef, 0x25, 0x42, 0xb8, 0xfe, 0xe8, 0x23, 0x80, 0x30, 0xca, 0x11, 0x13, 0xb9, 0xdb, + 0x40, 0x92, 0x0a, 0xfd, 0x84, 0x72, 0xe4, 0x15, 0x86, 0x7c, 0x07, 0xa9, 0x31, 0x90, 0xb5, 0xe3, + 0xe6, 0x6c, 0x39, 0x41, 0xef, 0x00, 0x4c, 0xb2, 0x1b, 0x8d, 0x72, 0xb1, 0xaa, 0x8b, 0x53, 0x4a, + 0xca, 0x5f, 0x27, 0x84, 0x83, 0x2e, 0x30, 0xd0, 0x59, 0x94, 0xe9, 0x05, 0xea, 0x31, 0x9a, 0xcf, + 0x00, 0x4e, 0x76, 0x5c, 0x62, 0xf4, 0x20, 0x56, 0xc1, 0x5e, 0x53, 0x47, 0x5a, 0xeb, 0x37, 0x9c, + 0xb3, 0xe7, 0x19, 0xfb, 0x6d, 0x94, 0xed, 0xc5, 0xde, 0x39, 0xb0, 0x36, 0x9e, 0x9c, 0x5d, 0xc8, + 0xe0, 0xfc, 0x42, 0x06, 0x3f, 0x2e, 0x64, 0xf0, 0xe6, 0x52, 0x4e, 0x9c, 0x5f, 0xca, 0x89, 0xaf, + 0x97, 0x72, 0xe2, 0x45, 0xde, 0xb2, 0x69, 0xf5, 0xb0, 0xa4, 0x9a, 0x64, 0x5f, 0xcc, 0xd7, 0x04, + 0xd3, 0x1a, 0x2d, 0xa9, 0xe9, 0x91, 0x87, 0xfd, 0xd2, 0x30, 0xfb, 0x6b, 0x76, 0xf7, 0x57, 0x00, + 0x00, 0x00, 0xff, 0xff, 0x25, 0x64, 0xfd, 0xdf, 0x93, 0x0a, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1365,16 +1365,20 @@ func (m *QueryVerificationFlagsResponse) MarshalToSizedBuffer(dAtA []byte) (int, _ = i var l int _ = l - { - size, err := m.VerificationFlags.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err + if len(m.VerificationFlags) > 0 { + for iNdEx := len(m.VerificationFlags) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.VerificationFlags[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) } - i-- - dAtA[i] = 0xa return len(dAtA) - i, nil } @@ -1558,8 +1562,12 @@ func (m *QueryVerificationFlagsResponse) Size() (n int) { } var l int _ = l - l = m.VerificationFlags.Size() - n += 1 + l + sovQuery(uint64(l)) + if len(m.VerificationFlags) > 0 { + for _, e := range m.VerificationFlags { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } return n } @@ -2672,7 +2680,8 @@ func (m *QueryVerificationFlagsResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.VerificationFlags.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.VerificationFlags = append(m.VerificationFlags, VerificationFlags{}) + if err := m.VerificationFlags[len(m.VerificationFlags)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/x/lightclient/types/tx.pb.go b/x/lightclient/types/tx.pb.go index 669311aeda..09d00266ab 100644 --- a/x/lightclient/types/tx.pb.go +++ b/x/lightclient/types/tx.pb.go @@ -29,23 +29,23 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -type MsgUpdateVerificationFlags struct { - Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` - VerificationFlags VerificationFlags `protobuf:"bytes,2,opt,name=verification_flags,json=verificationFlags,proto3" json:"verification_flags"` +type MsgEnableVerificationFlags struct { + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + ChainIdList []int64 `protobuf:"varint,2,rep,packed,name=chain_id_list,json=chainIdList,proto3" json:"chain_id_list,omitempty"` } -func (m *MsgUpdateVerificationFlags) Reset() { *m = MsgUpdateVerificationFlags{} } -func (m *MsgUpdateVerificationFlags) String() string { return proto.CompactTextString(m) } -func (*MsgUpdateVerificationFlags) ProtoMessage() {} -func (*MsgUpdateVerificationFlags) Descriptor() ([]byte, []int) { +func (m *MsgEnableVerificationFlags) Reset() { *m = MsgEnableVerificationFlags{} } +func (m *MsgEnableVerificationFlags) String() string { return proto.CompactTextString(m) } +func (*MsgEnableVerificationFlags) ProtoMessage() {} +func (*MsgEnableVerificationFlags) Descriptor() ([]byte, []int) { return fileDescriptor_81fed8987f08d9c5, []int{0} } -func (m *MsgUpdateVerificationFlags) XXX_Unmarshal(b []byte) error { +func (m *MsgEnableVerificationFlags) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgUpdateVerificationFlags) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgEnableVerificationFlags) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgUpdateVerificationFlags.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgEnableVerificationFlags.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -55,47 +55,135 @@ func (m *MsgUpdateVerificationFlags) XXX_Marshal(b []byte, deterministic bool) ( return b[:n], nil } } -func (m *MsgUpdateVerificationFlags) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgUpdateVerificationFlags.Merge(m, src) +func (m *MsgEnableVerificationFlags) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgEnableVerificationFlags.Merge(m, src) } -func (m *MsgUpdateVerificationFlags) XXX_Size() int { +func (m *MsgEnableVerificationFlags) XXX_Size() int { return m.Size() } -func (m *MsgUpdateVerificationFlags) XXX_DiscardUnknown() { - xxx_messageInfo_MsgUpdateVerificationFlags.DiscardUnknown(m) +func (m *MsgEnableVerificationFlags) XXX_DiscardUnknown() { + xxx_messageInfo_MsgEnableVerificationFlags.DiscardUnknown(m) } -var xxx_messageInfo_MsgUpdateVerificationFlags proto.InternalMessageInfo +var xxx_messageInfo_MsgEnableVerificationFlags proto.InternalMessageInfo -func (m *MsgUpdateVerificationFlags) GetCreator() string { +func (m *MsgEnableVerificationFlags) GetCreator() string { if m != nil { return m.Creator } return "" } -func (m *MsgUpdateVerificationFlags) GetVerificationFlags() VerificationFlags { +func (m *MsgEnableVerificationFlags) GetChainIdList() []int64 { if m != nil { - return m.VerificationFlags + return m.ChainIdList } - return VerificationFlags{} + return nil } -type MsgUpdateVerificationFlagsResponse struct { +type MsgEnableVerificationFlagsResponse struct { } -func (m *MsgUpdateVerificationFlagsResponse) Reset() { *m = MsgUpdateVerificationFlagsResponse{} } -func (m *MsgUpdateVerificationFlagsResponse) String() string { return proto.CompactTextString(m) } -func (*MsgUpdateVerificationFlagsResponse) ProtoMessage() {} -func (*MsgUpdateVerificationFlagsResponse) Descriptor() ([]byte, []int) { +func (m *MsgEnableVerificationFlagsResponse) Reset() { *m = MsgEnableVerificationFlagsResponse{} } +func (m *MsgEnableVerificationFlagsResponse) String() string { return proto.CompactTextString(m) } +func (*MsgEnableVerificationFlagsResponse) ProtoMessage() {} +func (*MsgEnableVerificationFlagsResponse) Descriptor() ([]byte, []int) { return fileDescriptor_81fed8987f08d9c5, []int{1} } -func (m *MsgUpdateVerificationFlagsResponse) XXX_Unmarshal(b []byte) error { +func (m *MsgEnableVerificationFlagsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgEnableVerificationFlagsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgEnableVerificationFlagsResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgEnableVerificationFlagsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgEnableVerificationFlagsResponse.Merge(m, src) +} +func (m *MsgEnableVerificationFlagsResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgEnableVerificationFlagsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgEnableVerificationFlagsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgEnableVerificationFlagsResponse proto.InternalMessageInfo + +type MsgDisableVerificationFlags struct { + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + ChainIdList []int64 `protobuf:"varint,2,rep,packed,name=chain_id_list,json=chainIdList,proto3" json:"chain_id_list,omitempty"` +} + +func (m *MsgDisableVerificationFlags) Reset() { *m = MsgDisableVerificationFlags{} } +func (m *MsgDisableVerificationFlags) String() string { return proto.CompactTextString(m) } +func (*MsgDisableVerificationFlags) ProtoMessage() {} +func (*MsgDisableVerificationFlags) Descriptor() ([]byte, []int) { + return fileDescriptor_81fed8987f08d9c5, []int{2} +} +func (m *MsgDisableVerificationFlags) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgDisableVerificationFlags) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgDisableVerificationFlags.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgDisableVerificationFlags) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgDisableVerificationFlags.Merge(m, src) +} +func (m *MsgDisableVerificationFlags) XXX_Size() int { + return m.Size() +} +func (m *MsgDisableVerificationFlags) XXX_DiscardUnknown() { + xxx_messageInfo_MsgDisableVerificationFlags.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgDisableVerificationFlags proto.InternalMessageInfo + +func (m *MsgDisableVerificationFlags) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +func (m *MsgDisableVerificationFlags) GetChainIdList() []int64 { + if m != nil { + return m.ChainIdList + } + return nil +} + +type MsgDisableVerificationFlagsResponse struct { +} + +func (m *MsgDisableVerificationFlagsResponse) Reset() { *m = MsgDisableVerificationFlagsResponse{} } +func (m *MsgDisableVerificationFlagsResponse) String() string { return proto.CompactTextString(m) } +func (*MsgDisableVerificationFlagsResponse) ProtoMessage() {} +func (*MsgDisableVerificationFlagsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_81fed8987f08d9c5, []int{3} +} +func (m *MsgDisableVerificationFlagsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgUpdateVerificationFlagsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgDisableVerificationFlagsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgUpdateVerificationFlagsResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgDisableVerificationFlagsResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -105,45 +193,50 @@ func (m *MsgUpdateVerificationFlagsResponse) XXX_Marshal(b []byte, deterministic return b[:n], nil } } -func (m *MsgUpdateVerificationFlagsResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgUpdateVerificationFlagsResponse.Merge(m, src) +func (m *MsgDisableVerificationFlagsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgDisableVerificationFlagsResponse.Merge(m, src) } -func (m *MsgUpdateVerificationFlagsResponse) XXX_Size() int { +func (m *MsgDisableVerificationFlagsResponse) XXX_Size() int { return m.Size() } -func (m *MsgUpdateVerificationFlagsResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgUpdateVerificationFlagsResponse.DiscardUnknown(m) +func (m *MsgDisableVerificationFlagsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgDisableVerificationFlagsResponse.DiscardUnknown(m) } -var xxx_messageInfo_MsgUpdateVerificationFlagsResponse proto.InternalMessageInfo +var xxx_messageInfo_MsgDisableVerificationFlagsResponse proto.InternalMessageInfo func init() { - proto.RegisterType((*MsgUpdateVerificationFlags)(nil), "zetachain.zetacore.lightclient.MsgUpdateVerificationFlags") - proto.RegisterType((*MsgUpdateVerificationFlagsResponse)(nil), "zetachain.zetacore.lightclient.MsgUpdateVerificationFlagsResponse") + proto.RegisterType((*MsgEnableVerificationFlags)(nil), "zetachain.zetacore.lightclient.MsgEnableVerificationFlags") + proto.RegisterType((*MsgEnableVerificationFlagsResponse)(nil), "zetachain.zetacore.lightclient.MsgEnableVerificationFlagsResponse") + proto.RegisterType((*MsgDisableVerificationFlags)(nil), "zetachain.zetacore.lightclient.MsgDisableVerificationFlags") + proto.RegisterType((*MsgDisableVerificationFlagsResponse)(nil), "zetachain.zetacore.lightclient.MsgDisableVerificationFlagsResponse") } func init() { proto.RegisterFile("lightclient/tx.proto", fileDescriptor_81fed8987f08d9c5) } var fileDescriptor_81fed8987f08d9c5 = []byte{ - // 282 bytes of a gzipped FileDescriptorProto + // 321 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0xc9, 0xc9, 0x4c, 0xcf, 0x28, 0x49, 0xce, 0xc9, 0x4c, 0xcd, 0x2b, 0xd1, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0xab, 0x4a, 0x2d, 0x49, 0x4c, 0xce, 0x48, 0xcc, 0xcc, 0xd3, 0x03, 0xb3, 0xf2, 0x8b, 0x52, 0xf5, 0x90, 0x14, 0x4a, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0x95, 0xea, 0x83, 0x58, 0x10, 0x5d, 0x52, 0x2a, 0xc8, 0x66, 0x95, 0xa5, 0x16, 0x65, 0xa6, 0x65, 0x26, 0x27, 0x96, 0x64, 0xe6, - 0xe7, 0xc5, 0xa7, 0xe5, 0x24, 0xa6, 0x17, 0x43, 0x54, 0x29, 0xcd, 0x63, 0xe4, 0x92, 0xf2, 0x2d, - 0x4e, 0x0f, 0x2d, 0x48, 0x49, 0x2c, 0x49, 0x0d, 0x43, 0x52, 0xe5, 0x06, 0x52, 0x24, 0x24, 0xc1, - 0xc5, 0x9e, 0x5c, 0x94, 0x9a, 0x58, 0x92, 0x5f, 0x24, 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, 0x19, 0x04, - 0xe3, 0x0a, 0xa5, 0x71, 0x09, 0x61, 0x1a, 0x2a, 0xc1, 0xa4, 0xc0, 0xa8, 0xc1, 0x6d, 0x64, 0xa8, - 0x87, 0xdf, 0xc5, 0x7a, 0x18, 0x16, 0x39, 0xb1, 0x9c, 0xb8, 0x27, 0xcf, 0x10, 0x24, 0x58, 0x86, - 0x2e, 0xa1, 0xa4, 0xc2, 0xa5, 0x84, 0xdb, 0x7d, 0x41, 0xa9, 0xc5, 0x05, 0xf9, 0x79, 0xc5, 0xa9, - 0x46, 0x0b, 0x19, 0xb9, 0x98, 0x7d, 0x8b, 0xd3, 0x85, 0x66, 0x32, 0x72, 0x89, 0xe3, 0xf2, 0x8b, - 0x15, 0x21, 0x57, 0xe1, 0xb6, 0x47, 0xca, 0x89, 0x7c, 0xbd, 0x30, 0x37, 0x3a, 0xf9, 0x9c, 0x78, - 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, - 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x51, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, - 0x5e, 0x72, 0x7e, 0xae, 0x3e, 0xc8, 0x74, 0x5d, 0xb0, 0x45, 0xfa, 0x30, 0x8b, 0xf4, 0x2b, 0xf4, - 0x51, 0xd2, 0x45, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0x38, 0xfe, 0x8c, 0x01, 0x01, 0x00, 0x00, - 0xff, 0xff, 0x5d, 0x1d, 0xfc, 0x77, 0x33, 0x02, 0x00, 0x00, + 0xe7, 0xc5, 0xa7, 0xe5, 0x24, 0xa6, 0x17, 0x43, 0x54, 0x29, 0x45, 0x71, 0x49, 0xf9, 0x16, 0xa7, + 0xbb, 0xe6, 0x25, 0x26, 0xe5, 0xa4, 0x86, 0x21, 0x29, 0x72, 0x03, 0xa9, 0x11, 0x92, 0xe0, 0x62, + 0x4f, 0x2e, 0x4a, 0x4d, 0x2c, 0xc9, 0x2f, 0x92, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x0c, 0x82, 0x71, + 0x85, 0x94, 0xb8, 0x78, 0xc1, 0x2e, 0x8a, 0xcf, 0x4c, 0x89, 0xcf, 0xc9, 0x2c, 0x2e, 0x91, 0x60, + 0x52, 0x60, 0xd6, 0x60, 0x0e, 0xe2, 0x06, 0x0b, 0x7a, 0xa6, 0xf8, 0x64, 0x16, 0x97, 0x28, 0xa9, + 0x70, 0x29, 0xe1, 0x36, 0x3b, 0x28, 0xb5, 0xb8, 0x20, 0x3f, 0xaf, 0x38, 0x55, 0x29, 0x9a, 0x4b, + 0xda, 0xb7, 0x38, 0xdd, 0x25, 0xb3, 0x98, 0x16, 0x4e, 0x50, 0xe5, 0x52, 0xc6, 0x63, 0x38, 0xcc, + 0x0d, 0x46, 0x07, 0x98, 0xb8, 0x98, 0x7d, 0x8b, 0xd3, 0x85, 0x66, 0x32, 0x72, 0x89, 0xe3, 0x0a, + 0x0b, 0x2b, 0x3d, 0xfc, 0xd1, 0xa0, 0x87, 0xdb, 0xaf, 0x52, 0x4e, 0xe4, 0xeb, 0x85, 0xb9, 0x51, + 0x68, 0x0e, 0x23, 0x97, 0x04, 0xce, 0x50, 0xb2, 0x26, 0xc2, 0x02, 0x5c, 0x9a, 0xa5, 0x9c, 0x29, + 0xd0, 0x0c, 0x73, 0x9e, 0x93, 0xcf, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, + 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, + 0x19, 0xa5, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x83, 0x8c, 0xd7, 0x05, + 0xdb, 0xa4, 0x0f, 0xb3, 0x49, 0xbf, 0x42, 0x1f, 0x25, 0xd5, 0x57, 0x16, 0xa4, 0x16, 0x27, 0xb1, + 0x81, 0x53, 0xa7, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x0d, 0xfc, 0x84, 0x07, 0x11, 0x03, 0x00, + 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -158,7 +251,8 @@ const _ = grpc.SupportPackageIsVersion4 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type MsgClient interface { - UpdateVerificationFlags(ctx context.Context, in *MsgUpdateVerificationFlags, opts ...grpc.CallOption) (*MsgUpdateVerificationFlagsResponse, error) + EnableVerificationFlags(ctx context.Context, in *MsgEnableVerificationFlags, opts ...grpc.CallOption) (*MsgEnableVerificationFlagsResponse, error) + DisableVerificationFlags(ctx context.Context, in *MsgDisableVerificationFlags, opts ...grpc.CallOption) (*MsgDisableVerificationFlagsResponse, error) } type msgClient struct { @@ -169,9 +263,18 @@ func NewMsgClient(cc grpc1.ClientConn) MsgClient { return &msgClient{cc} } -func (c *msgClient) UpdateVerificationFlags(ctx context.Context, in *MsgUpdateVerificationFlags, opts ...grpc.CallOption) (*MsgUpdateVerificationFlagsResponse, error) { - out := new(MsgUpdateVerificationFlagsResponse) - err := c.cc.Invoke(ctx, "/zetachain.zetacore.lightclient.Msg/UpdateVerificationFlags", in, out, opts...) +func (c *msgClient) EnableVerificationFlags(ctx context.Context, in *MsgEnableVerificationFlags, opts ...grpc.CallOption) (*MsgEnableVerificationFlagsResponse, error) { + out := new(MsgEnableVerificationFlagsResponse) + err := c.cc.Invoke(ctx, "/zetachain.zetacore.lightclient.Msg/EnableVerificationFlags", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) DisableVerificationFlags(ctx context.Context, in *MsgDisableVerificationFlags, opts ...grpc.CallOption) (*MsgDisableVerificationFlagsResponse, error) { + out := new(MsgDisableVerificationFlagsResponse) + err := c.cc.Invoke(ctx, "/zetachain.zetacore.lightclient.Msg/DisableVerificationFlags", in, out, opts...) if err != nil { return nil, err } @@ -180,35 +283,57 @@ func (c *msgClient) UpdateVerificationFlags(ctx context.Context, in *MsgUpdateVe // MsgServer is the server API for Msg service. type MsgServer interface { - UpdateVerificationFlags(context.Context, *MsgUpdateVerificationFlags) (*MsgUpdateVerificationFlagsResponse, error) + EnableVerificationFlags(context.Context, *MsgEnableVerificationFlags) (*MsgEnableVerificationFlagsResponse, error) + DisableVerificationFlags(context.Context, *MsgDisableVerificationFlags) (*MsgDisableVerificationFlagsResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. type UnimplementedMsgServer struct { } -func (*UnimplementedMsgServer) UpdateVerificationFlags(ctx context.Context, req *MsgUpdateVerificationFlags) (*MsgUpdateVerificationFlagsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method UpdateVerificationFlags not implemented") +func (*UnimplementedMsgServer) EnableVerificationFlags(ctx context.Context, req *MsgEnableVerificationFlags) (*MsgEnableVerificationFlagsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method EnableVerificationFlags not implemented") +} +func (*UnimplementedMsgServer) DisableVerificationFlags(ctx context.Context, req *MsgDisableVerificationFlags) (*MsgDisableVerificationFlagsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DisableVerificationFlags not implemented") } func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) } -func _Msg_UpdateVerificationFlags_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgUpdateVerificationFlags) +func _Msg_EnableVerificationFlags_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgEnableVerificationFlags) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).EnableVerificationFlags(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/zetachain.zetacore.lightclient.Msg/EnableVerificationFlags", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).EnableVerificationFlags(ctx, req.(*MsgEnableVerificationFlags)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_DisableVerificationFlags_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgDisableVerificationFlags) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(MsgServer).UpdateVerificationFlags(ctx, in) + return srv.(MsgServer).DisableVerificationFlags(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/zetachain.zetacore.lightclient.Msg/UpdateVerificationFlags", + FullMethod: "/zetachain.zetacore.lightclient.Msg/DisableVerificationFlags", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).UpdateVerificationFlags(ctx, req.(*MsgUpdateVerificationFlags)) + return srv.(MsgServer).DisableVerificationFlags(ctx, req.(*MsgDisableVerificationFlags)) } return interceptor(ctx, in, info, handler) } @@ -218,15 +343,19 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ HandlerType: (*MsgServer)(nil), Methods: []grpc.MethodDesc{ { - MethodName: "UpdateVerificationFlags", - Handler: _Msg_UpdateVerificationFlags_Handler, + MethodName: "EnableVerificationFlags", + Handler: _Msg_EnableVerificationFlags_Handler, + }, + { + MethodName: "DisableVerificationFlags", + Handler: _Msg_DisableVerificationFlags_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "lightclient/tx.proto", } -func (m *MsgUpdateVerificationFlags) Marshal() (dAtA []byte, err error) { +func (m *MsgEnableVerificationFlags) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -236,26 +365,107 @@ func (m *MsgUpdateVerificationFlags) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgUpdateVerificationFlags) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgEnableVerificationFlags) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgUpdateVerificationFlags) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgEnableVerificationFlags) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - { - size, err := m.VerificationFlags.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err + if len(m.ChainIdList) > 0 { + dAtA2 := make([]byte, len(m.ChainIdList)*10) + var j1 int + for _, num1 := range m.ChainIdList { + num := uint64(num1) + for num >= 1<<7 { + dAtA2[j1] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j1++ + } + dAtA2[j1] = uint8(num) + j1++ + } + i -= j1 + copy(dAtA[i:], dAtA2[:j1]) + i = encodeVarintTx(dAtA, i, uint64(j1)) + i-- + dAtA[i] = 0x12 + } + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintTx(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgEnableVerificationFlagsResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgEnableVerificationFlagsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgEnableVerificationFlagsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgDisableVerificationFlags) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgDisableVerificationFlags) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgDisableVerificationFlags) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ChainIdList) > 0 { + dAtA4 := make([]byte, len(m.ChainIdList)*10) + var j3 int + for _, num1 := range m.ChainIdList { + num := uint64(num1) + for num >= 1<<7 { + dAtA4[j3] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j3++ + } + dAtA4[j3] = uint8(num) + j3++ } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) + i -= j3 + copy(dAtA[i:], dAtA4[:j3]) + i = encodeVarintTx(dAtA, i, uint64(j3)) + i-- + dAtA[i] = 0x12 } - i-- - dAtA[i] = 0x12 if len(m.Creator) > 0 { i -= len(m.Creator) copy(dAtA[i:], m.Creator) @@ -266,7 +476,7 @@ func (m *MsgUpdateVerificationFlags) MarshalToSizedBuffer(dAtA []byte) (int, err return len(dAtA) - i, nil } -func (m *MsgUpdateVerificationFlagsResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgDisableVerificationFlagsResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -276,12 +486,12 @@ func (m *MsgUpdateVerificationFlagsResponse) Marshal() (dAtA []byte, err error) return dAtA[:n], nil } -func (m *MsgUpdateVerificationFlagsResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgDisableVerificationFlagsResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgUpdateVerificationFlagsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgDisableVerificationFlagsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -300,7 +510,7 @@ func encodeVarintTx(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *MsgUpdateVerificationFlags) Size() (n int) { +func (m *MsgEnableVerificationFlags) Size() (n int) { if m == nil { return 0 } @@ -310,12 +520,46 @@ func (m *MsgUpdateVerificationFlags) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = m.VerificationFlags.Size() - n += 1 + l + sovTx(uint64(l)) + if len(m.ChainIdList) > 0 { + l = 0 + for _, e := range m.ChainIdList { + l += sovTx(uint64(e)) + } + n += 1 + sovTx(uint64(l)) + l + } return n } -func (m *MsgUpdateVerificationFlagsResponse) Size() (n int) { +func (m *MsgEnableVerificationFlagsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgDisableVerificationFlags) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if len(m.ChainIdList) > 0 { + l = 0 + for _, e := range m.ChainIdList { + l += sovTx(uint64(e)) + } + n += 1 + sovTx(uint64(l)) + l + } + return n +} + +func (m *MsgDisableVerificationFlagsResponse) Size() (n int) { if m == nil { return 0 } @@ -330,7 +574,7 @@ func sovTx(x uint64) (n int) { func sozTx(x uint64) (n int) { return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *MsgUpdateVerificationFlags) Unmarshal(dAtA []byte) error { +func (m *MsgEnableVerificationFlags) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -353,10 +597,10 @@ func (m *MsgUpdateVerificationFlags) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgUpdateVerificationFlags: wiretype end group for non-group") + return fmt.Errorf("proto: MsgEnableVerificationFlags: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateVerificationFlags: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgEnableVerificationFlags: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -392,10 +636,186 @@ func (m *MsgUpdateVerificationFlags) Unmarshal(dAtA []byte) error { m.Creator = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: + if wireType == 0 { + var v int64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.ChainIdList = append(m.ChainIdList, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.ChainIdList) == 0 { + m.ChainIdList = make([]int64, 0, elementCount) + } + for iNdEx < postIndex { + var v int64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.ChainIdList = append(m.ChainIdList, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field ChainIdList", wireType) + } + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgEnableVerificationFlagsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgEnableVerificationFlagsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgEnableVerificationFlagsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgDisableVerificationFlags) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgDisableVerificationFlags: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgDisableVerificationFlags: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field VerificationFlags", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -405,25 +825,100 @@ func (m *MsgUpdateVerificationFlags) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.VerificationFlags.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.Creator = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 2: + if wireType == 0 { + var v int64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.ChainIdList = append(m.ChainIdList, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.ChainIdList) == 0 { + m.ChainIdList = make([]int64, 0, elementCount) + } + for iNdEx < postIndex { + var v int64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.ChainIdList = append(m.ChainIdList, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field ChainIdList", wireType) + } default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) @@ -445,7 +940,7 @@ func (m *MsgUpdateVerificationFlags) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgUpdateVerificationFlagsResponse) Unmarshal(dAtA []byte) error { +func (m *MsgDisableVerificationFlagsResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -468,10 +963,10 @@ func (m *MsgUpdateVerificationFlagsResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgUpdateVerificationFlagsResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgDisableVerificationFlagsResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateVerificationFlagsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgDisableVerificationFlagsResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: diff --git a/x/lightclient/types/verification_flags.go b/x/lightclient/types/verification_flags.go index c410158336..de3aa1aa93 100644 --- a/x/lightclient/types/verification_flags.go +++ b/x/lightclient/types/verification_flags.go @@ -1,10 +1,34 @@ package types +import "github.com/zeta-chain/zetacore/pkg/chains" + // DefaultVerificationFlags returns the default verification flags. // By default, everything disabled. -func DefaultVerificationFlags() VerificationFlags { - return VerificationFlags{ - EthTypeChainEnabled: false, - BtcTypeChainEnabled: false, +func DefaultVerificationFlags() []VerificationFlags { + return []VerificationFlags{ + { + ChainId: chains.EthChain.ChainId, + Enabled: false, + }, + { + ChainId: chains.BscMainnetChain.ChainId, + Enabled: false, + }, + { + ChainId: chains.SepoliaChain.ChainId, + Enabled: false, + }, + { + ChainId: chains.BscTestnetChain.ChainId, + Enabled: false, + }, + { + ChainId: chains.GoerliLocalnetChain.ChainId, + Enabled: false, + }, + { + ChainId: chains.GoerliChain.ChainId, + Enabled: false, + }, } } diff --git a/x/lightclient/types/verification_flags.pb.go b/x/lightclient/types/verification_flags.pb.go index 94c90b358a..c7dd07de14 100644 --- a/x/lightclient/types/verification_flags.pb.go +++ b/x/lightclient/types/verification_flags.pb.go @@ -9,6 +9,7 @@ import ( math "math" math_bits "math/bits" + _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/gogo/protobuf/proto" ) @@ -25,8 +26,8 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // VerificationFlags is a structure containing information which chain types are enabled for block header verification type VerificationFlags struct { - EthTypeChainEnabled bool `protobuf:"varint,1,opt,name=ethTypeChainEnabled,proto3" json:"ethTypeChainEnabled,omitempty"` - BtcTypeChainEnabled bool `protobuf:"varint,2,opt,name=btcTypeChainEnabled,proto3" json:"btcTypeChainEnabled,omitempty"` + ChainId int64 `protobuf:"varint,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` + Enabled bool `protobuf:"varint,2,opt,name=enabled,proto3" json:"enabled,omitempty"` } func (m *VerificationFlags) Reset() { *m = VerificationFlags{} } @@ -62,16 +63,16 @@ func (m *VerificationFlags) XXX_DiscardUnknown() { var xxx_messageInfo_VerificationFlags proto.InternalMessageInfo -func (m *VerificationFlags) GetEthTypeChainEnabled() bool { +func (m *VerificationFlags) GetChainId() int64 { if m != nil { - return m.EthTypeChainEnabled + return m.ChainId } - return false + return 0 } -func (m *VerificationFlags) GetBtcTypeChainEnabled() bool { +func (m *VerificationFlags) GetEnabled() bool { if m != nil { - return m.BtcTypeChainEnabled + return m.Enabled } return false } @@ -85,20 +86,21 @@ func init() { } var fileDescriptor_86eae6d737b3f8cc = []byte{ - // 199 bytes of a gzipped FileDescriptorProto + // 210 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xc9, 0xc9, 0x4c, 0xcf, 0x28, 0x49, 0xce, 0xc9, 0x4c, 0xcd, 0x2b, 0xd1, 0x2f, 0x4b, 0x2d, 0xca, 0x4c, 0xcb, 0x4c, 0x4e, 0x2c, 0xc9, 0xcc, 0xcf, 0x8b, 0x4f, 0xcb, 0x49, 0x4c, 0x2f, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0xab, 0x4a, 0x2d, 0x49, 0x4c, 0xce, 0x48, 0xcc, 0xcc, 0xd3, 0x03, 0xb3, 0xf2, 0x8b, - 0x52, 0xf5, 0x90, 0x34, 0x2a, 0x95, 0x73, 0x09, 0x86, 0x21, 0xe9, 0x75, 0x03, 0x69, 0x15, 0x32, - 0xe0, 0x12, 0x4e, 0x2d, 0xc9, 0x08, 0xa9, 0x2c, 0x48, 0x75, 0x06, 0xe9, 0x74, 0xcd, 0x4b, 0x4c, - 0xca, 0x49, 0x4d, 0x91, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x08, 0xc2, 0x26, 0x05, 0xd2, 0x91, 0x54, - 0x92, 0x8c, 0xa1, 0x83, 0x09, 0xa2, 0x03, 0x8b, 0x94, 0x93, 0xcf, 0x89, 0x47, 0x72, 0x8c, 0x17, - 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, - 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x19, 0xa5, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, - 0xea, 0x83, 0xdc, 0xac, 0x0b, 0x76, 0xbe, 0x3e, 0xcc, 0xf9, 0xfa, 0x15, 0xfa, 0xc8, 0x3e, 0x2f, - 0xa9, 0x2c, 0x48, 0x2d, 0x4e, 0x62, 0x03, 0xfb, 0xd6, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0x84, - 0x57, 0x0d, 0x3e, 0x15, 0x01, 0x00, 0x00, + 0x52, 0xf5, 0x90, 0x34, 0x4a, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0x95, 0xea, 0x83, 0x58, 0x10, + 0x5d, 0x4a, 0x1e, 0x5c, 0x82, 0x61, 0x48, 0x26, 0xba, 0x81, 0x0c, 0x14, 0x92, 0xe4, 0xe2, 0x00, + 0x1b, 0x14, 0x9f, 0x99, 0x22, 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, 0x1c, 0xc4, 0x0e, 0xe6, 0x7b, 0xa6, + 0x08, 0x49, 0x70, 0xb1, 0xa7, 0xe6, 0x25, 0x26, 0xe5, 0xa4, 0xa6, 0x48, 0x30, 0x29, 0x30, 0x6a, + 0x70, 0x04, 0xc1, 0xb8, 0x4e, 0x3e, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, + 0x91, 0x1c, 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, 0x10, + 0x65, 0x94, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0x0f, 0x72, 0x9a, 0x2e, + 0xd8, 0x30, 0x7d, 0x98, 0x2b, 0xf5, 0x2b, 0xf4, 0x91, 0x3d, 0x58, 0x52, 0x59, 0x90, 0x5a, 0x9c, + 0xc4, 0x06, 0x76, 0x9e, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0xd3, 0x77, 0xd4, 0x9b, 0xfc, 0x00, + 0x00, 0x00, } func (m *VerificationFlags) Marshal() (dAtA []byte, err error) { @@ -121,9 +123,9 @@ func (m *VerificationFlags) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.BtcTypeChainEnabled { + if m.Enabled { i-- - if m.BtcTypeChainEnabled { + if m.Enabled { dAtA[i] = 1 } else { dAtA[i] = 0 @@ -131,13 +133,8 @@ func (m *VerificationFlags) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x10 } - if m.EthTypeChainEnabled { - i-- - if m.EthTypeChainEnabled { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } + if m.ChainId != 0 { + i = encodeVarintVerificationFlags(dAtA, i, uint64(m.ChainId)) i-- dAtA[i] = 0x8 } @@ -161,10 +158,10 @@ func (m *VerificationFlags) Size() (n int) { } var l int _ = l - if m.EthTypeChainEnabled { - n += 2 + if m.ChainId != 0 { + n += 1 + sovVerificationFlags(uint64(m.ChainId)) } - if m.BtcTypeChainEnabled { + if m.Enabled { n += 2 } return n @@ -207,9 +204,9 @@ func (m *VerificationFlags) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field EthTypeChainEnabled", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ChainId", wireType) } - var v int + m.ChainId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowVerificationFlags @@ -219,15 +216,14 @@ func (m *VerificationFlags) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - v |= int(b&0x7F) << shift + m.ChainId |= int64(b&0x7F) << shift if b < 0x80 { break } } - m.EthTypeChainEnabled = bool(v != 0) case 2: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field BtcTypeChainEnabled", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Enabled", wireType) } var v int for shift := uint(0); ; shift += 7 { @@ -244,7 +240,7 @@ func (m *VerificationFlags) Unmarshal(dAtA []byte) error { break } } - m.BtcTypeChainEnabled = bool(v != 0) + m.Enabled = bool(v != 0) default: iNdEx = preIndex skippy, err := skipVerificationFlags(dAtA[iNdEx:]) diff --git a/x/lightclient/types/verification_flags_test.go b/x/lightclient/types/verification_flags_test.go index 6cb3806480..7b3ddee193 100644 --- a/x/lightclient/types/verification_flags_test.go +++ b/x/lightclient/types/verification_flags_test.go @@ -4,12 +4,29 @@ import ( "testing" "github.com/stretchr/testify/require" + "github.com/zeta-chain/zetacore/pkg/chains" ) func TestDefaultVerificationFlags(t *testing.T) { t.Run("default verification flags is all disabled", func(t *testing.T) { flags := DefaultVerificationFlags() - require.False(t, flags.EthTypeChainEnabled) - require.False(t, flags.BtcTypeChainEnabled) + for _, f := range flags { + switch f.ChainId { + case chains.EthChain.ChainId: + require.False(t, f.Enabled) + case chains.BscMainnetChain.ChainId: + require.False(t, f.Enabled) + case chains.SepoliaChain.ChainId: + require.False(t, f.Enabled) + case chains.BscTestnetChain.ChainId: + require.False(t, f.Enabled) + case chains.GoerliLocalnetChain.ChainId: + require.False(t, f.Enabled) + case chains.GoerliChain.ChainId: + require.False(t, f.Enabled) + default: + require.False(t, f.Enabled, "unexpected chain id") + } + } }) } diff --git a/zetaclient/bitcoin/bitcoin_client.go b/zetaclient/bitcoin/bitcoin_client.go index ba1c30b585..0b34b754d4 100644 --- a/zetaclient/bitcoin/bitcoin_client.go +++ b/zetaclient/bitcoin/bitcoin_client.go @@ -436,8 +436,8 @@ func (ob *BTCChainClient) ObserveInTx() error { // add block header to zetabridge // TODO: consider having a separate ticker(from TSS scaning) for posting block headers // https://github.com/zeta-chain/node/issues/1847 - verificationFlags := ob.coreContext.GetVerificationFlags() - if verificationFlags.BtcTypeChainEnabled { + verificationFlags, found := ob.coreContext.GetVerificationFlags(ob.chain.ChainId) + if found && verificationFlags.Enabled { err = ob.postBlockHeader(bn) if err != nil { ob.logger.InTx.Warn().Err(err).Msgf("observeInTxBTC: error posting block header %d", bn) diff --git a/zetaclient/core_context/zeta_core_context.go b/zetaclient/core_context/zeta_core_context.go index 5bb8d23089..3d66cbc0fb 100644 --- a/zetaclient/core_context/zeta_core_context.go +++ b/zetaclient/core_context/zeta_core_context.go @@ -25,7 +25,7 @@ type ZetaCoreContext struct { crossChainFlags observertypes.CrosschainFlags // verificationFlags is used to store the verification flags for the lightclient module to enable header/proof verification - verificationFlags lightclienttypes.VerificationFlags + verificationFlags []lightclienttypes.VerificationFlags } // NewZetaCoreContext creates and returns new ZetaCoreContext @@ -46,7 +46,7 @@ func NewZetaCoreContext(cfg config.Config) *ZetaCoreContext { evmChainParams: evmChainParams, bitcoinChainParams: bitcoinChainParams, crossChainFlags: observertypes.CrosschainFlags{}, - verificationFlags: lightclienttypes.VerificationFlags{}, + verificationFlags: []lightclienttypes.VerificationFlags{}, } } @@ -120,12 +120,25 @@ func (c *ZetaCoreContext) GetCrossChainFlags() observertypes.CrosschainFlags { return c.crossChainFlags } -func (c *ZetaCoreContext) GetVerificationFlags() lightclienttypes.VerificationFlags { +// GetAllVerificationFlags returns all verification flags +func (c *ZetaCoreContext) GetAllVerificationFlags() []lightclienttypes.VerificationFlags { c.coreContextLock.RLock() defer c.coreContextLock.RUnlock() return c.verificationFlags } +// GetVerificationFlags returns verification flags for a chain +func (c *ZetaCoreContext) GetVerificationFlags(chainID int64) (lightclienttypes.VerificationFlags, bool) { + c.coreContextLock.RLock() + defer c.coreContextLock.RUnlock() + for _, flags := range c.verificationFlags { + if flags.ChainId == chainID { + return flags, true + } + } + return lightclienttypes.VerificationFlags{}, false +} + // Update updates core context and params for all chains // this must be the ONLY function that writes to core context func (c *ZetaCoreContext) Update( @@ -135,7 +148,7 @@ func (c *ZetaCoreContext) Update( btcChainParams *observertypes.ChainParams, tssPubKey string, crosschainFlags observertypes.CrosschainFlags, - verificationFlags lightclienttypes.VerificationFlags, + verificationFlags []lightclienttypes.VerificationFlags, init bool, logger zerolog.Logger, ) { diff --git a/zetaclient/core_context/zeta_core_context_test.go b/zetaclient/core_context/zeta_core_context_test.go index e9fb129023..bbfd23f311 100644 --- a/zetaclient/core_context/zeta_core_context_test.go +++ b/zetaclient/core_context/zeta_core_context_test.go @@ -28,7 +28,7 @@ func getTestCoreContext( evmChain chains.Chain, evmChainParams *observertypes.ChainParams, ccFlags observertypes.CrosschainFlags, - verificationFlags lightclienttypes.VerificationFlags, + verificationFlags []lightclienttypes.VerificationFlags, ) *corecontext.ZetaCoreContext { // create config cfg := config.NewConfig() @@ -208,7 +208,7 @@ func TestUpdateZetaCoreContext(t *testing.T) { ccFlags := zetaContext.GetCrossChainFlags() require.Equal(t, *crosschainFlags, ccFlags) - verFlags := zetaContext.GetVerificationFlags() + verFlags := zetaContext.GetAllVerificationFlags() require.Equal(t, verificationFlags, verFlags) }) @@ -313,7 +313,7 @@ func TestUpdateZetaCoreContext(t *testing.T) { ccFlags := zetaContext.GetCrossChainFlags() require.Equal(t, ccFlags, *crosschainFlags) - verFlags := zetaContext.GetVerificationFlags() + verFlags := zetaContext.GetAllVerificationFlags() require.Equal(t, verFlags, verificationFlags) }) } diff --git a/zetaclient/evm/evm_client.go b/zetaclient/evm/evm_client.go index 63e8da7d7c..1ee4a2edf5 100644 --- a/zetaclient/evm/evm_client.go +++ b/zetaclient/evm/evm_client.go @@ -839,8 +839,8 @@ func (ob *ChainClient) ObserverTSSReceive(startBlock, toBlock uint64) uint64 { // post new block header (if any) to zetabridge and ignore error // TODO: consider having a independent ticker(from TSS scaning) for posting block headers // https://github.com/zeta-chain/node/issues/1847 - verificationFlags := ob.coreContext.GetVerificationFlags() - if verificationFlags.EthTypeChainEnabled && chains.IsHeaderSupportedEvmChain(ob.chain.ChainId) { + verificationFlags, found := ob.coreContext.GetVerificationFlags(ob.chain.ChainId) + if found && verificationFlags.Enabled && chains.IsHeaderSupportedEvmChain(ob.chain.ChainId) { // post block header for supported chains err := ob.postBlockHeader(toBlock) if err != nil { diff --git a/zetaclient/zetabridge/query.go b/zetaclient/zetabridge/query.go index 09d3b20e82..31cb82aeaa 100644 --- a/zetaclient/zetabridge/query.go +++ b/zetaclient/zetabridge/query.go @@ -33,11 +33,11 @@ func (b *ZetaCoreBridge) GetCrosschainFlags() (observertypes.CrosschainFlags, er return resp.CrosschainFlags, nil } -func (b *ZetaCoreBridge) GetVerificationFlags() (lightclienttypes.VerificationFlags, error) { +func (b *ZetaCoreBridge) GetVerificationFlags() ([]lightclienttypes.VerificationFlags, error) { client := lightclienttypes.NewQueryClient(b.grpcConn) resp, err := client.VerificationFlags(context.Background(), &lightclienttypes.QueryVerificationFlagsRequest{}) if err != nil { - return lightclienttypes.VerificationFlags{}, err + return []lightclienttypes.VerificationFlags{}, err } return resp.VerificationFlags, nil } diff --git a/zetaclient/zetabridge/query_test.go b/zetaclient/zetabridge/query_test.go index 44fe8a1b74..4dd814c15d 100644 --- a/zetaclient/zetabridge/query_test.go +++ b/zetaclient/zetabridge/query_test.go @@ -103,9 +103,15 @@ func TestZetaCoreBridge_GetCrosschainFlags(t *testing.T) { } func TestZetaCoreBridge_GetVerificationFlags(t *testing.T) { - expectedOutput := lightclienttypes.QueryVerificationFlagsResponse{VerificationFlags: lightclienttypes.VerificationFlags{ - EthTypeChainEnabled: true, - BtcTypeChainEnabled: false, + expectedOutput := lightclienttypes.QueryVerificationFlagsResponse{VerificationFlags: []lightclienttypes.VerificationFlags{ + { + ChainId: chains.EthChain.ChainId, + Enabled: true, + }, + { + ChainId: chains.BtcMainnetChain.ChainId, + Enabled: true, + }, }} input := lightclienttypes.QueryVerificationFlagsRequest{} method := "/zetachain.zetacore.lightclient.Query/VerificationFlags" @@ -791,7 +797,6 @@ func TestZetaCoreBridge_GetSupportedChains(t *testing.T) { chains.BscMainnetChain.Vm, chains.BscMainnetChain.Consensus, chains.BscMainnetChain.IsExternal, - chains.BscMainnetChain.IsHeaderSupported, }, { chains.EthChain.ChainName, @@ -801,7 +806,6 @@ func TestZetaCoreBridge_GetSupportedChains(t *testing.T) { chains.EthChain.Vm, chains.EthChain.Consensus, chains.EthChain.IsExternal, - chains.EthChain.IsHeaderSupported, }, }, } diff --git a/zetaclient/zetabridge/tx_test.go b/zetaclient/zetabridge/tx_test.go index 498774a28c..2fa2473abd 100644 --- a/zetaclient/zetabridge/tx_test.go +++ b/zetaclient/zetabridge/tx_test.go @@ -254,7 +254,6 @@ func TestZetaCoreBridge_UpdateZetaCoreContext(t *testing.T) { chains.BscMainnetChain.Vm, chains.BscMainnetChain.Consensus, chains.BscMainnetChain.IsExternal, - chains.BscMainnetChain.IsHeaderSupported, }, { chains.EthChain.ChainName, @@ -264,7 +263,6 @@ func TestZetaCoreBridge_UpdateZetaCoreContext(t *testing.T) { chains.EthChain.Vm, chains.EthChain.Consensus, chains.EthChain.IsExternal, - chains.EthChain.IsHeaderSupported, }, }, }) @@ -309,9 +307,15 @@ func TestZetaCoreBridge_UpdateZetaCoreContext(t *testing.T) { s.ExpectUnary(method). UnlimitedTimes(). WithPayload(lightclienttypes.QueryVerificationFlagsRequest{}). - Return(lightclienttypes.QueryVerificationFlagsResponse{VerificationFlags: lightclienttypes.VerificationFlags{ - EthTypeChainEnabled: true, - BtcTypeChainEnabled: false, + Return(lightclienttypes.QueryVerificationFlagsResponse{VerificationFlags: []lightclienttypes.VerificationFlags{ + { + ChainId: chains.EthChain.ChainId, + Enabled: true, + }, + { + ChainId: chains.BtcMainnetChain.ChainId, + Enabled: false, + }, }}) }, )(t) From b70101700a8fbf13048ce6da5ceba2ad0c77a663 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Mon, 29 Apr 2024 17:33:50 -0400 Subject: [PATCH 15/31] generate files --- .../cli/zetacored/zetacored_tx_lightclient.md | 3 +- ...x_lightclient_update-verification-flags.md | 52 ------------ docs/openapi/openapi.swagger.yaml | 18 ++-- docs/spec/lightclient/messages.md | 23 +++-- pkg/chains/chain.go | 4 +- pkg/chains/chain_test.go | 2 +- typescript/lightclient/genesis_pb.d.ts | 4 +- typescript/lightclient/query_pb.d.ts | 4 +- typescript/lightclient/tx_pb.d.ts | 85 ++++++++++++++----- .../lightclient/verification_flags_pb.d.ts | 8 +- typescript/pkg/chains/chains_pb.d.ts | 5 -- x/lightclient/client/cli/tx.go | 3 +- .../cli/tx_disable_verification_flags.go | 4 +- .../cli/tx_enable_verification_flags.go | 6 +- .../msg_server_disable_verification_flags.go | 2 + .../msg_server_enable_verification_flags.go | 5 +- x/observer/types/message_vote_block_header.go | 2 +- .../types/message_vote_block_header_test.go | 12 +++ zetaclient/evm/evm_client.go | 2 +- 19 files changed, 132 insertions(+), 112 deletions(-) delete mode 100644 docs/cli/zetacored/zetacored_tx_lightclient_update-verification-flags.md 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 { From 8eb27f6b6e3c252c4f698e5b96f1bde84362deac Mon Sep 17 00:00:00 2001 From: Tanmay Date: Mon, 29 Apr 2024 17:37:16 -0400 Subject: [PATCH 16/31] add cli docs --- ..._lightclient_disable-verification-flags.md | 61 +++++++++++++++++++ ...x_lightclient_enable-verification-flags.md | 61 +++++++++++++++++++ x/lightclient/keeper/verification_flags.go | 2 +- 3 files changed, 123 insertions(+), 1 deletion(-) create mode 100644 docs/cli/zetacored/zetacored_tx_lightclient_disable-verification-flags.md create mode 100644 docs/cli/zetacored/zetacored_tx_lightclient_enable-verification-flags.md diff --git a/docs/cli/zetacored/zetacored_tx_lightclient_disable-verification-flags.md b/docs/cli/zetacored/zetacored_tx_lightclient_disable-verification-flags.md new file mode 100644 index 0000000000..c7fcd8d441 --- /dev/null +++ b/docs/cli/zetacored/zetacored_tx_lightclient_disable-verification-flags.md @@ -0,0 +1,61 @@ +# tx lightclient disable-verification-flags + +Disable verification flags for the list of chains separated by comma + +### Synopsis + +Provide a list of chain ids separated by comma to enable block header verification for the specified chain ids. + + Example: + To disable verification flags for chain ids 1 and 56 + zetacored tx lightclient disable-verification-flags "1,56" + + +``` +zetacored tx lightclient disable-verification-flags [list of chain-id] [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 disable-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/cli/zetacored/zetacored_tx_lightclient_enable-verification-flags.md b/docs/cli/zetacored/zetacored_tx_lightclient_enable-verification-flags.md new file mode 100644 index 0000000000..901c337e89 --- /dev/null +++ b/docs/cli/zetacored/zetacored_tx_lightclient_enable-verification-flags.md @@ -0,0 +1,61 @@ +# tx lightclient enable-verification-flags + +Disable verification flags for the list of chains separated by comma + +### Synopsis + +Provide a list of chain ids separated by comma to enable block header verification for the specified chain ids. + + Example: + To enable verification flags for chain ids 1 and 56 + zetacored tx lightclient enable-verification-flags "1,56" + + +``` +zetacored tx lightclient enable-verification-flags [list of chain-id] [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 enable-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/x/lightclient/keeper/verification_flags.go b/x/lightclient/keeper/verification_flags.go index cb712f3241..eac7bd99ee 100644 --- a/x/lightclient/keeper/verification_flags.go +++ b/x/lightclient/keeper/verification_flags.go @@ -49,7 +49,7 @@ func (k Keeper) GetAllVerificationFlags(ctx sdk.Context) (verificationFlags []ty // It returns an error if the chain is not enabled func (k Keeper) CheckVerificationFlagsEnabled(ctx sdk.Context, chainID int64) error { verificationFlags, found := k.GetVerificationFlags(ctx, chainID) - if !found || verificationFlags.Enabled != true { + if !found || !verificationFlags.Enabled { return cosmoserrors.Wrapf( types.ErrBlockHeaderVerificationDisabled, "proof verification not enabled for,chain id: %d", From 416f42def81ec8784d3e17c86d76b79727b4b694 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Mon, 29 Apr 2024 20:05:03 -0400 Subject: [PATCH 17/31] add bitcoin headers --- cmd/zetae2e/local/local.go | 5 ++++- e2e/runner/setup_zeta.go | 4 ++-- e2e/txserver/zeta_tx_server.go | 4 ++-- pkg/chains/chains.go | 2 +- x/observer/types/message_vote_block_header.go | 2 +- zetaclient/bitcoin/bitcoin_client.go | 4 ++-- 6 files changed, 12 insertions(+), 9 deletions(-) diff --git a/cmd/zetae2e/local/local.go b/cmd/zetae2e/local/local.go index 0fee34f8a9..a46582c634 100644 --- a/cmd/zetae2e/local/local.go +++ b/cmd/zetae2e/local/local.go @@ -13,6 +13,7 @@ import ( "github.com/zeta-chain/zetacore/e2e/e2etests" "github.com/zeta-chain/zetacore/e2e/runner" "github.com/zeta-chain/zetacore/e2e/utils" + "github.com/zeta-chain/zetacore/pkg/chains" "golang.org/x/sync/errgroup" ) @@ -189,7 +190,9 @@ func localE2ETest(cmd *cobra.Command, _ []string) { logger.Print("⚙️ setting up networks") startTime := time.Now() - if err := deployerRunner.EnableVerificationFlags(); err != nil { + if err := deployerRunner.EnableVerificationFlags([]int64{ + chains.GoerliLocalnetChain.ChainId, + chains.BtcRegtestChain.ChainId}); err != nil { panic(err) } diff --git a/e2e/runner/setup_zeta.go b/e2e/runner/setup_zeta.go index 4213173ed7..84f4dcab6d 100644 --- a/e2e/runner/setup_zeta.go +++ b/e2e/runner/setup_zeta.go @@ -215,10 +215,10 @@ func (runner *E2ERunner) SetupBTCZRC20() { } // EnableVerificationFlags enables the verification flags on ZetaChain -func (runner *E2ERunner) EnableVerificationFlags() error { +func (runner *E2ERunner) EnableVerificationFlags(chainIdList []int64) error { runner.Logger.Print("⚙️ enabling verification flags for block headers") - return runner.ZetaTxServer.EnableVerificationFlags(e2eutils.FungibleAdminName) + return runner.ZetaTxServer.EnableVerificationFlags(e2eutils.FungibleAdminName, chainIdList) } // FundEmissionsPool funds the emissions pool on ZetaChain with the same value as used originally on mainnet (20M ZETA) diff --git a/e2e/txserver/zeta_tx_server.go b/e2e/txserver/zeta_tx_server.go index 352c6b7482..7612a5669b 100644 --- a/e2e/txserver/zeta_tx_server.go +++ b/e2e/txserver/zeta_tx_server.go @@ -251,7 +251,7 @@ type intoAny interface { } // EnableVerificationFlags enables the verification flags for the lightclient module -func (zts ZetaTxServer) EnableVerificationFlags(account string) error { +func (zts ZetaTxServer) EnableVerificationFlags(account string, chainIdList []int64) error { // retrieve account acc, err := zts.clientCtx.Keyring.Key(account) if err != nil { @@ -264,7 +264,7 @@ func (zts ZetaTxServer) EnableVerificationFlags(account string) error { _, err = zts.BroadcastTx(account, lightclienttypes.NewMsgEnableVerificationFlags( addr.String(), - []int64{chains.GoerliLocalnetChain.ChainId}, + chainIdList, )) return err diff --git a/pkg/chains/chains.go b/pkg/chains/chains.go index 4e7d71daa4..83c1d16bcc 100644 --- a/pkg/chains/chains.go +++ b/pkg/chains/chains.go @@ -248,7 +248,7 @@ func ChainListByConsensus(consensus Consensus) []*Chain { func ChainListForHeaderSupport() []*Chain { var chainList []*Chain for _, chain := range DefaultChainsList() { - if chain.Consensus == Consensus_ethereum { + if chain.Consensus == Consensus_ethereum || chain.Consensus == Consensus_bitcoin { chainList = append(chainList, chain) } } diff --git a/x/observer/types/message_vote_block_header.go b/x/observer/types/message_vote_block_header.go index 29a138c13f..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.IsHeaderSupportedChain(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/zetaclient/bitcoin/bitcoin_client.go b/zetaclient/bitcoin/bitcoin_client.go index bef74f7310..c6d223b28e 100644 --- a/zetaclient/bitcoin/bitcoin_client.go +++ b/zetaclient/bitcoin/bitcoin_client.go @@ -1341,13 +1341,13 @@ func (ob *BTCChainClient) postBlockHeader(tip int64) error { return err } blockHash := res2.Header.BlockHash() - _, err = ob.zetaClient.PostVoteBlockHeader( + zetatxHash, err := ob.zetaClient.PostVoteBlockHeader( ob.chain.ChainId, blockHash[:], res2.Block.Height, proofs.NewBitcoinHeader(headerBuf.Bytes()), ) - ob.logger.InTx.Info().Msgf("posted block header %d: %s", bn, blockHash) + ob.logger.InTx.Info().Msgf("posted block header %d: %s , Zeta tx hash :%s", bn, blockHash, zetatxHash) if err != nil { // error shouldn't block the process ob.logger.InTx.Error().Err(err).Msgf("error posting bitcoin block header: %d", bn) } From 9569fddfd2d136209189e933f9aff7425f32a66c Mon Sep 17 00:00:00 2001 From: Tanmay Date: Mon, 29 Apr 2024 21:06:29 -0400 Subject: [PATCH 18/31] add changelog --- changelog.md | 1 + docs/cli/zetacored/zetacored_tx_lightclient.md | 2 +- ...ed_tx_lightclient_disable-verification-flags.md | 2 +- ...red_tx_lightclient_enable-verification-flags.md | 2 +- docs/openapi/openapi.swagger.yaml | 2 +- e2e/runner/setup_zeta.go | 4 ++-- e2e/txserver/zeta_tx_server.go | 4 ++-- pkg/chains/chain.go | 2 +- pkg/chains/chain_test.go | 4 ++-- proto/lightclient/verification_flags.proto | 2 +- typescript/lightclient/verification_flags_pb.d.ts | 2 +- .../client/cli/tx_disable_verification_flags.go | 6 +++++- .../client/cli/tx_enable_verification_flags.go | 6 +++++- .../keeper/grpc_query_verification_flags_test.go | 2 +- x/lightclient/keeper/verification_flags.go | 14 +++++++------- .../types/message_disable_verification_flags.go | 6 +++--- .../message_disable_verification_flags_test.go | 4 ++-- .../types/message_enable_verification_flags.go | 7 +++---- .../message_enable_verification_flags_test.go | 4 ++-- x/lightclient/types/verification_flags.pb.go | 2 +- zetaclient/bitcoin/bitcoin_client.go | 2 +- zetaclient/evm/evm_client.go | 2 +- 22 files changed, 45 insertions(+), 37 deletions(-) diff --git a/changelog.md b/changelog.md index 24f443e4d9..dec96b903c 100644 --- a/changelog.md +++ b/changelog.md @@ -5,6 +5,7 @@ ### Refactor * [2032](https://github.com/zeta-chain/node/pull/2032) - improve some general structure of the ZetaClient codebase +* [2097](https://github.com/zeta-chain/node/pull/2097) - refactor lightclient verification flags to account for individual chains ## Unreleased ### Breaking Changes diff --git a/docs/cli/zetacored/zetacored_tx_lightclient.md b/docs/cli/zetacored/zetacored_tx_lightclient.md index befe33201a..65cbae6ac3 100644 --- a/docs/cli/zetacored/zetacored_tx_lightclient.md +++ b/docs/cli/zetacored/zetacored_tx_lightclient.md @@ -26,5 +26,5 @@ zetacored tx lightclient [flags] * [zetacored tx](zetacored_tx.md) - Transactions subcommands * [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 +* [zetacored tx lightclient enable-verification-flags](zetacored_tx_lightclient_enable-verification-flags.md) - Enable verification flags for the list of chains separated by comma diff --git a/docs/cli/zetacored/zetacored_tx_lightclient_disable-verification-flags.md b/docs/cli/zetacored/zetacored_tx_lightclient_disable-verification-flags.md index c7fcd8d441..675b133cd3 100644 --- a/docs/cli/zetacored/zetacored_tx_lightclient_disable-verification-flags.md +++ b/docs/cli/zetacored/zetacored_tx_lightclient_disable-verification-flags.md @@ -4,7 +4,7 @@ Disable verification flags for the list of chains separated by comma ### Synopsis -Provide a list of chain ids separated by comma to enable block header verification for the specified chain ids. +Provide a list of chain ids separated by comma to disable block header verification for the specified chain ids. Example: To disable verification flags for chain ids 1 and 56 diff --git a/docs/cli/zetacored/zetacored_tx_lightclient_enable-verification-flags.md b/docs/cli/zetacored/zetacored_tx_lightclient_enable-verification-flags.md index 901c337e89..ff4dabf58c 100644 --- a/docs/cli/zetacored/zetacored_tx_lightclient_enable-verification-flags.md +++ b/docs/cli/zetacored/zetacored_tx_lightclient_enable-verification-flags.md @@ -1,6 +1,6 @@ # tx lightclient enable-verification-flags -Disable verification flags for the list of chains separated by comma +Enable verification flags for the list of chains separated by comma ### Synopsis diff --git a/docs/openapi/openapi.swagger.yaml b/docs/openapi/openapi.swagger.yaml index 9c92d44d60..23fa44755d 100644 --- a/docs/openapi/openapi.swagger.yaml +++ b/docs/openapi/openapi.swagger.yaml @@ -54359,7 +54359,7 @@ definitions: format: int64 enabled: type: boolean - title: VerificationFlags is a structure containing information which chain types are enabled for block header verification + title: VerificationFlags is a structure containing information of weather a chain is enabled or not for block header verification observerAdmin_Policy: type: object properties: diff --git a/e2e/runner/setup_zeta.go b/e2e/runner/setup_zeta.go index 84f4dcab6d..31d8c39d6b 100644 --- a/e2e/runner/setup_zeta.go +++ b/e2e/runner/setup_zeta.go @@ -215,10 +215,10 @@ func (runner *E2ERunner) SetupBTCZRC20() { } // EnableVerificationFlags enables the verification flags on ZetaChain -func (runner *E2ERunner) EnableVerificationFlags(chainIdList []int64) error { +func (runner *E2ERunner) EnableVerificationFlags(chainIDList []int64) error { runner.Logger.Print("⚙️ enabling verification flags for block headers") - return runner.ZetaTxServer.EnableVerificationFlags(e2eutils.FungibleAdminName, chainIdList) + return runner.ZetaTxServer.EnableVerificationFlags(e2eutils.FungibleAdminName, chainIDList) } // FundEmissionsPool funds the emissions pool on ZetaChain with the same value as used originally on mainnet (20M ZETA) diff --git a/e2e/txserver/zeta_tx_server.go b/e2e/txserver/zeta_tx_server.go index 7612a5669b..9dfdfe35e2 100644 --- a/e2e/txserver/zeta_tx_server.go +++ b/e2e/txserver/zeta_tx_server.go @@ -251,7 +251,7 @@ type intoAny interface { } // EnableVerificationFlags enables the verification flags for the lightclient module -func (zts ZetaTxServer) EnableVerificationFlags(account string, chainIdList []int64) error { +func (zts ZetaTxServer) EnableVerificationFlags(account string, chainIDList []int64) error { // retrieve account acc, err := zts.clientCtx.Keyring.Key(account) if err != nil { @@ -264,7 +264,7 @@ func (zts ZetaTxServer) EnableVerificationFlags(account string, chainIdList []in _, err = zts.BroadcastTx(account, lightclienttypes.NewMsgEnableVerificationFlags( addr.String(), - chainIdList, + chainIDList, )) return err diff --git a/pkg/chains/chain.go b/pkg/chains/chain.go index 9d6b57acf2..1306e991fe 100644 --- a/pkg/chains/chain.go +++ b/pkg/chains/chain.go @@ -101,7 +101,7 @@ func IsZetaChain(chainID int64) bool { return ChainIDInChainList(chainID, ChainListByNetwork(Network_zeta)) } -// IsHeaderSupportedChain returns true if the chain is an EVM chain supporting block header-based verification +// IsHeaderSupportedChain returns true if the chain is supports 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 e66bb6432b..6630aac8b7 100644 --- a/pkg/chains/chain_test.go +++ b/pkg/chains/chain_test.go @@ -185,7 +185,7 @@ func TestIsEVMChain(t *testing.T) { } } -func TestIsHeaderSupportedEVMChain(t *testing.T) { +func TestIsHeaderSupportedChain(t *testing.T) { tests := []struct { name string chainID int64 @@ -197,7 +197,7 @@ func TestIsHeaderSupportedEVMChain(t *testing.T) { {"Sepolia Testnet", SepoliaChain.ChainId, true}, {"BSC Testnet", BscTestnetChain.ChainId, true}, {"BSC Mainnet", BscMainnetChain.ChainId, true}, - {"Non-EVM", BtcMainnetChain.ChainId, false}, + {"BTC", BtcMainnetChain.ChainId, true}, {"Zeta Mainnet", ZetaChainMainnet.ChainId, false}, } diff --git a/proto/lightclient/verification_flags.proto b/proto/lightclient/verification_flags.proto index 6638edccce..22a3a7c75b 100644 --- a/proto/lightclient/verification_flags.proto +++ b/proto/lightclient/verification_flags.proto @@ -5,7 +5,7 @@ import "gogoproto/gogo.proto"; option go_package = "github.com/zeta-chain/zetacore/x/lightclient/types"; -// VerificationFlags is a structure containing information which chain types are enabled for block header verification +// VerificationFlags is a structure containing information of weather a chain is enabled or not for block header verification message VerificationFlags { int64 chain_id = 1; bool enabled = 2; diff --git a/typescript/lightclient/verification_flags_pb.d.ts b/typescript/lightclient/verification_flags_pb.d.ts index 9487b13516..d5a4df9b6d 100644 --- a/typescript/lightclient/verification_flags_pb.d.ts +++ b/typescript/lightclient/verification_flags_pb.d.ts @@ -7,7 +7,7 @@ import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialM import { Message, proto3 } from "@bufbuild/protobuf"; /** - * VerificationFlags is a structure containing information which chain types are enabled for block header verification + * VerificationFlags is a structure containing information of weather a chain is enabled or not for block header verification * * @generated from message zetachain.zetacore.lightclient.VerificationFlags */ diff --git a/x/lightclient/client/cli/tx_disable_verification_flags.go b/x/lightclient/client/cli/tx_disable_verification_flags.go index 136fc14b71..42ab435175 100644 --- a/x/lightclient/client/cli/tx_disable_verification_flags.go +++ b/x/lightclient/client/cli/tx_disable_verification_flags.go @@ -15,7 +15,7 @@ func CmdDisableVerificationFlags() *cobra.Command { cmd := &cobra.Command{ 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. + Long: `Provide a list of chain ids separated by comma to disable block header verification for the specified chain ids. Example: To disable verification flags for chain ids 1 and 56 @@ -40,6 +40,10 @@ func CmdDisableVerificationFlags() *cobra.Command { } msg := types.NewMsgDisableVerificationFlags(clientCtx.GetFromAddress().String(), chainIDList) + err = msg.ValidateBasic() + if err != nil { + return err + } return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) }, diff --git a/x/lightclient/client/cli/tx_enable_verification_flags.go b/x/lightclient/client/cli/tx_enable_verification_flags.go index 6ced87a553..7b597da2c6 100644 --- a/x/lightclient/client/cli/tx_enable_verification_flags.go +++ b/x/lightclient/client/cli/tx_enable_verification_flags.go @@ -14,7 +14,7 @@ import ( func CmdEnableVerificationFlags() *cobra.Command { cmd := &cobra.Command{ Use: "enable-verification-flags [list of chain-id]", - Short: "Disable verification flags for the list of chains separated by comma", + Short: "Enable 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: @@ -40,6 +40,10 @@ func CmdEnableVerificationFlags() *cobra.Command { } msg := types.NewMsgEnableVerificationFlags(clientCtx.GetFromAddress().String(), chainIDList) + err = msg.ValidateBasic() + if err != nil { + return err + } return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) }, diff --git a/x/lightclient/keeper/grpc_query_verification_flags_test.go b/x/lightclient/keeper/grpc_query_verification_flags_test.go index ec7f679ab0..793f65eac8 100644 --- a/x/lightclient/keeper/grpc_query_verification_flags_test.go +++ b/x/lightclient/keeper/grpc_query_verification_flags_test.go @@ -20,7 +20,7 @@ func TestKeeper_VerificationFlags(t *testing.T) { require.Error(t, err) }) - t.Run("should error if not found", func(t *testing.T) { + t.Run("should return empty set if not found", func(t *testing.T) { k, ctx, _, _ := keepertest.LightclientKeeper(t) wctx := sdk.WrapSDKContext(ctx) diff --git a/x/lightclient/keeper/verification_flags.go b/x/lightclient/keeper/verification_flags.go index eac7bd99ee..387e4801d8 100644 --- a/x/lightclient/keeper/verification_flags.go +++ b/x/lightclient/keeper/verification_flags.go @@ -10,24 +10,24 @@ import ( ) // SetVerificationFlags set the verification flags in the store -func (k Keeper) SetVerificationFlags(ctx sdk.Context, vf types.VerificationFlags) { +func (k Keeper) SetVerificationFlags(ctx sdk.Context, verificationFlag types.VerificationFlags) { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.VerificationFlagsKey)) - b := k.cdc.MustMarshal(&vf) - key := types.KeyPrefix(fmt.Sprintf("%d", vf.ChainId)) + b := k.cdc.MustMarshal(&verificationFlag) + key := types.KeyPrefix(fmt.Sprintf("%d", verificationFlag.ChainId)) store.Set(key, b) } // GetVerificationFlags returns the verification flags -func (k Keeper) GetVerificationFlags(ctx sdk.Context, chainID int64) (val types.VerificationFlags, found bool) { +func (k Keeper) GetVerificationFlags(ctx sdk.Context, chainID int64) (verificationFlag types.VerificationFlags, found bool) { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.VerificationFlagsKey)) key := types.KeyPrefix(fmt.Sprintf("%d", chainID)) b := store.Get(key) if b == nil { - return val, false + return verificationFlag, false } - k.cdc.MustUnmarshal(b, &val) - return val, true + k.cdc.MustUnmarshal(b, &verificationFlag) + return verificationFlag, true } func (k Keeper) GetAllVerificationFlags(ctx sdk.Context) (verificationFlags []types.VerificationFlags) { diff --git a/x/lightclient/types/message_disable_verification_flags.go b/x/lightclient/types/message_disable_verification_flags.go index 12df4cddd3..5ac004ad5c 100644 --- a/x/lightclient/types/message_disable_verification_flags.go +++ b/x/lightclient/types/message_disable_verification_flags.go @@ -46,15 +46,15 @@ func (msg *MsgDisableVerificationFlags) ValidateBasic() error { if _, err := sdk.AccAddressFromBech32(msg.Creator); err != nil { return cosmoserrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) } - changelistForHeaderSupport := chains.ChainListForHeaderSupport() + chainListForHeaderSupport := chains.ChainListForHeaderSupport() if len(msg.ChainIdList) == 0 { return cosmoserrors.Wrapf(sdkerrors.ErrInvalidRequest, "chain id list cannot be empty") } - if len(msg.ChainIdList) > len(changelistForHeaderSupport) { + if len(msg.ChainIdList) > len(chainListForHeaderSupport) { return cosmoserrors.Wrapf(sdkerrors.ErrInvalidRequest, "chain id list cannot be greater than supported chains") } for _, chainID := range msg.ChainIdList { - if !chains.ChainIDInChainList(chainID, changelistForHeaderSupport) { + if !chains.ChainIDInChainList(chainID, chainListForHeaderSupport) { return cosmoserrors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid chain id header not supported (%d)", chainID) } } diff --git a/x/lightclient/types/message_disable_verification_flags_test.go b/x/lightclient/types/message_disable_verification_flags_test.go index 18f45764e7..6d4231c9cc 100644 --- a/x/lightclient/types/message_disable_verification_flags_test.go +++ b/x/lightclient/types/message_disable_verification_flags_test.go @@ -53,11 +53,11 @@ func TestMsgDisableVerificationFlags_ValidateBasic(t *testing.T) { name: "invalid chain id", msg: types.MsgDisableVerificationFlags{ Creator: sample.AccAddress(), - ChainIdList: []int64{chains.BtcMainnetChain.ChainId}, + ChainIdList: []int64{chains.ZetaPrivnetChain.ChainId}, }, err: func(t require.TestingT, err error, i ...interface{}) { require.ErrorIs(t, err, sdkerrors.ErrInvalidRequest) - require.ErrorContains(t, err, fmt.Sprintf("invalid chain id header not supported (%d)", chains.BtcMainnetChain.ChainId)) + require.ErrorContains(t, err, fmt.Sprintf("invalid chain id header not supported (%d)", chains.ZetaPrivnetChain.ChainId)) }, }, { diff --git a/x/lightclient/types/message_enable_verification_flags.go b/x/lightclient/types/message_enable_verification_flags.go index 1252274f02..6d517ebd9d 100644 --- a/x/lightclient/types/message_enable_verification_flags.go +++ b/x/lightclient/types/message_enable_verification_flags.go @@ -18,7 +18,6 @@ func NewMsgEnableVerificationFlags(creator string, chainIDs []int64) *MsgEnableV Creator: creator, ChainIdList: chainIDs, } - } func (msg *MsgEnableVerificationFlags) Route() string { @@ -46,15 +45,15 @@ func (msg *MsgEnableVerificationFlags) ValidateBasic() error { if _, err := sdk.AccAddressFromBech32(msg.Creator); err != nil { return cosmoserrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) } - changelistForHeaderSupport := chains.ChainListForHeaderSupport() + chainListForHeaderSupport := chains.ChainListForHeaderSupport() if len(msg.ChainIdList) == 0 { return cosmoserrors.Wrapf(sdkerrors.ErrInvalidRequest, "chain id list cannot be empty") } - if len(msg.ChainIdList) > len(changelistForHeaderSupport) { + if len(msg.ChainIdList) > len(chainListForHeaderSupport) { return cosmoserrors.Wrapf(sdkerrors.ErrInvalidRequest, "chain id list cannot be greater than supported chains") } for _, chainID := range msg.ChainIdList { - if !chains.ChainIDInChainList(chainID, changelistForHeaderSupport) { + if !chains.ChainIDInChainList(chainID, chainListForHeaderSupport) { return cosmoserrors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid chain id header not supported (%d)", chainID) } } diff --git a/x/lightclient/types/message_enable_verification_flags_test.go b/x/lightclient/types/message_enable_verification_flags_test.go index c534267b29..fc8e75a5c7 100644 --- a/x/lightclient/types/message_enable_verification_flags_test.go +++ b/x/lightclient/types/message_enable_verification_flags_test.go @@ -53,11 +53,11 @@ func TestMsgEnableVerificationFlags_ValidateBasic(t *testing.T) { name: "invalid chain id", msg: types.MsgEnableVerificationFlags{ Creator: sample.AccAddress(), - ChainIdList: []int64{chains.BtcMainnetChain.ChainId}, + ChainIdList: []int64{chains.ZetaPrivnetChain.ChainId}, }, err: func(t require.TestingT, err error, i ...interface{}) { require.ErrorIs(t, err, sdkerrors.ErrInvalidRequest) - require.ErrorContains(t, err, fmt.Sprintf("invalid chain id header not supported (%d)", chains.BtcMainnetChain.ChainId)) + require.ErrorContains(t, err, fmt.Sprintf("invalid chain id header not supported (%d)", chains.ZetaPrivnetChain.ChainId)) }, }, { diff --git a/x/lightclient/types/verification_flags.pb.go b/x/lightclient/types/verification_flags.pb.go index c7dd07de14..ad6a724f2a 100644 --- a/x/lightclient/types/verification_flags.pb.go +++ b/x/lightclient/types/verification_flags.pb.go @@ -24,7 +24,7 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// VerificationFlags is a structure containing information which chain types are enabled for block header verification +// VerificationFlags is a structure containing information of weather a chain is enabled or not for block header verification type VerificationFlags struct { ChainId int64 `protobuf:"varint,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` Enabled bool `protobuf:"varint,2,opt,name=enabled,proto3" json:"enabled,omitempty"` diff --git a/zetaclient/bitcoin/bitcoin_client.go b/zetaclient/bitcoin/bitcoin_client.go index c6d223b28e..ab65d2e171 100644 --- a/zetaclient/bitcoin/bitcoin_client.go +++ b/zetaclient/bitcoin/bitcoin_client.go @@ -1347,7 +1347,7 @@ func (ob *BTCChainClient) postBlockHeader(tip int64) error { res2.Block.Height, proofs.NewBitcoinHeader(headerBuf.Bytes()), ) - ob.logger.InTx.Info().Msgf("posted block header %d: %s , Zeta tx hash :%s", bn, blockHash, zetatxHash) + ob.logger.InTx.Info().Msgf("posted block header %d: %s, zeta tx hash :%s", bn, blockHash, zetatxHash) if err != nil { // error shouldn't block the process ob.logger.InTx.Error().Err(err).Msgf("error posting bitcoin block header: %d", bn) } diff --git a/zetaclient/evm/evm_client.go b/zetaclient/evm/evm_client.go index 8b6031c63f..1985181051 100644 --- a/zetaclient/evm/evm_client.go +++ b/zetaclient/evm/evm_client.go @@ -983,7 +983,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.IsHeaderSupportedChain(ob.chain.ChainId) { + if found && verificationFlags.Enabled { // post block header for supported chains err := ob.postBlockHeader(toBlock) if err != nil { From 0a17356082c181ccecb2eb5a2740d6c59e6e52ea Mon Sep 17 00:00:00 2001 From: Tanmay Date: Tue, 30 Apr 2024 00:48:56 -0400 Subject: [PATCH 19/31] ad some unit tests for verification_flags.go --- .../msg_server_disable_verification_flags.go | 2 +- .../msg_server_enable_verification_flags.go | 2 +- x/lightclient/keeper/verification_flags.go | 4 +- .../keeper/verification_flags_test.go | 43 +++++++++++++++++++ 4 files changed, 47 insertions(+), 4 deletions(-) diff --git a/x/lightclient/keeper/msg_server_disable_verification_flags.go b/x/lightclient/keeper/msg_server_disable_verification_flags.go index 1950bd716c..97730e3d83 100644 --- a/x/lightclient/keeper/msg_server_disable_verification_flags.go +++ b/x/lightclient/keeper/msg_server_disable_verification_flags.go @@ -19,7 +19,7 @@ func (k msgServer) DisableVerificationFlags(goCtx context.Context, msg *types.Ms } for _, chainID := range msg.ChainIdList { - // set the verification flags + // set the verification flags to false to disable verification k.SetVerificationFlags(ctx, types.VerificationFlags{ ChainId: chainID, Enabled: false, diff --git a/x/lightclient/keeper/msg_server_enable_verification_flags.go b/x/lightclient/keeper/msg_server_enable_verification_flags.go index 4d3c0f2750..7818f00987 100644 --- a/x/lightclient/keeper/msg_server_enable_verification_flags.go +++ b/x/lightclient/keeper/msg_server_enable_verification_flags.go @@ -22,7 +22,7 @@ func (k msgServer) EnableVerificationFlags(goCtx context.Context, msg *types.Msg } for _, chainID := range msg.ChainIdList { - // set the verification flags + // set the verification flags to true to enable verification k.SetVerificationFlags(ctx, types.VerificationFlags{ ChainId: chainID, Enabled: true, diff --git a/x/lightclient/keeper/verification_flags.go b/x/lightclient/keeper/verification_flags.go index 387e4801d8..caf9372962 100644 --- a/x/lightclient/keeper/verification_flags.go +++ b/x/lightclient/keeper/verification_flags.go @@ -9,7 +9,7 @@ import ( "github.com/zeta-chain/zetacore/x/lightclient/types" ) -// SetVerificationFlags set the verification flags in the store +// SetVerificationFlags set the verification flags in the store. The key is the chain id func (k Keeper) SetVerificationFlags(ctx sdk.Context, verificationFlag types.VerificationFlags) { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.VerificationFlagsKey)) b := k.cdc.MustMarshal(&verificationFlag) @@ -46,7 +46,7 @@ func (k Keeper) GetAllVerificationFlags(ctx sdk.Context) (verificationFlags []ty } // CheckVerificationFlagsEnabled checks for a specific chain if the verification flags are enabled -// It returns an error if the chain is not enabled +// It returns an error if the chain is not enabled or the verification flags are not for that chain func (k Keeper) CheckVerificationFlagsEnabled(ctx sdk.Context, chainID int64) error { verificationFlags, found := k.GetVerificationFlags(ctx, chainID) if !found || !verificationFlags.Enabled { diff --git a/x/lightclient/keeper/verification_flags_test.go b/x/lightclient/keeper/verification_flags_test.go index 20b71c3eeb..784632dbbd 100644 --- a/x/lightclient/keeper/verification_flags_test.go +++ b/x/lightclient/keeper/verification_flags_test.go @@ -7,9 +7,32 @@ import ( "github.com/stretchr/testify/require" "github.com/zeta-chain/zetacore/pkg/chains" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" + "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/lightclient/types" ) +func TestKeeper_GetAllVerificationFlags(t *testing.T) { + t.Run("can get all verification flags", func(t *testing.T) { + k, ctx, _, _ := keepertest.LightclientKeeper(t) + + vf := sample.VerificationFlags() + + for _, v := range vf { + k.SetVerificationFlags(ctx, v) + } + + allVf := k.GetAllVerificationFlags(ctx) + require.Len(t, allVf, 2) + require.Equal(t, vf, allVf) + }) + + t.Run("return empty list when no flags are set", func(t *testing.T) { + k, ctx, _, _ := keepertest.LightclientKeeper(t) + + allVf := k.GetAllVerificationFlags(ctx) + require.Len(t, allVf, 0) + }) +} func TestKeeper_GetVerificationFlags(t *testing.T) { t.Run("can get and set verification flags", func(t *testing.T) { k, ctx, _, _ := keepertest.LightclientKeeper(t) @@ -66,4 +89,24 @@ func TestKeeper_CheckVerificationFlagsEnabled(t *testing.T) { require.Error(t, err) require.ErrorContains(t, err, fmt.Sprintf("proof verification not enabled for,chain id: %d", 1000)) }) + + t.Run("check returns false if flag is not set", func(t *testing.T) { + k, ctx, _, _ := keepertest.LightclientKeeper(t) + err := k.CheckVerificationFlagsEnabled(ctx, chains.EthChain.ChainId) + require.ErrorContains(t, err, fmt.Sprintf("proof verification not enabled for,chain id: %d", chains.EthChain.ChainId)) + + err = k.CheckVerificationFlagsEnabled(ctx, chains.BtcMainnetChain.ChainId) + require.ErrorContains(t, err, fmt.Sprintf("proof verification not enabled for,chain id: %d", chains.BtcMainnetChain.ChainId)) + }) + + t.Run("check returns false is flag is disabled", func(t *testing.T) { + k, ctx, _, _ := keepertest.LightclientKeeper(t) + k.SetVerificationFlags(ctx, types.VerificationFlags{ + ChainId: chains.EthChain.ChainId, + Enabled: false, + }) + + err := k.CheckVerificationFlagsEnabled(ctx, chains.EthChain.ChainId) + require.ErrorContains(t, err, fmt.Sprintf("proof verification not enabled for,chain id: %d", chains.EthChain.ChainId)) + }) } From ab71ad834a571eca159c8a350401b5453566ba1d Mon Sep 17 00:00:00 2001 From: Tanmay Date: Tue, 30 Apr 2024 01:04:44 -0400 Subject: [PATCH 20/31] add breaking changes section --- changelog.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/changelog.md b/changelog.md index dec96b903c..10f48a49b3 100644 --- a/changelog.md +++ b/changelog.md @@ -1,6 +1,10 @@ # CHANGELOG ## Unreleased +### Breaking Changes +* `MsgUpdateVerificationFlags` has been removed, and replaced with `MsgEnableVerificationFlags` and `MsgDisableVerificationFlags` messages. + * `MsgEnableVerificationFlags` message enables the verification flags for a list of chains and can be triggered via `PolicyType_groupOperational` + * `MsgDisableVerificationFlags` message disables the verification flags for a list of chains and can be triggered via `PolicyType_emergency` ### Refactor From 6c3d4db3fc2f2268e6d7971d950aa3e5ce90991c Mon Sep 17 00:00:00 2001 From: Tanmay Date: Tue, 30 Apr 2024 12:45:28 -0400 Subject: [PATCH 21/31] add trim space for cli inputs --- x/lightclient/client/cli/tx_disable_verification_flags.go | 2 +- x/lightclient/client/cli/tx_enable_verification_flags.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/x/lightclient/client/cli/tx_disable_verification_flags.go b/x/lightclient/client/cli/tx_disable_verification_flags.go index 42ab435175..fe8213060d 100644 --- a/x/lightclient/client/cli/tx_disable_verification_flags.go +++ b/x/lightclient/client/cli/tx_disable_verification_flags.go @@ -29,7 +29,7 @@ func CmdDisableVerificationFlags() *cobra.Command { return err } - chainIDs := strings.Split(args[0], ",") + chainIDs := strings.Split(strings.TrimSpace(args[0]), ",") var chainIDList []int64 for _, chainID := range chainIDs { chainIDInt, err := strconv.ParseInt(chainID, 10, 64) diff --git a/x/lightclient/client/cli/tx_enable_verification_flags.go b/x/lightclient/client/cli/tx_enable_verification_flags.go index 7b597da2c6..33a3934f8f 100644 --- a/x/lightclient/client/cli/tx_enable_verification_flags.go +++ b/x/lightclient/client/cli/tx_enable_verification_flags.go @@ -29,7 +29,7 @@ func CmdEnableVerificationFlags() *cobra.Command { return err } - chainIDs := strings.Split(args[0], ",") + chainIDs := strings.Split(strings.TrimSpace(args[0]), ",") var chainIDList []int64 for _, chainID := range chainIDs { chainIDInt, err := strconv.ParseInt(chainID, 10, 64) From 415adcc6f8f1d908f490959b872f282d5fc37132 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Tue, 30 Apr 2024 18:05:59 -0400 Subject: [PATCH 22/31] refactor verification flags into enabled chains --- cmd/zetae2e/local/local.go | 2 +- e2e/runner/setup_zeta.go | 6 +- e2e/txserver/zeta_tx_server.go | 6 +- proto/lightclient/genesis.proto | 2 +- proto/lightclient/query.proto | 8 +- proto/lightclient/tx.proto | 12 +- proto/lightclient/verification_flags.proto | 6 +- testutil/sample/lightclient.go | 9 +- x/lightclient/client/cli/query.go | 2 +- .../client/cli/query_verification_flags.go | 8 +- .../cli/tx_disable_verification_flags.go | 8 +- .../cli/tx_enable_verification_flags.go | 8 +- x/lightclient/genesis.go | 16 +- x/lightclient/genesis_test.go | 11 +- x/lightclient/keeper/block_header.go | 2 +- x/lightclient/keeper/block_header_test.go | 83 ++++-- .../keeper/block_header_verification.go | 47 +++ .../keeper/block_header_verification_test.go | 107 +++++++ .../grpc_query_header_enabled_chains.go | 22 ++ ... grpc_query_header_enabled_chains_test.go} | 16 +- .../keeper/grpc_query_verification_flags.go | 22 -- ...isable_block_header_verification._test.go} | 54 ++-- ...rver_disable_block_header_verification.go} | 14 +- ...erver_enable_block_header_verification.go} | 17 +- ..._enable_block_header_verification_test.go} | 54 ++-- x/lightclient/keeper/proof.go | 2 +- x/lightclient/keeper/proof_test.go | 114 +++++--- x/lightclient/keeper/verification_flags.go | 60 ---- .../keeper/verification_flags_test.go | 112 ------- .../types/block_header_verification.go | 59 ++++ .../types/block_header_verification_test.go | 17 ++ x/lightclient/types/codec.go | 8 +- x/lightclient/types/genesis.go | 6 +- x/lightclient/types/genesis.pb.go | 73 ++--- x/lightclient/types/genesis_test.go | 2 +- .../message_disable_verification_flags.go | 20 +- ...message_disable_verification_flags_test.go | 36 +-- .../message_enable_verification_flags.go | 20 +- .../message_enable_verification_flags_test.go | 36 +-- x/lightclient/types/query.pb.go | 247 ++++++++-------- x/lightclient/types/query.pb.gw.go | 28 +- x/lightclient/types/tx.pb.go | 274 +++++++++--------- x/lightclient/types/verification_flags.go | 10 +- x/lightclient/types/verification_flags.pb.go | 252 +++++++++++++--- zetaclient/core_context/zeta_core_context.go | 30 +- .../core_context/zeta_core_context_test.go | 2 +- zetaclient/zetabridge/query.go | 8 +- zetaclient/zetabridge/query_test.go | 12 +- zetaclient/zetabridge/tx_test.go | 6 +- zetaclient/zetabridge/zetacore_bridge.go | 6 +- 50 files changed, 1152 insertions(+), 830 deletions(-) create mode 100644 x/lightclient/keeper/block_header_verification.go create mode 100644 x/lightclient/keeper/block_header_verification_test.go create mode 100644 x/lightclient/keeper/grpc_query_header_enabled_chains.go rename x/lightclient/keeper/{grpc_query_verification_flags_test.go => grpc_query_header_enabled_chains_test.go} (69%) delete mode 100644 x/lightclient/keeper/grpc_query_verification_flags.go rename x/lightclient/keeper/{msg_server_disable_verification_flags_test.go => msg_server_disable_block_header_verification._test.go} (67%) rename x/lightclient/keeper/{msg_server_disable_verification_flags.go => msg_server_disable_block_header_verification.go} (63%) rename x/lightclient/keeper/{msg_server_enable_verification_flags.go => msg_server_enable_block_header_verification.go} (56%) rename x/lightclient/keeper/{msg_server_enable_verification_flags_test.go => msg_server_enable_block_header_verification_test.go} (68%) delete mode 100644 x/lightclient/keeper/verification_flags.go delete mode 100644 x/lightclient/keeper/verification_flags_test.go create mode 100644 x/lightclient/types/block_header_verification.go create mode 100644 x/lightclient/types/block_header_verification_test.go diff --git a/cmd/zetae2e/local/local.go b/cmd/zetae2e/local/local.go index a46582c634..0b116e980d 100644 --- a/cmd/zetae2e/local/local.go +++ b/cmd/zetae2e/local/local.go @@ -190,7 +190,7 @@ func localE2ETest(cmd *cobra.Command, _ []string) { logger.Print("⚙️ setting up networks") startTime := time.Now() - if err := deployerRunner.EnableVerificationFlags([]int64{ + if err := deployerRunner.EnableHeaderVerification([]int64{ chains.GoerliLocalnetChain.ChainId, chains.BtcRegtestChain.ChainId}); err != nil { panic(err) diff --git a/e2e/runner/setup_zeta.go b/e2e/runner/setup_zeta.go index 31d8c39d6b..4d2d260a92 100644 --- a/e2e/runner/setup_zeta.go +++ b/e2e/runner/setup_zeta.go @@ -214,11 +214,11 @@ func (runner *E2ERunner) SetupBTCZRC20() { runner.BTCZRC20 = BTCZRC20 } -// EnableVerificationFlags enables the verification flags on ZetaChain -func (runner *E2ERunner) EnableVerificationFlags(chainIDList []int64) error { +// EnableHeaderVerification enables the verification flags on ZetaChain +func (runner *E2ERunner) EnableHeaderVerification(chainIDList []int64) error { runner.Logger.Print("⚙️ enabling verification flags for block headers") - return runner.ZetaTxServer.EnableVerificationFlags(e2eutils.FungibleAdminName, chainIDList) + return runner.ZetaTxServer.EnableHeaderVerification(e2eutils.FungibleAdminName, chainIDList) } // FundEmissionsPool funds the emissions pool on ZetaChain with the same value as used originally on mainnet (20M ZETA) diff --git a/e2e/txserver/zeta_tx_server.go b/e2e/txserver/zeta_tx_server.go index 9dfdfe35e2..8850b04a5d 100644 --- a/e2e/txserver/zeta_tx_server.go +++ b/e2e/txserver/zeta_tx_server.go @@ -250,8 +250,8 @@ type intoAny interface { AsAny() *codectypes.Any } -// EnableVerificationFlags enables the verification flags for the lightclient module -func (zts ZetaTxServer) EnableVerificationFlags(account string, chainIDList []int64) error { +// EnableHeaderVerification enables the verification flags for the lightclient module +func (zts ZetaTxServer) EnableHeaderVerification(account string, chainIDList []int64) error { // retrieve account acc, err := zts.clientCtx.Keyring.Key(account) if err != nil { @@ -262,7 +262,7 @@ func (zts ZetaTxServer) EnableVerificationFlags(account string, chainIDList []in return err } - _, err = zts.BroadcastTx(account, lightclienttypes.NewMsgEnableVerificationFlags( + _, err = zts.BroadcastTx(account, lightclienttypes.NewMsgEnableHeaderVerification( addr.String(), chainIDList, )) diff --git a/proto/lightclient/genesis.proto b/proto/lightclient/genesis.proto index 1aba265f35..c09213987a 100644 --- a/proto/lightclient/genesis.proto +++ b/proto/lightclient/genesis.proto @@ -12,5 +12,5 @@ option go_package = "github.com/zeta-chain/zetacore/x/lightclient/types"; message GenesisState { repeated proofs.BlockHeader block_headers = 1 [(gogoproto.nullable) = false]; repeated ChainState chain_states = 2 [(gogoproto.nullable) = false]; - repeated VerificationFlags verification_flags = 3 [(gogoproto.nullable) = false]; + BlockHeaderVerification block_header_verification = 3 [(gogoproto.nullable) = false]; } diff --git a/proto/lightclient/query.proto b/proto/lightclient/query.proto index 6221535778..2195ae64b8 100644 --- a/proto/lightclient/query.proto +++ b/proto/lightclient/query.proto @@ -32,7 +32,7 @@ service Query { option (google.api.http).get = "/zeta-chain/lightclient/prove"; } - rpc VerificationFlags(QueryVerificationFlagsRequest) returns (QueryVerificationFlagsResponse) { + rpc HeaderEnabledChains(QueryHeaderEnabledChainsRequest) returns (QueryHeaderEnabledChainsResponse) { option (google.api.http).get = "/zeta-chain/lightclient/verification_flags"; } } @@ -83,8 +83,8 @@ message QueryProveResponse { bool valid = 1; } -message QueryVerificationFlagsRequest {} +message QueryHeaderEnabledChainsRequest {} -message QueryVerificationFlagsResponse { - repeated VerificationFlags verification_flags = 1 [(gogoproto.nullable) = false]; +message QueryHeaderEnabledChainsResponse { + repeated EnabledChain enabled_chains = 1 [(gogoproto.nullable) = false]; } diff --git a/proto/lightclient/tx.proto b/proto/lightclient/tx.proto index 4a2b943df3..6d8e11ccec 100644 --- a/proto/lightclient/tx.proto +++ b/proto/lightclient/tx.proto @@ -8,19 +8,19 @@ option go_package = "github.com/zeta-chain/zetacore/x/lightclient/types"; // Msg defines the Msg service. service Msg { - rpc EnableVerificationFlags(MsgEnableVerificationFlags) returns (MsgEnableVerificationFlagsResponse); - rpc DisableVerificationFlags(MsgDisableVerificationFlags) returns (MsgDisableVerificationFlagsResponse); + rpc EnableHeaderVerification(MsgEnableHeaderVerification) returns (MsgEnableHeaderVerificationResponse); + rpc DisableHeaderVerification(MsgDisableHeaderVerification) returns (MsgDisableHeaderVerificationResponse); } -message MsgEnableVerificationFlags { +message MsgEnableHeaderVerification { string creator = 1; repeated int64 chain_id_list = 2; } -message MsgEnableVerificationFlagsResponse {} +message MsgEnableHeaderVerificationResponse {} -message MsgDisableVerificationFlags { +message MsgDisableHeaderVerification { string creator = 1; repeated int64 chain_id_list = 2; } -message MsgDisableVerificationFlagsResponse {} +message MsgDisableHeaderVerificationResponse {} diff --git a/proto/lightclient/verification_flags.proto b/proto/lightclient/verification_flags.proto index 22a3a7c75b..60b6ef6c01 100644 --- a/proto/lightclient/verification_flags.proto +++ b/proto/lightclient/verification_flags.proto @@ -6,7 +6,11 @@ import "gogoproto/gogo.proto"; option go_package = "github.com/zeta-chain/zetacore/x/lightclient/types"; // VerificationFlags is a structure containing information of weather a chain is enabled or not for block header verification -message VerificationFlags { +message EnabledChain { int64 chain_id = 1; bool enabled = 2; } + +message BlockHeaderVerification { + repeated EnabledChain enabled_chains = 1 [(gogoproto.nullable) = false]; +} diff --git a/testutil/sample/lightclient.go b/testutil/sample/lightclient.go index 42e5bef373..dc1ec01e06 100644 --- a/testutil/sample/lightclient.go +++ b/testutil/sample/lightclient.go @@ -33,8 +33,8 @@ func ChainState(chainID int64) lightclienttypes.ChainState { } } -func VerificationFlags() []lightclienttypes.VerificationFlags { - return []lightclienttypes.VerificationFlags{ +func VerificationFlags() []lightclienttypes.EnabledChain { + return []lightclienttypes.EnabledChain{ { ChainId: 1, Enabled: true, @@ -46,6 +46,11 @@ func VerificationFlags() []lightclienttypes.VerificationFlags { } } +func BlockHeaderVerification() lightclienttypes.BlockHeaderVerification { + return lightclienttypes.BlockHeaderVerification{EnabledChains: VerificationFlags()} + +} + // Proof generates a proof and block header // returns the proof, block header, block hash, tx index, chain id, and tx hash func Proof(t *testing.T) (*proofs.Proof, proofs.BlockHeader, string, int64, int64, ethcommon.Hash) { diff --git a/x/lightclient/client/cli/query.go b/x/lightclient/client/cli/query.go index 304c730bb7..d7cd7b92c9 100644 --- a/x/lightclient/client/cli/query.go +++ b/x/lightclient/client/cli/query.go @@ -24,7 +24,7 @@ func GetQueryCmd(_ string) *cobra.Command { CmdListBlockHeader(), CmdShowChainState(), CmdListChainState(), - CmdShowVerificationFlags(), + CmdShowHeaderEnabledChains(), ) return cmd diff --git a/x/lightclient/client/cli/query_verification_flags.go b/x/lightclient/client/cli/query_verification_flags.go index 5b4962c8e5..e8390ccad4 100644 --- a/x/lightclient/client/cli/query_verification_flags.go +++ b/x/lightclient/client/cli/query_verification_flags.go @@ -7,9 +7,9 @@ import ( "github.com/zeta-chain/zetacore/x/lightclient/types" ) -func CmdShowVerificationFlags() *cobra.Command { +func CmdShowHeaderEnabledChains() *cobra.Command { cmd := &cobra.Command{ - Use: "show-verification-flags", + Use: "show-header-enabled-chains", Short: "Show the verification flags", Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, _ []string) (err error) { @@ -20,9 +20,9 @@ func CmdShowVerificationFlags() *cobra.Command { queryClient := types.NewQueryClient(clientCtx) - params := &types.QueryVerificationFlagsRequest{} + params := &types.QueryHeaderEnabledChainsRequest{} - res, err := queryClient.VerificationFlags(cmd.Context(), params) + res, err := queryClient.HeaderEnabledChains(cmd.Context(), params) if err != nil { return err } diff --git a/x/lightclient/client/cli/tx_disable_verification_flags.go b/x/lightclient/client/cli/tx_disable_verification_flags.go index fe8213060d..3d3a92dcba 100644 --- a/x/lightclient/client/cli/tx_disable_verification_flags.go +++ b/x/lightclient/client/cli/tx_disable_verification_flags.go @@ -13,13 +13,13 @@ import ( func CmdDisableVerificationFlags() *cobra.Command { cmd := &cobra.Command{ - Use: "disable-verification-flags [list of chain-id]", - Short: "Disable verification flags for the list of chains separated by comma", + Use: "disable-header-verification [list of chain-id]", + Short: "Disable header verification for the list of chains separated by comma", Long: `Provide a list of chain ids separated by comma to disable block header verification for the specified chain ids. Example: To disable verification flags for chain ids 1 and 56 - zetacored tx lightclient disable-verification-flags "1,56" + zetacored tx lightclient disable-header-verification "1,56" `, Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) (err error) { @@ -39,7 +39,7 @@ func CmdDisableVerificationFlags() *cobra.Command { chainIDList = append(chainIDList, chainIDInt) } - msg := types.NewMsgDisableVerificationFlags(clientCtx.GetFromAddress().String(), chainIDList) + msg := types.NewMsgDisableHeaderVerification(clientCtx.GetFromAddress().String(), chainIDList) err = msg.ValidateBasic() if err != nil { return err diff --git a/x/lightclient/client/cli/tx_enable_verification_flags.go b/x/lightclient/client/cli/tx_enable_verification_flags.go index 33a3934f8f..518b9030f2 100644 --- a/x/lightclient/client/cli/tx_enable_verification_flags.go +++ b/x/lightclient/client/cli/tx_enable_verification_flags.go @@ -13,13 +13,13 @@ import ( func CmdEnableVerificationFlags() *cobra.Command { cmd := &cobra.Command{ - Use: "enable-verification-flags [list of chain-id]", - Short: "Enable verification flags for the list of chains separated by comma", + Use: "enable-header-verification [list of chain-id]", + Short: "Enable verification 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: To enable verification flags for chain ids 1 and 56 - zetacored tx lightclient enable-verification-flags "1,56" + zetacored tx lightclient enable-header-verification "1,56" `, Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) (err error) { @@ -39,7 +39,7 @@ func CmdEnableVerificationFlags() *cobra.Command { chainIDList = append(chainIDList, chainIDInt) } - msg := types.NewMsgEnableVerificationFlags(clientCtx.GetFromAddress().String(), chainIDList) + msg := types.NewMsgEnableHeaderVerification(clientCtx.GetFromAddress().String(), chainIDList) err = msg.ValidateBasic() if err != nil { return err diff --git a/x/lightclient/genesis.go b/x/lightclient/genesis.go index d6b209361b..6df4bc8ae6 100644 --- a/x/lightclient/genesis.go +++ b/x/lightclient/genesis.go @@ -18,17 +18,19 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) k.SetChainState(ctx, elem) } - // set verification flags for all chains - for _, elem := range genState.VerificationFlags { - k.SetVerificationFlags(ctx, elem) - } + k.SetBlockHeaderVerification(ctx, genState.BlockHeaderVerification) } // ExportGenesis returns the lightclient module's exported genesis. func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { + blockHeaderVerification := types.DefaultBlockHeaderVerification() + bhv, found := k.GetBlockHeaderVerification(ctx) + if found { + blockHeaderVerification = bhv + } return &types.GenesisState{ - BlockHeaders: k.GetAllBlockHeaders(ctx), - ChainStates: k.GetAllChainStates(ctx), - VerificationFlags: k.GetAllVerificationFlags(ctx), + BlockHeaders: k.GetAllBlockHeaders(ctx), + ChainStates: k.GetAllChainStates(ctx), + BlockHeaderVerification: blockHeaderVerification, } } diff --git a/x/lightclient/genesis_test.go b/x/lightclient/genesis_test.go index 9591686e27..2778c2e102 100644 --- a/x/lightclient/genesis_test.go +++ b/x/lightclient/genesis_test.go @@ -16,7 +16,7 @@ import ( func TestGenesis(t *testing.T) { t.Run("can import and export genesis", func(t *testing.T) { genesisState := types.GenesisState{ - VerificationFlags: sample.VerificationFlags(), + BlockHeaderVerification: sample.BlockHeaderVerification(), BlockHeaders: []proofs.BlockHeader{ sample.BlockHeader(sample.Hash().Bytes()), sample.BlockHeader(sample.Hash().Bytes()), @@ -49,12 +49,11 @@ func TestGenesis(t *testing.T) { // Compare genesis after export expected := types.GenesisState{ - VerificationFlags: []types.VerificationFlags{}, - BlockHeaders: []proofs.BlockHeader{}, - ChainStates: []types.ChainState{}, + BlockHeaderVerification: types.DefaultBlockHeaderVerification(), + BlockHeaders: []proofs.BlockHeader(nil), + ChainStates: []types.ChainState(nil), } - nullify.Fill(got) - nullify.Fill(expected) require.Equal(t, expected, *got) + require.Equal(t, expected.BlockHeaderVerification.EnabledChains, got.BlockHeaderVerification.EnabledChains) }) } diff --git a/x/lightclient/keeper/block_header.go b/x/lightclient/keeper/block_header.go index 88acb7828f..be8c6fabff 100644 --- a/x/lightclient/keeper/block_header.go +++ b/x/lightclient/keeper/block_header.go @@ -67,7 +67,7 @@ func (k Keeper) CheckNewBlockHeader( header proofs.HeaderData, ) ([]byte, error) { // check verification flags are set - if err := k.CheckVerificationFlagsEnabled(ctx, chainID); err != nil { + if err := k.CheckBlockHeaderVerificationEnabled(ctx, chainID); err != nil { return nil, err } diff --git a/x/lightclient/keeper/block_header_test.go b/x/lightclient/keeper/block_header_test.go index 233e6ef452..f903370ad4 100644 --- a/x/lightclient/keeper/block_header_test.go +++ b/x/lightclient/keeper/block_header_test.go @@ -127,9 +127,13 @@ func TestKeeper_CheckNewBlockHeader(t *testing.T) { t.Run("should succeed if block header is valid", func(t *testing.T) { k, ctx, _, _ := keepertest.LightclientKeeper(t) - k.SetVerificationFlags(ctx, types.VerificationFlags{ - ChainId: chains.SepoliaChain.ChainId, - Enabled: true, + k.SetBlockHeaderVerification(ctx, types.BlockHeaderVerification{ + EnabledChains: []types.EnabledChain{ + { + ChainId: chains.SepoliaChain.ChainId, + Enabled: true, + }, + }, }) bh, _, _ := sepoliaBlockHeaders(t) @@ -142,9 +146,13 @@ func TestKeeper_CheckNewBlockHeader(t *testing.T) { t.Run("should fail if verification flag not enabled", func(t *testing.T) { k, ctx, _, _ := keepertest.LightclientKeeper(t) - k.SetVerificationFlags(ctx, types.VerificationFlags{ - ChainId: chains.SepoliaChain.ChainId, - Enabled: false, + k.SetBlockHeaderVerification(ctx, types.BlockHeaderVerification{ + EnabledChains: []types.EnabledChain{ + { + ChainId: chains.SepoliaChain.ChainId, + Enabled: false, + }, + }, }) bh, _, _ := sepoliaBlockHeaders(t) @@ -158,7 +166,7 @@ func TestKeeper_CheckNewBlockHeader(t *testing.T) { //t.Run("should succeed if block header is valid with chain state existing", func(t *testing.T) { // k, ctx, _, _ := keepertest.LightclientKeeper(t) // - // k.SetVerificationFlags(ctx, types.VerificationFlags{ + // k.SetEnabledChain(ctx, types.EnabledChain{ // EthTypeChainEnabled: true, // }) // @@ -179,11 +187,14 @@ func TestKeeper_CheckNewBlockHeader(t *testing.T) { t.Run("fail if block already exist", func(t *testing.T) { k, ctx, _, _ := keepertest.LightclientKeeper(t) - k.SetVerificationFlags(ctx, types.VerificationFlags{ - ChainId: chains.SepoliaChain.ChainId, - Enabled: true, + k.SetBlockHeaderVerification(ctx, types.BlockHeaderVerification{ + EnabledChains: []types.EnabledChain{ + { + ChainId: chains.SepoliaChain.ChainId, + Enabled: true, + }, + }, }) - bh, _, _ := sepoliaBlockHeaders(t) k.SetBlockHeader(ctx, bh) @@ -194,9 +205,13 @@ func TestKeeper_CheckNewBlockHeader(t *testing.T) { t.Run("fail if chain state and invalid height", func(t *testing.T) { k, ctx, _, _ := keepertest.LightclientKeeper(t) - k.SetVerificationFlags(ctx, types.VerificationFlags{ - ChainId: chains.SepoliaChain.ChainId, - Enabled: true, + k.SetBlockHeaderVerification(ctx, types.BlockHeaderVerification{ + EnabledChains: []types.EnabledChain{ + { + ChainId: chains.SepoliaChain.ChainId, + Enabled: true, + }, + }, }) bh, _, _ := sepoliaBlockHeaders(t) @@ -214,9 +229,13 @@ func TestKeeper_CheckNewBlockHeader(t *testing.T) { t.Run("fail if chain state and no parent", func(t *testing.T) { k, ctx, _, _ := keepertest.LightclientKeeper(t) - k.SetVerificationFlags(ctx, types.VerificationFlags{ - ChainId: chains.SepoliaChain.ChainId, - Enabled: true, + k.SetBlockHeaderVerification(ctx, types.BlockHeaderVerification{ + EnabledChains: []types.EnabledChain{ + { + ChainId: chains.SepoliaChain.ChainId, + Enabled: true, + }, + }, }) bh, _, _ := sepoliaBlockHeaders(t) @@ -237,9 +256,13 @@ func TestKeeper_AddBlockHeader(t *testing.T) { t.Run("should add a block header and create chain state if doesn't exist", func(t *testing.T) { k, ctx, _, _ := keepertest.LightclientKeeper(t) - k.SetVerificationFlags(ctx, types.VerificationFlags{ - ChainId: chains.SepoliaChain.ChainId, - Enabled: true, + k.SetBlockHeaderVerification(ctx, types.BlockHeaderVerification{ + EnabledChains: []types.EnabledChain{ + { + ChainId: chains.SepoliaChain.ChainId, + Enabled: true, + }, + }, }) bh, _, _ := sepoliaBlockHeaders(t) @@ -265,9 +288,13 @@ func TestKeeper_AddBlockHeader(t *testing.T) { t.Run("should add a block header and update chain state if exists", func(t *testing.T) { k, ctx, _, _ := keepertest.LightclientKeeper(t) - k.SetVerificationFlags(ctx, types.VerificationFlags{ - ChainId: chains.SepoliaChain.ChainId, - Enabled: true, + k.SetBlockHeaderVerification(ctx, types.BlockHeaderVerification{ + EnabledChains: []types.EnabledChain{ + { + ChainId: chains.SepoliaChain.ChainId, + Enabled: true, + }, + }, }) bh, _, _ := sepoliaBlockHeaders(t) @@ -301,9 +328,13 @@ func TestKeeper_AddBlockHeader(t *testing.T) { t.Run("should add a block header and update chain state if exists and set earliest height if 0", func(t *testing.T) { k, ctx, _, _ := keepertest.LightclientKeeper(t) - k.SetVerificationFlags(ctx, types.VerificationFlags{ - ChainId: chains.SepoliaChain.ChainId, - Enabled: true, + k.SetBlockHeaderVerification(ctx, types.BlockHeaderVerification{ + EnabledChains: []types.EnabledChain{ + { + ChainId: chains.SepoliaChain.ChainId, + Enabled: true, + }, + }, }) bh, _, _ := sepoliaBlockHeaders(t) diff --git a/x/lightclient/keeper/block_header_verification.go b/x/lightclient/keeper/block_header_verification.go new file mode 100644 index 0000000000..3dc7629a12 --- /dev/null +++ b/x/lightclient/keeper/block_header_verification.go @@ -0,0 +1,47 @@ +package keeper + +import ( + cosmoserrors "cosmossdk.io/errors" + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/zeta-chain/zetacore/x/lightclient/types" +) + +// SetVerificationFlags set the verification flags in the store. The key is the chain id +func (k Keeper) SetBlockHeaderVerification(ctx sdk.Context, bhv types.BlockHeaderVerification) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.VerificationFlagsKey)) + b := k.cdc.MustMarshal(&bhv) + store.Set([]byte{0}, b) +} + +// GetBlockHeaderVerification returns the verification flags +func (k Keeper) GetBlockHeaderVerification(ctx sdk.Context) (bhv types.BlockHeaderVerification, found bool) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.VerificationFlagsKey)) + b := store.Get([]byte{0}) + if b == nil { + return bhv, false + } + + k.cdc.MustUnmarshal(b, &bhv) + return bhv, true +} + +// CheckBlockHeaderVerificationEnabled checks for a specific chain if the verification flags are enabled +// It returns an error if the chain is not enabled or the verification flags are not for that chain +func (k Keeper) CheckBlockHeaderVerificationEnabled(ctx sdk.Context, chainID int64) error { + bhv, found := k.GetBlockHeaderVerification(ctx) + if !found { + return cosmoserrors.Wrapf( + types.ErrBlockHeaderVerificationDisabled, + "proof verification is disabled for all chains", + ) + } + if !bhv.IsChainEnabled(chainID) { + return cosmoserrors.Wrapf( + types.ErrBlockHeaderVerificationDisabled, + "proof verification is disabled for chain %d", + chainID, + ) + } + return nil +} diff --git a/x/lightclient/keeper/block_header_verification_test.go b/x/lightclient/keeper/block_header_verification_test.go new file mode 100644 index 0000000000..df93ef95a3 --- /dev/null +++ b/x/lightclient/keeper/block_header_verification_test.go @@ -0,0 +1,107 @@ +package keeper_test + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/require" + "github.com/zeta-chain/zetacore/pkg/chains" + keepertest "github.com/zeta-chain/zetacore/testutil/keeper" + "github.com/zeta-chain/zetacore/testutil/sample" + "github.com/zeta-chain/zetacore/x/lightclient/types" +) + +func TestKeeper_GetBlockHeaderVerification(t *testing.T) { + t.Run("can get all verification flags", func(t *testing.T) { + k, ctx, _, _ := keepertest.LightclientKeeper(t) + + bhv := sample.BlockHeaderVerification() + + k.SetBlockHeaderVerification(ctx, bhv) + + blockHeaderVerification, found := k.GetBlockHeaderVerification(ctx) + require.True(t, found) + require.Len(t, blockHeaderVerification.EnabledChains, 2) + require.Equal(t, bhv, blockHeaderVerification) + }) + + t.Run("return empty list when no flags are set", func(t *testing.T) { + k, ctx, _, _ := keepertest.LightclientKeeper(t) + + blockHeaderVerification, found := k.GetBlockHeaderVerification(ctx) + require.False(t, found) + require.Len(t, blockHeaderVerification.EnabledChains, 0) + }) +} + +func TestKeeper_CheckVerificationFlagsEnabled(t *testing.T) { + t.Run("can check verification flags with ethereum enabled", func(t *testing.T) { + k, ctx, _, _ := keepertest.LightclientKeeper(t) + k.SetBlockHeaderVerification(ctx, types.BlockHeaderVerification{ + EnabledChains: []types.EnabledChain{ + { + ChainId: chains.EthChain.ChainId, + Enabled: true, + }, + }, + }) + + err := k.CheckBlockHeaderVerificationEnabled(ctx, chains.EthChain.ChainId) + require.NoError(t, err) + + err = k.CheckBlockHeaderVerificationEnabled(ctx, chains.BtcMainnetChain.ChainId) + require.Error(t, err) + require.ErrorContains(t, err, fmt.Sprintf("proof verification is disabled for chain %d", chains.BtcMainnetChain.ChainId)) + + err = k.CheckBlockHeaderVerificationEnabled(ctx, 1000) + require.Error(t, err) + require.ErrorContains(t, err, fmt.Sprintf("proof verification is disabled for chain %d", 1000)) + }) + + t.Run("can check verification flags with bitcoin enabled", func(t *testing.T) { + k, ctx, _, _ := keepertest.LightclientKeeper(t) + k.SetBlockHeaderVerification(ctx, types.BlockHeaderVerification{ + EnabledChains: []types.EnabledChain{ + { + ChainId: chains.BtcMainnetChain.ChainId, + Enabled: true, + }, + }, + }) + + err := k.CheckBlockHeaderVerificationEnabled(ctx, chains.EthChain.ChainId) + require.Error(t, err) + require.ErrorContains(t, err, fmt.Sprintf("proof verification is disabled for chain %d", chains.EthChain.ChainId)) + + err = k.CheckBlockHeaderVerificationEnabled(ctx, chains.BtcMainnetChain.ChainId) + require.NoError(t, err) + + err = k.CheckBlockHeaderVerificationEnabled(ctx, 1000) + require.Error(t, err) + require.ErrorContains(t, err, fmt.Sprintf("proof verification is disabled for chain %d", 1000)) + }) + + t.Run("check returns false if flag is not set", func(t *testing.T) { + k, ctx, _, _ := keepertest.LightclientKeeper(t) + err := k.CheckBlockHeaderVerificationEnabled(ctx, chains.EthChain.ChainId) + require.ErrorContains(t, err, "proof verification is disabled for all chains") + + err = k.CheckBlockHeaderVerificationEnabled(ctx, chains.BtcMainnetChain.ChainId) + require.ErrorContains(t, err, "proof verification is disabled for all chains") + }) + + t.Run("check returns false is flag is disabled", func(t *testing.T) { + k, ctx, _, _ := keepertest.LightclientKeeper(t) + k.SetBlockHeaderVerification(ctx, types.BlockHeaderVerification{ + EnabledChains: []types.EnabledChain{ + { + ChainId: chains.EthChain.ChainId, + Enabled: false, + }, + }, + }) + + err := k.CheckBlockHeaderVerificationEnabled(ctx, chains.EthChain.ChainId) + require.ErrorContains(t, err, fmt.Sprintf("proof verification is disabled for chain %d", chains.EthChain.ChainId)) + }) +} diff --git a/x/lightclient/keeper/grpc_query_header_enabled_chains.go b/x/lightclient/keeper/grpc_query_header_enabled_chains.go new file mode 100644 index 0000000000..797169155f --- /dev/null +++ b/x/lightclient/keeper/grpc_query_header_enabled_chains.go @@ -0,0 +1,22 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/zeta-chain/zetacore/x/lightclient/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +// EnabledChain implements the Query/EnabledChain gRPC method +func (k Keeper) HeaderEnabledChains(c context.Context, req *types.QueryHeaderEnabledChainsRequest) (*types.QueryHeaderEnabledChainsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + ctx := sdk.UnwrapSDKContext(c) + + val, _ := k.GetBlockHeaderVerification(ctx) + + return &types.QueryHeaderEnabledChainsResponse{EnabledChains: val.GetVerificationFlags()}, nil +} diff --git a/x/lightclient/keeper/grpc_query_verification_flags_test.go b/x/lightclient/keeper/grpc_query_header_enabled_chains_test.go similarity index 69% rename from x/lightclient/keeper/grpc_query_verification_flags_test.go rename to x/lightclient/keeper/grpc_query_header_enabled_chains_test.go index 793f65eac8..905f5900bd 100644 --- a/x/lightclient/keeper/grpc_query_verification_flags_test.go +++ b/x/lightclient/keeper/grpc_query_header_enabled_chains_test.go @@ -15,7 +15,7 @@ func TestKeeper_VerificationFlags(t *testing.T) { k, ctx, _, _ := keepertest.LightclientKeeper(t) wctx := sdk.WrapSDKContext(ctx) - res, err := k.VerificationFlags(wctx, nil) + res, err := k.HeaderEnabledChains(wctx, nil) require.Nil(t, res) require.Error(t, err) }) @@ -24,20 +24,18 @@ func TestKeeper_VerificationFlags(t *testing.T) { k, ctx, _, _ := keepertest.LightclientKeeper(t) wctx := sdk.WrapSDKContext(ctx) - res, _ := k.VerificationFlags(wctx, &types.QueryVerificationFlagsRequest{}) - require.Len(t, res.VerificationFlags, 0) + res, _ := k.HeaderEnabledChains(wctx, &types.QueryHeaderEnabledChainsRequest{}) + require.Len(t, res.EnabledChains, 0) }) t.Run("should return if block header state is found", func(t *testing.T) { k, ctx, _, _ := keepertest.LightclientKeeper(t) wctx := sdk.WrapSDKContext(ctx) - vf := sample.VerificationFlags() - for _, v := range vf { - k.SetVerificationFlags(ctx, v) - } + bhv := sample.BlockHeaderVerification() + k.SetBlockHeaderVerification(ctx, bhv) - res, err := k.VerificationFlags(wctx, &types.QueryVerificationFlagsRequest{}) + res, err := k.HeaderEnabledChains(wctx, &types.QueryHeaderEnabledChainsRequest{}) require.NoError(t, err) - require.Equal(t, vf, res.VerificationFlags) + require.Equal(t, bhv.EnabledChains, res.EnabledChains) }) } diff --git a/x/lightclient/keeper/grpc_query_verification_flags.go b/x/lightclient/keeper/grpc_query_verification_flags.go deleted file mode 100644 index 6eff4962c7..0000000000 --- a/x/lightclient/keeper/grpc_query_verification_flags.go +++ /dev/null @@ -1,22 +0,0 @@ -package keeper - -import ( - "context" - - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/zeta-chain/zetacore/x/lightclient/types" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" -) - -// VerificationFlags implements the Query/VerificationFlags gRPC method -func (k Keeper) VerificationFlags(c context.Context, req *types.QueryVerificationFlagsRequest) (*types.QueryVerificationFlagsResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "invalid request") - } - ctx := sdk.UnwrapSDKContext(c) - - val := k.GetAllVerificationFlags(ctx) - - return &types.QueryVerificationFlagsResponse{VerificationFlags: val}, nil -} diff --git a/x/lightclient/keeper/msg_server_disable_verification_flags_test.go b/x/lightclient/keeper/msg_server_disable_block_header_verification._test.go similarity index 67% rename from x/lightclient/keeper/msg_server_disable_verification_flags_test.go rename to x/lightclient/keeper/msg_server_disable_block_header_verification._test.go index 9bda2219e9..b3f8c23961 100644 --- a/x/lightclient/keeper/msg_server_disable_verification_flags_test.go +++ b/x/lightclient/keeper/msg_server_disable_block_header_verification._test.go @@ -24,28 +24,30 @@ func TestMsgServer_DisableVerificationFlags(t *testing.T) { // mock the authority keeper for authorization authorityMock := keepertest.GetLightclientAuthorityMock(t, k) - k.SetVerificationFlags(ctx, types.VerificationFlags{ - ChainId: chains.EthChain.ChainId, - Enabled: true, - }) - k.SetVerificationFlags(ctx, types.VerificationFlags{ - ChainId: chains.BscMainnetChain.ChainId, - Enabled: true, + k.SetBlockHeaderVerification(ctx, types.BlockHeaderVerification{ + EnabledChains: []types.EnabledChain{ + { + ChainId: chains.EthChain.ChainId, + Enabled: true, + }, + { + ChainId: chains.BtcMainnetChain.ChainId, + Enabled: true, + }, + }, }) // enable eth type chain keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupEmergency, true) - _, err := srv.DisableVerificationFlags(sdk.WrapSDKContext(ctx), &types.MsgDisableVerificationFlags{ + _, err := srv.DisableHeaderVerification(sdk.WrapSDKContext(ctx), &types.MsgDisableHeaderVerification{ Creator: admin, ChainIdList: []int64{chains.EthChain.ChainId, chains.BtcMainnetChain.ChainId}, }) require.NoError(t, err) - vf, found := k.GetVerificationFlags(ctx, chains.EthChain.ChainId) - require.True(t, found) - require.False(t, vf.Enabled) - vf, found = k.GetVerificationFlags(ctx, chains.BtcMainnetChain.ChainId) + bhv, found := k.GetBlockHeaderVerification(ctx) require.True(t, found) - require.False(t, vf.Enabled) + require.False(t, bhv.IsChainEnabled(chains.EthChain.ChainId)) + require.False(t, bhv.IsChainEnabled(chains.BtcMainnetChain.ChainId)) }) @@ -59,13 +61,21 @@ func TestMsgServer_DisableVerificationFlags(t *testing.T) { // mock the authority keeper for authorization authorityMock := keepertest.GetLightclientAuthorityMock(t, k) - k.SetVerificationFlags(ctx, types.VerificationFlags{ - ChainId: chains.EthChain.ChainId, - Enabled: true, + k.SetBlockHeaderVerification(ctx, types.BlockHeaderVerification{ + EnabledChains: []types.EnabledChain{ + { + ChainId: chains.EthChain.ChainId, + Enabled: true, + }, + { + ChainId: chains.BtcMainnetChain.ChainId, + Enabled: true, + }, + }, }) keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupEmergency, false) - _, err := srv.DisableVerificationFlags(sdk.WrapSDKContext(ctx), &types.MsgDisableVerificationFlags{ + _, err := srv.DisableHeaderVerification(sdk.WrapSDKContext(ctx), &types.MsgDisableHeaderVerification{ Creator: admin, ChainIdList: []int64{chains.EthChain.ChainId}, }) @@ -84,16 +94,14 @@ func TestMsgServer_DisableVerificationFlags(t *testing.T) { // enable eth type chain keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupEmergency, true) - _, err := srv.DisableVerificationFlags(sdk.WrapSDKContext(ctx), &types.MsgDisableVerificationFlags{ + _, err := srv.DisableHeaderVerification(sdk.WrapSDKContext(ctx), &types.MsgDisableHeaderVerification{ Creator: admin, ChainIdList: []int64{chains.EthChain.ChainId, chains.BtcMainnetChain.ChainId}, }) require.NoError(t, err) - vf, found := k.GetVerificationFlags(ctx, chains.EthChain.ChainId) - require.True(t, found) - require.False(t, vf.Enabled) - vf, found = k.GetVerificationFlags(ctx, chains.BtcMainnetChain.ChainId) + bhv, found := k.GetBlockHeaderVerification(ctx) require.True(t, found) - require.False(t, vf.Enabled) + require.False(t, bhv.IsChainEnabled(chains.EthChain.ChainId)) + require.False(t, bhv.IsChainEnabled(chains.BtcMainnetChain.ChainId)) }) } diff --git a/x/lightclient/keeper/msg_server_disable_verification_flags.go b/x/lightclient/keeper/msg_server_disable_block_header_verification.go similarity index 63% rename from x/lightclient/keeper/msg_server_disable_verification_flags.go rename to x/lightclient/keeper/msg_server_disable_block_header_verification.go index 97730e3d83..6c2bfd740a 100644 --- a/x/lightclient/keeper/msg_server_disable_verification_flags.go +++ b/x/lightclient/keeper/msg_server_disable_block_header_verification.go @@ -10,7 +10,7 @@ import ( // 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) { +func (k msgServer) DisableHeaderVerification(goCtx context.Context, msg *types.MsgDisableHeaderVerification) (*types.MsgDisableHeaderVerificationResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) // check permission @@ -18,13 +18,13 @@ func (k msgServer) DisableVerificationFlags(goCtx context.Context, msg *types.Ms return nil, authoritytypes.ErrUnauthorized } + bhv, _ := k.GetBlockHeaderVerification(ctx) + for _, chainID := range msg.ChainIdList { - // set the verification flags to false to disable verification - k.SetVerificationFlags(ctx, types.VerificationFlags{ - ChainId: chainID, - Enabled: false, - }) + bhv.DisableChain(chainID) } - return &types.MsgDisableVerificationFlagsResponse{}, nil + k.SetBlockHeaderVerification(ctx, bhv) + + return &types.MsgDisableHeaderVerificationResponse{}, nil } diff --git a/x/lightclient/keeper/msg_server_enable_verification_flags.go b/x/lightclient/keeper/msg_server_enable_block_header_verification.go similarity index 56% rename from x/lightclient/keeper/msg_server_enable_verification_flags.go rename to x/lightclient/keeper/msg_server_enable_block_header_verification.go index 7818f00987..ae78f803d0 100644 --- a/x/lightclient/keeper/msg_server_enable_verification_flags.go +++ b/x/lightclient/keeper/msg_server_enable_block_header_verification.go @@ -8,10 +8,10 @@ import ( "github.com/zeta-chain/zetacore/x/lightclient/types" ) -// EnableVerificationFlags enables the verification flags for the given chain IDs +// EnableHeaderVerification 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, +func (k msgServer) EnableHeaderVerification(goCtx context.Context, msg *types.MsgEnableHeaderVerification) ( + *types.MsgEnableHeaderVerificationResponse, error, ) { ctx := sdk.UnwrapSDKContext(goCtx) @@ -21,13 +21,12 @@ func (k msgServer) EnableVerificationFlags(goCtx context.Context, msg *types.Msg return nil, authoritytypes.ErrUnauthorized } + bhv, _ := k.GetBlockHeaderVerification(ctx) + for _, chainID := range msg.ChainIdList { - // set the verification flags to true to enable verification - k.SetVerificationFlags(ctx, types.VerificationFlags{ - ChainId: chainID, - Enabled: true, - }) + bhv.EnableChain(chainID) } - return &types.MsgEnableVerificationFlagsResponse{}, nil + k.SetBlockHeaderVerification(ctx, bhv) + return &types.MsgEnableHeaderVerificationResponse{}, nil } diff --git a/x/lightclient/keeper/msg_server_enable_verification_flags_test.go b/x/lightclient/keeper/msg_server_enable_block_header_verification_test.go similarity index 68% rename from x/lightclient/keeper/msg_server_enable_verification_flags_test.go rename to x/lightclient/keeper/msg_server_enable_block_header_verification_test.go index 1f5621fecd..28e4ed765e 100644 --- a/x/lightclient/keeper/msg_server_enable_verification_flags_test.go +++ b/x/lightclient/keeper/msg_server_enable_block_header_verification_test.go @@ -24,28 +24,30 @@ func TestMsgServer_EnableVerificationFlags(t *testing.T) { // mock the authority keeper for authorization authorityMock := keepertest.GetLightclientAuthorityMock(t, k) - k.SetVerificationFlags(ctx, types.VerificationFlags{ - ChainId: chains.EthChain.ChainId, - Enabled: false, - }) - k.SetVerificationFlags(ctx, types.VerificationFlags{ - ChainId: chains.BtcMainnetChain.ChainId, - Enabled: false, + k.SetBlockHeaderVerification(ctx, types.BlockHeaderVerification{ + EnabledChains: []types.EnabledChain{ + { + ChainId: chains.EthChain.ChainId, + Enabled: false, + }, + { + ChainId: chains.BtcMainnetChain.ChainId, + Enabled: false, + }, + }, }) // enable both eth and btc type chain together keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupOperational, true) - _, err := srv.EnableVerificationFlags(sdk.WrapSDKContext(ctx), &types.MsgEnableVerificationFlags{ + _, err := srv.EnableHeaderVerification(sdk.WrapSDKContext(ctx), &types.MsgEnableHeaderVerification{ Creator: admin, ChainIdList: []int64{chains.EthChain.ChainId, chains.BtcMainnetChain.ChainId}, }) require.NoError(t, err) - vf, found := k.GetVerificationFlags(ctx, chains.BtcMainnetChain.ChainId) - require.True(t, found) - require.True(t, vf.Enabled) - vf, found = k.GetVerificationFlags(ctx, chains.EthChain.ChainId) + bhv, found := k.GetBlockHeaderVerification(ctx) require.True(t, found) - require.True(t, vf.Enabled) + require.True(t, bhv.IsChainEnabled(chains.EthChain.ChainId)) + require.True(t, bhv.IsChainEnabled(chains.BtcMainnetChain.ChainId)) }) t.Run("enable verification flags even if the chain has not been set previously", func(t *testing.T) { @@ -60,17 +62,15 @@ func TestMsgServer_EnableVerificationFlags(t *testing.T) { // enable both eth and btc type chain together keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupOperational, true) - _, err := srv.EnableVerificationFlags(sdk.WrapSDKContext(ctx), &types.MsgEnableVerificationFlags{ + _, err := srv.EnableHeaderVerification(sdk.WrapSDKContext(ctx), &types.MsgEnableHeaderVerification{ Creator: admin, ChainIdList: []int64{chains.EthChain.ChainId, chains.BtcMainnetChain.ChainId}, }) require.NoError(t, err) - vf, found := k.GetVerificationFlags(ctx, chains.BtcMainnetChain.ChainId) - require.True(t, found) - require.True(t, vf.Enabled) - vf, found = k.GetVerificationFlags(ctx, chains.EthChain.ChainId) + bhv, found := k.GetBlockHeaderVerification(ctx) require.True(t, found) - require.True(t, vf.Enabled) + require.True(t, bhv.IsChainEnabled(chains.EthChain.ChainId)) + require.True(t, bhv.IsChainEnabled(chains.BtcMainnetChain.ChainId)) }) t.Run("cannot update if not authorized group", func(t *testing.T) { @@ -83,13 +83,21 @@ func TestMsgServer_EnableVerificationFlags(t *testing.T) { // mock the authority keeper for authorization authorityMock := keepertest.GetLightclientAuthorityMock(t, k) - k.SetVerificationFlags(ctx, types.VerificationFlags{ - ChainId: chains.EthChain.ChainId, - Enabled: true, + k.SetBlockHeaderVerification(ctx, types.BlockHeaderVerification{ + EnabledChains: []types.EnabledChain{ + { + ChainId: chains.EthChain.ChainId, + Enabled: false, + }, + { + ChainId: chains.BtcMainnetChain.ChainId, + Enabled: false, + }, + }, }) keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupOperational, false) - _, err := srv.EnableVerificationFlags(sdk.WrapSDKContext(ctx), &types.MsgEnableVerificationFlags{ + _, err := srv.EnableHeaderVerification(sdk.WrapSDKContext(ctx), &types.MsgEnableHeaderVerification{ Creator: admin, ChainIdList: []int64{chains.EthChain.ChainId}, }) diff --git a/x/lightclient/keeper/proof.go b/x/lightclient/keeper/proof.go index 9cfcd45828..6720bc3c7d 100644 --- a/x/lightclient/keeper/proof.go +++ b/x/lightclient/keeper/proof.go @@ -12,7 +12,7 @@ import ( // It returns the transaction bytes if the proof is valid func (k Keeper) VerifyProof(ctx sdk.Context, proof *proofs.Proof, chainID int64, blockHash string, txIndex int64) ([]byte, error) { // check verification flags are set - if err := k.CheckVerificationFlagsEnabled(ctx, chainID); err != nil { + if err := k.CheckBlockHeaderVerificationEnabled(ctx, chainID); err != nil { return nil, err } diff --git a/x/lightclient/keeper/proof_test.go b/x/lightclient/keeper/proof_test.go index 945b9b51d6..8492230467 100644 --- a/x/lightclient/keeper/proof_test.go +++ b/x/lightclient/keeper/proof_test.go @@ -17,15 +17,19 @@ func TestKeeper_VerifyProof(t *testing.T) { k, ctx, _, _ := keepertest.LightclientKeeper(t) _, err := k.VerifyProof(ctx, &proofs.Proof{}, chains.SepoliaChain.ChainId, sample.Hash().String(), 1) - require.ErrorContains(t, err, fmt.Sprintf("proof verification not enabled for,chain id: %d", chains.SepoliaChain.ChainId)) + require.ErrorContains(t, err, "proof verification is disabled for all chains") }) t.Run("should error if verification not enabled for btc chain", func(t *testing.T) { k, ctx, _, _ := keepertest.LightclientKeeper(t) - k.SetVerificationFlags(ctx, types.VerificationFlags{ - ChainId: chains.BtcMainnetChain.ChainId, - Enabled: false, + k.SetBlockHeaderVerification(ctx, types.BlockHeaderVerification{ + EnabledChains: []types.EnabledChain{ + { + ChainId: chains.BtcMainnetChain.ChainId, + Enabled: false, + }, + }, }) _, err := k.VerifyProof(ctx, &proofs.Proof{}, chains.BtcMainnetChain.ChainId, sample.Hash().String(), 1) @@ -35,9 +39,13 @@ func TestKeeper_VerifyProof(t *testing.T) { t.Run("should error if verification not enabled for evm chain", func(t *testing.T) { k, ctx, _, _ := keepertest.LightclientKeeper(t) - k.SetVerificationFlags(ctx, types.VerificationFlags{ - ChainId: chains.EthChain.ChainId, - Enabled: false, + k.SetBlockHeaderVerification(ctx, types.BlockHeaderVerification{ + EnabledChains: []types.EnabledChain{ + { + ChainId: chains.EthChain.ChainId, + Enabled: false, + }, + }, }) _, err := k.VerifyProof(ctx, &proofs.Proof{}, chains.SepoliaChain.ChainId, sample.Hash().String(), 1) require.ErrorIs(t, err, types.ErrBlockHeaderVerificationDisabled) @@ -46,29 +54,37 @@ func TestKeeper_VerifyProof(t *testing.T) { t.Run("should error if block header-based verification not supported", func(t *testing.T) { k, ctx, _, _ := keepertest.LightclientKeeper(t) - k.SetVerificationFlags(ctx, types.VerificationFlags{ - ChainId: chains.BtcMainnetChain.ChainId, - Enabled: false, - }) - k.SetVerificationFlags(ctx, types.VerificationFlags{ - ChainId: chains.EthChain.ChainId, - Enabled: false, + k.SetBlockHeaderVerification(ctx, types.BlockHeaderVerification{ + EnabledChains: []types.EnabledChain{ + { + ChainId: chains.BtcMainnetChain.ChainId, + Enabled: false, + }, + { + ChainId: chains.EthChain.ChainId, + Enabled: false, + }, + }, }) _, err := k.VerifyProof(ctx, &proofs.Proof{}, chains.ZetaPrivnetChain.ChainId, sample.Hash().String(), 1) - require.ErrorContains(t, err, fmt.Sprintf("proof verification not enabled for,chain id: %d", chains.ZetaPrivnetChain.ChainId)) + require.ErrorContains(t, err, fmt.Sprintf("proof verification is disabled for chain %d", chains.ZetaPrivnetChain.ChainId)) }) t.Run("should error if blockhash invalid", func(t *testing.T) { k, ctx, _, _ := keepertest.LightclientKeeper(t) - k.SetVerificationFlags(ctx, types.VerificationFlags{ - ChainId: chains.BtcMainnetChain.ChainId, - Enabled: true, - }) - k.SetVerificationFlags(ctx, types.VerificationFlags{ - ChainId: chains.EthChain.ChainId, - Enabled: true, + k.SetBlockHeaderVerification(ctx, types.BlockHeaderVerification{ + EnabledChains: []types.EnabledChain{ + { + ChainId: chains.BtcMainnetChain.ChainId, + Enabled: true, + }, + { + ChainId: chains.EthChain.ChainId, + Enabled: true, + }, + }, }) _, err := k.VerifyProof(ctx, &proofs.Proof{}, chains.BtcMainnetChain.ChainId, "invalid", 1) @@ -78,13 +94,17 @@ func TestKeeper_VerifyProof(t *testing.T) { t.Run("should error if block header not found", func(t *testing.T) { k, ctx, _, _ := keepertest.LightclientKeeper(t) - k.SetVerificationFlags(ctx, types.VerificationFlags{ - ChainId: chains.BtcMainnetChain.ChainId, - Enabled: true, - }) - k.SetVerificationFlags(ctx, types.VerificationFlags{ - ChainId: chains.EthChain.ChainId, - Enabled: true, + k.SetBlockHeaderVerification(ctx, types.BlockHeaderVerification{ + EnabledChains: []types.EnabledChain{ + { + ChainId: chains.BtcMainnetChain.ChainId, + Enabled: true, + }, + { + ChainId: chains.EthChain.ChainId, + Enabled: true, + }, + }, }) _, err := k.VerifyProof(ctx, &proofs.Proof{}, chains.SepoliaChain.ChainId, sample.Hash().String(), 1) @@ -96,13 +116,17 @@ func TestKeeper_VerifyProof(t *testing.T) { proof, blockHeader, blockHash, txIndex, chainID, _ := sample.Proof(t) - k.SetVerificationFlags(ctx, types.VerificationFlags{ - ChainId: chains.BtcMainnetChain.ChainId, - Enabled: true, - }) - k.SetVerificationFlags(ctx, types.VerificationFlags{ - ChainId: chains.EthChain.ChainId, - Enabled: true, + k.SetBlockHeaderVerification(ctx, types.BlockHeaderVerification{ + EnabledChains: []types.EnabledChain{ + { + ChainId: chains.BtcMainnetChain.ChainId, + Enabled: true, + }, + { + ChainId: chains.EthChain.ChainId, + Enabled: true, + }, + }, }) k.SetBlockHeader(ctx, blockHeader) @@ -117,13 +141,17 @@ func TestKeeper_VerifyProof(t *testing.T) { proof, blockHeader, blockHash, txIndex, chainID, _ := sample.Proof(t) - k.SetVerificationFlags(ctx, types.VerificationFlags{ - ChainId: chains.BtcMainnetChain.ChainId, - Enabled: true, - }) - k.SetVerificationFlags(ctx, types.VerificationFlags{ - ChainId: chains.SepoliaChain.ChainId, - Enabled: true, + k.SetBlockHeaderVerification(ctx, types.BlockHeaderVerification{ + EnabledChains: []types.EnabledChain{ + { + ChainId: chains.BtcMainnetChain.ChainId, + Enabled: true, + }, + { + ChainId: chains.SepoliaChain.ChainId, + Enabled: true, + }, + }, }) k.SetBlockHeader(ctx, blockHeader) diff --git a/x/lightclient/keeper/verification_flags.go b/x/lightclient/keeper/verification_flags.go deleted file mode 100644 index caf9372962..0000000000 --- a/x/lightclient/keeper/verification_flags.go +++ /dev/null @@ -1,60 +0,0 @@ -package keeper - -import ( - "fmt" - - cosmoserrors "cosmossdk.io/errors" - "github.com/cosmos/cosmos-sdk/store/prefix" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/zeta-chain/zetacore/x/lightclient/types" -) - -// SetVerificationFlags set the verification flags in the store. The key is the chain id -func (k Keeper) SetVerificationFlags(ctx sdk.Context, verificationFlag types.VerificationFlags) { - store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.VerificationFlagsKey)) - b := k.cdc.MustMarshal(&verificationFlag) - key := types.KeyPrefix(fmt.Sprintf("%d", verificationFlag.ChainId)) - store.Set(key, b) -} - -// GetVerificationFlags returns the verification flags -func (k Keeper) GetVerificationFlags(ctx sdk.Context, chainID int64) (verificationFlag types.VerificationFlags, found bool) { - store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.VerificationFlagsKey)) - key := types.KeyPrefix(fmt.Sprintf("%d", chainID)) - b := store.Get(key) - if b == nil { - return verificationFlag, false - } - - k.cdc.MustUnmarshal(b, &verificationFlag) - return verificationFlag, true -} - -func (k Keeper) GetAllVerificationFlags(ctx sdk.Context) (verificationFlags []types.VerificationFlags) { - store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.VerificationFlagsKey)) - iterator := sdk.KVStorePrefixIterator(store, []byte{}) - defer iterator.Close() - - for ; iterator.Valid(); iterator.Next() { - var val types.VerificationFlags - k.cdc.MustUnmarshal(iterator.Value(), &val) - verificationFlags = append(verificationFlags, val) - } - - return verificationFlags - -} - -// CheckVerificationFlagsEnabled checks for a specific chain if the verification flags are enabled -// It returns an error if the chain is not enabled or the verification flags are not for that chain -func (k Keeper) CheckVerificationFlagsEnabled(ctx sdk.Context, chainID int64) error { - verificationFlags, found := k.GetVerificationFlags(ctx, chainID) - if !found || !verificationFlags.Enabled { - return cosmoserrors.Wrapf( - types.ErrBlockHeaderVerificationDisabled, - "proof verification not enabled for,chain id: %d", - chainID, - ) - } - return nil -} diff --git a/x/lightclient/keeper/verification_flags_test.go b/x/lightclient/keeper/verification_flags_test.go deleted file mode 100644 index 784632dbbd..0000000000 --- a/x/lightclient/keeper/verification_flags_test.go +++ /dev/null @@ -1,112 +0,0 @@ -package keeper_test - -import ( - "fmt" - "testing" - - "github.com/stretchr/testify/require" - "github.com/zeta-chain/zetacore/pkg/chains" - keepertest "github.com/zeta-chain/zetacore/testutil/keeper" - "github.com/zeta-chain/zetacore/testutil/sample" - "github.com/zeta-chain/zetacore/x/lightclient/types" -) - -func TestKeeper_GetAllVerificationFlags(t *testing.T) { - t.Run("can get all verification flags", func(t *testing.T) { - k, ctx, _, _ := keepertest.LightclientKeeper(t) - - vf := sample.VerificationFlags() - - for _, v := range vf { - k.SetVerificationFlags(ctx, v) - } - - allVf := k.GetAllVerificationFlags(ctx) - require.Len(t, allVf, 2) - require.Equal(t, vf, allVf) - }) - - t.Run("return empty list when no flags are set", func(t *testing.T) { - k, ctx, _, _ := keepertest.LightclientKeeper(t) - - allVf := k.GetAllVerificationFlags(ctx) - require.Len(t, allVf, 0) - }) -} -func TestKeeper_GetVerificationFlags(t *testing.T) { - t.Run("can get and set verification flags", func(t *testing.T) { - k, ctx, _, _ := keepertest.LightclientKeeper(t) - ethChainId := chains.EthChain.ChainId - - vf, found := k.GetVerificationFlags(ctx, ethChainId) - require.False(t, found) - - k.SetVerificationFlags(ctx, types.VerificationFlags{ - ChainId: ethChainId, - Enabled: true, - }) - vf, found = k.GetVerificationFlags(ctx, ethChainId) - require.True(t, found) - require.True(t, vf.Enabled) - }) -} - -func TestKeeper_CheckVerificationFlagsEnabled(t *testing.T) { - t.Run("can check verification flags with ethereum enabled", func(t *testing.T) { - k, ctx, _, _ := keepertest.LightclientKeeper(t) - k.SetVerificationFlags(ctx, types.VerificationFlags{ - ChainId: chains.EthChain.ChainId, - Enabled: true, - }) - - err := k.CheckVerificationFlagsEnabled(ctx, chains.EthChain.ChainId) - require.NoError(t, err) - - err = k.CheckVerificationFlagsEnabled(ctx, chains.BtcMainnetChain.ChainId) - require.Error(t, err) - require.ErrorContains(t, err, fmt.Sprintf("proof verification not enabled for,chain id: %d", chains.BtcMainnetChain.ChainId)) - - err = k.CheckVerificationFlagsEnabled(ctx, 1000) - require.Error(t, err) - require.ErrorContains(t, err, fmt.Sprintf("proof verification not enabled for,chain id: %d", 1000)) - }) - - t.Run("can check verification flags with bitcoin enabled", func(t *testing.T) { - k, ctx, _, _ := keepertest.LightclientKeeper(t) - k.SetVerificationFlags(ctx, types.VerificationFlags{ - ChainId: chains.BtcMainnetChain.ChainId, - Enabled: true, - }) - - err := k.CheckVerificationFlagsEnabled(ctx, chains.EthChain.ChainId) - require.Error(t, err) - require.ErrorContains(t, err, fmt.Sprintf("proof verification not enabled for,chain id: %d", chains.EthChain.ChainId)) - - err = k.CheckVerificationFlagsEnabled(ctx, chains.BtcMainnetChain.ChainId) - require.NoError(t, err) - - err = k.CheckVerificationFlagsEnabled(ctx, 1000) - require.Error(t, err) - require.ErrorContains(t, err, fmt.Sprintf("proof verification not enabled for,chain id: %d", 1000)) - }) - - t.Run("check returns false if flag is not set", func(t *testing.T) { - k, ctx, _, _ := keepertest.LightclientKeeper(t) - err := k.CheckVerificationFlagsEnabled(ctx, chains.EthChain.ChainId) - require.ErrorContains(t, err, fmt.Sprintf("proof verification not enabled for,chain id: %d", chains.EthChain.ChainId)) - - err = k.CheckVerificationFlagsEnabled(ctx, chains.BtcMainnetChain.ChainId) - require.ErrorContains(t, err, fmt.Sprintf("proof verification not enabled for,chain id: %d", chains.BtcMainnetChain.ChainId)) - }) - - t.Run("check returns false is flag is disabled", func(t *testing.T) { - k, ctx, _, _ := keepertest.LightclientKeeper(t) - k.SetVerificationFlags(ctx, types.VerificationFlags{ - ChainId: chains.EthChain.ChainId, - Enabled: false, - }) - - err := k.CheckVerificationFlagsEnabled(ctx, chains.EthChain.ChainId) - require.ErrorContains(t, err, fmt.Sprintf("proof verification not enabled for,chain id: %d", chains.EthChain.ChainId)) - }) -} diff --git a/x/lightclient/types/block_header_verification.go b/x/lightclient/types/block_header_verification.go new file mode 100644 index 0000000000..f8359ba297 --- /dev/null +++ b/x/lightclient/types/block_header_verification.go @@ -0,0 +1,59 @@ +package types + +func (b *BlockHeaderVerification) EnableChain(chainID int64) { + found := false + for i, enabledChain := range b.EnabledChains { + if enabledChain.ChainId == chainID { + b.EnabledChains[i].Enabled = true + found = true + } + } + if !found { + b.EnabledChains = append(b.EnabledChains, EnabledChain{ + ChainId: chainID, + Enabled: true, + }) + } +} + +func (b *BlockHeaderVerification) DisableChain(chainID int64) { + found := false + for i, v := range b.EnabledChains { + if v.ChainId == chainID { + b.EnabledChains[i].Enabled = false + found = true + } + } + if !found { + b.EnabledChains = append(b.EnabledChains, EnabledChain{ + ChainId: chainID, + Enabled: false, + }) + } +} + +func (b *BlockHeaderVerification) IsChainEnabled(chainID int64) bool { + for _, v := range b.EnabledChains { + if v.ChainId == chainID { + return v.Enabled + } + } + return false +} + +func (b *BlockHeaderVerification) GetEnabledChainIDList() []int64 { + var enabledChains []int64 + for _, v := range b.EnabledChains { + if v.Enabled { + enabledChains = append(enabledChains, v.ChainId) + } + } + return enabledChains +} + +func (b *BlockHeaderVerification) GetVerificationFlags() []EnabledChain { + if b == nil || b.EnabledChains == nil { + return []EnabledChain{} + } + return b.EnabledChains +} diff --git a/x/lightclient/types/block_header_verification_test.go b/x/lightclient/types/block_header_verification_test.go new file mode 100644 index 0000000000..f8543306c8 --- /dev/null +++ b/x/lightclient/types/block_header_verification_test.go @@ -0,0 +1,17 @@ +package types_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + "github.com/zeta-chain/zetacore/pkg/chains" + "github.com/zeta-chain/zetacore/testutil/sample" +) + +func TestBlockHeaderVerification_EnableChain(t *testing.T) { + t.Run("should enable chain", func(t *testing.T) { + bhv := sample.BlockHeaderVerification() + bhv.EnableChain(chains.BscMainnetChain.ChainId) + require.True(t, bhv.IsChainEnabled(chains.BscMainnetChain.ChainId)) + }) +} diff --git a/x/lightclient/types/codec.go b/x/lightclient/types/codec.go index b80f2c778b..46d1f45cd6 100644 --- a/x/lightclient/types/codec.go +++ b/x/lightclient/types/codec.go @@ -8,16 +8,16 @@ import ( ) func RegisterCodec(cdc *codec.LegacyAmino) { - cdc.RegisterConcrete(&MsgEnableVerificationFlags{}, "lightclient/EnableVerificationFlags", nil) - cdc.RegisterConcrete(&MsgDisableVerificationFlags{}, "lightclient/DisableVerificationFlags", nil) + cdc.RegisterConcrete(&MsgEnableHeaderVerification{}, "lightclient/EnableHeaderVerification", nil) + cdc.RegisterConcrete(&MsgDisableHeaderVerification{}, "lightclient/DisableHeaderVerification", nil) } func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { registry.RegisterImplementations((*sdk.Msg)(nil), - &MsgEnableVerificationFlags{}, + &MsgEnableHeaderVerification{}, ) registry.RegisterImplementations((*sdk.Msg)(nil), - &MsgDisableVerificationFlags{}, + &MsgDisableHeaderVerification{}, ) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) diff --git a/x/lightclient/types/genesis.go b/x/lightclient/types/genesis.go index d9325ab546..74be724903 100644 --- a/x/lightclient/types/genesis.go +++ b/x/lightclient/types/genesis.go @@ -9,9 +9,9 @@ import ( // DefaultGenesis returns the default lightclient genesis state func DefaultGenesis() *GenesisState { return &GenesisState{ - BlockHeaders: []proofs.BlockHeader{}, - ChainStates: []ChainState{}, - VerificationFlags: []VerificationFlags{}, + BlockHeaders: []proofs.BlockHeader{}, + ChainStates: []ChainState{}, + BlockHeaderVerification: BlockHeaderVerification{}, } } diff --git a/x/lightclient/types/genesis.pb.go b/x/lightclient/types/genesis.pb.go index 8ad8850330..87ab1d7f4e 100644 --- a/x/lightclient/types/genesis.pb.go +++ b/x/lightclient/types/genesis.pb.go @@ -27,9 +27,9 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // GenesisState defines the lightclient module's genesis state. type GenesisState struct { - BlockHeaders []proofs.BlockHeader `protobuf:"bytes,1,rep,name=block_headers,json=blockHeaders,proto3" json:"block_headers"` - ChainStates []ChainState `protobuf:"bytes,2,rep,name=chain_states,json=chainStates,proto3" json:"chain_states"` - VerificationFlags []VerificationFlags `protobuf:"bytes,3,rep,name=verification_flags,json=verificationFlags,proto3" json:"verification_flags"` + BlockHeaders []proofs.BlockHeader `protobuf:"bytes,1,rep,name=block_headers,json=blockHeaders,proto3" json:"block_headers"` + ChainStates []ChainState `protobuf:"bytes,2,rep,name=chain_states,json=chainStates,proto3" json:"chain_states"` + BlockHeaderVerification BlockHeaderVerification `protobuf:"bytes,3,opt,name=block_header_verification,json=blockHeaderVerification,proto3" json:"block_header_verification"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -79,11 +79,11 @@ func (m *GenesisState) GetChainStates() []ChainState { return nil } -func (m *GenesisState) GetVerificationFlags() []VerificationFlags { +func (m *GenesisState) GetBlockHeaderVerification() BlockHeaderVerification { if m != nil { - return m.VerificationFlags + return m.BlockHeaderVerification } - return nil + return BlockHeaderVerification{} } func init() { @@ -93,7 +93,7 @@ func init() { func init() { proto.RegisterFile("lightclient/genesis.proto", fileDescriptor_645b5300b371cd43) } var fileDescriptor_645b5300b371cd43 = []byte{ - // 312 bytes of a gzipped FileDescriptorProto + // 317 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xcc, 0xc9, 0x4c, 0xcf, 0x28, 0x49, 0xce, 0xc9, 0x4c, 0xcd, 0x2b, 0xd1, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0xab, 0x4a, 0x2d, 0x49, 0x4c, 0xce, 0x48, 0xcc, 0xcc, @@ -101,19 +101,19 @@ var fileDescriptor_645b5300b371cd43 = []byte{ 0x95, 0xea, 0x83, 0x58, 0x10, 0x5d, 0x52, 0xb2, 0xc8, 0x06, 0x82, 0x75, 0xc7, 0x17, 0x97, 0x24, 0x96, 0xa4, 0x42, 0xa5, 0x55, 0x90, 0xa5, 0xcb, 0x52, 0x8b, 0x32, 0xd3, 0x32, 0x93, 0x13, 0x4b, 0x32, 0xf3, 0xf3, 0xe2, 0xd3, 0x72, 0x12, 0xd3, 0xa1, 0x56, 0x4b, 0x89, 0x17, 0x64, 0xa7, 0xeb, - 0x17, 0x14, 0xe5, 0xe7, 0xa7, 0x15, 0x43, 0x29, 0x88, 0x84, 0x52, 0x37, 0x13, 0x17, 0x8f, 0x3b, - 0xc4, 0x95, 0xc1, 0x20, 0x53, 0x85, 0xec, 0xb8, 0x78, 0x93, 0x72, 0xf2, 0x93, 0xb3, 0xe3, 0x33, - 0x52, 0x13, 0x53, 0x52, 0x8b, 0x8a, 0x25, 0x18, 0x15, 0x98, 0x35, 0xb8, 0x8d, 0x84, 0xf5, 0xa0, - 0xda, 0x9c, 0x40, 0x92, 0x1e, 0x60, 0x39, 0x27, 0x96, 0x13, 0xf7, 0xe4, 0x19, 0x82, 0x78, 0x92, - 0x10, 0x42, 0xc5, 0x42, 0xc1, 0x5c, 0x3c, 0x48, 0x8e, 0x2c, 0x96, 0x60, 0x02, 0x6b, 0xd7, 0xd2, - 0xc3, 0xef, 0x77, 0x3d, 0x67, 0x90, 0x14, 0xd8, 0x05, 0x50, 0x53, 0xb9, 0x93, 0xe1, 0x22, 0xc5, - 0x42, 0x69, 0x5c, 0x42, 0x98, 0x5e, 0x93, 0x60, 0x06, 0x1b, 0x6d, 0x48, 0xc8, 0xe8, 0x30, 0x24, - 0x9d, 0x6e, 0x20, 0x8d, 0x50, 0x1b, 0x04, 0xcb, 0x30, 0x24, 0x7c, 0x4e, 0x3c, 0x92, 0x63, 0xbc, - 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, - 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0xca, 0x28, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, - 0x57, 0x1f, 0x64, 0x8b, 0x2e, 0xd8, 0x42, 0x7d, 0x98, 0x85, 0xfa, 0x15, 0xfa, 0xc8, 0xf1, 0x50, - 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, 0x0e, 0x62, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, - 0xac, 0xc7, 0x30, 0xaf, 0x13, 0x02, 0x00, 0x00, + 0x17, 0x14, 0xe5, 0xe7, 0xa7, 0x15, 0x43, 0x29, 0x88, 0x84, 0xd2, 0x3c, 0x26, 0x2e, 0x1e, 0x77, + 0x88, 0x2b, 0x83, 0x41, 0xa6, 0x0a, 0xd9, 0x71, 0xf1, 0x26, 0xe5, 0xe4, 0x27, 0x67, 0xc7, 0x67, + 0xa4, 0x26, 0xa6, 0xa4, 0x16, 0x15, 0x4b, 0x30, 0x2a, 0x30, 0x6b, 0x70, 0x1b, 0x09, 0xeb, 0x41, + 0xb5, 0x39, 0x81, 0x24, 0x3d, 0xc0, 0x72, 0x4e, 0x2c, 0x27, 0xee, 0xc9, 0x33, 0x04, 0xf1, 0x24, + 0x21, 0x84, 0x8a, 0x85, 0x82, 0xb9, 0x78, 0x90, 0x1c, 0x59, 0x2c, 0xc1, 0x04, 0xd6, 0xae, 0xa5, + 0x87, 0xdf, 0xef, 0x7a, 0xce, 0x20, 0x29, 0xb0, 0x0b, 0xa0, 0xa6, 0x72, 0x27, 0xc3, 0x45, 0x8a, + 0x85, 0x2a, 0xb9, 0x24, 0x91, 0x1d, 0x15, 0x8f, 0xec, 0x4f, 0x09, 0x66, 0x05, 0x46, 0x0d, 0x6e, + 0x23, 0x73, 0x42, 0x36, 0x20, 0x39, 0x3c, 0x0c, 0x49, 0x3b, 0xd4, 0x3a, 0xf1, 0x24, 0x1c, 0xd2, + 0x3e, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, 0x1c, 0xe3, 0x84, 0xc7, + 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, 0x10, 0x65, 0x94, 0x9e, 0x59, 0x92, + 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0x0f, 0xb2, 0x51, 0x17, 0x6c, 0xb9, 0x3e, 0xcc, 0x72, + 0xfd, 0x0a, 0x7d, 0xe4, 0xa8, 0x29, 0xa9, 0x2c, 0x48, 0x2d, 0x4e, 0x62, 0x03, 0x87, 0xba, 0x31, + 0x20, 0x00, 0x00, 0xff, 0xff, 0x30, 0x00, 0x9e, 0x2c, 0x26, 0x02, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -136,20 +136,16 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.VerificationFlags) > 0 { - for iNdEx := len(m.VerificationFlags) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.VerificationFlags[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a + { + size, err := m.BlockHeaderVerification.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0x1a if len(m.ChainStates) > 0 { for iNdEx := len(m.ChainStates) - 1; iNdEx >= 0; iNdEx-- { { @@ -210,12 +206,8 @@ func (m *GenesisState) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } - if len(m.VerificationFlags) > 0 { - for _, e := range m.VerificationFlags { - l = e.Size() - n += 1 + l + sovGenesis(uint64(l)) - } - } + l = m.BlockHeaderVerification.Size() + n += 1 + l + sovGenesis(uint64(l)) return n } @@ -324,7 +316,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field VerificationFlags", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field BlockHeaderVerification", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -351,8 +343,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.VerificationFlags = append(m.VerificationFlags, VerificationFlags{}) - if err := m.VerificationFlags[len(m.VerificationFlags)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.BlockHeaderVerification.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/x/lightclient/types/genesis_test.go b/x/lightclient/types/genesis_test.go index 004b8dc022..3e5e2cf7d7 100644 --- a/x/lightclient/types/genesis_test.go +++ b/x/lightclient/types/genesis_test.go @@ -22,7 +22,7 @@ func TestGenesisState_Validate(t *testing.T) { { desc: "valid genesis state", genState: &types.GenesisState{ - VerificationFlags: sample.VerificationFlags(), + BlockHeaderVerification: sample.BlockHeaderVerification(), BlockHeaders: []proofs.BlockHeader{ sample.BlockHeader(sample.Hash().Bytes()), sample.BlockHeader(sample.Hash().Bytes()), diff --git a/x/lightclient/types/message_disable_verification_flags.go b/x/lightclient/types/message_disable_verification_flags.go index 5ac004ad5c..90779b53dd 100644 --- a/x/lightclient/types/message_disable_verification_flags.go +++ b/x/lightclient/types/message_disable_verification_flags.go @@ -8,28 +8,28 @@ import ( ) const ( - TypeMsgDisableVerificationFlags = "disable_verification_flags" + TypeMsgDisableHeaderVerification = "disable_header_verification" ) -var _ sdk.Msg = &MsgDisableVerificationFlags{} +var _ sdk.Msg = &MsgDisableHeaderVerification{} -func NewMsgDisableVerificationFlags(creator string, chainIDs []int64) *MsgDisableVerificationFlags { - return &MsgDisableVerificationFlags{ +func NewMsgDisableHeaderVerification(creator string, chainIDs []int64) *MsgDisableHeaderVerification { + return &MsgDisableHeaderVerification{ Creator: creator, ChainIdList: chainIDs, } } -func (msg *MsgDisableVerificationFlags) Route() string { +func (msg *MsgDisableHeaderVerification) Route() string { return RouterKey } -func (msg *MsgDisableVerificationFlags) Type() string { - return TypeMsgDisableVerificationFlags +func (msg *MsgDisableHeaderVerification) Type() string { + return TypeMsgDisableHeaderVerification } -func (msg *MsgDisableVerificationFlags) GetSigners() []sdk.AccAddress { +func (msg *MsgDisableHeaderVerification) GetSigners() []sdk.AccAddress { creator, err := sdk.AccAddressFromBech32(msg.Creator) if err != nil { panic(err) @@ -37,12 +37,12 @@ func (msg *MsgDisableVerificationFlags) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{creator} } -func (msg *MsgDisableVerificationFlags) GetSignBytes() []byte { +func (msg *MsgDisableHeaderVerification) GetSignBytes() []byte { bz := ModuleCdc.MustMarshalJSON(msg) return sdk.MustSortJSON(bz) } -func (msg *MsgDisableVerificationFlags) ValidateBasic() error { +func (msg *MsgDisableHeaderVerification) ValidateBasic() error { if _, err := sdk.AccAddressFromBech32(msg.Creator); err != nil { return cosmoserrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) } diff --git a/x/lightclient/types/message_disable_verification_flags_test.go b/x/lightclient/types/message_disable_verification_flags_test.go index 6d4231c9cc..bc9fc16910 100644 --- a/x/lightclient/types/message_disable_verification_flags_test.go +++ b/x/lightclient/types/message_disable_verification_flags_test.go @@ -12,15 +12,15 @@ import ( "github.com/zeta-chain/zetacore/x/lightclient/types" ) -func TestMsgDisableVerificationFlags_ValidateBasic(t *testing.T) { +func TestMsgDisableHeaderVerification_ValidateBasic(t *testing.T) { tests := []struct { name string - msg types.MsgDisableVerificationFlags + msg types.MsgDisableHeaderVerification err require.ErrorAssertionFunc }{ { name: "invalid address", - msg: types.MsgDisableVerificationFlags{ + msg: types.MsgDisableHeaderVerification{ Creator: "invalid_address", }, err: func(t require.TestingT, err error, i ...interface{}) { @@ -29,7 +29,7 @@ func TestMsgDisableVerificationFlags_ValidateBasic(t *testing.T) { }, { name: "empty chain id list", - msg: types.MsgDisableVerificationFlags{ + msg: types.MsgDisableHeaderVerification{ Creator: sample.AccAddress(), ChainIdList: []int64{}, }, @@ -40,7 +40,7 @@ func TestMsgDisableVerificationFlags_ValidateBasic(t *testing.T) { }, { name: "chain id list is too long", - msg: types.MsgDisableVerificationFlags{ + msg: types.MsgDisableHeaderVerification{ Creator: sample.AccAddress(), ChainIdList: make([]int64, 200), }, @@ -51,7 +51,7 @@ func TestMsgDisableVerificationFlags_ValidateBasic(t *testing.T) { }, { name: "invalid chain id", - msg: types.MsgDisableVerificationFlags{ + msg: types.MsgDisableHeaderVerification{ Creator: sample.AccAddress(), ChainIdList: []int64{chains.ZetaPrivnetChain.ChainId}, }, @@ -62,7 +62,7 @@ func TestMsgDisableVerificationFlags_ValidateBasic(t *testing.T) { }, { name: "valid address", - msg: types.MsgDisableVerificationFlags{ + msg: types.MsgDisableHeaderVerification{ Creator: sample.AccAddress(), ChainIdList: []int64{chains.EthChain.ChainId}, }, @@ -77,16 +77,16 @@ func TestMsgDisableVerificationFlags_ValidateBasic(t *testing.T) { } } -func TestMsgDisableVerificationFlags_GetSigners(t *testing.T) { +func TestMsgDisableHeaderVerification_GetSigners(t *testing.T) { signer := sample.AccAddress() tests := []struct { name string - msg *types.MsgEnableVerificationFlags + msg *types.MsgEnableHeaderVerification panics bool }{ { name: "valid signer", - msg: types.NewMsgEnableVerificationFlags( + msg: types.NewMsgEnableHeaderVerification( signer, []int64{chains.EthChain.ChainId, chains.BtcMainnetChain.ChainId}, ), @@ -94,7 +94,7 @@ func TestMsgDisableVerificationFlags_GetSigners(t *testing.T) { }, { name: "invalid signer", - msg: types.NewMsgEnableVerificationFlags( + msg: types.NewMsgEnableHeaderVerification( "invalid", []int64{chains.EthChain.ChainId, chains.BtcMainnetChain.ChainId}, ), @@ -116,22 +116,22 @@ func TestMsgDisableVerificationFlags_GetSigners(t *testing.T) { } } -func TestMsgDisableVerificationFlags_Type(t *testing.T) { - msg := types.MsgDisableVerificationFlags{ +func TestMsgDisableHeaderVerification_Type(t *testing.T) { + msg := types.MsgDisableHeaderVerification{ Creator: sample.AccAddress(), } - require.Equal(t, types.TypeMsgDisableVerificationFlags, msg.Type()) + require.Equal(t, types.TypeMsgDisableHeaderVerification, msg.Type()) } -func TestMsgDisableVerificationFlags_Route(t *testing.T) { - msg := types.MsgEnableVerificationFlags{ +func TestMsgDisableHeaderVerification_Route(t *testing.T) { + msg := types.MsgEnableHeaderVerification{ Creator: sample.AccAddress(), } require.Equal(t, types.RouterKey, msg.Route()) } -func TestMsgDisableVerificationFlags_GetSignBytes(t *testing.T) { - msg := types.MsgEnableVerificationFlags{ +func TestMsgDisableHeaderVerification_GetSignBytes(t *testing.T) { + msg := types.MsgEnableHeaderVerification{ Creator: sample.AccAddress(), } require.NotPanics(t, func() { diff --git a/x/lightclient/types/message_enable_verification_flags.go b/x/lightclient/types/message_enable_verification_flags.go index 6d517ebd9d..3e41a0c4fc 100644 --- a/x/lightclient/types/message_enable_verification_flags.go +++ b/x/lightclient/types/message_enable_verification_flags.go @@ -8,27 +8,27 @@ import ( ) const ( - TypeMsgEnableVerificationFlags = "enable_verification_flags" + TypeMsgEnableHeaderVerification = "enable_header_verification" ) -var _ sdk.Msg = &MsgEnableVerificationFlags{} +var _ sdk.Msg = &MsgEnableHeaderVerification{} -func NewMsgEnableVerificationFlags(creator string, chainIDs []int64) *MsgEnableVerificationFlags { - return &MsgEnableVerificationFlags{ +func NewMsgEnableHeaderVerification(creator string, chainIDs []int64) *MsgEnableHeaderVerification { + return &MsgEnableHeaderVerification{ Creator: creator, ChainIdList: chainIDs, } } -func (msg *MsgEnableVerificationFlags) Route() string { +func (msg *MsgEnableHeaderVerification) Route() string { return RouterKey } -func (msg *MsgEnableVerificationFlags) Type() string { - return TypeMsgEnableVerificationFlags +func (msg *MsgEnableHeaderVerification) Type() string { + return TypeMsgEnableHeaderVerification } -func (msg *MsgEnableVerificationFlags) GetSigners() []sdk.AccAddress { +func (msg *MsgEnableHeaderVerification) GetSigners() []sdk.AccAddress { creator, err := sdk.AccAddressFromBech32(msg.Creator) if err != nil { panic(err) @@ -36,12 +36,12 @@ func (msg *MsgEnableVerificationFlags) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{creator} } -func (msg *MsgEnableVerificationFlags) GetSignBytes() []byte { +func (msg *MsgEnableHeaderVerification) GetSignBytes() []byte { bz := ModuleCdc.MustMarshalJSON(msg) return sdk.MustSortJSON(bz) } -func (msg *MsgEnableVerificationFlags) ValidateBasic() error { +func (msg *MsgEnableHeaderVerification) ValidateBasic() error { if _, err := sdk.AccAddressFromBech32(msg.Creator); err != nil { return cosmoserrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) } diff --git a/x/lightclient/types/message_enable_verification_flags_test.go b/x/lightclient/types/message_enable_verification_flags_test.go index fc8e75a5c7..0f00adc989 100644 --- a/x/lightclient/types/message_enable_verification_flags_test.go +++ b/x/lightclient/types/message_enable_verification_flags_test.go @@ -12,15 +12,15 @@ import ( "github.com/zeta-chain/zetacore/x/lightclient/types" ) -func TestMsgEnableVerificationFlags_ValidateBasic(t *testing.T) { +func TestMsgEnableHeaderVerification_ValidateBasic(t *testing.T) { tests := []struct { name string - msg types.MsgEnableVerificationFlags + msg types.MsgEnableHeaderVerification err require.ErrorAssertionFunc }{ { name: "invalid address", - msg: types.MsgEnableVerificationFlags{ + msg: types.MsgEnableHeaderVerification{ Creator: "invalid_address", }, err: func(t require.TestingT, err error, i ...interface{}) { @@ -29,7 +29,7 @@ func TestMsgEnableVerificationFlags_ValidateBasic(t *testing.T) { }, { name: "empty chain id list", - msg: types.MsgEnableVerificationFlags{ + msg: types.MsgEnableHeaderVerification{ Creator: sample.AccAddress(), ChainIdList: []int64{}, }, @@ -40,7 +40,7 @@ func TestMsgEnableVerificationFlags_ValidateBasic(t *testing.T) { }, { name: "chain id list is too long", - msg: types.MsgEnableVerificationFlags{ + msg: types.MsgEnableHeaderVerification{ Creator: sample.AccAddress(), ChainIdList: make([]int64, 200), }, @@ -51,7 +51,7 @@ func TestMsgEnableVerificationFlags_ValidateBasic(t *testing.T) { }, { name: "invalid chain id", - msg: types.MsgEnableVerificationFlags{ + msg: types.MsgEnableHeaderVerification{ Creator: sample.AccAddress(), ChainIdList: []int64{chains.ZetaPrivnetChain.ChainId}, }, @@ -62,7 +62,7 @@ func TestMsgEnableVerificationFlags_ValidateBasic(t *testing.T) { }, { name: "valid address", - msg: types.MsgEnableVerificationFlags{ + msg: types.MsgEnableHeaderVerification{ Creator: sample.AccAddress(), ChainIdList: []int64{chains.EthChain.ChainId}, }, @@ -77,16 +77,16 @@ func TestMsgEnableVerificationFlags_ValidateBasic(t *testing.T) { } } -func TestMsgEnableVerificationFlags_GetSigners(t *testing.T) { +func TestMsgEnableHeaderVerification_GetSigners(t *testing.T) { signer := sample.AccAddress() tests := []struct { name string - msg *types.MsgEnableVerificationFlags + msg *types.MsgEnableHeaderVerification panics bool }{ { name: "valid signer", - msg: types.NewMsgEnableVerificationFlags( + msg: types.NewMsgEnableHeaderVerification( signer, []int64{chains.EthChain.ChainId, chains.BtcMainnetChain.ChainId}, ), @@ -94,7 +94,7 @@ func TestMsgEnableVerificationFlags_GetSigners(t *testing.T) { }, { name: "invalid signer", - msg: types.NewMsgEnableVerificationFlags( + msg: types.NewMsgEnableHeaderVerification( "invalid", []int64{chains.EthChain.ChainId, chains.BtcMainnetChain.ChainId}, ), @@ -116,22 +116,22 @@ func TestMsgEnableVerificationFlags_GetSigners(t *testing.T) { } } -func TestMsgEnableVerificationFlags_Type(t *testing.T) { - msg := types.MsgEnableVerificationFlags{ +func TestMsgEnableHeaderVerification_Type(t *testing.T) { + msg := types.MsgEnableHeaderVerification{ Creator: sample.AccAddress(), } - require.Equal(t, types.TypeMsgEnableVerificationFlags, msg.Type()) + require.Equal(t, types.TypeMsgEnableHeaderVerification, msg.Type()) } -func TestMsgEnableVerificationFlags_Route(t *testing.T) { - msg := types.MsgEnableVerificationFlags{ +func TestMsgEnableHeaderVerification_Route(t *testing.T) { + msg := types.MsgEnableHeaderVerification{ Creator: sample.AccAddress(), } require.Equal(t, types.RouterKey, msg.Route()) } -func TestMsgEnableVerificationFlags_GetSignBytes(t *testing.T) { - msg := types.MsgEnableVerificationFlags{ +func TestMsgEnableHeaderVerification_GetSignBytes(t *testing.T) { + msg := types.MsgEnableHeaderVerification{ Creator: sample.AccAddress(), } require.NotPanics(t, func() { diff --git a/x/lightclient/types/query.pb.go b/x/lightclient/types/query.pb.go index c60a481d0a..47ad733970 100644 --- a/x/lightclient/types/query.pb.go +++ b/x/lightclient/types/query.pb.go @@ -520,21 +520,21 @@ func (m *QueryProveResponse) GetValid() bool { return false } -type QueryVerificationFlagsRequest struct { +type QueryHeaderEnabledChainsRequest struct { } -func (m *QueryVerificationFlagsRequest) Reset() { *m = QueryVerificationFlagsRequest{} } -func (m *QueryVerificationFlagsRequest) String() string { return proto.CompactTextString(m) } -func (*QueryVerificationFlagsRequest) ProtoMessage() {} -func (*QueryVerificationFlagsRequest) Descriptor() ([]byte, []int) { +func (m *QueryHeaderEnabledChainsRequest) Reset() { *m = QueryHeaderEnabledChainsRequest{} } +func (m *QueryHeaderEnabledChainsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryHeaderEnabledChainsRequest) ProtoMessage() {} +func (*QueryHeaderEnabledChainsRequest) Descriptor() ([]byte, []int) { return fileDescriptor_03e46747c4ffba77, []int{10} } -func (m *QueryVerificationFlagsRequest) XXX_Unmarshal(b []byte) error { +func (m *QueryHeaderEnabledChainsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryVerificationFlagsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryHeaderEnabledChainsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryVerificationFlagsRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryHeaderEnabledChainsRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -544,34 +544,34 @@ func (m *QueryVerificationFlagsRequest) XXX_Marshal(b []byte, deterministic bool return b[:n], nil } } -func (m *QueryVerificationFlagsRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryVerificationFlagsRequest.Merge(m, src) +func (m *QueryHeaderEnabledChainsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryHeaderEnabledChainsRequest.Merge(m, src) } -func (m *QueryVerificationFlagsRequest) XXX_Size() int { +func (m *QueryHeaderEnabledChainsRequest) XXX_Size() int { return m.Size() } -func (m *QueryVerificationFlagsRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryVerificationFlagsRequest.DiscardUnknown(m) +func (m *QueryHeaderEnabledChainsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryHeaderEnabledChainsRequest.DiscardUnknown(m) } -var xxx_messageInfo_QueryVerificationFlagsRequest proto.InternalMessageInfo +var xxx_messageInfo_QueryHeaderEnabledChainsRequest proto.InternalMessageInfo -type QueryVerificationFlagsResponse struct { - VerificationFlags []VerificationFlags `protobuf:"bytes,1,rep,name=verification_flags,json=verificationFlags,proto3" json:"verification_flags"` +type QueryHeaderEnabledChainsResponse struct { + EnabledChains []EnabledChain `protobuf:"bytes,1,rep,name=enabled_chains,json=enabledChains,proto3" json:"enabled_chains"` } -func (m *QueryVerificationFlagsResponse) Reset() { *m = QueryVerificationFlagsResponse{} } -func (m *QueryVerificationFlagsResponse) String() string { return proto.CompactTextString(m) } -func (*QueryVerificationFlagsResponse) ProtoMessage() {} -func (*QueryVerificationFlagsResponse) Descriptor() ([]byte, []int) { +func (m *QueryHeaderEnabledChainsResponse) Reset() { *m = QueryHeaderEnabledChainsResponse{} } +func (m *QueryHeaderEnabledChainsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryHeaderEnabledChainsResponse) ProtoMessage() {} +func (*QueryHeaderEnabledChainsResponse) Descriptor() ([]byte, []int) { return fileDescriptor_03e46747c4ffba77, []int{11} } -func (m *QueryVerificationFlagsResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryHeaderEnabledChainsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryVerificationFlagsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryHeaderEnabledChainsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryVerificationFlagsResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryHeaderEnabledChainsResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -581,21 +581,21 @@ func (m *QueryVerificationFlagsResponse) XXX_Marshal(b []byte, deterministic boo return b[:n], nil } } -func (m *QueryVerificationFlagsResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryVerificationFlagsResponse.Merge(m, src) +func (m *QueryHeaderEnabledChainsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryHeaderEnabledChainsResponse.Merge(m, src) } -func (m *QueryVerificationFlagsResponse) XXX_Size() int { +func (m *QueryHeaderEnabledChainsResponse) XXX_Size() int { return m.Size() } -func (m *QueryVerificationFlagsResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryVerificationFlagsResponse.DiscardUnknown(m) +func (m *QueryHeaderEnabledChainsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryHeaderEnabledChainsResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryVerificationFlagsResponse proto.InternalMessageInfo +var xxx_messageInfo_QueryHeaderEnabledChainsResponse proto.InternalMessageInfo -func (m *QueryVerificationFlagsResponse) GetVerificationFlags() []VerificationFlags { +func (m *QueryHeaderEnabledChainsResponse) GetEnabledChains() []EnabledChain { if m != nil { - return m.VerificationFlags + return m.EnabledChains } return nil } @@ -611,67 +611,68 @@ func init() { proto.RegisterType((*QueryGetChainStateResponse)(nil), "zetachain.zetacore.lightclient.QueryGetChainStateResponse") proto.RegisterType((*QueryProveRequest)(nil), "zetachain.zetacore.lightclient.QueryProveRequest") proto.RegisterType((*QueryProveResponse)(nil), "zetachain.zetacore.lightclient.QueryProveResponse") - proto.RegisterType((*QueryVerificationFlagsRequest)(nil), "zetachain.zetacore.lightclient.QueryVerificationFlagsRequest") - proto.RegisterType((*QueryVerificationFlagsResponse)(nil), "zetachain.zetacore.lightclient.QueryVerificationFlagsResponse") + proto.RegisterType((*QueryHeaderEnabledChainsRequest)(nil), "zetachain.zetacore.lightclient.QueryHeaderEnabledChainsRequest") + proto.RegisterType((*QueryHeaderEnabledChainsResponse)(nil), "zetachain.zetacore.lightclient.QueryHeaderEnabledChainsResponse") } func init() { proto.RegisterFile("lightclient/query.proto", fileDescriptor_03e46747c4ffba77) } var fileDescriptor_03e46747c4ffba77 = []byte{ - // 844 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x96, 0xcd, 0x4e, 0xdb, 0x4a, - 0x14, 0xc7, 0x33, 0x40, 0xf8, 0x98, 0xc0, 0x95, 0x98, 0x8b, 0x44, 0xf0, 0xbd, 0x31, 0xc8, 0x5c, - 0x2e, 0x28, 0x2d, 0x76, 0x93, 0x56, 0x48, 0x0d, 0x2a, 0x12, 0x54, 0x82, 0xa2, 0x76, 0x01, 0xae, - 0xda, 0x45, 0x37, 0x91, 0xe3, 0x4c, 0x1c, 0x0b, 0xe3, 0x31, 0xf1, 0x10, 0x85, 0x22, 0x36, 0x5d, - 0x75, 0x59, 0xa9, 0xea, 0x2b, 0xf4, 0x05, 0xba, 0x41, 0xea, 0xae, 0x8b, 0x8a, 0x25, 0x52, 0x37, - 0x5d, 0x54, 0x55, 0x05, 0x7d, 0x90, 0xca, 0xe3, 0x49, 0x3d, 0xf9, 0x2a, 0x26, 0x62, 0x15, 0x7b, - 0xc6, 0xe7, 0x9c, 0xdf, 0xff, 0x3f, 0x67, 0x8e, 0x02, 0xa7, 0x1d, 0xdb, 0xaa, 0x52, 0xd3, 0xb1, - 0xb1, 0x4b, 0xb5, 0x83, 0x43, 0x5c, 0x3b, 0x52, 0xbd, 0x1a, 0xa1, 0x04, 0xc9, 0x2f, 0x31, 0x35, - 0xcc, 0xaa, 0x61, 0xbb, 0x2a, 0x7b, 0x22, 0x35, 0xac, 0x0a, 0xdf, 0x4a, 0x59, 0x93, 0xf8, 0xfb, - 0xc4, 0xd7, 0x4a, 0x86, 0x8f, 0xc3, 0x40, 0xad, 0x9e, 0x2b, 0x61, 0x6a, 0xe4, 0x34, 0xcf, 0xb0, - 0x6c, 0xd7, 0xa0, 0x36, 0x71, 0xc3, 0x5c, 0xd2, 0x94, 0x45, 0x2c, 0xc2, 0x1e, 0xb5, 0xe0, 0x89, - 0xaf, 0xfe, 0x6b, 0x11, 0x62, 0x39, 0x58, 0x33, 0x3c, 0x5b, 0x33, 0x5c, 0x97, 0x50, 0x16, 0xe2, - 0xf3, 0xdd, 0x8c, 0x08, 0xc6, 0x38, 0x8a, 0x3e, 0x35, 0x28, 0xe6, 0xdb, 0xff, 0x89, 0xdb, 0x75, - 0x5c, 0xb3, 0x2b, 0xb6, 0xc9, 0xe2, 0x8b, 0x15, 0xc7, 0xb0, 0x9a, 0x49, 0xa6, 0xbd, 0x3d, 0x4b, - 0xf3, 0x6a, 0x84, 0x54, 0x7c, 0xfe, 0x13, 0x6e, 0x28, 0x65, 0x28, 0xed, 0x06, 0xcc, 0xeb, 0x8e, - 0xb3, 0xe1, 0x10, 0x73, 0xef, 0x11, 0x36, 0xca, 0xb8, 0xa6, 0xe3, 0x83, 0x43, 0xec, 0x53, 0xb4, - 0x09, 0x61, 0xa4, 0x21, 0x0d, 0xe6, 0xc0, 0x52, 0x2a, 0xff, 0xbf, 0x1a, 0x0a, 0x56, 0x03, 0xc1, - 0x6a, 0xe8, 0x14, 0x17, 0xac, 0xee, 0x18, 0x16, 0xe6, 0xb1, 0xba, 0x10, 0xa9, 0xbc, 0x07, 0xf0, - 0x9f, 0xae, 0x65, 0x7c, 0x8f, 0xb8, 0x3e, 0x46, 0x6b, 0x70, 0xa2, 0x14, 0x2c, 0x17, 0xab, 0x6c, - 0xdd, 0x4f, 0x83, 0xb9, 0xc1, 0xa5, 0x54, 0xfe, 0x6f, 0x95, 0xb3, 0x0a, 0x31, 0x1b, 0x43, 0x67, - 0xdf, 0x67, 0x13, 0xfa, 0x78, 0x29, 0x5a, 0xf2, 0xd1, 0x56, 0x0b, 0xe7, 0x00, 0xe3, 0x5c, 0xbc, - 0x92, 0x33, 0x2c, 0xde, 0x02, 0xba, 0xca, 0xed, 0xd8, 0xc2, 0xb4, 0x8b, 0x1d, 0x19, 0x08, 0x39, - 0xa6, 0xe1, 0x57, 0x99, 0x1d, 0xe3, 0xfa, 0x58, 0x08, 0x62, 0xf8, 0x55, 0xe5, 0x19, 0x17, 0xd9, - 0x1e, 0xcc, 0x45, 0xae, 0xc0, 0x71, 0x51, 0x24, 0xb7, 0xb3, 0x9b, 0x46, 0x3d, 0x25, 0xa8, 0x53, - 0x4c, 0x38, 0xd3, 0xf4, 0xee, 0x61, 0x70, 0xfc, 0x4f, 0x83, 0xd3, 0xbf, 0xe9, 0x13, 0x3a, 0x05, - 0x51, 0x23, 0x88, 0x55, 0x38, 0xfb, 0x2e, 0x4c, 0x09, 0xad, 0xc7, 0x8f, 0x27, 0xab, 0xfe, 0xf9, - 0x6a, 0xa8, 0x51, 0x22, 0x7e, 0x6a, 0xd0, 0xfc, 0xbd, 0x72, 0x73, 0x67, 0xb6, 0xc2, 0xfd, 0xd9, - 0xc2, 0xb4, 0xd3, 0x9f, 0x19, 0x38, 0x1a, 0x82, 0xdb, 0x65, 0xe6, 0xce, 0xa0, 0x3e, 0xc2, 0xde, - 0xb7, 0xcb, 0x8a, 0x1d, 0x9d, 0x75, 0x17, 0xc5, 0x8f, 0xdb, 0x15, 0x83, 0xeb, 0x29, 0x16, 0xb5, - 0x06, 0xfd, 0x3f, 0xc9, 0x6a, 0xed, 0xd4, 0x48, 0x3d, 0x06, 0x1b, 0x9a, 0x86, 0x23, 0xb4, 0x11, - 0xb6, 0x59, 0xe0, 0xcc, 0x98, 0x3e, 0x4c, 0x1b, 0x41, 0x8f, 0xa1, 0x79, 0x98, 0x64, 0xfd, 0x92, - 0x1e, 0x64, 0x40, 0x13, 0xcd, 0xee, 0xd9, 0x09, 0x7e, 0xf4, 0x70, 0xaf, 0xad, 0x4f, 0x87, 0x58, - 0x82, 0xa8, 0x4f, 0x83, 0xba, 0xb4, 0x51, 0xb4, 0xdd, 0x32, 0x6e, 0xa4, 0x93, 0x61, 0x5d, 0xda, - 0xd8, 0x0e, 0x5e, 0x95, 0x2c, 0x44, 0x22, 0x27, 0xf7, 0x62, 0x0a, 0x26, 0xeb, 0x86, 0xc3, 0x29, - 0x47, 0xf5, 0xf0, 0x45, 0x99, 0x85, 0x19, 0xf6, 0xed, 0x73, 0x61, 0xe8, 0x6c, 0x06, 0x33, 0x87, - 0xeb, 0x53, 0x5e, 0x03, 0x28, 0xf7, 0xfa, 0x82, 0x67, 0xae, 0x40, 0xd4, 0x39, 0xb3, 0x78, 0x7b, - 0xe5, 0xae, 0x32, 0xbb, 0x23, 0x2d, 0xef, 0xb2, 0xc9, 0x7a, 0xfb, 0x46, 0xfe, 0xdb, 0x28, 0x4c, - 0x32, 0x14, 0x74, 0x0a, 0xe0, 0x5f, 0xc2, 0x55, 0x5b, 0x77, 0x1c, 0x54, 0xb8, 0xaa, 0x50, 0xef, - 0x09, 0x29, 0xad, 0xf6, 0x15, 0x1b, 0xaa, 0x57, 0x96, 0x5f, 0x7d, 0xf9, 0xf9, 0x76, 0x60, 0x11, - 0x2d, 0x68, 0x41, 0xe8, 0x32, 0xcb, 0xa2, 0x89, 0xf3, 0xbc, 0x65, 0x28, 0xa2, 0x4f, 0x00, 0xa6, - 0x84, 0x34, 0x31, 0xb9, 0xbb, 0x8e, 0xb2, 0x98, 0xdc, 0xdd, 0x27, 0x99, 0x52, 0x60, 0xdc, 0xf7, - 0x50, 0x3e, 0x16, 0xb7, 0x76, 0x1c, 0x35, 0xe3, 0x09, 0xfa, 0x00, 0xe0, 0x44, 0x74, 0x4b, 0x02, - 0xfb, 0xef, 0xc7, 0xb5, 0xb0, 0xe3, 0x76, 0x4b, 0x85, 0x7e, 0x42, 0xb9, 0x88, 0x5b, 0x4c, 0xc4, - 0x02, 0x9a, 0xef, 0x25, 0x42, 0xb8, 0xfe, 0xe8, 0x23, 0x80, 0x30, 0xca, 0x11, 0x13, 0xb9, 0xdb, - 0x40, 0x92, 0x0a, 0xfd, 0x84, 0x72, 0xe4, 0x15, 0x86, 0x7c, 0x07, 0xa9, 0x31, 0x90, 0xb5, 0xe3, - 0xe6, 0x6c, 0x39, 0x41, 0xef, 0x00, 0x4c, 0xb2, 0x1b, 0x8d, 0x72, 0xb1, 0xaa, 0x8b, 0x53, 0x4a, - 0xca, 0x5f, 0x27, 0x84, 0x83, 0x2e, 0x30, 0xd0, 0x59, 0x94, 0xe9, 0x05, 0xea, 0x31, 0x9a, 0xcf, - 0x00, 0x4e, 0x76, 0x5c, 0x62, 0xf4, 0x20, 0x56, 0xc1, 0x5e, 0x53, 0x47, 0x5a, 0xeb, 0x37, 0x9c, - 0xb3, 0xe7, 0x19, 0xfb, 0x6d, 0x94, 0xed, 0xc5, 0xde, 0x39, 0xb0, 0x36, 0x9e, 0x9c, 0x5d, 0xc8, - 0xe0, 0xfc, 0x42, 0x06, 0x3f, 0x2e, 0x64, 0xf0, 0xe6, 0x52, 0x4e, 0x9c, 0x5f, 0xca, 0x89, 0xaf, - 0x97, 0x72, 0xe2, 0x45, 0xde, 0xb2, 0x69, 0xf5, 0xb0, 0xa4, 0x9a, 0x64, 0x5f, 0xcc, 0xd7, 0x04, - 0xd3, 0x1a, 0x2d, 0xa9, 0xe9, 0x91, 0x87, 0xfd, 0xd2, 0x30, 0xfb, 0x6b, 0x76, 0xf7, 0x57, 0x00, - 0x00, 0x00, 0xff, 0xff, 0x25, 0x64, 0xfd, 0xdf, 0x93, 0x0a, 0x00, 0x00, + // 851 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x96, 0x4f, 0x4f, 0xdb, 0x48, + 0x18, 0xc6, 0x63, 0x20, 0xfc, 0x99, 0x10, 0xa4, 0x1d, 0x90, 0x08, 0xde, 0x25, 0xb0, 0x66, 0x59, + 0x50, 0x16, 0xec, 0x25, 0xbb, 0x42, 0xda, 0x20, 0x6d, 0x0b, 0x55, 0x4b, 0x51, 0x7b, 0x00, 0x57, + 0x3d, 0xb4, 0x97, 0x68, 0xe2, 0x0c, 0x8e, 0x85, 0xf1, 0x98, 0x78, 0x88, 0x42, 0x11, 0x97, 0x7e, + 0x82, 0x4a, 0x55, 0xbf, 0x42, 0xbf, 0x40, 0x2f, 0x48, 0xbd, 0xf5, 0xc4, 0xa1, 0x07, 0xa4, 0x5e, + 0x7a, 0xaa, 0xaa, 0xd0, 0x0f, 0x52, 0x79, 0x66, 0x52, 0x4f, 0xc0, 0x29, 0x26, 0xe2, 0x14, 0x7b, + 0xc6, 0xef, 0xfb, 0xfe, 0x9e, 0x67, 0xde, 0x79, 0x15, 0x30, 0xe9, 0x3a, 0x76, 0x8d, 0x5a, 0xae, + 0x83, 0x3d, 0x6a, 0x1c, 0x1c, 0xe2, 0xfa, 0x91, 0xee, 0xd7, 0x09, 0x25, 0x30, 0xff, 0x02, 0x53, + 0x64, 0xd5, 0x90, 0xe3, 0xe9, 0xec, 0x89, 0xd4, 0xb1, 0x2e, 0x7d, 0xab, 0x16, 0x2c, 0x12, 0xec, + 0x93, 0xc0, 0xa8, 0xa0, 0x00, 0xf3, 0x40, 0xa3, 0xb1, 0x52, 0xc1, 0x14, 0xad, 0x18, 0x3e, 0xb2, + 0x1d, 0x0f, 0x51, 0x87, 0x78, 0x3c, 0x97, 0x3a, 0x61, 0x13, 0x9b, 0xb0, 0x47, 0x23, 0x7c, 0x12, + 0xab, 0xbf, 0xd9, 0x84, 0xd8, 0x2e, 0x36, 0x90, 0xef, 0x18, 0xc8, 0xf3, 0x08, 0x65, 0x21, 0x81, + 0xd8, 0x9d, 0x96, 0xc1, 0x18, 0x47, 0x39, 0xa0, 0x88, 0x62, 0xb1, 0xfd, 0x87, 0xbc, 0xdd, 0xc0, + 0x75, 0x67, 0xd7, 0xb1, 0x58, 0x7c, 0x79, 0xd7, 0x45, 0x76, 0x3b, 0xc9, 0xa4, 0xbf, 0x67, 0x1b, + 0x7e, 0x9d, 0x90, 0xdd, 0x40, 0xfc, 0xf0, 0x0d, 0xad, 0x0a, 0xd4, 0x9d, 0x90, 0x79, 0xdd, 0x75, + 0x37, 0x5c, 0x62, 0xed, 0x3d, 0xc4, 0xa8, 0x8a, 0xeb, 0x26, 0x3e, 0x38, 0xc4, 0x01, 0x85, 0x0f, + 0x00, 0x88, 0x34, 0xe4, 0x94, 0x59, 0x65, 0x31, 0x53, 0xfc, 0x53, 0xe7, 0x82, 0xf5, 0x50, 0xb0, + 0xce, 0x9d, 0x12, 0x82, 0xf5, 0x6d, 0x64, 0x63, 0x11, 0x6b, 0x4a, 0x91, 0xda, 0x5b, 0x05, 0xfc, + 0x1a, 0x5b, 0x26, 0xf0, 0x89, 0x17, 0x60, 0xf8, 0x3f, 0xc8, 0x56, 0xc2, 0xe5, 0x72, 0x8d, 0xad, + 0x07, 0x39, 0x65, 0xb6, 0x7f, 0x31, 0x53, 0x1c, 0xd7, 0x05, 0xab, 0x14, 0xb3, 0x31, 0x70, 0xf6, + 0x65, 0x26, 0x65, 0x8e, 0x56, 0xa2, 0xa5, 0x00, 0x6e, 0x76, 0x70, 0xf6, 0x31, 0xce, 0x85, 0x6b, + 0x39, 0x79, 0xf1, 0x0e, 0xd0, 0x35, 0x61, 0xc7, 0x26, 0xa6, 0x31, 0x76, 0x4c, 0x03, 0x20, 0x30, + 0x51, 0x50, 0x63, 0x76, 0x8c, 0x9a, 0x23, 0x1c, 0x04, 0x05, 0x35, 0xed, 0xa9, 0x10, 0x79, 0x39, + 0x58, 0x88, 0x5c, 0x05, 0xa3, 0xb2, 0x48, 0x61, 0x67, 0x9c, 0x46, 0x33, 0x23, 0xa9, 0xd3, 0x2c, + 0x30, 0xd5, 0xf6, 0xee, 0x5e, 0x78, 0xfc, 0x4f, 0xc2, 0xd3, 0xbf, 0xed, 0x13, 0x3a, 0x55, 0xa2, + 0x46, 0x90, 0xab, 0x08, 0xf6, 0x1d, 0x90, 0x91, 0x5a, 0x4f, 0x1c, 0x4f, 0x41, 0xff, 0xf9, 0xd5, + 0xd0, 0xa3, 0x44, 0xe2, 0xd4, 0x80, 0xf5, 0x63, 0xe5, 0xf6, 0xce, 0x6c, 0x55, 0xf8, 0xb3, 0x89, + 0xe9, 0x55, 0x7f, 0xa6, 0xc0, 0x30, 0x07, 0x77, 0xaa, 0xcc, 0x9d, 0x7e, 0x73, 0x88, 0xbd, 0x6f, + 0x55, 0x35, 0x27, 0x3a, 0xeb, 0x18, 0xc5, 0x8f, 0x2e, 0x2b, 0x56, 0x6e, 0xa6, 0x58, 0xd6, 0x1a, + 0xf6, 0xff, 0x2f, 0xac, 0xd6, 0x76, 0x9d, 0x34, 0x12, 0xb0, 0xc1, 0x49, 0x30, 0x44, 0x9b, 0xbc, + 0xcd, 0x42, 0x67, 0x46, 0xcc, 0x41, 0xda, 0x0c, 0x7b, 0x0c, 0xce, 0x81, 0x34, 0xeb, 0x97, 0x5c, + 0x3f, 0x03, 0xca, 0xb6, 0xbb, 0x67, 0x3b, 0xfc, 0x31, 0xf9, 0xde, 0xa5, 0x3e, 0x1d, 0x60, 0x09, + 0xa2, 0x3e, 0x0d, 0xeb, 0xd2, 0x66, 0xd9, 0xf1, 0xaa, 0xb8, 0x99, 0x4b, 0xf3, 0xba, 0xb4, 0xb9, + 0x15, 0xbe, 0x6a, 0x05, 0x00, 0x65, 0x4e, 0xe1, 0xc5, 0x04, 0x48, 0x37, 0x90, 0x2b, 0x28, 0x87, + 0x4d, 0xfe, 0xa2, 0xfd, 0x0e, 0x66, 0xd8, 0xb7, 0xbc, 0x4d, 0xef, 0x7b, 0xa8, 0xe2, 0xe2, 0x2a, + 0x33, 0x20, 0x10, 0x0a, 0xb5, 0x13, 0x30, 0xdb, 0xfd, 0x13, 0x91, 0xfc, 0x19, 0x18, 0xc3, 0x7c, + 0xa3, 0xcc, 0xd4, 0xb7, 0x2f, 0xff, 0xd2, 0x75, 0x5e, 0xcb, 0xe9, 0x44, 0x7f, 0x65, 0xb1, 0x5c, + 0xa2, 0xd8, 0x1a, 0x06, 0x69, 0x56, 0x1f, 0x9e, 0x2a, 0x60, 0x4c, 0xba, 0x60, 0xeb, 0xae, 0x0b, + 0x4b, 0xd7, 0xe5, 0xef, 0x3e, 0x17, 0xd5, 0xb5, 0x9e, 0x62, 0xb9, 0x60, 0x6d, 0xf9, 0xe5, 0xa7, + 0x6f, 0xaf, 0xfb, 0x16, 0xe0, 0xbc, 0x11, 0x86, 0x2e, 0xb3, 0x2c, 0x86, 0x3c, 0xc5, 0x3b, 0x46, + 0x21, 0xfc, 0xa0, 0x80, 0x8c, 0x94, 0x26, 0x21, 0x77, 0xec, 0x00, 0x4b, 0xc8, 0x1d, 0x3f, 0xbf, + 0xb4, 0x12, 0xe3, 0xfe, 0x17, 0x16, 0x13, 0x71, 0x1b, 0xc7, 0x51, 0x0b, 0x9e, 0xc0, 0x77, 0x0a, + 0xc8, 0x46, 0x77, 0x23, 0xb4, 0xff, 0xbf, 0xa4, 0x16, 0x5e, 0xb9, 0xd3, 0x6a, 0xa9, 0x97, 0x50, + 0x21, 0xe2, 0x2f, 0x26, 0x62, 0x1e, 0xce, 0x75, 0x13, 0x21, 0x5d, 0x7a, 0xf8, 0x5e, 0x01, 0x20, + 0xca, 0x91, 0x10, 0x39, 0x6e, 0x0c, 0xa9, 0xa5, 0x5e, 0x42, 0x05, 0xf2, 0x2a, 0x43, 0xfe, 0x1b, + 0xea, 0x09, 0x90, 0x8d, 0xe3, 0xf6, 0x44, 0x39, 0x81, 0x6f, 0x14, 0x90, 0x66, 0xf7, 0x18, 0xae, + 0x24, 0xaa, 0x2e, 0xcf, 0x26, 0xb5, 0x78, 0x93, 0x10, 0x01, 0x3a, 0xcf, 0x40, 0x67, 0xe0, 0x74, + 0x37, 0x50, 0x9f, 0xd1, 0x7c, 0x54, 0xc0, 0x78, 0xcc, 0x40, 0x80, 0x77, 0x12, 0x95, 0xec, 0x3e, + 0x6d, 0xd4, 0xbb, 0xbd, 0x27, 0x10, 0x0a, 0x8a, 0x4c, 0xc1, 0x12, 0x2c, 0x74, 0x53, 0x70, 0xf5, + 0x0f, 0xd6, 0xc6, 0xe3, 0xb3, 0x56, 0x5e, 0x39, 0x6f, 0xe5, 0x95, 0xaf, 0xad, 0xbc, 0xf2, 0xea, + 0x22, 0x9f, 0x3a, 0xbf, 0xc8, 0xa7, 0x3e, 0x5f, 0xe4, 0x53, 0xcf, 0x8b, 0xb6, 0x43, 0x6b, 0x87, + 0x15, 0xdd, 0x22, 0xfb, 0x72, 0xbe, 0x36, 0x9a, 0xd1, 0xec, 0x48, 0x4d, 0x8f, 0x7c, 0x1c, 0x54, + 0x06, 0xd9, 0xdf, 0xb2, 0x7f, 0xbe, 0x07, 0x00, 0x00, 0xff, 0xff, 0xd3, 0x32, 0xe8, 0x94, 0x8f, + 0x0a, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -691,7 +692,7 @@ type QueryClient interface { ChainStateAll(ctx context.Context, in *QueryAllChainStateRequest, opts ...grpc.CallOption) (*QueryAllChainStateResponse, error) ChainState(ctx context.Context, in *QueryGetChainStateRequest, opts ...grpc.CallOption) (*QueryGetChainStateResponse, error) Prove(ctx context.Context, in *QueryProveRequest, opts ...grpc.CallOption) (*QueryProveResponse, error) - VerificationFlags(ctx context.Context, in *QueryVerificationFlagsRequest, opts ...grpc.CallOption) (*QueryVerificationFlagsResponse, error) + HeaderEnabledChains(ctx context.Context, in *QueryHeaderEnabledChainsRequest, opts ...grpc.CallOption) (*QueryHeaderEnabledChainsResponse, error) } type queryClient struct { @@ -747,9 +748,9 @@ func (c *queryClient) Prove(ctx context.Context, in *QueryProveRequest, opts ... return out, nil } -func (c *queryClient) VerificationFlags(ctx context.Context, in *QueryVerificationFlagsRequest, opts ...grpc.CallOption) (*QueryVerificationFlagsResponse, error) { - out := new(QueryVerificationFlagsResponse) - err := c.cc.Invoke(ctx, "/zetachain.zetacore.lightclient.Query/VerificationFlags", in, out, opts...) +func (c *queryClient) HeaderEnabledChains(ctx context.Context, in *QueryHeaderEnabledChainsRequest, opts ...grpc.CallOption) (*QueryHeaderEnabledChainsResponse, error) { + out := new(QueryHeaderEnabledChainsResponse) + err := c.cc.Invoke(ctx, "/zetachain.zetacore.lightclient.Query/HeaderEnabledChains", in, out, opts...) if err != nil { return nil, err } @@ -763,7 +764,7 @@ type QueryServer interface { ChainStateAll(context.Context, *QueryAllChainStateRequest) (*QueryAllChainStateResponse, error) ChainState(context.Context, *QueryGetChainStateRequest) (*QueryGetChainStateResponse, error) Prove(context.Context, *QueryProveRequest) (*QueryProveResponse, error) - VerificationFlags(context.Context, *QueryVerificationFlagsRequest) (*QueryVerificationFlagsResponse, error) + HeaderEnabledChains(context.Context, *QueryHeaderEnabledChainsRequest) (*QueryHeaderEnabledChainsResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -785,8 +786,8 @@ func (*UnimplementedQueryServer) ChainState(ctx context.Context, req *QueryGetCh func (*UnimplementedQueryServer) Prove(ctx context.Context, req *QueryProveRequest) (*QueryProveResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Prove not implemented") } -func (*UnimplementedQueryServer) VerificationFlags(ctx context.Context, req *QueryVerificationFlagsRequest) (*QueryVerificationFlagsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method VerificationFlags not implemented") +func (*UnimplementedQueryServer) HeaderEnabledChains(ctx context.Context, req *QueryHeaderEnabledChainsRequest) (*QueryHeaderEnabledChainsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method HeaderEnabledChains not implemented") } func RegisterQueryServer(s grpc1.Server, srv QueryServer) { @@ -883,20 +884,20 @@ func _Query_Prove_Handler(srv interface{}, ctx context.Context, dec func(interfa return interceptor(ctx, in, info, handler) } -func _Query_VerificationFlags_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryVerificationFlagsRequest) +func _Query_HeaderEnabledChains_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryHeaderEnabledChainsRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(QueryServer).VerificationFlags(ctx, in) + return srv.(QueryServer).HeaderEnabledChains(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/zetachain.zetacore.lightclient.Query/VerificationFlags", + FullMethod: "/zetachain.zetacore.lightclient.Query/HeaderEnabledChains", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).VerificationFlags(ctx, req.(*QueryVerificationFlagsRequest)) + return srv.(QueryServer).HeaderEnabledChains(ctx, req.(*QueryHeaderEnabledChainsRequest)) } return interceptor(ctx, in, info, handler) } @@ -926,8 +927,8 @@ var _Query_serviceDesc = grpc.ServiceDesc{ Handler: _Query_Prove_Handler, }, { - MethodName: "VerificationFlags", - Handler: _Query_VerificationFlags_Handler, + MethodName: "HeaderEnabledChains", + Handler: _Query_HeaderEnabledChains_Handler, }, }, Streams: []grpc.StreamDesc{}, @@ -1322,7 +1323,7 @@ func (m *QueryProveResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *QueryVerificationFlagsRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryHeaderEnabledChainsRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1332,12 +1333,12 @@ func (m *QueryVerificationFlagsRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryVerificationFlagsRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryHeaderEnabledChainsRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryVerificationFlagsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryHeaderEnabledChainsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1345,7 +1346,7 @@ func (m *QueryVerificationFlagsRequest) MarshalToSizedBuffer(dAtA []byte) (int, return len(dAtA) - i, nil } -func (m *QueryVerificationFlagsResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryHeaderEnabledChainsResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1355,20 +1356,20 @@ func (m *QueryVerificationFlagsResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryVerificationFlagsResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryHeaderEnabledChainsResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryVerificationFlagsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryHeaderEnabledChainsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.VerificationFlags) > 0 { - for iNdEx := len(m.VerificationFlags) - 1; iNdEx >= 0; iNdEx-- { + if len(m.EnabledChains) > 0 { + for iNdEx := len(m.EnabledChains) - 1; iNdEx >= 0; iNdEx-- { { - size, err := m.VerificationFlags[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + size, err := m.EnabledChains[iNdEx].MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -1547,7 +1548,7 @@ func (m *QueryProveResponse) Size() (n int) { return n } -func (m *QueryVerificationFlagsRequest) Size() (n int) { +func (m *QueryHeaderEnabledChainsRequest) Size() (n int) { if m == nil { return 0 } @@ -1556,14 +1557,14 @@ func (m *QueryVerificationFlagsRequest) Size() (n int) { return n } -func (m *QueryVerificationFlagsResponse) Size() (n int) { +func (m *QueryHeaderEnabledChainsResponse) Size() (n int) { if m == nil { return 0 } var l int _ = l - if len(m.VerificationFlags) > 0 { - for _, e := range m.VerificationFlags { + if len(m.EnabledChains) > 0 { + for _, e := range m.EnabledChains { l = e.Size() n += 1 + l + sovQuery(uint64(l)) } @@ -2572,7 +2573,7 @@ func (m *QueryProveResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryVerificationFlagsRequest) Unmarshal(dAtA []byte) error { +func (m *QueryHeaderEnabledChainsRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2595,10 +2596,10 @@ func (m *QueryVerificationFlagsRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryVerificationFlagsRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryHeaderEnabledChainsRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryVerificationFlagsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryHeaderEnabledChainsRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: @@ -2622,7 +2623,7 @@ func (m *QueryVerificationFlagsRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryVerificationFlagsResponse) Unmarshal(dAtA []byte) error { +func (m *QueryHeaderEnabledChainsResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2645,15 +2646,15 @@ func (m *QueryVerificationFlagsResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryVerificationFlagsResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryHeaderEnabledChainsResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryVerificationFlagsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryHeaderEnabledChainsResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field VerificationFlags", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field EnabledChains", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -2680,8 +2681,8 @@ func (m *QueryVerificationFlagsResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.VerificationFlags = append(m.VerificationFlags, VerificationFlags{}) - if err := m.VerificationFlags[len(m.VerificationFlags)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.EnabledChains = append(m.EnabledChains, EnabledChain{}) + if err := m.EnabledChains[len(m.EnabledChains)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/x/lightclient/types/query.pb.gw.go b/x/lightclient/types/query.pb.gw.go index 1b62c608cb..4f8ca48267 100644 --- a/x/lightclient/types/query.pb.gw.go +++ b/x/lightclient/types/query.pb.gw.go @@ -249,20 +249,20 @@ func local_request_Query_Prove_0(ctx context.Context, marshaler runtime.Marshale } -func request_Query_VerificationFlags_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryVerificationFlagsRequest +func request_Query_HeaderEnabledChains_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryHeaderEnabledChainsRequest var metadata runtime.ServerMetadata - msg, err := client.VerificationFlags(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.HeaderEnabledChains(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Query_VerificationFlags_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryVerificationFlagsRequest +func local_request_Query_HeaderEnabledChains_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryHeaderEnabledChainsRequest var metadata runtime.ServerMetadata - msg, err := server.VerificationFlags(ctx, &protoReq) + msg, err := server.HeaderEnabledChains(ctx, &protoReq) return msg, metadata, err } @@ -388,7 +388,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) - mux.Handle("GET", pattern_Query_VerificationFlags_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_HeaderEnabledChains_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream @@ -399,7 +399,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Query_VerificationFlags_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_Query_HeaderEnabledChains_0(rctx, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { @@ -407,7 +407,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } - forward_Query_VerificationFlags_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_HeaderEnabledChains_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -552,7 +552,7 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) - mux.Handle("GET", pattern_Query_VerificationFlags_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_HeaderEnabledChains_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) @@ -561,14 +561,14 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Query_VerificationFlags_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Query_HeaderEnabledChains_0(rctx, inboundMarshaler, client, req, pathParams) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - forward_Query_VerificationFlags_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_HeaderEnabledChains_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -586,7 +586,7 @@ var ( pattern_Query_Prove_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"zeta-chain", "lightclient", "prove"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_VerificationFlags_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"zeta-chain", "lightclient", "verification_flags"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_HeaderEnabledChains_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"zeta-chain", "lightclient", "verification_flags"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( @@ -600,5 +600,5 @@ var ( forward_Query_Prove_0 = runtime.ForwardResponseMessage - forward_Query_VerificationFlags_0 = runtime.ForwardResponseMessage + forward_Query_HeaderEnabledChains_0 = runtime.ForwardResponseMessage ) diff --git a/x/lightclient/types/tx.pb.go b/x/lightclient/types/tx.pb.go index 09d00266ab..125887490f 100644 --- a/x/lightclient/types/tx.pb.go +++ b/x/lightclient/types/tx.pb.go @@ -29,23 +29,23 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -type MsgEnableVerificationFlags struct { +type MsgEnableHeaderVerification struct { Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` ChainIdList []int64 `protobuf:"varint,2,rep,packed,name=chain_id_list,json=chainIdList,proto3" json:"chain_id_list,omitempty"` } -func (m *MsgEnableVerificationFlags) Reset() { *m = MsgEnableVerificationFlags{} } -func (m *MsgEnableVerificationFlags) String() string { return proto.CompactTextString(m) } -func (*MsgEnableVerificationFlags) ProtoMessage() {} -func (*MsgEnableVerificationFlags) Descriptor() ([]byte, []int) { +func (m *MsgEnableHeaderVerification) Reset() { *m = MsgEnableHeaderVerification{} } +func (m *MsgEnableHeaderVerification) String() string { return proto.CompactTextString(m) } +func (*MsgEnableHeaderVerification) ProtoMessage() {} +func (*MsgEnableHeaderVerification) Descriptor() ([]byte, []int) { return fileDescriptor_81fed8987f08d9c5, []int{0} } -func (m *MsgEnableVerificationFlags) XXX_Unmarshal(b []byte) error { +func (m *MsgEnableHeaderVerification) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgEnableVerificationFlags) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgEnableHeaderVerification) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgEnableVerificationFlags.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgEnableHeaderVerification.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -55,47 +55,47 @@ func (m *MsgEnableVerificationFlags) XXX_Marshal(b []byte, deterministic bool) ( return b[:n], nil } } -func (m *MsgEnableVerificationFlags) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgEnableVerificationFlags.Merge(m, src) +func (m *MsgEnableHeaderVerification) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgEnableHeaderVerification.Merge(m, src) } -func (m *MsgEnableVerificationFlags) XXX_Size() int { +func (m *MsgEnableHeaderVerification) XXX_Size() int { return m.Size() } -func (m *MsgEnableVerificationFlags) XXX_DiscardUnknown() { - xxx_messageInfo_MsgEnableVerificationFlags.DiscardUnknown(m) +func (m *MsgEnableHeaderVerification) XXX_DiscardUnknown() { + xxx_messageInfo_MsgEnableHeaderVerification.DiscardUnknown(m) } -var xxx_messageInfo_MsgEnableVerificationFlags proto.InternalMessageInfo +var xxx_messageInfo_MsgEnableHeaderVerification proto.InternalMessageInfo -func (m *MsgEnableVerificationFlags) GetCreator() string { +func (m *MsgEnableHeaderVerification) GetCreator() string { if m != nil { return m.Creator } return "" } -func (m *MsgEnableVerificationFlags) GetChainIdList() []int64 { +func (m *MsgEnableHeaderVerification) GetChainIdList() []int64 { if m != nil { return m.ChainIdList } return nil } -type MsgEnableVerificationFlagsResponse struct { +type MsgEnableHeaderVerificationResponse struct { } -func (m *MsgEnableVerificationFlagsResponse) Reset() { *m = MsgEnableVerificationFlagsResponse{} } -func (m *MsgEnableVerificationFlagsResponse) String() string { return proto.CompactTextString(m) } -func (*MsgEnableVerificationFlagsResponse) ProtoMessage() {} -func (*MsgEnableVerificationFlagsResponse) Descriptor() ([]byte, []int) { +func (m *MsgEnableHeaderVerificationResponse) Reset() { *m = MsgEnableHeaderVerificationResponse{} } +func (m *MsgEnableHeaderVerificationResponse) String() string { return proto.CompactTextString(m) } +func (*MsgEnableHeaderVerificationResponse) ProtoMessage() {} +func (*MsgEnableHeaderVerificationResponse) Descriptor() ([]byte, []int) { return fileDescriptor_81fed8987f08d9c5, []int{1} } -func (m *MsgEnableVerificationFlagsResponse) XXX_Unmarshal(b []byte) error { +func (m *MsgEnableHeaderVerificationResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgEnableVerificationFlagsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgEnableHeaderVerificationResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgEnableVerificationFlagsResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgEnableHeaderVerificationResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -105,35 +105,35 @@ func (m *MsgEnableVerificationFlagsResponse) XXX_Marshal(b []byte, deterministic return b[:n], nil } } -func (m *MsgEnableVerificationFlagsResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgEnableVerificationFlagsResponse.Merge(m, src) +func (m *MsgEnableHeaderVerificationResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgEnableHeaderVerificationResponse.Merge(m, src) } -func (m *MsgEnableVerificationFlagsResponse) XXX_Size() int { +func (m *MsgEnableHeaderVerificationResponse) XXX_Size() int { return m.Size() } -func (m *MsgEnableVerificationFlagsResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgEnableVerificationFlagsResponse.DiscardUnknown(m) +func (m *MsgEnableHeaderVerificationResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgEnableHeaderVerificationResponse.DiscardUnknown(m) } -var xxx_messageInfo_MsgEnableVerificationFlagsResponse proto.InternalMessageInfo +var xxx_messageInfo_MsgEnableHeaderVerificationResponse proto.InternalMessageInfo -type MsgDisableVerificationFlags struct { +type MsgDisableHeaderVerification struct { Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` ChainIdList []int64 `protobuf:"varint,2,rep,packed,name=chain_id_list,json=chainIdList,proto3" json:"chain_id_list,omitempty"` } -func (m *MsgDisableVerificationFlags) Reset() { *m = MsgDisableVerificationFlags{} } -func (m *MsgDisableVerificationFlags) String() string { return proto.CompactTextString(m) } -func (*MsgDisableVerificationFlags) ProtoMessage() {} -func (*MsgDisableVerificationFlags) Descriptor() ([]byte, []int) { +func (m *MsgDisableHeaderVerification) Reset() { *m = MsgDisableHeaderVerification{} } +func (m *MsgDisableHeaderVerification) String() string { return proto.CompactTextString(m) } +func (*MsgDisableHeaderVerification) ProtoMessage() {} +func (*MsgDisableHeaderVerification) Descriptor() ([]byte, []int) { return fileDescriptor_81fed8987f08d9c5, []int{2} } -func (m *MsgDisableVerificationFlags) XXX_Unmarshal(b []byte) error { +func (m *MsgDisableHeaderVerification) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgDisableVerificationFlags) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgDisableHeaderVerification) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgDisableVerificationFlags.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgDisableHeaderVerification.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -143,47 +143,47 @@ func (m *MsgDisableVerificationFlags) XXX_Marshal(b []byte, deterministic bool) return b[:n], nil } } -func (m *MsgDisableVerificationFlags) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgDisableVerificationFlags.Merge(m, src) +func (m *MsgDisableHeaderVerification) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgDisableHeaderVerification.Merge(m, src) } -func (m *MsgDisableVerificationFlags) XXX_Size() int { +func (m *MsgDisableHeaderVerification) XXX_Size() int { return m.Size() } -func (m *MsgDisableVerificationFlags) XXX_DiscardUnknown() { - xxx_messageInfo_MsgDisableVerificationFlags.DiscardUnknown(m) +func (m *MsgDisableHeaderVerification) XXX_DiscardUnknown() { + xxx_messageInfo_MsgDisableHeaderVerification.DiscardUnknown(m) } -var xxx_messageInfo_MsgDisableVerificationFlags proto.InternalMessageInfo +var xxx_messageInfo_MsgDisableHeaderVerification proto.InternalMessageInfo -func (m *MsgDisableVerificationFlags) GetCreator() string { +func (m *MsgDisableHeaderVerification) GetCreator() string { if m != nil { return m.Creator } return "" } -func (m *MsgDisableVerificationFlags) GetChainIdList() []int64 { +func (m *MsgDisableHeaderVerification) GetChainIdList() []int64 { if m != nil { return m.ChainIdList } return nil } -type MsgDisableVerificationFlagsResponse struct { +type MsgDisableHeaderVerificationResponse struct { } -func (m *MsgDisableVerificationFlagsResponse) Reset() { *m = MsgDisableVerificationFlagsResponse{} } -func (m *MsgDisableVerificationFlagsResponse) String() string { return proto.CompactTextString(m) } -func (*MsgDisableVerificationFlagsResponse) ProtoMessage() {} -func (*MsgDisableVerificationFlagsResponse) Descriptor() ([]byte, []int) { +func (m *MsgDisableHeaderVerificationResponse) Reset() { *m = MsgDisableHeaderVerificationResponse{} } +func (m *MsgDisableHeaderVerificationResponse) String() string { return proto.CompactTextString(m) } +func (*MsgDisableHeaderVerificationResponse) ProtoMessage() {} +func (*MsgDisableHeaderVerificationResponse) Descriptor() ([]byte, []int) { return fileDescriptor_81fed8987f08d9c5, []int{3} } -func (m *MsgDisableVerificationFlagsResponse) XXX_Unmarshal(b []byte) error { +func (m *MsgDisableHeaderVerificationResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgDisableVerificationFlagsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgDisableHeaderVerificationResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgDisableVerificationFlagsResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgDisableHeaderVerificationResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -193,50 +193,50 @@ func (m *MsgDisableVerificationFlagsResponse) XXX_Marshal(b []byte, deterministi return b[:n], nil } } -func (m *MsgDisableVerificationFlagsResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgDisableVerificationFlagsResponse.Merge(m, src) +func (m *MsgDisableHeaderVerificationResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgDisableHeaderVerificationResponse.Merge(m, src) } -func (m *MsgDisableVerificationFlagsResponse) XXX_Size() int { +func (m *MsgDisableHeaderVerificationResponse) XXX_Size() int { return m.Size() } -func (m *MsgDisableVerificationFlagsResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgDisableVerificationFlagsResponse.DiscardUnknown(m) +func (m *MsgDisableHeaderVerificationResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgDisableHeaderVerificationResponse.DiscardUnknown(m) } -var xxx_messageInfo_MsgDisableVerificationFlagsResponse proto.InternalMessageInfo +var xxx_messageInfo_MsgDisableHeaderVerificationResponse proto.InternalMessageInfo func init() { - proto.RegisterType((*MsgEnableVerificationFlags)(nil), "zetachain.zetacore.lightclient.MsgEnableVerificationFlags") - proto.RegisterType((*MsgEnableVerificationFlagsResponse)(nil), "zetachain.zetacore.lightclient.MsgEnableVerificationFlagsResponse") - proto.RegisterType((*MsgDisableVerificationFlags)(nil), "zetachain.zetacore.lightclient.MsgDisableVerificationFlags") - proto.RegisterType((*MsgDisableVerificationFlagsResponse)(nil), "zetachain.zetacore.lightclient.MsgDisableVerificationFlagsResponse") + proto.RegisterType((*MsgEnableHeaderVerification)(nil), "zetachain.zetacore.lightclient.MsgEnableHeaderVerification") + proto.RegisterType((*MsgEnableHeaderVerificationResponse)(nil), "zetachain.zetacore.lightclient.MsgEnableHeaderVerificationResponse") + proto.RegisterType((*MsgDisableHeaderVerification)(nil), "zetachain.zetacore.lightclient.MsgDisableHeaderVerification") + proto.RegisterType((*MsgDisableHeaderVerificationResponse)(nil), "zetachain.zetacore.lightclient.MsgDisableHeaderVerificationResponse") } func init() { proto.RegisterFile("lightclient/tx.proto", fileDescriptor_81fed8987f08d9c5) } var fileDescriptor_81fed8987f08d9c5 = []byte{ - // 321 bytes of a gzipped FileDescriptorProto + // 324 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0xc9, 0xc9, 0x4c, 0xcf, 0x28, 0x49, 0xce, 0xc9, 0x4c, 0xcd, 0x2b, 0xd1, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0xab, 0x4a, 0x2d, 0x49, 0x4c, 0xce, 0x48, 0xcc, 0xcc, 0xd3, 0x03, 0xb3, 0xf2, 0x8b, 0x52, 0xf5, 0x90, 0x14, 0x4a, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0x95, 0xea, 0x83, 0x58, 0x10, 0x5d, 0x52, 0x2a, 0xc8, 0x66, 0x95, 0xa5, 0x16, 0x65, 0xa6, 0x65, 0x26, 0x27, 0x96, 0x64, 0xe6, - 0xe7, 0xc5, 0xa7, 0xe5, 0x24, 0xa6, 0x17, 0x43, 0x54, 0x29, 0x45, 0x71, 0x49, 0xf9, 0x16, 0xa7, - 0xbb, 0xe6, 0x25, 0x26, 0xe5, 0xa4, 0x86, 0x21, 0x29, 0x72, 0x03, 0xa9, 0x11, 0x92, 0xe0, 0x62, - 0x4f, 0x2e, 0x4a, 0x4d, 0x2c, 0xc9, 0x2f, 0x92, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x0c, 0x82, 0x71, - 0x85, 0x94, 0xb8, 0x78, 0xc1, 0x2e, 0x8a, 0xcf, 0x4c, 0x89, 0xcf, 0xc9, 0x2c, 0x2e, 0x91, 0x60, - 0x52, 0x60, 0xd6, 0x60, 0x0e, 0xe2, 0x06, 0x0b, 0x7a, 0xa6, 0xf8, 0x64, 0x16, 0x97, 0x28, 0xa9, - 0x70, 0x29, 0xe1, 0x36, 0x3b, 0x28, 0xb5, 0xb8, 0x20, 0x3f, 0xaf, 0x38, 0x55, 0x29, 0x9a, 0x4b, - 0xda, 0xb7, 0x38, 0xdd, 0x25, 0xb3, 0x98, 0x16, 0x4e, 0x50, 0xe5, 0x52, 0xc6, 0x63, 0x38, 0xcc, - 0x0d, 0x46, 0x07, 0x98, 0xb8, 0x98, 0x7d, 0x8b, 0xd3, 0x85, 0x66, 0x32, 0x72, 0x89, 0xe3, 0x0a, - 0x0b, 0x2b, 0x3d, 0xfc, 0xd1, 0xa0, 0x87, 0xdb, 0xaf, 0x52, 0x4e, 0xe4, 0xeb, 0x85, 0xb9, 0x51, - 0x68, 0x0e, 0x23, 0x97, 0x04, 0xce, 0x50, 0xb2, 0x26, 0xc2, 0x02, 0x5c, 0x9a, 0xa5, 0x9c, 0x29, - 0xd0, 0x0c, 0x73, 0x9e, 0x93, 0xcf, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, - 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, - 0x19, 0xa5, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x83, 0x8c, 0xd7, 0x05, - 0xdb, 0xa4, 0x0f, 0xb3, 0x49, 0xbf, 0x42, 0x1f, 0x25, 0xd5, 0x57, 0x16, 0xa4, 0x16, 0x27, 0xb1, - 0x81, 0x53, 0xa7, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x0d, 0xfc, 0x84, 0x07, 0x11, 0x03, 0x00, - 0x00, + 0xe7, 0xc5, 0xa7, 0xe5, 0x24, 0xa6, 0x17, 0x43, 0x54, 0x29, 0x45, 0x73, 0x49, 0xfb, 0x16, 0xa7, + 0xbb, 0xe6, 0x25, 0x26, 0xe5, 0xa4, 0x7a, 0xa4, 0x26, 0xa6, 0xa4, 0x16, 0x85, 0x21, 0x29, 0x15, + 0x92, 0xe0, 0x62, 0x4f, 0x2e, 0x4a, 0x4d, 0x2c, 0xc9, 0x2f, 0x92, 0x60, 0x54, 0x60, 0xd4, 0xe0, + 0x0c, 0x82, 0x71, 0x85, 0x94, 0xb8, 0x78, 0xc1, 0x4e, 0x8a, 0xcf, 0x4c, 0x89, 0xcf, 0xc9, 0x2c, + 0x2e, 0x91, 0x60, 0x52, 0x60, 0xd6, 0x60, 0x0e, 0xe2, 0x06, 0x0b, 0x7a, 0xa6, 0xf8, 0x64, 0x16, + 0x97, 0x28, 0xa9, 0x72, 0x29, 0xe3, 0x31, 0x3c, 0x28, 0xb5, 0xb8, 0x20, 0x3f, 0xaf, 0x38, 0x55, + 0x29, 0x86, 0x4b, 0xc6, 0xb7, 0x38, 0xdd, 0x25, 0xb3, 0x98, 0x26, 0x8e, 0x50, 0xe3, 0x52, 0xc1, + 0x67, 0x3a, 0xcc, 0x15, 0x46, 0xc7, 0x98, 0xb8, 0x98, 0x7d, 0x8b, 0xd3, 0x85, 0xe6, 0x30, 0x72, + 0x49, 0xe0, 0x0c, 0x0f, 0x6b, 0x3d, 0xfc, 0x71, 0xa1, 0x87, 0xc7, 0xbf, 0x52, 0xce, 0x14, 0x68, + 0x86, 0x39, 0x53, 0x68, 0x3e, 0x23, 0x97, 0x24, 0xee, 0xa0, 0xb2, 0x21, 0xc2, 0x0a, 0x9c, 0xba, + 0xa5, 0x5c, 0x28, 0xd1, 0x0d, 0x73, 0xa1, 0x93, 0xcf, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, + 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, + 0xcb, 0x31, 0x44, 0x19, 0xa5, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x83, + 0xcc, 0xd7, 0x05, 0x5b, 0xa5, 0x0f, 0xb3, 0x4a, 0xbf, 0x42, 0x1f, 0x25, 0xfd, 0x57, 0x16, 0xa4, + 0x16, 0x27, 0xb1, 0x81, 0xd3, 0xa9, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x23, 0x96, 0x87, 0x88, + 0x1b, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -251,8 +251,8 @@ const _ = grpc.SupportPackageIsVersion4 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type MsgClient interface { - EnableVerificationFlags(ctx context.Context, in *MsgEnableVerificationFlags, opts ...grpc.CallOption) (*MsgEnableVerificationFlagsResponse, error) - DisableVerificationFlags(ctx context.Context, in *MsgDisableVerificationFlags, opts ...grpc.CallOption) (*MsgDisableVerificationFlagsResponse, error) + EnableHeaderVerification(ctx context.Context, in *MsgEnableHeaderVerification, opts ...grpc.CallOption) (*MsgEnableHeaderVerificationResponse, error) + DisableHeaderVerification(ctx context.Context, in *MsgDisableHeaderVerification, opts ...grpc.CallOption) (*MsgDisableHeaderVerificationResponse, error) } type msgClient struct { @@ -263,18 +263,18 @@ func NewMsgClient(cc grpc1.ClientConn) MsgClient { return &msgClient{cc} } -func (c *msgClient) EnableVerificationFlags(ctx context.Context, in *MsgEnableVerificationFlags, opts ...grpc.CallOption) (*MsgEnableVerificationFlagsResponse, error) { - out := new(MsgEnableVerificationFlagsResponse) - err := c.cc.Invoke(ctx, "/zetachain.zetacore.lightclient.Msg/EnableVerificationFlags", in, out, opts...) +func (c *msgClient) EnableHeaderVerification(ctx context.Context, in *MsgEnableHeaderVerification, opts ...grpc.CallOption) (*MsgEnableHeaderVerificationResponse, error) { + out := new(MsgEnableHeaderVerificationResponse) + err := c.cc.Invoke(ctx, "/zetachain.zetacore.lightclient.Msg/EnableHeaderVerification", in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *msgClient) DisableVerificationFlags(ctx context.Context, in *MsgDisableVerificationFlags, opts ...grpc.CallOption) (*MsgDisableVerificationFlagsResponse, error) { - out := new(MsgDisableVerificationFlagsResponse) - err := c.cc.Invoke(ctx, "/zetachain.zetacore.lightclient.Msg/DisableVerificationFlags", in, out, opts...) +func (c *msgClient) DisableHeaderVerification(ctx context.Context, in *MsgDisableHeaderVerification, opts ...grpc.CallOption) (*MsgDisableHeaderVerificationResponse, error) { + out := new(MsgDisableHeaderVerificationResponse) + err := c.cc.Invoke(ctx, "/zetachain.zetacore.lightclient.Msg/DisableHeaderVerification", in, out, opts...) if err != nil { return nil, err } @@ -283,57 +283,57 @@ func (c *msgClient) DisableVerificationFlags(ctx context.Context, in *MsgDisable // MsgServer is the server API for Msg service. type MsgServer interface { - EnableVerificationFlags(context.Context, *MsgEnableVerificationFlags) (*MsgEnableVerificationFlagsResponse, error) - DisableVerificationFlags(context.Context, *MsgDisableVerificationFlags) (*MsgDisableVerificationFlagsResponse, error) + EnableHeaderVerification(context.Context, *MsgEnableHeaderVerification) (*MsgEnableHeaderVerificationResponse, error) + DisableHeaderVerification(context.Context, *MsgDisableHeaderVerification) (*MsgDisableHeaderVerificationResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. type UnimplementedMsgServer struct { } -func (*UnimplementedMsgServer) EnableVerificationFlags(ctx context.Context, req *MsgEnableVerificationFlags) (*MsgEnableVerificationFlagsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method EnableVerificationFlags not implemented") +func (*UnimplementedMsgServer) EnableHeaderVerification(ctx context.Context, req *MsgEnableHeaderVerification) (*MsgEnableHeaderVerificationResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method EnableHeaderVerification not implemented") } -func (*UnimplementedMsgServer) DisableVerificationFlags(ctx context.Context, req *MsgDisableVerificationFlags) (*MsgDisableVerificationFlagsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method DisableVerificationFlags not implemented") +func (*UnimplementedMsgServer) DisableHeaderVerification(ctx context.Context, req *MsgDisableHeaderVerification) (*MsgDisableHeaderVerificationResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DisableHeaderVerification not implemented") } func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) } -func _Msg_EnableVerificationFlags_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgEnableVerificationFlags) +func _Msg_EnableHeaderVerification_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgEnableHeaderVerification) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(MsgServer).EnableVerificationFlags(ctx, in) + return srv.(MsgServer).EnableHeaderVerification(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/zetachain.zetacore.lightclient.Msg/EnableVerificationFlags", + FullMethod: "/zetachain.zetacore.lightclient.Msg/EnableHeaderVerification", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).EnableVerificationFlags(ctx, req.(*MsgEnableVerificationFlags)) + return srv.(MsgServer).EnableHeaderVerification(ctx, req.(*MsgEnableHeaderVerification)) } return interceptor(ctx, in, info, handler) } -func _Msg_DisableVerificationFlags_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgDisableVerificationFlags) +func _Msg_DisableHeaderVerification_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgDisableHeaderVerification) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(MsgServer).DisableVerificationFlags(ctx, in) + return srv.(MsgServer).DisableHeaderVerification(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/zetachain.zetacore.lightclient.Msg/DisableVerificationFlags", + FullMethod: "/zetachain.zetacore.lightclient.Msg/DisableHeaderVerification", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).DisableVerificationFlags(ctx, req.(*MsgDisableVerificationFlags)) + return srv.(MsgServer).DisableHeaderVerification(ctx, req.(*MsgDisableHeaderVerification)) } return interceptor(ctx, in, info, handler) } @@ -343,19 +343,19 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ HandlerType: (*MsgServer)(nil), Methods: []grpc.MethodDesc{ { - MethodName: "EnableVerificationFlags", - Handler: _Msg_EnableVerificationFlags_Handler, + MethodName: "EnableHeaderVerification", + Handler: _Msg_EnableHeaderVerification_Handler, }, { - MethodName: "DisableVerificationFlags", - Handler: _Msg_DisableVerificationFlags_Handler, + MethodName: "DisableHeaderVerification", + Handler: _Msg_DisableHeaderVerification_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "lightclient/tx.proto", } -func (m *MsgEnableVerificationFlags) Marshal() (dAtA []byte, err error) { +func (m *MsgEnableHeaderVerification) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -365,12 +365,12 @@ func (m *MsgEnableVerificationFlags) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgEnableVerificationFlags) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgEnableHeaderVerification) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgEnableVerificationFlags) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgEnableHeaderVerification) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -404,7 +404,7 @@ func (m *MsgEnableVerificationFlags) MarshalToSizedBuffer(dAtA []byte) (int, err return len(dAtA) - i, nil } -func (m *MsgEnableVerificationFlagsResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgEnableHeaderVerificationResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -414,12 +414,12 @@ func (m *MsgEnableVerificationFlagsResponse) Marshal() (dAtA []byte, err error) return dAtA[:n], nil } -func (m *MsgEnableVerificationFlagsResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgEnableHeaderVerificationResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgEnableVerificationFlagsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgEnableHeaderVerificationResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -427,7 +427,7 @@ func (m *MsgEnableVerificationFlagsResponse) MarshalToSizedBuffer(dAtA []byte) ( return len(dAtA) - i, nil } -func (m *MsgDisableVerificationFlags) Marshal() (dAtA []byte, err error) { +func (m *MsgDisableHeaderVerification) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -437,12 +437,12 @@ func (m *MsgDisableVerificationFlags) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgDisableVerificationFlags) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgDisableHeaderVerification) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgDisableVerificationFlags) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgDisableHeaderVerification) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -476,7 +476,7 @@ func (m *MsgDisableVerificationFlags) MarshalToSizedBuffer(dAtA []byte) (int, er return len(dAtA) - i, nil } -func (m *MsgDisableVerificationFlagsResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgDisableHeaderVerificationResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -486,12 +486,12 @@ func (m *MsgDisableVerificationFlagsResponse) Marshal() (dAtA []byte, err error) return dAtA[:n], nil } -func (m *MsgDisableVerificationFlagsResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgDisableHeaderVerificationResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgDisableVerificationFlagsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgDisableHeaderVerificationResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -510,7 +510,7 @@ func encodeVarintTx(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *MsgEnableVerificationFlags) Size() (n int) { +func (m *MsgEnableHeaderVerification) Size() (n int) { if m == nil { return 0 } @@ -530,7 +530,7 @@ func (m *MsgEnableVerificationFlags) Size() (n int) { return n } -func (m *MsgEnableVerificationFlagsResponse) Size() (n int) { +func (m *MsgEnableHeaderVerificationResponse) Size() (n int) { if m == nil { return 0 } @@ -539,7 +539,7 @@ func (m *MsgEnableVerificationFlagsResponse) Size() (n int) { return n } -func (m *MsgDisableVerificationFlags) Size() (n int) { +func (m *MsgDisableHeaderVerification) Size() (n int) { if m == nil { return 0 } @@ -559,7 +559,7 @@ func (m *MsgDisableVerificationFlags) Size() (n int) { return n } -func (m *MsgDisableVerificationFlagsResponse) Size() (n int) { +func (m *MsgDisableHeaderVerificationResponse) Size() (n int) { if m == nil { return 0 } @@ -574,7 +574,7 @@ func sovTx(x uint64) (n int) { func sozTx(x uint64) (n int) { return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *MsgEnableVerificationFlags) Unmarshal(dAtA []byte) error { +func (m *MsgEnableHeaderVerification) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -597,10 +597,10 @@ func (m *MsgEnableVerificationFlags) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgEnableVerificationFlags: wiretype end group for non-group") + return fmt.Errorf("proto: MsgEnableHeaderVerification: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgEnableVerificationFlags: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgEnableHeaderVerification: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -732,7 +732,7 @@ func (m *MsgEnableVerificationFlags) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgEnableVerificationFlagsResponse) Unmarshal(dAtA []byte) error { +func (m *MsgEnableHeaderVerificationResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -755,10 +755,10 @@ func (m *MsgEnableVerificationFlagsResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgEnableVerificationFlagsResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgEnableHeaderVerificationResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgEnableVerificationFlagsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgEnableHeaderVerificationResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: @@ -782,7 +782,7 @@ func (m *MsgEnableVerificationFlagsResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgDisableVerificationFlags) Unmarshal(dAtA []byte) error { +func (m *MsgDisableHeaderVerification) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -805,10 +805,10 @@ func (m *MsgDisableVerificationFlags) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgDisableVerificationFlags: wiretype end group for non-group") + return fmt.Errorf("proto: MsgDisableHeaderVerification: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgDisableVerificationFlags: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgDisableHeaderVerification: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -940,7 +940,7 @@ func (m *MsgDisableVerificationFlags) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgDisableVerificationFlagsResponse) Unmarshal(dAtA []byte) error { +func (m *MsgDisableHeaderVerificationResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -963,10 +963,10 @@ func (m *MsgDisableVerificationFlagsResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgDisableVerificationFlagsResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgDisableHeaderVerificationResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgDisableVerificationFlagsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgDisableHeaderVerificationResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: diff --git a/x/lightclient/types/verification_flags.go b/x/lightclient/types/verification_flags.go index de3aa1aa93..6430cf1cdb 100644 --- a/x/lightclient/types/verification_flags.go +++ b/x/lightclient/types/verification_flags.go @@ -2,10 +2,16 @@ package types import "github.com/zeta-chain/zetacore/pkg/chains" +func DefaultBlockHeaderVerification() BlockHeaderVerification { + return BlockHeaderVerification{ + EnabledChains: DefaultVerificationFlags(), + } +} + // DefaultVerificationFlags returns the default verification flags. // By default, everything disabled. -func DefaultVerificationFlags() []VerificationFlags { - return []VerificationFlags{ +func DefaultVerificationFlags() []EnabledChain { + return []EnabledChain{ { ChainId: chains.EthChain.ChainId, Enabled: false, diff --git a/x/lightclient/types/verification_flags.pb.go b/x/lightclient/types/verification_flags.pb.go index ad6a724f2a..6c1eccaf60 100644 --- a/x/lightclient/types/verification_flags.pb.go +++ b/x/lightclient/types/verification_flags.pb.go @@ -25,23 +25,23 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // VerificationFlags is a structure containing information of weather a chain is enabled or not for block header verification -type VerificationFlags struct { +type EnabledChain struct { ChainId int64 `protobuf:"varint,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` Enabled bool `protobuf:"varint,2,opt,name=enabled,proto3" json:"enabled,omitempty"` } -func (m *VerificationFlags) Reset() { *m = VerificationFlags{} } -func (m *VerificationFlags) String() string { return proto.CompactTextString(m) } -func (*VerificationFlags) ProtoMessage() {} -func (*VerificationFlags) Descriptor() ([]byte, []int) { +func (m *EnabledChain) Reset() { *m = EnabledChain{} } +func (m *EnabledChain) String() string { return proto.CompactTextString(m) } +func (*EnabledChain) ProtoMessage() {} +func (*EnabledChain) Descriptor() ([]byte, []int) { return fileDescriptor_86eae6d737b3f8cc, []int{0} } -func (m *VerificationFlags) XXX_Unmarshal(b []byte) error { +func (m *EnabledChain) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *VerificationFlags) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *EnabledChain) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_VerificationFlags.Marshal(b, m, deterministic) + return xxx_messageInfo_EnabledChain.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -51,34 +51,79 @@ func (m *VerificationFlags) XXX_Marshal(b []byte, deterministic bool) ([]byte, e return b[:n], nil } } -func (m *VerificationFlags) XXX_Merge(src proto.Message) { - xxx_messageInfo_VerificationFlags.Merge(m, src) +func (m *EnabledChain) XXX_Merge(src proto.Message) { + xxx_messageInfo_EnabledChain.Merge(m, src) } -func (m *VerificationFlags) XXX_Size() int { +func (m *EnabledChain) XXX_Size() int { return m.Size() } -func (m *VerificationFlags) XXX_DiscardUnknown() { - xxx_messageInfo_VerificationFlags.DiscardUnknown(m) +func (m *EnabledChain) XXX_DiscardUnknown() { + xxx_messageInfo_EnabledChain.DiscardUnknown(m) } -var xxx_messageInfo_VerificationFlags proto.InternalMessageInfo +var xxx_messageInfo_EnabledChain proto.InternalMessageInfo -func (m *VerificationFlags) GetChainId() int64 { +func (m *EnabledChain) GetChainId() int64 { if m != nil { return m.ChainId } return 0 } -func (m *VerificationFlags) GetEnabled() bool { +func (m *EnabledChain) GetEnabled() bool { if m != nil { return m.Enabled } return false } +type BlockHeaderVerification struct { + EnabledChains []EnabledChain `protobuf:"bytes,1,rep,name=enabled_chains,json=enabledChains,proto3" json:"enabled_chains"` +} + +func (m *BlockHeaderVerification) Reset() { *m = BlockHeaderVerification{} } +func (m *BlockHeaderVerification) String() string { return proto.CompactTextString(m) } +func (*BlockHeaderVerification) ProtoMessage() {} +func (*BlockHeaderVerification) Descriptor() ([]byte, []int) { + return fileDescriptor_86eae6d737b3f8cc, []int{1} +} +func (m *BlockHeaderVerification) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *BlockHeaderVerification) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_BlockHeaderVerification.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *BlockHeaderVerification) XXX_Merge(src proto.Message) { + xxx_messageInfo_BlockHeaderVerification.Merge(m, src) +} +func (m *BlockHeaderVerification) XXX_Size() int { + return m.Size() +} +func (m *BlockHeaderVerification) XXX_DiscardUnknown() { + xxx_messageInfo_BlockHeaderVerification.DiscardUnknown(m) +} + +var xxx_messageInfo_BlockHeaderVerification proto.InternalMessageInfo + +func (m *BlockHeaderVerification) GetEnabledChains() []EnabledChain { + if m != nil { + return m.EnabledChains + } + return nil +} + func init() { - proto.RegisterType((*VerificationFlags)(nil), "zetachain.zetacore.lightclient.VerificationFlags") + proto.RegisterType((*EnabledChain)(nil), "zetachain.zetacore.lightclient.EnabledChain") + proto.RegisterType((*BlockHeaderVerification)(nil), "zetachain.zetacore.lightclient.BlockHeaderVerification") } func init() { @@ -86,24 +131,27 @@ func init() { } var fileDescriptor_86eae6d737b3f8cc = []byte{ - // 210 bytes of a gzipped FileDescriptorProto + // 266 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xc9, 0xc9, 0x4c, 0xcf, 0x28, 0x49, 0xce, 0xc9, 0x4c, 0xcd, 0x2b, 0xd1, 0x2f, 0x4b, 0x2d, 0xca, 0x4c, 0xcb, 0x4c, 0x4e, 0x2c, 0xc9, 0xcc, 0xcf, 0x8b, 0x4f, 0xcb, 0x49, 0x4c, 0x2f, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0xab, 0x4a, 0x2d, 0x49, 0x4c, 0xce, 0x48, 0xcc, 0xcc, 0xd3, 0x03, 0xb3, 0xf2, 0x8b, 0x52, 0xf5, 0x90, 0x34, 0x4a, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0x95, 0xea, 0x83, 0x58, 0x10, - 0x5d, 0x4a, 0x1e, 0x5c, 0x82, 0x61, 0x48, 0x26, 0xba, 0x81, 0x0c, 0x14, 0x92, 0xe4, 0xe2, 0x00, - 0x1b, 0x14, 0x9f, 0x99, 0x22, 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, 0x1c, 0xc4, 0x0e, 0xe6, 0x7b, 0xa6, - 0x08, 0x49, 0x70, 0xb1, 0xa7, 0xe6, 0x25, 0x26, 0xe5, 0xa4, 0xa6, 0x48, 0x30, 0x29, 0x30, 0x6a, - 0x70, 0x04, 0xc1, 0xb8, 0x4e, 0x3e, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, - 0x91, 0x1c, 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, 0x10, - 0x65, 0x94, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0x0f, 0x72, 0x9a, 0x2e, - 0xd8, 0x30, 0x7d, 0x98, 0x2b, 0xf5, 0x2b, 0xf4, 0x91, 0x3d, 0x58, 0x52, 0x59, 0x90, 0x5a, 0x9c, - 0xc4, 0x06, 0x76, 0x9e, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0xd3, 0x77, 0xd4, 0x9b, 0xfc, 0x00, - 0x00, 0x00, + 0x5d, 0x4a, 0xce, 0x5c, 0x3c, 0xae, 0x79, 0x89, 0x49, 0x39, 0xa9, 0x29, 0xce, 0x20, 0xad, 0x42, + 0x92, 0x5c, 0x1c, 0x60, 0x33, 0xe2, 0x33, 0x53, 0x24, 0x18, 0x15, 0x18, 0x35, 0x98, 0x83, 0xd8, + 0xc1, 0x7c, 0xcf, 0x14, 0x21, 0x09, 0x2e, 0xf6, 0x54, 0x88, 0x52, 0x09, 0x26, 0x05, 0x46, 0x0d, + 0x8e, 0x20, 0x18, 0x57, 0xa9, 0x84, 0x4b, 0xdc, 0x29, 0x27, 0x3f, 0x39, 0xdb, 0x23, 0x35, 0x31, + 0x25, 0xb5, 0x28, 0x0c, 0xc9, 0x85, 0x42, 0x91, 0x5c, 0x7c, 0x50, 0x55, 0xf1, 0x60, 0x73, 0x8a, + 0x25, 0x18, 0x15, 0x98, 0x35, 0xb8, 0x8d, 0x74, 0xf4, 0xf0, 0x3b, 0x57, 0x0f, 0xd9, 0x55, 0x4e, + 0x2c, 0x27, 0xee, 0xc9, 0x33, 0x04, 0xf1, 0xa6, 0x22, 0x89, 0x15, 0x3b, 0xf9, 0x9c, 0x78, 0x24, + 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, + 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x51, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, + 0x72, 0x7e, 0xae, 0x3e, 0xc8, 0x70, 0x5d, 0xb0, 0x3d, 0xfa, 0x30, 0x7b, 0xf4, 0x2b, 0xf4, 0x91, + 0x43, 0xb4, 0xa4, 0xb2, 0x20, 0xb5, 0x38, 0x89, 0x0d, 0x1c, 0x1e, 0xc6, 0x80, 0x00, 0x00, 0x00, + 0xff, 0xff, 0xc2, 0x8d, 0x20, 0x39, 0x6d, 0x01, 0x00, 0x00, } -func (m *VerificationFlags) Marshal() (dAtA []byte, err error) { +func (m *EnabledChain) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -113,12 +161,12 @@ func (m *VerificationFlags) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *VerificationFlags) MarshalTo(dAtA []byte) (int, error) { +func (m *EnabledChain) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *VerificationFlags) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *EnabledChain) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -141,6 +189,43 @@ func (m *VerificationFlags) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *BlockHeaderVerification) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *BlockHeaderVerification) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *BlockHeaderVerification) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.EnabledChains) > 0 { + for iNdEx := len(m.EnabledChains) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.EnabledChains[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintVerificationFlags(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + func encodeVarintVerificationFlags(dAtA []byte, offset int, v uint64) int { offset -= sovVerificationFlags(v) base := offset @@ -152,7 +237,7 @@ func encodeVarintVerificationFlags(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *VerificationFlags) Size() (n int) { +func (m *EnabledChain) Size() (n int) { if m == nil { return 0 } @@ -167,13 +252,28 @@ func (m *VerificationFlags) Size() (n int) { return n } +func (m *BlockHeaderVerification) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.EnabledChains) > 0 { + for _, e := range m.EnabledChains { + l = e.Size() + n += 1 + l + sovVerificationFlags(uint64(l)) + } + } + return n +} + func sovVerificationFlags(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } func sozVerificationFlags(x uint64) (n int) { return sovVerificationFlags(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *VerificationFlags) Unmarshal(dAtA []byte) error { +func (m *EnabledChain) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -196,10 +296,10 @@ func (m *VerificationFlags) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: VerificationFlags: wiretype end group for non-group") + return fmt.Errorf("proto: EnabledChain: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: VerificationFlags: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: EnabledChain: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -262,6 +362,90 @@ func (m *VerificationFlags) Unmarshal(dAtA []byte) error { } return nil } +func (m *BlockHeaderVerification) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVerificationFlags + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: BlockHeaderVerification: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: BlockHeaderVerification: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EnabledChains", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVerificationFlags + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthVerificationFlags + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthVerificationFlags + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.EnabledChains = append(m.EnabledChains, EnabledChain{}) + if err := m.EnabledChains[len(m.EnabledChains)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipVerificationFlags(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthVerificationFlags + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipVerificationFlags(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/zetaclient/core_context/zeta_core_context.go b/zetaclient/core_context/zeta_core_context.go index 4dd682dd84..7133f47acf 100644 --- a/zetaclient/core_context/zeta_core_context.go +++ b/zetaclient/core_context/zeta_core_context.go @@ -24,8 +24,8 @@ type ZetaCoreContext struct { currentTssPubkey string crossChainFlags observertypes.CrosschainFlags - // verificationFlags is used to store the verification flags for the lightclient module to enable header/proof verification - verificationFlags []lightclienttypes.VerificationFlags + // blockHeaderEnabledChains is used to store the list of chains that have block header verification enabled + blockHeaderEnabledChains []lightclienttypes.EnabledChain } // NewZetaCoreContext creates and returns new ZetaCoreContext @@ -43,12 +43,12 @@ func NewZetaCoreContext(cfg config.Config) *ZetaCoreContext { } return &ZetaCoreContext{ - coreContextLock: new(sync.RWMutex), - chainsEnabled: []chains.Chain{}, - evmChainParams: evmChainParams, - bitcoinChainParams: bitcoinChainParams, - crossChainFlags: observertypes.CrosschainFlags{}, - verificationFlags: []lightclienttypes.VerificationFlags{}, + coreContextLock: new(sync.RWMutex), + chainsEnabled: []chains.Chain{}, + evmChainParams: evmChainParams, + bitcoinChainParams: bitcoinChainParams, + crossChainFlags: observertypes.CrosschainFlags{}, + blockHeaderEnabledChains: []lightclienttypes.EnabledChain{}, } } @@ -126,22 +126,22 @@ func (c *ZetaCoreContext) GetCrossChainFlags() observertypes.CrosschainFlags { } // GetAllVerificationFlags returns all verification flags -func (c *ZetaCoreContext) GetAllVerificationFlags() []lightclienttypes.VerificationFlags { +func (c *ZetaCoreContext) GetAllVerificationFlags() []lightclienttypes.EnabledChain { c.coreContextLock.RLock() defer c.coreContextLock.RUnlock() - return c.verificationFlags + return c.blockHeaderEnabledChains } // GetVerificationFlags returns verification flags for a chain -func (c *ZetaCoreContext) GetVerificationFlags(chainID int64) (lightclienttypes.VerificationFlags, bool) { +func (c *ZetaCoreContext) GetVerificationFlags(chainID int64) (lightclienttypes.EnabledChain, bool) { c.coreContextLock.RLock() defer c.coreContextLock.RUnlock() - for _, flags := range c.verificationFlags { + for _, flags := range c.blockHeaderEnabledChains { if flags.ChainId == chainID { return flags, true } } - return lightclienttypes.VerificationFlags{}, false + return lightclienttypes.EnabledChain{}, false } // Update updates core context and params for all chains @@ -153,7 +153,7 @@ func (c *ZetaCoreContext) Update( btcChainParams *observertypes.ChainParams, tssPubKey string, crosschainFlags observertypes.CrosschainFlags, - verificationFlags []lightclienttypes.VerificationFlags, + verificationFlags []lightclienttypes.EnabledChain, init bool, logger zerolog.Logger, ) { @@ -196,7 +196,7 @@ func (c *ZetaCoreContext) Update( c.chainsEnabled = newChains c.crossChainFlags = crosschainFlags - c.verificationFlags = verificationFlags + c.blockHeaderEnabledChains = verificationFlags // update chain params for bitcoin if it has config in file if c.bitcoinChainParams != nil && btcChainParams != nil { diff --git a/zetaclient/core_context/zeta_core_context_test.go b/zetaclient/core_context/zeta_core_context_test.go index bbfd23f311..6e517571d9 100644 --- a/zetaclient/core_context/zeta_core_context_test.go +++ b/zetaclient/core_context/zeta_core_context_test.go @@ -28,7 +28,7 @@ func getTestCoreContext( evmChain chains.Chain, evmChainParams *observertypes.ChainParams, ccFlags observertypes.CrosschainFlags, - verificationFlags []lightclienttypes.VerificationFlags, + verificationFlags []lightclienttypes.EnabledChain, ) *corecontext.ZetaCoreContext { // create config cfg := config.NewConfig() diff --git a/zetaclient/zetabridge/query.go b/zetaclient/zetabridge/query.go index 31cb82aeaa..89b097aefd 100644 --- a/zetaclient/zetabridge/query.go +++ b/zetaclient/zetabridge/query.go @@ -33,13 +33,13 @@ func (b *ZetaCoreBridge) GetCrosschainFlags() (observertypes.CrosschainFlags, er return resp.CrosschainFlags, nil } -func (b *ZetaCoreBridge) GetVerificationFlags() ([]lightclienttypes.VerificationFlags, error) { +func (b *ZetaCoreBridge) GetBlockHeaderEnabledChains() ([]lightclienttypes.EnabledChain, error) { client := lightclienttypes.NewQueryClient(b.grpcConn) - resp, err := client.VerificationFlags(context.Background(), &lightclienttypes.QueryVerificationFlagsRequest{}) + resp, err := client.HeaderEnabledChains(context.Background(), &lightclienttypes.QueryHeaderEnabledChainsRequest{}) if err != nil { - return []lightclienttypes.VerificationFlags{}, err + return []lightclienttypes.EnabledChain{}, err } - return resp.VerificationFlags, nil + return resp.EnabledChains, nil } func (b *ZetaCoreBridge) GetChainParamsForChainID(externalChainID int64) (*observertypes.ChainParams, error) { diff --git a/zetaclient/zetabridge/query_test.go b/zetaclient/zetabridge/query_test.go index 3ff68d89ef..68c254cb96 100644 --- a/zetaclient/zetabridge/query_test.go +++ b/zetaclient/zetabridge/query_test.go @@ -102,8 +102,8 @@ func TestZetaCoreBridge_GetCrosschainFlags(t *testing.T) { require.Equal(t, expectedOutput.CrosschainFlags, resp) } -func TestZetaCoreBridge_GetVerificationFlags(t *testing.T) { - expectedOutput := lightclienttypes.QueryVerificationFlagsResponse{VerificationFlags: []lightclienttypes.VerificationFlags{ +func TestZetaCoreBridge_HeaderEnabledChains(t *testing.T) { + expectedOutput := lightclienttypes.QueryHeaderEnabledChainsResponse{EnabledChains: []lightclienttypes.EnabledChain{ { ChainId: chains.EthChain.ChainId, Enabled: true, @@ -113,8 +113,8 @@ func TestZetaCoreBridge_GetVerificationFlags(t *testing.T) { Enabled: true, }, }} - input := lightclienttypes.QueryVerificationFlagsRequest{} - method := "/zetachain.zetacore.lightclient.Query/VerificationFlags" + input := lightclienttypes.QueryHeaderEnabledChainsRequest{} + method := "/zetachain.zetacore.lightclient.Query/HeaderEnabledChains" server := setupMockServer(t, lightclienttypes.RegisterQueryServer, method, input, expectedOutput) server.Serve() defer closeMockServer(t, server) @@ -122,9 +122,9 @@ func TestZetaCoreBridge_GetVerificationFlags(t *testing.T) { zetabridge, err := setupCoreBridge() require.NoError(t, err) - resp, err := zetabridge.GetVerificationFlags() + resp, err := zetabridge.GetBlockHeaderEnabledChains() require.NoError(t, err) - require.Equal(t, expectedOutput.VerificationFlags, resp) + require.Equal(t, expectedOutput.EnabledChains, resp) } func TestZetaCoreBridge_GetChainParamsForChainID(t *testing.T) { diff --git a/zetaclient/zetabridge/tx_test.go b/zetaclient/zetabridge/tx_test.go index 2fa2473abd..c99c5db7d4 100644 --- a/zetaclient/zetabridge/tx_test.go +++ b/zetaclient/zetabridge/tx_test.go @@ -303,11 +303,11 @@ func TestZetaCoreBridge_UpdateZetaCoreContext(t *testing.T) { BlockHeaderVerificationFlags: nil, }}) - method = "/zetachain.zetacore.lightclient.Query/VerificationFlags" + method = "/zetachain.zetacore.lightclient.Query/HeaderEnabledChains" s.ExpectUnary(method). UnlimitedTimes(). - WithPayload(lightclienttypes.QueryVerificationFlagsRequest{}). - Return(lightclienttypes.QueryVerificationFlagsResponse{VerificationFlags: []lightclienttypes.VerificationFlags{ + WithPayload(lightclienttypes.QueryHeaderEnabledChainsRequest{}). + Return(lightclienttypes.QueryHeaderEnabledChainsResponse{EnabledChains: []lightclienttypes.EnabledChain{ { ChainId: chains.EthChain.ChainId, Enabled: true, diff --git a/zetaclient/zetabridge/zetacore_bridge.go b/zetaclient/zetabridge/zetacore_bridge.go index 5da5b592f1..f47e000027 100644 --- a/zetaclient/zetabridge/zetacore_bridge.go +++ b/zetaclient/zetabridge/zetacore_bridge.go @@ -251,9 +251,9 @@ func (b *ZetaCoreBridge) UpdateZetaCoreContext(coreContext *corecontext.ZetaCore return err } - verificationFlags, err := b.GetVerificationFlags() + blockHeaderEnabledChains, err := b.GetBlockHeaderEnabledChains() if err != nil { - b.logger.Info().Msg("Unable to fetch verification flags from zetabridge") + b.logger.Info().Msg("Unable to fetch block header enabled chains from zetabridge") return err } @@ -264,7 +264,7 @@ func (b *ZetaCoreBridge) UpdateZetaCoreContext(coreContext *corecontext.ZetaCore newBTCParams, tssPubKey, crosschainFlags, - verificationFlags, + blockHeaderEnabledChains, init, b.logger, ) From 361c07a853d3d0d2fb5700f48e25bcec8fe1ac3a Mon Sep 17 00:00:00 2001 From: Tanmay Date: Tue, 30 Apr 2024 18:25:33 -0400 Subject: [PATCH 23/31] add unit tests for block header verification --- .../types/block_header_verification_test.go | 43 ++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/x/lightclient/types/block_header_verification_test.go b/x/lightclient/types/block_header_verification_test.go index f8543306c8..a470a62ca0 100644 --- a/x/lightclient/types/block_header_verification_test.go +++ b/x/lightclient/types/block_header_verification_test.go @@ -6,12 +6,53 @@ import ( "github.com/stretchr/testify/require" "github.com/zeta-chain/zetacore/pkg/chains" "github.com/zeta-chain/zetacore/testutil/sample" + "github.com/zeta-chain/zetacore/x/lightclient/types" ) func TestBlockHeaderVerification_EnableChain(t *testing.T) { - t.Run("should enable chain", func(t *testing.T) { + t.Run("should enable chain if chain not present", func(t *testing.T) { bhv := sample.BlockHeaderVerification() bhv.EnableChain(chains.BscMainnetChain.ChainId) require.True(t, bhv.IsChainEnabled(chains.BscMainnetChain.ChainId)) }) + + t.Run("should not enable chain is present", func(t *testing.T) { + bhv := types.BlockHeaderVerification{ + EnabledChains: []types.EnabledChain{{ChainId: chains.BscMainnetChain.ChainId, Enabled: false}}} + bhv.EnableChain(chains.BscMainnetChain.ChainId) + require.True(t, bhv.IsChainEnabled(chains.BscMainnetChain.ChainId)) + }) +} + +func TestBlockHeaderVerification_DisableChain(t *testing.T) { + t.Run("should disable chain if chain not present", func(t *testing.T) { + bhv := sample.BlockHeaderVerification() + bhv.DisableChain(chains.BscMainnetChain.ChainId) + require.False(t, bhv.IsChainEnabled(chains.BscMainnetChain.ChainId)) + }) + + t.Run("should disable chain if chain present", func(t *testing.T) { + bhv := types.BlockHeaderVerification{ + EnabledChains: []types.EnabledChain{{ChainId: chains.BscMainnetChain.ChainId, Enabled: true}}} + bhv.DisableChain(chains.BscMainnetChain.ChainId) + require.False(t, bhv.IsChainEnabled(chains.BscMainnetChain.ChainId)) + }) +} + +func TestBlockHeaderVerification_IsChainEnabled(t *testing.T) { + t.Run("should return true if chain is enabled", func(t *testing.T) { + bhv := sample.BlockHeaderVerification() + require.True(t, bhv.IsChainEnabled(1)) + }) + + t.Run("should return false if chain is disabled", func(t *testing.T) { + bhv := types.BlockHeaderVerification{ + EnabledChains: []types.EnabledChain{{ChainId: 1, Enabled: false}}} + require.False(t, bhv.IsChainEnabled(1)) + }) + + t.Run("should return false if chain is not present", func(t *testing.T) { + bhv := sample.BlockHeaderVerification() + require.False(t, bhv.IsChainEnabled(1000)) + }) } From 494e6f354253401608ce0eeda4cd66bcaf86fae5 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Tue, 30 Apr 2024 18:30:58 -0400 Subject: [PATCH 24/31] fix changelog --- changelog.md | 6 +++--- .../keeper/msg_server_disable_block_header_verification.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/changelog.md b/changelog.md index 10f48a49b3..71f3a990d8 100644 --- a/changelog.md +++ b/changelog.md @@ -2,9 +2,9 @@ ## Unreleased ### Breaking Changes -* `MsgUpdateVerificationFlags` has been removed, and replaced with `MsgEnableVerificationFlags` and `MsgDisableVerificationFlags` messages. - * `MsgEnableVerificationFlags` message enables the verification flags for a list of chains and can be triggered via `PolicyType_groupOperational` - * `MsgDisableVerificationFlags` message disables the verification flags for a list of chains and can be triggered via `PolicyType_emergency` +* `MsgUpdateVerificationFlags` has been removed, and replaced with `MsgEnableHeaderVerification` and `MsgDisableHeaderVerification` messages. + * `MsgEnableHeaderVerification` message enables the verification flags for a list of chains and can be triggered via `PolicyType_groupOperational` + * `MsgDisableHeaderVerification` message disables the verification flags for a list of chains and can be triggered via `PolicyType_emergency` ### Refactor diff --git a/x/lightclient/keeper/msg_server_disable_block_header_verification.go b/x/lightclient/keeper/msg_server_disable_block_header_verification.go index 6c2bfd740a..b7e97c7290 100644 --- a/x/lightclient/keeper/msg_server_disable_block_header_verification.go +++ b/x/lightclient/keeper/msg_server_disable_block_header_verification.go @@ -8,7 +8,7 @@ import ( "github.com/zeta-chain/zetacore/x/lightclient/types" ) -// DisableVerificationFlags disables the verification flags for the given chain IDs +// DisableHeaderVerification 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) DisableHeaderVerification(goCtx context.Context, msg *types.MsgDisableHeaderVerification) (*types.MsgDisableHeaderVerificationResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) From e0269680f0b990b06f84452ac2c73eefb501c0d8 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Tue, 30 Apr 2024 19:04:38 -0400 Subject: [PATCH 25/31] generate files 3 --- .../zetacored/zetacored_query_lightclient.md | 2 +- ...lightclient_show-header-enabled-chains.md} | 6 +- .../cli/zetacored/zetacored_tx_lightclient.md | 4 +- ...ightclient_disable-header-verification.md} | 10 +-- ...lightclient_enable-header-verification.md} | 10 +-- docs/openapi/openapi.swagger.yaml | 36 +++++------ docs/spec/lightclient/messages.md | 12 ++-- typescript/lightclient/genesis_pb.d.ts | 6 +- typescript/lightclient/query_pb.d.ts | 38 +++++------ typescript/lightclient/tx_pb.d.ts | 64 +++++++++---------- .../lightclient/verification_flags_pb.d.ts | 40 +++++++++--- 11 files changed, 126 insertions(+), 102 deletions(-) rename docs/cli/zetacored/{zetacored_query_lightclient_show-verification-flags.md => zetacored_query_lightclient_show-header-enabled-chains.md} (84%) rename docs/cli/zetacored/{zetacored_tx_lightclient_disable-verification-flags.md => zetacored_tx_lightclient_disable-header-verification.md} (91%) rename docs/cli/zetacored/{zetacored_tx_lightclient_enable-verification-flags.md => zetacored_tx_lightclient_enable-header-verification.md} (91%) diff --git a/docs/cli/zetacored/zetacored_query_lightclient.md b/docs/cli/zetacored/zetacored_query_lightclient.md index a576a4e71b..e8ee902d1c 100644 --- a/docs/cli/zetacored/zetacored_query_lightclient.md +++ b/docs/cli/zetacored/zetacored_query_lightclient.md @@ -29,5 +29,5 @@ zetacored query lightclient [flags] * [zetacored query lightclient list-chain-state](zetacored_query_lightclient_list-chain-state.md) - List all the chain states * [zetacored query lightclient show-block-header](zetacored_query_lightclient_show-block-header.md) - Show a block header from its hash * [zetacored query lightclient show-chain-state](zetacored_query_lightclient_show-chain-state.md) - Show a chain state from its chain id -* [zetacored query lightclient show-verification-flags](zetacored_query_lightclient_show-verification-flags.md) - Show the verification flags +* [zetacored query lightclient show-header-enabled-chains](zetacored_query_lightclient_show-header-enabled-chains.md) - Show the verification flags diff --git a/docs/cli/zetacored/zetacored_query_lightclient_show-verification-flags.md b/docs/cli/zetacored/zetacored_query_lightclient_show-header-enabled-chains.md similarity index 84% rename from docs/cli/zetacored/zetacored_query_lightclient_show-verification-flags.md rename to docs/cli/zetacored/zetacored_query_lightclient_show-header-enabled-chains.md index d8e8d97527..fdf5d0159a 100644 --- a/docs/cli/zetacored/zetacored_query_lightclient_show-verification-flags.md +++ b/docs/cli/zetacored/zetacored_query_lightclient_show-header-enabled-chains.md @@ -1,9 +1,9 @@ -# query lightclient show-verification-flags +# query lightclient show-header-enabled-chains Show the verification flags ``` -zetacored query lightclient show-verification-flags [flags] +zetacored query lightclient show-header-enabled-chains [flags] ``` ### Options @@ -12,7 +12,7 @@ zetacored query lightclient show-verification-flags [flags] --grpc-addr string the gRPC endpoint to use for this chain --grpc-insecure allow gRPC over insecure channels, if not TLS the server must use TLS --height int Use a specific height to query state at (this can error if the node is pruning state) - -h, --help help for show-verification-flags + -h, --help help for show-header-enabled-chains --node string [host]:[port] to Tendermint RPC interface for this chain -o, --output string Output format (text|json) ``` diff --git a/docs/cli/zetacored/zetacored_tx_lightclient.md b/docs/cli/zetacored/zetacored_tx_lightclient.md index 65cbae6ac3..7febbd14ed 100644 --- a/docs/cli/zetacored/zetacored_tx_lightclient.md +++ b/docs/cli/zetacored/zetacored_tx_lightclient.md @@ -25,6 +25,6 @@ zetacored tx lightclient [flags] ### SEE ALSO * [zetacored tx](zetacored_tx.md) - Transactions subcommands -* [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) - Enable verification flags for the list of chains separated by comma +* [zetacored tx lightclient disable-header-verification](zetacored_tx_lightclient_disable-header-verification.md) - Disable header verification for the list of chains separated by comma +* [zetacored tx lightclient enable-header-verification](zetacored_tx_lightclient_enable-header-verification.md) - Enable verification for the list of chains separated by comma diff --git a/docs/cli/zetacored/zetacored_tx_lightclient_disable-verification-flags.md b/docs/cli/zetacored/zetacored_tx_lightclient_disable-header-verification.md similarity index 91% rename from docs/cli/zetacored/zetacored_tx_lightclient_disable-verification-flags.md rename to docs/cli/zetacored/zetacored_tx_lightclient_disable-header-verification.md index 675b133cd3..cf04129dfa 100644 --- a/docs/cli/zetacored/zetacored_tx_lightclient_disable-verification-flags.md +++ b/docs/cli/zetacored/zetacored_tx_lightclient_disable-header-verification.md @@ -1,6 +1,6 @@ -# tx lightclient disable-verification-flags +# tx lightclient disable-header-verification -Disable verification flags for the list of chains separated by comma +Disable header verification for the list of chains separated by comma ### Synopsis @@ -8,11 +8,11 @@ Provide a list of chain ids separated by comma to disable block header verificat Example: To disable verification flags for chain ids 1 and 56 - zetacored tx lightclient disable-verification-flags "1,56" + zetacored tx lightclient disable-header-verification "1,56" ``` -zetacored tx lightclient disable-verification-flags [list of chain-id] [flags] +zetacored tx lightclient disable-header-verification [list of chain-id] [flags] ``` ### Options @@ -30,7 +30,7 @@ zetacored tx lightclient disable-verification-flags [list of chain-id] [flags] --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 disable-verification-flags + -h, --help help for disable-header-verification --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 diff --git a/docs/cli/zetacored/zetacored_tx_lightclient_enable-verification-flags.md b/docs/cli/zetacored/zetacored_tx_lightclient_enable-header-verification.md similarity index 91% rename from docs/cli/zetacored/zetacored_tx_lightclient_enable-verification-flags.md rename to docs/cli/zetacored/zetacored_tx_lightclient_enable-header-verification.md index ff4dabf58c..9f94c5785f 100644 --- a/docs/cli/zetacored/zetacored_tx_lightclient_enable-verification-flags.md +++ b/docs/cli/zetacored/zetacored_tx_lightclient_enable-header-verification.md @@ -1,6 +1,6 @@ -# tx lightclient enable-verification-flags +# tx lightclient enable-header-verification -Enable verification flags for the list of chains separated by comma +Enable verification for the list of chains separated by comma ### Synopsis @@ -8,11 +8,11 @@ Provide a list of chain ids separated by comma to enable block header verificati Example: To enable verification flags for chain ids 1 and 56 - zetacored tx lightclient enable-verification-flags "1,56" + zetacored tx lightclient enable-header-verification "1,56" ``` -zetacored tx lightclient enable-verification-flags [list of chain-id] [flags] +zetacored tx lightclient enable-header-verification [list of chain-id] [flags] ``` ### Options @@ -30,7 +30,7 @@ zetacored tx lightclient enable-verification-flags [list of chain-id] [flags] --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 enable-verification-flags + -h, --help help for enable-header-verification --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 diff --git a/docs/openapi/openapi.swagger.yaml b/docs/openapi/openapi.swagger.yaml index 23fa44755d..9e769f0654 100644 --- a/docs/openapi/openapi.swagger.yaml +++ b/docs/openapi/openapi.swagger.yaml @@ -27674,12 +27674,12 @@ paths: - Query /zeta-chain/lightclient/verification_flags: get: - operationId: Query_VerificationFlags + operationId: Query_HeaderEnabledChains responses: "200": description: A successful response. schema: - $ref: '#/definitions/lightclientQueryVerificationFlagsResponse' + $ref: '#/definitions/lightclientQueryHeaderEnabledChainsResponse' default: description: An unexpected error response. schema: @@ -54304,9 +54304,18 @@ definitions: type: string format: byte title: ChainState defines the overall state of the block headers for a given chain - lightclientMsgDisableVerificationFlagsResponse: + lightclientEnabledChain: type: object - lightclientMsgEnableVerificationFlagsResponse: + properties: + chain_id: + type: string + format: int64 + enabled: + type: boolean + title: VerificationFlags is a structure containing information of weather a chain is enabled or not for block header verification + lightclientMsgDisableHeaderVerificationResponse: + type: object + lightclientMsgEnableHeaderVerificationResponse: type: object lightclientQueryAllBlockHeaderResponse: type: object @@ -54338,28 +54347,19 @@ definitions: properties: chain_state: $ref: '#/definitions/lightclientChainState' - lightclientQueryProveResponse: - type: object - properties: - valid: - type: boolean - lightclientQueryVerificationFlagsResponse: + lightclientQueryHeaderEnabledChainsResponse: type: object properties: - verification_flags: + enabled_chains: type: array items: type: object - $ref: '#/definitions/lightclientVerificationFlags' - lightclientVerificationFlags: + $ref: '#/definitions/lightclientEnabledChain' + lightclientQueryProveResponse: type: object properties: - chain_id: - type: string - format: int64 - enabled: + valid: type: boolean - title: VerificationFlags is a structure containing information of weather a chain is enabled or not for block header verification observerAdmin_Policy: type: object properties: diff --git a/docs/spec/lightclient/messages.md b/docs/spec/lightclient/messages.md index 269274e011..394d4b7398 100644 --- a/docs/spec/lightclient/messages.md +++ b/docs/spec/lightclient/messages.md @@ -1,24 +1,24 @@ # Messages -## MsgEnableVerificationFlags +## MsgEnableHeaderVerification -EnableVerificationFlags enables the verification flags for the given chain IDs +EnableHeaderVerification 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 MsgEnableVerificationFlags { +message MsgEnableHeaderVerification { string creator = 1; int64 chain_id_list = 2; } ``` -## MsgDisableVerificationFlags +## MsgDisableHeaderVerification -DisableVerificationFlags disables the verification flags for the given chain IDs +DisableHeaderVerification 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 { +message MsgDisableHeaderVerification { string creator = 1; int64 chain_id_list = 2; } diff --git a/typescript/lightclient/genesis_pb.d.ts b/typescript/lightclient/genesis_pb.d.ts index 7982115e5b..2cac56f722 100644 --- a/typescript/lightclient/genesis_pb.d.ts +++ b/typescript/lightclient/genesis_pb.d.ts @@ -7,7 +7,7 @@ import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialM import { Message, proto3 } from "@bufbuild/protobuf"; import type { BlockHeader } from "../pkg/proofs/proofs_pb.js"; import type { ChainState } from "./chain_state_pb.js"; -import type { VerificationFlags } from "./verification_flags_pb.js"; +import type { BlockHeaderVerification } from "./verification_flags_pb.js"; /** * GenesisState defines the lightclient module's genesis state. @@ -26,9 +26,9 @@ export declare class GenesisState extends Message { chainStates: ChainState[]; /** - * @generated from field: repeated zetachain.zetacore.lightclient.VerificationFlags verification_flags = 3; + * @generated from field: zetachain.zetacore.lightclient.BlockHeaderVerification block_header_verification = 3; */ - verificationFlags: VerificationFlags[]; + blockHeaderVerification?: BlockHeaderVerification; constructor(data?: PartialMessage); diff --git a/typescript/lightclient/query_pb.d.ts b/typescript/lightclient/query_pb.d.ts index 0f38cf60de..8aa02127b9 100644 --- a/typescript/lightclient/query_pb.d.ts +++ b/typescript/lightclient/query_pb.d.ts @@ -8,7 +8,7 @@ import { Message, proto3 } from "@bufbuild/protobuf"; import type { PageRequest, PageResponse } from "../cosmos/base/query/v1beta1/pagination_pb.js"; import type { BlockHeader, Proof } from "../pkg/proofs/proofs_pb.js"; import type { ChainState } from "./chain_state_pb.js"; -import type { VerificationFlags } from "./verification_flags_pb.js"; +import type { EnabledChain } from "./verification_flags_pb.js"; /** * @generated from message zetachain.zetacore.lightclient.QueryAllBlockHeaderRequest @@ -281,45 +281,45 @@ export declare class QueryProveResponse extends Message { } /** - * @generated from message zetachain.zetacore.lightclient.QueryVerificationFlagsRequest + * @generated from message zetachain.zetacore.lightclient.QueryHeaderEnabledChainsRequest */ -export declare class QueryVerificationFlagsRequest extends Message { - constructor(data?: PartialMessage); +export declare class QueryHeaderEnabledChainsRequest extends Message { + constructor(data?: PartialMessage); static readonly runtime: typeof proto3; - static readonly typeName = "zetachain.zetacore.lightclient.QueryVerificationFlagsRequest"; + static readonly typeName = "zetachain.zetacore.lightclient.QueryHeaderEnabledChainsRequest"; static readonly fields: FieldList; - static fromBinary(bytes: Uint8Array, options?: Partial): QueryVerificationFlagsRequest; + static fromBinary(bytes: Uint8Array, options?: Partial): QueryHeaderEnabledChainsRequest; - static fromJson(jsonValue: JsonValue, options?: Partial): QueryVerificationFlagsRequest; + static fromJson(jsonValue: JsonValue, options?: Partial): QueryHeaderEnabledChainsRequest; - static fromJsonString(jsonString: string, options?: Partial): QueryVerificationFlagsRequest; + static fromJsonString(jsonString: string, options?: Partial): QueryHeaderEnabledChainsRequest; - static equals(a: QueryVerificationFlagsRequest | PlainMessage | undefined, b: QueryVerificationFlagsRequest | PlainMessage | undefined): boolean; + static equals(a: QueryHeaderEnabledChainsRequest | PlainMessage | undefined, b: QueryHeaderEnabledChainsRequest | PlainMessage | undefined): boolean; } /** - * @generated from message zetachain.zetacore.lightclient.QueryVerificationFlagsResponse + * @generated from message zetachain.zetacore.lightclient.QueryHeaderEnabledChainsResponse */ -export declare class QueryVerificationFlagsResponse extends Message { +export declare class QueryHeaderEnabledChainsResponse extends Message { /** - * @generated from field: repeated zetachain.zetacore.lightclient.VerificationFlags verification_flags = 1; + * @generated from field: repeated zetachain.zetacore.lightclient.EnabledChain enabled_chains = 1; */ - verificationFlags: VerificationFlags[]; + enabledChains: EnabledChain[]; - constructor(data?: PartialMessage); + constructor(data?: PartialMessage); static readonly runtime: typeof proto3; - static readonly typeName = "zetachain.zetacore.lightclient.QueryVerificationFlagsResponse"; + static readonly typeName = "zetachain.zetacore.lightclient.QueryHeaderEnabledChainsResponse"; static readonly fields: FieldList; - static fromBinary(bytes: Uint8Array, options?: Partial): QueryVerificationFlagsResponse; + static fromBinary(bytes: Uint8Array, options?: Partial): QueryHeaderEnabledChainsResponse; - static fromJson(jsonValue: JsonValue, options?: Partial): QueryVerificationFlagsResponse; + static fromJson(jsonValue: JsonValue, options?: Partial): QueryHeaderEnabledChainsResponse; - static fromJsonString(jsonString: string, options?: Partial): QueryVerificationFlagsResponse; + static fromJsonString(jsonString: string, options?: Partial): QueryHeaderEnabledChainsResponse; - static equals(a: QueryVerificationFlagsResponse | PlainMessage | undefined, b: QueryVerificationFlagsResponse | PlainMessage | undefined): boolean; + static equals(a: QueryHeaderEnabledChainsResponse | PlainMessage | undefined, b: QueryHeaderEnabledChainsResponse | PlainMessage | undefined): boolean; } diff --git a/typescript/lightclient/tx_pb.d.ts b/typescript/lightclient/tx_pb.d.ts index 154e6f7878..6691ac0c41 100644 --- a/typescript/lightclient/tx_pb.d.ts +++ b/typescript/lightclient/tx_pb.d.ts @@ -7,9 +7,9 @@ import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialM import { Message, proto3 } from "@bufbuild/protobuf"; /** - * @generated from message zetachain.zetacore.lightclient.MsgEnableVerificationFlags + * @generated from message zetachain.zetacore.lightclient.MsgEnableHeaderVerification */ -export declare class MsgEnableVerificationFlags extends Message { +export declare class MsgEnableHeaderVerification extends Message { /** * @generated from field: string creator = 1; */ @@ -20,44 +20,44 @@ export declare class MsgEnableVerificationFlags extends Message); + constructor(data?: PartialMessage); static readonly runtime: typeof proto3; - static readonly typeName = "zetachain.zetacore.lightclient.MsgEnableVerificationFlags"; + static readonly typeName = "zetachain.zetacore.lightclient.MsgEnableHeaderVerification"; static readonly fields: FieldList; - static fromBinary(bytes: Uint8Array, options?: Partial): MsgEnableVerificationFlags; + static fromBinary(bytes: Uint8Array, options?: Partial): MsgEnableHeaderVerification; - static fromJson(jsonValue: JsonValue, options?: Partial): MsgEnableVerificationFlags; + static fromJson(jsonValue: JsonValue, options?: Partial): MsgEnableHeaderVerification; - static fromJsonString(jsonString: string, options?: Partial): MsgEnableVerificationFlags; + static fromJsonString(jsonString: string, options?: Partial): MsgEnableHeaderVerification; - static equals(a: MsgEnableVerificationFlags | PlainMessage | undefined, b: MsgEnableVerificationFlags | PlainMessage | undefined): boolean; + static equals(a: MsgEnableHeaderVerification | PlainMessage | undefined, b: MsgEnableHeaderVerification | PlainMessage | undefined): boolean; } /** - * @generated from message zetachain.zetacore.lightclient.MsgEnableVerificationFlagsResponse + * @generated from message zetachain.zetacore.lightclient.MsgEnableHeaderVerificationResponse */ -export declare class MsgEnableVerificationFlagsResponse extends Message { - constructor(data?: PartialMessage); +export declare class MsgEnableHeaderVerificationResponse extends Message { + constructor(data?: PartialMessage); static readonly runtime: typeof proto3; - static readonly typeName = "zetachain.zetacore.lightclient.MsgEnableVerificationFlagsResponse"; + static readonly typeName = "zetachain.zetacore.lightclient.MsgEnableHeaderVerificationResponse"; static readonly fields: FieldList; - static fromBinary(bytes: Uint8Array, options?: Partial): MsgEnableVerificationFlagsResponse; + static fromBinary(bytes: Uint8Array, options?: Partial): MsgEnableHeaderVerificationResponse; - static fromJson(jsonValue: JsonValue, options?: Partial): MsgEnableVerificationFlagsResponse; + static fromJson(jsonValue: JsonValue, options?: Partial): MsgEnableHeaderVerificationResponse; - static fromJsonString(jsonString: string, options?: Partial): MsgEnableVerificationFlagsResponse; + static fromJsonString(jsonString: string, options?: Partial): MsgEnableHeaderVerificationResponse; - static equals(a: MsgEnableVerificationFlagsResponse | PlainMessage | undefined, b: MsgEnableVerificationFlagsResponse | PlainMessage | undefined): boolean; + static equals(a: MsgEnableHeaderVerificationResponse | PlainMessage | undefined, b: MsgEnableHeaderVerificationResponse | PlainMessage | undefined): boolean; } /** - * @generated from message zetachain.zetacore.lightclient.MsgDisableVerificationFlags + * @generated from message zetachain.zetacore.lightclient.MsgDisableHeaderVerification */ -export declare class MsgDisableVerificationFlags extends Message { +export declare class MsgDisableHeaderVerification extends Message { /** * @generated from field: string creator = 1; */ @@ -68,37 +68,37 @@ export declare class MsgDisableVerificationFlags extends Message); + constructor(data?: PartialMessage); static readonly runtime: typeof proto3; - static readonly typeName = "zetachain.zetacore.lightclient.MsgDisableVerificationFlags"; + static readonly typeName = "zetachain.zetacore.lightclient.MsgDisableHeaderVerification"; static readonly fields: FieldList; - static fromBinary(bytes: Uint8Array, options?: Partial): MsgDisableVerificationFlags; + static fromBinary(bytes: Uint8Array, options?: Partial): MsgDisableHeaderVerification; - static fromJson(jsonValue: JsonValue, options?: Partial): MsgDisableVerificationFlags; + static fromJson(jsonValue: JsonValue, options?: Partial): MsgDisableHeaderVerification; - static fromJsonString(jsonString: string, options?: Partial): MsgDisableVerificationFlags; + static fromJsonString(jsonString: string, options?: Partial): MsgDisableHeaderVerification; - static equals(a: MsgDisableVerificationFlags | PlainMessage | undefined, b: MsgDisableVerificationFlags | PlainMessage | undefined): boolean; + static equals(a: MsgDisableHeaderVerification | PlainMessage | undefined, b: MsgDisableHeaderVerification | PlainMessage | undefined): boolean; } /** - * @generated from message zetachain.zetacore.lightclient.MsgDisableVerificationFlagsResponse + * @generated from message zetachain.zetacore.lightclient.MsgDisableHeaderVerificationResponse */ -export declare class MsgDisableVerificationFlagsResponse extends Message { - constructor(data?: PartialMessage); +export declare class MsgDisableHeaderVerificationResponse extends Message { + constructor(data?: PartialMessage); static readonly runtime: typeof proto3; - static readonly typeName = "zetachain.zetacore.lightclient.MsgDisableVerificationFlagsResponse"; + static readonly typeName = "zetachain.zetacore.lightclient.MsgDisableHeaderVerificationResponse"; static readonly fields: FieldList; - static fromBinary(bytes: Uint8Array, options?: Partial): MsgDisableVerificationFlagsResponse; + static fromBinary(bytes: Uint8Array, options?: Partial): MsgDisableHeaderVerificationResponse; - static fromJson(jsonValue: JsonValue, options?: Partial): MsgDisableVerificationFlagsResponse; + static fromJson(jsonValue: JsonValue, options?: Partial): MsgDisableHeaderVerificationResponse; - static fromJsonString(jsonString: string, options?: Partial): MsgDisableVerificationFlagsResponse; + static fromJsonString(jsonString: string, options?: Partial): MsgDisableHeaderVerificationResponse; - static equals(a: MsgDisableVerificationFlagsResponse | PlainMessage | undefined, b: MsgDisableVerificationFlagsResponse | PlainMessage | undefined): boolean; + static equals(a: MsgDisableHeaderVerificationResponse | PlainMessage | undefined, b: MsgDisableHeaderVerificationResponse | PlainMessage | undefined): boolean; } diff --git a/typescript/lightclient/verification_flags_pb.d.ts b/typescript/lightclient/verification_flags_pb.d.ts index d5a4df9b6d..f6db17a3c7 100644 --- a/typescript/lightclient/verification_flags_pb.d.ts +++ b/typescript/lightclient/verification_flags_pb.d.ts @@ -9,9 +9,9 @@ import { Message, proto3 } from "@bufbuild/protobuf"; /** * VerificationFlags is a structure containing information of weather a chain is enabled or not for block header verification * - * @generated from message zetachain.zetacore.lightclient.VerificationFlags + * @generated from message zetachain.zetacore.lightclient.EnabledChain */ -export declare class VerificationFlags extends Message { +export declare class EnabledChain extends Message { /** * @generated from field: int64 chain_id = 1; */ @@ -22,18 +22,42 @@ export declare class VerificationFlags extends Message { */ enabled: boolean; - constructor(data?: PartialMessage); + constructor(data?: PartialMessage); static readonly runtime: typeof proto3; - static readonly typeName = "zetachain.zetacore.lightclient.VerificationFlags"; + static readonly typeName = "zetachain.zetacore.lightclient.EnabledChain"; static readonly fields: FieldList; - static fromBinary(bytes: Uint8Array, options?: Partial): VerificationFlags; + static fromBinary(bytes: Uint8Array, options?: Partial): EnabledChain; - static fromJson(jsonValue: JsonValue, options?: Partial): VerificationFlags; + static fromJson(jsonValue: JsonValue, options?: Partial): EnabledChain; - static fromJsonString(jsonString: string, options?: Partial): VerificationFlags; + static fromJsonString(jsonString: string, options?: Partial): EnabledChain; - static equals(a: VerificationFlags | PlainMessage | undefined, b: VerificationFlags | PlainMessage | undefined): boolean; + static equals(a: EnabledChain | PlainMessage | undefined, b: EnabledChain | PlainMessage | undefined): boolean; +} + +/** + * @generated from message zetachain.zetacore.lightclient.BlockHeaderVerification + */ +export declare class BlockHeaderVerification extends Message { + /** + * @generated from field: repeated zetachain.zetacore.lightclient.EnabledChain enabled_chains = 1; + */ + enabledChains: EnabledChain[]; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "zetachain.zetacore.lightclient.BlockHeaderVerification"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): BlockHeaderVerification; + + static fromJson(jsonValue: JsonValue, options?: Partial): BlockHeaderVerification; + + static fromJsonString(jsonString: string, options?: Partial): BlockHeaderVerification; + + static equals(a: BlockHeaderVerification | PlainMessage | undefined, b: BlockHeaderVerification | PlainMessage | undefined): boolean; } From d9bab159f538ddf992b1c89b9e3fbc8df3b9769d Mon Sep 17 00:00:00 2001 From: Tanmay Date: Wed, 1 May 2024 01:23:16 -0400 Subject: [PATCH 26/31] rename enabled chains to supported chains --- changelog.md | 4 +- docs/openapi/openapi.swagger.yaml | 58 +- e2e/runner/setup_zeta.go | 2 +- e2e/txserver/zeta_tx_server.go | 2 +- ....proto => block_header_verification.proto} | 4 +- proto/lightclient/genesis.proto | 2 +- proto/lightclient/query.proto | 22 +- proto/lightclient/tx.proto | 2 +- testutil/sample/lightclient.go | 6 +- ...d.ts => block_header_verification_pb.d.ts} | 22 +- typescript/lightclient/genesis_pb.d.ts | 2 +- typescript/lightclient/index.d.ts | 2 +- typescript/lightclient/query_pb.d.ts | 81 ++- x/lightclient/client/cli/query.go | 2 +- .../client/cli/query_verification_flags.go | 6 +- x/lightclient/genesis_test.go | 2 +- x/lightclient/keeper/block_header_test.go | 18 +- .../keeper/block_header_verification.go | 7 +- .../keeper/block_header_verification_test.go | 10 +- .../grpc_query_header_enabled_chains.go | 22 +- .../grpc_query_header_enabled_chains_test.go | 12 +- ...disable_block_header_verification._test.go | 4 +- ...r_enable_block_header_verification_test.go | 4 +- x/lightclient/keeper/proof.go | 2 +- x/lightclient/keeper/proof_test.go | 14 +- .../types/block_header_verification.go | 49 +- ....pb.go => block_header_verification.pb.go} | 177 +++--- .../types/block_header_verification_test.go | 77 ++- x/lightclient/types/genesis.pb.go | 34 +- ...message_disable_verification_flags_test.go | 10 +- x/lightclient/types/query.pb.go | 574 ++++++++++++++---- x/lightclient/types/query.pb.gw.go | 71 ++- x/lightclient/types/tx.pb.go | 36 +- x/lightclient/types/verification_flags.go | 8 +- .../types/verification_flags_test.go | 2 +- zetaclient/bitcoin/bitcoin_client.go | 4 +- zetaclient/core_context/zeta_core_context.go | 19 +- .../core_context/zeta_core_context_test.go | 14 +- zetaclient/evm/evm_client.go | 4 +- zetaclient/evm/evm_client_test.go | 2 +- zetaclient/zetabridge/query.go | 8 +- zetaclient/zetabridge/query_test.go | 8 +- zetaclient/zetabridge/tx_test.go | 6 +- zetaclient/zetacore_observer_test.go | 2 +- 44 files changed, 1004 insertions(+), 413 deletions(-) rename proto/lightclient/{verification_flags.proto => block_header_verification.proto} (75%) rename typescript/lightclient/{verification_flags_pb.d.ts => block_header_verification_pb.d.ts} (69%) rename x/lightclient/types/{verification_flags.pb.go => block_header_verification.pb.go} (57%) diff --git a/changelog.md b/changelog.md index 71f3a990d8..b7845011d3 100644 --- a/changelog.md +++ b/changelog.md @@ -3,8 +3,8 @@ ## Unreleased ### Breaking Changes * `MsgUpdateVerificationFlags` has been removed, and replaced with `MsgEnableHeaderVerification` and `MsgDisableHeaderVerification` messages. - * `MsgEnableHeaderVerification` message enables the verification flags for a list of chains and can be triggered via `PolicyType_groupOperational` - * `MsgDisableHeaderVerification` message disables the verification flags for a list of chains and can be triggered via `PolicyType_emergency` + * `MsgEnableHeaderVerification` message enables block header verification for a list of chains and can be triggered via `PolicyType_groupOperational` + * `MsgDisableHeaderVerification` message disables block header verification for a list of chains and can be triggered via `PolicyType_emergency` ### Refactor diff --git a/docs/openapi/openapi.swagger.yaml b/docs/openapi/openapi.swagger.yaml index 9e769f0654..afdcafafe7 100644 --- a/docs/openapi/openapi.swagger.yaml +++ b/docs/openapi/openapi.swagger.yaml @@ -27608,6 +27608,34 @@ paths: format: int64 tags: - Query + /zeta-chain/lightclient/header_enabled_chains: + get: + operationId: Query_HeaderEnabledChains + responses: + "200": + description: A successful response. + schema: + $ref: '#/definitions/lightclientHeaderEnabledChainsResponse' + default: + description: An unexpected error response. + schema: + $ref: '#/definitions/googlerpcStatus' + tags: + - Query + /zeta-chain/lightclient/header_supported_chains: + get: + operationId: Query_HeaderSupportedChains + responses: + "200": + description: A successful response. + schema: + $ref: '#/definitions/lightclientQueryHeaderSupportedChainsResponse' + default: + description: An unexpected error response. + schema: + $ref: '#/definitions/googlerpcStatus' + tags: + - Query /zeta-chain/lightclient/prove: get: operationId: Query_Prove @@ -27672,20 +27700,6 @@ paths: format: int64 tags: - Query - /zeta-chain/lightclient/verification_flags: - get: - operationId: Query_HeaderEnabledChains - responses: - "200": - description: A successful response. - schema: - $ref: '#/definitions/lightclientQueryHeaderEnabledChainsResponse' - default: - description: An unexpected error response. - schema: - $ref: '#/definitions/googlerpcStatus' - tags: - - Query /zeta-chain/observer/TSS: get: summary: Queries a tSS by index. @@ -54304,7 +54318,15 @@ definitions: type: string format: byte title: ChainState defines the overall state of the block headers for a given chain - lightclientEnabledChain: + lightclientHeaderEnabledChainsResponse: + type: object + properties: + header_enabled_chains: + type: array + items: + type: object + $ref: '#/definitions/lightclientHeaderSupportedChain' + lightclientHeaderSupportedChain: type: object properties: chain_id: @@ -54347,14 +54369,14 @@ definitions: properties: chain_state: $ref: '#/definitions/lightclientChainState' - lightclientQueryHeaderEnabledChainsResponse: + lightclientQueryHeaderSupportedChainsResponse: type: object properties: - enabled_chains: + header_supported_chains: type: array items: type: object - $ref: '#/definitions/lightclientEnabledChain' + $ref: '#/definitions/lightclientHeaderSupportedChain' lightclientQueryProveResponse: type: object properties: diff --git a/e2e/runner/setup_zeta.go b/e2e/runner/setup_zeta.go index 4d2d260a92..b78f9b3e02 100644 --- a/e2e/runner/setup_zeta.go +++ b/e2e/runner/setup_zeta.go @@ -214,7 +214,7 @@ func (runner *E2ERunner) SetupBTCZRC20() { runner.BTCZRC20 = BTCZRC20 } -// EnableHeaderVerification enables the verification flags on ZetaChain +// EnableHeaderVerification enables the header verification for the given chain IDs func (runner *E2ERunner) EnableHeaderVerification(chainIDList []int64) error { runner.Logger.Print("⚙️ enabling verification flags for block headers") diff --git a/e2e/txserver/zeta_tx_server.go b/e2e/txserver/zeta_tx_server.go index 8850b04a5d..361516696e 100644 --- a/e2e/txserver/zeta_tx_server.go +++ b/e2e/txserver/zeta_tx_server.go @@ -250,7 +250,7 @@ type intoAny interface { AsAny() *codectypes.Any } -// EnableHeaderVerification enables the verification flags for the lightclient module +// EnableHeaderVerification enables the header verification for the given chain IDs func (zts ZetaTxServer) EnableHeaderVerification(account string, chainIDList []int64) error { // retrieve account acc, err := zts.clientCtx.Keyring.Key(account) diff --git a/proto/lightclient/verification_flags.proto b/proto/lightclient/block_header_verification.proto similarity index 75% rename from proto/lightclient/verification_flags.proto rename to proto/lightclient/block_header_verification.proto index 60b6ef6c01..c1f0410fa7 100644 --- a/proto/lightclient/verification_flags.proto +++ b/proto/lightclient/block_header_verification.proto @@ -6,11 +6,11 @@ import "gogoproto/gogo.proto"; option go_package = "github.com/zeta-chain/zetacore/x/lightclient/types"; // VerificationFlags is a structure containing information of weather a chain is enabled or not for block header verification -message EnabledChain { +message HeaderSupportedChain { int64 chain_id = 1; bool enabled = 2; } message BlockHeaderVerification { - repeated EnabledChain enabled_chains = 1 [(gogoproto.nullable) = false]; + repeated HeaderSupportedChain header_supported_chains = 1 [(gogoproto.nullable) = false]; } diff --git a/proto/lightclient/genesis.proto b/proto/lightclient/genesis.proto index c09213987a..6144ee276a 100644 --- a/proto/lightclient/genesis.proto +++ b/proto/lightclient/genesis.proto @@ -2,8 +2,8 @@ syntax = "proto3"; package zetachain.zetacore.lightclient; import "gogoproto/gogo.proto"; +import "lightclient/block_header_verification.proto"; import "lightclient/chain_state.proto"; -import "lightclient/verification_flags.proto"; import "pkg/proofs/proofs.proto"; option go_package = "github.com/zeta-chain/zetacore/x/lightclient/types"; diff --git a/proto/lightclient/query.proto b/proto/lightclient/query.proto index 2195ae64b8..385a2f1f21 100644 --- a/proto/lightclient/query.proto +++ b/proto/lightclient/query.proto @@ -4,8 +4,8 @@ package zetachain.zetacore.lightclient; import "cosmos/base/query/v1beta1/pagination.proto"; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; +import "lightclient/block_header_verification.proto"; import "lightclient/chain_state.proto"; -import "lightclient/verification_flags.proto"; import "pkg/proofs/proofs.proto"; option go_package = "github.com/zeta-chain/zetacore/x/lightclient/types"; @@ -32,8 +32,12 @@ service Query { option (google.api.http).get = "/zeta-chain/lightclient/prove"; } - rpc HeaderEnabledChains(QueryHeaderEnabledChainsRequest) returns (QueryHeaderEnabledChainsResponse) { - option (google.api.http).get = "/zeta-chain/lightclient/verification_flags"; + rpc HeaderSupportedChains(QueryHeaderSupportedChainsRequest) returns (QueryHeaderSupportedChainsResponse) { + option (google.api.http).get = "/zeta-chain/lightclient/header_supported_chains"; + } + + rpc HeaderEnabledChains(HeaderEnabledChainsRequest) returns (HeaderEnabledChainsResponse) { + option (google.api.http).get = "/zeta-chain/lightclient/header_enabled_chains"; } } @@ -83,8 +87,14 @@ message QueryProveResponse { bool valid = 1; } -message QueryHeaderEnabledChainsRequest {} +message QueryHeaderSupportedChainsRequest {} + +message QueryHeaderSupportedChainsResponse { + repeated HeaderSupportedChain header_supported_chains = 1 [(gogoproto.nullable) = false]; +} + +message HeaderEnabledChainsRequest {} -message QueryHeaderEnabledChainsResponse { - repeated EnabledChain enabled_chains = 1 [(gogoproto.nullable) = false]; +message HeaderEnabledChainsResponse { + repeated HeaderSupportedChain header_enabled_chains = 1 [(gogoproto.nullable) = false]; } diff --git a/proto/lightclient/tx.proto b/proto/lightclient/tx.proto index 6d8e11ccec..4e54c787e5 100644 --- a/proto/lightclient/tx.proto +++ b/proto/lightclient/tx.proto @@ -2,7 +2,7 @@ syntax = "proto3"; package zetachain.zetacore.lightclient; import "gogoproto/gogo.proto"; -import "lightclient/verification_flags.proto"; +import "lightclient/block_header_verification.proto"; option go_package = "github.com/zeta-chain/zetacore/x/lightclient/types"; diff --git a/testutil/sample/lightclient.go b/testutil/sample/lightclient.go index dc1ec01e06..ca24e92bbf 100644 --- a/testutil/sample/lightclient.go +++ b/testutil/sample/lightclient.go @@ -33,8 +33,8 @@ func ChainState(chainID int64) lightclienttypes.ChainState { } } -func VerificationFlags() []lightclienttypes.EnabledChain { - return []lightclienttypes.EnabledChain{ +func HeaderSupportedChains() []lightclienttypes.HeaderSupportedChain { + return []lightclienttypes.HeaderSupportedChain{ { ChainId: 1, Enabled: true, @@ -47,7 +47,7 @@ func VerificationFlags() []lightclienttypes.EnabledChain { } func BlockHeaderVerification() lightclienttypes.BlockHeaderVerification { - return lightclienttypes.BlockHeaderVerification{EnabledChains: VerificationFlags()} + return lightclienttypes.BlockHeaderVerification{HeaderSupportedChains: HeaderSupportedChains()} } diff --git a/typescript/lightclient/verification_flags_pb.d.ts b/typescript/lightclient/block_header_verification_pb.d.ts similarity index 69% rename from typescript/lightclient/verification_flags_pb.d.ts rename to typescript/lightclient/block_header_verification_pb.d.ts index f6db17a3c7..d40170bb61 100644 --- a/typescript/lightclient/verification_flags_pb.d.ts +++ b/typescript/lightclient/block_header_verification_pb.d.ts @@ -1,5 +1,5 @@ // @generated by protoc-gen-es v1.3.0 with parameter "target=dts" -// @generated from file lightclient/verification_flags.proto (package zetachain.zetacore.lightclient, syntax proto3) +// @generated from file lightclient/block_header_verification.proto (package zetachain.zetacore.lightclient, syntax proto3) /* eslint-disable */ // @ts-nocheck @@ -9,9 +9,9 @@ import { Message, proto3 } from "@bufbuild/protobuf"; /** * VerificationFlags is a structure containing information of weather a chain is enabled or not for block header verification * - * @generated from message zetachain.zetacore.lightclient.EnabledChain + * @generated from message zetachain.zetacore.lightclient.HeaderSupportedChain */ -export declare class EnabledChain extends Message { +export declare class HeaderSupportedChain extends Message { /** * @generated from field: int64 chain_id = 1; */ @@ -22,19 +22,19 @@ export declare class EnabledChain extends Message { */ enabled: boolean; - constructor(data?: PartialMessage); + constructor(data?: PartialMessage); static readonly runtime: typeof proto3; - static readonly typeName = "zetachain.zetacore.lightclient.EnabledChain"; + static readonly typeName = "zetachain.zetacore.lightclient.HeaderSupportedChain"; static readonly fields: FieldList; - static fromBinary(bytes: Uint8Array, options?: Partial): EnabledChain; + static fromBinary(bytes: Uint8Array, options?: Partial): HeaderSupportedChain; - static fromJson(jsonValue: JsonValue, options?: Partial): EnabledChain; + static fromJson(jsonValue: JsonValue, options?: Partial): HeaderSupportedChain; - static fromJsonString(jsonString: string, options?: Partial): EnabledChain; + static fromJsonString(jsonString: string, options?: Partial): HeaderSupportedChain; - static equals(a: EnabledChain | PlainMessage | undefined, b: EnabledChain | PlainMessage | undefined): boolean; + static equals(a: HeaderSupportedChain | PlainMessage | undefined, b: HeaderSupportedChain | PlainMessage | undefined): boolean; } /** @@ -42,9 +42,9 @@ export declare class EnabledChain extends Message { */ export declare class BlockHeaderVerification extends Message { /** - * @generated from field: repeated zetachain.zetacore.lightclient.EnabledChain enabled_chains = 1; + * @generated from field: repeated zetachain.zetacore.lightclient.HeaderSupportedChain header_supported_chains = 1; */ - enabledChains: EnabledChain[]; + headerSupportedChains: HeaderSupportedChain[]; constructor(data?: PartialMessage); diff --git a/typescript/lightclient/genesis_pb.d.ts b/typescript/lightclient/genesis_pb.d.ts index 2cac56f722..a2f8e96e9e 100644 --- a/typescript/lightclient/genesis_pb.d.ts +++ b/typescript/lightclient/genesis_pb.d.ts @@ -7,7 +7,7 @@ import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialM import { Message, proto3 } from "@bufbuild/protobuf"; import type { BlockHeader } from "../pkg/proofs/proofs_pb.js"; import type { ChainState } from "./chain_state_pb.js"; -import type { BlockHeaderVerification } from "./verification_flags_pb.js"; +import type { BlockHeaderVerification } from "./block_header_verification_pb.js"; /** * GenesisState defines the lightclient module's genesis state. diff --git a/typescript/lightclient/index.d.ts b/typescript/lightclient/index.d.ts index 767468a720..ccaac063d0 100644 --- a/typescript/lightclient/index.d.ts +++ b/typescript/lightclient/index.d.ts @@ -1,5 +1,5 @@ +export * from "./block_header_verification_pb"; export * from "./chain_state_pb"; export * from "./genesis_pb"; export * from "./query_pb"; export * from "./tx_pb"; -export * from "./verification_flags_pb"; diff --git a/typescript/lightclient/query_pb.d.ts b/typescript/lightclient/query_pb.d.ts index 8aa02127b9..944e6bcfd8 100644 --- a/typescript/lightclient/query_pb.d.ts +++ b/typescript/lightclient/query_pb.d.ts @@ -8,7 +8,7 @@ import { Message, proto3 } from "@bufbuild/protobuf"; import type { PageRequest, PageResponse } from "../cosmos/base/query/v1beta1/pagination_pb.js"; import type { BlockHeader, Proof } from "../pkg/proofs/proofs_pb.js"; import type { ChainState } from "./chain_state_pb.js"; -import type { EnabledChain } from "./verification_flags_pb.js"; +import type { HeaderSupportedChain } from "./block_header_verification_pb.js"; /** * @generated from message zetachain.zetacore.lightclient.QueryAllBlockHeaderRequest @@ -281,45 +281,88 @@ export declare class QueryProveResponse extends Message { } /** - * @generated from message zetachain.zetacore.lightclient.QueryHeaderEnabledChainsRequest + * @generated from message zetachain.zetacore.lightclient.QueryHeaderSupportedChainsRequest */ -export declare class QueryHeaderEnabledChainsRequest extends Message { - constructor(data?: PartialMessage); +export declare class QueryHeaderSupportedChainsRequest extends Message { + constructor(data?: PartialMessage); static readonly runtime: typeof proto3; - static readonly typeName = "zetachain.zetacore.lightclient.QueryHeaderEnabledChainsRequest"; + static readonly typeName = "zetachain.zetacore.lightclient.QueryHeaderSupportedChainsRequest"; static readonly fields: FieldList; - static fromBinary(bytes: Uint8Array, options?: Partial): QueryHeaderEnabledChainsRequest; + static fromBinary(bytes: Uint8Array, options?: Partial): QueryHeaderSupportedChainsRequest; - static fromJson(jsonValue: JsonValue, options?: Partial): QueryHeaderEnabledChainsRequest; + static fromJson(jsonValue: JsonValue, options?: Partial): QueryHeaderSupportedChainsRequest; - static fromJsonString(jsonString: string, options?: Partial): QueryHeaderEnabledChainsRequest; + static fromJsonString(jsonString: string, options?: Partial): QueryHeaderSupportedChainsRequest; - static equals(a: QueryHeaderEnabledChainsRequest | PlainMessage | undefined, b: QueryHeaderEnabledChainsRequest | PlainMessage | undefined): boolean; + static equals(a: QueryHeaderSupportedChainsRequest | PlainMessage | undefined, b: QueryHeaderSupportedChainsRequest | PlainMessage | undefined): boolean; } /** - * @generated from message zetachain.zetacore.lightclient.QueryHeaderEnabledChainsResponse + * @generated from message zetachain.zetacore.lightclient.QueryHeaderSupportedChainsResponse */ -export declare class QueryHeaderEnabledChainsResponse extends Message { +export declare class QueryHeaderSupportedChainsResponse extends Message { /** - * @generated from field: repeated zetachain.zetacore.lightclient.EnabledChain enabled_chains = 1; + * @generated from field: repeated zetachain.zetacore.lightclient.HeaderSupportedChain header_supported_chains = 1; */ - enabledChains: EnabledChain[]; + headerSupportedChains: HeaderSupportedChain[]; - constructor(data?: PartialMessage); + constructor(data?: PartialMessage); static readonly runtime: typeof proto3; - static readonly typeName = "zetachain.zetacore.lightclient.QueryHeaderEnabledChainsResponse"; + static readonly typeName = "zetachain.zetacore.lightclient.QueryHeaderSupportedChainsResponse"; static readonly fields: FieldList; - static fromBinary(bytes: Uint8Array, options?: Partial): QueryHeaderEnabledChainsResponse; + static fromBinary(bytes: Uint8Array, options?: Partial): QueryHeaderSupportedChainsResponse; - static fromJson(jsonValue: JsonValue, options?: Partial): QueryHeaderEnabledChainsResponse; + static fromJson(jsonValue: JsonValue, options?: Partial): QueryHeaderSupportedChainsResponse; - static fromJsonString(jsonString: string, options?: Partial): QueryHeaderEnabledChainsResponse; + static fromJsonString(jsonString: string, options?: Partial): QueryHeaderSupportedChainsResponse; - static equals(a: QueryHeaderEnabledChainsResponse | PlainMessage | undefined, b: QueryHeaderEnabledChainsResponse | PlainMessage | undefined): boolean; + static equals(a: QueryHeaderSupportedChainsResponse | PlainMessage | undefined, b: QueryHeaderSupportedChainsResponse | PlainMessage | undefined): boolean; +} + +/** + * @generated from message zetachain.zetacore.lightclient.HeaderEnabledChainsRequest + */ +export declare class HeaderEnabledChainsRequest extends Message { + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "zetachain.zetacore.lightclient.HeaderEnabledChainsRequest"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): HeaderEnabledChainsRequest; + + static fromJson(jsonValue: JsonValue, options?: Partial): HeaderEnabledChainsRequest; + + static fromJsonString(jsonString: string, options?: Partial): HeaderEnabledChainsRequest; + + static equals(a: HeaderEnabledChainsRequest | PlainMessage | undefined, b: HeaderEnabledChainsRequest | PlainMessage | undefined): boolean; +} + +/** + * @generated from message zetachain.zetacore.lightclient.HeaderEnabledChainsResponse + */ +export declare class HeaderEnabledChainsResponse extends Message { + /** + * @generated from field: repeated zetachain.zetacore.lightclient.HeaderSupportedChain header_enabled_chains = 1; + */ + headerEnabledChains: HeaderSupportedChain[]; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "zetachain.zetacore.lightclient.HeaderEnabledChainsResponse"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): HeaderEnabledChainsResponse; + + static fromJson(jsonValue: JsonValue, options?: Partial): HeaderEnabledChainsResponse; + + static fromJsonString(jsonString: string, options?: Partial): HeaderEnabledChainsResponse; + + static equals(a: HeaderEnabledChainsResponse | PlainMessage | undefined, b: HeaderEnabledChainsResponse | PlainMessage | undefined): boolean; } diff --git a/x/lightclient/client/cli/query.go b/x/lightclient/client/cli/query.go index d7cd7b92c9..70fb5ff65a 100644 --- a/x/lightclient/client/cli/query.go +++ b/x/lightclient/client/cli/query.go @@ -24,7 +24,7 @@ func GetQueryCmd(_ string) *cobra.Command { CmdListBlockHeader(), CmdShowChainState(), CmdListChainState(), - CmdShowHeaderEnabledChains(), + CmdShowHeaderHeaderSupportedChains(), ) return cmd diff --git a/x/lightclient/client/cli/query_verification_flags.go b/x/lightclient/client/cli/query_verification_flags.go index e8390ccad4..168ba4acbb 100644 --- a/x/lightclient/client/cli/query_verification_flags.go +++ b/x/lightclient/client/cli/query_verification_flags.go @@ -7,7 +7,7 @@ import ( "github.com/zeta-chain/zetacore/x/lightclient/types" ) -func CmdShowHeaderEnabledChains() *cobra.Command { +func CmdShowHeaderHeaderSupportedChains() *cobra.Command { cmd := &cobra.Command{ Use: "show-header-enabled-chains", Short: "Show the verification flags", @@ -20,9 +20,9 @@ func CmdShowHeaderEnabledChains() *cobra.Command { queryClient := types.NewQueryClient(clientCtx) - params := &types.QueryHeaderEnabledChainsRequest{} + params := &types.QueryHeaderSupportedChainsRequest{} - res, err := queryClient.HeaderEnabledChains(cmd.Context(), params) + res, err := queryClient.HeaderSupportedChains(cmd.Context(), params) if err != nil { return err } diff --git a/x/lightclient/genesis_test.go b/x/lightclient/genesis_test.go index 2778c2e102..0c7a08c97a 100644 --- a/x/lightclient/genesis_test.go +++ b/x/lightclient/genesis_test.go @@ -54,6 +54,6 @@ func TestGenesis(t *testing.T) { ChainStates: []types.ChainState(nil), } require.Equal(t, expected, *got) - require.Equal(t, expected.BlockHeaderVerification.EnabledChains, got.BlockHeaderVerification.EnabledChains) + require.Equal(t, expected.BlockHeaderVerification.HeaderSupportedChains, got.BlockHeaderVerification.HeaderSupportedChains) }) } diff --git a/x/lightclient/keeper/block_header_test.go b/x/lightclient/keeper/block_header_test.go index f903370ad4..8d610e621f 100644 --- a/x/lightclient/keeper/block_header_test.go +++ b/x/lightclient/keeper/block_header_test.go @@ -128,7 +128,7 @@ func TestKeeper_CheckNewBlockHeader(t *testing.T) { k, ctx, _, _ := keepertest.LightclientKeeper(t) k.SetBlockHeaderVerification(ctx, types.BlockHeaderVerification{ - EnabledChains: []types.EnabledChain{ + HeaderSupportedChains: []types.HeaderSupportedChain{ { ChainId: chains.SepoliaChain.ChainId, Enabled: true, @@ -147,7 +147,7 @@ func TestKeeper_CheckNewBlockHeader(t *testing.T) { k, ctx, _, _ := keepertest.LightclientKeeper(t) k.SetBlockHeaderVerification(ctx, types.BlockHeaderVerification{ - EnabledChains: []types.EnabledChain{ + HeaderSupportedChains: []types.HeaderSupportedChain{ { ChainId: chains.SepoliaChain.ChainId, Enabled: false, @@ -166,7 +166,7 @@ func TestKeeper_CheckNewBlockHeader(t *testing.T) { //t.Run("should succeed if block header is valid with chain state existing", func(t *testing.T) { // k, ctx, _, _ := keepertest.LightclientKeeper(t) // - // k.SetEnabledChain(ctx, types.EnabledChain{ + // k.SetHeaderSupportedChain(ctx, types.HeaderSupportedChain{ // EthTypeChainEnabled: true, // }) // @@ -188,7 +188,7 @@ func TestKeeper_CheckNewBlockHeader(t *testing.T) { k, ctx, _, _ := keepertest.LightclientKeeper(t) k.SetBlockHeaderVerification(ctx, types.BlockHeaderVerification{ - EnabledChains: []types.EnabledChain{ + HeaderSupportedChains: []types.HeaderSupportedChain{ { ChainId: chains.SepoliaChain.ChainId, Enabled: true, @@ -206,7 +206,7 @@ func TestKeeper_CheckNewBlockHeader(t *testing.T) { k, ctx, _, _ := keepertest.LightclientKeeper(t) k.SetBlockHeaderVerification(ctx, types.BlockHeaderVerification{ - EnabledChains: []types.EnabledChain{ + HeaderSupportedChains: []types.HeaderSupportedChain{ { ChainId: chains.SepoliaChain.ChainId, Enabled: true, @@ -230,7 +230,7 @@ func TestKeeper_CheckNewBlockHeader(t *testing.T) { k, ctx, _, _ := keepertest.LightclientKeeper(t) k.SetBlockHeaderVerification(ctx, types.BlockHeaderVerification{ - EnabledChains: []types.EnabledChain{ + HeaderSupportedChains: []types.HeaderSupportedChain{ { ChainId: chains.SepoliaChain.ChainId, Enabled: true, @@ -257,7 +257,7 @@ func TestKeeper_AddBlockHeader(t *testing.T) { k, ctx, _, _ := keepertest.LightclientKeeper(t) k.SetBlockHeaderVerification(ctx, types.BlockHeaderVerification{ - EnabledChains: []types.EnabledChain{ + HeaderSupportedChains: []types.HeaderSupportedChain{ { ChainId: chains.SepoliaChain.ChainId, Enabled: true, @@ -289,7 +289,7 @@ func TestKeeper_AddBlockHeader(t *testing.T) { k, ctx, _, _ := keepertest.LightclientKeeper(t) k.SetBlockHeaderVerification(ctx, types.BlockHeaderVerification{ - EnabledChains: []types.EnabledChain{ + HeaderSupportedChains: []types.HeaderSupportedChain{ { ChainId: chains.SepoliaChain.ChainId, Enabled: true, @@ -329,7 +329,7 @@ func TestKeeper_AddBlockHeader(t *testing.T) { k, ctx, _, _ := keepertest.LightclientKeeper(t) k.SetBlockHeaderVerification(ctx, types.BlockHeaderVerification{ - EnabledChains: []types.EnabledChain{ + HeaderSupportedChains: []types.HeaderSupportedChain{ { ChainId: chains.SepoliaChain.ChainId, Enabled: true, diff --git a/x/lightclient/keeper/block_header_verification.go b/x/lightclient/keeper/block_header_verification.go index 3dc7629a12..5455b672b8 100644 --- a/x/lightclient/keeper/block_header_verification.go +++ b/x/lightclient/keeper/block_header_verification.go @@ -7,14 +7,14 @@ import ( "github.com/zeta-chain/zetacore/x/lightclient/types" ) -// SetVerificationFlags set the verification flags in the store. The key is the chain id +// SetBlockHeaderVerification sets BlockHeaderVerification settings for all chains func (k Keeper) SetBlockHeaderVerification(ctx sdk.Context, bhv types.BlockHeaderVerification) { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.VerificationFlagsKey)) b := k.cdc.MustMarshal(&bhv) store.Set([]byte{0}, b) } -// GetBlockHeaderVerification returns the verification flags +// GetBlockHeaderVerification returns the BlockHeaderVerification settings for all chains func (k Keeper) GetBlockHeaderVerification(ctx sdk.Context) (bhv types.BlockHeaderVerification, found bool) { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.VerificationFlagsKey)) b := store.Get([]byte{0}) @@ -26,8 +26,7 @@ func (k Keeper) GetBlockHeaderVerification(ctx sdk.Context) (bhv types.BlockHead return bhv, true } -// CheckBlockHeaderVerificationEnabled checks for a specific chain if the verification flags are enabled -// It returns an error if the chain is not enabled or the verification flags are not for that chain +// CheckBlockHeaderVerificationEnabled checks for a specific chain if BlockHeaderVerification is enabled or not func (k Keeper) CheckBlockHeaderVerificationEnabled(ctx sdk.Context, chainID int64) error { bhv, found := k.GetBlockHeaderVerification(ctx) if !found { diff --git a/x/lightclient/keeper/block_header_verification_test.go b/x/lightclient/keeper/block_header_verification_test.go index df93ef95a3..2c4ed5900b 100644 --- a/x/lightclient/keeper/block_header_verification_test.go +++ b/x/lightclient/keeper/block_header_verification_test.go @@ -21,7 +21,7 @@ func TestKeeper_GetBlockHeaderVerification(t *testing.T) { blockHeaderVerification, found := k.GetBlockHeaderVerification(ctx) require.True(t, found) - require.Len(t, blockHeaderVerification.EnabledChains, 2) + require.Len(t, blockHeaderVerification.HeaderSupportedChains, 2) require.Equal(t, bhv, blockHeaderVerification) }) @@ -30,7 +30,7 @@ func TestKeeper_GetBlockHeaderVerification(t *testing.T) { blockHeaderVerification, found := k.GetBlockHeaderVerification(ctx) require.False(t, found) - require.Len(t, blockHeaderVerification.EnabledChains, 0) + require.Len(t, blockHeaderVerification.HeaderSupportedChains, 0) }) } @@ -38,7 +38,7 @@ func TestKeeper_CheckVerificationFlagsEnabled(t *testing.T) { t.Run("can check verification flags with ethereum enabled", func(t *testing.T) { k, ctx, _, _ := keepertest.LightclientKeeper(t) k.SetBlockHeaderVerification(ctx, types.BlockHeaderVerification{ - EnabledChains: []types.EnabledChain{ + HeaderSupportedChains: []types.HeaderSupportedChain{ { ChainId: chains.EthChain.ChainId, Enabled: true, @@ -61,7 +61,7 @@ func TestKeeper_CheckVerificationFlagsEnabled(t *testing.T) { t.Run("can check verification flags with bitcoin enabled", func(t *testing.T) { k, ctx, _, _ := keepertest.LightclientKeeper(t) k.SetBlockHeaderVerification(ctx, types.BlockHeaderVerification{ - EnabledChains: []types.EnabledChain{ + HeaderSupportedChains: []types.HeaderSupportedChain{ { ChainId: chains.BtcMainnetChain.ChainId, Enabled: true, @@ -93,7 +93,7 @@ func TestKeeper_CheckVerificationFlagsEnabled(t *testing.T) { t.Run("check returns false is flag is disabled", func(t *testing.T) { k, ctx, _, _ := keepertest.LightclientKeeper(t) k.SetBlockHeaderVerification(ctx, types.BlockHeaderVerification{ - EnabledChains: []types.EnabledChain{ + HeaderSupportedChains: []types.HeaderSupportedChain{ { ChainId: chains.EthChain.ChainId, Enabled: false, diff --git a/x/lightclient/keeper/grpc_query_header_enabled_chains.go b/x/lightclient/keeper/grpc_query_header_enabled_chains.go index 797169155f..c5c2f318e6 100644 --- a/x/lightclient/keeper/grpc_query_header_enabled_chains.go +++ b/x/lightclient/keeper/grpc_query_header_enabled_chains.go @@ -9,8 +9,10 @@ import ( "google.golang.org/grpc/status" ) -// EnabledChain implements the Query/EnabledChain gRPC method -func (k Keeper) HeaderEnabledChains(c context.Context, req *types.QueryHeaderEnabledChainsRequest) (*types.QueryHeaderEnabledChainsResponse, error) { +// HeaderSupportedChains implements the Query/HeaderEnabledChains gRPC method +// It returns a list for chains that support block header verification. +// Some chains in this list might be disabled which is indicated by the value of the `enabled` field. +func (k Keeper) HeaderSupportedChains(c context.Context, req *types.QueryHeaderSupportedChainsRequest) (*types.QueryHeaderSupportedChainsResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "invalid request") } @@ -18,5 +20,19 @@ func (k Keeper) HeaderEnabledChains(c context.Context, req *types.QueryHeaderEna val, _ := k.GetBlockHeaderVerification(ctx) - return &types.QueryHeaderEnabledChainsResponse{EnabledChains: val.GetVerificationFlags()}, nil + return &types.QueryHeaderSupportedChainsResponse{HeaderSupportedChains: val.GetHeaderSupportedChainsList()}, nil +} + +// HeaderEnabledChains implements the Query/HeaderEnabledChains gRPC method +// It returns a list of chains that have block header verification enabled. +func (k Keeper) HeaderEnabledChains(c context.Context, req *types.HeaderEnabledChainsRequest) (*types.HeaderEnabledChainsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + ctx := sdk.UnwrapSDKContext(c) + + val, _ := k.GetBlockHeaderVerification(ctx) + + return &types.HeaderEnabledChainsResponse{HeaderEnabledChains: val.GetHeaderEnabledChains()}, nil + } diff --git a/x/lightclient/keeper/grpc_query_header_enabled_chains_test.go b/x/lightclient/keeper/grpc_query_header_enabled_chains_test.go index 905f5900bd..8b13ba1b95 100644 --- a/x/lightclient/keeper/grpc_query_header_enabled_chains_test.go +++ b/x/lightclient/keeper/grpc_query_header_enabled_chains_test.go @@ -10,12 +10,12 @@ import ( "github.com/zeta-chain/zetacore/x/lightclient/types" ) -func TestKeeper_VerificationFlags(t *testing.T) { +func TestKeeper_HeaderSupportedChains(t *testing.T) { t.Run("should error if req is nil", func(t *testing.T) { k, ctx, _, _ := keepertest.LightclientKeeper(t) wctx := sdk.WrapSDKContext(ctx) - res, err := k.HeaderEnabledChains(wctx, nil) + res, err := k.HeaderSupportedChains(wctx, nil) require.Nil(t, res) require.Error(t, err) }) @@ -24,8 +24,8 @@ func TestKeeper_VerificationFlags(t *testing.T) { k, ctx, _, _ := keepertest.LightclientKeeper(t) wctx := sdk.WrapSDKContext(ctx) - res, _ := k.HeaderEnabledChains(wctx, &types.QueryHeaderEnabledChainsRequest{}) - require.Len(t, res.EnabledChains, 0) + res, _ := k.HeaderSupportedChains(wctx, &types.QueryHeaderSupportedChainsRequest{}) + require.Len(t, res.HeaderSupportedChains, 0) }) t.Run("should return if block header state is found", func(t *testing.T) { @@ -34,8 +34,8 @@ func TestKeeper_VerificationFlags(t *testing.T) { bhv := sample.BlockHeaderVerification() k.SetBlockHeaderVerification(ctx, bhv) - res, err := k.HeaderEnabledChains(wctx, &types.QueryHeaderEnabledChainsRequest{}) + res, err := k.HeaderSupportedChains(wctx, &types.QueryHeaderSupportedChainsRequest{}) require.NoError(t, err) - require.Equal(t, bhv.EnabledChains, res.EnabledChains) + require.Equal(t, bhv.HeaderSupportedChains, res.HeaderSupportedChains) }) } diff --git a/x/lightclient/keeper/msg_server_disable_block_header_verification._test.go b/x/lightclient/keeper/msg_server_disable_block_header_verification._test.go index b3f8c23961..122de250f2 100644 --- a/x/lightclient/keeper/msg_server_disable_block_header_verification._test.go +++ b/x/lightclient/keeper/msg_server_disable_block_header_verification._test.go @@ -25,7 +25,7 @@ func TestMsgServer_DisableVerificationFlags(t *testing.T) { authorityMock := keepertest.GetLightclientAuthorityMock(t, k) k.SetBlockHeaderVerification(ctx, types.BlockHeaderVerification{ - EnabledChains: []types.EnabledChain{ + HeaderSupportedChains: []types.HeaderSupportedChain{ { ChainId: chains.EthChain.ChainId, Enabled: true, @@ -62,7 +62,7 @@ func TestMsgServer_DisableVerificationFlags(t *testing.T) { authorityMock := keepertest.GetLightclientAuthorityMock(t, k) k.SetBlockHeaderVerification(ctx, types.BlockHeaderVerification{ - EnabledChains: []types.EnabledChain{ + HeaderSupportedChains: []types.HeaderSupportedChain{ { ChainId: chains.EthChain.ChainId, Enabled: true, diff --git a/x/lightclient/keeper/msg_server_enable_block_header_verification_test.go b/x/lightclient/keeper/msg_server_enable_block_header_verification_test.go index 28e4ed765e..87d21cf211 100644 --- a/x/lightclient/keeper/msg_server_enable_block_header_verification_test.go +++ b/x/lightclient/keeper/msg_server_enable_block_header_verification_test.go @@ -25,7 +25,7 @@ func TestMsgServer_EnableVerificationFlags(t *testing.T) { authorityMock := keepertest.GetLightclientAuthorityMock(t, k) k.SetBlockHeaderVerification(ctx, types.BlockHeaderVerification{ - EnabledChains: []types.EnabledChain{ + HeaderSupportedChains: []types.HeaderSupportedChain{ { ChainId: chains.EthChain.ChainId, Enabled: false, @@ -84,7 +84,7 @@ func TestMsgServer_EnableVerificationFlags(t *testing.T) { authorityMock := keepertest.GetLightclientAuthorityMock(t, k) k.SetBlockHeaderVerification(ctx, types.BlockHeaderVerification{ - EnabledChains: []types.EnabledChain{ + HeaderSupportedChains: []types.HeaderSupportedChain{ { ChainId: chains.EthChain.ChainId, Enabled: false, diff --git a/x/lightclient/keeper/proof.go b/x/lightclient/keeper/proof.go index 6720bc3c7d..8b84cd7977 100644 --- a/x/lightclient/keeper/proof.go +++ b/x/lightclient/keeper/proof.go @@ -11,7 +11,7 @@ import ( // VerifyProof verifies the merkle proof for a given chain and block header // It returns the transaction bytes if the proof is valid func (k Keeper) VerifyProof(ctx sdk.Context, proof *proofs.Proof, chainID int64, blockHash string, txIndex int64) ([]byte, error) { - // check verification flags are set + // check block header verification is set if err := k.CheckBlockHeaderVerificationEnabled(ctx, chainID); err != nil { return nil, err } diff --git a/x/lightclient/keeper/proof_test.go b/x/lightclient/keeper/proof_test.go index 8492230467..11633f4b82 100644 --- a/x/lightclient/keeper/proof_test.go +++ b/x/lightclient/keeper/proof_test.go @@ -24,7 +24,7 @@ func TestKeeper_VerifyProof(t *testing.T) { k, ctx, _, _ := keepertest.LightclientKeeper(t) k.SetBlockHeaderVerification(ctx, types.BlockHeaderVerification{ - EnabledChains: []types.EnabledChain{ + HeaderSupportedChains: []types.HeaderSupportedChain{ { ChainId: chains.BtcMainnetChain.ChainId, Enabled: false, @@ -40,7 +40,7 @@ func TestKeeper_VerifyProof(t *testing.T) { k, ctx, _, _ := keepertest.LightclientKeeper(t) k.SetBlockHeaderVerification(ctx, types.BlockHeaderVerification{ - EnabledChains: []types.EnabledChain{ + HeaderSupportedChains: []types.HeaderSupportedChain{ { ChainId: chains.EthChain.ChainId, Enabled: false, @@ -55,7 +55,7 @@ func TestKeeper_VerifyProof(t *testing.T) { k, ctx, _, _ := keepertest.LightclientKeeper(t) k.SetBlockHeaderVerification(ctx, types.BlockHeaderVerification{ - EnabledChains: []types.EnabledChain{ + HeaderSupportedChains: []types.HeaderSupportedChain{ { ChainId: chains.BtcMainnetChain.ChainId, Enabled: false, @@ -75,7 +75,7 @@ func TestKeeper_VerifyProof(t *testing.T) { k, ctx, _, _ := keepertest.LightclientKeeper(t) k.SetBlockHeaderVerification(ctx, types.BlockHeaderVerification{ - EnabledChains: []types.EnabledChain{ + HeaderSupportedChains: []types.HeaderSupportedChain{ { ChainId: chains.BtcMainnetChain.ChainId, Enabled: true, @@ -95,7 +95,7 @@ func TestKeeper_VerifyProof(t *testing.T) { k, ctx, _, _ := keepertest.LightclientKeeper(t) k.SetBlockHeaderVerification(ctx, types.BlockHeaderVerification{ - EnabledChains: []types.EnabledChain{ + HeaderSupportedChains: []types.HeaderSupportedChain{ { ChainId: chains.BtcMainnetChain.ChainId, Enabled: true, @@ -117,7 +117,7 @@ func TestKeeper_VerifyProof(t *testing.T) { proof, blockHeader, blockHash, txIndex, chainID, _ := sample.Proof(t) k.SetBlockHeaderVerification(ctx, types.BlockHeaderVerification{ - EnabledChains: []types.EnabledChain{ + HeaderSupportedChains: []types.HeaderSupportedChain{ { ChainId: chains.BtcMainnetChain.ChainId, Enabled: true, @@ -142,7 +142,7 @@ func TestKeeper_VerifyProof(t *testing.T) { proof, blockHeader, blockHash, txIndex, chainID, _ := sample.Proof(t) k.SetBlockHeaderVerification(ctx, types.BlockHeaderVerification{ - EnabledChains: []types.EnabledChain{ + HeaderSupportedChains: []types.HeaderSupportedChain{ { ChainId: chains.BtcMainnetChain.ChainId, Enabled: true, diff --git a/x/lightclient/types/block_header_verification.go b/x/lightclient/types/block_header_verification.go index f8359ba297..47f0e855ee 100644 --- a/x/lightclient/types/block_header_verification.go +++ b/x/lightclient/types/block_header_verification.go @@ -1,39 +1,46 @@ package types +// EnableChain enables block header verification for a specific chain func (b *BlockHeaderVerification) EnableChain(chainID int64) { found := false - for i, enabledChain := range b.EnabledChains { + for i, enabledChain := range b.HeaderSupportedChains { if enabledChain.ChainId == chainID { - b.EnabledChains[i].Enabled = true + b.HeaderSupportedChains[i].Enabled = true found = true } } if !found { - b.EnabledChains = append(b.EnabledChains, EnabledChain{ + b.HeaderSupportedChains = append(b.HeaderSupportedChains, HeaderSupportedChain{ ChainId: chainID, Enabled: true, }) } } +// DisableChain disables block header verification for a specific chain +// This function does not remove the chain from the list of enabled chains, it just disables it +// This keeps track of the chains tha support block header verification and also the ones that currently disabled or enabled func (b *BlockHeaderVerification) DisableChain(chainID int64) { found := false - for i, v := range b.EnabledChains { + for i, v := range b.HeaderSupportedChains { if v.ChainId == chainID { - b.EnabledChains[i].Enabled = false + b.HeaderSupportedChains[i].Enabled = false found = true } } if !found { - b.EnabledChains = append(b.EnabledChains, EnabledChain{ + b.HeaderSupportedChains = append(b.HeaderSupportedChains, HeaderSupportedChain{ ChainId: chainID, Enabled: false, }) } } +// IsChainEnabled checks if block header verification is enabled for a specific chain +// It returns true if the chain is enabled, false otherwise +// If the chain is not found in the list of chains, it returns false func (b *BlockHeaderVerification) IsChainEnabled(chainID int64) bool { - for _, v := range b.EnabledChains { + for _, v := range b.HeaderSupportedChains { if v.ChainId == chainID { return v.Enabled } @@ -41,9 +48,10 @@ func (b *BlockHeaderVerification) IsChainEnabled(chainID int64) bool { return false } -func (b *BlockHeaderVerification) GetEnabledChainIDList() []int64 { +// GetHeaderSupportedChainIDList returns a list of chain IDs that have block header verification enabled +func (b *BlockHeaderVerification) GetHeaderEnabledChainIDs() []int64 { var enabledChains []int64 - for _, v := range b.EnabledChains { + for _, v := range b.HeaderSupportedChains { if v.Enabled { enabledChains = append(enabledChains, v.ChainId) } @@ -51,9 +59,24 @@ func (b *BlockHeaderVerification) GetEnabledChainIDList() []int64 { return enabledChains } -func (b *BlockHeaderVerification) GetVerificationFlags() []EnabledChain { - if b == nil || b.EnabledChains == nil { - return []EnabledChain{} +// GetHeaderSupportedChainsList returns a list of chains that support block header verification +func (b *BlockHeaderVerification) GetHeaderSupportedChainsList() []HeaderSupportedChain { + if b == nil || b.HeaderSupportedChains == nil { + return []HeaderSupportedChain{} } - return b.EnabledChains + return b.HeaderSupportedChains +} + +// GetHeaderEnabledChains returns a list of chains that have block header verification enabled +func (b *BlockHeaderVerification) GetHeaderEnabledChains() []HeaderSupportedChain { + var chains []HeaderSupportedChain + if b == nil || b.HeaderSupportedChains == nil { + return []HeaderSupportedChain{} + } + for _, chain := range b.HeaderSupportedChains { + if chain.Enabled { + chains = append(chains, chain) + } + } + return chains } diff --git a/x/lightclient/types/verification_flags.pb.go b/x/lightclient/types/block_header_verification.pb.go similarity index 57% rename from x/lightclient/types/verification_flags.pb.go rename to x/lightclient/types/block_header_verification.pb.go index 6c1eccaf60..9cb6435377 100644 --- a/x/lightclient/types/verification_flags.pb.go +++ b/x/lightclient/types/block_header_verification.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: lightclient/verification_flags.proto +// source: lightclient/block_header_verification.proto package types @@ -25,23 +25,23 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // VerificationFlags is a structure containing information of weather a chain is enabled or not for block header verification -type EnabledChain struct { +type HeaderSupportedChain struct { ChainId int64 `protobuf:"varint,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` Enabled bool `protobuf:"varint,2,opt,name=enabled,proto3" json:"enabled,omitempty"` } -func (m *EnabledChain) Reset() { *m = EnabledChain{} } -func (m *EnabledChain) String() string { return proto.CompactTextString(m) } -func (*EnabledChain) ProtoMessage() {} -func (*EnabledChain) Descriptor() ([]byte, []int) { - return fileDescriptor_86eae6d737b3f8cc, []int{0} +func (m *HeaderSupportedChain) Reset() { *m = HeaderSupportedChain{} } +func (m *HeaderSupportedChain) String() string { return proto.CompactTextString(m) } +func (*HeaderSupportedChain) ProtoMessage() {} +func (*HeaderSupportedChain) Descriptor() ([]byte, []int) { + return fileDescriptor_8d165c67bfda80f3, []int{0} } -func (m *EnabledChain) XXX_Unmarshal(b []byte) error { +func (m *HeaderSupportedChain) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *EnabledChain) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *HeaderSupportedChain) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_EnabledChain.Marshal(b, m, deterministic) + return xxx_messageInfo_HeaderSupportedChain.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -51,26 +51,26 @@ func (m *EnabledChain) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) return b[:n], nil } } -func (m *EnabledChain) XXX_Merge(src proto.Message) { - xxx_messageInfo_EnabledChain.Merge(m, src) +func (m *HeaderSupportedChain) XXX_Merge(src proto.Message) { + xxx_messageInfo_HeaderSupportedChain.Merge(m, src) } -func (m *EnabledChain) XXX_Size() int { +func (m *HeaderSupportedChain) XXX_Size() int { return m.Size() } -func (m *EnabledChain) XXX_DiscardUnknown() { - xxx_messageInfo_EnabledChain.DiscardUnknown(m) +func (m *HeaderSupportedChain) XXX_DiscardUnknown() { + xxx_messageInfo_HeaderSupportedChain.DiscardUnknown(m) } -var xxx_messageInfo_EnabledChain proto.InternalMessageInfo +var xxx_messageInfo_HeaderSupportedChain proto.InternalMessageInfo -func (m *EnabledChain) GetChainId() int64 { +func (m *HeaderSupportedChain) GetChainId() int64 { if m != nil { return m.ChainId } return 0 } -func (m *EnabledChain) GetEnabled() bool { +func (m *HeaderSupportedChain) GetEnabled() bool { if m != nil { return m.Enabled } @@ -78,14 +78,14 @@ func (m *EnabledChain) GetEnabled() bool { } type BlockHeaderVerification struct { - EnabledChains []EnabledChain `protobuf:"bytes,1,rep,name=enabled_chains,json=enabledChains,proto3" json:"enabled_chains"` + HeaderSupportedChains []HeaderSupportedChain `protobuf:"bytes,1,rep,name=header_supported_chains,json=headerSupportedChains,proto3" json:"header_supported_chains"` } func (m *BlockHeaderVerification) Reset() { *m = BlockHeaderVerification{} } func (m *BlockHeaderVerification) String() string { return proto.CompactTextString(m) } func (*BlockHeaderVerification) ProtoMessage() {} func (*BlockHeaderVerification) Descriptor() ([]byte, []int) { - return fileDescriptor_86eae6d737b3f8cc, []int{1} + return fileDescriptor_8d165c67bfda80f3, []int{1} } func (m *BlockHeaderVerification) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -114,44 +114,45 @@ func (m *BlockHeaderVerification) XXX_DiscardUnknown() { var xxx_messageInfo_BlockHeaderVerification proto.InternalMessageInfo -func (m *BlockHeaderVerification) GetEnabledChains() []EnabledChain { +func (m *BlockHeaderVerification) GetHeaderSupportedChains() []HeaderSupportedChain { if m != nil { - return m.EnabledChains + return m.HeaderSupportedChains } return nil } func init() { - proto.RegisterType((*EnabledChain)(nil), "zetachain.zetacore.lightclient.EnabledChain") + proto.RegisterType((*HeaderSupportedChain)(nil), "zetachain.zetacore.lightclient.HeaderSupportedChain") proto.RegisterType((*BlockHeaderVerification)(nil), "zetachain.zetacore.lightclient.BlockHeaderVerification") } func init() { - proto.RegisterFile("lightclient/verification_flags.proto", fileDescriptor_86eae6d737b3f8cc) + proto.RegisterFile("lightclient/block_header_verification.proto", fileDescriptor_8d165c67bfda80f3) } -var fileDescriptor_86eae6d737b3f8cc = []byte{ - // 266 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xc9, 0xc9, 0x4c, 0xcf, - 0x28, 0x49, 0xce, 0xc9, 0x4c, 0xcd, 0x2b, 0xd1, 0x2f, 0x4b, 0x2d, 0xca, 0x4c, 0xcb, 0x4c, 0x4e, - 0x2c, 0xc9, 0xcc, 0xcf, 0x8b, 0x4f, 0xcb, 0x49, 0x4c, 0x2f, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, - 0x17, 0x92, 0xab, 0x4a, 0x2d, 0x49, 0x4c, 0xce, 0x48, 0xcc, 0xcc, 0xd3, 0x03, 0xb3, 0xf2, 0x8b, - 0x52, 0xf5, 0x90, 0x34, 0x4a, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0x95, 0xea, 0x83, 0x58, 0x10, - 0x5d, 0x4a, 0xce, 0x5c, 0x3c, 0xae, 0x79, 0x89, 0x49, 0x39, 0xa9, 0x29, 0xce, 0x20, 0xad, 0x42, - 0x92, 0x5c, 0x1c, 0x60, 0x33, 0xe2, 0x33, 0x53, 0x24, 0x18, 0x15, 0x18, 0x35, 0x98, 0x83, 0xd8, - 0xc1, 0x7c, 0xcf, 0x14, 0x21, 0x09, 0x2e, 0xf6, 0x54, 0x88, 0x52, 0x09, 0x26, 0x05, 0x46, 0x0d, - 0x8e, 0x20, 0x18, 0x57, 0xa9, 0x84, 0x4b, 0xdc, 0x29, 0x27, 0x3f, 0x39, 0xdb, 0x23, 0x35, 0x31, - 0x25, 0xb5, 0x28, 0x0c, 0xc9, 0x85, 0x42, 0x91, 0x5c, 0x7c, 0x50, 0x55, 0xf1, 0x60, 0x73, 0x8a, - 0x25, 0x18, 0x15, 0x98, 0x35, 0xb8, 0x8d, 0x74, 0xf4, 0xf0, 0x3b, 0x57, 0x0f, 0xd9, 0x55, 0x4e, - 0x2c, 0x27, 0xee, 0xc9, 0x33, 0x04, 0xf1, 0xa6, 0x22, 0x89, 0x15, 0x3b, 0xf9, 0x9c, 0x78, 0x24, - 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, - 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x51, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, - 0x72, 0x7e, 0xae, 0x3e, 0xc8, 0x70, 0x5d, 0xb0, 0x3d, 0xfa, 0x30, 0x7b, 0xf4, 0x2b, 0xf4, 0x91, - 0x43, 0xb4, 0xa4, 0xb2, 0x20, 0xb5, 0x38, 0x89, 0x0d, 0x1c, 0x1e, 0xc6, 0x80, 0x00, 0x00, 0x00, - 0xff, 0xff, 0xc2, 0x8d, 0x20, 0x39, 0x6d, 0x01, 0x00, 0x00, +var fileDescriptor_8d165c67bfda80f3 = []byte{ + // 281 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0xce, 0xc9, 0x4c, 0xcf, + 0x28, 0x49, 0xce, 0xc9, 0x4c, 0xcd, 0x2b, 0xd1, 0x4f, 0xca, 0xc9, 0x4f, 0xce, 0x8e, 0xcf, 0x48, + 0x4d, 0x4c, 0x49, 0x2d, 0x8a, 0x2f, 0x4b, 0x2d, 0xca, 0x4c, 0xcb, 0x4c, 0x4e, 0x2c, 0xc9, 0xcc, + 0xcf, 0xd3, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0xab, 0x4a, 0x2d, 0x49, 0x4c, 0xce, 0x48, + 0xcc, 0xcc, 0xd3, 0x03, 0xb3, 0xf2, 0x8b, 0x52, 0xf5, 0x90, 0xf4, 0x4b, 0x89, 0xa4, 0xe7, 0xa7, + 0xe7, 0x83, 0x95, 0xea, 0x83, 0x58, 0x10, 0x5d, 0x4a, 0xde, 0x5c, 0x22, 0x1e, 0x60, 0x23, 0x83, + 0x4b, 0x0b, 0x0a, 0xf2, 0x8b, 0x4a, 0x52, 0x53, 0x9c, 0x41, 0x46, 0x08, 0x49, 0x72, 0x71, 0x80, + 0xcd, 0x8a, 0xcf, 0x4c, 0x91, 0x60, 0x54, 0x60, 0xd4, 0x60, 0x0e, 0x62, 0x07, 0xf3, 0x3d, 0x53, + 0x84, 0x24, 0xb8, 0xd8, 0x53, 0xf3, 0x12, 0x93, 0x72, 0x52, 0x53, 0x24, 0x98, 0x14, 0x18, 0x35, + 0x38, 0x82, 0x60, 0x5c, 0xa5, 0x5e, 0x46, 0x2e, 0x71, 0x27, 0x90, 0x33, 0x21, 0x46, 0x86, 0x21, + 0x39, 0x52, 0xa8, 0x88, 0x4b, 0x1c, 0xea, 0xf6, 0x62, 0x98, 0x4d, 0xf1, 0x60, 0x13, 0x8b, 0x25, + 0x18, 0x15, 0x98, 0x35, 0xb8, 0x8d, 0x4c, 0xf4, 0xf0, 0x7b, 0x40, 0x0f, 0x9b, 0x3b, 0x9d, 0x58, + 0x4e, 0xdc, 0x93, 0x67, 0x08, 0x12, 0xcd, 0xc0, 0x22, 0x57, 0xec, 0xe4, 0x73, 0xe2, 0x91, 0x1c, + 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, + 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x51, 0x46, 0xe9, 0x99, 0x25, 0x19, 0xa5, 0x49, 0x7a, 0xc9, + 0xf9, 0xb9, 0xfa, 0x20, 0xcb, 0x74, 0xc1, 0xf6, 0xea, 0xc3, 0xec, 0xd5, 0xaf, 0xd0, 0x47, 0x0e, + 0xfa, 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0x70, 0x88, 0x19, 0x03, 0x02, 0x00, 0x00, 0xff, + 0xff, 0x6e, 0xea, 0x75, 0xab, 0x96, 0x01, 0x00, 0x00, } -func (m *EnabledChain) Marshal() (dAtA []byte, err error) { +func (m *HeaderSupportedChain) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -161,12 +162,12 @@ func (m *EnabledChain) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *EnabledChain) MarshalTo(dAtA []byte) (int, error) { +func (m *HeaderSupportedChain) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *EnabledChain) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *HeaderSupportedChain) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -182,7 +183,7 @@ func (m *EnabledChain) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0x10 } if m.ChainId != 0 { - i = encodeVarintVerificationFlags(dAtA, i, uint64(m.ChainId)) + i = encodeVarintBlockHeaderVerification(dAtA, i, uint64(m.ChainId)) i-- dAtA[i] = 0x8 } @@ -209,15 +210,15 @@ func (m *BlockHeaderVerification) MarshalToSizedBuffer(dAtA []byte) (int, error) _ = i var l int _ = l - if len(m.EnabledChains) > 0 { - for iNdEx := len(m.EnabledChains) - 1; iNdEx >= 0; iNdEx-- { + if len(m.HeaderSupportedChains) > 0 { + for iNdEx := len(m.HeaderSupportedChains) - 1; iNdEx >= 0; iNdEx-- { { - size, err := m.EnabledChains[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + size, err := m.HeaderSupportedChains[iNdEx].MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } i -= size - i = encodeVarintVerificationFlags(dAtA, i, uint64(size)) + i = encodeVarintBlockHeaderVerification(dAtA, i, uint64(size)) } i-- dAtA[i] = 0xa @@ -226,8 +227,8 @@ func (m *BlockHeaderVerification) MarshalToSizedBuffer(dAtA []byte) (int, error) return len(dAtA) - i, nil } -func encodeVarintVerificationFlags(dAtA []byte, offset int, v uint64) int { - offset -= sovVerificationFlags(v) +func encodeVarintBlockHeaderVerification(dAtA []byte, offset int, v uint64) int { + offset -= sovBlockHeaderVerification(v) base := offset for v >= 1<<7 { dAtA[offset] = uint8(v&0x7f | 0x80) @@ -237,14 +238,14 @@ func encodeVarintVerificationFlags(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *EnabledChain) Size() (n int) { +func (m *HeaderSupportedChain) Size() (n int) { if m == nil { return 0 } var l int _ = l if m.ChainId != 0 { - n += 1 + sovVerificationFlags(uint64(m.ChainId)) + n += 1 + sovBlockHeaderVerification(uint64(m.ChainId)) } if m.Enabled { n += 2 @@ -258,22 +259,22 @@ func (m *BlockHeaderVerification) Size() (n int) { } var l int _ = l - if len(m.EnabledChains) > 0 { - for _, e := range m.EnabledChains { + if len(m.HeaderSupportedChains) > 0 { + for _, e := range m.HeaderSupportedChains { l = e.Size() - n += 1 + l + sovVerificationFlags(uint64(l)) + n += 1 + l + sovBlockHeaderVerification(uint64(l)) } } return n } -func sovVerificationFlags(x uint64) (n int) { +func sovBlockHeaderVerification(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } -func sozVerificationFlags(x uint64) (n int) { - return sovVerificationFlags(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +func sozBlockHeaderVerification(x uint64) (n int) { + return sovBlockHeaderVerification(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *EnabledChain) Unmarshal(dAtA []byte) error { +func (m *HeaderSupportedChain) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -281,7 +282,7 @@ func (m *EnabledChain) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowVerificationFlags + return ErrIntOverflowBlockHeaderVerification } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -296,10 +297,10 @@ func (m *EnabledChain) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: EnabledChain: wiretype end group for non-group") + return fmt.Errorf("proto: HeaderSupportedChain: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: EnabledChain: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: HeaderSupportedChain: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -309,7 +310,7 @@ func (m *EnabledChain) Unmarshal(dAtA []byte) error { m.ChainId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowVerificationFlags + return ErrIntOverflowBlockHeaderVerification } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -328,7 +329,7 @@ func (m *EnabledChain) Unmarshal(dAtA []byte) error { var v int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowVerificationFlags + return ErrIntOverflowBlockHeaderVerification } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -343,12 +344,12 @@ func (m *EnabledChain) Unmarshal(dAtA []byte) error { m.Enabled = bool(v != 0) default: iNdEx = preIndex - skippy, err := skipVerificationFlags(dAtA[iNdEx:]) + skippy, err := skipBlockHeaderVerification(dAtA[iNdEx:]) if err != nil { return err } if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthVerificationFlags + return ErrInvalidLengthBlockHeaderVerification } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -370,7 +371,7 @@ func (m *BlockHeaderVerification) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowVerificationFlags + return ErrIntOverflowBlockHeaderVerification } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -393,12 +394,12 @@ func (m *BlockHeaderVerification) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field EnabledChains", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field HeaderSupportedChains", wireType) } var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowVerificationFlags + return ErrIntOverflowBlockHeaderVerification } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -411,28 +412,28 @@ func (m *BlockHeaderVerification) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthVerificationFlags + return ErrInvalidLengthBlockHeaderVerification } postIndex := iNdEx + msglen if postIndex < 0 { - return ErrInvalidLengthVerificationFlags + return ErrInvalidLengthBlockHeaderVerification } if postIndex > l { return io.ErrUnexpectedEOF } - m.EnabledChains = append(m.EnabledChains, EnabledChain{}) - if err := m.EnabledChains[len(m.EnabledChains)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.HeaderSupportedChains = append(m.HeaderSupportedChains, HeaderSupportedChain{}) + if err := m.HeaderSupportedChains[len(m.HeaderSupportedChains)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex default: iNdEx = preIndex - skippy, err := skipVerificationFlags(dAtA[iNdEx:]) + skippy, err := skipBlockHeaderVerification(dAtA[iNdEx:]) if err != nil { return err } if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthVerificationFlags + return ErrInvalidLengthBlockHeaderVerification } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -446,7 +447,7 @@ func (m *BlockHeaderVerification) Unmarshal(dAtA []byte) error { } return nil } -func skipVerificationFlags(dAtA []byte) (n int, err error) { +func skipBlockHeaderVerification(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 depth := 0 @@ -454,7 +455,7 @@ func skipVerificationFlags(dAtA []byte) (n int, err error) { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return 0, ErrIntOverflowVerificationFlags + return 0, ErrIntOverflowBlockHeaderVerification } if iNdEx >= l { return 0, io.ErrUnexpectedEOF @@ -471,7 +472,7 @@ func skipVerificationFlags(dAtA []byte) (n int, err error) { case 0: for shift := uint(0); ; shift += 7 { if shift >= 64 { - return 0, ErrIntOverflowVerificationFlags + return 0, ErrIntOverflowBlockHeaderVerification } if iNdEx >= l { return 0, io.ErrUnexpectedEOF @@ -487,7 +488,7 @@ func skipVerificationFlags(dAtA []byte) (n int, err error) { var length int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return 0, ErrIntOverflowVerificationFlags + return 0, ErrIntOverflowBlockHeaderVerification } if iNdEx >= l { return 0, io.ErrUnexpectedEOF @@ -500,14 +501,14 @@ func skipVerificationFlags(dAtA []byte) (n int, err error) { } } if length < 0 { - return 0, ErrInvalidLengthVerificationFlags + return 0, ErrInvalidLengthBlockHeaderVerification } iNdEx += length case 3: depth++ case 4: if depth == 0 { - return 0, ErrUnexpectedEndOfGroupVerificationFlags + return 0, ErrUnexpectedEndOfGroupBlockHeaderVerification } depth-- case 5: @@ -516,7 +517,7 @@ func skipVerificationFlags(dAtA []byte) (n int, err error) { return 0, fmt.Errorf("proto: illegal wireType %d", wireType) } if iNdEx < 0 { - return 0, ErrInvalidLengthVerificationFlags + return 0, ErrInvalidLengthBlockHeaderVerification } if depth == 0 { return iNdEx, nil @@ -526,7 +527,7 @@ func skipVerificationFlags(dAtA []byte) (n int, err error) { } var ( - ErrInvalidLengthVerificationFlags = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowVerificationFlags = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupVerificationFlags = fmt.Errorf("proto: unexpected end of group") + ErrInvalidLengthBlockHeaderVerification = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowBlockHeaderVerification = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupBlockHeaderVerification = fmt.Errorf("proto: unexpected end of group") ) diff --git a/x/lightclient/types/block_header_verification_test.go b/x/lightclient/types/block_header_verification_test.go index a470a62ca0..48dcc0d22f 100644 --- a/x/lightclient/types/block_header_verification_test.go +++ b/x/lightclient/types/block_header_verification_test.go @@ -18,7 +18,7 @@ func TestBlockHeaderVerification_EnableChain(t *testing.T) { t.Run("should not enable chain is present", func(t *testing.T) { bhv := types.BlockHeaderVerification{ - EnabledChains: []types.EnabledChain{{ChainId: chains.BscMainnetChain.ChainId, Enabled: false}}} + HeaderSupportedChains: []types.HeaderSupportedChain{{ChainId: chains.BscMainnetChain.ChainId, Enabled: false}}} bhv.EnableChain(chains.BscMainnetChain.ChainId) require.True(t, bhv.IsChainEnabled(chains.BscMainnetChain.ChainId)) }) @@ -33,7 +33,7 @@ func TestBlockHeaderVerification_DisableChain(t *testing.T) { t.Run("should disable chain if chain present", func(t *testing.T) { bhv := types.BlockHeaderVerification{ - EnabledChains: []types.EnabledChain{{ChainId: chains.BscMainnetChain.ChainId, Enabled: true}}} + HeaderSupportedChains: []types.HeaderSupportedChain{{ChainId: chains.BscMainnetChain.ChainId, Enabled: true}}} bhv.DisableChain(chains.BscMainnetChain.ChainId) require.False(t, bhv.IsChainEnabled(chains.BscMainnetChain.ChainId)) }) @@ -47,7 +47,7 @@ func TestBlockHeaderVerification_IsChainEnabled(t *testing.T) { t.Run("should return false if chain is disabled", func(t *testing.T) { bhv := types.BlockHeaderVerification{ - EnabledChains: []types.EnabledChain{{ChainId: 1, Enabled: false}}} + HeaderSupportedChains: []types.HeaderSupportedChain{{ChainId: 1, Enabled: false}}} require.False(t, bhv.IsChainEnabled(1)) }) @@ -56,3 +56,74 @@ func TestBlockHeaderVerification_IsChainEnabled(t *testing.T) { require.False(t, bhv.IsChainEnabled(1000)) }) } + +func TestBlockHeaderVerification_GetEnabledChainIDList(t *testing.T) { + t.Run("should return list of enabled chain ids", func(t *testing.T) { + bhv := sample.BlockHeaderVerification() + enabledChains := bhv.GetHeaderEnabledChainIDs() + require.Len(t, enabledChains, 2) + require.Contains(t, enabledChains, int64(1)) + require.Contains(t, enabledChains, int64(2)) + }) + + t.Run("should return empty list if no chain is enabled", func(t *testing.T) { + bhv := types.BlockHeaderVerification{ + HeaderSupportedChains: []types.HeaderSupportedChain{{ChainId: 1, Enabled: false}, {ChainId: 2, Enabled: false}}} + enabledChains := bhv.GetHeaderEnabledChainIDs() + require.Len(t, enabledChains, 0) + }) + + t.Run("should return empty list if no chain is present", func(t *testing.T) { + bhv := types.BlockHeaderVerification{} + enabledChains := bhv.GetHeaderEnabledChainIDs() + require.Len(t, enabledChains, 0) + }) +} + +func TestBlockHeaderVerification_GetEnabledChainsList(t *testing.T) { + t.Run("should return list of enabled chains", func(t *testing.T) { + bhv := sample.BlockHeaderVerification() + enabledChains := bhv.GetHeaderEnabledChains() + require.Len(t, enabledChains, 2) + require.Contains(t, enabledChains, types.HeaderSupportedChain{ChainId: 1, Enabled: true}) + require.Contains(t, enabledChains, types.HeaderSupportedChain{ChainId: 2, Enabled: true}) + }) + + t.Run("should return empty list if no chain is enabled", func(t *testing.T) { + bhv := types.BlockHeaderVerification{ + HeaderSupportedChains: []types.HeaderSupportedChain{{ChainId: 1, Enabled: false}, {ChainId: 2, Enabled: false}}} + enabledChains := bhv.GetHeaderEnabledChains() + require.Len(t, enabledChains, 0) + }) + + t.Run("should return empty list if no chain is present", func(t *testing.T) { + bhv := types.BlockHeaderVerification{} + enabledChains := bhv.GetHeaderEnabledChains() + require.Len(t, enabledChains, 0) + }) +} + +func TestBlockHeaderVerification_GetSupportedChainsList(t *testing.T) { + t.Run("should return list of supported chains", func(t *testing.T) { + bhv := sample.BlockHeaderVerification() + supportedChains := bhv.GetHeaderSupportedChainsList() + require.Len(t, supportedChains, 2) + require.Contains(t, supportedChains, types.HeaderSupportedChain{ChainId: 1, Enabled: true}) + require.Contains(t, supportedChains, types.HeaderSupportedChain{ChainId: 2, Enabled: true}) + }) + + t.Run("should return empty list if no chain is present", func(t *testing.T) { + bhv := types.BlockHeaderVerification{} + supportedChains := bhv.GetHeaderSupportedChainsList() + require.Len(t, supportedChains, 0) + }) + + t.Run("should items even if chain is not enabled but still supported", func(t *testing.T) { + bhv := types.BlockHeaderVerification{ + HeaderSupportedChains: []types.HeaderSupportedChain{{ChainId: 1, Enabled: false}, {ChainId: 2, Enabled: false}}} + supportedChains := bhv.GetHeaderSupportedChains() + require.Len(t, supportedChains, 2) + require.Contains(t, supportedChains, types.HeaderSupportedChain{ChainId: 1, Enabled: false}) + require.Contains(t, supportedChains, types.HeaderSupportedChain{ChainId: 2, Enabled: false}) + }) +} diff --git a/x/lightclient/types/genesis.pb.go b/x/lightclient/types/genesis.pb.go index 87ab1d7f4e..8225e5697d 100644 --- a/x/lightclient/types/genesis.pb.go +++ b/x/lightclient/types/genesis.pb.go @@ -93,27 +93,27 @@ func init() { func init() { proto.RegisterFile("lightclient/genesis.proto", fileDescriptor_645b5300b371cd43) } var fileDescriptor_645b5300b371cd43 = []byte{ - // 317 bytes of a gzipped FileDescriptorProto + // 312 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xcc, 0xc9, 0x4c, 0xcf, 0x28, 0x49, 0xce, 0xc9, 0x4c, 0xcd, 0x2b, 0xd1, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0xab, 0x4a, 0x2d, 0x49, 0x4c, 0xce, 0x48, 0xcc, 0xcc, 0xd3, 0x03, 0xb3, 0xf2, 0x8b, 0x52, 0xf5, 0x90, 0x54, 0x4b, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, - 0x95, 0xea, 0x83, 0x58, 0x10, 0x5d, 0x52, 0xb2, 0xc8, 0x06, 0x82, 0x75, 0xc7, 0x17, 0x97, 0x24, - 0x96, 0xa4, 0x42, 0xa5, 0x55, 0x90, 0xa5, 0xcb, 0x52, 0x8b, 0x32, 0xd3, 0x32, 0x93, 0x13, 0x4b, - 0x32, 0xf3, 0xf3, 0xe2, 0xd3, 0x72, 0x12, 0xd3, 0xa1, 0x56, 0x4b, 0x89, 0x17, 0x64, 0xa7, 0xeb, - 0x17, 0x14, 0xe5, 0xe7, 0xa7, 0x15, 0x43, 0x29, 0x88, 0x84, 0xd2, 0x3c, 0x26, 0x2e, 0x1e, 0x77, - 0x88, 0x2b, 0x83, 0x41, 0xa6, 0x0a, 0xd9, 0x71, 0xf1, 0x26, 0xe5, 0xe4, 0x27, 0x67, 0xc7, 0x67, - 0xa4, 0x26, 0xa6, 0xa4, 0x16, 0x15, 0x4b, 0x30, 0x2a, 0x30, 0x6b, 0x70, 0x1b, 0x09, 0xeb, 0x41, - 0xb5, 0x39, 0x81, 0x24, 0x3d, 0xc0, 0x72, 0x4e, 0x2c, 0x27, 0xee, 0xc9, 0x33, 0x04, 0xf1, 0x24, - 0x21, 0x84, 0x8a, 0x85, 0x82, 0xb9, 0x78, 0x90, 0x1c, 0x59, 0x2c, 0xc1, 0x04, 0xd6, 0xae, 0xa5, - 0x87, 0xdf, 0xef, 0x7a, 0xce, 0x20, 0x29, 0xb0, 0x0b, 0xa0, 0xa6, 0x72, 0x27, 0xc3, 0x45, 0x8a, - 0x85, 0x2a, 0xb9, 0x24, 0x91, 0x1d, 0x15, 0x8f, 0xec, 0x4f, 0x09, 0x66, 0x05, 0x46, 0x0d, 0x6e, - 0x23, 0x73, 0x42, 0x36, 0x20, 0x39, 0x3c, 0x0c, 0x49, 0x3b, 0xd4, 0x3a, 0xf1, 0x24, 0x1c, 0xd2, - 0x3e, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, 0x1c, 0xe3, 0x84, 0xc7, - 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, 0x10, 0x65, 0x94, 0x9e, 0x59, 0x92, - 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0x0f, 0xb2, 0x51, 0x17, 0x6c, 0xb9, 0x3e, 0xcc, 0x72, - 0xfd, 0x0a, 0x7d, 0xe4, 0xa8, 0x29, 0xa9, 0x2c, 0x48, 0x2d, 0x4e, 0x62, 0x03, 0x87, 0xba, 0x31, - 0x20, 0x00, 0x00, 0xff, 0xff, 0x30, 0x00, 0x9e, 0x2c, 0x26, 0x02, 0x00, 0x00, + 0x95, 0xea, 0x83, 0x58, 0x10, 0x5d, 0x52, 0xda, 0xc8, 0x06, 0x26, 0xe5, 0xe4, 0x27, 0x67, 0xc7, + 0x67, 0xa4, 0x26, 0xa6, 0xa4, 0x16, 0xc5, 0x97, 0xa5, 0x16, 0x65, 0xa6, 0x65, 0x26, 0x27, 0x96, + 0x64, 0xe6, 0xe7, 0x41, 0x15, 0xcb, 0x22, 0x2b, 0x06, 0x5b, 0x15, 0x5f, 0x5c, 0x92, 0x58, 0x92, + 0x0a, 0x95, 0x16, 0x2f, 0xc8, 0x4e, 0xd7, 0x2f, 0x28, 0xca, 0xcf, 0x4f, 0x2b, 0x86, 0x52, 0x10, + 0x09, 0xa5, 0x79, 0x4c, 0x5c, 0x3c, 0xee, 0x10, 0xc7, 0x06, 0x83, 0xd4, 0x0b, 0xd9, 0x71, 0xf1, + 0x22, 0xdb, 0x55, 0x2c, 0xc1, 0xa8, 0xc0, 0xac, 0xc1, 0x6d, 0x24, 0xac, 0x07, 0xd5, 0xe6, 0x04, + 0x92, 0xf4, 0x00, 0xcb, 0x39, 0xb1, 0x9c, 0xb8, 0x27, 0xcf, 0x10, 0xc4, 0x93, 0x84, 0x10, 0x2a, + 0x16, 0x0a, 0xe6, 0xe2, 0x41, 0xb2, 0xbe, 0x58, 0x82, 0x09, 0xac, 0x5d, 0x4b, 0x0f, 0x7f, 0x10, + 0xe8, 0x39, 0x83, 0xa4, 0xc0, 0x2e, 0x80, 0x9a, 0xca, 0x9d, 0x0c, 0x17, 0x29, 0x16, 0xaa, 0xe4, + 0x92, 0xc4, 0x19, 0x00, 0x12, 0xcc, 0x0a, 0x8c, 0x1a, 0xdc, 0x46, 0xe6, 0x84, 0x6c, 0x40, 0x72, + 0x78, 0x18, 0x92, 0x76, 0xa8, 0x75, 0xe2, 0x49, 0x38, 0xa4, 0x7d, 0x4e, 0x3c, 0x92, 0x63, 0xbc, + 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, + 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0xca, 0x28, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, + 0x57, 0x1f, 0x64, 0xa3, 0x2e, 0xd8, 0x72, 0x7d, 0x98, 0xe5, 0xfa, 0x15, 0xfa, 0xc8, 0x71, 0x52, + 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, 0x0e, 0x75, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, + 0x3b, 0x0e, 0x72, 0xe1, 0x2d, 0x02, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { diff --git a/x/lightclient/types/message_disable_verification_flags_test.go b/x/lightclient/types/message_disable_verification_flags_test.go index bc9fc16910..c3ca7af003 100644 --- a/x/lightclient/types/message_disable_verification_flags_test.go +++ b/x/lightclient/types/message_disable_verification_flags_test.go @@ -81,12 +81,12 @@ func TestMsgDisableHeaderVerification_GetSigners(t *testing.T) { signer := sample.AccAddress() tests := []struct { name string - msg *types.MsgEnableHeaderVerification + msg *types.MsgDisableHeaderVerification panics bool }{ { name: "valid signer", - msg: types.NewMsgEnableHeaderVerification( + msg: types.NewMsgDisableHeaderVerification( signer, []int64{chains.EthChain.ChainId, chains.BtcMainnetChain.ChainId}, ), @@ -94,7 +94,7 @@ func TestMsgDisableHeaderVerification_GetSigners(t *testing.T) { }, { name: "invalid signer", - msg: types.NewMsgEnableHeaderVerification( + msg: types.NewMsgDisableHeaderVerification( "invalid", []int64{chains.EthChain.ChainId, chains.BtcMainnetChain.ChainId}, ), @@ -124,14 +124,14 @@ func TestMsgDisableHeaderVerification_Type(t *testing.T) { } func TestMsgDisableHeaderVerification_Route(t *testing.T) { - msg := types.MsgEnableHeaderVerification{ + msg := types.MsgDisableHeaderVerification{ Creator: sample.AccAddress(), } require.Equal(t, types.RouterKey, msg.Route()) } func TestMsgDisableHeaderVerification_GetSignBytes(t *testing.T) { - msg := types.MsgEnableHeaderVerification{ + msg := types.MsgDisableHeaderVerification{ Creator: sample.AccAddress(), } require.NotPanics(t, func() { diff --git a/x/lightclient/types/query.pb.go b/x/lightclient/types/query.pb.go index 47ad733970..8e1c3e16d5 100644 --- a/x/lightclient/types/query.pb.go +++ b/x/lightclient/types/query.pb.go @@ -520,21 +520,21 @@ func (m *QueryProveResponse) GetValid() bool { return false } -type QueryHeaderEnabledChainsRequest struct { +type QueryHeaderSupportedChainsRequest struct { } -func (m *QueryHeaderEnabledChainsRequest) Reset() { *m = QueryHeaderEnabledChainsRequest{} } -func (m *QueryHeaderEnabledChainsRequest) String() string { return proto.CompactTextString(m) } -func (*QueryHeaderEnabledChainsRequest) ProtoMessage() {} -func (*QueryHeaderEnabledChainsRequest) Descriptor() ([]byte, []int) { +func (m *QueryHeaderSupportedChainsRequest) Reset() { *m = QueryHeaderSupportedChainsRequest{} } +func (m *QueryHeaderSupportedChainsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryHeaderSupportedChainsRequest) ProtoMessage() {} +func (*QueryHeaderSupportedChainsRequest) Descriptor() ([]byte, []int) { return fileDescriptor_03e46747c4ffba77, []int{10} } -func (m *QueryHeaderEnabledChainsRequest) XXX_Unmarshal(b []byte) error { +func (m *QueryHeaderSupportedChainsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryHeaderEnabledChainsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryHeaderSupportedChainsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryHeaderEnabledChainsRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryHeaderSupportedChainsRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -544,34 +544,34 @@ func (m *QueryHeaderEnabledChainsRequest) XXX_Marshal(b []byte, deterministic bo return b[:n], nil } } -func (m *QueryHeaderEnabledChainsRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryHeaderEnabledChainsRequest.Merge(m, src) +func (m *QueryHeaderSupportedChainsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryHeaderSupportedChainsRequest.Merge(m, src) } -func (m *QueryHeaderEnabledChainsRequest) XXX_Size() int { +func (m *QueryHeaderSupportedChainsRequest) XXX_Size() int { return m.Size() } -func (m *QueryHeaderEnabledChainsRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryHeaderEnabledChainsRequest.DiscardUnknown(m) +func (m *QueryHeaderSupportedChainsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryHeaderSupportedChainsRequest.DiscardUnknown(m) } -var xxx_messageInfo_QueryHeaderEnabledChainsRequest proto.InternalMessageInfo +var xxx_messageInfo_QueryHeaderSupportedChainsRequest proto.InternalMessageInfo -type QueryHeaderEnabledChainsResponse struct { - EnabledChains []EnabledChain `protobuf:"bytes,1,rep,name=enabled_chains,json=enabledChains,proto3" json:"enabled_chains"` +type QueryHeaderSupportedChainsResponse struct { + HeaderSupportedChains []HeaderSupportedChain `protobuf:"bytes,1,rep,name=header_supported_chains,json=headerSupportedChains,proto3" json:"header_supported_chains"` } -func (m *QueryHeaderEnabledChainsResponse) Reset() { *m = QueryHeaderEnabledChainsResponse{} } -func (m *QueryHeaderEnabledChainsResponse) String() string { return proto.CompactTextString(m) } -func (*QueryHeaderEnabledChainsResponse) ProtoMessage() {} -func (*QueryHeaderEnabledChainsResponse) Descriptor() ([]byte, []int) { +func (m *QueryHeaderSupportedChainsResponse) Reset() { *m = QueryHeaderSupportedChainsResponse{} } +func (m *QueryHeaderSupportedChainsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryHeaderSupportedChainsResponse) ProtoMessage() {} +func (*QueryHeaderSupportedChainsResponse) Descriptor() ([]byte, []int) { return fileDescriptor_03e46747c4ffba77, []int{11} } -func (m *QueryHeaderEnabledChainsResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryHeaderSupportedChainsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryHeaderEnabledChainsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryHeaderSupportedChainsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryHeaderEnabledChainsResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryHeaderSupportedChainsResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -581,21 +581,101 @@ func (m *QueryHeaderEnabledChainsResponse) XXX_Marshal(b []byte, deterministic b return b[:n], nil } } -func (m *QueryHeaderEnabledChainsResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryHeaderEnabledChainsResponse.Merge(m, src) +func (m *QueryHeaderSupportedChainsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryHeaderSupportedChainsResponse.Merge(m, src) } -func (m *QueryHeaderEnabledChainsResponse) XXX_Size() int { +func (m *QueryHeaderSupportedChainsResponse) XXX_Size() int { return m.Size() } -func (m *QueryHeaderEnabledChainsResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryHeaderEnabledChainsResponse.DiscardUnknown(m) +func (m *QueryHeaderSupportedChainsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryHeaderSupportedChainsResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryHeaderEnabledChainsResponse proto.InternalMessageInfo +var xxx_messageInfo_QueryHeaderSupportedChainsResponse proto.InternalMessageInfo -func (m *QueryHeaderEnabledChainsResponse) GetEnabledChains() []EnabledChain { +func (m *QueryHeaderSupportedChainsResponse) GetHeaderSupportedChains() []HeaderSupportedChain { if m != nil { - return m.EnabledChains + return m.HeaderSupportedChains + } + return nil +} + +type HeaderEnabledChainsRequest struct { +} + +func (m *HeaderEnabledChainsRequest) Reset() { *m = HeaderEnabledChainsRequest{} } +func (m *HeaderEnabledChainsRequest) String() string { return proto.CompactTextString(m) } +func (*HeaderEnabledChainsRequest) ProtoMessage() {} +func (*HeaderEnabledChainsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_03e46747c4ffba77, []int{12} +} +func (m *HeaderEnabledChainsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *HeaderEnabledChainsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_HeaderEnabledChainsRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *HeaderEnabledChainsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_HeaderEnabledChainsRequest.Merge(m, src) +} +func (m *HeaderEnabledChainsRequest) XXX_Size() int { + return m.Size() +} +func (m *HeaderEnabledChainsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_HeaderEnabledChainsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_HeaderEnabledChainsRequest proto.InternalMessageInfo + +type HeaderEnabledChainsResponse struct { + HeaderEnabledChains []HeaderSupportedChain `protobuf:"bytes,1,rep,name=header_enabled_chains,json=headerEnabledChains,proto3" json:"header_enabled_chains"` +} + +func (m *HeaderEnabledChainsResponse) Reset() { *m = HeaderEnabledChainsResponse{} } +func (m *HeaderEnabledChainsResponse) String() string { return proto.CompactTextString(m) } +func (*HeaderEnabledChainsResponse) ProtoMessage() {} +func (*HeaderEnabledChainsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_03e46747c4ffba77, []int{13} +} +func (m *HeaderEnabledChainsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *HeaderEnabledChainsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_HeaderEnabledChainsResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *HeaderEnabledChainsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_HeaderEnabledChainsResponse.Merge(m, src) +} +func (m *HeaderEnabledChainsResponse) XXX_Size() int { + return m.Size() +} +func (m *HeaderEnabledChainsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_HeaderEnabledChainsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_HeaderEnabledChainsResponse proto.InternalMessageInfo + +func (m *HeaderEnabledChainsResponse) GetHeaderEnabledChains() []HeaderSupportedChain { + if m != nil { + return m.HeaderEnabledChains } return nil } @@ -611,68 +691,74 @@ func init() { proto.RegisterType((*QueryGetChainStateResponse)(nil), "zetachain.zetacore.lightclient.QueryGetChainStateResponse") proto.RegisterType((*QueryProveRequest)(nil), "zetachain.zetacore.lightclient.QueryProveRequest") proto.RegisterType((*QueryProveResponse)(nil), "zetachain.zetacore.lightclient.QueryProveResponse") - proto.RegisterType((*QueryHeaderEnabledChainsRequest)(nil), "zetachain.zetacore.lightclient.QueryHeaderEnabledChainsRequest") - proto.RegisterType((*QueryHeaderEnabledChainsResponse)(nil), "zetachain.zetacore.lightclient.QueryHeaderEnabledChainsResponse") + proto.RegisterType((*QueryHeaderSupportedChainsRequest)(nil), "zetachain.zetacore.lightclient.QueryHeaderSupportedChainsRequest") + proto.RegisterType((*QueryHeaderSupportedChainsResponse)(nil), "zetachain.zetacore.lightclient.QueryHeaderSupportedChainsResponse") + proto.RegisterType((*HeaderEnabledChainsRequest)(nil), "zetachain.zetacore.lightclient.HeaderEnabledChainsRequest") + proto.RegisterType((*HeaderEnabledChainsResponse)(nil), "zetachain.zetacore.lightclient.HeaderEnabledChainsResponse") } func init() { proto.RegisterFile("lightclient/query.proto", fileDescriptor_03e46747c4ffba77) } var fileDescriptor_03e46747c4ffba77 = []byte{ - // 851 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x96, 0x4f, 0x4f, 0xdb, 0x48, - 0x18, 0xc6, 0x63, 0x20, 0xfc, 0x99, 0x10, 0xa4, 0x1d, 0x90, 0x08, 0xde, 0x25, 0xb0, 0x66, 0x59, - 0x50, 0x16, 0xec, 0x25, 0xbb, 0x42, 0xda, 0x20, 0x6d, 0x0b, 0x55, 0x4b, 0x51, 0x7b, 0x00, 0x57, - 0x3d, 0xb4, 0x97, 0x68, 0xe2, 0x0c, 0x8e, 0x85, 0xf1, 0x98, 0x78, 0x88, 0x42, 0x11, 0x97, 0x7e, - 0x82, 0x4a, 0x55, 0xbf, 0x42, 0xbf, 0x40, 0x2f, 0x48, 0xbd, 0xf5, 0xc4, 0xa1, 0x07, 0xa4, 0x5e, - 0x7a, 0xaa, 0xaa, 0xd0, 0x0f, 0x52, 0x79, 0x66, 0x52, 0x4f, 0xc0, 0x29, 0x26, 0xe2, 0x14, 0x7b, - 0xc6, 0xef, 0xfb, 0xfe, 0x9e, 0x67, 0xde, 0x79, 0x15, 0x30, 0xe9, 0x3a, 0x76, 0x8d, 0x5a, 0xae, - 0x83, 0x3d, 0x6a, 0x1c, 0x1c, 0xe2, 0xfa, 0x91, 0xee, 0xd7, 0x09, 0x25, 0x30, 0xff, 0x02, 0x53, - 0x64, 0xd5, 0x90, 0xe3, 0xe9, 0xec, 0x89, 0xd4, 0xb1, 0x2e, 0x7d, 0xab, 0x16, 0x2c, 0x12, 0xec, - 0x93, 0xc0, 0xa8, 0xa0, 0x00, 0xf3, 0x40, 0xa3, 0xb1, 0x52, 0xc1, 0x14, 0xad, 0x18, 0x3e, 0xb2, - 0x1d, 0x0f, 0x51, 0x87, 0x78, 0x3c, 0x97, 0x3a, 0x61, 0x13, 0x9b, 0xb0, 0x47, 0x23, 0x7c, 0x12, - 0xab, 0xbf, 0xd9, 0x84, 0xd8, 0x2e, 0x36, 0x90, 0xef, 0x18, 0xc8, 0xf3, 0x08, 0x65, 0x21, 0x81, - 0xd8, 0x9d, 0x96, 0xc1, 0x18, 0x47, 0x39, 0xa0, 0x88, 0x62, 0xb1, 0xfd, 0x87, 0xbc, 0xdd, 0xc0, - 0x75, 0x67, 0xd7, 0xb1, 0x58, 0x7c, 0x79, 0xd7, 0x45, 0x76, 0x3b, 0xc9, 0xa4, 0xbf, 0x67, 0x1b, - 0x7e, 0x9d, 0x90, 0xdd, 0x40, 0xfc, 0xf0, 0x0d, 0xad, 0x0a, 0xd4, 0x9d, 0x90, 0x79, 0xdd, 0x75, - 0x37, 0x5c, 0x62, 0xed, 0x3d, 0xc4, 0xa8, 0x8a, 0xeb, 0x26, 0x3e, 0x38, 0xc4, 0x01, 0x85, 0x0f, - 0x00, 0x88, 0x34, 0xe4, 0x94, 0x59, 0x65, 0x31, 0x53, 0xfc, 0x53, 0xe7, 0x82, 0xf5, 0x50, 0xb0, - 0xce, 0x9d, 0x12, 0x82, 0xf5, 0x6d, 0x64, 0x63, 0x11, 0x6b, 0x4a, 0x91, 0xda, 0x5b, 0x05, 0xfc, - 0x1a, 0x5b, 0x26, 0xf0, 0x89, 0x17, 0x60, 0xf8, 0x3f, 0xc8, 0x56, 0xc2, 0xe5, 0x72, 0x8d, 0xad, - 0x07, 0x39, 0x65, 0xb6, 0x7f, 0x31, 0x53, 0x1c, 0xd7, 0x05, 0xab, 0x14, 0xb3, 0x31, 0x70, 0xf6, - 0x65, 0x26, 0x65, 0x8e, 0x56, 0xa2, 0xa5, 0x00, 0x6e, 0x76, 0x70, 0xf6, 0x31, 0xce, 0x85, 0x6b, - 0x39, 0x79, 0xf1, 0x0e, 0xd0, 0x35, 0x61, 0xc7, 0x26, 0xa6, 0x31, 0x76, 0x4c, 0x03, 0x20, 0x30, - 0x51, 0x50, 0x63, 0x76, 0x8c, 0x9a, 0x23, 0x1c, 0x04, 0x05, 0x35, 0xed, 0xa9, 0x10, 0x79, 0x39, - 0x58, 0x88, 0x5c, 0x05, 0xa3, 0xb2, 0x48, 0x61, 0x67, 0x9c, 0x46, 0x33, 0x23, 0xa9, 0xd3, 0x2c, - 0x30, 0xd5, 0xf6, 0xee, 0x5e, 0x78, 0xfc, 0x4f, 0xc2, 0xd3, 0xbf, 0xed, 0x13, 0x3a, 0x55, 0xa2, - 0x46, 0x90, 0xab, 0x08, 0xf6, 0x1d, 0x90, 0x91, 0x5a, 0x4f, 0x1c, 0x4f, 0x41, 0xff, 0xf9, 0xd5, - 0xd0, 0xa3, 0x44, 0xe2, 0xd4, 0x80, 0xf5, 0x63, 0xe5, 0xf6, 0xce, 0x6c, 0x55, 0xf8, 0xb3, 0x89, - 0xe9, 0x55, 0x7f, 0xa6, 0xc0, 0x30, 0x07, 0x77, 0xaa, 0xcc, 0x9d, 0x7e, 0x73, 0x88, 0xbd, 0x6f, - 0x55, 0x35, 0x27, 0x3a, 0xeb, 0x18, 0xc5, 0x8f, 0x2e, 0x2b, 0x56, 0x6e, 0xa6, 0x58, 0xd6, 0x1a, - 0xf6, 0xff, 0x2f, 0xac, 0xd6, 0x76, 0x9d, 0x34, 0x12, 0xb0, 0xc1, 0x49, 0x30, 0x44, 0x9b, 0xbc, - 0xcd, 0x42, 0x67, 0x46, 0xcc, 0x41, 0xda, 0x0c, 0x7b, 0x0c, 0xce, 0x81, 0x34, 0xeb, 0x97, 0x5c, - 0x3f, 0x03, 0xca, 0xb6, 0xbb, 0x67, 0x3b, 0xfc, 0x31, 0xf9, 0xde, 0xa5, 0x3e, 0x1d, 0x60, 0x09, - 0xa2, 0x3e, 0x0d, 0xeb, 0xd2, 0x66, 0xd9, 0xf1, 0xaa, 0xb8, 0x99, 0x4b, 0xf3, 0xba, 0xb4, 0xb9, - 0x15, 0xbe, 0x6a, 0x05, 0x00, 0x65, 0x4e, 0xe1, 0xc5, 0x04, 0x48, 0x37, 0x90, 0x2b, 0x28, 0x87, - 0x4d, 0xfe, 0xa2, 0xfd, 0x0e, 0x66, 0xd8, 0xb7, 0xbc, 0x4d, 0xef, 0x7b, 0xa8, 0xe2, 0xe2, 0x2a, - 0x33, 0x20, 0x10, 0x0a, 0xb5, 0x13, 0x30, 0xdb, 0xfd, 0x13, 0x91, 0xfc, 0x19, 0x18, 0xc3, 0x7c, - 0xa3, 0xcc, 0xd4, 0xb7, 0x2f, 0xff, 0xd2, 0x75, 0x5e, 0xcb, 0xe9, 0x44, 0x7f, 0x65, 0xb1, 0x5c, - 0xa2, 0xd8, 0x1a, 0x06, 0x69, 0x56, 0x1f, 0x9e, 0x2a, 0x60, 0x4c, 0xba, 0x60, 0xeb, 0xae, 0x0b, - 0x4b, 0xd7, 0xe5, 0xef, 0x3e, 0x17, 0xd5, 0xb5, 0x9e, 0x62, 0xb9, 0x60, 0x6d, 0xf9, 0xe5, 0xa7, - 0x6f, 0xaf, 0xfb, 0x16, 0xe0, 0xbc, 0x11, 0x86, 0x2e, 0xb3, 0x2c, 0x86, 0x3c, 0xc5, 0x3b, 0x46, - 0x21, 0xfc, 0xa0, 0x80, 0x8c, 0x94, 0x26, 0x21, 0x77, 0xec, 0x00, 0x4b, 0xc8, 0x1d, 0x3f, 0xbf, - 0xb4, 0x12, 0xe3, 0xfe, 0x17, 0x16, 0x13, 0x71, 0x1b, 0xc7, 0x51, 0x0b, 0x9e, 0xc0, 0x77, 0x0a, - 0xc8, 0x46, 0x77, 0x23, 0xb4, 0xff, 0xbf, 0xa4, 0x16, 0x5e, 0xb9, 0xd3, 0x6a, 0xa9, 0x97, 0x50, - 0x21, 0xe2, 0x2f, 0x26, 0x62, 0x1e, 0xce, 0x75, 0x13, 0x21, 0x5d, 0x7a, 0xf8, 0x5e, 0x01, 0x20, - 0xca, 0x91, 0x10, 0x39, 0x6e, 0x0c, 0xa9, 0xa5, 0x5e, 0x42, 0x05, 0xf2, 0x2a, 0x43, 0xfe, 0x1b, - 0xea, 0x09, 0x90, 0x8d, 0xe3, 0xf6, 0x44, 0x39, 0x81, 0x6f, 0x14, 0x90, 0x66, 0xf7, 0x18, 0xae, - 0x24, 0xaa, 0x2e, 0xcf, 0x26, 0xb5, 0x78, 0x93, 0x10, 0x01, 0x3a, 0xcf, 0x40, 0x67, 0xe0, 0x74, - 0x37, 0x50, 0x9f, 0xd1, 0x7c, 0x54, 0xc0, 0x78, 0xcc, 0x40, 0x80, 0x77, 0x12, 0x95, 0xec, 0x3e, - 0x6d, 0xd4, 0xbb, 0xbd, 0x27, 0x10, 0x0a, 0x8a, 0x4c, 0xc1, 0x12, 0x2c, 0x74, 0x53, 0x70, 0xf5, - 0x0f, 0xd6, 0xc6, 0xe3, 0xb3, 0x56, 0x5e, 0x39, 0x6f, 0xe5, 0x95, 0xaf, 0xad, 0xbc, 0xf2, 0xea, - 0x22, 0x9f, 0x3a, 0xbf, 0xc8, 0xa7, 0x3e, 0x5f, 0xe4, 0x53, 0xcf, 0x8b, 0xb6, 0x43, 0x6b, 0x87, - 0x15, 0xdd, 0x22, 0xfb, 0x72, 0xbe, 0x36, 0x9a, 0xd1, 0xec, 0x48, 0x4d, 0x8f, 0x7c, 0x1c, 0x54, - 0x06, 0xd9, 0xdf, 0xb2, 0x7f, 0xbe, 0x07, 0x00, 0x00, 0xff, 0xff, 0xd3, 0x32, 0xe8, 0x94, 0x8f, - 0x0a, 0x00, 0x00, + // 915 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0x4f, 0x8f, 0xdb, 0x44, + 0x14, 0xcf, 0x74, 0x9b, 0xfe, 0x79, 0xd9, 0x45, 0x62, 0xb6, 0x55, 0x52, 0xb7, 0x9b, 0x16, 0xaf, + 0x96, 0x56, 0x5b, 0xad, 0x4d, 0x42, 0x59, 0x44, 0x2a, 0x21, 0x6d, 0x10, 0x2c, 0x15, 0x1c, 0xb6, + 0xae, 0xb8, 0x70, 0x89, 0x1c, 0x67, 0x6a, 0x5b, 0x75, 0x3d, 0xae, 0x67, 0x12, 0xa5, 0x54, 0xbd, + 0x70, 0x47, 0x42, 0x42, 0x48, 0x7c, 0x02, 0xbe, 0x00, 0x42, 0xaa, 0xc4, 0x0d, 0x09, 0xa9, 0xc7, + 0x4a, 0x1c, 0xe0, 0x84, 0xd0, 0x2e, 0x1f, 0x04, 0x79, 0x66, 0x82, 0x27, 0x59, 0x27, 0x71, 0x97, + 0x3d, 0xc5, 0xf6, 0xcc, 0x7b, 0xbf, 0x3f, 0xf3, 0xe6, 0xb7, 0x0b, 0xf5, 0x28, 0xf4, 0x03, 0xee, + 0x45, 0x21, 0x89, 0xb9, 0xfd, 0x64, 0x48, 0xd2, 0xa7, 0x56, 0x92, 0x52, 0x4e, 0x71, 0xf3, 0x2b, + 0xc2, 0x5d, 0x2f, 0x70, 0xc3, 0xd8, 0x12, 0x4f, 0x34, 0x25, 0x96, 0xb6, 0xd7, 0xd8, 0xf6, 0x28, + 0x7b, 0x4c, 0x99, 0xdd, 0x77, 0x19, 0x91, 0x85, 0xf6, 0xa8, 0xd5, 0x27, 0xdc, 0x6d, 0xd9, 0x89, + 0xeb, 0x87, 0xb1, 0xcb, 0x43, 0x1a, 0xcb, 0x5e, 0xc6, 0x25, 0x9f, 0xfa, 0x54, 0x3c, 0xda, 0xd9, + 0x93, 0xfa, 0x7a, 0xcd, 0xa7, 0xd4, 0x8f, 0x88, 0xed, 0x26, 0xa1, 0xed, 0xc6, 0x31, 0xe5, 0xa2, + 0x84, 0xa9, 0xd5, 0xdb, 0x3a, 0xb1, 0x7e, 0x44, 0xbd, 0x47, 0xbd, 0x80, 0xb8, 0x03, 0x92, 0xf6, + 0x46, 0x24, 0x0d, 0x1f, 0x86, 0x9e, 0x0e, 0xb0, 0xa1, 0x6f, 0x16, 0xa4, 0x7b, 0x8c, 0xbb, 0x9c, + 0xa8, 0xe5, 0x7a, 0xf2, 0xc8, 0xb7, 0x93, 0x94, 0xd2, 0x87, 0x4c, 0xfd, 0xc8, 0x05, 0x73, 0x00, + 0xc6, 0xfd, 0x8c, 0xfa, 0x5e, 0x14, 0x75, 0x33, 0x88, 0x4f, 0x05, 0x82, 0x43, 0x9e, 0x0c, 0x09, + 0xe3, 0xf8, 0x13, 0x80, 0x5c, 0x4a, 0x03, 0xdd, 0x40, 0xb7, 0x6a, 0xed, 0xb7, 0x2d, 0xa9, 0xdb, + 0xca, 0x74, 0x5b, 0xd2, 0x30, 0xa5, 0xdb, 0x3a, 0x70, 0x7d, 0xa2, 0x6a, 0x1d, 0xad, 0xd2, 0xfc, + 0x11, 0xc1, 0xd5, 0x42, 0x18, 0x96, 0xd0, 0x98, 0x11, 0xfc, 0x21, 0xac, 0xe9, 0x02, 0x59, 0x03, + 0xdd, 0x58, 0xb9, 0x55, 0x6b, 0xaf, 0x5b, 0x8a, 0xab, 0x56, 0xd3, 0x3d, 0xfb, 0xf2, 0xaf, 0xeb, + 0x15, 0x67, 0xb5, 0x9f, 0x7f, 0x62, 0x78, 0x7f, 0x8a, 0xe7, 0x19, 0xc1, 0xf3, 0xe6, 0x52, 0x9e, + 0x12, 0x7c, 0x8a, 0xe8, 0x5d, 0x65, 0xc7, 0x3e, 0xe1, 0x05, 0x76, 0x6c, 0x00, 0x28, 0x9a, 0x2e, + 0x0b, 0x84, 0x1d, 0xab, 0xce, 0x45, 0x49, 0xc4, 0x65, 0x81, 0xf9, 0x85, 0x12, 0x39, 0x5b, 0xac, + 0x44, 0xee, 0xc2, 0xaa, 0x2e, 0x52, 0xd9, 0x59, 0xa4, 0xd1, 0xa9, 0x69, 0xea, 0x4c, 0x0f, 0xae, + 0x4c, 0xbc, 0xfb, 0x28, 0x3b, 0xd8, 0x07, 0xd9, 0xb9, 0x9e, 0xf6, 0x09, 0xbd, 0x40, 0xf9, 0x20, + 0xe8, 0x28, 0x8a, 0xfb, 0x7d, 0xa8, 0x69, 0x43, 0xa5, 0x8e, 0x67, 0xdb, 0x5a, 0x7c, 0x43, 0xac, + 0xbc, 0x91, 0x3a, 0x35, 0xf0, 0xfe, 0xfb, 0x72, 0x7a, 0x67, 0xb6, 0xab, 0xfc, 0xd9, 0x27, 0xfc, + 0xb8, 0x3f, 0x57, 0xe0, 0x82, 0x24, 0x1e, 0x0e, 0x84, 0x3b, 0x2b, 0xce, 0x79, 0xf1, 0x7e, 0x6f, + 0x60, 0x86, 0xf9, 0x59, 0x17, 0x28, 0xfe, 0x6c, 0x56, 0x31, 0x7a, 0x3d, 0xc5, 0xba, 0xd6, 0x6c, + 0xfe, 0xdf, 0x14, 0x58, 0x07, 0x29, 0x1d, 0x95, 0xe0, 0x86, 0xeb, 0x70, 0x9e, 0x8f, 0xe5, 0x98, + 0x65, 0xce, 0x5c, 0x74, 0xce, 0xf1, 0x71, 0x36, 0x63, 0x78, 0x13, 0xaa, 0x62, 0x5e, 0x1a, 0x2b, + 0x82, 0xd0, 0xda, 0x64, 0x7a, 0x0e, 0xb2, 0x1f, 0x47, 0xae, 0xcd, 0xcc, 0xe9, 0x59, 0xd1, 0x20, + 0x9f, 0xd3, 0x0c, 0x97, 0x8f, 0x7b, 0x61, 0x3c, 0x20, 0xe3, 0x46, 0x55, 0xe2, 0xf2, 0xf1, 0xbd, + 0xec, 0xd5, 0xdc, 0x06, 0xac, 0xf3, 0x54, 0x5e, 0x5c, 0x82, 0xea, 0xc8, 0x8d, 0x14, 0xcb, 0x0b, + 0x8e, 0x7c, 0x31, 0x37, 0xe1, 0x2d, 0xb1, 0x57, 0x8e, 0xe9, 0x83, 0x61, 0x92, 0xd0, 0x94, 0x93, + 0x81, 0xb0, 0x80, 0x29, 0x8d, 0xe6, 0x0f, 0x08, 0xcc, 0x45, 0xbb, 0x14, 0x42, 0x0a, 0x75, 0x95, + 0x6d, 0x6c, 0xb2, 0xa3, 0x27, 0xbc, 0x98, 0x44, 0xc1, 0x9d, 0x65, 0xce, 0x17, 0xf5, 0x57, 0x53, + 0x77, 0x39, 0x28, 0xc2, 0x36, 0xaf, 0x81, 0x21, 0x8b, 0x3e, 0x8e, 0xdd, 0x7e, 0x34, 0x4b, 0xfc, + 0x1b, 0x04, 0x57, 0x0b, 0x97, 0x15, 0xe3, 0x18, 0x54, 0xdb, 0x1e, 0x91, 0xeb, 0xa7, 0xc7, 0x77, + 0x3d, 0x38, 0x8e, 0xdb, 0xfe, 0x19, 0xa0, 0x2a, 0x8c, 0xc4, 0x2f, 0x10, 0xbc, 0xa1, 0x85, 0xc5, + 0x5e, 0x14, 0xe1, 0xce, 0x32, 0xb4, 0xf9, 0x19, 0x6f, 0xdc, 0x3d, 0x51, 0xad, 0x74, 0xc1, 0xdc, + 0xf9, 0xfa, 0xf7, 0x7f, 0xbe, 0x3b, 0x73, 0x13, 0x6f, 0xd9, 0x59, 0xe9, 0x8e, 0xe8, 0x62, 0xcf, + 0xfb, 0xbb, 0xc5, 0xf0, 0xaf, 0x08, 0x6a, 0x5a, 0x9b, 0x92, 0xbc, 0x0b, 0xc3, 0xb8, 0x24, 0xef, + 0xe2, 0x2c, 0x36, 0x3b, 0x82, 0xf7, 0x1d, 0xdc, 0x2e, 0xc5, 0xdb, 0x7e, 0x96, 0x5f, 0xa7, 0xe7, + 0xf8, 0x27, 0x04, 0x6b, 0xf9, 0x3d, 0xcf, 0xec, 0xff, 0xa0, 0xac, 0x85, 0xc7, 0xf2, 0xc9, 0xe8, + 0x9c, 0xa4, 0x54, 0x89, 0xb8, 0x2d, 0x44, 0x6c, 0xe1, 0xcd, 0x79, 0x22, 0xb4, 0x00, 0xc3, 0xbf, + 0x20, 0x80, 0xbc, 0x47, 0x49, 0xca, 0x45, 0x91, 0x6a, 0x74, 0x4e, 0x52, 0xaa, 0x28, 0xef, 0x0a, + 0xca, 0xef, 0x60, 0xab, 0x04, 0x65, 0xfb, 0xd9, 0x24, 0x1d, 0x9f, 0xe3, 0xef, 0x11, 0x54, 0x45, + 0x26, 0xe1, 0x56, 0x29, 0x74, 0x3d, 0x67, 0x8d, 0xf6, 0xeb, 0x94, 0x28, 0xa2, 0x5b, 0x82, 0xe8, + 0x75, 0xbc, 0x31, 0x8f, 0x68, 0x22, 0xd8, 0xfc, 0x81, 0xe0, 0x72, 0x61, 0xb2, 0xe1, 0xbd, 0x52, + 0xa0, 0x8b, 0xb2, 0xd3, 0xe8, 0xfe, 0x9f, 0x16, 0x4a, 0xc7, 0xfb, 0x42, 0x47, 0x0b, 0xdb, 0xf3, + 0x74, 0xcc, 0x89, 0x5d, 0xfc, 0x1b, 0x82, 0xf5, 0x82, 0xfc, 0x5b, 0x7e, 0x65, 0xe7, 0x67, 0xea, + 0xf2, 0x2b, 0xbb, 0x20, 0x70, 0xcd, 0xf7, 0x84, 0x12, 0x1b, 0xef, 0x2c, 0x51, 0x32, 0x1d, 0xc7, + 0xdd, 0xcf, 0x5f, 0x1e, 0x36, 0xd1, 0xab, 0xc3, 0x26, 0xfa, 0xfb, 0xb0, 0x89, 0xbe, 0x3d, 0x6a, + 0x56, 0x5e, 0x1d, 0x35, 0x2b, 0x7f, 0x1e, 0x35, 0x2b, 0x5f, 0xb6, 0xfd, 0x90, 0x07, 0xc3, 0xbe, + 0xe5, 0xd1, 0xc7, 0x7a, 0xcb, 0x09, 0x31, 0x7b, 0x3c, 0xd5, 0x9d, 0x3f, 0x4d, 0x08, 0xeb, 0x9f, + 0x13, 0xff, 0x35, 0xbf, 0xfb, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x11, 0xf5, 0x39, 0x4b, 0x35, + 0x0c, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -692,7 +778,8 @@ type QueryClient interface { ChainStateAll(ctx context.Context, in *QueryAllChainStateRequest, opts ...grpc.CallOption) (*QueryAllChainStateResponse, error) ChainState(ctx context.Context, in *QueryGetChainStateRequest, opts ...grpc.CallOption) (*QueryGetChainStateResponse, error) Prove(ctx context.Context, in *QueryProveRequest, opts ...grpc.CallOption) (*QueryProveResponse, error) - HeaderEnabledChains(ctx context.Context, in *QueryHeaderEnabledChainsRequest, opts ...grpc.CallOption) (*QueryHeaderEnabledChainsResponse, error) + HeaderSupportedChains(ctx context.Context, in *QueryHeaderSupportedChainsRequest, opts ...grpc.CallOption) (*QueryHeaderSupportedChainsResponse, error) + HeaderEnabledChains(ctx context.Context, in *HeaderEnabledChainsRequest, opts ...grpc.CallOption) (*HeaderEnabledChainsResponse, error) } type queryClient struct { @@ -748,8 +835,17 @@ func (c *queryClient) Prove(ctx context.Context, in *QueryProveRequest, opts ... return out, nil } -func (c *queryClient) HeaderEnabledChains(ctx context.Context, in *QueryHeaderEnabledChainsRequest, opts ...grpc.CallOption) (*QueryHeaderEnabledChainsResponse, error) { - out := new(QueryHeaderEnabledChainsResponse) +func (c *queryClient) HeaderSupportedChains(ctx context.Context, in *QueryHeaderSupportedChainsRequest, opts ...grpc.CallOption) (*QueryHeaderSupportedChainsResponse, error) { + out := new(QueryHeaderSupportedChainsResponse) + err := c.cc.Invoke(ctx, "/zetachain.zetacore.lightclient.Query/HeaderSupportedChains", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) HeaderEnabledChains(ctx context.Context, in *HeaderEnabledChainsRequest, opts ...grpc.CallOption) (*HeaderEnabledChainsResponse, error) { + out := new(HeaderEnabledChainsResponse) err := c.cc.Invoke(ctx, "/zetachain.zetacore.lightclient.Query/HeaderEnabledChains", in, out, opts...) if err != nil { return nil, err @@ -764,7 +860,8 @@ type QueryServer interface { ChainStateAll(context.Context, *QueryAllChainStateRequest) (*QueryAllChainStateResponse, error) ChainState(context.Context, *QueryGetChainStateRequest) (*QueryGetChainStateResponse, error) Prove(context.Context, *QueryProveRequest) (*QueryProveResponse, error) - HeaderEnabledChains(context.Context, *QueryHeaderEnabledChainsRequest) (*QueryHeaderEnabledChainsResponse, error) + HeaderSupportedChains(context.Context, *QueryHeaderSupportedChainsRequest) (*QueryHeaderSupportedChainsResponse, error) + HeaderEnabledChains(context.Context, *HeaderEnabledChainsRequest) (*HeaderEnabledChainsResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -786,7 +883,10 @@ func (*UnimplementedQueryServer) ChainState(ctx context.Context, req *QueryGetCh func (*UnimplementedQueryServer) Prove(ctx context.Context, req *QueryProveRequest) (*QueryProveResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Prove not implemented") } -func (*UnimplementedQueryServer) HeaderEnabledChains(ctx context.Context, req *QueryHeaderEnabledChainsRequest) (*QueryHeaderEnabledChainsResponse, error) { +func (*UnimplementedQueryServer) HeaderSupportedChains(ctx context.Context, req *QueryHeaderSupportedChainsRequest) (*QueryHeaderSupportedChainsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method HeaderSupportedChains not implemented") +} +func (*UnimplementedQueryServer) HeaderEnabledChains(ctx context.Context, req *HeaderEnabledChainsRequest) (*HeaderEnabledChainsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method HeaderEnabledChains not implemented") } @@ -884,8 +984,26 @@ func _Query_Prove_Handler(srv interface{}, ctx context.Context, dec func(interfa return interceptor(ctx, in, info, handler) } +func _Query_HeaderSupportedChains_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryHeaderSupportedChainsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).HeaderSupportedChains(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/zetachain.zetacore.lightclient.Query/HeaderSupportedChains", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).HeaderSupportedChains(ctx, req.(*QueryHeaderSupportedChainsRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _Query_HeaderEnabledChains_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryHeaderEnabledChainsRequest) + in := new(HeaderEnabledChainsRequest) if err := dec(in); err != nil { return nil, err } @@ -897,7 +1015,7 @@ func _Query_HeaderEnabledChains_Handler(srv interface{}, ctx context.Context, de FullMethod: "/zetachain.zetacore.lightclient.Query/HeaderEnabledChains", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).HeaderEnabledChains(ctx, req.(*QueryHeaderEnabledChainsRequest)) + return srv.(QueryServer).HeaderEnabledChains(ctx, req.(*HeaderEnabledChainsRequest)) } return interceptor(ctx, in, info, handler) } @@ -926,6 +1044,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "Prove", Handler: _Query_Prove_Handler, }, + { + MethodName: "HeaderSupportedChains", + Handler: _Query_HeaderSupportedChains_Handler, + }, { MethodName: "HeaderEnabledChains", Handler: _Query_HeaderEnabledChains_Handler, @@ -1323,7 +1445,67 @@ func (m *QueryProveResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *QueryHeaderEnabledChainsRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryHeaderSupportedChainsRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryHeaderSupportedChainsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryHeaderSupportedChainsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryHeaderSupportedChainsResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryHeaderSupportedChainsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryHeaderSupportedChainsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.HeaderSupportedChains) > 0 { + for iNdEx := len(m.HeaderSupportedChains) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.HeaderSupportedChains[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *HeaderEnabledChainsRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1333,12 +1515,12 @@ func (m *QueryHeaderEnabledChainsRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryHeaderEnabledChainsRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *HeaderEnabledChainsRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryHeaderEnabledChainsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *HeaderEnabledChainsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1346,7 +1528,7 @@ func (m *QueryHeaderEnabledChainsRequest) MarshalToSizedBuffer(dAtA []byte) (int return len(dAtA) - i, nil } -func (m *QueryHeaderEnabledChainsResponse) Marshal() (dAtA []byte, err error) { +func (m *HeaderEnabledChainsResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1356,20 +1538,20 @@ func (m *QueryHeaderEnabledChainsResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryHeaderEnabledChainsResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *HeaderEnabledChainsResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryHeaderEnabledChainsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *HeaderEnabledChainsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.EnabledChains) > 0 { - for iNdEx := len(m.EnabledChains) - 1; iNdEx >= 0; iNdEx-- { + if len(m.HeaderEnabledChains) > 0 { + for iNdEx := len(m.HeaderEnabledChains) - 1; iNdEx >= 0; iNdEx-- { { - size, err := m.EnabledChains[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + size, err := m.HeaderEnabledChains[iNdEx].MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -1548,7 +1730,7 @@ func (m *QueryProveResponse) Size() (n int) { return n } -func (m *QueryHeaderEnabledChainsRequest) Size() (n int) { +func (m *QueryHeaderSupportedChainsRequest) Size() (n int) { if m == nil { return 0 } @@ -1557,14 +1739,38 @@ func (m *QueryHeaderEnabledChainsRequest) Size() (n int) { return n } -func (m *QueryHeaderEnabledChainsResponse) Size() (n int) { +func (m *QueryHeaderSupportedChainsResponse) Size() (n int) { if m == nil { return 0 } var l int _ = l - if len(m.EnabledChains) > 0 { - for _, e := range m.EnabledChains { + if len(m.HeaderSupportedChains) > 0 { + for _, e := range m.HeaderSupportedChains { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func (m *HeaderEnabledChainsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *HeaderEnabledChainsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.HeaderEnabledChains) > 0 { + for _, e := range m.HeaderEnabledChains { l = e.Size() n += 1 + l + sovQuery(uint64(l)) } @@ -2573,7 +2779,141 @@ func (m *QueryProveResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryHeaderEnabledChainsRequest) Unmarshal(dAtA []byte) error { +func (m *QueryHeaderSupportedChainsRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryHeaderSupportedChainsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryHeaderSupportedChainsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryHeaderSupportedChainsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryHeaderSupportedChainsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryHeaderSupportedChainsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field HeaderSupportedChains", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.HeaderSupportedChains = append(m.HeaderSupportedChains, HeaderSupportedChain{}) + if err := m.HeaderSupportedChains[len(m.HeaderSupportedChains)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *HeaderEnabledChainsRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2596,10 +2936,10 @@ func (m *QueryHeaderEnabledChainsRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryHeaderEnabledChainsRequest: wiretype end group for non-group") + return fmt.Errorf("proto: HeaderEnabledChainsRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryHeaderEnabledChainsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: HeaderEnabledChainsRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: @@ -2623,7 +2963,7 @@ func (m *QueryHeaderEnabledChainsRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryHeaderEnabledChainsResponse) Unmarshal(dAtA []byte) error { +func (m *HeaderEnabledChainsResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2646,15 +2986,15 @@ func (m *QueryHeaderEnabledChainsResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryHeaderEnabledChainsResponse: wiretype end group for non-group") + return fmt.Errorf("proto: HeaderEnabledChainsResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryHeaderEnabledChainsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: HeaderEnabledChainsResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field EnabledChains", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field HeaderEnabledChains", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -2681,8 +3021,8 @@ func (m *QueryHeaderEnabledChainsResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.EnabledChains = append(m.EnabledChains, EnabledChain{}) - if err := m.EnabledChains[len(m.EnabledChains)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.HeaderEnabledChains = append(m.HeaderEnabledChains, HeaderSupportedChain{}) + if err := m.HeaderEnabledChains[len(m.HeaderEnabledChains)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/x/lightclient/types/query.pb.gw.go b/x/lightclient/types/query.pb.gw.go index 4f8ca48267..75c595fea1 100644 --- a/x/lightclient/types/query.pb.gw.go +++ b/x/lightclient/types/query.pb.gw.go @@ -249,8 +249,26 @@ func local_request_Query_Prove_0(ctx context.Context, marshaler runtime.Marshale } +func request_Query_HeaderSupportedChains_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryHeaderSupportedChainsRequest + var metadata runtime.ServerMetadata + + msg, err := client.HeaderSupportedChains(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_HeaderSupportedChains_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryHeaderSupportedChainsRequest + var metadata runtime.ServerMetadata + + msg, err := server.HeaderSupportedChains(ctx, &protoReq) + return msg, metadata, err + +} + func request_Query_HeaderEnabledChains_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryHeaderEnabledChainsRequest + var protoReq HeaderEnabledChainsRequest var metadata runtime.ServerMetadata msg, err := client.HeaderEnabledChains(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) @@ -259,7 +277,7 @@ func request_Query_HeaderEnabledChains_0(ctx context.Context, marshaler runtime. } func local_request_Query_HeaderEnabledChains_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryHeaderEnabledChainsRequest + var protoReq HeaderEnabledChainsRequest var metadata runtime.ServerMetadata msg, err := server.HeaderEnabledChains(ctx, &protoReq) @@ -388,6 +406,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_HeaderSupportedChains_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_HeaderSupportedChains_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_HeaderSupportedChains_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_HeaderEnabledChains_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -552,6 +593,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_HeaderSupportedChains_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_HeaderSupportedChains_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_HeaderSupportedChains_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_HeaderEnabledChains_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -586,7 +647,9 @@ var ( pattern_Query_Prove_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"zeta-chain", "lightclient", "prove"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_HeaderEnabledChains_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"zeta-chain", "lightclient", "verification_flags"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_HeaderSupportedChains_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"zeta-chain", "lightclient", "header_supported_chains"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_HeaderEnabledChains_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"zeta-chain", "lightclient", "header_enabled_chains"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( @@ -600,5 +663,7 @@ var ( forward_Query_Prove_0 = runtime.ForwardResponseMessage + forward_Query_HeaderSupportedChains_0 = runtime.ForwardResponseMessage + forward_Query_HeaderEnabledChains_0 = runtime.ForwardResponseMessage ) diff --git a/x/lightclient/types/tx.pb.go b/x/lightclient/types/tx.pb.go index 125887490f..2cc183b555 100644 --- a/x/lightclient/types/tx.pb.go +++ b/x/lightclient/types/tx.pb.go @@ -215,28 +215,28 @@ func init() { func init() { proto.RegisterFile("lightclient/tx.proto", fileDescriptor_81fed8987f08d9c5) } var fileDescriptor_81fed8987f08d9c5 = []byte{ - // 324 bytes of a gzipped FileDescriptorProto + // 328 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0xc9, 0xc9, 0x4c, 0xcf, 0x28, 0x49, 0xce, 0xc9, 0x4c, 0xcd, 0x2b, 0xd1, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0xab, 0x4a, 0x2d, 0x49, 0x4c, 0xce, 0x48, 0xcc, 0xcc, 0xd3, 0x03, 0xb3, 0xf2, 0x8b, 0x52, 0xf5, 0x90, 0x14, 0x4a, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0x95, 0xea, 0x83, 0x58, 0x10, - 0x5d, 0x52, 0x2a, 0xc8, 0x66, 0x95, 0xa5, 0x16, 0x65, 0xa6, 0x65, 0x26, 0x27, 0x96, 0x64, 0xe6, - 0xe7, 0xc5, 0xa7, 0xe5, 0x24, 0xa6, 0x17, 0x43, 0x54, 0x29, 0x45, 0x73, 0x49, 0xfb, 0x16, 0xa7, - 0xbb, 0xe6, 0x25, 0x26, 0xe5, 0xa4, 0x7a, 0xa4, 0x26, 0xa6, 0xa4, 0x16, 0x85, 0x21, 0x29, 0x15, - 0x92, 0xe0, 0x62, 0x4f, 0x2e, 0x4a, 0x4d, 0x2c, 0xc9, 0x2f, 0x92, 0x60, 0x54, 0x60, 0xd4, 0xe0, - 0x0c, 0x82, 0x71, 0x85, 0x94, 0xb8, 0x78, 0xc1, 0x4e, 0x8a, 0xcf, 0x4c, 0x89, 0xcf, 0xc9, 0x2c, - 0x2e, 0x91, 0x60, 0x52, 0x60, 0xd6, 0x60, 0x0e, 0xe2, 0x06, 0x0b, 0x7a, 0xa6, 0xf8, 0x64, 0x16, - 0x97, 0x28, 0xa9, 0x72, 0x29, 0xe3, 0x31, 0x3c, 0x28, 0xb5, 0xb8, 0x20, 0x3f, 0xaf, 0x38, 0x55, - 0x29, 0x86, 0x4b, 0xc6, 0xb7, 0x38, 0xdd, 0x25, 0xb3, 0x98, 0x26, 0x8e, 0x50, 0xe3, 0x52, 0xc1, - 0x67, 0x3a, 0xcc, 0x15, 0x46, 0xc7, 0x98, 0xb8, 0x98, 0x7d, 0x8b, 0xd3, 0x85, 0xe6, 0x30, 0x72, - 0x49, 0xe0, 0x0c, 0x0f, 0x6b, 0x3d, 0xfc, 0x71, 0xa1, 0x87, 0xc7, 0xbf, 0x52, 0xce, 0x14, 0x68, - 0x86, 0x39, 0x53, 0x68, 0x3e, 0x23, 0x97, 0x24, 0xee, 0xa0, 0xb2, 0x21, 0xc2, 0x0a, 0x9c, 0xba, - 0xa5, 0x5c, 0x28, 0xd1, 0x0d, 0x73, 0xa1, 0x93, 0xcf, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, - 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, - 0xcb, 0x31, 0x44, 0x19, 0xa5, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x83, - 0xcc, 0xd7, 0x05, 0x5b, 0xa5, 0x0f, 0xb3, 0x4a, 0xbf, 0x42, 0x1f, 0x25, 0xfd, 0x57, 0x16, 0xa4, - 0x16, 0x27, 0xb1, 0x81, 0xd3, 0xa9, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x23, 0x96, 0x87, 0x88, - 0x1b, 0x03, 0x00, 0x00, + 0x5d, 0x52, 0xda, 0xc8, 0x66, 0x25, 0xe5, 0xe4, 0x27, 0x67, 0xc7, 0x67, 0xa4, 0x26, 0xa6, 0xa4, + 0x16, 0xc5, 0x97, 0xa5, 0x16, 0x65, 0xa6, 0x65, 0x26, 0x27, 0x96, 0x64, 0xe6, 0xe7, 0x41, 0x14, + 0x2b, 0x45, 0x73, 0x49, 0xfb, 0x16, 0xa7, 0xbb, 0xe6, 0x25, 0x26, 0xe5, 0xa4, 0x7a, 0x80, 0x55, + 0x85, 0x21, 0x29, 0x12, 0x92, 0xe0, 0x62, 0x4f, 0x2e, 0x4a, 0x4d, 0x2c, 0xc9, 0x2f, 0x92, 0x60, + 0x54, 0x60, 0xd4, 0xe0, 0x0c, 0x82, 0x71, 0x85, 0x94, 0xb8, 0x78, 0xc1, 0x2e, 0x8b, 0xcf, 0x4c, + 0x89, 0xcf, 0xc9, 0x2c, 0x2e, 0x91, 0x60, 0x52, 0x60, 0xd6, 0x60, 0x0e, 0xe2, 0x06, 0x0b, 0x7a, + 0xa6, 0xf8, 0x64, 0x16, 0x97, 0x28, 0xa9, 0x72, 0x29, 0xe3, 0x31, 0x3c, 0x28, 0xb5, 0xb8, 0x20, + 0x3f, 0xaf, 0x38, 0x55, 0x29, 0x86, 0x4b, 0xc6, 0xb7, 0x38, 0xdd, 0x25, 0xb3, 0x98, 0x26, 0x8e, + 0x50, 0xe3, 0x52, 0xc1, 0x67, 0x3a, 0xcc, 0x15, 0x46, 0xc7, 0x98, 0xb8, 0x98, 0x7d, 0x8b, 0xd3, + 0x85, 0xe6, 0x30, 0x72, 0x49, 0xe0, 0x0c, 0x0f, 0x6b, 0x3d, 0xfc, 0x51, 0xa2, 0x87, 0xc7, 0xbf, + 0x52, 0xce, 0x14, 0x68, 0x86, 0x39, 0x53, 0x68, 0x3e, 0x23, 0x97, 0x24, 0xee, 0xa0, 0xb2, 0x21, + 0xc2, 0x0a, 0x9c, 0xba, 0xa5, 0x5c, 0x28, 0xd1, 0x0d, 0x73, 0xa1, 0x93, 0xcf, 0x89, 0x47, 0x72, + 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, + 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x19, 0xa5, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, + 0xe7, 0xe7, 0xea, 0x83, 0xcc, 0xd7, 0x05, 0x5b, 0xa5, 0x0f, 0xb3, 0x4a, 0xbf, 0x42, 0x1f, 0x25, + 0x1b, 0x54, 0x16, 0xa4, 0x16, 0x27, 0xb1, 0x81, 0xd3, 0xa9, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, + 0x47, 0xa2, 0x8f, 0xac, 0x22, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/lightclient/types/verification_flags.go b/x/lightclient/types/verification_flags.go index 6430cf1cdb..b71c9cf55b 100644 --- a/x/lightclient/types/verification_flags.go +++ b/x/lightclient/types/verification_flags.go @@ -4,14 +4,14 @@ import "github.com/zeta-chain/zetacore/pkg/chains" func DefaultBlockHeaderVerification() BlockHeaderVerification { return BlockHeaderVerification{ - EnabledChains: DefaultVerificationFlags(), + HeaderSupportedChains: DefaultHeaderSupportedChains(), } } -// DefaultVerificationFlags returns the default verification flags. +// DefaultHeaderSupportedChains returns the default verification flags. // By default, everything disabled. -func DefaultVerificationFlags() []EnabledChain { - return []EnabledChain{ +func DefaultHeaderSupportedChains() []HeaderSupportedChain { + return []HeaderSupportedChain{ { ChainId: chains.EthChain.ChainId, Enabled: false, diff --git a/x/lightclient/types/verification_flags_test.go b/x/lightclient/types/verification_flags_test.go index 7b3ddee193..0fedb960c8 100644 --- a/x/lightclient/types/verification_flags_test.go +++ b/x/lightclient/types/verification_flags_test.go @@ -9,7 +9,7 @@ import ( func TestDefaultVerificationFlags(t *testing.T) { t.Run("default verification flags is all disabled", func(t *testing.T) { - flags := DefaultVerificationFlags() + flags := DefaultHeaderSupportedChains() for _, f := range flags { switch f.ChainId { case chains.EthChain.ChainId: diff --git a/zetaclient/bitcoin/bitcoin_client.go b/zetaclient/bitcoin/bitcoin_client.go index ab65d2e171..e57f620323 100644 --- a/zetaclient/bitcoin/bitcoin_client.go +++ b/zetaclient/bitcoin/bitcoin_client.go @@ -476,8 +476,8 @@ func (ob *BTCChainClient) ObserveInTx() error { // add block header to zetabridge // TODO: consider having a separate 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 { + blockHeaderVerification, found := ob.coreContext.GetBlockHeaderEnabledChains(ob.chain.ChainId) + if found && blockHeaderVerification.Enabled { err = ob.postBlockHeader(blockNumber) if err != nil { ob.logger.InTx.Warn().Err(err).Msgf("observeInTxBTC: error posting block header %d", blockNumber) diff --git a/zetaclient/core_context/zeta_core_context.go b/zetaclient/core_context/zeta_core_context.go index 7133f47acf..ad68a9699a 100644 --- a/zetaclient/core_context/zeta_core_context.go +++ b/zetaclient/core_context/zeta_core_context.go @@ -25,7 +25,8 @@ type ZetaCoreContext struct { crossChainFlags observertypes.CrosschainFlags // blockHeaderEnabledChains is used to store the list of chains that have block header verification enabled - blockHeaderEnabledChains []lightclienttypes.EnabledChain + // All chains in this list will have Enabled flag set to true + blockHeaderEnabledChains []lightclienttypes.HeaderSupportedChain } // NewZetaCoreContext creates and returns new ZetaCoreContext @@ -48,7 +49,7 @@ func NewZetaCoreContext(cfg config.Config) *ZetaCoreContext { evmChainParams: evmChainParams, bitcoinChainParams: bitcoinChainParams, crossChainFlags: observertypes.CrosschainFlags{}, - blockHeaderEnabledChains: []lightclienttypes.EnabledChain{}, + blockHeaderEnabledChains: []lightclienttypes.HeaderSupportedChain{}, } } @@ -125,15 +126,15 @@ func (c *ZetaCoreContext) GetCrossChainFlags() observertypes.CrosschainFlags { return c.crossChainFlags } -// GetAllVerificationFlags returns all verification flags -func (c *ZetaCoreContext) GetAllVerificationFlags() []lightclienttypes.EnabledChain { +// GetAllHeaderEnabledChains returns all verification flags +func (c *ZetaCoreContext) GetAllHeaderEnabledChains() []lightclienttypes.HeaderSupportedChain { c.coreContextLock.RLock() defer c.coreContextLock.RUnlock() return c.blockHeaderEnabledChains } -// GetVerificationFlags returns verification flags for a chain -func (c *ZetaCoreContext) GetVerificationFlags(chainID int64) (lightclienttypes.EnabledChain, bool) { +// GetBlockHeaderEnabledChains checks if block header verification is enabled for a specific chain +func (c *ZetaCoreContext) GetBlockHeaderEnabledChains(chainID int64) (lightclienttypes.HeaderSupportedChain, bool) { c.coreContextLock.RLock() defer c.coreContextLock.RUnlock() for _, flags := range c.blockHeaderEnabledChains { @@ -141,7 +142,7 @@ func (c *ZetaCoreContext) GetVerificationFlags(chainID int64) (lightclienttypes. return flags, true } } - return lightclienttypes.EnabledChain{}, false + return lightclienttypes.HeaderSupportedChain{}, false } // Update updates core context and params for all chains @@ -153,7 +154,7 @@ func (c *ZetaCoreContext) Update( btcChainParams *observertypes.ChainParams, tssPubKey string, crosschainFlags observertypes.CrosschainFlags, - verificationFlags []lightclienttypes.EnabledChain, + blockHeaderEnabledChains []lightclienttypes.HeaderSupportedChain, init bool, logger zerolog.Logger, ) { @@ -196,7 +197,7 @@ func (c *ZetaCoreContext) Update( c.chainsEnabled = newChains c.crossChainFlags = crosschainFlags - c.blockHeaderEnabledChains = verificationFlags + c.blockHeaderEnabledChains = blockHeaderEnabledChains // update chain params for bitcoin if it has config in file if c.bitcoinChainParams != nil && btcChainParams != nil { diff --git a/zetaclient/core_context/zeta_core_context_test.go b/zetaclient/core_context/zeta_core_context_test.go index 6e517571d9..deb28aab14 100644 --- a/zetaclient/core_context/zeta_core_context_test.go +++ b/zetaclient/core_context/zeta_core_context_test.go @@ -28,7 +28,7 @@ func getTestCoreContext( evmChain chains.Chain, evmChainParams *observertypes.ChainParams, ccFlags observertypes.CrosschainFlags, - verificationFlags []lightclienttypes.EnabledChain, + verificationFlags []lightclienttypes.HeaderSupportedChain, ) *corecontext.ZetaCoreContext { // create config cfg := config.NewConfig() @@ -170,7 +170,7 @@ func TestUpdateZetaCoreContext(t *testing.T) { tssPubKeyToUpdate := "tsspubkeytest" loggers := clientcommon.DefaultLoggers() crosschainFlags := sample.CrosschainFlags() - verificationFlags := sample.VerificationFlags() + verificationFlags := sample.HeaderSupportedChains() require.NotNil(t, crosschainFlags) zetaContext.Update( @@ -208,7 +208,7 @@ func TestUpdateZetaCoreContext(t *testing.T) { ccFlags := zetaContext.GetCrossChainFlags() require.Equal(t, *crosschainFlags, ccFlags) - verFlags := zetaContext.GetAllVerificationFlags() + verFlags := zetaContext.GetAllHeaderEnabledChains() require.Equal(t, verificationFlags, verFlags) }) @@ -267,7 +267,7 @@ func TestUpdateZetaCoreContext(t *testing.T) { } tssPubKeyToUpdate := "tsspubkeytest" crosschainFlags := sample.CrosschainFlags() - verificationFlags := sample.VerificationFlags() + verificationFlags := sample.HeaderSupportedChains() require.NotNil(t, crosschainFlags) loggers := clientcommon.DefaultLoggers() zetaContext.Update( @@ -313,7 +313,7 @@ func TestUpdateZetaCoreContext(t *testing.T) { ccFlags := zetaContext.GetCrossChainFlags() require.Equal(t, ccFlags, *crosschainFlags) - verFlags := zetaContext.GetAllVerificationFlags() + verFlags := zetaContext.GetAllHeaderEnabledChains() require.Equal(t, verFlags, verificationFlags) }) } @@ -322,7 +322,7 @@ func TestIsOutboundObservationEnabled(t *testing.T) { // create test chain params and flags evmChain := chains.EthChain ccFlags := *sample.CrosschainFlags() - verificationFlags := sample.VerificationFlags() + verificationFlags := sample.HeaderSupportedChains() chainParams := &observertypes.ChainParams{ ChainId: evmChain.ChainId, IsSupported: true, @@ -352,7 +352,7 @@ func TestIsInboundObservationEnabled(t *testing.T) { // create test chain params and flags evmChain := chains.EthChain ccFlags := *sample.CrosschainFlags() - verificationFlags := sample.VerificationFlags() + verificationFlags := sample.HeaderSupportedChains() chainParams := &observertypes.ChainParams{ ChainId: evmChain.ChainId, IsSupported: true, diff --git a/zetaclient/evm/evm_client.go b/zetaclient/evm/evm_client.go index 1985181051..58f00edbeb 100644 --- a/zetaclient/evm/evm_client.go +++ b/zetaclient/evm/evm_client.go @@ -982,8 +982,8 @@ func (ob *ChainClient) ObserverTSSReceive(startBlock, toBlock uint64) uint64 { // post new block header (if any) to zetabridge and ignore error // 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 { + blockHeaderVerification, found := ob.coreContext.GetBlockHeaderEnabledChains(ob.chain.ChainId) + if found && blockHeaderVerification.Enabled { // post block header for supported chains err := ob.postBlockHeader(toBlock) if err != nil { diff --git a/zetaclient/evm/evm_client_test.go b/zetaclient/evm/evm_client_test.go index 6b195ab85c..9748228231 100644 --- a/zetaclient/evm/evm_client_test.go +++ b/zetaclient/evm/evm_client_test.go @@ -46,7 +46,7 @@ func getAppContext(evmChain chains.Chain, evmChainParams *observertypes.ChainPar nil, "", *sample.CrosschainFlags(), - sample.VerificationFlags(), + sample.HeaderSupportedChains(), true, zerolog.Logger{}, ) diff --git a/zetaclient/zetabridge/query.go b/zetaclient/zetabridge/query.go index 89b097aefd..37283dde2d 100644 --- a/zetaclient/zetabridge/query.go +++ b/zetaclient/zetabridge/query.go @@ -33,13 +33,13 @@ func (b *ZetaCoreBridge) GetCrosschainFlags() (observertypes.CrosschainFlags, er return resp.CrosschainFlags, nil } -func (b *ZetaCoreBridge) GetBlockHeaderEnabledChains() ([]lightclienttypes.EnabledChain, error) { +func (b *ZetaCoreBridge) GetBlockHeaderEnabledChains() ([]lightclienttypes.HeaderSupportedChain, error) { client := lightclienttypes.NewQueryClient(b.grpcConn) - resp, err := client.HeaderEnabledChains(context.Background(), &lightclienttypes.QueryHeaderEnabledChainsRequest{}) + resp, err := client.HeaderEnabledChains(context.Background(), &lightclienttypes.HeaderEnabledChainsRequest{}) if err != nil { - return []lightclienttypes.EnabledChain{}, err + return []lightclienttypes.HeaderSupportedChain{}, err } - return resp.EnabledChains, nil + return resp.HeaderEnabledChains, nil } func (b *ZetaCoreBridge) GetChainParamsForChainID(externalChainID int64) (*observertypes.ChainParams, error) { diff --git a/zetaclient/zetabridge/query_test.go b/zetaclient/zetabridge/query_test.go index 68c254cb96..8bb6017833 100644 --- a/zetaclient/zetabridge/query_test.go +++ b/zetaclient/zetabridge/query_test.go @@ -103,7 +103,7 @@ func TestZetaCoreBridge_GetCrosschainFlags(t *testing.T) { } func TestZetaCoreBridge_HeaderEnabledChains(t *testing.T) { - expectedOutput := lightclienttypes.QueryHeaderEnabledChainsResponse{EnabledChains: []lightclienttypes.EnabledChain{ + expectedOutput := lightclienttypes.QueryHeaderSupportedChainsResponse{HeaderSupportedChains: []lightclienttypes.HeaderSupportedChain{ { ChainId: chains.EthChain.ChainId, Enabled: true, @@ -113,8 +113,8 @@ func TestZetaCoreBridge_HeaderEnabledChains(t *testing.T) { Enabled: true, }, }} - input := lightclienttypes.QueryHeaderEnabledChainsRequest{} - method := "/zetachain.zetacore.lightclient.Query/HeaderEnabledChains" + input := lightclienttypes.QueryHeaderSupportedChainsRequest{} + method := "/zetachain.zetacore.lightclient.Query/HeaderSupportedChains" server := setupMockServer(t, lightclienttypes.RegisterQueryServer, method, input, expectedOutput) server.Serve() defer closeMockServer(t, server) @@ -124,7 +124,7 @@ func TestZetaCoreBridge_HeaderEnabledChains(t *testing.T) { resp, err := zetabridge.GetBlockHeaderEnabledChains() require.NoError(t, err) - require.Equal(t, expectedOutput.EnabledChains, resp) + require.Equal(t, expectedOutput.HeaderSupportedChains, resp) } func TestZetaCoreBridge_GetChainParamsForChainID(t *testing.T) { diff --git a/zetaclient/zetabridge/tx_test.go b/zetaclient/zetabridge/tx_test.go index c99c5db7d4..8cc6b7b449 100644 --- a/zetaclient/zetabridge/tx_test.go +++ b/zetaclient/zetabridge/tx_test.go @@ -303,11 +303,11 @@ func TestZetaCoreBridge_UpdateZetaCoreContext(t *testing.T) { BlockHeaderVerificationFlags: nil, }}) - method = "/zetachain.zetacore.lightclient.Query/HeaderEnabledChains" + method = "/zetachain.zetacore.lightclient.Query/HeaderSupportedChains" s.ExpectUnary(method). UnlimitedTimes(). - WithPayload(lightclienttypes.QueryHeaderEnabledChainsRequest{}). - Return(lightclienttypes.QueryHeaderEnabledChainsResponse{EnabledChains: []lightclienttypes.EnabledChain{ + WithPayload(lightclienttypes.QueryHeaderSupportedChainsRequest{}). + Return(lightclienttypes.QueryHeaderSupportedChainsResponse{HeaderSupportedChains: []lightclienttypes.HeaderSupportedChain{ { ChainId: chains.EthChain.ChainId, Enabled: true, diff --git a/zetaclient/zetacore_observer_test.go b/zetaclient/zetacore_observer_test.go index a02263fb0f..b5cf74e2a9 100644 --- a/zetaclient/zetacore_observer_test.go +++ b/zetaclient/zetacore_observer_test.go @@ -56,7 +56,7 @@ func CreateCoreContext(evmChain, btcChain chains.Chain, evmChainParams, btcChain evmChainParamsMap := make(map[int64]*observertypes.ChainParams) evmChainParamsMap[evmChain.ChainId] = evmChainParams ccFlags := sample.CrosschainFlags() - verificationFlags := sample.VerificationFlags() + verificationFlags := sample.HeaderSupportedChains() // feed chain params coreContext.Update( From 3fa5987e5edd213e61b0634e34fa761cfda6097c Mon Sep 17 00:00:00 2001 From: Tanmay Date: Wed, 1 May 2024 01:29:36 -0400 Subject: [PATCH 27/31] add enabled chain query to zetacliet tests --- proto/lightclient/query.proto | 6 +- .../grpc_query_header_enabled_chains.go | 4 +- x/lightclient/types/query.pb.go | 222 +++++++++--------- x/lightclient/types/query.pb.gw.go | 4 +- zetaclient/zetabridge/query.go | 2 +- zetaclient/zetabridge/query_test.go | 8 +- zetaclient/zetabridge/tx_test.go | 6 +- 7 files changed, 126 insertions(+), 126 deletions(-) diff --git a/proto/lightclient/query.proto b/proto/lightclient/query.proto index 385a2f1f21..02d1735613 100644 --- a/proto/lightclient/query.proto +++ b/proto/lightclient/query.proto @@ -36,7 +36,7 @@ service Query { option (google.api.http).get = "/zeta-chain/lightclient/header_supported_chains"; } - rpc HeaderEnabledChains(HeaderEnabledChainsRequest) returns (HeaderEnabledChainsResponse) { + rpc HeaderEnabledChains(QueryHeaderEnabledChainsRequest) returns (QueryHeaderEnabledChainsResponse) { option (google.api.http).get = "/zeta-chain/lightclient/header_enabled_chains"; } } @@ -93,8 +93,8 @@ message QueryHeaderSupportedChainsResponse { repeated HeaderSupportedChain header_supported_chains = 1 [(gogoproto.nullable) = false]; } -message HeaderEnabledChainsRequest {} +message QueryHeaderEnabledChainsRequest {} -message HeaderEnabledChainsResponse { +message QueryHeaderEnabledChainsResponse { repeated HeaderSupportedChain header_enabled_chains = 1 [(gogoproto.nullable) = false]; } diff --git a/x/lightclient/keeper/grpc_query_header_enabled_chains.go b/x/lightclient/keeper/grpc_query_header_enabled_chains.go index c5c2f318e6..70a447f6e8 100644 --- a/x/lightclient/keeper/grpc_query_header_enabled_chains.go +++ b/x/lightclient/keeper/grpc_query_header_enabled_chains.go @@ -25,7 +25,7 @@ func (k Keeper) HeaderSupportedChains(c context.Context, req *types.QueryHeaderS // HeaderEnabledChains implements the Query/HeaderEnabledChains gRPC method // It returns a list of chains that have block header verification enabled. -func (k Keeper) HeaderEnabledChains(c context.Context, req *types.HeaderEnabledChainsRequest) (*types.HeaderEnabledChainsResponse, error) { +func (k Keeper) HeaderEnabledChains(c context.Context, req *types.QueryHeaderEnabledChainsRequest) (*types.QueryHeaderEnabledChainsResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "invalid request") } @@ -33,6 +33,6 @@ func (k Keeper) HeaderEnabledChains(c context.Context, req *types.HeaderEnabledC val, _ := k.GetBlockHeaderVerification(ctx) - return &types.HeaderEnabledChainsResponse{HeaderEnabledChains: val.GetHeaderEnabledChains()}, nil + return &types.QueryHeaderEnabledChainsResponse{HeaderEnabledChains: val.GetHeaderEnabledChains()}, nil } diff --git a/x/lightclient/types/query.pb.go b/x/lightclient/types/query.pb.go index 8e1c3e16d5..57737e0ac1 100644 --- a/x/lightclient/types/query.pb.go +++ b/x/lightclient/types/query.pb.go @@ -600,21 +600,21 @@ func (m *QueryHeaderSupportedChainsResponse) GetHeaderSupportedChains() []Header return nil } -type HeaderEnabledChainsRequest struct { +type QueryHeaderEnabledChainsRequest struct { } -func (m *HeaderEnabledChainsRequest) Reset() { *m = HeaderEnabledChainsRequest{} } -func (m *HeaderEnabledChainsRequest) String() string { return proto.CompactTextString(m) } -func (*HeaderEnabledChainsRequest) ProtoMessage() {} -func (*HeaderEnabledChainsRequest) Descriptor() ([]byte, []int) { +func (m *QueryHeaderEnabledChainsRequest) Reset() { *m = QueryHeaderEnabledChainsRequest{} } +func (m *QueryHeaderEnabledChainsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryHeaderEnabledChainsRequest) ProtoMessage() {} +func (*QueryHeaderEnabledChainsRequest) Descriptor() ([]byte, []int) { return fileDescriptor_03e46747c4ffba77, []int{12} } -func (m *HeaderEnabledChainsRequest) XXX_Unmarshal(b []byte) error { +func (m *QueryHeaderEnabledChainsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *HeaderEnabledChainsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryHeaderEnabledChainsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_HeaderEnabledChainsRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryHeaderEnabledChainsRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -624,34 +624,34 @@ func (m *HeaderEnabledChainsRequest) XXX_Marshal(b []byte, deterministic bool) ( return b[:n], nil } } -func (m *HeaderEnabledChainsRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_HeaderEnabledChainsRequest.Merge(m, src) +func (m *QueryHeaderEnabledChainsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryHeaderEnabledChainsRequest.Merge(m, src) } -func (m *HeaderEnabledChainsRequest) XXX_Size() int { +func (m *QueryHeaderEnabledChainsRequest) XXX_Size() int { return m.Size() } -func (m *HeaderEnabledChainsRequest) XXX_DiscardUnknown() { - xxx_messageInfo_HeaderEnabledChainsRequest.DiscardUnknown(m) +func (m *QueryHeaderEnabledChainsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryHeaderEnabledChainsRequest.DiscardUnknown(m) } -var xxx_messageInfo_HeaderEnabledChainsRequest proto.InternalMessageInfo +var xxx_messageInfo_QueryHeaderEnabledChainsRequest proto.InternalMessageInfo -type HeaderEnabledChainsResponse struct { +type QueryHeaderEnabledChainsResponse struct { HeaderEnabledChains []HeaderSupportedChain `protobuf:"bytes,1,rep,name=header_enabled_chains,json=headerEnabledChains,proto3" json:"header_enabled_chains"` } -func (m *HeaderEnabledChainsResponse) Reset() { *m = HeaderEnabledChainsResponse{} } -func (m *HeaderEnabledChainsResponse) String() string { return proto.CompactTextString(m) } -func (*HeaderEnabledChainsResponse) ProtoMessage() {} -func (*HeaderEnabledChainsResponse) Descriptor() ([]byte, []int) { +func (m *QueryHeaderEnabledChainsResponse) Reset() { *m = QueryHeaderEnabledChainsResponse{} } +func (m *QueryHeaderEnabledChainsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryHeaderEnabledChainsResponse) ProtoMessage() {} +func (*QueryHeaderEnabledChainsResponse) Descriptor() ([]byte, []int) { return fileDescriptor_03e46747c4ffba77, []int{13} } -func (m *HeaderEnabledChainsResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryHeaderEnabledChainsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *HeaderEnabledChainsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryHeaderEnabledChainsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_HeaderEnabledChainsResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryHeaderEnabledChainsResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -661,19 +661,19 @@ func (m *HeaderEnabledChainsResponse) XXX_Marshal(b []byte, deterministic bool) return b[:n], nil } } -func (m *HeaderEnabledChainsResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_HeaderEnabledChainsResponse.Merge(m, src) +func (m *QueryHeaderEnabledChainsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryHeaderEnabledChainsResponse.Merge(m, src) } -func (m *HeaderEnabledChainsResponse) XXX_Size() int { +func (m *QueryHeaderEnabledChainsResponse) XXX_Size() int { return m.Size() } -func (m *HeaderEnabledChainsResponse) XXX_DiscardUnknown() { - xxx_messageInfo_HeaderEnabledChainsResponse.DiscardUnknown(m) +func (m *QueryHeaderEnabledChainsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryHeaderEnabledChainsResponse.DiscardUnknown(m) } -var xxx_messageInfo_HeaderEnabledChainsResponse proto.InternalMessageInfo +var xxx_messageInfo_QueryHeaderEnabledChainsResponse proto.InternalMessageInfo -func (m *HeaderEnabledChainsResponse) GetHeaderEnabledChains() []HeaderSupportedChain { +func (m *QueryHeaderEnabledChainsResponse) GetHeaderEnabledChains() []HeaderSupportedChain { if m != nil { return m.HeaderEnabledChains } @@ -693,72 +693,72 @@ func init() { proto.RegisterType((*QueryProveResponse)(nil), "zetachain.zetacore.lightclient.QueryProveResponse") proto.RegisterType((*QueryHeaderSupportedChainsRequest)(nil), "zetachain.zetacore.lightclient.QueryHeaderSupportedChainsRequest") proto.RegisterType((*QueryHeaderSupportedChainsResponse)(nil), "zetachain.zetacore.lightclient.QueryHeaderSupportedChainsResponse") - proto.RegisterType((*HeaderEnabledChainsRequest)(nil), "zetachain.zetacore.lightclient.HeaderEnabledChainsRequest") - proto.RegisterType((*HeaderEnabledChainsResponse)(nil), "zetachain.zetacore.lightclient.HeaderEnabledChainsResponse") + proto.RegisterType((*QueryHeaderEnabledChainsRequest)(nil), "zetachain.zetacore.lightclient.QueryHeaderEnabledChainsRequest") + proto.RegisterType((*QueryHeaderEnabledChainsResponse)(nil), "zetachain.zetacore.lightclient.QueryHeaderEnabledChainsResponse") } func init() { proto.RegisterFile("lightclient/query.proto", fileDescriptor_03e46747c4ffba77) } var fileDescriptor_03e46747c4ffba77 = []byte{ - // 915 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0x4f, 0x8f, 0xdb, 0x44, - 0x14, 0xcf, 0x74, 0x9b, 0xfe, 0x79, 0xd9, 0x45, 0x62, 0xb6, 0x55, 0x52, 0xb7, 0x9b, 0x16, 0xaf, - 0x96, 0x56, 0x5b, 0xad, 0x4d, 0x42, 0x59, 0x44, 0x2a, 0x21, 0x6d, 0x10, 0x2c, 0x15, 0x1c, 0xb6, - 0xae, 0xb8, 0x70, 0x89, 0x1c, 0x67, 0x6a, 0x5b, 0x75, 0x3d, 0xae, 0x67, 0x12, 0xa5, 0x54, 0xbd, - 0x70, 0x47, 0x42, 0x42, 0x48, 0x7c, 0x02, 0xbe, 0x00, 0x42, 0xaa, 0xc4, 0x0d, 0x09, 0xa9, 0xc7, - 0x4a, 0x1c, 0xe0, 0x84, 0xd0, 0x2e, 0x1f, 0x04, 0x79, 0x66, 0x82, 0x27, 0x59, 0x27, 0x71, 0x97, - 0x3d, 0xc5, 0xf6, 0xcc, 0x7b, 0xbf, 0x3f, 0xf3, 0xe6, 0xb7, 0x0b, 0xf5, 0x28, 0xf4, 0x03, 0xee, - 0x45, 0x21, 0x89, 0xb9, 0xfd, 0x64, 0x48, 0xd2, 0xa7, 0x56, 0x92, 0x52, 0x4e, 0x71, 0xf3, 0x2b, - 0xc2, 0x5d, 0x2f, 0x70, 0xc3, 0xd8, 0x12, 0x4f, 0x34, 0x25, 0x96, 0xb6, 0xd7, 0xd8, 0xf6, 0x28, - 0x7b, 0x4c, 0x99, 0xdd, 0x77, 0x19, 0x91, 0x85, 0xf6, 0xa8, 0xd5, 0x27, 0xdc, 0x6d, 0xd9, 0x89, - 0xeb, 0x87, 0xb1, 0xcb, 0x43, 0x1a, 0xcb, 0x5e, 0xc6, 0x25, 0x9f, 0xfa, 0x54, 0x3c, 0xda, 0xd9, - 0x93, 0xfa, 0x7a, 0xcd, 0xa7, 0xd4, 0x8f, 0x88, 0xed, 0x26, 0xa1, 0xed, 0xc6, 0x31, 0xe5, 0xa2, - 0x84, 0xa9, 0xd5, 0xdb, 0x3a, 0xb1, 0x7e, 0x44, 0xbd, 0x47, 0xbd, 0x80, 0xb8, 0x03, 0x92, 0xf6, - 0x46, 0x24, 0x0d, 0x1f, 0x86, 0x9e, 0x0e, 0xb0, 0xa1, 0x6f, 0x16, 0xa4, 0x7b, 0x8c, 0xbb, 0x9c, - 0xa8, 0xe5, 0x7a, 0xf2, 0xc8, 0xb7, 0x93, 0x94, 0xd2, 0x87, 0x4c, 0xfd, 0xc8, 0x05, 0x73, 0x00, - 0xc6, 0xfd, 0x8c, 0xfa, 0x5e, 0x14, 0x75, 0x33, 0x88, 0x4f, 0x05, 0x82, 0x43, 0x9e, 0x0c, 0x09, - 0xe3, 0xf8, 0x13, 0x80, 0x5c, 0x4a, 0x03, 0xdd, 0x40, 0xb7, 0x6a, 0xed, 0xb7, 0x2d, 0xa9, 0xdb, - 0xca, 0x74, 0x5b, 0xd2, 0x30, 0xa5, 0xdb, 0x3a, 0x70, 0x7d, 0xa2, 0x6a, 0x1d, 0xad, 0xd2, 0xfc, - 0x11, 0xc1, 0xd5, 0x42, 0x18, 0x96, 0xd0, 0x98, 0x11, 0xfc, 0x21, 0xac, 0xe9, 0x02, 0x59, 0x03, - 0xdd, 0x58, 0xb9, 0x55, 0x6b, 0xaf, 0x5b, 0x8a, 0xab, 0x56, 0xd3, 0x3d, 0xfb, 0xf2, 0xaf, 0xeb, - 0x15, 0x67, 0xb5, 0x9f, 0x7f, 0x62, 0x78, 0x7f, 0x8a, 0xe7, 0x19, 0xc1, 0xf3, 0xe6, 0x52, 0x9e, - 0x12, 0x7c, 0x8a, 0xe8, 0x5d, 0x65, 0xc7, 0x3e, 0xe1, 0x05, 0x76, 0x6c, 0x00, 0x28, 0x9a, 0x2e, - 0x0b, 0x84, 0x1d, 0xab, 0xce, 0x45, 0x49, 0xc4, 0x65, 0x81, 0xf9, 0x85, 0x12, 0x39, 0x5b, 0xac, - 0x44, 0xee, 0xc2, 0xaa, 0x2e, 0x52, 0xd9, 0x59, 0xa4, 0xd1, 0xa9, 0x69, 0xea, 0x4c, 0x0f, 0xae, - 0x4c, 0xbc, 0xfb, 0x28, 0x3b, 0xd8, 0x07, 0xd9, 0xb9, 0x9e, 0xf6, 0x09, 0xbd, 0x40, 0xf9, 0x20, - 0xe8, 0x28, 0x8a, 0xfb, 0x7d, 0xa8, 0x69, 0x43, 0xa5, 0x8e, 0x67, 0xdb, 0x5a, 0x7c, 0x43, 0xac, - 0xbc, 0x91, 0x3a, 0x35, 0xf0, 0xfe, 0xfb, 0x72, 0x7a, 0x67, 0xb6, 0xab, 0xfc, 0xd9, 0x27, 0xfc, - 0xb8, 0x3f, 0x57, 0xe0, 0x82, 0x24, 0x1e, 0x0e, 0x84, 0x3b, 0x2b, 0xce, 0x79, 0xf1, 0x7e, 0x6f, - 0x60, 0x86, 0xf9, 0x59, 0x17, 0x28, 0xfe, 0x6c, 0x56, 0x31, 0x7a, 0x3d, 0xc5, 0xba, 0xd6, 0x6c, - 0xfe, 0xdf, 0x14, 0x58, 0x07, 0x29, 0x1d, 0x95, 0xe0, 0x86, 0xeb, 0x70, 0x9e, 0x8f, 0xe5, 0x98, - 0x65, 0xce, 0x5c, 0x74, 0xce, 0xf1, 0x71, 0x36, 0x63, 0x78, 0x13, 0xaa, 0x62, 0x5e, 0x1a, 0x2b, - 0x82, 0xd0, 0xda, 0x64, 0x7a, 0x0e, 0xb2, 0x1f, 0x47, 0xae, 0xcd, 0xcc, 0xe9, 0x59, 0xd1, 0x20, - 0x9f, 0xd3, 0x0c, 0x97, 0x8f, 0x7b, 0x61, 0x3c, 0x20, 0xe3, 0x46, 0x55, 0xe2, 0xf2, 0xf1, 0xbd, - 0xec, 0xd5, 0xdc, 0x06, 0xac, 0xf3, 0x54, 0x5e, 0x5c, 0x82, 0xea, 0xc8, 0x8d, 0x14, 0xcb, 0x0b, - 0x8e, 0x7c, 0x31, 0x37, 0xe1, 0x2d, 0xb1, 0x57, 0x8e, 0xe9, 0x83, 0x61, 0x92, 0xd0, 0x94, 0x93, - 0x81, 0xb0, 0x80, 0x29, 0x8d, 0xe6, 0x0f, 0x08, 0xcc, 0x45, 0xbb, 0x14, 0x42, 0x0a, 0x75, 0x95, - 0x6d, 0x6c, 0xb2, 0xa3, 0x27, 0xbc, 0x98, 0x44, 0xc1, 0x9d, 0x65, 0xce, 0x17, 0xf5, 0x57, 0x53, - 0x77, 0x39, 0x28, 0xc2, 0x36, 0xaf, 0x81, 0x21, 0x8b, 0x3e, 0x8e, 0xdd, 0x7e, 0x34, 0x4b, 0xfc, - 0x1b, 0x04, 0x57, 0x0b, 0x97, 0x15, 0xe3, 0x18, 0x54, 0xdb, 0x1e, 0x91, 0xeb, 0xa7, 0xc7, 0x77, - 0x3d, 0x38, 0x8e, 0xdb, 0xfe, 0x19, 0xa0, 0x2a, 0x8c, 0xc4, 0x2f, 0x10, 0xbc, 0xa1, 0x85, 0xc5, - 0x5e, 0x14, 0xe1, 0xce, 0x32, 0xb4, 0xf9, 0x19, 0x6f, 0xdc, 0x3d, 0x51, 0xad, 0x74, 0xc1, 0xdc, - 0xf9, 0xfa, 0xf7, 0x7f, 0xbe, 0x3b, 0x73, 0x13, 0x6f, 0xd9, 0x59, 0xe9, 0x8e, 0xe8, 0x62, 0xcf, - 0xfb, 0xbb, 0xc5, 0xf0, 0xaf, 0x08, 0x6a, 0x5a, 0x9b, 0x92, 0xbc, 0x0b, 0xc3, 0xb8, 0x24, 0xef, - 0xe2, 0x2c, 0x36, 0x3b, 0x82, 0xf7, 0x1d, 0xdc, 0x2e, 0xc5, 0xdb, 0x7e, 0x96, 0x5f, 0xa7, 0xe7, - 0xf8, 0x27, 0x04, 0x6b, 0xf9, 0x3d, 0xcf, 0xec, 0xff, 0xa0, 0xac, 0x85, 0xc7, 0xf2, 0xc9, 0xe8, - 0x9c, 0xa4, 0x54, 0x89, 0xb8, 0x2d, 0x44, 0x6c, 0xe1, 0xcd, 0x79, 0x22, 0xb4, 0x00, 0xc3, 0xbf, - 0x20, 0x80, 0xbc, 0x47, 0x49, 0xca, 0x45, 0x91, 0x6a, 0x74, 0x4e, 0x52, 0xaa, 0x28, 0xef, 0x0a, - 0xca, 0xef, 0x60, 0xab, 0x04, 0x65, 0xfb, 0xd9, 0x24, 0x1d, 0x9f, 0xe3, 0xef, 0x11, 0x54, 0x45, - 0x26, 0xe1, 0x56, 0x29, 0x74, 0x3d, 0x67, 0x8d, 0xf6, 0xeb, 0x94, 0x28, 0xa2, 0x5b, 0x82, 0xe8, - 0x75, 0xbc, 0x31, 0x8f, 0x68, 0x22, 0xd8, 0xfc, 0x81, 0xe0, 0x72, 0x61, 0xb2, 0xe1, 0xbd, 0x52, - 0xa0, 0x8b, 0xb2, 0xd3, 0xe8, 0xfe, 0x9f, 0x16, 0x4a, 0xc7, 0xfb, 0x42, 0x47, 0x0b, 0xdb, 0xf3, - 0x74, 0xcc, 0x89, 0x5d, 0xfc, 0x1b, 0x82, 0xf5, 0x82, 0xfc, 0x5b, 0x7e, 0x65, 0xe7, 0x67, 0xea, - 0xf2, 0x2b, 0xbb, 0x20, 0x70, 0xcd, 0xf7, 0x84, 0x12, 0x1b, 0xef, 0x2c, 0x51, 0x32, 0x1d, 0xc7, - 0xdd, 0xcf, 0x5f, 0x1e, 0x36, 0xd1, 0xab, 0xc3, 0x26, 0xfa, 0xfb, 0xb0, 0x89, 0xbe, 0x3d, 0x6a, - 0x56, 0x5e, 0x1d, 0x35, 0x2b, 0x7f, 0x1e, 0x35, 0x2b, 0x5f, 0xb6, 0xfd, 0x90, 0x07, 0xc3, 0xbe, - 0xe5, 0xd1, 0xc7, 0x7a, 0xcb, 0x09, 0x31, 0x7b, 0x3c, 0xd5, 0x9d, 0x3f, 0x4d, 0x08, 0xeb, 0x9f, - 0x13, 0xff, 0x35, 0xbf, 0xfb, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x11, 0xf5, 0x39, 0x4b, 0x35, - 0x0c, 0x00, 0x00, + // 918 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x96, 0xcf, 0x6f, 0x1b, 0x45, + 0x14, 0xc7, 0x3d, 0x4d, 0xdd, 0x1f, 0xcf, 0x09, 0x12, 0x93, 0x56, 0x76, 0x17, 0xe2, 0xa4, 0x1b, + 0x85, 0x56, 0xa9, 0xb2, 0x8b, 0x4d, 0x09, 0xc2, 0x95, 0x80, 0x18, 0x41, 0xa8, 0xe0, 0x90, 0x6e, + 0xc5, 0x85, 0x8b, 0xb5, 0x5e, 0x4f, 0x77, 0x57, 0xdd, 0xee, 0x6c, 0x77, 0xc6, 0x96, 0x4b, 0x95, + 0x0b, 0x7f, 0x01, 0x02, 0x21, 0xf1, 0x17, 0xf0, 0x0f, 0x70, 0x89, 0xc4, 0x01, 0x89, 0x53, 0x6e, + 0x44, 0xe2, 0x00, 0x27, 0x84, 0x12, 0xfe, 0x10, 0xb4, 0xb3, 0x63, 0x76, 0xec, 0xac, 0xe3, 0x8d, + 0x9b, 0xd3, 0xfe, 0x98, 0x79, 0xef, 0x7d, 0xbe, 0x6f, 0xde, 0x7e, 0x6d, 0xa8, 0x06, 0xbe, 0xeb, + 0x71, 0x27, 0xf0, 0x49, 0xc8, 0xcd, 0xe7, 0x7d, 0x12, 0xbf, 0x30, 0xa2, 0x98, 0x72, 0x8a, 0xeb, + 0x5f, 0x13, 0x6e, 0x3b, 0x9e, 0xed, 0x87, 0x86, 0xb8, 0xa3, 0x31, 0x31, 0x94, 0xbd, 0xda, 0xa6, + 0x43, 0xd9, 0x33, 0xca, 0xcc, 0xae, 0xcd, 0x48, 0x1a, 0x68, 0x0e, 0x1a, 0x5d, 0xc2, 0xed, 0x86, + 0x19, 0xd9, 0xae, 0x1f, 0xda, 0xdc, 0xa7, 0x61, 0x9a, 0x4b, 0xbb, 0xe1, 0x52, 0x97, 0x8a, 0x5b, + 0x33, 0xb9, 0x93, 0x6f, 0xdf, 0x74, 0x29, 0x75, 0x03, 0x62, 0xda, 0x91, 0x6f, 0xda, 0x61, 0x48, + 0xb9, 0x08, 0x61, 0x72, 0xf5, 0x9e, 0x0a, 0xd6, 0x0d, 0xa8, 0xf3, 0xb4, 0xe3, 0x11, 0xbb, 0x47, + 0xe2, 0xce, 0x80, 0xc4, 0xfe, 0x13, 0xdf, 0x51, 0x0b, 0xac, 0xa8, 0x9b, 0x05, 0x74, 0x87, 0x71, + 0x9b, 0x13, 0xb9, 0x5c, 0x8d, 0x9e, 0xba, 0x66, 0x14, 0x53, 0xfa, 0x84, 0xc9, 0x4b, 0xba, 0xa0, + 0xf7, 0x40, 0x7b, 0x94, 0xa0, 0xef, 0x04, 0x41, 0x3b, 0x29, 0xf1, 0x99, 0xa8, 0x60, 0x91, 0xe7, + 0x7d, 0xc2, 0x38, 0xfe, 0x14, 0x20, 0x93, 0x52, 0x43, 0x6b, 0xe8, 0x6e, 0xa5, 0xf9, 0x96, 0x91, + 0xea, 0x36, 0x12, 0xdd, 0x46, 0xda, 0x30, 0xa9, 0xdb, 0xd8, 0xb3, 0x5d, 0x22, 0x63, 0x2d, 0x25, + 0x52, 0xff, 0x09, 0xc1, 0x1b, 0xb9, 0x65, 0x58, 0x44, 0x43, 0x46, 0xf0, 0x07, 0xb0, 0xa4, 0x0a, + 0x64, 0x35, 0xb4, 0xb6, 0x70, 0xb7, 0xd2, 0x5c, 0x36, 0x24, 0xab, 0x12, 0xd3, 0xbe, 0x7c, 0xf8, + 0xf7, 0x6a, 0xc9, 0x5a, 0xec, 0x66, 0xaf, 0x18, 0xde, 0x1d, 0xe3, 0xbc, 0x24, 0x38, 0xef, 0xcc, + 0xe4, 0x4c, 0x8b, 0x8f, 0x81, 0x3e, 0x90, 0xed, 0xd8, 0x25, 0x3c, 0xa7, 0x1d, 0x2b, 0x00, 0x12, + 0xd3, 0x66, 0x9e, 0x68, 0xc7, 0xa2, 0x75, 0x3d, 0x05, 0xb1, 0x99, 0xa7, 0x7f, 0x29, 0x45, 0x4e, + 0x06, 0x4b, 0x91, 0xdb, 0xb0, 0xa8, 0x8a, 0x94, 0xed, 0xcc, 0xd3, 0x68, 0x55, 0x14, 0x75, 0xba, + 0x03, 0xb7, 0x46, 0xbd, 0xfb, 0x38, 0x39, 0xd8, 0xc7, 0xc9, 0xb9, 0x5e, 0xf4, 0x09, 0x1d, 0xa0, + 0x6c, 0x10, 0xd4, 0x2a, 0x92, 0xfd, 0x11, 0x54, 0x94, 0xa1, 0x92, 0xc7, 0xb3, 0x69, 0x9c, 0xfd, + 0x85, 0x18, 0x59, 0x22, 0x79, 0x6a, 0xe0, 0xfc, 0xff, 0xe6, 0xe2, 0xce, 0x6c, 0x5b, 0xf6, 0x67, + 0x97, 0xf0, 0xd3, 0xfd, 0xb9, 0x05, 0xd7, 0x52, 0x70, 0xbf, 0x27, 0xba, 0xb3, 0x60, 0x5d, 0x15, + 0xcf, 0x0f, 0x7b, 0xba, 0x9f, 0x9d, 0x75, 0x8e, 0xe2, 0xcf, 0x27, 0x15, 0xa3, 0xf3, 0x29, 0x56, + 0xb5, 0x26, 0xf3, 0xff, 0xba, 0xa8, 0xb5, 0x17, 0xd3, 0x41, 0x01, 0x36, 0x5c, 0x85, 0xab, 0x7c, + 0x98, 0x8e, 0x59, 0xd2, 0x99, 0xeb, 0xd6, 0x15, 0x3e, 0x4c, 0x66, 0x0c, 0xaf, 0x43, 0x59, 0xcc, + 0x4b, 0x6d, 0x41, 0x00, 0x2d, 0x8d, 0xa6, 0x67, 0x2f, 0xb9, 0x58, 0xe9, 0xda, 0xc4, 0x9c, 0x5e, + 0x16, 0x09, 0xb2, 0x39, 0x4d, 0xea, 0xf2, 0x61, 0xc7, 0x0f, 0x7b, 0x64, 0x58, 0x2b, 0xa7, 0x75, + 0xf9, 0xf0, 0x61, 0xf2, 0xa8, 0x6f, 0x02, 0x56, 0x39, 0x65, 0x2f, 0x6e, 0x40, 0x79, 0x60, 0x07, + 0x92, 0xf2, 0x9a, 0x95, 0x3e, 0xe8, 0xeb, 0x70, 0x5b, 0xec, 0x4d, 0xc7, 0xf4, 0x71, 0x3f, 0x8a, + 0x68, 0xcc, 0x49, 0x4f, 0xb4, 0x80, 0x49, 0x8d, 0xfa, 0x8f, 0x08, 0xf4, 0xb3, 0x76, 0xc9, 0x0a, + 0x31, 0x54, 0xa5, 0xb7, 0xb1, 0xd1, 0x8e, 0x8e, 0xe8, 0xc5, 0xc8, 0x0a, 0xee, 0xcf, 0xea, 0x7c, + 0x5e, 0x7e, 0x39, 0x75, 0x37, 0xbd, 0xbc, 0xda, 0xfa, 0x6d, 0x58, 0x55, 0xc8, 0x3e, 0x09, 0xed, + 0x6e, 0x30, 0x49, 0xff, 0x1d, 0x82, 0xb5, 0xe9, 0x7b, 0x24, 0x7b, 0x08, 0xb2, 0x40, 0x87, 0xa4, + 0xeb, 0x17, 0x47, 0xbe, 0xec, 0x9d, 0xae, 0xdb, 0xfc, 0x15, 0xa0, 0x2c, 0xa0, 0xf0, 0x01, 0x82, + 0xd7, 0x14, 0xdb, 0xd8, 0x09, 0x02, 0xdc, 0x9a, 0x55, 0x6d, 0xba, 0xdb, 0x6b, 0x0f, 0xe6, 0x8a, + 0x4d, 0xbb, 0xa0, 0x6f, 0x7d, 0xf3, 0xc7, 0xbf, 0xdf, 0x5f, 0xba, 0x83, 0x37, 0xcc, 0x24, 0x74, + 0x4b, 0x64, 0x31, 0xa7, 0xfd, 0x82, 0x31, 0xfc, 0x1b, 0x82, 0x8a, 0x92, 0xa6, 0x20, 0x77, 0xae, + 0x2d, 0x17, 0xe4, 0xce, 0x77, 0x65, 0xbd, 0x25, 0xb8, 0xef, 0xe3, 0x66, 0x21, 0x6e, 0xf3, 0x65, + 0xf6, 0x61, 0xed, 0xe3, 0x9f, 0x11, 0x2c, 0x65, 0x5f, 0x7c, 0xd2, 0xfe, 0xf7, 0x8b, 0xb6, 0xf0, + 0x94, 0x53, 0x69, 0xad, 0x79, 0x42, 0xa5, 0x88, 0x7b, 0x42, 0xc4, 0x06, 0x5e, 0x9f, 0x26, 0x42, + 0xb1, 0x32, 0xfc, 0x0b, 0x02, 0xc8, 0x72, 0x14, 0x44, 0xce, 0x33, 0x57, 0xad, 0x35, 0x4f, 0xa8, + 0x44, 0xde, 0x16, 0xc8, 0x6f, 0x63, 0xa3, 0x00, 0xb2, 0xf9, 0x72, 0xe4, 0x93, 0xfb, 0xf8, 0x07, + 0x04, 0x65, 0xe1, 0x4e, 0xb8, 0x51, 0xa8, 0xba, 0xea, 0xb8, 0x5a, 0xf3, 0x3c, 0x21, 0x12, 0x74, + 0x43, 0x80, 0xae, 0xe2, 0x95, 0x69, 0xa0, 0x91, 0xa0, 0xf9, 0x13, 0xc1, 0xcd, 0x5c, 0x8f, 0xc3, + 0x3b, 0x85, 0x8a, 0x9e, 0xe5, 0xa2, 0x5a, 0xfb, 0x55, 0x52, 0x48, 0x1d, 0xef, 0x09, 0x1d, 0x0d, + 0x6c, 0x4e, 0xd3, 0x31, 0xc5, 0x80, 0xf1, 0xef, 0x08, 0x96, 0x73, 0xfc, 0x0f, 0x7f, 0x78, 0x0e, + 0xa8, 0x3c, 0x77, 0xd5, 0x3e, 0x9a, 0x3f, 0x81, 0xd4, 0xf4, 0xae, 0xd0, 0x64, 0xe2, 0xad, 0x19, + 0x9a, 0xc6, 0x8d, 0xb9, 0xfd, 0xc5, 0xe1, 0x71, 0x1d, 0x1d, 0x1d, 0xd7, 0xd1, 0x3f, 0xc7, 0x75, + 0xf4, 0xed, 0x49, 0xbd, 0x74, 0x74, 0x52, 0x2f, 0xfd, 0x75, 0x52, 0x2f, 0x7d, 0xd5, 0x74, 0x7d, + 0xee, 0xf5, 0xbb, 0x86, 0x43, 0x9f, 0xa9, 0x29, 0x47, 0x74, 0xe6, 0x70, 0x2c, 0x3b, 0x7f, 0x11, + 0x11, 0xd6, 0xbd, 0x22, 0xfe, 0x49, 0xbf, 0xf3, 0x5f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xef, 0xeb, + 0x13, 0x0f, 0x49, 0x0c, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -779,7 +779,7 @@ type QueryClient interface { ChainState(ctx context.Context, in *QueryGetChainStateRequest, opts ...grpc.CallOption) (*QueryGetChainStateResponse, error) Prove(ctx context.Context, in *QueryProveRequest, opts ...grpc.CallOption) (*QueryProveResponse, error) HeaderSupportedChains(ctx context.Context, in *QueryHeaderSupportedChainsRequest, opts ...grpc.CallOption) (*QueryHeaderSupportedChainsResponse, error) - HeaderEnabledChains(ctx context.Context, in *HeaderEnabledChainsRequest, opts ...grpc.CallOption) (*HeaderEnabledChainsResponse, error) + HeaderEnabledChains(ctx context.Context, in *QueryHeaderEnabledChainsRequest, opts ...grpc.CallOption) (*QueryHeaderEnabledChainsResponse, error) } type queryClient struct { @@ -844,8 +844,8 @@ func (c *queryClient) HeaderSupportedChains(ctx context.Context, in *QueryHeader return out, nil } -func (c *queryClient) HeaderEnabledChains(ctx context.Context, in *HeaderEnabledChainsRequest, opts ...grpc.CallOption) (*HeaderEnabledChainsResponse, error) { - out := new(HeaderEnabledChainsResponse) +func (c *queryClient) HeaderEnabledChains(ctx context.Context, in *QueryHeaderEnabledChainsRequest, opts ...grpc.CallOption) (*QueryHeaderEnabledChainsResponse, error) { + out := new(QueryHeaderEnabledChainsResponse) err := c.cc.Invoke(ctx, "/zetachain.zetacore.lightclient.Query/HeaderEnabledChains", in, out, opts...) if err != nil { return nil, err @@ -861,7 +861,7 @@ type QueryServer interface { ChainState(context.Context, *QueryGetChainStateRequest) (*QueryGetChainStateResponse, error) Prove(context.Context, *QueryProveRequest) (*QueryProveResponse, error) HeaderSupportedChains(context.Context, *QueryHeaderSupportedChainsRequest) (*QueryHeaderSupportedChainsResponse, error) - HeaderEnabledChains(context.Context, *HeaderEnabledChainsRequest) (*HeaderEnabledChainsResponse, error) + HeaderEnabledChains(context.Context, *QueryHeaderEnabledChainsRequest) (*QueryHeaderEnabledChainsResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -886,7 +886,7 @@ func (*UnimplementedQueryServer) Prove(ctx context.Context, req *QueryProveReque func (*UnimplementedQueryServer) HeaderSupportedChains(ctx context.Context, req *QueryHeaderSupportedChainsRequest) (*QueryHeaderSupportedChainsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method HeaderSupportedChains not implemented") } -func (*UnimplementedQueryServer) HeaderEnabledChains(ctx context.Context, req *HeaderEnabledChainsRequest) (*HeaderEnabledChainsResponse, error) { +func (*UnimplementedQueryServer) HeaderEnabledChains(ctx context.Context, req *QueryHeaderEnabledChainsRequest) (*QueryHeaderEnabledChainsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method HeaderEnabledChains not implemented") } @@ -1003,7 +1003,7 @@ func _Query_HeaderSupportedChains_Handler(srv interface{}, ctx context.Context, } func _Query_HeaderEnabledChains_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(HeaderEnabledChainsRequest) + in := new(QueryHeaderEnabledChainsRequest) if err := dec(in); err != nil { return nil, err } @@ -1015,7 +1015,7 @@ func _Query_HeaderEnabledChains_Handler(srv interface{}, ctx context.Context, de FullMethod: "/zetachain.zetacore.lightclient.Query/HeaderEnabledChains", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).HeaderEnabledChains(ctx, req.(*HeaderEnabledChainsRequest)) + return srv.(QueryServer).HeaderEnabledChains(ctx, req.(*QueryHeaderEnabledChainsRequest)) } return interceptor(ctx, in, info, handler) } @@ -1505,7 +1505,7 @@ func (m *QueryHeaderSupportedChainsResponse) MarshalToSizedBuffer(dAtA []byte) ( return len(dAtA) - i, nil } -func (m *HeaderEnabledChainsRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryHeaderEnabledChainsRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1515,12 +1515,12 @@ func (m *HeaderEnabledChainsRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *HeaderEnabledChainsRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryHeaderEnabledChainsRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *HeaderEnabledChainsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryHeaderEnabledChainsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1528,7 +1528,7 @@ func (m *HeaderEnabledChainsRequest) MarshalToSizedBuffer(dAtA []byte) (int, err return len(dAtA) - i, nil } -func (m *HeaderEnabledChainsResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryHeaderEnabledChainsResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1538,12 +1538,12 @@ func (m *HeaderEnabledChainsResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *HeaderEnabledChainsResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryHeaderEnabledChainsResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *HeaderEnabledChainsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryHeaderEnabledChainsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1754,7 +1754,7 @@ func (m *QueryHeaderSupportedChainsResponse) Size() (n int) { return n } -func (m *HeaderEnabledChainsRequest) Size() (n int) { +func (m *QueryHeaderEnabledChainsRequest) Size() (n int) { if m == nil { return 0 } @@ -1763,7 +1763,7 @@ func (m *HeaderEnabledChainsRequest) Size() (n int) { return n } -func (m *HeaderEnabledChainsResponse) Size() (n int) { +func (m *QueryHeaderEnabledChainsResponse) Size() (n int) { if m == nil { return 0 } @@ -2913,7 +2913,7 @@ func (m *QueryHeaderSupportedChainsResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *HeaderEnabledChainsRequest) Unmarshal(dAtA []byte) error { +func (m *QueryHeaderEnabledChainsRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2936,10 +2936,10 @@ func (m *HeaderEnabledChainsRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: HeaderEnabledChainsRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryHeaderEnabledChainsRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: HeaderEnabledChainsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryHeaderEnabledChainsRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: @@ -2963,7 +2963,7 @@ func (m *HeaderEnabledChainsRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *HeaderEnabledChainsResponse) Unmarshal(dAtA []byte) error { +func (m *QueryHeaderEnabledChainsResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2986,10 +2986,10 @@ func (m *HeaderEnabledChainsResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: HeaderEnabledChainsResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryHeaderEnabledChainsResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: HeaderEnabledChainsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryHeaderEnabledChainsResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: diff --git a/x/lightclient/types/query.pb.gw.go b/x/lightclient/types/query.pb.gw.go index 75c595fea1..7b359abf33 100644 --- a/x/lightclient/types/query.pb.gw.go +++ b/x/lightclient/types/query.pb.gw.go @@ -268,7 +268,7 @@ func local_request_Query_HeaderSupportedChains_0(ctx context.Context, marshaler } func request_Query_HeaderEnabledChains_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq HeaderEnabledChainsRequest + var protoReq QueryHeaderEnabledChainsRequest var metadata runtime.ServerMetadata msg, err := client.HeaderEnabledChains(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) @@ -277,7 +277,7 @@ func request_Query_HeaderEnabledChains_0(ctx context.Context, marshaler runtime. } func local_request_Query_HeaderEnabledChains_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq HeaderEnabledChainsRequest + var protoReq QueryHeaderEnabledChainsRequest var metadata runtime.ServerMetadata msg, err := server.HeaderEnabledChains(ctx, &protoReq) diff --git a/zetaclient/zetabridge/query.go b/zetaclient/zetabridge/query.go index 37283dde2d..d8ae3f9340 100644 --- a/zetaclient/zetabridge/query.go +++ b/zetaclient/zetabridge/query.go @@ -35,7 +35,7 @@ func (b *ZetaCoreBridge) GetCrosschainFlags() (observertypes.CrosschainFlags, er func (b *ZetaCoreBridge) GetBlockHeaderEnabledChains() ([]lightclienttypes.HeaderSupportedChain, error) { client := lightclienttypes.NewQueryClient(b.grpcConn) - resp, err := client.HeaderEnabledChains(context.Background(), &lightclienttypes.HeaderEnabledChainsRequest{}) + resp, err := client.HeaderEnabledChains(context.Background(), &lightclienttypes.QueryHeaderEnabledChainsRequest{}) if err != nil { return []lightclienttypes.HeaderSupportedChain{}, err } diff --git a/zetaclient/zetabridge/query_test.go b/zetaclient/zetabridge/query_test.go index 8bb6017833..d05ca5bbe5 100644 --- a/zetaclient/zetabridge/query_test.go +++ b/zetaclient/zetabridge/query_test.go @@ -103,7 +103,7 @@ func TestZetaCoreBridge_GetCrosschainFlags(t *testing.T) { } func TestZetaCoreBridge_HeaderEnabledChains(t *testing.T) { - expectedOutput := lightclienttypes.QueryHeaderSupportedChainsResponse{HeaderSupportedChains: []lightclienttypes.HeaderSupportedChain{ + expectedOutput := lightclienttypes.QueryHeaderEnabledChainsResponse{HeaderEnabledChains: []lightclienttypes.HeaderSupportedChain{ { ChainId: chains.EthChain.ChainId, Enabled: true, @@ -113,8 +113,8 @@ func TestZetaCoreBridge_HeaderEnabledChains(t *testing.T) { Enabled: true, }, }} - input := lightclienttypes.QueryHeaderSupportedChainsRequest{} - method := "/zetachain.zetacore.lightclient.Query/HeaderSupportedChains" + input := lightclienttypes.QueryHeaderEnabledChainsRequest{} + method := "/zetachain.zetacore.lightclient.Query/HeaderEnabledChains" server := setupMockServer(t, lightclienttypes.RegisterQueryServer, method, input, expectedOutput) server.Serve() defer closeMockServer(t, server) @@ -124,7 +124,7 @@ func TestZetaCoreBridge_HeaderEnabledChains(t *testing.T) { resp, err := zetabridge.GetBlockHeaderEnabledChains() require.NoError(t, err) - require.Equal(t, expectedOutput.HeaderSupportedChains, resp) + require.Equal(t, expectedOutput.HeaderEnabledChains, resp) } func TestZetaCoreBridge_GetChainParamsForChainID(t *testing.T) { diff --git a/zetaclient/zetabridge/tx_test.go b/zetaclient/zetabridge/tx_test.go index 8cc6b7b449..d371c578ed 100644 --- a/zetaclient/zetabridge/tx_test.go +++ b/zetaclient/zetabridge/tx_test.go @@ -303,11 +303,11 @@ func TestZetaCoreBridge_UpdateZetaCoreContext(t *testing.T) { BlockHeaderVerificationFlags: nil, }}) - method = "/zetachain.zetacore.lightclient.Query/HeaderSupportedChains" + method = "/zetachain.zetacore.lightclient.Query/HeaderEnabledChains" s.ExpectUnary(method). UnlimitedTimes(). - WithPayload(lightclienttypes.QueryHeaderSupportedChainsRequest{}). - Return(lightclienttypes.QueryHeaderSupportedChainsResponse{HeaderSupportedChains: []lightclienttypes.HeaderSupportedChain{ + WithPayload(lightclienttypes.QueryHeaderEnabledChainsRequest{}). + Return(lightclienttypes.QueryHeaderEnabledChainsResponse{HeaderEnabledChains: []lightclienttypes.HeaderSupportedChain{ { ChainId: chains.EthChain.ChainId, Enabled: true, From 65b64d0c86c6f229d786eba5d9415ac78d665bfd Mon Sep 17 00:00:00 2001 From: Tanmay Date: Wed, 1 May 2024 01:44:59 -0400 Subject: [PATCH 28/31] generate files 4 --- docs/openapi/openapi.swagger.yaml | 18 ++++++++-------- typescript/lightclient/query_pb.d.ts | 32 ++++++++++++++-------------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/docs/openapi/openapi.swagger.yaml b/docs/openapi/openapi.swagger.yaml index afdcafafe7..e63668d66e 100644 --- a/docs/openapi/openapi.swagger.yaml +++ b/docs/openapi/openapi.swagger.yaml @@ -27615,7 +27615,7 @@ paths: "200": description: A successful response. schema: - $ref: '#/definitions/lightclientHeaderEnabledChainsResponse' + $ref: '#/definitions/lightclientQueryHeaderEnabledChainsResponse' default: description: An unexpected error response. schema: @@ -54318,14 +54318,6 @@ definitions: type: string format: byte title: ChainState defines the overall state of the block headers for a given chain - lightclientHeaderEnabledChainsResponse: - type: object - properties: - header_enabled_chains: - type: array - items: - type: object - $ref: '#/definitions/lightclientHeaderSupportedChain' lightclientHeaderSupportedChain: type: object properties: @@ -54369,6 +54361,14 @@ definitions: properties: chain_state: $ref: '#/definitions/lightclientChainState' + lightclientQueryHeaderEnabledChainsResponse: + type: object + properties: + header_enabled_chains: + type: array + items: + type: object + $ref: '#/definitions/lightclientHeaderSupportedChain' lightclientQueryHeaderSupportedChainsResponse: type: object properties: diff --git a/typescript/lightclient/query_pb.d.ts b/typescript/lightclient/query_pb.d.ts index 944e6bcfd8..d4e2f1f0aa 100644 --- a/typescript/lightclient/query_pb.d.ts +++ b/typescript/lightclient/query_pb.d.ts @@ -324,45 +324,45 @@ export declare class QueryHeaderSupportedChainsResponse extends Message { - constructor(data?: PartialMessage); +export declare class QueryHeaderEnabledChainsRequest extends Message { + constructor(data?: PartialMessage); static readonly runtime: typeof proto3; - static readonly typeName = "zetachain.zetacore.lightclient.HeaderEnabledChainsRequest"; + static readonly typeName = "zetachain.zetacore.lightclient.QueryHeaderEnabledChainsRequest"; static readonly fields: FieldList; - static fromBinary(bytes: Uint8Array, options?: Partial): HeaderEnabledChainsRequest; + static fromBinary(bytes: Uint8Array, options?: Partial): QueryHeaderEnabledChainsRequest; - static fromJson(jsonValue: JsonValue, options?: Partial): HeaderEnabledChainsRequest; + static fromJson(jsonValue: JsonValue, options?: Partial): QueryHeaderEnabledChainsRequest; - static fromJsonString(jsonString: string, options?: Partial): HeaderEnabledChainsRequest; + static fromJsonString(jsonString: string, options?: Partial): QueryHeaderEnabledChainsRequest; - static equals(a: HeaderEnabledChainsRequest | PlainMessage | undefined, b: HeaderEnabledChainsRequest | PlainMessage | undefined): boolean; + static equals(a: QueryHeaderEnabledChainsRequest | PlainMessage | undefined, b: QueryHeaderEnabledChainsRequest | PlainMessage | undefined): boolean; } /** - * @generated from message zetachain.zetacore.lightclient.HeaderEnabledChainsResponse + * @generated from message zetachain.zetacore.lightclient.QueryHeaderEnabledChainsResponse */ -export declare class HeaderEnabledChainsResponse extends Message { +export declare class QueryHeaderEnabledChainsResponse extends Message { /** * @generated from field: repeated zetachain.zetacore.lightclient.HeaderSupportedChain header_enabled_chains = 1; */ headerEnabledChains: HeaderSupportedChain[]; - constructor(data?: PartialMessage); + constructor(data?: PartialMessage); static readonly runtime: typeof proto3; - static readonly typeName = "zetachain.zetacore.lightclient.HeaderEnabledChainsResponse"; + static readonly typeName = "zetachain.zetacore.lightclient.QueryHeaderEnabledChainsResponse"; static readonly fields: FieldList; - static fromBinary(bytes: Uint8Array, options?: Partial): HeaderEnabledChainsResponse; + static fromBinary(bytes: Uint8Array, options?: Partial): QueryHeaderEnabledChainsResponse; - static fromJson(jsonValue: JsonValue, options?: Partial): HeaderEnabledChainsResponse; + static fromJson(jsonValue: JsonValue, options?: Partial): QueryHeaderEnabledChainsResponse; - static fromJsonString(jsonString: string, options?: Partial): HeaderEnabledChainsResponse; + static fromJsonString(jsonString: string, options?: Partial): QueryHeaderEnabledChainsResponse; - static equals(a: HeaderEnabledChainsResponse | PlainMessage | undefined, b: HeaderEnabledChainsResponse | PlainMessage | undefined): boolean; + static equals(a: QueryHeaderEnabledChainsResponse | PlainMessage | undefined, b: QueryHeaderEnabledChainsResponse | PlainMessage | undefined): boolean; } From 4e8daa9930ed46af6b0fd7c1b380959d5dc9956b Mon Sep 17 00:00:00 2001 From: Tanmay Date: Fri, 3 May 2024 10:21:25 -0400 Subject: [PATCH 29/31] Update pkg/chains/chain.go Co-authored-by: Lucas Bertrand --- pkg/chains/chain.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/chains/chain.go b/pkg/chains/chain.go index 1306e991fe..0b1c9edcc8 100644 --- a/pkg/chains/chain.go +++ b/pkg/chains/chain.go @@ -101,7 +101,7 @@ func IsZetaChain(chainID int64) bool { return ChainIDInChainList(chainID, ChainListByNetwork(Network_zeta)) } -// IsHeaderSupportedChain returns true if the chain is supports block header-based verification +// IsHeaderSupportedChain returns true if the chain's consensus supports block header-based verification func IsHeaderSupportedChain(chainID int64) bool { return ChainIDInChainList(chainID, ChainListForHeaderSupport()) } From 1e5d62c979b52915ce73e5ef819d5a479ab8cd77 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Fri, 3 May 2024 11:53:51 -0400 Subject: [PATCH 30/31] add check for duplicated chain id --- .../keeper/block_header_verification_test.go | 1 + .../grpc_query_header_enabled_chains.go | 10 +++++-- .../grpc_query_header_enabled_chains_test.go | 30 +++++++++++++++++++ ...erver_disable_block_header_verification.go | 5 +++- ...server_enable_block_header_verification.go | 5 +++- .../types/block_header_verification.go | 13 ++++++++ .../types/block_header_verification_test.go | 13 ++++++++ x/lightclient/types/genesis.go | 5 ++++ x/lightclient/types/genesis_test.go | 9 ++++++ 9 files changed, 87 insertions(+), 4 deletions(-) diff --git a/x/lightclient/keeper/block_header_verification_test.go b/x/lightclient/keeper/block_header_verification_test.go index 2c4ed5900b..0a5e29eb6a 100644 --- a/x/lightclient/keeper/block_header_verification_test.go +++ b/x/lightclient/keeper/block_header_verification_test.go @@ -31,6 +31,7 @@ func TestKeeper_GetBlockHeaderVerification(t *testing.T) { blockHeaderVerification, found := k.GetBlockHeaderVerification(ctx) require.False(t, found) require.Len(t, blockHeaderVerification.HeaderSupportedChains, 0) + require.Equal(t, types.BlockHeaderVerification{}, blockHeaderVerification) }) } diff --git a/x/lightclient/keeper/grpc_query_header_enabled_chains.go b/x/lightclient/keeper/grpc_query_header_enabled_chains.go index 70a447f6e8..39d5886b4c 100644 --- a/x/lightclient/keeper/grpc_query_header_enabled_chains.go +++ b/x/lightclient/keeper/grpc_query_header_enabled_chains.go @@ -18,7 +18,10 @@ func (k Keeper) HeaderSupportedChains(c context.Context, req *types.QueryHeaderS } ctx := sdk.UnwrapSDKContext(c) - val, _ := k.GetBlockHeaderVerification(ctx) + val, found := k.GetBlockHeaderVerification(ctx) + if !found { + return &types.QueryHeaderSupportedChainsResponse{}, types.ErrBlockHeaderVerificationDisabled.Wrapf("proof verification is disabled for all chains") + } return &types.QueryHeaderSupportedChainsResponse{HeaderSupportedChains: val.GetHeaderSupportedChainsList()}, nil } @@ -31,7 +34,10 @@ func (k Keeper) HeaderEnabledChains(c context.Context, req *types.QueryHeaderEna } ctx := sdk.UnwrapSDKContext(c) - val, _ := k.GetBlockHeaderVerification(ctx) + val, found := k.GetBlockHeaderVerification(ctx) + if !found { + return &types.QueryHeaderEnabledChainsResponse{}, types.ErrBlockHeaderVerificationDisabled.Wrapf("proof verification is disabled for all chains") + } return &types.QueryHeaderEnabledChainsResponse{HeaderEnabledChains: val.GetHeaderEnabledChains()}, nil diff --git a/x/lightclient/keeper/grpc_query_header_enabled_chains_test.go b/x/lightclient/keeper/grpc_query_header_enabled_chains_test.go index 8b13ba1b95..3f9f0e30a0 100644 --- a/x/lightclient/keeper/grpc_query_header_enabled_chains_test.go +++ b/x/lightclient/keeper/grpc_query_header_enabled_chains_test.go @@ -39,3 +39,33 @@ func TestKeeper_HeaderSupportedChains(t *testing.T) { require.Equal(t, bhv.HeaderSupportedChains, res.HeaderSupportedChains) }) } + +func TestKeeper_HeaderEnabledChains(t *testing.T) { + t.Run("should error if req is nil", func(t *testing.T) { + k, ctx, _, _ := keepertest.LightclientKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + + res, err := k.HeaderEnabledChains(wctx, nil) + require.Nil(t, res) + require.Error(t, err) + }) + + t.Run("should return empty set if not found", func(t *testing.T) { + k, ctx, _, _ := keepertest.LightclientKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + + res, _ := k.HeaderEnabledChains(wctx, &types.QueryHeaderEnabledChainsRequest{}) + require.Len(t, res.HeaderEnabledChains, 0) + }) + + t.Run("should return if block header state is found", func(t *testing.T) { + k, ctx, _, _ := keepertest.LightclientKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + bhv := sample.BlockHeaderVerification() + k.SetBlockHeaderVerification(ctx, bhv) + + res, err := k.HeaderEnabledChains(wctx, &types.QueryHeaderEnabledChainsRequest{}) + require.NoError(t, err) + require.Equal(t, bhv.GetHeaderEnabledChains(), res.HeaderEnabledChains) + }) +} diff --git a/x/lightclient/keeper/msg_server_disable_block_header_verification.go b/x/lightclient/keeper/msg_server_disable_block_header_verification.go index b7e97c7290..c6f33d133a 100644 --- a/x/lightclient/keeper/msg_server_disable_block_header_verification.go +++ b/x/lightclient/keeper/msg_server_disable_block_header_verification.go @@ -18,7 +18,10 @@ func (k msgServer) DisableHeaderVerification(goCtx context.Context, msg *types.M return nil, authoritytypes.ErrUnauthorized } - bhv, _ := k.GetBlockHeaderVerification(ctx) + bhv, found := k.GetBlockHeaderVerification(ctx) + if !found { + bhv = types.BlockHeaderVerification{} + } for _, chainID := range msg.ChainIdList { bhv.DisableChain(chainID) diff --git a/x/lightclient/keeper/msg_server_enable_block_header_verification.go b/x/lightclient/keeper/msg_server_enable_block_header_verification.go index ae78f803d0..a4653cd4b5 100644 --- a/x/lightclient/keeper/msg_server_enable_block_header_verification.go +++ b/x/lightclient/keeper/msg_server_enable_block_header_verification.go @@ -21,7 +21,10 @@ func (k msgServer) EnableHeaderVerification(goCtx context.Context, msg *types.Ms return nil, authoritytypes.ErrUnauthorized } - bhv, _ := k.GetBlockHeaderVerification(ctx) + bhv, found := k.GetBlockHeaderVerification(ctx) + if !found { + bhv = types.BlockHeaderVerification{} + } for _, chainID := range msg.ChainIdList { bhv.EnableChain(chainID) diff --git a/x/lightclient/types/block_header_verification.go b/x/lightclient/types/block_header_verification.go index 47f0e855ee..351a971d1b 100644 --- a/x/lightclient/types/block_header_verification.go +++ b/x/lightclient/types/block_header_verification.go @@ -1,5 +1,18 @@ package types +import "fmt" + +func (b *BlockHeaderVerification) Validate() error { + detectDuplicates := make(map[int64]bool) + for _, chain := range b.HeaderSupportedChains { + if _, ok := detectDuplicates[chain.ChainId]; ok { + return fmt.Errorf("duplicated chain id for block header verification") + } + detectDuplicates[chain.ChainId] = true + } + return nil +} + // EnableChain enables block header verification for a specific chain func (b *BlockHeaderVerification) EnableChain(chainID int64) { found := false diff --git a/x/lightclient/types/block_header_verification_test.go b/x/lightclient/types/block_header_verification_test.go index 48dcc0d22f..ec5d7cd4cc 100644 --- a/x/lightclient/types/block_header_verification_test.go +++ b/x/lightclient/types/block_header_verification_test.go @@ -9,6 +9,19 @@ import ( "github.com/zeta-chain/zetacore/x/lightclient/types" ) +func TestBlockHeaderVerification_Validate(t *testing.T) { + t.Run("should return nil if no duplicate chain id", func(t *testing.T) { + bhv := types.BlockHeaderVerification{ + HeaderSupportedChains: []types.HeaderSupportedChain{{ChainId: 1, Enabled: true}, {ChainId: 2, Enabled: true}}} + require.NoError(t, bhv.Validate()) + }) + + t.Run("should return error if duplicate chain id", func(t *testing.T) { + bhv := types.BlockHeaderVerification{ + HeaderSupportedChains: []types.HeaderSupportedChain{{ChainId: 1, Enabled: true}, {ChainId: 1, Enabled: true}}} + require.Error(t, bhv.Validate()) + }) +} func TestBlockHeaderVerification_EnableChain(t *testing.T) { t.Run("should enable chain if chain not present", func(t *testing.T) { bhv := sample.BlockHeaderVerification() diff --git a/x/lightclient/types/genesis.go b/x/lightclient/types/genesis.go index 74be724903..b796c678d5 100644 --- a/x/lightclient/types/genesis.go +++ b/x/lightclient/types/genesis.go @@ -34,5 +34,10 @@ func (gs GenesisState) Validate() error { ChainStateMap[elem.ChainId] = true } + err := gs.BlockHeaderVerification.Validate() + if err != nil { + return err + } + return nil } diff --git a/x/lightclient/types/genesis_test.go b/x/lightclient/types/genesis_test.go index 3e5e2cf7d7..0ccb3a11fe 100644 --- a/x/lightclient/types/genesis_test.go +++ b/x/lightclient/types/genesis_test.go @@ -63,6 +63,15 @@ func TestGenesisState_Validate(t *testing.T) { }, valid: false, }, + { + desc: "invalid block header verification", + genState: &types.GenesisState{ + BlockHeaderVerification: types.BlockHeaderVerification{ + HeaderSupportedChains: []types.HeaderSupportedChain{{ChainId: 1, Enabled: true}, {ChainId: 1, Enabled: true}}, + }, + }, + valid: false, + }, } { t.Run(tc.desc, func(t *testing.T) { err := tc.genState.Validate() From ae9501476640b31ee359a14ee572dc3fd3bf1e71 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Tue, 7 May 2024 17:12:37 -0400 Subject: [PATCH 31/31] fix comments and identifier names --- docs/openapi/openapi.swagger.yaml | 2 +- proto/lightclient/block_header_verification.proto | 2 +- typescript/lightclient/block_header_verification_pb.d.ts | 2 +- x/lightclient/types/block_header_verification.pb.go | 2 +- zetaclient/core_context/zeta_core_context_test.go | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/openapi/openapi.swagger.yaml b/docs/openapi/openapi.swagger.yaml index e63668d66e..99076d35d2 100644 --- a/docs/openapi/openapi.swagger.yaml +++ b/docs/openapi/openapi.swagger.yaml @@ -54326,7 +54326,7 @@ definitions: format: int64 enabled: type: boolean - title: VerificationFlags is a structure containing information of weather a chain is enabled or not for block header verification + title: HeaderSupportedChain is a structure containing information of weather a chain is enabled or not for block header verification lightclientMsgDisableHeaderVerificationResponse: type: object lightclientMsgEnableHeaderVerificationResponse: diff --git a/proto/lightclient/block_header_verification.proto b/proto/lightclient/block_header_verification.proto index c1f0410fa7..45151c1268 100644 --- a/proto/lightclient/block_header_verification.proto +++ b/proto/lightclient/block_header_verification.proto @@ -5,7 +5,7 @@ import "gogoproto/gogo.proto"; option go_package = "github.com/zeta-chain/zetacore/x/lightclient/types"; -// VerificationFlags is a structure containing information of weather a chain is enabled or not for block header verification +// HeaderSupportedChain is a structure containing information of weather a chain is enabled or not for block header verification message HeaderSupportedChain { int64 chain_id = 1; bool enabled = 2; diff --git a/typescript/lightclient/block_header_verification_pb.d.ts b/typescript/lightclient/block_header_verification_pb.d.ts index d40170bb61..24c14a2733 100644 --- a/typescript/lightclient/block_header_verification_pb.d.ts +++ b/typescript/lightclient/block_header_verification_pb.d.ts @@ -7,7 +7,7 @@ import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialM import { Message, proto3 } from "@bufbuild/protobuf"; /** - * VerificationFlags is a structure containing information of weather a chain is enabled or not for block header verification + * HeaderSupportedChain is a structure containing information of weather a chain is enabled or not for block header verification * * @generated from message zetachain.zetacore.lightclient.HeaderSupportedChain */ diff --git a/x/lightclient/types/block_header_verification.pb.go b/x/lightclient/types/block_header_verification.pb.go index 9cb6435377..94c935db22 100644 --- a/x/lightclient/types/block_header_verification.pb.go +++ b/x/lightclient/types/block_header_verification.pb.go @@ -24,7 +24,7 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// VerificationFlags is a structure containing information of weather a chain is enabled or not for block header verification +// HeaderSupportedChain is a structure containing information of weather a chain is enabled or not for block header verification type HeaderSupportedChain struct { ChainId int64 `protobuf:"varint,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` Enabled bool `protobuf:"varint,2,opt,name=enabled,proto3" json:"enabled,omitempty"` diff --git a/zetaclient/core_context/zeta_core_context_test.go b/zetaclient/core_context/zeta_core_context_test.go index deb28aab14..03f4e6defd 100644 --- a/zetaclient/core_context/zeta_core_context_test.go +++ b/zetaclient/core_context/zeta_core_context_test.go @@ -28,7 +28,7 @@ func getTestCoreContext( evmChain chains.Chain, evmChainParams *observertypes.ChainParams, ccFlags observertypes.CrosschainFlags, - verificationFlags []lightclienttypes.HeaderSupportedChain, + headerSupportedChains []lightclienttypes.HeaderSupportedChain, ) *corecontext.ZetaCoreContext { // create config cfg := config.NewConfig() @@ -48,7 +48,7 @@ func getTestCoreContext( nil, "", ccFlags, - verificationFlags, + headerSupportedChains, true, zerolog.Logger{}, )