From cab349348a611b2d4a9e7bc70b41c747591a7cec Mon Sep 17 00:00:00 2001 From: lumtis Date: Fri, 24 May 2024 08:25:19 +0200 Subject: [PATCH 01/22] add optimism and base --- pkg/chains/chains.go | 111 +++++++-- pkg/chains/chains.pb.go | 233 ++++++++++-------- .../zetacore/pkg/chains/chains.proto | 55 +++-- 3 files changed, 263 insertions(+), 136 deletions(-) diff --git a/pkg/chains/chains.go b/pkg/chains/chains.go index 83c1d16bcc..0c7a542b94 100644 --- a/pkg/chains/chains.go +++ b/pkg/chains/chains.go @@ -2,24 +2,12 @@ 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. -*/ - var ( + /** + * Mainnet chains + */ - // Mainnet chains + // ZetaChainMainnet is the mainnet chain for Zeta ZetaChainMainnet = Chain{ ChainName: ChainName_zeta_mainnet, ChainId: 7000, @@ -29,6 +17,8 @@ var ( Consensus: Consensus_tendermint, IsExternal: false, } + + // EthChain is Ethereum mainnet EthChain = Chain{ ChainName: ChainName_eth_mainnet, ChainId: 1, @@ -38,6 +28,8 @@ var ( Consensus: Consensus_ethereum, IsExternal: true, } + + // BscMainnetChain is Binance Smart Chain mainnet BscMainnetChain = Chain{ ChainName: ChainName_bsc_mainnet, ChainId: 56, @@ -47,6 +39,8 @@ var ( Consensus: Consensus_ethereum, IsExternal: true, } + + // BtcMainnetChain is Bitcoin mainnet BtcMainnetChain = Chain{ ChainName: ChainName_btc_mainnet, ChainId: 8332, @@ -56,6 +50,8 @@ var ( Consensus: Consensus_bitcoin, IsExternal: true, } + + // PolygonChain is Polygon mainnet PolygonChain = Chain{ ChainName: ChainName_polygon_mainnet, ChainId: 137, @@ -65,7 +61,34 @@ var ( Consensus: Consensus_ethereum, IsExternal: true, } - // Testnet chains + + // OptimismMainnet is Optimism mainnet + OptimismMainnet = Chain{ + ChainName: ChainName_optimism_mainnet, + ChainId: 10, + Network: Network_optimism, + NetworkType: NetworkType_mainnet, + Vm: Vm_evm, + Consensus: Consensus_op_stack, + IsExternal: true, + } + + // BaseMainnet is Base mainnet + BaseMainnet = Chain{ + ChainName: ChainName_base_mainnet, + ChainId: 8453, + Network: Network_base, + NetworkType: NetworkType_mainnet, + Vm: Vm_evm, + Consensus: Consensus_op_stack, + IsExternal: true, + } + + /** + * Testnet chains + */ + + // ZetaTestnetChain is the testnet chain for Zeta ZetaTestnetChain = Chain{ ChainName: ChainName_zeta_testnet, ChainId: 7001, @@ -75,6 +98,8 @@ var ( Consensus: Consensus_tendermint, IsExternal: false, } + + // SepoliaChain is Ethereum sepolia testnet SepoliaChain = Chain{ ChainName: ChainName_sepolia_testnet, ChainId: 11155111, @@ -84,6 +109,8 @@ var ( Consensus: Consensus_ethereum, IsExternal: true, } + + // BscTestnetChain is Binance Smart Chain testnet BscTestnetChain = Chain{ ChainName: ChainName_bsc_testnet, ChainId: 97, @@ -93,6 +120,8 @@ var ( Consensus: Consensus_ethereum, IsExternal: true, } + + // BtcTestNetChain is Bitcoin testnet3 BtcTestNetChain = Chain{ ChainName: ChainName_btc_testnet, ChainId: 18332, @@ -103,6 +132,7 @@ var ( IsExternal: true, } + // AmoyChain is Polygon amoy testnet AmoyChain = Chain{ ChainName: ChainName_amoy_testnet, ChainId: 80002, @@ -112,7 +142,35 @@ var ( Consensus: Consensus_ethereum, IsExternal: true, } - // Devnet chains + + // OptimismSepolia is Optimism sepolia testnet + OptimismSepolia = Chain{ + ChainName: ChainName_optimism_sepolia, + ChainId: 11155420, + Network: Network_optimism, + NetworkType: NetworkType_testnet, + Vm: Vm_evm, + Consensus: Consensus_op_stack, + IsExternal: true, + } + + // BaseSepolia is Base sepolia testnet + BaseSepolia = Chain{ + ChainName: ChainName_base_sepolia, + ChainId: 84532, + Network: Network_base, + NetworkType: NetworkType_testnet, + Vm: Vm_evm, + Consensus: Consensus_op_stack, + IsExternal: true, + } + + /** + * Devnet chains + */ + + // ZetaMocknetChain is the mocknet chain for Zeta + // used as live testing environment ZetaMocknetChain = Chain{ ChainName: ChainName_zeta_mainnet, ChainId: 70000, @@ -122,7 +180,12 @@ var ( Consensus: Consensus_tendermint, IsExternal: false, } - // Privnet chains + + /** + * Privnet chains + */ + + // ZetaPrivnetChain is the privnet chain for Zeta (localnet) ZetaPrivnetChain = Chain{ ChainName: ChainName_zeta_mainnet, ChainId: 101, @@ -133,6 +196,7 @@ var ( IsExternal: false, } + // BtcRegtestChain is Bitcoin regtest (localnet) BtcRegtestChain = Chain{ ChainName: ChainName_btc_regtest, ChainId: 18444, @@ -143,6 +207,7 @@ var ( IsExternal: true, } + // GoerliLocalnetChain is Ethereum local goerli (localnet) GoerliLocalnetChain = Chain{ ChainName: ChainName_goerli_localnet, ChainId: 1337, @@ -153,7 +218,11 @@ var ( IsExternal: true, } - // Deprecated testnet chains + /** + * Deprecated chains + */ + + // GoerliChain is Ethereum goerli testnet (deprecated for sepolia) GoerliChain = Chain{ ChainName: ChainName_goerli_testnet, ChainId: 5, @@ -163,6 +232,8 @@ var ( Consensus: Consensus_ethereum, IsExternal: true, } + + // MumbaiChain is Polygon mumbai testnet (deprecated for amoy) MumbaiChain = Chain{ ChainName: ChainName_mumbai_testnet, ChainId: 80001, diff --git a/pkg/chains/chains.pb.go b/pkg/chains/chains.pb.go index c1172e8bf7..1153208c6d 100644 --- a/pkg/chains/chains.pb.go +++ b/pkg/chains/chains.pb.go @@ -23,9 +23,13 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +// ReceiveStatus represents the status of an outbound +// TODO: Rename and move +// https://github.com/zeta-chain/node/issues/2257 type ReceiveStatus int32 const ( + // Created is used for inbounds ReceiveStatus_created ReceiveStatus = 0 ReceiveStatus_success ReceiveStatus = 1 ReceiveStatus_failed ReceiveStatus = 2 @@ -55,23 +59,25 @@ func (ReceiveStatus) EnumDescriptor() ([]byte, []int) { type ChainName int32 const ( - ChainName_empty ChainName = 0 - ChainName_eth_mainnet ChainName = 1 - ChainName_zeta_mainnet ChainName = 2 - ChainName_btc_mainnet ChainName = 3 - ChainName_polygon_mainnet ChainName = 4 - ChainName_bsc_mainnet ChainName = 5 - ChainName_goerli_testnet ChainName = 6 - ChainName_mumbai_testnet ChainName = 7 - ChainName_ganache_testnet ChainName = 8 - ChainName_baobab_testnet ChainName = 9 - ChainName_bsc_testnet ChainName = 10 - ChainName_zeta_testnet ChainName = 11 - ChainName_btc_testnet ChainName = 12 - ChainName_sepolia_testnet ChainName = 13 - ChainName_goerli_localnet ChainName = 14 - ChainName_btc_regtest ChainName = 15 - ChainName_amoy_testnet ChainName = 16 + ChainName_empty ChainName = 0 + ChainName_eth_mainnet ChainName = 1 + ChainName_zeta_mainnet ChainName = 2 + ChainName_btc_mainnet ChainName = 3 + ChainName_polygon_mainnet ChainName = 4 + ChainName_bsc_mainnet ChainName = 5 + ChainName_goerli_testnet ChainName = 6 + ChainName_mumbai_testnet ChainName = 7 + ChainName_bsc_testnet ChainName = 10 + ChainName_zeta_testnet ChainName = 11 + ChainName_btc_testnet ChainName = 12 + ChainName_sepolia_testnet ChainName = 13 + ChainName_goerli_localnet ChainName = 14 + ChainName_btc_regtest ChainName = 15 + ChainName_amoy_testnet ChainName = 16 + ChainName_optimism_mainnet ChainName = 17 + ChainName_optimism_sepolia ChainName = 18 + ChainName_base_mainnet ChainName = 19 + ChainName_base_sepolia ChainName = 20 ) var ChainName_name = map[int32]string{ @@ -83,8 +89,6 @@ var ChainName_name = map[int32]string{ 5: "bsc_mainnet", 6: "goerli_testnet", 7: "mumbai_testnet", - 8: "ganache_testnet", - 9: "baobab_testnet", 10: "bsc_testnet", 11: "zeta_testnet", 12: "btc_testnet", @@ -92,26 +96,32 @@ var ChainName_name = map[int32]string{ 14: "goerli_localnet", 15: "btc_regtest", 16: "amoy_testnet", + 17: "optimism_mainnet", + 18: "optimism_sepolia", + 19: "base_mainnet", + 20: "base_sepolia", } var ChainName_value = map[string]int32{ - "empty": 0, - "eth_mainnet": 1, - "zeta_mainnet": 2, - "btc_mainnet": 3, - "polygon_mainnet": 4, - "bsc_mainnet": 5, - "goerli_testnet": 6, - "mumbai_testnet": 7, - "ganache_testnet": 8, - "baobab_testnet": 9, - "bsc_testnet": 10, - "zeta_testnet": 11, - "btc_testnet": 12, - "sepolia_testnet": 13, - "goerli_localnet": 14, - "btc_regtest": 15, - "amoy_testnet": 16, + "empty": 0, + "eth_mainnet": 1, + "zeta_mainnet": 2, + "btc_mainnet": 3, + "polygon_mainnet": 4, + "bsc_mainnet": 5, + "goerli_testnet": 6, + "mumbai_testnet": 7, + "bsc_testnet": 10, + "zeta_testnet": 11, + "btc_testnet": 12, + "sepolia_testnet": 13, + "goerli_localnet": 14, + "btc_regtest": 15, + "amoy_testnet": 16, + "optimism_mainnet": 17, + "optimism_sepolia": 18, + "base_mainnet": 19, + "base_sepolia": 20, } func (x ChainName) String() string { @@ -122,15 +132,19 @@ func (ChainName) EnumDescriptor() ([]byte, []int) { return fileDescriptor_236b85e7bff6130d, []int{1} } -// Network represents the network type of the chain +// Network represents the network of the chain +// there is a single instance of the network on mainnet +// then the network can have eventual testnets or devnets 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 + Network_optimism Network = 5 + Network_base Network = 6 ) var Network_name = map[int32]string{ @@ -139,14 +153,18 @@ var Network_name = map[int32]string{ 2: "btc", 3: "polygon", 4: "bsc", + 5: "optimism", + 6: "base", } 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, + "optimism": 5, + "base": 6, } func (x Network) String() string { @@ -158,6 +176,7 @@ func (Network) EnumDescriptor() ([]byte, []int) { } // NetworkType represents the network type of the chain +// Mainnet, Testnet, Privnet, Devnet type NetworkType int32 const ( @@ -217,24 +236,29 @@ func (Vm) EnumDescriptor() ([]byte, []int) { } // Consensus represents the consensus algorithm used by the chain +// this can represent the consensus of a L1 +// this can also represent the solution of a L2 type Consensus int32 const ( Consensus_ethereum Consensus = 0 Consensus_tendermint Consensus = 1 Consensus_bitcoin Consensus = 2 + Consensus_op_stack Consensus = 3 ) var Consensus_name = map[int32]string{ 0: "ethereum", 1: "tendermint", 2: "bitcoin", + 3: "op_stack", } var Consensus_value = map[string]int32{ "ethereum": 0, "tendermint": 1, "bitcoin": 2, + "op_stack": 3, } func (x Consensus) String() string { @@ -245,14 +269,23 @@ func (Consensus) EnumDescriptor() ([]byte, []int) { return fileDescriptor_236b85e7bff6130d, []int{5} } +// Chain represents static data about a blockchain network +// it is identified by a unique chain ID type Chain struct { - ChainName ChainName `protobuf:"varint,1,opt,name=chain_name,json=chainName,proto3,enum=zetachain.zetacore.pkg.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=zetachain.zetacore.pkg.chains.Network" json:"network,omitempty"` + // ChainId is the unique identifier of the chain + ChainId int64 `protobuf:"varint,2,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` + // ChainName is the name of the chain + ChainName ChainName `protobuf:"varint,1,opt,name=chain_name,json=chainName,proto3,enum=zetachain.zetacore.pkg.chains.ChainName" json:"chain_name,omitempty"` + // Network is the network of the chain + Network Network `protobuf:"varint,3,opt,name=network,proto3,enum=zetachain.zetacore.pkg.chains.Network" json:"network,omitempty"` + // NetworkType is the network type of the chain: mainnet, testnet, etc.. NetworkType NetworkType `protobuf:"varint,4,opt,name=network_type,json=networkType,proto3,enum=zetachain.zetacore.pkg.chains.NetworkType" json:"network_type,omitempty"` - Vm Vm `protobuf:"varint,5,opt,name=vm,proto3,enum=zetachain.zetacore.pkg.chains.Vm" json:"vm,omitempty"` - Consensus Consensus `protobuf:"varint,6,opt,name=consensus,proto3,enum=zetachain.zetacore.pkg.chains.Consensus" json:"consensus,omitempty"` - IsExternal bool `protobuf:"varint,7,opt,name=is_external,json=isExternal,proto3" json:"is_external,omitempty"` + // Vm is the virtual machine used in the chain + Vm Vm `protobuf:"varint,5,opt,name=vm,proto3,enum=zetachain.zetacore.pkg.chains.Vm" json:"vm,omitempty"` + // Consensus is the underlying consensus algorithm used by the chain + Consensus Consensus `protobuf:"varint,6,opt,name=consensus,proto3,enum=zetachain.zetacore.pkg.chains.Consensus" json:"consensus,omitempty"` + // IsExternal describe if the chain is ZetaChain or external + IsExternal bool `protobuf:"varint,7,opt,name=is_external,json=isExternal,proto3" json:"is_external,omitempty"` } func (m *Chain) Reset() { *m = Chain{} } @@ -288,18 +321,18 @@ func (m *Chain) XXX_DiscardUnknown() { var xxx_messageInfo_Chain proto.InternalMessageInfo -func (m *Chain) GetChainName() ChainName { +func (m *Chain) GetChainId() int64 { if m != nil { - return m.ChainName + return m.ChainId } - return ChainName_empty + return 0 } -func (m *Chain) GetChainId() int64 { +func (m *Chain) GetChainName() ChainName { if m != nil { - return m.ChainId + return m.ChainName } - return 0 + return ChainName_empty } func (m *Chain) GetNetwork() Network { @@ -352,46 +385,48 @@ func init() { } var fileDescriptor_236b85e7bff6130d = []byte{ - // 626 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x94, 0xbf, 0x6e, 0x13, 0x4f, - 0x10, 0xc7, 0x7d, 0xe7, 0xff, 0x63, 0xc7, 0x59, 0xed, 0xef, 0x57, 0x98, 0x48, 0x1c, 0x81, 0x02, - 0x19, 0x4b, 0xd8, 0x02, 0x4a, 0x28, 0x80, 0x88, 0x20, 0x0a, 0x52, 0x1c, 0x28, 0x05, 0x8d, 0xb5, - 0xb7, 0x1e, 0xce, 0xab, 0x78, 0x77, 0x4f, 0xb7, 0x6b, 0x83, 0x79, 0x0a, 0x4a, 0x1e, 0x80, 0x82, - 0x47, 0x49, 0x99, 0x92, 0x12, 0x25, 0x2f, 0x82, 0x76, 0x7d, 0x77, 0xa6, 0x81, 0xa4, 0xba, 0xd9, - 0xef, 0x7d, 0xe6, 0x3b, 0xa3, 0x9d, 0xd1, 0xc2, 0xf8, 0x0b, 0x5a, 0xc6, 0x17, 0x4c, 0xa8, 0xa9, - 0x8f, 0x74, 0x8e, 0xd3, 0xec, 0x2c, 0x9d, 0x7a, 0xc9, 0x14, 0x9f, 0x49, 0x96, 0x6b, 0xab, 0xe9, - 0xed, 0x8a, 0x9d, 0x94, 0xec, 0x24, 0x3b, 0x4b, 0x27, 0x5b, 0xe8, 0xe0, 0xff, 0x54, 0xa7, 0xda, - 0x93, 0x53, 0x17, 0x6d, 0x93, 0xee, 0x7d, 0xab, 0x43, 0xf3, 0xc8, 0x01, 0xf4, 0x35, 0x80, 0x27, - 0x67, 0x8a, 0x49, 0x1c, 0x06, 0x87, 0xc1, 0x68, 0xf0, 0x78, 0x34, 0xf9, 0xa7, 0xe7, 0xc4, 0x67, - 0x9e, 0x30, 0x89, 0x71, 0x97, 0x97, 0x21, 0xbd, 0x05, 0x9d, 0xad, 0x91, 0x98, 0x0f, 0xc3, 0xc3, - 0x60, 0x54, 0x8f, 0xdb, 0xfe, 0xfc, 0x66, 0x4e, 0x9f, 0x43, 0x5b, 0xa1, 0xfd, 0xa4, 0xf3, 0xb3, - 0x61, 0xdd, 0x17, 0xb8, 0x7f, 0x4d, 0x81, 0x93, 0x2d, 0x1d, 0x97, 0x69, 0xf4, 0x2d, 0xf4, 0x8b, - 0x70, 0x66, 0x37, 0x19, 0x0e, 0x1b, 0xde, 0x66, 0x7c, 0x33, 0x9b, 0xf7, 0x9b, 0x0c, 0xe3, 0x9e, - 0xda, 0x1d, 0xe8, 0x23, 0x08, 0xd7, 0x72, 0xd8, 0xf4, 0x26, 0x77, 0xaf, 0x31, 0x39, 0x95, 0x71, - 0xb8, 0x96, 0xf4, 0x18, 0xba, 0x5c, 0x2b, 0x83, 0xca, 0xac, 0xcc, 0xb0, 0x75, 0xb3, 0x6b, 0x2a, - 0xf9, 0x78, 0x97, 0x4a, 0xef, 0x40, 0x4f, 0x98, 0x19, 0x7e, 0xb6, 0x98, 0x2b, 0xb6, 0x1c, 0xb6, - 0x0f, 0x83, 0x51, 0x27, 0x06, 0x61, 0x5e, 0x15, 0xca, 0xf8, 0x29, 0xec, 0xc5, 0xc8, 0x51, 0xac, - 0xf1, 0x9d, 0x65, 0x76, 0x65, 0x68, 0x0f, 0xda, 0x3c, 0x47, 0x66, 0x71, 0x4e, 0x6a, 0xee, 0x60, - 0x56, 0x9c, 0xa3, 0x31, 0x24, 0xa0, 0x00, 0xad, 0x8f, 0x4c, 0x2c, 0x71, 0x4e, 0xc2, 0x83, 0xc6, - 0x8f, 0xef, 0x51, 0x30, 0x3e, 0x0f, 0xa1, 0x5b, 0x4d, 0x87, 0x76, 0xa1, 0x89, 0x32, 0xb3, 0x1b, - 0x52, 0xa3, 0xfb, 0xd0, 0x43, 0xbb, 0x98, 0x49, 0x26, 0x94, 0x42, 0x4b, 0x02, 0x4a, 0xa0, 0xef, - 0x7a, 0xae, 0x94, 0xd0, 0x21, 0x89, 0xe5, 0x95, 0x50, 0xa7, 0xff, 0xc1, 0x7e, 0xa6, 0x97, 0x9b, - 0x54, 0xab, 0x4a, 0x6c, 0x78, 0xca, 0xec, 0xa8, 0x26, 0xa5, 0x30, 0x48, 0x35, 0xe6, 0x4b, 0x31, - 0xb3, 0x68, 0xac, 0xd3, 0x5a, 0x4e, 0x93, 0x2b, 0x99, 0xb0, 0x9d, 0xd6, 0x76, 0x6e, 0x29, 0x53, - 0x8c, 0x2f, 0xb0, 0x12, 0x3b, 0x0e, 0x4c, 0x98, 0x4e, 0x58, 0x52, 0x69, 0xdd, 0xb2, 0x42, 0x29, - 0x40, 0xd5, 0x6a, 0xa9, 0xf4, 0xca, 0x56, 0x4b, 0xa1, 0xef, 0xcc, 0x0d, 0x66, 0x7a, 0x29, 0x76, - 0xd4, 0x9e, 0xaf, 0xb8, 0xed, 0x6c, 0xa9, 0x39, 0x5b, 0x3a, 0x71, 0x50, 0xa6, 0xe6, 0x98, 0x3a, - 0x90, 0xec, 0x3b, 0x77, 0x26, 0xf5, 0xa6, 0xca, 0x23, 0xc5, 0x55, 0xbe, 0x80, 0x76, 0xb1, 0x3f, - 0xb4, 0x0d, 0x75, 0xb4, 0x0b, 0x52, 0xa3, 0x1d, 0x68, 0xb8, 0x4e, 0x48, 0xe0, 0xa4, 0xc4, 0x72, - 0x12, 0xba, 0x81, 0x14, 0x97, 0x44, 0xea, 0x5e, 0x35, 0x9c, 0x34, 0x0a, 0x8b, 0x63, 0xe8, 0xfd, - 0xb1, 0x82, 0x0e, 0x2d, 0xaf, 0xcd, 0x0f, 0xb2, 0xac, 0x18, 0x78, 0x93, 0x5c, 0xac, 0xb7, 0x73, - 0x00, 0x68, 0xcd, 0xd1, 0xc7, 0xf5, 0xc2, 0x27, 0x82, 0xf0, 0x54, 0xba, 0x69, 0x2a, 0x3d, 0x5b, - 0x4b, 0x52, 0xf3, 0x0d, 0xad, 0x25, 0x09, 0x8a, 0xff, 0xcf, 0xa0, 0x5b, 0xed, 0x1a, 0xed, 0x43, - 0x07, 0xed, 0x02, 0x73, 0x5c, 0x39, 0x72, 0x00, 0x60, 0x51, 0xcd, 0x31, 0x97, 0x42, 0x15, 0x95, - 0x12, 0x61, 0xb9, 0x16, 0xaa, 0xdc, 0x99, 0x97, 0x47, 0xe7, 0x97, 0x51, 0x70, 0x71, 0x19, 0x05, - 0xbf, 0x2e, 0xa3, 0xe0, 0xeb, 0x55, 0x54, 0xbb, 0xb8, 0x8a, 0x6a, 0x3f, 0xaf, 0xa2, 0xda, 0x87, - 0x07, 0xa9, 0xb0, 0x8b, 0x55, 0x32, 0xe1, 0x5a, 0xfa, 0x77, 0xe8, 0xe1, 0x5f, 0x9f, 0xa4, 0xa4, - 0xe5, 0xdf, 0x95, 0x27, 0xbf, 0x03, 0x00, 0x00, 0xff, 0xff, 0x63, 0xcd, 0x9e, 0x86, 0xba, 0x04, + // 658 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x94, 0xcf, 0x6e, 0x13, 0x3b, + 0x14, 0xc6, 0x33, 0x93, 0xff, 0x27, 0x69, 0xea, 0xeb, 0x76, 0x91, 0x5b, 0xe9, 0xce, 0xed, 0xbd, + 0x0b, 0x14, 0x22, 0x91, 0x08, 0x58, 0xb2, 0x41, 0x54, 0x14, 0x81, 0x44, 0x17, 0x03, 0xaa, 0x04, + 0x9b, 0x68, 0xe2, 0x1c, 0x26, 0x56, 0x62, 0x7b, 0x34, 0x76, 0x02, 0xe1, 0x29, 0x58, 0xf2, 0x00, + 0x2c, 0x78, 0x14, 0x96, 0x5d, 0xb2, 0x44, 0xed, 0x03, 0xf0, 0x0a, 0xc8, 0xce, 0x78, 0x02, 0x0b, + 0x68, 0x57, 0x73, 0xfc, 0x9b, 0xef, 0x7c, 0xe7, 0xd8, 0x3e, 0x32, 0x0c, 0xdf, 0xa3, 0x49, 0xd8, + 0x3c, 0xe1, 0x72, 0xec, 0x22, 0x95, 0xe3, 0x38, 0x5b, 0xa4, 0x63, 0x87, 0x74, 0xf1, 0x19, 0x65, + 0xb9, 0x32, 0x8a, 0xfe, 0x53, 0x6a, 0x47, 0x5e, 0x3b, 0xca, 0x16, 0xe9, 0x68, 0x2b, 0x3a, 0x3a, + 0x4c, 0x55, 0xaa, 0x9c, 0x72, 0x6c, 0xa3, 0x6d, 0xd2, 0xff, 0x1f, 0xab, 0x50, 0x3f, 0xb1, 0x02, + 0xfa, 0x37, 0xb4, 0x9c, 0x72, 0xc2, 0x67, 0xfd, 0xf0, 0x38, 0x18, 0x54, 0xe3, 0xa6, 0x5b, 0x3f, + 0x9d, 0xd1, 0x27, 0x00, 0xdb, 0x5f, 0x32, 0x11, 0xd8, 0x0f, 0x8e, 0x83, 0x41, 0xef, 0xde, 0x60, + 0xf4, 0xc7, 0x72, 0x23, 0x67, 0x7a, 0x96, 0x08, 0x8c, 0xdb, 0xcc, 0x87, 0xf4, 0x21, 0x34, 0x25, + 0x9a, 0xb7, 0x2a, 0x5f, 0xf4, 0xab, 0xce, 0xe5, 0xd6, 0x35, 0x2e, 0x67, 0x5b, 0x75, 0xec, 0xd3, + 0xe8, 0x73, 0xe8, 0x16, 0xe1, 0xc4, 0x6c, 0x32, 0xec, 0xd7, 0x9c, 0xcd, 0xf0, 0x66, 0x36, 0x2f, + 0x37, 0x19, 0xc6, 0x1d, 0xb9, 0x5b, 0xd0, 0xbb, 0x10, 0xae, 0x45, 0xbf, 0xee, 0x4c, 0xfe, 0xbb, + 0xc6, 0xe4, 0x5c, 0xc4, 0xe1, 0x5a, 0xd0, 0x53, 0x68, 0x33, 0x25, 0x35, 0x4a, 0xbd, 0xd2, 0xfd, + 0xc6, 0xcd, 0xce, 0xc2, 0xeb, 0xe3, 0x5d, 0x2a, 0xfd, 0x17, 0x3a, 0x5c, 0x4f, 0xf0, 0x9d, 0xc1, + 0x5c, 0x26, 0xcb, 0x7e, 0xf3, 0x38, 0x18, 0xb4, 0x62, 0xe0, 0xfa, 0x71, 0x41, 0x86, 0x0f, 0x60, + 0x2f, 0x46, 0x86, 0x7c, 0x8d, 0x2f, 0x4c, 0x62, 0x56, 0x9a, 0x76, 0xa0, 0xc9, 0x72, 0x4c, 0x0c, + 0xce, 0x48, 0xc5, 0x2e, 0xf4, 0x8a, 0x31, 0xd4, 0x9a, 0x04, 0x14, 0xa0, 0xf1, 0x26, 0xe1, 0x4b, + 0x9c, 0x91, 0xf0, 0xa8, 0xf6, 0xf9, 0x53, 0x14, 0x0c, 0xbf, 0x87, 0xd0, 0x2e, 0xaf, 0x80, 0xb6, + 0xa1, 0x8e, 0x22, 0x33, 0x1b, 0x52, 0xa1, 0xfb, 0xd0, 0x41, 0x33, 0x9f, 0x88, 0x84, 0x4b, 0x89, + 0x86, 0x04, 0x94, 0x40, 0xd7, 0xf6, 0x5c, 0x92, 0xd0, 0x4a, 0xa6, 0x86, 0x95, 0xa0, 0x4a, 0x0f, + 0x60, 0x3f, 0x53, 0xcb, 0x4d, 0xaa, 0x64, 0x09, 0x6b, 0x4e, 0xa5, 0x77, 0xaa, 0x3a, 0xa5, 0xd0, + 0x4b, 0x15, 0xe6, 0x4b, 0x3e, 0x31, 0xa8, 0x8d, 0x65, 0x0d, 0xcb, 0xc4, 0x4a, 0x4c, 0x93, 0x1d, + 0x6b, 0xfa, 0x44, 0x0f, 0xa0, 0xec, 0xc0, 0x93, 0x8e, 0xef, 0xc0, 0x83, 0xae, 0xed, 0x40, 0x63, + 0xa6, 0x96, 0x7c, 0xa7, 0xda, 0xb3, 0xb0, 0x28, 0xb8, 0x54, 0x2c, 0x59, 0x5a, 0xd8, 0xf3, 0xa9, + 0x39, 0xa6, 0x56, 0x48, 0xf6, 0xad, 0x7b, 0x22, 0xd4, 0xa6, 0xcc, 0x23, 0xf4, 0x10, 0x88, 0xca, + 0x0c, 0x17, 0x5c, 0x8b, 0xb2, 0xfd, 0xbf, 0x7e, 0xa1, 0x45, 0x2d, 0x42, 0x6d, 0xf6, 0x34, 0xd1, + 0x58, 0xea, 0x0e, 0x4a, 0xe2, 0x35, 0x87, 0xc5, 0x89, 0xbf, 0x82, 0x66, 0x31, 0x66, 0xb4, 0x09, + 0x55, 0x34, 0x73, 0x52, 0xa1, 0x2d, 0xa8, 0xd9, 0x9d, 0x91, 0xc0, 0xa2, 0xa9, 0x61, 0x24, 0xb4, + 0xf7, 0x56, 0x9c, 0x25, 0xa9, 0x3a, 0xaa, 0x19, 0xa9, 0xd1, 0x2e, 0xb4, 0x7c, 0x71, 0x52, 0xb7, + 0x69, 0xb6, 0x04, 0x69, 0x14, 0xd6, 0xa7, 0xd0, 0xf9, 0x69, 0x82, 0xad, 0x85, 0x6f, 0xc7, 0xcd, + 0x81, 0xdf, 0x59, 0xe0, 0xcc, 0x73, 0xbe, 0xde, 0x5e, 0x23, 0x40, 0x63, 0x86, 0x2e, 0xae, 0x16, + 0x3e, 0x11, 0x84, 0xe7, 0xc2, 0x0e, 0x83, 0x54, 0x93, 0xb5, 0x20, 0x15, 0xd7, 0xe8, 0x5a, 0x90, + 0xa0, 0xf8, 0xff, 0x0c, 0xda, 0xe5, 0xa8, 0xda, 0x96, 0xd0, 0xcc, 0x31, 0xc7, 0x95, 0x55, 0xf6, + 0x00, 0x0c, 0xca, 0x19, 0xe6, 0x82, 0xcb, 0xa2, 0xd2, 0x94, 0x1b, 0xa6, 0xb8, 0x24, 0xe1, 0xb6, + 0xfb, 0x89, 0x36, 0x09, 0x5b, 0xf8, 0x5a, 0x8f, 0x4e, 0xbe, 0x5c, 0x46, 0xc1, 0xc5, 0x65, 0x14, + 0x7c, 0xbb, 0x8c, 0x82, 0x0f, 0x57, 0x51, 0xe5, 0xe2, 0x2a, 0xaa, 0x7c, 0xbd, 0x8a, 0x2a, 0xaf, + 0x6f, 0xa7, 0xdc, 0xcc, 0x57, 0xd3, 0x11, 0x53, 0xc2, 0x3d, 0x6a, 0x77, 0x7e, 0xfb, 0xbe, 0x4d, + 0x1b, 0xee, 0x91, 0xba, 0xff, 0x23, 0x00, 0x00, 0xff, 0xff, 0x15, 0x2a, 0x93, 0x8e, 0x07, 0x05, 0x00, 0x00, } diff --git a/proto/zetachain/zetacore/pkg/chains/chains.proto b/proto/zetachain/zetacore/pkg/chains/chains.proto index 6a11265719..1f2279af35 100644 --- a/proto/zetachain/zetacore/pkg/chains/chains.proto +++ b/proto/zetachain/zetacore/pkg/chains/chains.proto @@ -5,9 +5,14 @@ import "gogoproto/gogo.proto"; option go_package = "github.com/zeta-chain/zetacore/pkg/chains"; +// ReceiveStatus represents the status of an outbound +// TODO: Rename and move +// https://github.com/zeta-chain/node/issues/2257 enum ReceiveStatus { option (gogoproto.goproto_enum_stringer) = true; - created = 0; // some observer sees inbound tx + + // Created is used for inbounds + created = 0; success = 1; failed = 2; } @@ -22,20 +27,27 @@ enum ChainName { btc_mainnet = 3; polygon_mainnet = 4; bsc_mainnet = 5; + goerli_testnet = 6; mumbai_testnet = 7; - ganache_testnet = 8; - baobab_testnet = 9; bsc_testnet = 10; zeta_testnet = 11; btc_testnet = 12; sepolia_testnet = 13; + goerli_localnet = 14; btc_regtest = 15; + amoy_testnet = 16; + optimism_mainnet = 17; + optimism_sepolia = 18; + base_mainnet = 19; + base_sepolia = 20; } -// Network represents the network type of the chain +// Network represents the network of the chain +// there is a single instance of the network on mainnet +// then the network can have eventual testnets or devnets enum Network { option (gogoproto.goproto_enum_stringer) = true; eth = 0; @@ -43,9 +55,12 @@ enum Network { btc = 2; polygon = 3; bsc = 4; + optimism = 5; + base = 6; } // NetworkType represents the network type of the chain +// Mainnet, Testnet, Privnet, Devnet enum NetworkType { option (gogoproto.goproto_enum_stringer) = true; mainnet = 0; @@ -63,31 +78,37 @@ enum Vm { } // Consensus represents the consensus algorithm used by the chain +// this can represent the consensus of a L1 +// this can also represent the solution of a L2 enum Consensus { option (gogoproto.goproto_enum_stringer) = true; ethereum = 0; tendermint = 1; bitcoin = 2; + op_stack = 3; } -// 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 - +// Chain represents static data about a blockchain network +// it is identified by a unique chain ID message Chain { - ChainName chain_name = 1; + // ChainId is the unique identifier of the chain int64 chain_id = 2; + + // ChainName is the name of the chain + ChainName chain_name = 1; + + // Network is the network of the chain Network network = 3; + + // NetworkType is the network type of the chain: mainnet, testnet, etc.. NetworkType network_type = 4; + + // Vm is the virtual machine used in the chain Vm vm = 5; + + // Consensus is the underlying consensus algorithm used by the chain Consensus consensus = 6; + + // IsExternal describe if the chain is ZetaChain or external bool is_external = 7; } From ac9431c80d46585c70e479850d60dbf9282fefe6 Mon Sep 17 00:00:00 2001 From: lumtis Date: Fri, 24 May 2024 09:48:01 +0200 Subject: [PATCH 02/22] add and improve tests --- pkg/chains/chains.go | 4 + pkg/chains/chains_test.go | 355 ++++++++++++-------------------------- 2 files changed, 113 insertions(+), 246 deletions(-) diff --git a/pkg/chains/chains.go b/pkg/chains/chains.go index 0c7a542b94..64d21c9840 100644 --- a/pkg/chains/chains.go +++ b/pkg/chains/chains.go @@ -268,6 +268,10 @@ func DefaultChainsList() []*Chain { ZetaMocknetChain, ZetaPrivnetChain, PolygonChain, + OptimismMainnet, + OptimismSepolia, + BaseMainnet, + BaseSepolia, }) } diff --git a/pkg/chains/chains_test.go b/pkg/chains/chains_test.go index ba3452b6be..2f9db718a9 100644 --- a/pkg/chains/chains_test.go +++ b/pkg/chains/chains_test.go @@ -1,215 +1,59 @@ package chains import ( - "sort" "testing" "github.com/stretchr/testify/require" ) -func TestChainRetrievalFunctions(t *testing.T) { - tests := []struct { - name string - chain Chain - expected Chain - }{ - {"ZetaChainMainnet", ZetaChainMainnet, Chain{ - 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, - Consensus: Consensus_tendermint, - }, - }, - {"ZetaMocknetChain", ZetaMocknetChain, Chain{ - 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, - Consensus: Consensus_tendermint, - }}, - {"EthChain", EthChain, Chain{ - 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, - Consensus: Consensus_ethereum, - }}, - {"BtcMainnetChain", BtcMainnetChain, Chain{ - 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, - Consensus: Consensus_ethereum, - }}, - {"SepoliaChain", SepoliaChain, Chain{ - 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, - Consensus: Consensus_ethereum, - }}, - {"AmoyChain", AmoyChain, Chain{ - 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, - Consensus: Consensus_ethereum, - }}, - {"MumbaiChain", MumbaiChain, Chain{ - 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, - Consensus: Consensus_bitcoin, - }}, - {"BtcRegtestChain", BtcRegtestChain, Chain{ - 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, - Consensus: Consensus_ethereum, - }}, - } - - for _, tc := range tests { - t.Run(tc.name, func(t *testing.T) { - chain := tc.chain - require.Equal(t, tc.expected, chain) - }) - } -} func TestChainListByNetworkType(t *testing.T) { listTests := []struct { name string networkType NetworkType - expected []Chain + expected []*Chain }{ { - "MainnetChainList", + "mainnet chains", NetworkType_mainnet, - []Chain{ZetaChainMainnet, BtcMainnetChain, BscMainnetChain, EthChain, PolygonChain}, + []*Chain{ + &ZetaChainMainnet, + &BtcMainnetChain, + &BscMainnetChain, + &EthChain, + &PolygonChain, + &OptimismMainnet, + &BaseMainnet, + }, }, { - "TestnetChainList", + "testnet chains", NetworkType_testnet, - []Chain{ - ZetaTestnetChain, - BtcTestNetChain, - MumbaiChain, - AmoyChain, - BscTestnetChain, - GoerliChain, - SepoliaChain, + []*Chain{ + &ZetaTestnetChain, + &BtcTestNetChain, + &MumbaiChain, + &AmoyChain, + &BscTestnetChain, + &GoerliChain, + &SepoliaChain, + &OptimismSepolia, + &BaseSepolia, + }, + }, + { + "privnet chains", + NetworkType_privnet, + []*Chain{ + &ZetaPrivnetChain, + &BtcRegtestChain, + &GoerliLocalnetChain, }, }, - {"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]) - } + require.ElementsMatch(t, lt.expected, ChainListByNetworkType(lt.networkType)) }) } } @@ -218,28 +62,48 @@ func TestChainListByNetwork(t *testing.T) { listTests := []struct { name string network Network - expected []Chain + 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}, + }, + { + "Optimism", + Network_optimism, + []*Chain{&OptimismMainnet, &OptimismSepolia}, + }, + { + "Base", + Network_base, + []*Chain{&BaseMainnet, &BaseSepolia}, + }, } 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]) - } + require.ElementsMatch(t, lt.expected, ChainListByNetwork(lt.network)) }) } } @@ -247,46 +111,54 @@ func TestChainListFunctions(t *testing.T) { listTests := []struct { name string function func() []*Chain - expected []Chain + expected []*Chain }{ { "DefaultChainsList", DefaultChainsList, - []Chain{ - BtcMainnetChain, - BscMainnetChain, - EthChain, - BtcTestNetChain, - MumbaiChain, - AmoyChain, - BscTestnetChain, - GoerliChain, - SepoliaChain, - BtcRegtestChain, - GoerliLocalnetChain, - ZetaChainMainnet, - ZetaTestnetChain, - ZetaMocknetChain, - ZetaPrivnetChain, - PolygonChain, + []*Chain{ + &BtcMainnetChain, + &BscMainnetChain, + &EthChain, + &BtcTestNetChain, + &MumbaiChain, + &AmoyChain, + &BscTestnetChain, + &GoerliChain, + &SepoliaChain, + &BtcRegtestChain, + &GoerliLocalnetChain, + &ZetaChainMainnet, + &ZetaTestnetChain, + &ZetaMocknetChain, + &ZetaPrivnetChain, + &PolygonChain, + &OptimismMainnet, + &OptimismSepolia, + &BaseMainnet, + &BaseSepolia, }, }, { "ExternalChainList", ExternalChainList, - []Chain{ - BtcMainnetChain, - BscMainnetChain, - EthChain, - BtcTestNetChain, - MumbaiChain, - AmoyChain, - BscTestnetChain, - GoerliChain, - SepoliaChain, - BtcRegtestChain, - GoerliLocalnetChain, - PolygonChain, + []*Chain{ + &BtcMainnetChain, + &BscMainnetChain, + &EthChain, + &BtcTestNetChain, + &MumbaiChain, + &AmoyChain, + &BscTestnetChain, + &GoerliChain, + &SepoliaChain, + &BtcRegtestChain, + &GoerliLocalnetChain, + &PolygonChain, + &OptimismMainnet, + &OptimismSepolia, + &BaseMainnet, + &BaseSepolia, }, }, } @@ -294,16 +166,7 @@ func TestChainListFunctions(t *testing.T) { 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]) - } + require.ElementsMatch(t, lt.expected, chains) }) } } From 9c6e337bc782572d5c401498ba4ea4a463347353 Mon Sep 17 00:00:00 2001 From: lumtis Date: Fri, 24 May 2024 09:53:49 +0200 Subject: [PATCH 03/22] rename Ethereum chain --- Makefile | 2 +- docs/openapi/openapi.swagger.yaml | 43 ++++++++-- pkg/chains/chain_test.go | 22 ++--- pkg/chains/chains.go | 6 +- pkg/chains/chains_test.go | 8 +- .../zetacore/pkg/chains/chains_pb.d.ts | 83 +++++++++++++++---- x/crosschain/keeper/abci_test.go | 4 +- x/crosschain/keeper/evm_hooks_test.go | 36 ++++---- .../msg_server_add_inbound_tracker_test.go | 8 +- x/crosschain/migrations/v4/migrate_test.go | 4 +- x/crosschain/migrations/v5/migrate_test.go | 2 +- .../types/tx_body_verification_test.go | 40 ++++----- x/lightclient/genesis_test.go | 2 +- .../keeper/block_header_verification_test.go | 16 ++-- ...disable_block_header_verification._test.go | 14 ++-- ...r_enable_block_header_verification_test.go | 14 ++-- x/lightclient/keeper/proof_test.go | 10 +-- x/lightclient/types/genesis_test.go | 6 +- ...message_disable_verification_flags_test.go | 6 +- .../message_enable_verification_flags_test.go | 6 +- x/lightclient/types/verification_flags.go | 2 +- .../types/verification_flags_test.go | 2 +- x/observer/types/chain_params.go | 2 +- .../chains/evm/observer/inbound_test.go | 14 ++-- .../chains/evm/observer/outbound_test.go | 16 ++-- zetaclient/compliance/compliance_test.go | 2 +- zetaclient/config/config_chain.go | 4 +- zetaclient/context/zetacore_context_test.go | 4 +- zetaclient/orchestrator/orchestrator_test.go | 6 +- zetaclient/ratelimiter/rate_limiter_test.go | 2 +- zetaclient/zetacore/broadcast_test.go | 4 +- zetaclient/zetacore/query_test.go | 22 ++--- zetaclient/zetacore/tx_test.go | 22 ++--- 33 files changed, 256 insertions(+), 178 deletions(-) diff --git a/Makefile b/Makefile index 6508b07b50..1a0357854b 100644 --- a/Makefile +++ b/Makefile @@ -199,7 +199,7 @@ mocks: .PHONY: mocks # generate also includes Go code formatting -generate: proto-gen openapi specs typescript docs-zetacored mocks fmt-import fmt-golines +generate: proto-gen openapi specs typescript docs-zetacored mocks fmt-import .PHONY: generate ############################################################################### diff --git a/docs/openapi/openapi.swagger.yaml b/docs/openapi/openapi.swagger.yaml index d9995b839b..92c7ac28c8 100644 --- a/docs/openapi/openapi.swagger.yaml +++ b/docs/openapi/openapi.swagger.yaml @@ -56747,21 +56747,31 @@ definitions: chainsChain: type: object properties: - chain_name: - $ref: '#/definitions/chainsChainName' chain_id: type: string format: int64 + title: ChainId is the unique identifier of the chain + chain_name: + $ref: '#/definitions/chainsChainName' + title: ChainName is the name of the chain network: $ref: '#/definitions/chainsNetwork' + title: Network is the network of the chain network_type: $ref: '#/definitions/chainsNetworkType' + description: 'NetworkType is the network type of the chain: mainnet, testnet, etc..' vm: $ref: '#/definitions/chainsVm' + title: Vm is the virtual machine used in the chain consensus: $ref: '#/definitions/chainsConsensus' + title: Consensus is the underlying consensus algorithm used by the chain is_external: type: boolean + title: IsExternal describe if the chain is ZetaChain or external + title: |- + Chain represents static data about a blockchain network + it is identified by a unique chain ID chainsChainName: type: string enum: @@ -56773,8 +56783,6 @@ definitions: - bsc_mainnet - goerli_testnet - mumbai_testnet - - ganache_testnet - - baobab_testnet - bsc_testnet - zeta_testnet - btc_testnet @@ -56782,6 +56790,10 @@ definitions: - goerli_localnet - btc_regtest - amoy_testnet + - optimism_mainnet + - optimism_sepolia + - base_mainnet + - base_sepolia default: empty title: ChainName represents the name of the chain chainsConsensus: @@ -56790,8 +56802,12 @@ definitions: - ethereum - tendermint - bitcoin + - op_stack default: ethereum - title: Consensus represents the consensus algorithm used by the chain + title: |- + Consensus represents the consensus algorithm used by the chain + this can represent the consensus of a L1 + this can also represent the solution of a L2 chainsNetwork: type: string enum: @@ -56800,8 +56816,13 @@ definitions: - btc - polygon - bsc + - optimism + - base default: eth - title: Network represents the network type of the chain + title: |- + Network represents the network of the chain + there is a single instance of the network on mainnet + then the network can have eventual testnets or devnets chainsNetworkType: type: string enum: @@ -56810,7 +56831,9 @@ definitions: - privnet - devnet default: mainnet - title: NetworkType represents the network type of the chain + title: |- + NetworkType represents the network type of the chain + Mainnet, Testnet, Privnet, Devnet chainsReceiveStatus: type: string enum: @@ -56818,7 +56841,11 @@ definitions: - success - failed default: created - title: '- created: some observer sees inbound tx' + description: '- created: Created is used for inbounds' + title: |- + ReceiveStatus represents the status of an outbound + TODO: Rename and move + https://github.com/zeta-chain/node/issues/2257 chainsVm: type: string enum: diff --git a/pkg/chains/chain_test.go b/pkg/chains/chain_test.go index 6630aac8b7..bc9b9213af 100644 --- a/pkg/chains/chain_test.go +++ b/pkg/chains/chain_test.go @@ -142,7 +142,7 @@ func TestChain_InChainList(t *testing.T) { 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.False(t, Ethereum.InChainList(ChainListByNetwork(Network_zeta))) } func TestIsZetaChain(t *testing.T) { @@ -155,7 +155,7 @@ func TestIsZetaChain(t *testing.T) { {"Zeta Testnet", ZetaTestnetChain.ChainId, true}, {"Zeta Mocknet", ZetaMocknetChain.ChainId, true}, {"Zeta Privnet", ZetaPrivnetChain.ChainId, true}, - {"Non-Zeta", EthChain.ChainId, false}, + {"Non-Zeta", Ethereum.ChainId, false}, } for _, tt := range tests { @@ -171,7 +171,7 @@ func TestIsEVMChain(t *testing.T) { chainID int64 want bool }{ - {"Ethereum Mainnet", EthChain.ChainId, true}, + {"Ethereum Mainnet", Ethereum.ChainId, true}, {"Goerli Testnet", GoerliChain.ChainId, true}, {"Sepolia Testnet", SepoliaChain.ChainId, true}, {"Non-EVM", BtcMainnetChain.ChainId, false}, @@ -191,7 +191,7 @@ func TestIsHeaderSupportedChain(t *testing.T) { chainID int64 want bool }{ - {"Ethereum Mainnet", EthChain.ChainId, true}, + {"Ethereum Mainnet", Ethereum.ChainId, true}, {"Goerli Testnet", GoerliChain.ChainId, true}, {"Goerli Localnet", GoerliLocalnetChain.ChainId, true}, {"Sepolia Testnet", SepoliaChain.ChainId, true}, @@ -214,7 +214,7 @@ func TestSupportMerkleProof(t *testing.T) { chain Chain want bool }{ - {"Ethereum Mainnet", EthChain, true}, + {"Ethereum Mainnet", Ethereum, true}, {"BSC Testnet", BscTestnetChain, true}, {"BSC Mainnet", BscMainnetChain, true}, {"Non-EVM", BtcMainnetChain, true}, @@ -237,7 +237,7 @@ func TestIsBitcoinChain(t *testing.T) { {"Bitcoin Mainnet", BtcMainnetChain.ChainId, true}, {"Bitcoin Testnet", BtcTestNetChain.ChainId, true}, {"Bitcoin Regtest", BtcRegtestChain.ChainId, true}, - {"Non-Bitcoin", EthChain.ChainId, false}, + {"Non-Bitcoin", Ethereum.ChainId, false}, {"Zeta Mainnet", ZetaChainMainnet.ChainId, false}, } @@ -254,7 +254,7 @@ func TestIsEthereumChain(t *testing.T) { chainID int64 want bool }{ - {"Ethereum Mainnet", EthChain.ChainId, true}, + {"Ethereum Mainnet", Ethereum.ChainId, true}, {"Goerli Testnet", GoerliChain.ChainId, true}, {"Sepolia Testnet", SepoliaChain.ChainId, true}, {"Non-Ethereum", BtcMainnetChain.ChainId, false}, @@ -270,12 +270,12 @@ func TestIsEthereumChain(t *testing.T) { func TestChain_IsExternalChain(t *testing.T) { require.False(t, ZetaChainMainnet.IsExternalChain()) - require.True(t, EthChain.IsExternalChain()) + require.True(t, Ethereum.IsExternalChain()) } func TestChain_IsZetaChain(t *testing.T) { require.True(t, ZetaChainMainnet.IsZetaChain()) - require.False(t, EthChain.IsZetaChain()) + require.False(t, Ethereum.IsZetaChain()) } func TestChain_IsEmpty(t *testing.T) { @@ -327,7 +327,7 @@ func TestChain_WitnessProgram(t *testing.T) { func TestChains_Has(t *testing.T) { chains := Chains{ZetaChainMainnet, ZetaTestnetChain} require.True(t, chains.Has(ZetaChainMainnet)) - require.False(t, chains.Has(EthChain)) + require.False(t, chains.Has(Ethereum)) } func TestChains_Distinct(t *testing.T) { @@ -377,5 +377,5 @@ 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.False(t, ChainIDInChainList(Ethereum.ChainId, ChainListByNetwork(Network_zeta))) } diff --git a/pkg/chains/chains.go b/pkg/chains/chains.go index 64d21c9840..b2ef6a0407 100644 --- a/pkg/chains/chains.go +++ b/pkg/chains/chains.go @@ -18,8 +18,8 @@ var ( IsExternal: false, } - // EthChain is Ethereum mainnet - EthChain = Chain{ + // Ethereum is Ethereum mainnet + Ethereum = Chain{ ChainName: ChainName_eth_mainnet, ChainId: 1, Network: Network_eth, @@ -254,7 +254,7 @@ func DefaultChainsList() []*Chain { return chainListPointers([]Chain{ BtcMainnetChain, BscMainnetChain, - EthChain, + Ethereum, BtcTestNetChain, MumbaiChain, AmoyChain, diff --git a/pkg/chains/chains_test.go b/pkg/chains/chains_test.go index 2f9db718a9..92d25d696b 100644 --- a/pkg/chains/chains_test.go +++ b/pkg/chains/chains_test.go @@ -19,7 +19,7 @@ func TestChainListByNetworkType(t *testing.T) { &ZetaChainMainnet, &BtcMainnetChain, &BscMainnetChain, - &EthChain, + &Ethereum, &PolygonChain, &OptimismMainnet, &BaseMainnet, @@ -77,7 +77,7 @@ func TestChainListByNetwork(t *testing.T) { { "Eth", Network_eth, - []*Chain{&EthChain, &GoerliChain, &SepoliaChain, &GoerliLocalnetChain}, + []*Chain{&Ethereum, &GoerliChain, &SepoliaChain, &GoerliLocalnetChain}, }, { "Bsc", @@ -119,7 +119,7 @@ func TestChainListFunctions(t *testing.T) { []*Chain{ &BtcMainnetChain, &BscMainnetChain, - &EthChain, + &Ethereum, &BtcTestNetChain, &MumbaiChain, &AmoyChain, @@ -145,7 +145,7 @@ func TestChainListFunctions(t *testing.T) { []*Chain{ &BtcMainnetChain, &BscMainnetChain, - &EthChain, + &Ethereum, &BtcTestNetChain, &MumbaiChain, &AmoyChain, diff --git a/typescript/zetachain/zetacore/pkg/chains/chains_pb.d.ts b/typescript/zetachain/zetacore/pkg/chains/chains_pb.d.ts index f076ac5bb9..6abe26cd04 100644 --- a/typescript/zetachain/zetacore/pkg/chains/chains_pb.d.ts +++ b/typescript/zetachain/zetacore/pkg/chains/chains_pb.d.ts @@ -7,11 +7,15 @@ import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialM import { Message, proto3 } from "@bufbuild/protobuf"; /** + * ReceiveStatus represents the status of an outbound + * TODO: Rename and move + * https://github.com/zeta-chain/node/issues/2257 + * * @generated from enum zetachain.zetacore.pkg.chains.ReceiveStatus */ export declare enum ReceiveStatus { /** - * some observer sees inbound tx + * Created is used for inbounds * * @generated from enum value: created = 0; */ @@ -74,16 +78,6 @@ export declare enum ChainName { */ mumbai_testnet = 7, - /** - * @generated from enum value: ganache_testnet = 8; - */ - ganache_testnet = 8, - - /** - * @generated from enum value: baobab_testnet = 9; - */ - baobab_testnet = 9, - /** * @generated from enum value: bsc_testnet = 10; */ @@ -118,10 +112,32 @@ export declare enum ChainName { * @generated from enum value: amoy_testnet = 16; */ amoy_testnet = 16, + + /** + * @generated from enum value: optimism_mainnet = 17; + */ + optimism_mainnet = 17, + + /** + * @generated from enum value: optimism_sepolia = 18; + */ + optimism_sepolia = 18, + + /** + * @generated from enum value: base_mainnet = 19; + */ + base_mainnet = 19, + + /** + * @generated from enum value: base_sepolia = 20; + */ + base_sepolia = 20, } /** - * Network represents the network type of the chain + * Network represents the network of the chain + * there is a single instance of the network on mainnet + * then the network can have eventual testnets or devnets * * @generated from enum zetachain.zetacore.pkg.chains.Network */ @@ -150,10 +166,21 @@ export declare enum Network { * @generated from enum value: bsc = 4; */ bsc = 4, + + /** + * @generated from enum value: optimism = 5; + */ + optimism = 5, + + /** + * @generated from enum value: base = 6; + */ + base = 6, } /** * NetworkType represents the network type of the chain + * Mainnet, Testnet, Privnet, Devnet * * @generated from enum zetachain.zetacore.pkg.chains.NetworkType */ @@ -199,6 +226,8 @@ export declare enum Vm { /** * Consensus represents the consensus algorithm used by the chain + * this can represent the consensus of a L1 + * this can also represent the solution of a L2 * * @generated from enum zetachain.zetacore.pkg.chains.Consensus */ @@ -217,43 +246,65 @@ export declare enum Consensus { * @generated from enum value: bitcoin = 2; */ bitcoin = 2, + + /** + * @generated from enum value: op_stack = 3; + */ + op_stack = 3, } /** + * Chain represents static data about a blockchain network + * it is identified by a unique chain ID + * * @generated from message zetachain.zetacore.pkg.chains.Chain */ export declare class Chain extends Message { /** - * @generated from field: zetachain.zetacore.pkg.chains.ChainName chain_name = 1; + * ChainId is the unique identifier of the chain + * + * @generated from field: int64 chain_id = 2; */ - chainName: ChainName; + chainId: bigint; /** - * @generated from field: int64 chain_id = 2; + * ChainName is the name of the chain + * + * @generated from field: zetachain.zetacore.pkg.chains.ChainName chain_name = 1; */ - chainId: bigint; + chainName: ChainName; /** + * Network is the network of the chain + * * @generated from field: zetachain.zetacore.pkg.chains.Network network = 3; */ network: Network; /** + * NetworkType is the network type of the chain: mainnet, testnet, etc.. + * * @generated from field: zetachain.zetacore.pkg.chains.NetworkType network_type = 4; */ networkType: NetworkType; /** + * Vm is the virtual machine used in the chain + * * @generated from field: zetachain.zetacore.pkg.chains.Vm vm = 5; */ vm: Vm; /** + * Consensus is the underlying consensus algorithm used by the chain + * * @generated from field: zetachain.zetacore.pkg.chains.Consensus consensus = 6; */ consensus: Consensus; /** + * IsExternal describe if the chain is ZetaChain or external + * * @generated from field: bool is_external = 7; */ isExternal: boolean; diff --git a/x/crosschain/keeper/abci_test.go b/x/crosschain/keeper/abci_test.go index d44e5d1ef1..e390621978 100644 --- a/x/crosschain/keeper/abci_test.go +++ b/x/crosschain/keeper/abci_test.go @@ -43,7 +43,7 @@ func TestKeeper_IterateAndUpdateCctxGasPrice(t *testing.T) { // add some evm and non-evm chains supportedChains := []*chains.Chain{ - {ChainId: chains.EthChain.ChainId}, + {ChainId: chains.Ethereum.ChainId}, {ChainId: chains.BtcMainnetChain.ChainId}, {ChainId: chains.BscMainnetChain.ChainId}, {ChainId: chains.ZetaChainMainnet.ChainId}, @@ -52,7 +52,7 @@ func TestKeeper_IterateAndUpdateCctxGasPrice(t *testing.T) { // 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, 10, 15, chains.Ethereum.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) diff --git a/x/crosschain/keeper/evm_hooks_test.go b/x/crosschain/keeper/evm_hooks_test.go index 39ee88e63e..eca45bd21e 100644 --- a/x/crosschain/keeper/evm_hooks_test.go +++ b/x/crosschain/keeper/evm_hooks_test.go @@ -226,7 +226,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.Ethereum chainID := chain.ChainId setSupportedChain(ctx, zk, chainID) SetupStateForProcessLogs(t, ctx, k, zk, sdkk, chain) @@ -252,7 +252,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.Ethereum chainID := chain.ChainId setSupportedChain(ctx, zk, chainID) SetupStateForProcessLogs(t, ctx, k, zk, sdkk, chain) @@ -273,7 +273,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.Ethereum chainID := chain.ChainId SetupStateForProcessLogs(t, ctx, k, zk, sdkk, chain) @@ -294,7 +294,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.Ethereum chainID := chain.ChainId setSupportedChain(ctx, zk, chainID) SetupStateForProcessLogs(t, ctx, k, zk, sdkk, chain) @@ -317,7 +317,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.Ethereum chainID := chain.ChainId setSupportedChain(ctx, zk, chainID) SetupStateForProcessLogs(t, ctx, k, zk, sdkk, chain) @@ -343,7 +343,7 @@ func TestKeeper_ProcessZRC20WithdrawalEvent(t *testing.T) { fungibleMock := keepertest.GetCrosschainFungibleMock(t, k) k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) - chain := chains.EthChain + chain := chains.Ethereum chainID := chain.ChainId setSupportedChain(ctx, zk, chainID) SetupStateForProcessLogs(t, ctx, k, zk, sdkk, chain) @@ -369,7 +369,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.Ethereum chainID := chain.ChainId setSupportedChain(ctx, zk, chainID) SetupStateForProcessLogs(t, ctx, k, zk, sdkk, chain) @@ -392,7 +392,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.Ethereum chainID := chain.ChainId setSupportedChain(ctx, zk, chainID) SetupStateForProcessLogs(t, ctx, k, zk, sdkk, chain) @@ -427,7 +427,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.Ethereum.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()) @@ -465,7 +465,7 @@ func TestKeeper_ProcessZetaSentEvent(t *testing.T) { k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) - chain := chains.EthChain + chain := chains.Ethereum chainID := chain.ChainId setSupportedChain(ctx, zk, chainID) @@ -503,7 +503,7 @@ func TestKeeper_ProcessZetaSentEvent(t *testing.T) { ), 0, ) - require.Equal(t, chains.EthChain.ChainId, cctxList[0].GetCurrentOutboundParam().ReceiverChainId) + require.Equal(t, chains.Ethereum.ChainId, cctxList[0].GetCurrentOutboundParam().ReceiverChainId) require.Equal(t, emittingContract.Hex(), cctxList[0].InboundParams.Sender) require.Equal(t, txOrigin.Hex(), cctxList[0].InboundParams.TxOrigin) }) @@ -512,7 +512,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.Ethereum chainID := chain.ChainId setSupportedChain(ctx, zk, chainID) SetupStateForProcessLogs(t, ctx, k, zk, sdkk, chain) @@ -536,7 +536,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.Ethereum SetupStateForProcessLogs(t, ctx, k, zk, sdkk, chain) admin := keepertest.SetAdminPolices(ctx, zk.AuthorityKeeper) SetupStateForProcessLogsZetaSent(t, ctx, k, zk, sdkk, chain, admin) @@ -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.Ethereum chainID := chain.ChainId setSupportedChain(ctx, zk, chainID) SetupStateForProcessLogs(t, ctx, k, zk, sdkk, chain) @@ -599,7 +599,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.Ethereum chainID := chain.ChainId setSupportedChain(ctx, zk, chainID) SetupStateForProcessLogs(t, ctx, k, zk, sdkk, chain) @@ -629,7 +629,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.Ethereum chainID := chain.ChainId setSupportedChain(ctx, zk, chainID) @@ -695,7 +695,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.Ethereum chainID := chain.ChainId setSupportedChain(ctx, zk, chainID) SetupStateForProcessLogs(t, ctx, k, zk, sdkk, chain) @@ -731,7 +731,7 @@ func TestKeeper_ProcessLogs(t *testing.T) { ), 0, ) - require.Equal(t, chains.EthChain.ChainId, cctxList[0].GetCurrentOutboundParam().ReceiverChainId) + require.Equal(t, chains.Ethereum.ChainId, cctxList[0].GetCurrentOutboundParam().ReceiverChainId) require.Equal(t, emittingContract.Hex(), cctxList[0].InboundParams.Sender) require.Equal(t, txOrigin.Hex(), cctxList[0].InboundParams.TxOrigin) }) diff --git a/x/crosschain/keeper/msg_server_add_inbound_tracker_test.go b/x/crosschain/keeper/msg_server_add_inbound_tracker_test.go index ba91595689..94773a302b 100644 --- a/x/crosschain/keeper/msg_server_add_inbound_tracker_test.go +++ b/x/crosschain/keeper/msg_server_add_inbound_tracker_test.go @@ -232,7 +232,7 @@ func TestMsgServer_AddToInboundTracker(t *testing.T) { 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) + Return(sample.ChainParams(chains.Ethereum.ChainId), true) observerMock.On("GetTssAddress", mock.Anything, mock.Anything).Return(nil, errors.New("error")) txHash := "string" @@ -268,7 +268,7 @@ func TestMsgServer_AddToInboundTracker(t *testing.T) { 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) + Return(sample.ChainParams(chains.Ethereum.ChainId), true) observerMock.On("GetTssAddress", mock.Anything, mock.Anything).Return(&observertypes.QueryGetTssAddressResponse{ Eth: sample.EthAddress().Hex(), }, nil) @@ -303,7 +303,7 @@ func TestMsgServer_AddToInboundTracker(t *testing.T) { admin := sample.AccAddress() - chainID := chains.EthChain.ChainId + chainID := chains.Ethereum.ChainId tssAddress := sample.EthAddress() ethTx, ethTxBytes := sample.EthTx(t, chainID, tssAddress, 42) txHash := ethTx.Hash().Hex() @@ -316,7 +316,7 @@ func TestMsgServer_AddToInboundTracker(t *testing.T) { 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) + Return(sample.ChainParams(chains.Ethereum.ChainId), true) observerMock.On("GetTssAddress", mock.Anything, mock.Anything).Return(&observertypes.QueryGetTssAddressResponse{ Eth: tssAddress.Hex(), }, nil) diff --git a/x/crosschain/migrations/v4/migrate_test.go b/x/crosschain/migrations/v4/migrate_test.go index 00eaf9c51f..edf084bff5 100644 --- a/x/crosschain/migrations/v4/migrate_test.go +++ b/x/crosschain/migrations/v4/migrate_test.go @@ -115,7 +115,7 @@ func TestSetBitcoinFinalizedInbound(t *testing.T) { k.SetCrossChainTx(ctx, types.CrossChainTx{ Index: "2", InboundParams: &types.InboundParams{ - SenderChainId: chains.EthChain.ChainId, + SenderChainId: chains.Ethereum.ChainId, ObservedHash: "0xbbb", }, }) @@ -153,7 +153,7 @@ func TestSetBitcoinFinalizedInbound(t *testing.T) { // 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, "0xbbb", chains.Ethereum.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)) diff --git a/x/crosschain/migrations/v5/migrate_test.go b/x/crosschain/migrations/v5/migrate_test.go index 577dc160d0..872176388b 100644 --- a/x/crosschain/migrations/v5/migrate_test.go +++ b/x/crosschain/migrations/v5/migrate_test.go @@ -78,7 +78,7 @@ func TestResetTestnetNonce(t *testing.T) { chains.BscTestnetChain, chains.BtcTestNetChain, } - mainnetChains := []chains.Chain{chains.EthChain, chains.BscMainnetChain, chains.BtcMainnetChain} + mainnetChains := []chains.Chain{chains.Ethereum, chains.BscMainnetChain, chains.BtcMainnetChain} nonceLow := int64(1) nonceHigh := int64(10) tss := sample.Tss() diff --git a/x/crosschain/types/tx_body_verification_test.go b/x/crosschain/types/tx_body_verification_test.go index a51d56b8bc..cc051ac7ba 100644 --- a/x/crosschain/types/tx_body_verification_test.go +++ b/x/crosschain/types/tx_body_verification_test.go @@ -14,7 +14,7 @@ import ( func TestVerifyInboundBody(t *testing.T) { sampleTo := sample.EthAddress() - sampleEthTx, sampleEthTxBytes := sample.EthTx(t, chains.EthChain.ChainId, sampleTo, 42) + sampleEthTx, sampleEthTxBytes := sample.EthTx(t, chains.Ethereum.ChainId, sampleTo, 42) // NOTE: errContains == "" means no error for _, tc := range []struct { @@ -36,7 +36,7 @@ func TestVerifyInboundBody(t *testing.T) { { desc: "txBytes can't be unmarshaled", msg: types.MsgAddInboundTracker{ - ChainId: chains.EthChain.ChainId, + ChainId: chains.Ethereum.ChainId, }, txBytes: []byte("invalid"), errContains: "failed to unmarshal transaction", @@ -44,7 +44,7 @@ func TestVerifyInboundBody(t *testing.T) { { desc: "txHash doesn't correspond", msg: types.MsgAddInboundTracker{ - ChainId: chains.EthChain.ChainId, + ChainId: chains.Ethereum.ChainId, TxHash: sample.Hash().Hex(), }, txBytes: sampleEthTxBytes, @@ -62,7 +62,7 @@ func TestVerifyInboundBody(t *testing.T) { { desc: "invalid coin type", msg: types.MsgAddInboundTracker{ - ChainId: chains.EthChain.ChainId, + ChainId: chains.Ethereum.ChainId, TxHash: sampleEthTx.Hash().Hex(), CoinType: coin.CoinType(1000), }, @@ -72,7 +72,7 @@ func TestVerifyInboundBody(t *testing.T) { { desc: "coin types is zeta, but connector contract address is wrong", msg: types.MsgAddInboundTracker{ - ChainId: chains.EthChain.ChainId, + ChainId: chains.Ethereum.ChainId, TxHash: sampleEthTx.Hash().Hex(), CoinType: coin.CoinType_Zeta, }, @@ -83,7 +83,7 @@ func TestVerifyInboundBody(t *testing.T) { { desc: "coin types is zeta, connector contract address is correct", msg: types.MsgAddInboundTracker{ - ChainId: chains.EthChain.ChainId, + ChainId: chains.Ethereum.ChainId, TxHash: sampleEthTx.Hash().Hex(), CoinType: coin.CoinType_Zeta, }, @@ -93,7 +93,7 @@ func TestVerifyInboundBody(t *testing.T) { { desc: "coin types is erc20, but erc20 custody contract address is wrong", msg: types.MsgAddInboundTracker{ - ChainId: chains.EthChain.ChainId, + ChainId: chains.Ethereum.ChainId, TxHash: sampleEthTx.Hash().Hex(), CoinType: coin.CoinType_ERC20, }, @@ -104,7 +104,7 @@ func TestVerifyInboundBody(t *testing.T) { { desc: "coin types is erc20, erc20 custody contract address is correct", msg: types.MsgAddInboundTracker{ - ChainId: chains.EthChain.ChainId, + ChainId: chains.Ethereum.ChainId, TxHash: sampleEthTx.Hash().Hex(), CoinType: coin.CoinType_ERC20, }, @@ -114,7 +114,7 @@ func TestVerifyInboundBody(t *testing.T) { { desc: "coin types is gas, but tss address is not found", msg: types.MsgAddInboundTracker{ - ChainId: chains.EthChain.ChainId, + ChainId: chains.Ethereum.ChainId, TxHash: sampleEthTx.Hash().Hex(), CoinType: coin.CoinType_Gas, }, @@ -125,7 +125,7 @@ func TestVerifyInboundBody(t *testing.T) { { desc: "coin types is gas, but tss address is wrong", msg: types.MsgAddInboundTracker{ - ChainId: chains.EthChain.ChainId, + ChainId: chains.Ethereum.ChainId, TxHash: sampleEthTx.Hash().Hex(), CoinType: coin.CoinType_Gas, }, @@ -136,7 +136,7 @@ func TestVerifyInboundBody(t *testing.T) { { desc: "coin types is gas, tss address is correct", msg: types.MsgAddInboundTracker{ - ChainId: chains.EthChain.ChainId, + ChainId: chains.Ethereum.ChainId, TxHash: sampleEthTx.Hash().Hex(), CoinType: coin.CoinType_Gas, }, @@ -158,8 +158,8 @@ func TestVerifyInboundBody(t *testing.T) { func TestVerifyOutboundBody(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.Ethereum.ChainId, sampleTo, 42) + _, sampleEthTxBytesNonSigned := sample.EthTx(t, chains.Ethereum.ChainId, sampleTo, 42) // NOTE: errContains == "" means no error for _, tc := range []struct { @@ -182,7 +182,7 @@ func TestVerifyOutboundBody(t *testing.T) { { desc: "txBytes can't be unmarshaled", msg: types.MsgAddOutboundTracker{ - ChainId: chains.EthChain.ChainId, + ChainId: chains.Ethereum.ChainId, Nonce: 42, TxHash: sampleEthTx.Hash().Hex(), }, @@ -192,7 +192,7 @@ func TestVerifyOutboundBody(t *testing.T) { { desc: "can't recover sender address", msg: types.MsgAddOutboundTracker{ - ChainId: chains.EthChain.ChainId, + ChainId: chains.Ethereum.ChainId, Nonce: 42, TxHash: sampleEthTx.Hash().Hex(), }, @@ -202,7 +202,7 @@ func TestVerifyOutboundBody(t *testing.T) { { desc: "tss address not found", msg: types.MsgAddOutboundTracker{ - ChainId: chains.EthChain.ChainId, + ChainId: chains.Ethereum.ChainId, Nonce: 42, TxHash: sampleEthTx.Hash().Hex(), }, @@ -213,7 +213,7 @@ func TestVerifyOutboundBody(t *testing.T) { { desc: "tss address is wrong", msg: types.MsgAddOutboundTracker{ - ChainId: chains.EthChain.ChainId, + ChainId: chains.Ethereum.ChainId, Nonce: 42, TxHash: sampleEthTx.Hash().Hex(), }, @@ -235,7 +235,7 @@ func TestVerifyOutboundBody(t *testing.T) { { desc: "nonce doesn't correspond", msg: types.MsgAddOutboundTracker{ - ChainId: chains.EthChain.ChainId, + ChainId: chains.Ethereum.ChainId, Nonce: 100, TxHash: sampleEthTx.Hash().Hex(), }, @@ -246,7 +246,7 @@ func TestVerifyOutboundBody(t *testing.T) { { desc: "tx hash doesn't correspond", msg: types.MsgAddOutboundTracker{ - ChainId: chains.EthChain.ChainId, + ChainId: chains.Ethereum.ChainId, Nonce: 42, TxHash: sample.Hash().Hex(), }, @@ -257,7 +257,7 @@ func TestVerifyOutboundBody(t *testing.T) { { desc: "valid outbound body", msg: types.MsgAddOutboundTracker{ - ChainId: chains.EthChain.ChainId, + ChainId: chains.Ethereum.ChainId, Nonce: 42, TxHash: sampleEthTx.Hash().Hex(), }, diff --git a/x/lightclient/genesis_test.go b/x/lightclient/genesis_test.go index 6613701a8d..6b5d94fec8 100644 --- a/x/lightclient/genesis_test.go +++ b/x/lightclient/genesis_test.go @@ -24,7 +24,7 @@ func TestGenesis(t *testing.T) { sample.BlockHeader(sample.Hash().Bytes()), }, ChainStates: []types.ChainState{ - sample.ChainState(chains.EthChain.ChainId), + sample.ChainState(chains.Ethereum.ChainId), sample.ChainState(chains.BtcMainnetChain.ChainId), sample.ChainState(chains.BscMainnetChain.ChainId), }, diff --git a/x/lightclient/keeper/block_header_verification_test.go b/x/lightclient/keeper/block_header_verification_test.go index 6bdc608540..6714153349 100644 --- a/x/lightclient/keeper/block_header_verification_test.go +++ b/x/lightclient/keeper/block_header_verification_test.go @@ -42,13 +42,13 @@ func TestKeeper_CheckVerificationFlagsEnabled(t *testing.T) { k.SetBlockHeaderVerification(ctx, types.BlockHeaderVerification{ HeaderSupportedChains: []types.HeaderSupportedChain{ { - ChainId: chains.EthChain.ChainId, + ChainId: chains.Ethereum.ChainId, Enabled: true, }, }, }) - err := k.CheckBlockHeaderVerificationEnabled(ctx, chains.EthChain.ChainId) + err := k.CheckBlockHeaderVerificationEnabled(ctx, chains.Ethereum.ChainId) require.NoError(t, err) err = k.CheckBlockHeaderVerificationEnabled(ctx, chains.BtcMainnetChain.ChainId) @@ -75,12 +75,12 @@ func TestKeeper_CheckVerificationFlagsEnabled(t *testing.T) { }, }) - err := k.CheckBlockHeaderVerificationEnabled(ctx, chains.EthChain.ChainId) + err := k.CheckBlockHeaderVerificationEnabled(ctx, chains.Ethereum.ChainId) require.Error(t, err) require.ErrorContains( t, err, - fmt.Sprintf("proof verification is disabled for chain %d", chains.EthChain.ChainId), + fmt.Sprintf("proof verification is disabled for chain %d", chains.Ethereum.ChainId), ) err = k.CheckBlockHeaderVerificationEnabled(ctx, chains.BtcMainnetChain.ChainId) @@ -93,7 +93,7 @@ func TestKeeper_CheckVerificationFlagsEnabled(t *testing.T) { 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) + err := k.CheckBlockHeaderVerificationEnabled(ctx, chains.Ethereum.ChainId) require.ErrorContains(t, err, "proof verification is disabled for all chains") err = k.CheckBlockHeaderVerificationEnabled(ctx, chains.BtcMainnetChain.ChainId) @@ -105,17 +105,17 @@ func TestKeeper_CheckVerificationFlagsEnabled(t *testing.T) { k.SetBlockHeaderVerification(ctx, types.BlockHeaderVerification{ HeaderSupportedChains: []types.HeaderSupportedChain{ { - ChainId: chains.EthChain.ChainId, + ChainId: chains.Ethereum.ChainId, Enabled: false, }, }, }) - err := k.CheckBlockHeaderVerificationEnabled(ctx, chains.EthChain.ChainId) + err := k.CheckBlockHeaderVerificationEnabled(ctx, chains.Ethereum.ChainId) require.ErrorContains( t, err, - fmt.Sprintf("proof verification is disabled for chain %d", chains.EthChain.ChainId), + fmt.Sprintf("proof verification is disabled for chain %d", chains.Ethereum.ChainId), ) }) } 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 d4aca8a708..7edef4bf99 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 @@ -28,7 +28,7 @@ func TestMsgServer_DisableVerificationFlags(t *testing.T) { k.SetBlockHeaderVerification(ctx, types.BlockHeaderVerification{ HeaderSupportedChains: []types.HeaderSupportedChain{ { - ChainId: chains.EthChain.ChainId, + ChainId: chains.Ethereum.ChainId, Enabled: true, }, { @@ -42,12 +42,12 @@ func TestMsgServer_DisableVerificationFlags(t *testing.T) { keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupEmergency, true) _, err := srv.DisableHeaderVerification(sdk.WrapSDKContext(ctx), &types.MsgDisableHeaderVerification{ Creator: admin, - ChainIdList: []int64{chains.EthChain.ChainId, chains.BtcMainnetChain.ChainId}, + ChainIdList: []int64{chains.Ethereum.ChainId, chains.BtcMainnetChain.ChainId}, }) require.NoError(t, err) bhv, found := k.GetBlockHeaderVerification(ctx) require.True(t, found) - require.False(t, bhv.IsChainEnabled(chains.EthChain.ChainId)) + require.False(t, bhv.IsChainEnabled(chains.Ethereum.ChainId)) require.False(t, bhv.IsChainEnabled(chains.BtcMainnetChain.ChainId)) }) @@ -65,7 +65,7 @@ func TestMsgServer_DisableVerificationFlags(t *testing.T) { k.SetBlockHeaderVerification(ctx, types.BlockHeaderVerification{ HeaderSupportedChains: []types.HeaderSupportedChain{ { - ChainId: chains.EthChain.ChainId, + ChainId: chains.Ethereum.ChainId, Enabled: true, }, { @@ -78,7 +78,7 @@ func TestMsgServer_DisableVerificationFlags(t *testing.T) { keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupEmergency, false) _, err := srv.DisableHeaderVerification(sdk.WrapSDKContext(ctx), &types.MsgDisableHeaderVerification{ Creator: admin, - ChainIdList: []int64{chains.EthChain.ChainId}, + ChainIdList: []int64{chains.Ethereum.ChainId}, }) require.ErrorIs(t, err, authoritytypes.ErrUnauthorized) }) @@ -97,12 +97,12 @@ func TestMsgServer_DisableVerificationFlags(t *testing.T) { keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupEmergency, true) _, err := srv.DisableHeaderVerification(sdk.WrapSDKContext(ctx), &types.MsgDisableHeaderVerification{ Creator: admin, - ChainIdList: []int64{chains.EthChain.ChainId, chains.BtcMainnetChain.ChainId}, + ChainIdList: []int64{chains.Ethereum.ChainId, chains.BtcMainnetChain.ChainId}, }) require.NoError(t, err) bhv, found := k.GetBlockHeaderVerification(ctx) require.True(t, found) - require.False(t, bhv.IsChainEnabled(chains.EthChain.ChainId)) + require.False(t, bhv.IsChainEnabled(chains.Ethereum.ChainId)) require.False(t, bhv.IsChainEnabled(chains.BtcMainnetChain.ChainId)) }) } 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 90cd4d0974..bf71d40f0f 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 @@ -28,7 +28,7 @@ func TestMsgServer_EnableVerificationFlags(t *testing.T) { k.SetBlockHeaderVerification(ctx, types.BlockHeaderVerification{ HeaderSupportedChains: []types.HeaderSupportedChain{ { - ChainId: chains.EthChain.ChainId, + ChainId: chains.Ethereum.ChainId, Enabled: false, }, { @@ -42,12 +42,12 @@ func TestMsgServer_EnableVerificationFlags(t *testing.T) { keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupOperational, true) _, err := srv.EnableHeaderVerification(sdk.WrapSDKContext(ctx), &types.MsgEnableHeaderVerification{ Creator: admin, - ChainIdList: []int64{chains.EthChain.ChainId, chains.BtcMainnetChain.ChainId}, + ChainIdList: []int64{chains.Ethereum.ChainId, chains.BtcMainnetChain.ChainId}, }) require.NoError(t, err) bhv, found := k.GetBlockHeaderVerification(ctx) require.True(t, found) - require.True(t, bhv.IsChainEnabled(chains.EthChain.ChainId)) + require.True(t, bhv.IsChainEnabled(chains.Ethereum.ChainId)) require.True(t, bhv.IsChainEnabled(chains.BtcMainnetChain.ChainId)) }) @@ -65,12 +65,12 @@ func TestMsgServer_EnableVerificationFlags(t *testing.T) { keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupOperational, true) _, err := srv.EnableHeaderVerification(sdk.WrapSDKContext(ctx), &types.MsgEnableHeaderVerification{ Creator: admin, - ChainIdList: []int64{chains.EthChain.ChainId, chains.BtcMainnetChain.ChainId}, + ChainIdList: []int64{chains.Ethereum.ChainId, chains.BtcMainnetChain.ChainId}, }) require.NoError(t, err) bhv, found := k.GetBlockHeaderVerification(ctx) require.True(t, found) - require.True(t, bhv.IsChainEnabled(chains.EthChain.ChainId)) + require.True(t, bhv.IsChainEnabled(chains.Ethereum.ChainId)) require.True(t, bhv.IsChainEnabled(chains.BtcMainnetChain.ChainId)) }) @@ -87,7 +87,7 @@ func TestMsgServer_EnableVerificationFlags(t *testing.T) { k.SetBlockHeaderVerification(ctx, types.BlockHeaderVerification{ HeaderSupportedChains: []types.HeaderSupportedChain{ { - ChainId: chains.EthChain.ChainId, + ChainId: chains.Ethereum.ChainId, Enabled: false, }, { @@ -100,7 +100,7 @@ func TestMsgServer_EnableVerificationFlags(t *testing.T) { keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupOperational, false) _, err := srv.EnableHeaderVerification(sdk.WrapSDKContext(ctx), &types.MsgEnableHeaderVerification{ Creator: admin, - ChainIdList: []int64{chains.EthChain.ChainId}, + ChainIdList: []int64{chains.Ethereum.ChainId}, }) require.ErrorIs(t, err, authoritytypes.ErrUnauthorized) }) diff --git a/x/lightclient/keeper/proof_test.go b/x/lightclient/keeper/proof_test.go index c637a29827..3908b91688 100644 --- a/x/lightclient/keeper/proof_test.go +++ b/x/lightclient/keeper/proof_test.go @@ -43,7 +43,7 @@ func TestKeeper_VerifyProof(t *testing.T) { k.SetBlockHeaderVerification(ctx, types.BlockHeaderVerification{ HeaderSupportedChains: []types.HeaderSupportedChain{ { - ChainId: chains.EthChain.ChainId, + ChainId: chains.Ethereum.ChainId, Enabled: false, }, }, @@ -62,7 +62,7 @@ func TestKeeper_VerifyProof(t *testing.T) { Enabled: false, }, { - ChainId: chains.EthChain.ChainId, + ChainId: chains.Ethereum.ChainId, Enabled: false, }, }, @@ -86,7 +86,7 @@ func TestKeeper_VerifyProof(t *testing.T) { Enabled: true, }, { - ChainId: chains.EthChain.ChainId, + ChainId: chains.Ethereum.ChainId, Enabled: true, }, }, @@ -106,7 +106,7 @@ func TestKeeper_VerifyProof(t *testing.T) { Enabled: true, }, { - ChainId: chains.EthChain.ChainId, + ChainId: chains.Ethereum.ChainId, Enabled: true, }, }, @@ -128,7 +128,7 @@ func TestKeeper_VerifyProof(t *testing.T) { Enabled: true, }, { - ChainId: chains.EthChain.ChainId, + ChainId: chains.Ethereum.ChainId, Enabled: true, }, }, diff --git a/x/lightclient/types/genesis_test.go b/x/lightclient/types/genesis_test.go index bf3067a570..d09d73dc78 100644 --- a/x/lightclient/types/genesis_test.go +++ b/x/lightclient/types/genesis_test.go @@ -29,7 +29,7 @@ func TestGenesisState_Validate(t *testing.T) { sample.BlockHeader(sample.Hash().Bytes()), }, ChainStates: []types.ChainState{ - sample.ChainState(chains.EthChain.ChainId), + sample.ChainState(chains.Ethereum.ChainId), sample.ChainState(chains.BtcMainnetChain.ChainId), sample.ChainState(chains.BscMainnetChain.ChainId), }, @@ -56,8 +56,8 @@ 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.Ethereum.ChainId), + sample.ChainState(chains.Ethereum.ChainId), sample.ChainState(chains.BscMainnetChain.ChainId), }, }, diff --git a/x/lightclient/types/message_disable_verification_flags_test.go b/x/lightclient/types/message_disable_verification_flags_test.go index 8559d1d14a..8a9382dc49 100644 --- a/x/lightclient/types/message_disable_verification_flags_test.go +++ b/x/lightclient/types/message_disable_verification_flags_test.go @@ -69,7 +69,7 @@ func TestMsgDisableHeaderVerification_ValidateBasic(t *testing.T) { name: "valid address", msg: types.MsgDisableHeaderVerification{ Creator: sample.AccAddress(), - ChainIdList: []int64{chains.EthChain.ChainId}, + ChainIdList: []int64{chains.Ethereum.ChainId}, }, err: require.NoError, }, @@ -93,7 +93,7 @@ func TestMsgDisableHeaderVerification_GetSigners(t *testing.T) { name: "valid signer", msg: types.NewMsgDisableHeaderVerification( signer, - []int64{chains.EthChain.ChainId, chains.BtcMainnetChain.ChainId}, + []int64{chains.Ethereum.ChainId, chains.BtcMainnetChain.ChainId}, ), panics: false, }, @@ -101,7 +101,7 @@ func TestMsgDisableHeaderVerification_GetSigners(t *testing.T) { name: "invalid signer", msg: types.NewMsgDisableHeaderVerification( "invalid", - []int64{chains.EthChain.ChainId, chains.BtcMainnetChain.ChainId}, + []int64{chains.Ethereum.ChainId, chains.BtcMainnetChain.ChainId}, ), panics: true, }, diff --git a/x/lightclient/types/message_enable_verification_flags_test.go b/x/lightclient/types/message_enable_verification_flags_test.go index b598bfa440..423cd146ec 100644 --- a/x/lightclient/types/message_enable_verification_flags_test.go +++ b/x/lightclient/types/message_enable_verification_flags_test.go @@ -69,7 +69,7 @@ func TestMsgEnableHeaderVerification_ValidateBasic(t *testing.T) { name: "valid address", msg: types.MsgEnableHeaderVerification{ Creator: sample.AccAddress(), - ChainIdList: []int64{chains.EthChain.ChainId}, + ChainIdList: []int64{chains.Ethereum.ChainId}, }, err: require.NoError, }, @@ -93,7 +93,7 @@ func TestMsgEnableHeaderVerification_GetSigners(t *testing.T) { name: "valid signer", msg: types.NewMsgEnableHeaderVerification( signer, - []int64{chains.EthChain.ChainId, chains.BtcMainnetChain.ChainId}, + []int64{chains.Ethereum.ChainId, chains.BtcMainnetChain.ChainId}, ), panics: false, }, @@ -101,7 +101,7 @@ func TestMsgEnableHeaderVerification_GetSigners(t *testing.T) { name: "invalid signer", msg: types.NewMsgEnableHeaderVerification( "invalid", - []int64{chains.EthChain.ChainId, chains.BtcMainnetChain.ChainId}, + []int64{chains.Ethereum.ChainId, chains.BtcMainnetChain.ChainId}, ), panics: true, }, diff --git a/x/lightclient/types/verification_flags.go b/x/lightclient/types/verification_flags.go index b71c9cf55b..503f11d346 100644 --- a/x/lightclient/types/verification_flags.go +++ b/x/lightclient/types/verification_flags.go @@ -13,7 +13,7 @@ func DefaultBlockHeaderVerification() BlockHeaderVerification { func DefaultHeaderSupportedChains() []HeaderSupportedChain { return []HeaderSupportedChain{ { - ChainId: chains.EthChain.ChainId, + ChainId: chains.Ethereum.ChainId, Enabled: false, }, { diff --git a/x/lightclient/types/verification_flags_test.go b/x/lightclient/types/verification_flags_test.go index 9db0aa4951..f4f5b90fc8 100644 --- a/x/lightclient/types/verification_flags_test.go +++ b/x/lightclient/types/verification_flags_test.go @@ -13,7 +13,7 @@ func TestDefaultVerificationFlags(t *testing.T) { flags := DefaultHeaderSupportedChains() for _, f := range flags { switch f.ChainId { - case chains.EthChain.ChainId: + case chains.Ethereum.ChainId: require.False(t, f.Enabled) case chains.BscMainnetChain.ChainId: require.False(t, f.Enabled) diff --git a/x/observer/types/chain_params.go b/x/observer/types/chain_params.go index 3ce11dbbc5..c682ba1753 100644 --- a/x/observer/types/chain_params.go +++ b/x/observer/types/chain_params.go @@ -164,7 +164,7 @@ func GetDefaultChainParams() ChainParamsList { func GetDefaultEthMainnetChainParams() *ChainParams { return &ChainParams{ - ChainId: chains.EthChain.ChainId, + ChainId: chains.Ethereum.ChainId, ConfirmationCount: 14, ZetaTokenContractAddress: zeroAddress, ConnectorContractAddress: zeroAddress, diff --git a/zetaclient/chains/evm/observer/inbound_test.go b/zetaclient/chains/evm/observer/inbound_test.go index 21d372a4ce..906634e1ad 100644 --- a/zetaclient/chains/evm/observer/inbound_test.go +++ b/zetaclient/chains/evm/observer/inbound_test.go @@ -23,7 +23,7 @@ import ( func Test_CheckAndVoteInboundTokenZeta(t *testing.T) { // load archived ZetaSent inbound, receipt and cctx // https://etherscan.io/tx/0xf3935200c80f98502d5edc7e871ffc40ca898e134525c42c2ae3cbc5725f9d76 - chain := chains.EthChain + chain := chains.Ethereum confirmation := uint64(10) chainID := chain.ChainId chainParam := mocks.MockChainParams(chain.ChainId, confirmation) @@ -98,7 +98,7 @@ func Test_CheckAndVoteInboundTokenZeta(t *testing.T) { func Test_CheckAndVoteInboundTokenERC20(t *testing.T) { // load archived ERC20 inbound, receipt and cctx // https://etherscan.io/tx/0x4ea69a0e2ff36f7548ab75791c3b990e076e2a4bffeb616035b239b7d33843da - chain := chains.EthChain + chain := chains.Ethereum confirmation := uint64(10) chainID := chain.ChainId chainParam := mocks.MockChainParams(chain.ChainId, confirmation) @@ -173,7 +173,7 @@ func Test_CheckAndVoteInboundTokenERC20(t *testing.T) { func Test_CheckAndVoteInboundTokenGas(t *testing.T) { // load archived Gas inbound, receipt and cctx // https://etherscan.io/tx/0xeaec67d5dd5d85f27b21bef83e01cbdf59154fd793ea7a22c297f7c3a722c532 - chain := chains.EthChain + chain := chains.Ethereum confirmation := uint64(10) chainID := chain.ChainId chainParam := mocks.MockChainParams(chain.ChainId, confirmation) @@ -243,7 +243,7 @@ func Test_BuildInboundVoteMsgForZetaSentEvent(t *testing.T) { // load archived ZetaSent receipt // https://etherscan.io/tx/0xf3935200c80f98502d5edc7e871ffc40ca898e134525c42c2ae3cbc5725f9d76 chainID := int64(1) - chain := chains.EthChain + chain := chains.Ethereum inboundHash := "0xf3935200c80f98502d5edc7e871ffc40ca898e134525c42c2ae3cbc5725f9d76" receipt := testutils.LoadEVMInboundReceipt(t, TestDataDir, chainID, inboundHash, coin.CoinType_Zeta) cctx := testutils.LoadCctxByInbound(t, chainID, coin.CoinType_Zeta, inboundHash) @@ -289,7 +289,7 @@ func Test_BuildInboundVoteMsgForZetaSentEvent(t *testing.T) { func Test_BuildInboundVoteMsgForDepositedEvent(t *testing.T) { // load archived Deposited receipt // https://etherscan.io/tx/0x4ea69a0e2ff36f7548ab75791c3b990e076e2a4bffeb616035b239b7d33843da - chain := chains.EthChain + chain := chains.Ethereum chainID := chain.ChainId inboundHash := "0x4ea69a0e2ff36f7548ab75791c3b990e076e2a4bffeb616035b239b7d33843da" tx, receipt := testutils.LoadEVMInboundNReceipt(t, TestDataDir, chainID, inboundHash, coin.CoinType_ERC20) @@ -334,7 +334,7 @@ func Test_BuildInboundVoteMsgForDepositedEvent(t *testing.T) { func Test_BuildInboundVoteMsgForTokenSentToTSS(t *testing.T) { // load archived gas token transfer to TSS // https://etherscan.io/tx/0xeaec67d5dd5d85f27b21bef83e01cbdf59154fd793ea7a22c297f7c3a722c532 - chain := chains.EthChain + chain := chains.Ethereum chainID := chain.ChainId inboundHash := "0xeaec67d5dd5d85f27b21bef83e01cbdf59154fd793ea7a22c297f7c3a722c532" tx, receipt := testutils.LoadEVMInboundNReceipt(t, TestDataDir, chainID, inboundHash, coin.CoinType_Gas) @@ -401,7 +401,7 @@ func Test_BuildInboundVoteMsgForTokenSentToTSS(t *testing.T) { func Test_ObserveTSSReceiveInBlock(t *testing.T) { // https://etherscan.io/tx/0xeaec67d5dd5d85f27b21bef83e01cbdf59154fd793ea7a22c297f7c3a722c532 - chain := chains.EthChain + chain := chains.Ethereum chainID := chain.ChainId confirmation := uint64(1) chainParam := mocks.MockChainParams(chain.ChainId, confirmation) diff --git a/zetaclient/chains/evm/observer/outbound_test.go b/zetaclient/chains/evm/observer/outbound_test.go index d757938c46..542afcea81 100644 --- a/zetaclient/chains/evm/observer/outbound_test.go +++ b/zetaclient/chains/evm/observer/outbound_test.go @@ -34,8 +34,8 @@ func getContractsByChainID( func Test_IsOutboundProcessed(t *testing.T) { // load archived outbound receipt that contains ZetaReceived event // https://etherscan.io/tx/0x81342051b8a85072d3e3771c1a57c7bdb5318e8caf37f5a687b7a91e50a7257f - chain := chains.EthChain - chainID := chains.EthChain.ChainId + chain := chains.Ethereum + chainID := chains.Ethereum.ChainId nonce := uint64(9718) chainParam := mocks.MockChainParams(chain.ChainId, 1) outboundHash := "0x81342051b8a85072d3e3771c1a57c7bdb5318e8caf37f5a687b7a91e50a7257f" @@ -124,8 +124,8 @@ func Test_IsOutboundProcessed_ContractError(t *testing.T) { // load archived outbound receipt that contains ZetaReceived event // https://etherscan.io/tx/0x81342051b8a85072d3e3771c1a57c7bdb5318e8caf37f5a687b7a91e50a7257f - chain := chains.EthChain - chainID := chains.EthChain.ChainId + chain := chains.Ethereum + chainID := chains.Ethereum.ChainId nonce := uint64(9718) chainParam := mocks.MockChainParams(chain.ChainId, 1) outboundHash := "0x81342051b8a85072d3e3771c1a57c7bdb5318e8caf37f5a687b7a91e50a7257f" @@ -175,7 +175,7 @@ func Test_PostVoteOutbound(t *testing.T) { // Note: outbound of Gas/ERC20 token can also be used for this test // load archived cctx, outbound and receipt for a ZetaReceived event // https://etherscan.io/tx/0x81342051b8a85072d3e3771c1a57c7bdb5318e8caf37f5a687b7a91e50a7257f - chain := chains.EthChain + chain := chains.Ethereum nonce := uint64(9718) coinType := coin.CoinType_Zeta cctx, outbound, receipt := testutils.LoadEVMCctxNOutboundNReceipt( @@ -223,7 +223,7 @@ func Test_PostVoteOutbound(t *testing.T) { func Test_ParseZetaReceived(t *testing.T) { // load archived outbound receipt that contains ZetaReceived event // https://etherscan.io/tx/0x81342051b8a85072d3e3771c1a57c7bdb5318e8caf37f5a687b7a91e50a7257f - chainID := chains.EthChain.ChainId + chainID := chains.Ethereum.ChainId nonce := uint64(9718) outboundHash := "0x81342051b8a85072d3e3771c1a57c7bdb5318e8caf37f5a687b7a91e50a7257f" connector := mocks.MockConnectorNonEth(t, chainID) @@ -357,7 +357,7 @@ func Test_ParseZetaReverted(t *testing.T) { func Test_ParseERC20WithdrawnEvent(t *testing.T) { // load archived outbound receipt that contains ERC20 Withdrawn event - chainID := chains.EthChain.ChainId + chainID := chains.Ethereum.ChainId nonce := uint64(8014) outboundHash := "0xd2eba7ac3da1b62800165414ea4bcaf69a3b0fb9b13a0fc32f4be11bfef79146" custody := mocks.MockERC20Custody(t, chainID) @@ -427,7 +427,7 @@ func Test_ParseERC20WithdrawnEvent(t *testing.T) { } func Test_ParseOutboundReceivedValue(t *testing.T) { - chainID := chains.EthChain.ChainId + chainID := chains.Ethereum.ChainId connector, connectorAddr, custody, custodyAddr := getContractsByChainID(t, chainID) t.Run("should parse and check ZetaReceived event from archived outbound receipt", func(t *testing.T) { diff --git a/zetaclient/compliance/compliance_test.go b/zetaclient/compliance/compliance_test.go index 036ca3a7e1..0f587ceb20 100644 --- a/zetaclient/compliance/compliance_test.go +++ b/zetaclient/compliance/compliance_test.go @@ -13,7 +13,7 @@ import ( func TestCctxRestricted(t *testing.T) { // load archived cctx - chain := chains.EthChain + chain := chains.Ethereum cctx := testutils.LoadCctxByNonce(t, chain.ChainId, 6270) // create config diff --git a/zetaclient/config/config_chain.go b/zetaclient/config/config_chain.go index f8d0f0f069..856cf9faf9 100644 --- a/zetaclient/config/config_chain.go +++ b/zetaclient/config/config_chain.go @@ -36,8 +36,8 @@ var bitcoinConfigRegnet = BTCConfig{ } var evmChainsConfigs = map[int64]EVMConfig{ - chains.EthChain.ChainId: { - Chain: chains.EthChain, + chains.Ethereum.ChainId: { + Chain: chains.Ethereum, }, chains.BscMainnetChain.ChainId: { Chain: chains.BscMainnetChain, diff --git a/zetaclient/context/zetacore_context_test.go b/zetaclient/context/zetacore_context_test.go index 7e2b162e5f..a550000e0b 100644 --- a/zetaclient/context/zetacore_context_test.go +++ b/zetaclient/context/zetacore_context_test.go @@ -337,7 +337,7 @@ func TestUpdateZetacoreContext(t *testing.T) { func TestIsOutboundObservationEnabled(t *testing.T) { // create test chain params and flags - evmChain := chains.EthChain + evmChain := chains.Ethereum ccFlags := *sample.CrosschainFlags() verificationFlags := sample.HeaderSupportedChains() chainParams := &observertypes.ChainParams{ @@ -367,7 +367,7 @@ func TestIsOutboundObservationEnabled(t *testing.T) { func TestIsInboundObservationEnabled(t *testing.T) { // create test chain params and flags - evmChain := chains.EthChain + evmChain := chains.Ethereum ccFlags := *sample.CrosschainFlags() verificationFlags := sample.HeaderSupportedChains() chainParams := &observertypes.ChainParams{ diff --git a/zetaclient/orchestrator/orchestrator_test.go b/zetaclient/orchestrator/orchestrator_test.go index f4dcf1ffd0..03cf7d82a8 100644 --- a/zetaclient/orchestrator/orchestrator_test.go +++ b/zetaclient/orchestrator/orchestrator_test.go @@ -89,7 +89,7 @@ func CreateCoreContext( func Test_GetUpdatedSigner(t *testing.T) { // initial parameters for orchestrator creation - evmChain := chains.EthChain + evmChain := chains.Ethereum btcChain := chains.BtcMainnetChain evmChainParams := &observertypes.ChainParams{ ChainId: evmChain.ChainId, @@ -125,7 +125,7 @@ func Test_GetUpdatedSigner(t *testing.T) { func Test_GetUpdatedChainObserver(t *testing.T) { // initial parameters for orchestrator creation - evmChain := chains.EthChain + evmChain := chains.Ethereum btcChain := chains.BtcMainnetChain evmChainParams := &observertypes.ChainParams{ ChainId: evmChain.ChainId, @@ -206,7 +206,7 @@ func Test_GetUpdatedChainObserver(t *testing.T) { func Test_GetPendingCctxsWithinRatelimit(t *testing.T) { // define test foreign chains - ethChain := chains.EthChain + ethChain := chains.Ethereum btcChain := chains.BtcMainnetChain foreignChains := []chains.Chain{ ethChain, diff --git a/zetaclient/ratelimiter/rate_limiter_test.go b/zetaclient/ratelimiter/rate_limiter_test.go index c028b3c526..9dacddb22b 100644 --- a/zetaclient/ratelimiter/rate_limiter_test.go +++ b/zetaclient/ratelimiter/rate_limiter_test.go @@ -113,7 +113,7 @@ func Test_IsRateLimiterUsable(t *testing.T) { func Test_ApplyRateLimiter(t *testing.T) { // define test chain ids - ethChainID := chains.EthChain.ChainId + ethChainID := chains.Ethereum.ChainId btcChainID := chains.BtcMainnetChain.ChainId // create 10 missed and 90 pending cctxs for eth chain, the coinType/amount does not matter for this test diff --git a/zetaclient/zetacore/broadcast_test.go b/zetaclient/zetacore/broadcast_test.go index 1449fc87e6..ba86407811 100644 --- a/zetaclient/zetacore/broadcast_test.go +++ b/zetaclient/zetacore/broadcast_test.go @@ -82,7 +82,7 @@ func TestBroadcast(t *testing.T) { require.NoError(t, err) msg := observerTypes.NewMsgVoteBlockHeader( address.String(), - chains.EthChain.ChainId, + chains.Ethereum.ChainId, blockHash, 18495266, getHeaderData(t), @@ -101,7 +101,7 @@ func TestBroadcast(t *testing.T) { require.NoError(t, err) msg := observerTypes.NewMsgVoteBlockHeader( address.String(), - chains.EthChain.ChainId, + chains.Ethereum.ChainId, blockHash, 18495266, getHeaderData(t), diff --git a/zetaclient/zetacore/query_test.go b/zetaclient/zetacore/query_test.go index c98e5560c2..8934440f70 100644 --- a/zetaclient/zetacore/query_test.go +++ b/zetaclient/zetacore/query_test.go @@ -130,7 +130,7 @@ func TestZetacore_HeaderEnabledChains(t *testing.T) { expectedOutput := lightclienttypes.QueryHeaderEnabledChainsResponse{ HeaderEnabledChains: []lightclienttypes.HeaderSupportedChain{ { - ChainId: chains.EthChain.ChainId, + ChainId: chains.Ethereum.ChainId, Enabled: true, }, { @@ -797,11 +797,11 @@ func TestZetacore_GetPendingNoncesByChain(t *testing.T) { PendingNonces: observertypes.PendingNonces{ NonceLow: 0, NonceHigh: 0, - ChainId: chains.EthChain.ChainId, + ChainId: chains.Ethereum.ChainId, Tss: "", }, } - input := observertypes.QueryPendingNoncesByChainRequest{ChainId: chains.EthChain.ChainId} + input := observertypes.QueryPendingNoncesByChainRequest{ChainId: chains.Ethereum.ChainId} method := "/zetachain.zetacore.observer.Query/PendingNoncesByChain" server := setupMockServer(t, observertypes.RegisterQueryServer, method, input, expectedOutput) server.Serve() @@ -810,7 +810,7 @@ func TestZetacore_GetPendingNoncesByChain(t *testing.T) { client, err := setupZetacoreClient() require.NoError(t, err) - resp, err := client.GetPendingNoncesByChain(chains.EthChain.ChainId) + resp, err := client.GetPendingNoncesByChain(chains.Ethereum.ChainId) require.NoError(t, err) require.Equal(t, expectedOutput.PendingNonces, resp) } @@ -850,13 +850,13 @@ func TestZetacore_GetSupportedChains(t *testing.T) { IsExternal: chains.BscMainnetChain.IsExternal, }, { - ChainName: chains.EthChain.ChainName, - ChainId: chains.EthChain.ChainId, - Network: chains.EthChain.Network, - NetworkType: chains.EthChain.NetworkType, - Vm: chains.EthChain.Vm, - Consensus: chains.EthChain.Consensus, - IsExternal: chains.EthChain.IsExternal, + ChainName: chains.Ethereum.ChainName, + ChainId: chains.Ethereum.ChainId, + Network: chains.Ethereum.Network, + NetworkType: chains.Ethereum.NetworkType, + Vm: chains.Ethereum.Vm, + Consensus: chains.Ethereum.Consensus, + IsExternal: chains.Ethereum.IsExternal, }, }, } diff --git a/zetaclient/zetacore/tx_test.go b/zetaclient/zetacore/tx_test.go index 02a3b17ab8..32d1875e6c 100644 --- a/zetaclient/zetacore/tx_test.go +++ b/zetaclient/zetacore/tx_test.go @@ -258,13 +258,13 @@ func TestZetacore_UpdateZetacoreContext(t *testing.T) { chains.BscMainnetChain.IsExternal, }, { - chains.EthChain.ChainName, - chains.EthChain.ChainId, - chains.EthChain.Network, - chains.EthChain.NetworkType, - chains.EthChain.Vm, - chains.EthChain.Consensus, - chains.EthChain.IsExternal, + chains.Ethereum.ChainName, + chains.Ethereum.ChainId, + chains.Ethereum.Network, + chains.Ethereum.NetworkType, + chains.Ethereum.Vm, + chains.Ethereum.Consensus, + chains.Ethereum.IsExternal, }, }, }) @@ -310,7 +310,7 @@ func TestZetacore_UpdateZetacoreContext(t *testing.T) { WithPayload(lightclienttypes.QueryHeaderEnabledChainsRequest{}). Return(lightclienttypes.QueryHeaderEnabledChainsResponse{HeaderEnabledChains: []lightclienttypes.HeaderSupportedChain{ { - ChainId: chains.EthChain.ChainId, + ChainId: chains.Ethereum.ChainId, Enabled: true, }, { @@ -372,7 +372,7 @@ func TestZetacore_PostVoteBlockHeader(t *testing.T) { t.Run("post add block header success", func(t *testing.T) { zetacoreBroadcast = MockBroadcast hash, err := client.PostVoteBlockHeader( - chains.EthChain.ChainId, + chains.Ethereum.ChainId, blockHash, 18495266, getHeaderData(t), @@ -416,7 +416,7 @@ func TestZetacore_GetInBoundVoteMessage(t *testing.T) { zetacoreBroadcast = MockBroadcast msg := GetInBoundVoteMessage( address.String(), - chains.EthChain.ChainId, + chains.Ethereum.ChainId, "", address.String(), chains.ZetaChainMainnet.ChainId, @@ -477,7 +477,7 @@ func TestZetacore_PostVoteOutbound(t *testing.T) { 1200, big.NewInt(500), chains.ReceiveStatus_success, - chains.EthChain, + chains.Ethereum, 10001, coin.CoinType_Gas) require.NoError(t, err) From 1043aadad909429708cbe20659235a425ed16ae0 Mon Sep 17 00:00:00 2001 From: lumtis Date: Fri, 24 May 2024 10:18:15 +0200 Subject: [PATCH 04/22] bsc renaming --- pkg/chains/chain_test.go | 4 ++-- pkg/chains/chains.go | 6 ++--- pkg/chains/chains_test.go | 8 +++---- x/crosschain/keeper/abci_test.go | 4 ++-- x/crosschain/migrations/v5/migrate_test.go | 2 +- x/lightclient/genesis_test.go | 2 +- .../types/block_header_verification_test.go | 20 ++++++++-------- x/lightclient/types/genesis_test.go | 4 ++-- x/lightclient/types/verification_flags.go | 2 +- .../types/verification_flags_test.go | 2 +- x/observer/types/chain_params.go | 2 +- .../chains/evm/signer/outbound_data_test.go | 4 ++-- zetaclient/chains/evm/signer/signer.go | 2 +- zetaclient/chains/evm/signer/signer_test.go | 6 ++--- zetaclient/config/config_chain.go | 4 ++-- zetaclient/orchestrator/orchestrator_test.go | 4 ++-- zetaclient/zetacore/query_test.go | 24 +++++++++---------- zetaclient/zetacore/tx_test.go | 20 ++++++++-------- 18 files changed, 60 insertions(+), 60 deletions(-) diff --git a/pkg/chains/chain_test.go b/pkg/chains/chain_test.go index bc9b9213af..20767de092 100644 --- a/pkg/chains/chain_test.go +++ b/pkg/chains/chain_test.go @@ -196,7 +196,7 @@ func TestIsHeaderSupportedChain(t *testing.T) { {"Goerli Localnet", GoerliLocalnetChain.ChainId, true}, {"Sepolia Testnet", SepoliaChain.ChainId, true}, {"BSC Testnet", BscTestnetChain.ChainId, true}, - {"BSC Mainnet", BscMainnetChain.ChainId, true}, + {"BSC Mainnet", BscMainnet.ChainId, true}, {"BTC", BtcMainnetChain.ChainId, true}, {"Zeta Mainnet", ZetaChainMainnet.ChainId, false}, } @@ -216,7 +216,7 @@ func TestSupportMerkleProof(t *testing.T) { }{ {"Ethereum Mainnet", Ethereum, true}, {"BSC Testnet", BscTestnetChain, true}, - {"BSC Mainnet", BscMainnetChain, true}, + {"BSC Mainnet", BscMainnet, true}, {"Non-EVM", BtcMainnetChain, true}, {"Zeta Mainnet", ZetaChainMainnet, false}, } diff --git a/pkg/chains/chains.go b/pkg/chains/chains.go index b2ef6a0407..9651ff5323 100644 --- a/pkg/chains/chains.go +++ b/pkg/chains/chains.go @@ -29,8 +29,8 @@ var ( IsExternal: true, } - // BscMainnetChain is Binance Smart Chain mainnet - BscMainnetChain = Chain{ + // BscMainnet is Binance Smart Chain mainnet + BscMainnet = Chain{ ChainName: ChainName_bsc_mainnet, ChainId: 56, Network: Network_bsc, @@ -253,7 +253,7 @@ func BtcDustOffset() int64 { func DefaultChainsList() []*Chain { return chainListPointers([]Chain{ BtcMainnetChain, - BscMainnetChain, + BscMainnet, Ethereum, BtcTestNetChain, MumbaiChain, diff --git a/pkg/chains/chains_test.go b/pkg/chains/chains_test.go index 92d25d696b..c8c44fa2ac 100644 --- a/pkg/chains/chains_test.go +++ b/pkg/chains/chains_test.go @@ -18,7 +18,7 @@ func TestChainListByNetworkType(t *testing.T) { []*Chain{ &ZetaChainMainnet, &BtcMainnetChain, - &BscMainnetChain, + &BscMainnet, &Ethereum, &PolygonChain, &OptimismMainnet, @@ -82,7 +82,7 @@ func TestChainListByNetwork(t *testing.T) { { "Bsc", Network_bsc, - []*Chain{&BscMainnetChain, &BscTestnetChain}, + []*Chain{&BscMainnet, &BscTestnetChain}, }, { "Polygon", @@ -118,7 +118,7 @@ func TestChainListFunctions(t *testing.T) { DefaultChainsList, []*Chain{ &BtcMainnetChain, - &BscMainnetChain, + &BscMainnet, &Ethereum, &BtcTestNetChain, &MumbaiChain, @@ -144,7 +144,7 @@ func TestChainListFunctions(t *testing.T) { ExternalChainList, []*Chain{ &BtcMainnetChain, - &BscMainnetChain, + &BscMainnet, &Ethereum, &BtcTestNetChain, &MumbaiChain, diff --git a/x/crosschain/keeper/abci_test.go b/x/crosschain/keeper/abci_test.go index e390621978..62005d0ea1 100644 --- a/x/crosschain/keeper/abci_test.go +++ b/x/crosschain/keeper/abci_test.go @@ -45,7 +45,7 @@ func TestKeeper_IterateAndUpdateCctxGasPrice(t *testing.T) { supportedChains := []*chains.Chain{ {ChainId: chains.Ethereum.ChainId}, {ChainId: chains.BtcMainnetChain.ChainId}, - {ChainId: chains.BscMainnetChain.ChainId}, + {ChainId: chains.BscMainnet.ChainId}, {ChainId: chains.ZetaChainMainnet.ChainId}, } @@ -54,7 +54,7 @@ func TestKeeper_IterateAndUpdateCctxGasPrice(t *testing.T) { zk.ObserverKeeper.SetTSS(ctx, tss) createCctxWithNonceRange(t, ctx, *k, 10, 15, chains.Ethereum.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, 30, 35, chains.BscMainnet.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 diff --git a/x/crosschain/migrations/v5/migrate_test.go b/x/crosschain/migrations/v5/migrate_test.go index 872176388b..53ef1940cf 100644 --- a/x/crosschain/migrations/v5/migrate_test.go +++ b/x/crosschain/migrations/v5/migrate_test.go @@ -78,7 +78,7 @@ func TestResetTestnetNonce(t *testing.T) { chains.BscTestnetChain, chains.BtcTestNetChain, } - mainnetChains := []chains.Chain{chains.Ethereum, chains.BscMainnetChain, chains.BtcMainnetChain} + mainnetChains := []chains.Chain{chains.Ethereum, chains.BscMainnet, chains.BtcMainnetChain} nonceLow := int64(1) nonceHigh := int64(10) tss := sample.Tss() diff --git a/x/lightclient/genesis_test.go b/x/lightclient/genesis_test.go index 6b5d94fec8..e65c88968b 100644 --- a/x/lightclient/genesis_test.go +++ b/x/lightclient/genesis_test.go @@ -26,7 +26,7 @@ func TestGenesis(t *testing.T) { ChainStates: []types.ChainState{ sample.ChainState(chains.Ethereum.ChainId), sample.ChainState(chains.BtcMainnetChain.ChainId), - sample.ChainState(chains.BscMainnetChain.ChainId), + sample.ChainState(chains.BscMainnet.ChainId), }, } diff --git a/x/lightclient/types/block_header_verification_test.go b/x/lightclient/types/block_header_verification_test.go index 2bc71a92ef..01745c7e35 100644 --- a/x/lightclient/types/block_header_verification_test.go +++ b/x/lightclient/types/block_header_verification_test.go @@ -32,34 +32,34 @@ func TestBlockHeaderVerification_Validate(t *testing.T) { func TestBlockHeaderVerification_EnableChain(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)) + bhv.EnableChain(chains.BscMainnet.ChainId) + require.True(t, bhv.IsChainEnabled(chains.BscMainnet.ChainId)) }) t.Run("should not enable chain is present", func(t *testing.T) { bhv := types.BlockHeaderVerification{ HeaderSupportedChains: []types.HeaderSupportedChain{ - {ChainId: chains.BscMainnetChain.ChainId, Enabled: false}, + {ChainId: chains.BscMainnet.ChainId, Enabled: false}, }} - bhv.EnableChain(chains.BscMainnetChain.ChainId) - require.True(t, bhv.IsChainEnabled(chains.BscMainnetChain.ChainId)) + bhv.EnableChain(chains.BscMainnet.ChainId) + require.True(t, bhv.IsChainEnabled(chains.BscMainnet.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)) + bhv.DisableChain(chains.BscMainnet.ChainId) + require.False(t, bhv.IsChainEnabled(chains.BscMainnet.ChainId)) }) t.Run("should disable chain if chain present", func(t *testing.T) { bhv := types.BlockHeaderVerification{ HeaderSupportedChains: []types.HeaderSupportedChain{ - {ChainId: chains.BscMainnetChain.ChainId, Enabled: true}, + {ChainId: chains.BscMainnet.ChainId, Enabled: true}, }} - bhv.DisableChain(chains.BscMainnetChain.ChainId) - require.False(t, bhv.IsChainEnabled(chains.BscMainnetChain.ChainId)) + bhv.DisableChain(chains.BscMainnet.ChainId) + require.False(t, bhv.IsChainEnabled(chains.BscMainnet.ChainId)) }) } diff --git a/x/lightclient/types/genesis_test.go b/x/lightclient/types/genesis_test.go index d09d73dc78..5a367e46ac 100644 --- a/x/lightclient/types/genesis_test.go +++ b/x/lightclient/types/genesis_test.go @@ -31,7 +31,7 @@ func TestGenesisState_Validate(t *testing.T) { ChainStates: []types.ChainState{ sample.ChainState(chains.Ethereum.ChainId), sample.ChainState(chains.BtcMainnetChain.ChainId), - sample.ChainState(chains.BscMainnetChain.ChainId), + sample.ChainState(chains.BscMainnet.ChainId), }, }, valid: true, @@ -58,7 +58,7 @@ func TestGenesisState_Validate(t *testing.T) { ChainStates: []types.ChainState{ sample.ChainState(chains.Ethereum.ChainId), sample.ChainState(chains.Ethereum.ChainId), - sample.ChainState(chains.BscMainnetChain.ChainId), + sample.ChainState(chains.BscMainnet.ChainId), }, }, valid: false, diff --git a/x/lightclient/types/verification_flags.go b/x/lightclient/types/verification_flags.go index 503f11d346..a8a28e1367 100644 --- a/x/lightclient/types/verification_flags.go +++ b/x/lightclient/types/verification_flags.go @@ -17,7 +17,7 @@ func DefaultHeaderSupportedChains() []HeaderSupportedChain { Enabled: false, }, { - ChainId: chains.BscMainnetChain.ChainId, + ChainId: chains.BscMainnet.ChainId, Enabled: false, }, { diff --git a/x/lightclient/types/verification_flags_test.go b/x/lightclient/types/verification_flags_test.go index f4f5b90fc8..71f98b7a42 100644 --- a/x/lightclient/types/verification_flags_test.go +++ b/x/lightclient/types/verification_flags_test.go @@ -15,7 +15,7 @@ func TestDefaultVerificationFlags(t *testing.T) { switch f.ChainId { case chains.Ethereum.ChainId: require.False(t, f.Enabled) - case chains.BscMainnetChain.ChainId: + case chains.BscMainnet.ChainId: require.False(t, f.Enabled) case chains.SepoliaChain.ChainId: require.False(t, f.Enabled) diff --git a/x/observer/types/chain_params.go b/x/observer/types/chain_params.go index c682ba1753..e5000da455 100644 --- a/x/observer/types/chain_params.go +++ b/x/observer/types/chain_params.go @@ -182,7 +182,7 @@ func GetDefaultEthMainnetChainParams() *ChainParams { } func GetDefaultBscMainnetChainParams() *ChainParams { return &ChainParams{ - ChainId: chains.BscMainnetChain.ChainId, + ChainId: chains.BscMainnet.ChainId, ConfirmationCount: 14, ZetaTokenContractAddress: zeroAddress, ConnectorContractAddress: zeroAddress, diff --git a/zetaclient/chains/evm/signer/outbound_data_test.go b/zetaclient/chains/evm/signer/outbound_data_test.go index f3b5cd5ce5..77d0f9a040 100644 --- a/zetaclient/chains/evm/signer/outbound_data_test.go +++ b/zetaclient/chains/evm/signer/outbound_data_test.go @@ -52,14 +52,14 @@ func TestSigner_SetupGas(t *testing.T) { logger := zerolog.Logger{} t.Run("SetupGas_success", func(t *testing.T) { - chain := chains.BscMainnetChain + chain := chains.BscMainnet err := txData.SetupGas(cctx, logger, evmSigner.EvmClient(), &chain) require.NoError(t, err) }) t.Run("SetupGas_error", func(t *testing.T) { cctx.GetCurrentOutboundParam().GasPrice = "invalidGasPrice" - chain := chains.BscMainnetChain + chain := chains.BscMainnet err := txData.SetupGas(cctx, logger, evmSigner.EvmClient(), &chain) require.ErrorContains(t, err, "cannot convert gas price") }) diff --git a/zetaclient/chains/evm/signer/signer.go b/zetaclient/chains/evm/signer/signer.go index e4fb93bbda..8ab5608959 100644 --- a/zetaclient/chains/evm/signer/signer.go +++ b/zetaclient/chains/evm/signer/signer.go @@ -832,7 +832,7 @@ func (signer *Signer) reportToOutboundTracker( // 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 == mocks.EVMRPCEnabled { - chainID := big.NewInt(chains.BscMainnetChain.ChainId) + chainID := big.NewInt(chains.BscMainnet.ChainId) ethSigner := ethtypes.NewLondonSigner(chainID) client := &mocks.MockEvmClient{} return client, ethSigner, nil diff --git a/zetaclient/chains/evm/signer/signer_test.go b/zetaclient/chains/evm/signer/signer_test.go index 06998c61a8..6039c44803 100644 --- a/zetaclient/chains/evm/signer/signer_test.go +++ b/zetaclient/chains/evm/signer/signer_test.go @@ -36,7 +36,7 @@ func getNewEvmSigner() (*Signer, error) { ts := &metrics.TelemetryServer{} cfg := config.NewConfig() return NewSigner( - chains.BscMainnetChain, + chains.BscMainnet, mocks.EVMRPCEnabled, mocks.NewTSSMainnet(), config.GetConnectorABI(), @@ -54,8 +54,8 @@ func getNewEvmChainObserver() (*observer.Observer, error) { cfg := config.NewConfig() tss := mocks.NewTSSMainnet() - evmcfg := config.EVMConfig{Chain: chains.BscMainnetChain, Endpoint: "http://localhost:8545"} - cfg.EVMChainConfigs[chains.BscMainnetChain.ChainId] = evmcfg + evmcfg := config.EVMConfig{Chain: chains.BscMainnet, Endpoint: "http://localhost:8545"} + cfg.EVMChainConfigs[chains.BscMainnet.ChainId] = evmcfg coreCTX := context.NewZetacoreContext(cfg) appCTX := context.NewAppContext(coreCTX, cfg) diff --git a/zetaclient/config/config_chain.go b/zetaclient/config/config_chain.go index 856cf9faf9..b00040ea91 100644 --- a/zetaclient/config/config_chain.go +++ b/zetaclient/config/config_chain.go @@ -39,8 +39,8 @@ var evmChainsConfigs = map[int64]EVMConfig{ chains.Ethereum.ChainId: { Chain: chains.Ethereum, }, - chains.BscMainnetChain.ChainId: { - Chain: chains.BscMainnetChain, + chains.BscMainnet.ChainId: { + Chain: chains.BscMainnet, }, chains.GoerliChain.ChainId: { Chain: chains.GoerliChain, diff --git a/zetaclient/orchestrator/orchestrator_test.go b/zetaclient/orchestrator/orchestrator_test.go index 03cf7d82a8..b1a0434bc3 100644 --- a/zetaclient/orchestrator/orchestrator_test.go +++ b/zetaclient/orchestrator/orchestrator_test.go @@ -109,7 +109,7 @@ func Test_GetUpdatedSigner(t *testing.T) { orchestrator := MockOrchestrator(t, nil, evmChain, btcChain, evmChainParams, btcChainParams) context := CreateCoreContext(evmChain, btcChain, evmChainParamsNew, btcChainParams) // BSC signer should not be found - _, err := orchestrator.GetUpdatedSigner(context, chains.BscMainnetChain.ChainId) + _, err := orchestrator.GetUpdatedSigner(context, chains.BscMainnet.ChainId) require.ErrorContains(t, err, "signer not found") }) t.Run("should be able to update connector and erc20 custody address", func(t *testing.T) { @@ -174,7 +174,7 @@ func Test_GetUpdatedChainObserver(t *testing.T) { orchestrator := MockOrchestrator(t, nil, evmChain, btcChain, evmChainParams, btcChainParams) coreContext := CreateCoreContext(evmChain, btcChain, evmChainParamsNew, btcChainParams) // BSC chain observer should not be found - _, err := orchestrator.GetUpdatedChainObserver(coreContext, chains.BscMainnetChain.ChainId) + _, err := orchestrator.GetUpdatedChainObserver(coreContext, chains.BscMainnet.ChainId) require.ErrorContains(t, err, "chain observer not found") }) t.Run("chain params in evm chain observer should be updated successfully", func(t *testing.T) { diff --git a/zetaclient/zetacore/query_test.go b/zetaclient/zetacore/query_test.go index 8934440f70..2faad2918a 100644 --- a/zetaclient/zetacore/query_test.go +++ b/zetaclient/zetacore/query_test.go @@ -462,7 +462,7 @@ func TestZetacore_GetNodeInfo(t *testing.T) { } func TestZetacore_GetLastBlockHeightByChain(t *testing.T) { - index := chains.BscMainnetChain + index := chains.BscMainnet expectedOutput := crosschainTypes.QueryGetLastBlockHeightResponse{ LastBlockHeight: &crosschainTypes.LastBlockHeight{ Index: index.ChainName.String(), @@ -524,7 +524,7 @@ func TestZetacore_GetBaseGasPrice(t *testing.T) { } func TestZetacore_GetNonceByChain(t *testing.T) { - chain := chains.BscMainnetChain + chain := chains.BscMainnet expectedOutput := observertypes.QueryGetChainNoncesResponse{ ChainNonces: observertypes.ChainNonces{ Creator: "", @@ -614,7 +614,7 @@ func TestZetacore_GetBallotByID(t *testing.T) { } func TestZetacore_GetInboundTrackersForChain(t *testing.T) { - chainID := chains.BscMainnetChain.ChainId + chainID := chains.BscMainnet.ChainId expectedOutput := crosschainTypes.QueryAllInboundTrackerByChainResponse{ InboundTracker: []crosschainTypes.InboundTracker{ { @@ -727,7 +727,7 @@ func TestZetacore_GetTssHistory(t *testing.T) { } func TestZetacore_GetOutboundTracker(t *testing.T) { - chain := chains.BscMainnetChain + chain := chains.BscMainnet expectedOutput := crosschainTypes.QueryGetOutboundTrackerResponse{ OutboundTracker: crosschainTypes.OutboundTracker{ Index: "tracker12345", @@ -754,7 +754,7 @@ func TestZetacore_GetOutboundTracker(t *testing.T) { } func TestZetacore_GetAllOutboundTrackerByChain(t *testing.T) { - chain := chains.BscMainnetChain + chain := chains.BscMainnet expectedOutput := crosschainTypes.QueryAllOutboundTrackerByChainResponse{ OutboundTracker: []crosschainTypes.OutboundTracker{ { @@ -816,7 +816,7 @@ func TestZetacore_GetPendingNoncesByChain(t *testing.T) { } func TestZetacore_GetBlockHeaderChainState(t *testing.T) { - chainID := chains.BscMainnetChain.ChainId + chainID := chains.BscMainnet.ChainId expectedOutput := lightclienttypes.QueryGetChainStateResponse{ChainState: &lightclienttypes.ChainState{ ChainId: chainID, LatestHeight: 5566654, @@ -843,11 +843,11 @@ func TestZetacore_GetSupportedChains(t *testing.T) { { ChainName: chains.BtcMainnetChain.ChainName, ChainId: chains.BtcMainnetChain.ChainId, - Network: chains.BscMainnetChain.Network, - NetworkType: chains.BscMainnetChain.NetworkType, - Vm: chains.BscMainnetChain.Vm, - Consensus: chains.BscMainnetChain.Consensus, - IsExternal: chains.BscMainnetChain.IsExternal, + Network: chains.BscMainnet.Network, + NetworkType: chains.BscMainnet.NetworkType, + Vm: chains.BscMainnet.Vm, + Consensus: chains.BscMainnet.Consensus, + IsExternal: chains.BscMainnet.IsExternal, }, { ChainName: chains.Ethereum.ChainName, @@ -900,7 +900,7 @@ func TestZetacore_GetPendingNonces(t *testing.T) { } func TestZetacore_Prove(t *testing.T) { - chainId := chains.BscMainnetChain.ChainId + chainId := chains.BscMainnet.ChainId txHash := "9c8d02b6956b9c78ecb6090a8160faaa48e7aecfd0026fcdf533721d861436a3" blockHash := "0000000000000000000172c9a64f86f208b867a84dc7a0b7c75be51e750ed8eb" txIndex := 555 diff --git a/zetaclient/zetacore/tx_test.go b/zetaclient/zetacore/tx_test.go index 32d1875e6c..fd13e551d4 100644 --- a/zetaclient/zetacore/tx_test.go +++ b/zetaclient/zetacore/tx_test.go @@ -145,7 +145,7 @@ func TestZetacore_PostGasPrice(t *testing.T) { t.Run("post gas price success", func(t *testing.T) { zetacoreBroadcast = MockBroadcast - hash, err := client.PostGasPrice(chains.BscMainnetChain, 1000000, "100", 1234) + hash, err := client.PostGasPrice(chains.BscMainnet, 1000000, "100", 1234) require.NoError(t, err) require.Equal(t, sampleHash, hash) }) @@ -154,7 +154,7 @@ func TestZetacore_PostGasPrice(t *testing.T) { // //t.Run("post gas price fail", func(t *testing.T) { // zetacoreBroadcast = MockBroadcastError - // hash, err := client.PostGasPrice(chains.BscMainnetChain, 1000000, "100", 1234) + // hash, err := client.PostGasPrice(chains.BscMainnet, 1000000, "100", 1234) // require.ErrorContains(t, err, "post gasprice failed") // require.Equal(t, "", hash) //}) @@ -168,14 +168,14 @@ func TestZetacore_AddOutboundTracker(t *testing.T) { t.Run("add tx hash success", func(t *testing.T) { zetacoreBroadcast = MockBroadcast - hash, err := client.AddOutboundTracker(chains.BscMainnetChain.ChainId, 123, "", nil, "", 456) + hash, err := client.AddOutboundTracker(chains.BscMainnet.ChainId, 123, "", nil, "", 456) require.NoError(t, err) require.Equal(t, sampleHash, hash) }) t.Run("add tx hash fail", func(t *testing.T) { zetacoreBroadcast = MockBroadcastError - hash, err := client.AddOutboundTracker(chains.BscMainnetChain.ChainId, 123, "", nil, "", 456) + hash, err := client.AddOutboundTracker(chains.BscMainnet.ChainId, 123, "", nil, "", 456) require.Error(t, err) require.Equal(t, "", hash) }) @@ -251,11 +251,11 @@ func TestZetacore_UpdateZetacoreContext(t *testing.T) { { chains.BtcMainnetChain.ChainName, chains.BtcMainnetChain.ChainId, - chains.BscMainnetChain.Network, - chains.BscMainnetChain.NetworkType, - chains.BscMainnetChain.Vm, - chains.BscMainnetChain.Consensus, - chains.BscMainnetChain.IsExternal, + chains.BscMainnet.Network, + chains.BscMainnet.NetworkType, + chains.BscMainnet.Vm, + chains.BscMainnet.Consensus, + chains.BscMainnet.IsExternal, }, { chains.Ethereum.ChainName, @@ -353,7 +353,7 @@ func TestZetacore_PostBlameData(t *testing.T) { IsUnicast: false, BlameNodes: nil, }, - chains.BscMainnetChain.ChainId, + chains.BscMainnet.ChainId, "102394876-bsc", ) require.NoError(t, err) From 5bc632516b731558d739e1e1713fd217191de379 Mon Sep 17 00:00:00 2001 From: lumtis Date: Fri, 24 May 2024 10:19:22 +0200 Subject: [PATCH 05/22] Bitcoin renaming --- pkg/chains/address_test.go | 16 ++++++------ pkg/chains/bitcoin.go | 6 ++--- pkg/chains/bitcoin_test.go | 8 +++--- pkg/chains/chain_test.go | 12 ++++----- pkg/chains/chains.go | 6 ++--- pkg/chains/chains_test.go | 8 +++--- x/crosschain/keeper/abci_test.go | 4 +-- x/crosschain/keeper/evm_hooks_test.go | 18 ++++++------- x/crosschain/migrations/v4/migrate_test.go | 4 +-- x/crosschain/migrations/v5/migrate_test.go | 2 +- .../types/tx_body_verification_test.go | 2 +- x/crosschain/types/validate_test.go | 14 +++++----- x/lightclient/genesis_test.go | 2 +- .../keeper/block_header_verification_test.go | 10 +++---- ...disable_block_header_verification._test.go | 12 ++++----- ...r_enable_block_header_verification_test.go | 12 ++++----- x/lightclient/keeper/proof_test.go | 16 ++++++------ x/lightclient/types/genesis_test.go | 2 +- ...message_disable_verification_flags_test.go | 4 +-- .../message_enable_verification_flags_test.go | 4 +-- x/observer/types/chain_params.go | 2 +- .../types/message_vote_block_header_test.go | 2 +- zetaclient/chains/bitcoin/fee_test.go | 2 +- .../chains/bitcoin/observer/inbound_test.go | 8 +++--- .../chains/bitcoin/observer/observer_test.go | 2 +- .../chains/bitcoin/observer/outbound_test.go | 6 ++--- .../chains/bitcoin/signer/signer_test.go | 2 +- zetaclient/chains/bitcoin/tx_script_test.go | 26 +++++++++---------- zetaclient/orchestrator/orchestrator_test.go | 6 ++--- zetaclient/ratelimiter/rate_limiter_test.go | 2 +- zetaclient/testutils/mocks/tss_signer.go | 2 +- zetaclient/zetacore/query_test.go | 6 ++--- zetaclient/zetacore/tx_test.go | 6 ++--- 33 files changed, 117 insertions(+), 117 deletions(-) diff --git a/pkg/chains/address_test.go b/pkg/chains/address_test.go index ee974dcd69..8282fea22b 100644 --- a/pkg/chains/address_test.go +++ b/pkg/chains/address_test.go @@ -65,7 +65,7 @@ func TestDecodeBtcAddress(t *testing.T) { }) t.Run("valid legacy main-net address address correct params", func(t *testing.T) { - _, err := DecodeBtcAddress("1EYVvXLusCxtVuEwoYvWRyN5EZTXwPVvo3", BtcMainnetChain.ChainId) + _, err := DecodeBtcAddress("1EYVvXLusCxtVuEwoYvWRyN5EZTXwPVvo3", BitcoinMainnet.ChainId) require.NoError(t, err) }) t.Run("valid legacy testnet address with correct params", func(t *testing.T) { @@ -74,7 +74,7 @@ func TestDecodeBtcAddress(t *testing.T) { }) t.Run("non legacy valid address with incorrect params", func(t *testing.T) { - _, err := DecodeBtcAddress("bcrt1qy9pqmk2pd9sv63g27jt8r657wy0d9uee4x2dt2", BtcMainnetChain.ChainId) + _, err := DecodeBtcAddress("bcrt1qy9pqmk2pd9sv63g27jt8r657wy0d9uee4x2dt2", BitcoinMainnet.ChainId) require.ErrorContains(t, err, "not for network mainnet") }) t.Run("non legacy valid address with correct params", func(t *testing.T) { @@ -85,7 +85,7 @@ func TestDecodeBtcAddress(t *testing.T) { t.Run("taproot address with correct params", func(t *testing.T) { _, err := DecodeBtcAddress( "bc1p4ur084x8y63mj5hj7eydscuc4awals7ly749x8vhyquc0twcmvhquspa5c", - BtcMainnetChain.ChainId, + BitcoinMainnet.ChainId, ) require.NoError(t, err) }) @@ -109,7 +109,7 @@ func Test_IsBtcAddressSupported_P2TR(t *testing.T) { // https://mempool.space/tx/259fc21e63e138136c8f19270a0f7ca10039a66a474f91d23a17896f46e677a7 name: "mainnet taproot address", addr: "bc1p4scddlkkuw9486579autxumxmkvuphm5pz4jvf7f6pdh50p2uzqstawjt9", - chainId: BtcMainnetChain.ChainId, + chainId: BitcoinMainnet.ChainId, supported: true, }, { @@ -153,7 +153,7 @@ func Test_IsBtcAddressSupported_P2WSH(t *testing.T) { // https://mempool.space/tx/791bb9d16f7ab05f70a116d18eaf3552faf77b9d5688699a480261424b4f7e53 name: "mainnet P2WSH address", addr: "bc1qqv6pwn470vu0tssdfha4zdk89v3c8ch5lsnyy855k9hcrcv3evequdmjmc", - chainId: BtcMainnetChain.ChainId, + chainId: BitcoinMainnet.ChainId, supported: true, }, { @@ -196,7 +196,7 @@ func Test_IsBtcAddressSupported_P2WPKH(t *testing.T) { // https://mempool.space/tx/5d09d232bfe41c7cb831bf53fc2e4029ab33a99087fd5328a2331b52ff2ebe5b name: "mainnet P2WPKH address", addr: "bc1qaxf82vyzy8y80v000e7t64gpten7gawewzu42y", - chainId: BtcMainnetChain.ChainId, + chainId: BitcoinMainnet.ChainId, supported: true, }, { @@ -239,7 +239,7 @@ func Test_IsBtcAddressSupported_P2SH(t *testing.T) { // https://mempool.space/tx/fd68c8b4478686ca6f5ae4c28eaab055490650dbdaa6c2c8e380a7e075958a21 name: "mainnet P2SH address", addr: "327z4GyFM8Y8DiYfasGKQWhRK4MvyMSEgE", - chainId: BtcMainnetChain.ChainId, + chainId: BitcoinMainnet.ChainId, supported: true, }, { @@ -295,7 +295,7 @@ func Test_IsBtcAddressSupported_P2PKH(t *testing.T) { // https://mempool.space/tx/9c741de6e17382b7a9113fc811e3558981a35a360e3d1262a6675892c91322ca name: "mainnet P2PKH address 1", addr: "1FueivsE338W2LgifJ25HhTcVJ7CRT8kte", - chainId: BtcMainnetChain.ChainId, + chainId: BitcoinMainnet.ChainId, supported: true, }, { diff --git a/pkg/chains/bitcoin.go b/pkg/chains/bitcoin.go index 5edf9fe73e..634926e140 100644 --- a/pkg/chains/bitcoin.go +++ b/pkg/chains/bitcoin.go @@ -17,7 +17,7 @@ func BitcoinNetParamsFromChainID(chainID int64) (*chaincfg.Params, error) { switch chainID { case BtcRegtestChain.ChainId: return BitcoinRegnetParams, nil - case BtcMainnetChain.ChainId: + case BitcoinMainnet.ChainId: return BitcoinMainnetParams, nil case BtcTestNetChain.ChainId: return BitcoinTestnetParams, nil @@ -32,7 +32,7 @@ func BitcoinChainIDFromNetworkName(name string) (int64, error) { case BitcoinRegnetParams.Name: return BtcRegtestChain.ChainId, nil case BitcoinMainnetParams.Name: - return BtcMainnetChain.ChainId, nil + return BitcoinMainnet.ChainId, nil case BitcoinTestnetParams.Name: return BtcTestNetChain.ChainId, nil default: @@ -47,5 +47,5 @@ func IsBitcoinRegnet(chainID int64) bool { // IsBitcoinMainnet returns true if the chain id is for the mainnet func IsBitcoinMainnet(chainID int64) bool { - return chainID == BtcMainnetChain.ChainId + return chainID == BitcoinMainnet.ChainId } diff --git a/pkg/chains/bitcoin_test.go b/pkg/chains/bitcoin_test.go index ab7c11ff48..5a69d2b339 100644 --- a/pkg/chains/bitcoin_test.go +++ b/pkg/chains/bitcoin_test.go @@ -15,7 +15,7 @@ func TestBitcoinNetParamsFromChainID(t *testing.T) { wantErr bool }{ {"Regnet", BtcRegtestChain.ChainId, BitcoinRegnetParams, false}, - {"Mainnet", BtcMainnetChain.ChainId, BitcoinMainnetParams, false}, + {"Mainnet", BitcoinMainnet.ChainId, BitcoinMainnetParams, false}, {"Testnet", BtcTestNetChain.ChainId, BitcoinTestnetParams, false}, {"Unknown", -1, nil, true}, } @@ -41,7 +41,7 @@ func TestBitcoinChainIDFromNetParams(t *testing.T) { wantErr bool }{ {"Regnet", BitcoinRegnetParams.Name, BtcRegtestChain.ChainId, false}, - {"Mainnet", BitcoinMainnetParams.Name, BtcMainnetChain.ChainId, false}, + {"Mainnet", BitcoinMainnetParams.Name, BitcoinMainnet.ChainId, false}, {"Testnet", BitcoinTestnetParams.Name, BtcTestNetChain.ChainId, false}, {"Unknown", "Unknown", 0, true}, } @@ -62,12 +62,12 @@ func TestBitcoinChainIDFromNetParams(t *testing.T) { func TestIsBitcoinRegnet(t *testing.T) { require.True(t, IsBitcoinRegnet(BtcRegtestChain.ChainId)) - require.False(t, IsBitcoinRegnet(BtcMainnetChain.ChainId)) + require.False(t, IsBitcoinRegnet(BitcoinMainnet.ChainId)) require.False(t, IsBitcoinRegnet(BtcTestNetChain.ChainId)) } func TestIsBitcoinMainnet(t *testing.T) { - require.True(t, IsBitcoinMainnet(BtcMainnetChain.ChainId)) + require.True(t, IsBitcoinMainnet(BitcoinMainnet.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 20767de092..3b69283ffa 100644 --- a/pkg/chains/chain_test.go +++ b/pkg/chains/chain_test.go @@ -174,7 +174,7 @@ func TestIsEVMChain(t *testing.T) { {"Ethereum Mainnet", Ethereum.ChainId, true}, {"Goerli Testnet", GoerliChain.ChainId, true}, {"Sepolia Testnet", SepoliaChain.ChainId, true}, - {"Non-EVM", BtcMainnetChain.ChainId, false}, + {"Non-EVM", BitcoinMainnet.ChainId, false}, {"Zeta Mainnet", ZetaChainMainnet.ChainId, false}, } @@ -197,7 +197,7 @@ func TestIsHeaderSupportedChain(t *testing.T) { {"Sepolia Testnet", SepoliaChain.ChainId, true}, {"BSC Testnet", BscTestnetChain.ChainId, true}, {"BSC Mainnet", BscMainnet.ChainId, true}, - {"BTC", BtcMainnetChain.ChainId, true}, + {"BTC", BitcoinMainnet.ChainId, true}, {"Zeta Mainnet", ZetaChainMainnet.ChainId, false}, } @@ -217,7 +217,7 @@ func TestSupportMerkleProof(t *testing.T) { {"Ethereum Mainnet", Ethereum, true}, {"BSC Testnet", BscTestnetChain, true}, {"BSC Mainnet", BscMainnet, true}, - {"Non-EVM", BtcMainnetChain, true}, + {"Non-EVM", BitcoinMainnet, true}, {"Zeta Mainnet", ZetaChainMainnet, false}, } @@ -234,7 +234,7 @@ func TestIsBitcoinChain(t *testing.T) { chainID int64 want bool }{ - {"Bitcoin Mainnet", BtcMainnetChain.ChainId, true}, + {"Bitcoin Mainnet", BitcoinMainnet.ChainId, true}, {"Bitcoin Testnet", BtcTestNetChain.ChainId, true}, {"Bitcoin Regtest", BtcRegtestChain.ChainId, true}, {"Non-Bitcoin", Ethereum.ChainId, false}, @@ -257,7 +257,7 @@ func TestIsEthereumChain(t *testing.T) { {"Ethereum Mainnet", Ethereum.ChainId, true}, {"Goerli Testnet", GoerliChain.ChainId, true}, {"Sepolia Testnet", SepoliaChain.ChainId, true}, - {"Non-Ethereum", BtcMainnetChain.ChainId, false}, + {"Non-Ethereum", BitcoinMainnet.ChainId, false}, {"Zeta Mainnet", ZetaChainMainnet.ChainId, false}, } @@ -350,7 +350,7 @@ func TestGetChainFromChainID(t *testing.T) { } func TestGetBTCChainParams(t *testing.T) { - params, err := GetBTCChainParams(BtcMainnetChain.ChainId) + params, err := GetBTCChainParams(BitcoinMainnet.ChainId) require.NoError(t, err) require.Equal(t, &chaincfg.MainNetParams, params) diff --git a/pkg/chains/chains.go b/pkg/chains/chains.go index 9651ff5323..da13015bd9 100644 --- a/pkg/chains/chains.go +++ b/pkg/chains/chains.go @@ -40,8 +40,8 @@ var ( IsExternal: true, } - // BtcMainnetChain is Bitcoin mainnet - BtcMainnetChain = Chain{ + // BitcoinMainnet is Bitcoin mainnet + BitcoinMainnet = Chain{ ChainName: ChainName_btc_mainnet, ChainId: 8332, Network: Network_btc, @@ -252,7 +252,7 @@ func BtcDustOffset() int64 { // DefaultChainsList returns a list of default chains func DefaultChainsList() []*Chain { return chainListPointers([]Chain{ - BtcMainnetChain, + BitcoinMainnet, BscMainnet, Ethereum, BtcTestNetChain, diff --git a/pkg/chains/chains_test.go b/pkg/chains/chains_test.go index c8c44fa2ac..9a6f49d286 100644 --- a/pkg/chains/chains_test.go +++ b/pkg/chains/chains_test.go @@ -17,7 +17,7 @@ func TestChainListByNetworkType(t *testing.T) { NetworkType_mainnet, []*Chain{ &ZetaChainMainnet, - &BtcMainnetChain, + &BitcoinMainnet, &BscMainnet, &Ethereum, &PolygonChain, @@ -72,7 +72,7 @@ func TestChainListByNetwork(t *testing.T) { { "Btc", Network_btc, - []*Chain{&BtcMainnetChain, &BtcTestNetChain, &BtcRegtestChain}, + []*Chain{&BitcoinMainnet, &BtcTestNetChain, &BtcRegtestChain}, }, { "Eth", @@ -117,7 +117,7 @@ func TestChainListFunctions(t *testing.T) { "DefaultChainsList", DefaultChainsList, []*Chain{ - &BtcMainnetChain, + &BitcoinMainnet, &BscMainnet, &Ethereum, &BtcTestNetChain, @@ -143,7 +143,7 @@ func TestChainListFunctions(t *testing.T) { "ExternalChainList", ExternalChainList, []*Chain{ - &BtcMainnetChain, + &BitcoinMainnet, &BscMainnet, &Ethereum, &BtcTestNetChain, diff --git a/x/crosschain/keeper/abci_test.go b/x/crosschain/keeper/abci_test.go index 62005d0ea1..36736b254b 100644 --- a/x/crosschain/keeper/abci_test.go +++ b/x/crosschain/keeper/abci_test.go @@ -44,7 +44,7 @@ func TestKeeper_IterateAndUpdateCctxGasPrice(t *testing.T) { // add some evm and non-evm chains supportedChains := []*chains.Chain{ {ChainId: chains.Ethereum.ChainId}, - {ChainId: chains.BtcMainnetChain.ChainId}, + {ChainId: chains.BitcoinMainnet.ChainId}, {ChainId: chains.BscMainnet.ChainId}, {ChainId: chains.ZetaChainMainnet.ChainId}, } @@ -53,7 +53,7 @@ func TestKeeper_IterateAndUpdateCctxGasPrice(t *testing.T) { tss := sample.Tss() zk.ObserverKeeper.SetTSS(ctx, tss) createCctxWithNonceRange(t, ctx, *k, 10, 15, chains.Ethereum.ChainId, tss, zk) - createCctxWithNonceRange(t, ctx, *k, 20, 25, chains.BtcMainnetChain.ChainId, tss, zk) + createCctxWithNonceRange(t, ctx, *k, 20, 25, chains.BitcoinMainnet.ChainId, tss, zk) createCctxWithNonceRange(t, ctx, *k, 30, 35, chains.BscMainnet.ChainId, tss, zk) createCctxWithNonceRange(t, ctx, *k, 40, 45, chains.ZetaChainMainnet.ChainId, tss, zk) diff --git a/x/crosschain/keeper/evm_hooks_test.go b/x/crosschain/keeper/evm_hooks_test.go index eca45bd21e..9112aea3f6 100644 --- a/x/crosschain/keeper/evm_hooks_test.go +++ b/x/crosschain/keeper/evm_hooks_test.go @@ -160,7 +160,7 @@ func TestValidateZrc20WithdrawEvent(t *testing.T) { *sample.GetValidZRC20WithdrawToBTC(t).Logs[3], ) require.NoError(t, err) - err = crosschainkeeper.ValidateZrc20WithdrawEvent(btcMainNetWithdrawalEvent, chains.BtcMainnetChain.ChainId) + err = crosschainkeeper.ValidateZrc20WithdrawEvent(btcMainNetWithdrawalEvent, chains.BitcoinMainnet.ChainId) require.NoError(t, err) }) @@ -170,7 +170,7 @@ func TestValidateZrc20WithdrawEvent(t *testing.T) { ) require.NoError(t, err) btcMainNetWithdrawalEvent.Value = big.NewInt(0) - err = crosschainkeeper.ValidateZrc20WithdrawEvent(btcMainNetWithdrawalEvent, chains.BtcMainnetChain.ChainId) + err = crosschainkeeper.ValidateZrc20WithdrawEvent(btcMainNetWithdrawalEvent, chains.BitcoinMainnet.ChainId) require.ErrorContains(t, err, "ParseZRC20WithdrawalEvent: invalid amount") }) @@ -190,7 +190,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.BitcoinMainnet.ChainId) require.ErrorContains(t, err, "unsupported address") }) } @@ -200,7 +200,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.BitcoinMainnet chainID := chain.ChainId setSupportedChain(ctx, zk, chainID) SetupStateForProcessLogs(t, ctx, k, zk, sdkk, chain) @@ -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.BitcoinMainnet chainID := chain.ChainId setSupportedChain(ctx, zk, chainID) SetupStateForProcessLogs(t, ctx, k, zk, sdkk, chain) @@ -750,7 +750,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.BitcoinMainnet chainID := chain.ChainId setSupportedChain(ctx, zk, chainID) SetupStateForProcessLogs(t, ctx, k, zk, sdkk, chain) @@ -773,7 +773,7 @@ func TestKeeper_ProcessLogs(t *testing.T) { func(t *testing.T) { k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) - chain := chains.BtcMainnetChain + chain := chains.BitcoinMainnet chainID := chain.ChainId setSupportedChain(ctx, zk, chainID) SetupStateForProcessLogs(t, ctx, k, zk, sdkk, chain) @@ -795,7 +795,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.BitcoinMainnet chainID := chain.ChainId setSupportedChain(ctx, zk, chainID) SetupStateForProcessLogs(t, ctx, k, zk, sdkk, chain) @@ -841,7 +841,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.BitcoinMainnet chainID := chain.ChainId setSupportedChain(ctx, zk, chainID) SetupStateForProcessLogs(t, ctx, k, zk, sdkk, chain) diff --git a/x/crosschain/migrations/v4/migrate_test.go b/x/crosschain/migrations/v4/migrate_test.go index edf084bff5..0457c5520b 100644 --- a/x/crosschain/migrations/v4/migrate_test.go +++ b/x/crosschain/migrations/v4/migrate_test.go @@ -108,7 +108,7 @@ func TestSetBitcoinFinalizedInbound(t *testing.T) { k.SetCrossChainTx(ctx, types.CrossChainTx{ Index: "1", InboundParams: &types.InboundParams{ - SenderChainId: chains.BtcMainnetChain.ChainId, + SenderChainId: chains.BitcoinMainnet.ChainId, ObservedHash: "0x111", }, }) @@ -155,7 +155,7 @@ func TestSetBitcoinFinalizedInbound(t *testing.T) { require.False(t, k.IsFinalizedInbound(ctx, "0xaaa", chains.GoerliChain.ChainId, 0)) require.False(t, k.IsFinalizedInbound(ctx, "0xbbb", chains.Ethereum.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, "0x111", chains.BitcoinMainnet.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_test.go b/x/crosschain/migrations/v5/migrate_test.go index 53ef1940cf..091070009d 100644 --- a/x/crosschain/migrations/v5/migrate_test.go +++ b/x/crosschain/migrations/v5/migrate_test.go @@ -78,7 +78,7 @@ func TestResetTestnetNonce(t *testing.T) { chains.BscTestnetChain, chains.BtcTestNetChain, } - mainnetChains := []chains.Chain{chains.Ethereum, chains.BscMainnet, chains.BtcMainnetChain} + mainnetChains := []chains.Chain{chains.Ethereum, chains.BscMainnet, chains.BitcoinMainnet} nonceLow := int64(1) nonceHigh := int64(10) tss := sample.Tss() diff --git a/x/crosschain/types/tx_body_verification_test.go b/x/crosschain/types/tx_body_verification_test.go index cc051ac7ba..960c01d867 100644 --- a/x/crosschain/types/tx_body_verification_test.go +++ b/x/crosschain/types/tx_body_verification_test.go @@ -28,7 +28,7 @@ func TestVerifyInboundBody(t *testing.T) { { desc: "can't verify btc tx tx body", msg: types.MsgAddInboundTracker{ - ChainId: chains.BtcMainnetChain.ChainId, + ChainId: chains.BitcoinMainnet.ChainId, }, txBytes: sample.Bytes(), errContains: "cannot verify inbound body for chain", diff --git a/x/crosschain/types/validate_test.go b/x/crosschain/types/validate_test.go index 25c52518f3..957d3ab436 100644 --- a/x/crosschain/types/validate_test.go +++ b/x/crosschain/types/validate_test.go @@ -25,25 +25,25 @@ func TestValidateAddressForChain(t *testing.T) { t, types.ValidateAddressForChain( "bc1p4scddlkkuw9486579autxumxmkvuphm5pz4jvf7f6pdh50p2uzqstawjt9", - chains.BtcMainnetChain.ChainId, + chains.BitcoinMainnet.ChainId, ), ) require.NoError( t, - types.ValidateAddressForChain("327z4GyFM8Y8DiYfasGKQWhRK4MvyMSEgE", chains.BtcMainnetChain.ChainId), + types.ValidateAddressForChain("327z4GyFM8Y8DiYfasGKQWhRK4MvyMSEgE", chains.BitcoinMainnet.ChainId), ) require.NoError( t, - types.ValidateAddressForChain("1EYVvXLusCxtVuEwoYvWRyN5EZTXwPVvo3", chains.BtcMainnetChain.ChainId), + types.ValidateAddressForChain("1EYVvXLusCxtVuEwoYvWRyN5EZTXwPVvo3", chains.BitcoinMainnet.ChainId), ) require.Error( t, - types.ValidateAddressForChain("bcrt1qs758ursh4q9z627kt3pp5yysm78ddny6txaqgw", chains.BtcMainnetChain.ChainId), + types.ValidateAddressForChain("bcrt1qs758ursh4q9z627kt3pp5yysm78ddny6txaqgw", chains.BitcoinMainnet.ChainId), ) require.Error(t, types.ValidateAddressForChain("", chains.BtcRegtestChain.ChainId)) require.NoError( t, - types.ValidateAddressForChain("bc1qysd4sp9q8my59ul9wsf5rvs9p387hf8vfwatzu", chains.BtcMainnetChain.ChainId), + types.ValidateAddressForChain("bc1qysd4sp9q8my59ul9wsf5rvs9p387hf8vfwatzu", chains.BitcoinMainnet.ChainId), ) require.NoError( t, @@ -88,7 +88,7 @@ func TestValidateHashForChain(t *testing.T) { t, types.ValidateHashForChain( "15b7880f5d236e857a5e8f043ce9d56f5ef01e1c3f2a786baf740fc0bb7a22a3", - chains.BtcMainnetChain.ChainId, + chains.BitcoinMainnet.ChainId, ), ) require.NoError( @@ -102,7 +102,7 @@ func TestValidateHashForChain(t *testing.T) { t, types.ValidateHashForChain( "0x84bd5c9922b63c52d8a9ca686e0a57ff978150b71be0583514d01c27aa341910", - chains.BtcMainnetChain.ChainId, + chains.BitcoinMainnet.ChainId, ), ) } diff --git a/x/lightclient/genesis_test.go b/x/lightclient/genesis_test.go index e65c88968b..69409ec911 100644 --- a/x/lightclient/genesis_test.go +++ b/x/lightclient/genesis_test.go @@ -25,7 +25,7 @@ func TestGenesis(t *testing.T) { }, ChainStates: []types.ChainState{ sample.ChainState(chains.Ethereum.ChainId), - sample.ChainState(chains.BtcMainnetChain.ChainId), + sample.ChainState(chains.BitcoinMainnet.ChainId), sample.ChainState(chains.BscMainnet.ChainId), }, } diff --git a/x/lightclient/keeper/block_header_verification_test.go b/x/lightclient/keeper/block_header_verification_test.go index 6714153349..4ca08a224e 100644 --- a/x/lightclient/keeper/block_header_verification_test.go +++ b/x/lightclient/keeper/block_header_verification_test.go @@ -51,12 +51,12 @@ func TestKeeper_CheckVerificationFlagsEnabled(t *testing.T) { err := k.CheckBlockHeaderVerificationEnabled(ctx, chains.Ethereum.ChainId) require.NoError(t, err) - err = k.CheckBlockHeaderVerificationEnabled(ctx, chains.BtcMainnetChain.ChainId) + err = k.CheckBlockHeaderVerificationEnabled(ctx, chains.BitcoinMainnet.ChainId) require.Error(t, err) require.ErrorContains( t, err, - fmt.Sprintf("proof verification is disabled for chain %d", chains.BtcMainnetChain.ChainId), + fmt.Sprintf("proof verification is disabled for chain %d", chains.BitcoinMainnet.ChainId), ) err = k.CheckBlockHeaderVerificationEnabled(ctx, 1000) @@ -69,7 +69,7 @@ func TestKeeper_CheckVerificationFlagsEnabled(t *testing.T) { k.SetBlockHeaderVerification(ctx, types.BlockHeaderVerification{ HeaderSupportedChains: []types.HeaderSupportedChain{ { - ChainId: chains.BtcMainnetChain.ChainId, + ChainId: chains.BitcoinMainnet.ChainId, Enabled: true, }, }, @@ -83,7 +83,7 @@ func TestKeeper_CheckVerificationFlagsEnabled(t *testing.T) { fmt.Sprintf("proof verification is disabled for chain %d", chains.Ethereum.ChainId), ) - err = k.CheckBlockHeaderVerificationEnabled(ctx, chains.BtcMainnetChain.ChainId) + err = k.CheckBlockHeaderVerificationEnabled(ctx, chains.BitcoinMainnet.ChainId) require.NoError(t, err) err = k.CheckBlockHeaderVerificationEnabled(ctx, 1000) @@ -96,7 +96,7 @@ func TestKeeper_CheckVerificationFlagsEnabled(t *testing.T) { err := k.CheckBlockHeaderVerificationEnabled(ctx, chains.Ethereum.ChainId) require.ErrorContains(t, err, "proof verification is disabled for all chains") - err = k.CheckBlockHeaderVerificationEnabled(ctx, chains.BtcMainnetChain.ChainId) + err = k.CheckBlockHeaderVerificationEnabled(ctx, chains.BitcoinMainnet.ChainId) require.ErrorContains(t, err, "proof verification is disabled for all chains") }) 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 7edef4bf99..bfb300a344 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 @@ -32,7 +32,7 @@ func TestMsgServer_DisableVerificationFlags(t *testing.T) { Enabled: true, }, { - ChainId: chains.BtcMainnetChain.ChainId, + ChainId: chains.BitcoinMainnet.ChainId, Enabled: true, }, }, @@ -42,13 +42,13 @@ func TestMsgServer_DisableVerificationFlags(t *testing.T) { keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupEmergency, true) _, err := srv.DisableHeaderVerification(sdk.WrapSDKContext(ctx), &types.MsgDisableHeaderVerification{ Creator: admin, - ChainIdList: []int64{chains.Ethereum.ChainId, chains.BtcMainnetChain.ChainId}, + ChainIdList: []int64{chains.Ethereum.ChainId, chains.BitcoinMainnet.ChainId}, }) require.NoError(t, err) bhv, found := k.GetBlockHeaderVerification(ctx) require.True(t, found) require.False(t, bhv.IsChainEnabled(chains.Ethereum.ChainId)) - require.False(t, bhv.IsChainEnabled(chains.BtcMainnetChain.ChainId)) + require.False(t, bhv.IsChainEnabled(chains.BitcoinMainnet.ChainId)) }) @@ -69,7 +69,7 @@ func TestMsgServer_DisableVerificationFlags(t *testing.T) { Enabled: true, }, { - ChainId: chains.BtcMainnetChain.ChainId, + ChainId: chains.BitcoinMainnet.ChainId, Enabled: true, }, }, @@ -97,12 +97,12 @@ func TestMsgServer_DisableVerificationFlags(t *testing.T) { keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupEmergency, true) _, err := srv.DisableHeaderVerification(sdk.WrapSDKContext(ctx), &types.MsgDisableHeaderVerification{ Creator: admin, - ChainIdList: []int64{chains.Ethereum.ChainId, chains.BtcMainnetChain.ChainId}, + ChainIdList: []int64{chains.Ethereum.ChainId, chains.BitcoinMainnet.ChainId}, }) require.NoError(t, err) bhv, found := k.GetBlockHeaderVerification(ctx) require.True(t, found) require.False(t, bhv.IsChainEnabled(chains.Ethereum.ChainId)) - require.False(t, bhv.IsChainEnabled(chains.BtcMainnetChain.ChainId)) + require.False(t, bhv.IsChainEnabled(chains.BitcoinMainnet.ChainId)) }) } 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 bf71d40f0f..2025904b9a 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 @@ -32,7 +32,7 @@ func TestMsgServer_EnableVerificationFlags(t *testing.T) { Enabled: false, }, { - ChainId: chains.BtcMainnetChain.ChainId, + ChainId: chains.BitcoinMainnet.ChainId, Enabled: false, }, }, @@ -42,13 +42,13 @@ func TestMsgServer_EnableVerificationFlags(t *testing.T) { keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupOperational, true) _, err := srv.EnableHeaderVerification(sdk.WrapSDKContext(ctx), &types.MsgEnableHeaderVerification{ Creator: admin, - ChainIdList: []int64{chains.Ethereum.ChainId, chains.BtcMainnetChain.ChainId}, + ChainIdList: []int64{chains.Ethereum.ChainId, chains.BitcoinMainnet.ChainId}, }) require.NoError(t, err) bhv, found := k.GetBlockHeaderVerification(ctx) require.True(t, found) require.True(t, bhv.IsChainEnabled(chains.Ethereum.ChainId)) - require.True(t, bhv.IsChainEnabled(chains.BtcMainnetChain.ChainId)) + require.True(t, bhv.IsChainEnabled(chains.BitcoinMainnet.ChainId)) }) t.Run("enable verification flags even if the chain has not been set previously", func(t *testing.T) { @@ -65,13 +65,13 @@ func TestMsgServer_EnableVerificationFlags(t *testing.T) { keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupOperational, true) _, err := srv.EnableHeaderVerification(sdk.WrapSDKContext(ctx), &types.MsgEnableHeaderVerification{ Creator: admin, - ChainIdList: []int64{chains.Ethereum.ChainId, chains.BtcMainnetChain.ChainId}, + ChainIdList: []int64{chains.Ethereum.ChainId, chains.BitcoinMainnet.ChainId}, }) require.NoError(t, err) bhv, found := k.GetBlockHeaderVerification(ctx) require.True(t, found) require.True(t, bhv.IsChainEnabled(chains.Ethereum.ChainId)) - require.True(t, bhv.IsChainEnabled(chains.BtcMainnetChain.ChainId)) + require.True(t, bhv.IsChainEnabled(chains.BitcoinMainnet.ChainId)) }) t.Run("cannot update if not authorized group", func(t *testing.T) { @@ -91,7 +91,7 @@ func TestMsgServer_EnableVerificationFlags(t *testing.T) { Enabled: false, }, { - ChainId: chains.BtcMainnetChain.ChainId, + ChainId: chains.BitcoinMainnet.ChainId, Enabled: false, }, }, diff --git a/x/lightclient/keeper/proof_test.go b/x/lightclient/keeper/proof_test.go index 3908b91688..1f80d28100 100644 --- a/x/lightclient/keeper/proof_test.go +++ b/x/lightclient/keeper/proof_test.go @@ -27,13 +27,13 @@ func TestKeeper_VerifyProof(t *testing.T) { k.SetBlockHeaderVerification(ctx, types.BlockHeaderVerification{ HeaderSupportedChains: []types.HeaderSupportedChain{ { - ChainId: chains.BtcMainnetChain.ChainId, + ChainId: chains.BitcoinMainnet.ChainId, Enabled: false, }, }, }) - _, err := k.VerifyProof(ctx, &proofs.Proof{}, chains.BtcMainnetChain.ChainId, sample.Hash().String(), 1) + _, err := k.VerifyProof(ctx, &proofs.Proof{}, chains.BitcoinMainnet.ChainId, sample.Hash().String(), 1) require.ErrorIs(t, err, types.ErrBlockHeaderVerificationDisabled) }) @@ -58,7 +58,7 @@ func TestKeeper_VerifyProof(t *testing.T) { k.SetBlockHeaderVerification(ctx, types.BlockHeaderVerification{ HeaderSupportedChains: []types.HeaderSupportedChain{ { - ChainId: chains.BtcMainnetChain.ChainId, + ChainId: chains.BitcoinMainnet.ChainId, Enabled: false, }, { @@ -82,7 +82,7 @@ func TestKeeper_VerifyProof(t *testing.T) { k.SetBlockHeaderVerification(ctx, types.BlockHeaderVerification{ HeaderSupportedChains: []types.HeaderSupportedChain{ { - ChainId: chains.BtcMainnetChain.ChainId, + ChainId: chains.BitcoinMainnet.ChainId, Enabled: true, }, { @@ -92,7 +92,7 @@ func TestKeeper_VerifyProof(t *testing.T) { }, }) - _, err := k.VerifyProof(ctx, &proofs.Proof{}, chains.BtcMainnetChain.ChainId, "invalid", 1) + _, err := k.VerifyProof(ctx, &proofs.Proof{}, chains.BitcoinMainnet.ChainId, "invalid", 1) require.ErrorIs(t, err, types.ErrInvalidBlockHash) }) @@ -102,7 +102,7 @@ func TestKeeper_VerifyProof(t *testing.T) { k.SetBlockHeaderVerification(ctx, types.BlockHeaderVerification{ HeaderSupportedChains: []types.HeaderSupportedChain{ { - ChainId: chains.BtcMainnetChain.ChainId, + ChainId: chains.BitcoinMainnet.ChainId, Enabled: true, }, { @@ -124,7 +124,7 @@ func TestKeeper_VerifyProof(t *testing.T) { k.SetBlockHeaderVerification(ctx, types.BlockHeaderVerification{ HeaderSupportedChains: []types.HeaderSupportedChain{ { - ChainId: chains.BtcMainnetChain.ChainId, + ChainId: chains.BitcoinMainnet.ChainId, Enabled: true, }, { @@ -149,7 +149,7 @@ func TestKeeper_VerifyProof(t *testing.T) { k.SetBlockHeaderVerification(ctx, types.BlockHeaderVerification{ HeaderSupportedChains: []types.HeaderSupportedChain{ { - ChainId: chains.BtcMainnetChain.ChainId, + ChainId: chains.BitcoinMainnet.ChainId, Enabled: true, }, { diff --git a/x/lightclient/types/genesis_test.go b/x/lightclient/types/genesis_test.go index 5a367e46ac..74ec63b21c 100644 --- a/x/lightclient/types/genesis_test.go +++ b/x/lightclient/types/genesis_test.go @@ -30,7 +30,7 @@ func TestGenesisState_Validate(t *testing.T) { }, ChainStates: []types.ChainState{ sample.ChainState(chains.Ethereum.ChainId), - sample.ChainState(chains.BtcMainnetChain.ChainId), + sample.ChainState(chains.BitcoinMainnet.ChainId), sample.ChainState(chains.BscMainnet.ChainId), }, }, diff --git a/x/lightclient/types/message_disable_verification_flags_test.go b/x/lightclient/types/message_disable_verification_flags_test.go index 8a9382dc49..06f173ff4e 100644 --- a/x/lightclient/types/message_disable_verification_flags_test.go +++ b/x/lightclient/types/message_disable_verification_flags_test.go @@ -93,7 +93,7 @@ func TestMsgDisableHeaderVerification_GetSigners(t *testing.T) { name: "valid signer", msg: types.NewMsgDisableHeaderVerification( signer, - []int64{chains.Ethereum.ChainId, chains.BtcMainnetChain.ChainId}, + []int64{chains.Ethereum.ChainId, chains.BitcoinMainnet.ChainId}, ), panics: false, }, @@ -101,7 +101,7 @@ func TestMsgDisableHeaderVerification_GetSigners(t *testing.T) { name: "invalid signer", msg: types.NewMsgDisableHeaderVerification( "invalid", - []int64{chains.Ethereum.ChainId, chains.BtcMainnetChain.ChainId}, + []int64{chains.Ethereum.ChainId, chains.BitcoinMainnet.ChainId}, ), panics: true, }, diff --git a/x/lightclient/types/message_enable_verification_flags_test.go b/x/lightclient/types/message_enable_verification_flags_test.go index 423cd146ec..8062681984 100644 --- a/x/lightclient/types/message_enable_verification_flags_test.go +++ b/x/lightclient/types/message_enable_verification_flags_test.go @@ -93,7 +93,7 @@ func TestMsgEnableHeaderVerification_GetSigners(t *testing.T) { name: "valid signer", msg: types.NewMsgEnableHeaderVerification( signer, - []int64{chains.Ethereum.ChainId, chains.BtcMainnetChain.ChainId}, + []int64{chains.Ethereum.ChainId, chains.BitcoinMainnet.ChainId}, ), panics: false, }, @@ -101,7 +101,7 @@ func TestMsgEnableHeaderVerification_GetSigners(t *testing.T) { name: "invalid signer", msg: types.NewMsgEnableHeaderVerification( "invalid", - []int64{chains.Ethereum.ChainId, chains.BtcMainnetChain.ChainId}, + []int64{chains.Ethereum.ChainId, chains.BitcoinMainnet.ChainId}, ), panics: true, }, diff --git a/x/observer/types/chain_params.go b/x/observer/types/chain_params.go index e5000da455..831a191897 100644 --- a/x/observer/types/chain_params.go +++ b/x/observer/types/chain_params.go @@ -200,7 +200,7 @@ func GetDefaultBscMainnetChainParams() *ChainParams { } func GetDefaultBtcMainnetChainParams() *ChainParams { return &ChainParams{ - ChainId: chains.BtcMainnetChain.ChainId, + ChainId: chains.BitcoinMainnet.ChainId, ConfirmationCount: 2, ZetaTokenContractAddress: zeroAddress, ConnectorContractAddress: zeroAddress, diff --git a/x/observer/types/message_vote_block_header_test.go b/x/observer/types/message_vote_block_header_test.go index 5b03a99041..192d164d43 100644 --- a/x/observer/types/message_vote_block_header_test.go +++ b/x/observer/types/message_vote_block_header_test.go @@ -63,7 +63,7 @@ func TestMsgVoteBlockHeader_ValidateBasic(t *testing.T) { name: "bitcoin chain id", msg: types.NewMsgVoteBlockHeader( sample.AccAddress(), - chains.BtcMainnetChain.ChainId, + chains.BitcoinMainnet.ChainId, []byte{}, 6, proofs.HeaderData{}, diff --git a/zetaclient/chains/bitcoin/fee_test.go b/zetaclient/chains/bitcoin/fee_test.go index cc2ab07386..bb6757ede2 100644 --- a/zetaclient/chains/bitcoin/fee_test.go +++ b/zetaclient/chains/bitcoin/fee_test.go @@ -72,7 +72,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.BitcoinMainnet inputAddress, found := testAddressMap[scriptType] require.True(t, found) address, err := chains.DecodeBtcAddress(inputAddress, chain.ChainId) diff --git a/zetaclient/chains/bitcoin/observer/inbound_test.go b/zetaclient/chains/bitcoin/observer/inbound_test.go index de27d6e1f3..b67b7d7b50 100644 --- a/zetaclient/chains/bitcoin/observer/inbound_test.go +++ b/zetaclient/chains/bitcoin/observer/inbound_test.go @@ -187,7 +187,7 @@ func TestCalcDepositorFee828440(t *testing.T) { } func TestGetSenderAddressByVin(t *testing.T) { - chain := chains.BtcMainnetChain + chain := chains.BitcoinMainnet net := &chaincfg.MainNetParams t.Run("should get sender address from P2TR tx", func(t *testing.T) { @@ -281,7 +281,7 @@ func TestGetSenderAddressByVin(t *testing.T) { func TestGetSenderAddressByVinErrors(t *testing.T) { // https://mempool.space/tx/3618e869f9e87863c0f1cc46dbbaa8b767b4a5d6d60b143c2c50af52b257e867 txHash := "3618e869f9e87863c0f1cc46dbbaa8b767b4a5d6d60b143c2c50af52b257e867" - chain := chains.BtcMainnetChain + chain := chains.BitcoinMainnet net := &chaincfg.MainNetParams t.Run("should get sender address from P2TR tx", func(t *testing.T) { @@ -315,7 +315,7 @@ func TestGetBtcEvent(t *testing.T) { // load archived inbound P2WPKH raw result // https://mempool.space/tx/847139aa65aa4a5ee896375951cbf7417cfc8a4d6f277ec11f40cd87319f04aa txHash := "847139aa65aa4a5ee896375951cbf7417cfc8a4d6f277ec11f40cd87319f04aa" - chain := chains.BtcMainnetChain + chain := chains.BitcoinMainnet // GetBtcEvent arguments tx := testutils.LoadBTCInboundRawResult(t, TestDataDir, chain.ChainId, txHash, false) @@ -489,7 +489,7 @@ func TestGetBtcEventErrors(t *testing.T) { // load archived inbound P2WPKH raw result // https://mempool.space/tx/847139aa65aa4a5ee896375951cbf7417cfc8a4d6f277ec11f40cd87319f04aa txHash := "847139aa65aa4a5ee896375951cbf7417cfc8a4d6f277ec11f40cd87319f04aa" - chain := chains.BtcMainnetChain + chain := chains.BitcoinMainnet net := &chaincfg.MainNetParams tssAddress := testutils.TSSAddressBTCMainnet blockNumber := uint64(835640) diff --git a/zetaclient/chains/bitcoin/observer/observer_test.go b/zetaclient/chains/bitcoin/observer/observer_test.go index ba2f417968..a352378b45 100644 --- a/zetaclient/chains/bitcoin/observer/observer_test.go +++ b/zetaclient/chains/bitcoin/observer/observer_test.go @@ -72,7 +72,7 @@ func TestNewBitcoinObserver(t *testing.T) { cfg := config.NewConfig() coreContext := context.NewZetacoreContext(cfg) appContext := context.NewAppContext(coreContext, cfg) - chain := chains.BtcMainnetChain + chain := chains.BitcoinMainnet zetacoreClient := mocks.NewMockZetacoreClient() tss := mocks.NewMockTSS(chains.BtcTestNetChain, sample.EthAddress().String(), "") loggers := clientcommon.ClientLogger{} diff --git a/zetaclient/chains/bitcoin/observer/outbound_test.go b/zetaclient/chains/bitcoin/observer/outbound_test.go index 726d12a2a0..2f25575284 100644 --- a/zetaclient/chains/bitcoin/observer/outbound_test.go +++ b/zetaclient/chains/bitcoin/observer/outbound_test.go @@ -22,7 +22,7 @@ func MockBTCObserverMainnet() *Observer { coreContext := context.NewZetacoreContext(cfg) return &Observer{ - chain: chains.BtcMainnetChain, + chain: chains.BitcoinMainnet, zetacoreClient: mocks.NewMockZetacoreClient(), Tss: mocks.NewTSSMainnet(), coreContext: coreContext, @@ -85,7 +85,7 @@ func mineTxNSetNonceMark(ob *Observer, nonce uint64, txid string, preMarkIndex i func TestCheckTSSVout(t *testing.T) { // the archived outbound raw result file and cctx file // https://blockstream.info/tx/030cd813443f7b70cc6d8a544d320c6d8465e4528fc0f3410b599dc0b26753a0 - chain := chains.BtcMainnetChain + chain := chains.BitcoinMainnet chainID := chain.ChainId nonce := uint64(148) @@ -167,7 +167,7 @@ func TestCheckTSSVout(t *testing.T) { func TestCheckTSSVoutCancelled(t *testing.T) { // the archived outbound raw result file and cctx file // https://blockstream.info/tx/030cd813443f7b70cc6d8a544d320c6d8465e4528fc0f3410b599dc0b26753a0 - chain := chains.BtcMainnetChain + chain := chains.BitcoinMainnet chainID := chain.ChainId nonce := uint64(148) diff --git a/zetaclient/chains/bitcoin/signer/signer_test.go b/zetaclient/chains/bitcoin/signer/signer_test.go index ef4ea522d3..76b46aef37 100644 --- a/zetaclient/chains/bitcoin/signer/signer_test.go +++ b/zetaclient/chains/bitcoin/signer/signer_test.go @@ -247,7 +247,7 @@ func TestAddWithdrawTxOutputs(t *testing.T) { // receiver addresses receiver := "bc1qaxf82vyzy8y80v000e7t64gpten7gawewzu42y" - to, err := chains.DecodeBtcAddress(receiver, chains.BtcMainnetChain.ChainId) + to, err := chains.DecodeBtcAddress(receiver, chains.BitcoinMainnet.ChainId) require.NoError(t, err) toScript, err := bitcoin.PayToAddrScript(to) require.NoError(t, err) diff --git a/zetaclient/chains/bitcoin/tx_script_test.go b/zetaclient/chains/bitcoin/tx_script_test.go index 26df8aa1f0..e9e907aae7 100644 --- a/zetaclient/chains/bitcoin/tx_script_test.go +++ b/zetaclient/chains/bitcoin/tx_script_test.go @@ -21,7 +21,7 @@ var TestDataDir = "../../" func TestDecodeVoutP2TR(t *testing.T) { // load archived tx raw result // https://mempool.space/tx/259fc21e63e138136c8f19270a0f7ca10039a66a474f91d23a17896f46e677a7 - chain := chains.BtcMainnetChain + chain := chains.BitcoinMainnet txHash := "259fc21e63e138136c8f19270a0f7ca10039a66a474f91d23a17896f46e677a7" net := &chaincfg.MainNetParams @@ -37,7 +37,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.BitcoinMainnet txHash := "259fc21e63e138136c8f19270a0f7ca10039a66a474f91d23a17896f46e677a7" net := &chaincfg.MainNetParams rawResult := testutils.LoadBTCTxRawResult(t, TestDataDir, chain.ChainId, "P2TR", txHash) @@ -73,7 +73,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.BitcoinMainnet txHash := "791bb9d16f7ab05f70a116d18eaf3552faf77b9d5688699a480261424b4f7e53" net := &chaincfg.MainNetParams @@ -89,7 +89,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.BitcoinMainnet txHash := "791bb9d16f7ab05f70a116d18eaf3552faf77b9d5688699a480261424b4f7e53" net := &chaincfg.MainNetParams rawResult := testutils.LoadBTCTxRawResult(t, TestDataDir, chain.ChainId, "P2WSH", txHash) @@ -125,7 +125,7 @@ func TestDecodeVoutP2WSHErrors(t *testing.T) { func TestDecodeP2WPKHVout(t *testing.T) { // load archived outbound raw result // https://mempool.space/tx/030cd813443f7b70cc6d8a544d320c6d8465e4528fc0f3410b599dc0b26753a0 - chain := chains.BtcMainnetChain + chain := chains.BitcoinMainnet nonce := uint64(148) net := &chaincfg.MainNetParams nameTx := path.Join(TestDataDir, testutils.TestDataPathBTC, testutils.FileNameBTCOutbound(chain.ChainId, nonce)) @@ -153,7 +153,7 @@ func TestDecodeP2WPKHVout(t *testing.T) { func TestDecodeP2WPKHVoutErrors(t *testing.T) { // load archived outbound raw result // https://mempool.space/tx/030cd813443f7b70cc6d8a544d320c6d8465e4528fc0f3410b599dc0b26753a0 - chain := chains.BtcMainnetChain + chain := chains.BitcoinMainnet nonce := uint64(148) net := &chaincfg.MainNetParams nameTx := path.Join(TestDataDir, testutils.TestDataPathBTC, testutils.FileNameBTCOutbound(chain.ChainId, nonce)) @@ -185,7 +185,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.BitcoinMainnet txHash := "fd68c8b4478686ca6f5ae4c28eaab055490650dbdaa6c2c8e380a7e075958a21" net := &chaincfg.MainNetParams @@ -201,7 +201,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.BitcoinMainnet txHash := "fd68c8b4478686ca6f5ae4c28eaab055490650dbdaa6c2c8e380a7e075958a21" net := &chaincfg.MainNetParams rawResult := testutils.LoadBTCTxRawResult(t, TestDataDir, chain.ChainId, "P2SH", txHash) @@ -243,7 +243,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.BitcoinMainnet txHash := "9c741de6e17382b7a9113fc811e3558981a35a360e3d1262a6675892c91322ca" net := &chaincfg.MainNetParams @@ -259,7 +259,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.BitcoinMainnet txHash := "9c741de6e17382b7a9113fc811e3558981a35a360e3d1262a6675892c91322ca" net := &chaincfg.MainNetParams rawResult := testutils.LoadBTCTxRawResult(t, TestDataDir, chain.ChainId, "P2PKH", txHash) @@ -316,7 +316,7 @@ func TestDecodeVoutP2PKHErrors(t *testing.T) { func TestDecodeOpReturnMemo(t *testing.T) { // load archived inbound raw result // https://mempool.space/tx/847139aa65aa4a5ee896375951cbf7417cfc8a4d6f277ec11f40cd87319f04aa - chain := chains.BtcMainnetChain + chain := chains.BitcoinMainnet txHash := "847139aa65aa4a5ee896375951cbf7417cfc8a4d6f277ec11f40cd87319f04aa" scriptHex := "6a1467ed0bcc4e1256bc2ce87d22e190d63a120114bf" rawResult := testutils.LoadBTCInboundRawResult(t, TestDataDir, chain.ChainId, txHash, false) @@ -388,7 +388,7 @@ func TestDecodeOpReturnMemoErrors(t *testing.T) { } func TestDecodeTSSVout(t *testing.T) { - chain := chains.BtcMainnetChain + chain := chains.BitcoinMainnet t.Run("should decode P2TR vout", func(t *testing.T) { // https://mempool.space/tx/259fc21e63e138136c8f19270a0f7ca10039a66a474f91d23a17896f46e677a7 @@ -450,7 +450,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.BitcoinMainnet txHash := "259fc21e63e138136c8f19270a0f7ca10039a66a474f91d23a17896f46e677a7" rawResult := testutils.LoadBTCTxRawResult(t, TestDataDir, chain.ChainId, "P2TR", txHash) diff --git a/zetaclient/orchestrator/orchestrator_test.go b/zetaclient/orchestrator/orchestrator_test.go index b1a0434bc3..f0508d371f 100644 --- a/zetaclient/orchestrator/orchestrator_test.go +++ b/zetaclient/orchestrator/orchestrator_test.go @@ -90,7 +90,7 @@ func CreateCoreContext( func Test_GetUpdatedSigner(t *testing.T) { // initial parameters for orchestrator creation evmChain := chains.Ethereum - btcChain := chains.BtcMainnetChain + btcChain := chains.BitcoinMainnet evmChainParams := &observertypes.ChainParams{ ChainId: evmChain.ChainId, ConnectorContractAddress: testutils.ConnectorAddresses[evmChain.ChainId].Hex(), @@ -126,7 +126,7 @@ func Test_GetUpdatedSigner(t *testing.T) { func Test_GetUpdatedChainObserver(t *testing.T) { // initial parameters for orchestrator creation evmChain := chains.Ethereum - btcChain := chains.BtcMainnetChain + btcChain := chains.BitcoinMainnet evmChainParams := &observertypes.ChainParams{ ChainId: evmChain.ChainId, ConnectorContractAddress: testutils.ConnectorAddresses[evmChain.ChainId].Hex(), @@ -207,7 +207,7 @@ func Test_GetUpdatedChainObserver(t *testing.T) { func Test_GetPendingCctxsWithinRatelimit(t *testing.T) { // define test foreign chains ethChain := chains.Ethereum - btcChain := chains.BtcMainnetChain + btcChain := chains.BitcoinMainnet foreignChains := []chains.Chain{ ethChain, btcChain, diff --git a/zetaclient/ratelimiter/rate_limiter_test.go b/zetaclient/ratelimiter/rate_limiter_test.go index 9dacddb22b..aab9bcbf6a 100644 --- a/zetaclient/ratelimiter/rate_limiter_test.go +++ b/zetaclient/ratelimiter/rate_limiter_test.go @@ -114,7 +114,7 @@ func Test_IsRateLimiterUsable(t *testing.T) { func Test_ApplyRateLimiter(t *testing.T) { // define test chain ids ethChainID := chains.Ethereum.ChainId - btcChainID := chains.BtcMainnetChain.ChainId + btcChainID := chains.BitcoinMainnet.ChainId // create 10 missed and 90 pending cctxs for eth chain, the coinType/amount does not matter for this test // but we still use a proper cctx value (0.5 ZETA) to make the test more realistic diff --git a/zetaclient/testutils/mocks/tss_signer.go b/zetaclient/testutils/mocks/tss_signer.go index ebe07d84bc..f25386d8df 100644 --- a/zetaclient/testutils/mocks/tss_signer.go +++ b/zetaclient/testutils/mocks/tss_signer.go @@ -50,7 +50,7 @@ func NewMockTSS(chain chains.Chain, evmAddress string, btcAddress string) *TSS { } func NewTSSMainnet() *TSS { - return NewMockTSS(chains.BtcMainnetChain, testutils.TSSAddressEVMMainnet, testutils.TSSAddressBTCMainnet) + return NewMockTSS(chains.BitcoinMainnet, testutils.TSSAddressEVMMainnet, testutils.TSSAddressBTCMainnet) } func NewTSSAthens3() *TSS { diff --git a/zetaclient/zetacore/query_test.go b/zetaclient/zetacore/query_test.go index 2faad2918a..05d52fc088 100644 --- a/zetaclient/zetacore/query_test.go +++ b/zetaclient/zetacore/query_test.go @@ -134,7 +134,7 @@ func TestZetacore_HeaderEnabledChains(t *testing.T) { Enabled: true, }, { - ChainId: chains.BtcMainnetChain.ChainId, + ChainId: chains.BitcoinMainnet.ChainId, Enabled: true, }, }, @@ -841,8 +841,8 @@ func TestZetacore_GetSupportedChains(t *testing.T) { expectedOutput := observertypes.QuerySupportedChainsResponse{ Chains: []*chains.Chain{ { - ChainName: chains.BtcMainnetChain.ChainName, - ChainId: chains.BtcMainnetChain.ChainId, + ChainName: chains.BitcoinMainnet.ChainName, + ChainId: chains.BitcoinMainnet.ChainId, Network: chains.BscMainnet.Network, NetworkType: chains.BscMainnet.NetworkType, Vm: chains.BscMainnet.Vm, diff --git a/zetaclient/zetacore/tx_test.go b/zetaclient/zetacore/tx_test.go index fd13e551d4..e1b8c6e530 100644 --- a/zetaclient/zetacore/tx_test.go +++ b/zetaclient/zetacore/tx_test.go @@ -249,8 +249,8 @@ func TestZetacore_UpdateZetacoreContext(t *testing.T) { Chains: []*chains.Chain{ { - chains.BtcMainnetChain.ChainName, - chains.BtcMainnetChain.ChainId, + chains.BitcoinMainnet.ChainName, + chains.BitcoinMainnet.ChainId, chains.BscMainnet.Network, chains.BscMainnet.NetworkType, chains.BscMainnet.Vm, @@ -314,7 +314,7 @@ func TestZetacore_UpdateZetacoreContext(t *testing.T) { Enabled: true, }, { - ChainId: chains.BtcMainnetChain.ChainId, + ChainId: chains.BitcoinMainnet.ChainId, Enabled: false, }, }}) From c350cfd1df7375f35baab82a3d5c1e1f7dedd7d3 Mon Sep 17 00:00:00 2001 From: lumtis Date: Fri, 24 May 2024 10:20:10 +0200 Subject: [PATCH 06/22] polygon --- pkg/chains/chains.go | 6 +++--- pkg/chains/chains_test.go | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pkg/chains/chains.go b/pkg/chains/chains.go index da13015bd9..6b974af6dc 100644 --- a/pkg/chains/chains.go +++ b/pkg/chains/chains.go @@ -51,8 +51,8 @@ var ( IsExternal: true, } - // PolygonChain is Polygon mainnet - PolygonChain = Chain{ + // Polygon is Polygon mainnet + Polygon = Chain{ ChainName: ChainName_polygon_mainnet, ChainId: 137, Network: Network_polygon, @@ -267,7 +267,7 @@ func DefaultChainsList() []*Chain { ZetaTestnetChain, ZetaMocknetChain, ZetaPrivnetChain, - PolygonChain, + Polygon, OptimismMainnet, OptimismSepolia, BaseMainnet, diff --git a/pkg/chains/chains_test.go b/pkg/chains/chains_test.go index 9a6f49d286..b39a4655f8 100644 --- a/pkg/chains/chains_test.go +++ b/pkg/chains/chains_test.go @@ -20,7 +20,7 @@ func TestChainListByNetworkType(t *testing.T) { &BitcoinMainnet, &BscMainnet, &Ethereum, - &PolygonChain, + &Polygon, &OptimismMainnet, &BaseMainnet, }, @@ -87,7 +87,7 @@ func TestChainListByNetwork(t *testing.T) { { "Polygon", Network_polygon, - []*Chain{&PolygonChain, &MumbaiChain, &AmoyChain}, + []*Chain{&Polygon, &MumbaiChain, &AmoyChain}, }, { "Optimism", @@ -132,7 +132,7 @@ func TestChainListFunctions(t *testing.T) { &ZetaTestnetChain, &ZetaMocknetChain, &ZetaPrivnetChain, - &PolygonChain, + &Polygon, &OptimismMainnet, &OptimismSepolia, &BaseMainnet, @@ -154,7 +154,7 @@ func TestChainListFunctions(t *testing.T) { &SepoliaChain, &BtcRegtestChain, &GoerliLocalnetChain, - &PolygonChain, + &Polygon, &OptimismMainnet, &OptimismSepolia, &BaseMainnet, From c37c1c6f4052e74c6c61f25a6a184b591a8084cb Mon Sep 17 00:00:00 2001 From: lumtis Date: Fri, 24 May 2024 10:21:16 +0200 Subject: [PATCH 07/22] zetachain testnet --- pkg/chains/chain_test.go | 10 +++++----- pkg/chains/chains.go | 10 +++++----- pkg/chains/chains_test.go | 10 +++++----- x/crosschain/types/message_add_inbound_tracker_test.go | 6 +++--- zetaclient/context/zetacore_context_test.go | 2 +- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/pkg/chains/chain_test.go b/pkg/chains/chain_test.go index 3b69283ffa..02819b2a35 100644 --- a/pkg/chains/chain_test.go +++ b/pkg/chains/chain_test.go @@ -141,7 +141,7 @@ 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.True(t, ZetaChainTestnet.InChainList(ChainListByNetwork(Network_zeta))) require.False(t, Ethereum.InChainList(ChainListByNetwork(Network_zeta))) } @@ -152,7 +152,7 @@ func TestIsZetaChain(t *testing.T) { want bool }{ {"Zeta Mainnet", ZetaChainMainnet.ChainId, true}, - {"Zeta Testnet", ZetaTestnetChain.ChainId, true}, + {"Zeta Testnet", ZetaChainTestnet.ChainId, true}, {"Zeta Mocknet", ZetaMocknetChain.ChainId, true}, {"Zeta Privnet", ZetaPrivnetChain.ChainId, true}, {"Non-Zeta", Ethereum.ChainId, false}, @@ -325,19 +325,19 @@ func TestChain_WitnessProgram(t *testing.T) { } func TestChains_Has(t *testing.T) { - chains := Chains{ZetaChainMainnet, ZetaTestnetChain} + chains := Chains{ZetaChainMainnet, ZetaChainTestnet} require.True(t, chains.Has(ZetaChainMainnet)) require.False(t, chains.Has(Ethereum)) } func TestChains_Distinct(t *testing.T) { - chains := Chains{ZetaChainMainnet, ZetaChainMainnet, ZetaTestnetChain} + chains := Chains{ZetaChainMainnet, ZetaChainMainnet, ZetaChainTestnet} distinctChains := chains.Distinct() require.Len(t, distinctChains, 2) } func TestChains_Strings(t *testing.T) { - chains := Chains{ZetaChainMainnet, ZetaTestnetChain} + chains := Chains{ZetaChainMainnet, ZetaChainTestnet} strings := chains.Strings() expected := []string{chains[0].String(), chains[1].String()} require.Equal(t, expected, strings) diff --git a/pkg/chains/chains.go b/pkg/chains/chains.go index 6b974af6dc..5a88f1ce11 100644 --- a/pkg/chains/chains.go +++ b/pkg/chains/chains.go @@ -88,8 +88,8 @@ var ( * Testnet chains */ - // ZetaTestnetChain is the testnet chain for Zeta - ZetaTestnetChain = Chain{ + // ZetaChainTestnet is the testnet chain for Zeta + ZetaChainTestnet = Chain{ ChainName: ChainName_zeta_testnet, ChainId: 7001, Network: Network_zeta, @@ -264,7 +264,7 @@ func DefaultChainsList() []*Chain { BtcRegtestChain, GoerliLocalnetChain, ZetaChainMainnet, - ZetaTestnetChain, + ZetaChainTestnet, ZetaMocknetChain, ZetaPrivnetChain, Polygon, @@ -342,8 +342,8 @@ func ZetaChainFromChainID(chainID string) (Chain, error) { return ZetaPrivnetChain, nil case ZetaChainMainnet.ChainId: return ZetaChainMainnet, nil - case ZetaTestnetChain.ChainId: - return ZetaTestnetChain, nil + case ZetaChainTestnet.ChainId: + return ZetaChainTestnet, nil case ZetaMocknetChain.ChainId: return ZetaMocknetChain, nil default: diff --git a/pkg/chains/chains_test.go b/pkg/chains/chains_test.go index b39a4655f8..2a10dd8e86 100644 --- a/pkg/chains/chains_test.go +++ b/pkg/chains/chains_test.go @@ -29,7 +29,7 @@ func TestChainListByNetworkType(t *testing.T) { "testnet chains", NetworkType_testnet, []*Chain{ - &ZetaTestnetChain, + &ZetaChainTestnet, &BtcTestNetChain, &MumbaiChain, &AmoyChain, @@ -67,7 +67,7 @@ func TestChainListByNetwork(t *testing.T) { { "Zeta", Network_zeta, - []*Chain{&ZetaChainMainnet, &ZetaMocknetChain, &ZetaPrivnetChain, &ZetaTestnetChain}, + []*Chain{&ZetaChainMainnet, &ZetaMocknetChain, &ZetaPrivnetChain, &ZetaChainTestnet}, }, { "Btc", @@ -129,7 +129,7 @@ func TestChainListFunctions(t *testing.T) { &BtcRegtestChain, &GoerliLocalnetChain, &ZetaChainMainnet, - &ZetaTestnetChain, + &ZetaChainTestnet, &ZetaMocknetChain, &ZetaPrivnetChain, &Polygon, @@ -185,9 +185,9 @@ func TestZetaChainFromChainID(t *testing.T) { wantErr: false, }, { - name: "ZetaTestnetChain", + name: "ZetaChainTestnet", chainID: "cosmoshub_7001-1", - expected: ZetaTestnetChain, + expected: ZetaChainTestnet, wantErr: false, }, { diff --git a/x/crosschain/types/message_add_inbound_tracker_test.go b/x/crosschain/types/message_add_inbound_tracker_test.go index 0c81de17a7..972b776cdb 100644 --- a/x/crosschain/types/message_add_inbound_tracker_test.go +++ b/x/crosschain/types/message_add_inbound_tracker_test.go @@ -45,21 +45,21 @@ func TestMsgAddInboundTracker_ValidateBasic(t *testing.T) { name: "invalid proof", msg: &types.MsgAddInboundTracker{ Creator: sample.AccAddress(), - ChainId: chains.ZetaTestnetChain.ChainId, + ChainId: chains.ZetaChainTestnet.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, + chains.ZetaChainTestnet.ChainId, ), }, { name: "invalid coin type", msg: &types.MsgAddInboundTracker{ Creator: sample.AccAddress(), - ChainId: chains.ZetaTestnetChain.ChainId, + ChainId: chains.ZetaChainTestnet.ChainId, CoinType: 5, }, err: errorsmod.Wrapf(types.ErrProofVerificationFail, "coin-type not supported"), diff --git a/zetaclient/context/zetacore_context_test.go b/zetaclient/context/zetacore_context_test.go index a550000e0b..e1e57b8f56 100644 --- a/zetaclient/context/zetacore_context_test.go +++ b/zetaclient/context/zetacore_context_test.go @@ -165,7 +165,7 @@ func TestUpdateZetacoreContext(t *testing.T) { ChainId: 2, IsExternal: true, }, - chains.ZetaTestnetChain, + chains.ZetaChainTestnet, } evmChainParamsToUpdate := map[int64]*observertypes.ChainParams{ 1: { From 48393bbce51e26e8b768a421958916afd7fa22c1 Mon Sep 17 00:00:00 2001 From: lumtis Date: Fri, 24 May 2024 10:22:34 +0200 Subject: [PATCH 08/22] sepolia --- e2e/e2etests/test_migrate_chain_support.go | 4 ++-- pkg/chains/chain_test.go | 6 ++--- pkg/chains/chains.go | 6 ++--- pkg/chains/chains_test.go | 8 +++---- testutil/sample/lightclient.go | 2 +- .../types/tx_body_verification_test.go | 4 ++-- x/lightclient/keeper/block_header_test.go | 22 +++++++++---------- x/lightclient/keeper/proof_test.go | 8 +++---- x/lightclient/types/verification_flags.go | 2 +- .../types/verification_flags_test.go | 2 +- zetaclient/config/config_chain.go | 4 ++-- 11 files changed, 34 insertions(+), 34 deletions(-) diff --git a/e2e/e2etests/test_migrate_chain_support.go b/e2e/e2etests/test_migrate_chain_support.go index df30e84713..052dc90742 100644 --- a/e2e/e2etests/test_migrate_chain_support.go +++ b/e2e/e2etests/test_migrate_chain_support.go @@ -31,7 +31,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.Sepolia.ChainId func TestMigrateChainSupport(r *runner.E2ERunner, _ []string) { // deposit most of the ZETA supply on ZetaChain @@ -187,7 +187,7 @@ func TestMigrateChainSupport(r *runner.E2ERunner, _ []string) { res, err := newRunner.ZetaTxServer.BroadcastTx(utils.FungibleAdminName, crosschaintypes.NewMsgWhitelistERC20( adminAddr, newRunner.ERC20Addr.Hex(), - chains.SepoliaChain.ChainId, + chains.Sepolia.ChainId, "USDT", "USDT", 18, diff --git a/pkg/chains/chain_test.go b/pkg/chains/chain_test.go index 02819b2a35..cb5e2e135c 100644 --- a/pkg/chains/chain_test.go +++ b/pkg/chains/chain_test.go @@ -173,7 +173,7 @@ func TestIsEVMChain(t *testing.T) { }{ {"Ethereum Mainnet", Ethereum.ChainId, true}, {"Goerli Testnet", GoerliChain.ChainId, true}, - {"Sepolia Testnet", SepoliaChain.ChainId, true}, + {"Sepolia Testnet", Sepolia.ChainId, true}, {"Non-EVM", BitcoinMainnet.ChainId, false}, {"Zeta Mainnet", ZetaChainMainnet.ChainId, false}, } @@ -194,7 +194,7 @@ func TestIsHeaderSupportedChain(t *testing.T) { {"Ethereum Mainnet", Ethereum.ChainId, true}, {"Goerli Testnet", GoerliChain.ChainId, true}, {"Goerli Localnet", GoerliLocalnetChain.ChainId, true}, - {"Sepolia Testnet", SepoliaChain.ChainId, true}, + {"Sepolia Testnet", Sepolia.ChainId, true}, {"BSC Testnet", BscTestnetChain.ChainId, true}, {"BSC Mainnet", BscMainnet.ChainId, true}, {"BTC", BitcoinMainnet.ChainId, true}, @@ -256,7 +256,7 @@ func TestIsEthereumChain(t *testing.T) { }{ {"Ethereum Mainnet", Ethereum.ChainId, true}, {"Goerli Testnet", GoerliChain.ChainId, true}, - {"Sepolia Testnet", SepoliaChain.ChainId, true}, + {"Sepolia Testnet", Sepolia.ChainId, true}, {"Non-Ethereum", BitcoinMainnet.ChainId, false}, {"Zeta Mainnet", ZetaChainMainnet.ChainId, false}, } diff --git a/pkg/chains/chains.go b/pkg/chains/chains.go index 5a88f1ce11..fc55cde430 100644 --- a/pkg/chains/chains.go +++ b/pkg/chains/chains.go @@ -99,8 +99,8 @@ var ( IsExternal: false, } - // SepoliaChain is Ethereum sepolia testnet - SepoliaChain = Chain{ + // Sepolia is Ethereum sepolia testnet + Sepolia = Chain{ ChainName: ChainName_sepolia_testnet, ChainId: 11155111, Network: Network_eth, @@ -260,7 +260,7 @@ func DefaultChainsList() []*Chain { AmoyChain, BscTestnetChain, GoerliChain, - SepoliaChain, + Sepolia, BtcRegtestChain, GoerliLocalnetChain, ZetaChainMainnet, diff --git a/pkg/chains/chains_test.go b/pkg/chains/chains_test.go index 2a10dd8e86..5ab170cb70 100644 --- a/pkg/chains/chains_test.go +++ b/pkg/chains/chains_test.go @@ -35,7 +35,7 @@ func TestChainListByNetworkType(t *testing.T) { &AmoyChain, &BscTestnetChain, &GoerliChain, - &SepoliaChain, + &Sepolia, &OptimismSepolia, &BaseSepolia, }, @@ -77,7 +77,7 @@ func TestChainListByNetwork(t *testing.T) { { "Eth", Network_eth, - []*Chain{&Ethereum, &GoerliChain, &SepoliaChain, &GoerliLocalnetChain}, + []*Chain{&Ethereum, &GoerliChain, &Sepolia, &GoerliLocalnetChain}, }, { "Bsc", @@ -125,7 +125,7 @@ func TestChainListFunctions(t *testing.T) { &AmoyChain, &BscTestnetChain, &GoerliChain, - &SepoliaChain, + &Sepolia, &BtcRegtestChain, &GoerliLocalnetChain, &ZetaChainMainnet, @@ -151,7 +151,7 @@ func TestChainListFunctions(t *testing.T) { &AmoyChain, &BscTestnetChain, &GoerliChain, - &SepoliaChain, + &Sepolia, &BtcRegtestChain, &GoerliLocalnetChain, &Polygon, diff --git a/testutil/sample/lightclient.go b/testutil/sample/lightclient.go index 34271f2a42..1d3725876a 100644 --- a/testutil/sample/lightclient.go +++ b/testutil/sample/lightclient.go @@ -73,7 +73,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.Sepolia.ChainId ethProof := proofs.NewEthereumProof(proof) ethHeader := proofs.NewEthereumHeader(b) blockHeader := proofs.BlockHeader{ diff --git a/x/crosschain/types/tx_body_verification_test.go b/x/crosschain/types/tx_body_verification_test.go index 960c01d867..a34cb945b0 100644 --- a/x/crosschain/types/tx_body_verification_test.go +++ b/x/crosschain/types/tx_body_verification_test.go @@ -53,7 +53,7 @@ func TestVerifyInboundBody(t *testing.T) { { desc: "chain id doesn't correspond", msg: types.MsgAddInboundTracker{ - ChainId: chains.SepoliaChain.ChainId, + ChainId: chains.Sepolia.ChainId, TxHash: sampleEthTx.Hash().Hex(), }, txBytes: sampleEthTxBytes, @@ -224,7 +224,7 @@ func TestVerifyOutboundBody(t *testing.T) { { desc: "chain id doesn't correspond", msg: types.MsgAddOutboundTracker{ - ChainId: chains.SepoliaChain.ChainId, + ChainId: chains.Sepolia.ChainId, Nonce: 42, TxHash: sampleEthTx.Hash().Hex(), }, diff --git a/x/lightclient/keeper/block_header_test.go b/x/lightclient/keeper/block_header_test.go index 756e4a4514..e8cf036d91 100644 --- a/x/lightclient/keeper/block_header_test.go +++ b/x/lightclient/keeper/block_header_test.go @@ -69,21 +69,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.Sepolia.ChainId, Header: proofs.NewEthereumHeader(headerRLP1), }, proofs.BlockHeader{ Height: 5000001, Hash: header2.Hash().Bytes(), ParentHash: header2.ParentHash.Bytes(), - ChainId: chains.SepoliaChain.ChainId, + ChainId: chains.Sepolia.ChainId, Header: proofs.NewEthereumHeader(headerRLP2), }, proofs.BlockHeader{ Height: 5000002, Hash: header3.Hash().Bytes(), ParentHash: header3.ParentHash.Bytes(), - ChainId: chains.SepoliaChain.ChainId, + ChainId: chains.Sepolia.ChainId, Header: proofs.NewEthereumHeader(headerRLP3), } } @@ -131,7 +131,7 @@ func TestKeeper_CheckNewBlockHeader(t *testing.T) { k.SetBlockHeaderVerification(ctx, types.BlockHeaderVerification{ HeaderSupportedChains: []types.HeaderSupportedChain{ { - ChainId: chains.SepoliaChain.ChainId, + ChainId: chains.Sepolia.ChainId, Enabled: true, }, }, @@ -150,7 +150,7 @@ func TestKeeper_CheckNewBlockHeader(t *testing.T) { k.SetBlockHeaderVerification(ctx, types.BlockHeaderVerification{ HeaderSupportedChains: []types.HeaderSupportedChain{ { - ChainId: chains.SepoliaChain.ChainId, + ChainId: chains.Sepolia.ChainId, Enabled: false, }, }, @@ -191,7 +191,7 @@ func TestKeeper_CheckNewBlockHeader(t *testing.T) { k.SetBlockHeaderVerification(ctx, types.BlockHeaderVerification{ HeaderSupportedChains: []types.HeaderSupportedChain{ { - ChainId: chains.SepoliaChain.ChainId, + ChainId: chains.Sepolia.ChainId, Enabled: true, }, }, @@ -209,7 +209,7 @@ func TestKeeper_CheckNewBlockHeader(t *testing.T) { k.SetBlockHeaderVerification(ctx, types.BlockHeaderVerification{ HeaderSupportedChains: []types.HeaderSupportedChain{ { - ChainId: chains.SepoliaChain.ChainId, + ChainId: chains.Sepolia.ChainId, Enabled: true, }, }, @@ -233,7 +233,7 @@ func TestKeeper_CheckNewBlockHeader(t *testing.T) { k.SetBlockHeaderVerification(ctx, types.BlockHeaderVerification{ HeaderSupportedChains: []types.HeaderSupportedChain{ { - ChainId: chains.SepoliaChain.ChainId, + ChainId: chains.Sepolia.ChainId, Enabled: true, }, }, @@ -260,7 +260,7 @@ func TestKeeper_AddBlockHeader(t *testing.T) { k.SetBlockHeaderVerification(ctx, types.BlockHeaderVerification{ HeaderSupportedChains: []types.HeaderSupportedChain{ { - ChainId: chains.SepoliaChain.ChainId, + ChainId: chains.Sepolia.ChainId, Enabled: true, }, }, @@ -292,7 +292,7 @@ func TestKeeper_AddBlockHeader(t *testing.T) { k.SetBlockHeaderVerification(ctx, types.BlockHeaderVerification{ HeaderSupportedChains: []types.HeaderSupportedChain{ { - ChainId: chains.SepoliaChain.ChainId, + ChainId: chains.Sepolia.ChainId, Enabled: true, }, }, @@ -334,7 +334,7 @@ func TestKeeper_AddBlockHeader(t *testing.T) { k.SetBlockHeaderVerification(ctx, types.BlockHeaderVerification{ HeaderSupportedChains: []types.HeaderSupportedChain{ { - ChainId: chains.SepoliaChain.ChainId, + ChainId: chains.Sepolia.ChainId, Enabled: true, }, }, diff --git a/x/lightclient/keeper/proof_test.go b/x/lightclient/keeper/proof_test.go index 1f80d28100..95e1ab3e6f 100644 --- a/x/lightclient/keeper/proof_test.go +++ b/x/lightclient/keeper/proof_test.go @@ -17,7 +17,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.Sepolia.ChainId, sample.Hash().String(), 1) require.ErrorContains(t, err, "proof verification is disabled for all chains") }) @@ -48,7 +48,7 @@ func TestKeeper_VerifyProof(t *testing.T) { }, }, }) - _, err := k.VerifyProof(ctx, &proofs.Proof{}, chains.SepoliaChain.ChainId, sample.Hash().String(), 1) + _, err := k.VerifyProof(ctx, &proofs.Proof{}, chains.Sepolia.ChainId, sample.Hash().String(), 1) require.ErrorIs(t, err, types.ErrBlockHeaderVerificationDisabled) }) @@ -112,7 +112,7 @@ func TestKeeper_VerifyProof(t *testing.T) { }, }) - _, err := k.VerifyProof(ctx, &proofs.Proof{}, chains.SepoliaChain.ChainId, sample.Hash().String(), 1) + _, err := k.VerifyProof(ctx, &proofs.Proof{}, chains.Sepolia.ChainId, sample.Hash().String(), 1) require.ErrorContains(t, err, "block header verification is disabled") }) @@ -153,7 +153,7 @@ func TestKeeper_VerifyProof(t *testing.T) { Enabled: true, }, { - ChainId: chains.SepoliaChain.ChainId, + ChainId: chains.Sepolia.ChainId, Enabled: true, }, }, diff --git a/x/lightclient/types/verification_flags.go b/x/lightclient/types/verification_flags.go index a8a28e1367..f0753b4401 100644 --- a/x/lightclient/types/verification_flags.go +++ b/x/lightclient/types/verification_flags.go @@ -21,7 +21,7 @@ func DefaultHeaderSupportedChains() []HeaderSupportedChain { Enabled: false, }, { - ChainId: chains.SepoliaChain.ChainId, + ChainId: chains.Sepolia.ChainId, Enabled: false, }, { diff --git a/x/lightclient/types/verification_flags_test.go b/x/lightclient/types/verification_flags_test.go index 71f98b7a42..0577cc1cc9 100644 --- a/x/lightclient/types/verification_flags_test.go +++ b/x/lightclient/types/verification_flags_test.go @@ -17,7 +17,7 @@ func TestDefaultVerificationFlags(t *testing.T) { require.False(t, f.Enabled) case chains.BscMainnet.ChainId: require.False(t, f.Enabled) - case chains.SepoliaChain.ChainId: + case chains.Sepolia.ChainId: require.False(t, f.Enabled) case chains.BscTestnetChain.ChainId: require.False(t, f.Enabled) diff --git a/zetaclient/config/config_chain.go b/zetaclient/config/config_chain.go index b00040ea91..0986970251 100644 --- a/zetaclient/config/config_chain.go +++ b/zetaclient/config/config_chain.go @@ -46,8 +46,8 @@ var evmChainsConfigs = map[int64]EVMConfig{ Chain: chains.GoerliChain, Endpoint: "", }, - chains.SepoliaChain.ChainId: { - Chain: chains.SepoliaChain, + chains.Sepolia.ChainId: { + Chain: chains.Sepolia, Endpoint: "", }, chains.BscTestnetChain.ChainId: { From 708908588c11228e039a6e329a2b592ed408aa0b Mon Sep 17 00:00:00 2001 From: lumtis Date: Fri, 24 May 2024 10:23:14 +0200 Subject: [PATCH 09/22] bsc testnet --- pkg/chains/chain_test.go | 4 ++-- pkg/chains/chains.go | 6 +++--- pkg/chains/chains_test.go | 8 ++++---- x/crosschain/migrations/v5/migrate.go | 2 +- x/crosschain/migrations/v5/migrate_test.go | 6 +++--- x/lightclient/types/verification_flags.go | 2 +- x/lightclient/types/verification_flags_test.go | 2 +- x/observer/types/chain_params.go | 2 +- zetaclient/config/config_chain.go | 4 ++-- zetaclient/testutils/mocks/tss_signer.go | 2 +- 10 files changed, 19 insertions(+), 19 deletions(-) diff --git a/pkg/chains/chain_test.go b/pkg/chains/chain_test.go index cb5e2e135c..2e83321238 100644 --- a/pkg/chains/chain_test.go +++ b/pkg/chains/chain_test.go @@ -195,7 +195,7 @@ func TestIsHeaderSupportedChain(t *testing.T) { {"Goerli Testnet", GoerliChain.ChainId, true}, {"Goerli Localnet", GoerliLocalnetChain.ChainId, true}, {"Sepolia Testnet", Sepolia.ChainId, true}, - {"BSC Testnet", BscTestnetChain.ChainId, true}, + {"BSC Testnet", BscTestnet.ChainId, true}, {"BSC Mainnet", BscMainnet.ChainId, true}, {"BTC", BitcoinMainnet.ChainId, true}, {"Zeta Mainnet", ZetaChainMainnet.ChainId, false}, @@ -215,7 +215,7 @@ func TestSupportMerkleProof(t *testing.T) { want bool }{ {"Ethereum Mainnet", Ethereum, true}, - {"BSC Testnet", BscTestnetChain, true}, + {"BSC Testnet", BscTestnet, true}, {"BSC Mainnet", BscMainnet, true}, {"Non-EVM", BitcoinMainnet, true}, {"Zeta Mainnet", ZetaChainMainnet, false}, diff --git a/pkg/chains/chains.go b/pkg/chains/chains.go index fc55cde430..7ec6ba0d62 100644 --- a/pkg/chains/chains.go +++ b/pkg/chains/chains.go @@ -110,8 +110,8 @@ var ( IsExternal: true, } - // BscTestnetChain is Binance Smart Chain testnet - BscTestnetChain = Chain{ + // BscTestnet is Binance Smart Chain testnet + BscTestnet = Chain{ ChainName: ChainName_bsc_testnet, ChainId: 97, Network: Network_bsc, @@ -258,7 +258,7 @@ func DefaultChainsList() []*Chain { BtcTestNetChain, MumbaiChain, AmoyChain, - BscTestnetChain, + BscTestnet, GoerliChain, Sepolia, BtcRegtestChain, diff --git a/pkg/chains/chains_test.go b/pkg/chains/chains_test.go index 5ab170cb70..a47f9726d9 100644 --- a/pkg/chains/chains_test.go +++ b/pkg/chains/chains_test.go @@ -33,7 +33,7 @@ func TestChainListByNetworkType(t *testing.T) { &BtcTestNetChain, &MumbaiChain, &AmoyChain, - &BscTestnetChain, + &BscTestnet, &GoerliChain, &Sepolia, &OptimismSepolia, @@ -82,7 +82,7 @@ func TestChainListByNetwork(t *testing.T) { { "Bsc", Network_bsc, - []*Chain{&BscMainnet, &BscTestnetChain}, + []*Chain{&BscMainnet, &BscTestnet}, }, { "Polygon", @@ -123,7 +123,7 @@ func TestChainListFunctions(t *testing.T) { &BtcTestNetChain, &MumbaiChain, &AmoyChain, - &BscTestnetChain, + &BscTestnet, &GoerliChain, &Sepolia, &BtcRegtestChain, @@ -149,7 +149,7 @@ func TestChainListFunctions(t *testing.T) { &BtcTestNetChain, &MumbaiChain, &AmoyChain, - &BscTestnetChain, + &BscTestnet, &GoerliChain, &Sepolia, &BtcRegtestChain, diff --git a/x/crosschain/migrations/v5/migrate.go b/x/crosschain/migrations/v5/migrate.go index 79990aa96e..9bd6518c8c 100644 --- a/x/crosschain/migrations/v5/migrate.go +++ b/x/crosschain/migrations/v5/migrate.go @@ -80,7 +80,7 @@ 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.BscTestnet, 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 091070009d..7195f80e3b 100644 --- a/x/crosschain/migrations/v5/migrate_test.go +++ b/x/crosschain/migrations/v5/migrate_test.go @@ -75,7 +75,7 @@ func TestResetTestnetNonce(t *testing.T) { testnetChains := []chains.Chain{ chains.GoerliChain, chains.MumbaiChain, - chains.BscTestnetChain, + chains.BscTestnet, chains.BtcTestNetChain, } mainnetChains := []chains.Chain{chains.Ethereum, chains.BscMainnet, chains.BitcoinMainnet} @@ -114,7 +114,7 @@ func TestResetTestnetNonce(t *testing.T) { assertValues := map[chains.Chain]int64{ chains.GoerliChain: 226841, chains.MumbaiChain: 200599, - chains.BscTestnetChain: 110454, + chains.BscTestnet: 110454, chains.BtcTestNetChain: 4881, } @@ -163,7 +163,7 @@ func TestResetTestnetNonce(t *testing.T) { assertValuesSet := map[chains.Chain]int64{ chains.GoerliChain: 226841, } - assertValuesNotSet := []chains.Chain{chains.MumbaiChain, chains.BscTestnetChain, chains.BtcTestNetChain} + assertValuesNotSet := []chains.Chain{chains.MumbaiChain, chains.BscTestnet, chains.BtcTestNetChain} for _, chain := range testnetChains { pn, found := zk.ObserverKeeper.GetPendingNonces(ctx, tss.TssPubkey, chain.ChainId) diff --git a/x/lightclient/types/verification_flags.go b/x/lightclient/types/verification_flags.go index f0753b4401..eecf819674 100644 --- a/x/lightclient/types/verification_flags.go +++ b/x/lightclient/types/verification_flags.go @@ -25,7 +25,7 @@ func DefaultHeaderSupportedChains() []HeaderSupportedChain { Enabled: false, }, { - ChainId: chains.BscTestnetChain.ChainId, + ChainId: chains.BscTestnet.ChainId, Enabled: false, }, { diff --git a/x/lightclient/types/verification_flags_test.go b/x/lightclient/types/verification_flags_test.go index 0577cc1cc9..a1e540d60b 100644 --- a/x/lightclient/types/verification_flags_test.go +++ b/x/lightclient/types/verification_flags_test.go @@ -19,7 +19,7 @@ func TestDefaultVerificationFlags(t *testing.T) { require.False(t, f.Enabled) case chains.Sepolia.ChainId: require.False(t, f.Enabled) - case chains.BscTestnetChain.ChainId: + case chains.BscTestnet.ChainId: require.False(t, f.Enabled) case chains.GoerliLocalnetChain.ChainId: require.False(t, f.Enabled) diff --git a/x/observer/types/chain_params.go b/x/observer/types/chain_params.go index 831a191897..7ea7a66128 100644 --- a/x/observer/types/chain_params.go +++ b/x/observer/types/chain_params.go @@ -237,7 +237,7 @@ func GetDefaultGoerliTestnetChainParams() *ChainParams { } func GetDefaultBscTestnetChainParams() *ChainParams { return &ChainParams{ - ChainId: chains.BscTestnetChain.ChainId, + ChainId: chains.BscTestnet.ChainId, ConfirmationCount: 6, ZetaTokenContractAddress: zeroAddress, ConnectorContractAddress: zeroAddress, diff --git a/zetaclient/config/config_chain.go b/zetaclient/config/config_chain.go index 0986970251..119911d3d9 100644 --- a/zetaclient/config/config_chain.go +++ b/zetaclient/config/config_chain.go @@ -50,8 +50,8 @@ var evmChainsConfigs = map[int64]EVMConfig{ Chain: chains.Sepolia, Endpoint: "", }, - chains.BscTestnetChain.ChainId: { - Chain: chains.BscTestnetChain, + chains.BscTestnet.ChainId: { + Chain: chains.BscTestnet, Endpoint: "", }, chains.MumbaiChain.ChainId: { diff --git a/zetaclient/testutils/mocks/tss_signer.go b/zetaclient/testutils/mocks/tss_signer.go index f25386d8df..6226200d08 100644 --- a/zetaclient/testutils/mocks/tss_signer.go +++ b/zetaclient/testutils/mocks/tss_signer.go @@ -54,7 +54,7 @@ func NewTSSMainnet() *TSS { } func NewTSSAthens3() *TSS { - return NewMockTSS(chains.BscTestnetChain, testutils.TSSAddressEVMAthens3, testutils.TSSAddressBTCAthens3) + return NewMockTSS(chains.BscTestnet, testutils.TSSAddressEVMAthens3, testutils.TSSAddressBTCAthens3) } // WithPrivKey sets the private key for the TSS From 075f5bf121457abff15811c19f0ec69ee945d78e Mon Sep 17 00:00:00 2001 From: lumtis Date: Fri, 24 May 2024 10:24:16 +0200 Subject: [PATCH 10/22] bitcoin testnet --- pkg/chains/address_test.go | 24 +++++++++---------- pkg/chains/bitcoin.go | 4 ++-- pkg/chains/bitcoin_test.go | 8 +++---- pkg/chains/chain_test.go | 6 ++--- pkg/chains/chains.go | 6 ++--- pkg/chains/chains_test.go | 8 +++---- x/crosschain/keeper/evm_hooks_test.go | 4 ++-- x/crosschain/migrations/v4/migrate_test.go | 8 +++---- x/crosschain/migrations/v5/migrate.go | 2 +- x/crosschain/migrations/v5/migrate_test.go | 12 +++++----- x/crosschain/types/validate_test.go | 2 +- x/observer/types/chain_params.go | 2 +- .../chains/bitcoin/observer/live_test.go | 2 +- .../chains/bitcoin/observer/observer_test.go | 2 +- zetaclient/chains/bitcoin/tx_script_test.go | 2 +- zetaclient/context/zetacore_context_test.go | 2 +- zetaclient/orchestrator/orchestrator_test.go | 2 +- 17 files changed, 48 insertions(+), 48 deletions(-) diff --git a/pkg/chains/address_test.go b/pkg/chains/address_test.go index 8282fea22b..a9e303e08c 100644 --- a/pkg/chains/address_test.go +++ b/pkg/chains/address_test.go @@ -44,7 +44,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", BitcoinTestnet.ChainId) require.ErrorContains(t, err, "runtime error: index out of range") }) t.Run("invalid chain", func(t *testing.T) { @@ -52,11 +52,11 @@ 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", BitcoinTestnet.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", BitcoinTestnet.ChainId) require.ErrorContains(t, err, "decode address failed") }) t.Run("valid legacy main-net address address incorrect params RegTestNet", func(t *testing.T) { @@ -69,7 +69,7 @@ func TestDecodeBtcAddress(t *testing.T) { 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", BitcoinTestnet.ChainId) require.NoError(t, err) }) @@ -92,7 +92,7 @@ func TestDecodeBtcAddress(t *testing.T) { t.Run("taproot address with incorrect params", func(t *testing.T) { _, err := DecodeBtcAddress( "bc1p4ur084x8y63mj5hj7eydscuc4awals7ly749x8vhyquc0twcmvhquspa5c", - BtcTestNetChain.ChainId, + BitcoinTestnet.ChainId, ) require.ErrorContains(t, err, "not for network testnet") }) @@ -116,7 +116,7 @@ func Test_IsBtcAddressSupported_P2TR(t *testing.T) { // https://mempool.space/testnet/tx/24991bd2fdc4f744bf7bbd915d4915925eecebdae249f81e057c0a6ffb700ab9 name: "testnet taproot address", addr: "tb1p7qqaucx69xtwkx7vwmhz03xjmzxxpy3hk29y7q06mt3k6a8sehhsu5lacw", - chainId: BtcTestNetChain.ChainId, + chainId: BitcoinTestnet.ChainId, supported: true, }, { @@ -160,7 +160,7 @@ func Test_IsBtcAddressSupported_P2WSH(t *testing.T) { // https://mempool.space/testnet/tx/78fac3f0d4c0174c88d21c4bb1e23a8f007e890c6d2cfa64c97389ead16c51ed name: "testnet P2WSH address", addr: "tb1quhassyrlj43qar0mn0k5sufyp6mazmh2q85lr6ex8ehqfhxpzsksllwrsu", - chainId: BtcTestNetChain.ChainId, + chainId: BitcoinTestnet.ChainId, supported: true, }, { @@ -203,7 +203,7 @@ func Test_IsBtcAddressSupported_P2WPKH(t *testing.T) { // https://mempool.space/testnet/tx/508b4d723c754bad001eae9b7f3c12377d3307bd5b595c27fd8a90089094f0e9 name: "testnet P2WPKH address", addr: "tb1q6rufg6myrxurdn0h57d2qhtm9zfmjw2mzcm05q", - chainId: BtcTestNetChain.ChainId, + chainId: BitcoinTestnet.ChainId, supported: true, }, { @@ -246,14 +246,14 @@ func Test_IsBtcAddressSupported_P2SH(t *testing.T) { // https://mempool.space/testnet/tx/0c8c8f94817e0288a5273f5c971adaa3cee18a895c3ec8544785dddcd96f3848 name: "testnet P2SH address 1", addr: "2N6AoUj3KPS7wNGZXuCckh8YEWcSYNsGbqd", - chainId: BtcTestNetChain.ChainId, + chainId: BitcoinTestnet.ChainId, supported: true, }, { // https://mempool.space/testnet/tx/b5e074c5e021fcbd91ea14b1db29dfe5d14e1a6e046039467bf6ada7f8cc01b3 name: "testnet P2SH address 2", addr: "2MwbFpRpZWv4zREjbdLB9jVW3Q8xonpVeyE", - chainId: BtcTestNetChain.ChainId, + chainId: BitcoinTestnet.ChainId, supported: true, }, { @@ -302,14 +302,14 @@ func Test_IsBtcAddressSupported_P2PKH(t *testing.T) { // https://mempool.space/testnet/tx/1e3974386f071de7f65cabb57346c1a22ec9b3e211a96928a98149673f681237 name: "testnet P2PKH address 1", addr: "mxpYha3UJKUgSwsAz2qYRqaDSwAkKZ3YEY", - chainId: BtcTestNetChain.ChainId, + chainId: BitcoinTestnet.ChainId, supported: true, }, { // https://mempool.space/testnet/tx/e48459f372727f2253b0ea8c71ded83e8270873b8a044feb3435fc7a799a648f name: "testnet P2PKH address 2", addr: "n1gXcqxmzwqHmqmgobe1XXuJaweSu69tZz", - chainId: BtcTestNetChain.ChainId, + chainId: BitcoinTestnet.ChainId, supported: true, }, { diff --git a/pkg/chains/bitcoin.go b/pkg/chains/bitcoin.go index 634926e140..fd885e1db4 100644 --- a/pkg/chains/bitcoin.go +++ b/pkg/chains/bitcoin.go @@ -19,7 +19,7 @@ func BitcoinNetParamsFromChainID(chainID int64) (*chaincfg.Params, error) { return BitcoinRegnetParams, nil case BitcoinMainnet.ChainId: return BitcoinMainnetParams, nil - case BtcTestNetChain.ChainId: + case BitcoinTestnet.ChainId: return BitcoinTestnetParams, nil default: return nil, fmt.Errorf("no Bitcoin net params for chain ID: %d", chainID) @@ -34,7 +34,7 @@ func BitcoinChainIDFromNetworkName(name string) (int64, error) { case BitcoinMainnetParams.Name: return BitcoinMainnet.ChainId, nil case BitcoinTestnetParams.Name: - return BtcTestNetChain.ChainId, nil + return BitcoinTestnet.ChainId, nil default: return 0, fmt.Errorf("invalid Bitcoin network name: %s", name) } diff --git a/pkg/chains/bitcoin_test.go b/pkg/chains/bitcoin_test.go index 5a69d2b339..3a9c3413c2 100644 --- a/pkg/chains/bitcoin_test.go +++ b/pkg/chains/bitcoin_test.go @@ -16,7 +16,7 @@ func TestBitcoinNetParamsFromChainID(t *testing.T) { }{ {"Regnet", BtcRegtestChain.ChainId, BitcoinRegnetParams, false}, {"Mainnet", BitcoinMainnet.ChainId, BitcoinMainnetParams, false}, - {"Testnet", BtcTestNetChain.ChainId, BitcoinTestnetParams, false}, + {"Testnet", BitcoinTestnet.ChainId, BitcoinTestnetParams, false}, {"Unknown", -1, nil, true}, } @@ -42,7 +42,7 @@ func TestBitcoinChainIDFromNetParams(t *testing.T) { }{ {"Regnet", BitcoinRegnetParams.Name, BtcRegtestChain.ChainId, false}, {"Mainnet", BitcoinMainnetParams.Name, BitcoinMainnet.ChainId, false}, - {"Testnet", BitcoinTestnetParams.Name, BtcTestNetChain.ChainId, false}, + {"Testnet", BitcoinTestnetParams.Name, BitcoinTestnet.ChainId, false}, {"Unknown", "Unknown", 0, true}, } @@ -63,11 +63,11 @@ func TestBitcoinChainIDFromNetParams(t *testing.T) { func TestIsBitcoinRegnet(t *testing.T) { require.True(t, IsBitcoinRegnet(BtcRegtestChain.ChainId)) require.False(t, IsBitcoinRegnet(BitcoinMainnet.ChainId)) - require.False(t, IsBitcoinRegnet(BtcTestNetChain.ChainId)) + require.False(t, IsBitcoinRegnet(BitcoinTestnet.ChainId)) } func TestIsBitcoinMainnet(t *testing.T) { require.True(t, IsBitcoinMainnet(BitcoinMainnet.ChainId)) require.False(t, IsBitcoinMainnet(BtcRegtestChain.ChainId)) - require.False(t, IsBitcoinMainnet(BtcTestNetChain.ChainId)) + require.False(t, IsBitcoinMainnet(BitcoinTestnet.ChainId)) } diff --git a/pkg/chains/chain_test.go b/pkg/chains/chain_test.go index 2e83321238..ccd67efa84 100644 --- a/pkg/chains/chain_test.go +++ b/pkg/chains/chain_test.go @@ -235,7 +235,7 @@ func TestIsBitcoinChain(t *testing.T) { want bool }{ {"Bitcoin Mainnet", BitcoinMainnet.ChainId, true}, - {"Bitcoin Testnet", BtcTestNetChain.ChainId, true}, + {"Bitcoin Testnet", BitcoinTestnet.ChainId, true}, {"Bitcoin Regtest", BtcRegtestChain.ChainId, true}, {"Non-Bitcoin", Ethereum.ChainId, false}, {"Zeta Mainnet", ZetaChainMainnet.ChainId, false}, @@ -296,7 +296,7 @@ func TestChain_WitnessProgram(t *testing.T) { addr, err := btcutil.NewAddressWitnessPubKeyHash(pubKeyHash, &chaincfg.RegressionNetParams) require.NoError(t, err) - chain := BtcTestNetChain + chain := BitcoinTestnet _, err = chain.BTCAddressFromWitnessProgram(addr.WitnessProgram()) require.NoError(t, err) }) @@ -318,7 +318,7 @@ func TestChain_WitnessProgram(t *testing.T) { addr, err := btcutil.NewAddressWitnessPubKeyHash(pubKeyHash, &chaincfg.RegressionNetParams) require.NoError(t, err) - chain := BtcTestNetChain + chain := BitcoinTestnet _, err = chain.BTCAddressFromWitnessProgram(addr.WitnessProgram()[0:19]) require.Error(t, err) }) diff --git a/pkg/chains/chains.go b/pkg/chains/chains.go index 7ec6ba0d62..76e894d620 100644 --- a/pkg/chains/chains.go +++ b/pkg/chains/chains.go @@ -121,8 +121,8 @@ var ( IsExternal: true, } - // BtcTestNetChain is Bitcoin testnet3 - BtcTestNetChain = Chain{ + // BitcoinTestnet is Bitcoin testnet3 + BitcoinTestnet = Chain{ ChainName: ChainName_btc_testnet, ChainId: 18332, Network: Network_btc, @@ -255,7 +255,7 @@ func DefaultChainsList() []*Chain { BitcoinMainnet, BscMainnet, Ethereum, - BtcTestNetChain, + BitcoinTestnet, MumbaiChain, AmoyChain, BscTestnet, diff --git a/pkg/chains/chains_test.go b/pkg/chains/chains_test.go index a47f9726d9..fc400ad110 100644 --- a/pkg/chains/chains_test.go +++ b/pkg/chains/chains_test.go @@ -30,7 +30,7 @@ func TestChainListByNetworkType(t *testing.T) { NetworkType_testnet, []*Chain{ &ZetaChainTestnet, - &BtcTestNetChain, + &BitcoinTestnet, &MumbaiChain, &AmoyChain, &BscTestnet, @@ -72,7 +72,7 @@ func TestChainListByNetwork(t *testing.T) { { "Btc", Network_btc, - []*Chain{&BitcoinMainnet, &BtcTestNetChain, &BtcRegtestChain}, + []*Chain{&BitcoinMainnet, &BitcoinTestnet, &BtcRegtestChain}, }, { "Eth", @@ -120,7 +120,7 @@ func TestChainListFunctions(t *testing.T) { &BitcoinMainnet, &BscMainnet, &Ethereum, - &BtcTestNetChain, + &BitcoinTestnet, &MumbaiChain, &AmoyChain, &BscTestnet, @@ -146,7 +146,7 @@ func TestChainListFunctions(t *testing.T) { &BitcoinMainnet, &BscMainnet, &Ethereum, - &BtcTestNetChain, + &BitcoinTestnet, &MumbaiChain, &AmoyChain, &BscTestnet, diff --git a/x/crosschain/keeper/evm_hooks_test.go b/x/crosschain/keeper/evm_hooks_test.go index 9112aea3f6..3ec4b49e65 100644 --- a/x/crosschain/keeper/evm_hooks_test.go +++ b/x/crosschain/keeper/evm_hooks_test.go @@ -179,7 +179,7 @@ func TestValidateZrc20WithdrawEvent(t *testing.T) { *sample.GetValidZRC20WithdrawToBTC(t).Logs[3], ) require.NoError(t, err) - err = crosschainkeeper.ValidateZrc20WithdrawEvent(btcMainNetWithdrawalEvent, chains.BtcTestNetChain.ChainId) + err = crosschainkeeper.ValidateZrc20WithdrawEvent(btcMainNetWithdrawalEvent, chains.BitcoinTestnet.ChainId) require.ErrorContains(t, err, "invalid address") }) @@ -820,7 +820,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.BitcoinTestnet chainID := chain.ChainId setSupportedChain(ctx, zk, chainID) SetupStateForProcessLogs(t, ctx, k, zk, sdkk, chain) diff --git a/x/crosschain/migrations/v4/migrate_test.go b/x/crosschain/migrations/v4/migrate_test.go index 0457c5520b..51a38aca89 100644 --- a/x/crosschain/migrations/v4/migrate_test.go +++ b/x/crosschain/migrations/v4/migrate_test.go @@ -122,14 +122,14 @@ func TestSetBitcoinFinalizedInbound(t *testing.T) { k.SetCrossChainTx(ctx, types.CrossChainTx{ Index: "3", InboundParams: &types.InboundParams{ - SenderChainId: chains.BtcTestNetChain.ChainId, + SenderChainId: chains.BitcoinTestnet.ChainId, ObservedHash: "0x222", }, }) k.SetCrossChainTx(ctx, types.CrossChainTx{ Index: "4", InboundParams: &types.InboundParams{ - SenderChainId: chains.BtcTestNetChain.ChainId, + SenderChainId: chains.BitcoinTestnet.ChainId, ObservedHash: "0x333", }, }) @@ -156,8 +156,8 @@ func TestSetBitcoinFinalizedInbound(t *testing.T) { require.False(t, k.IsFinalizedInbound(ctx, "0xbbb", chains.Ethereum.ChainId, 0)) require.False(t, k.IsFinalizedInbound(ctx, "0xccc", chains.MumbaiChain.ChainId, 0)) require.True(t, k.IsFinalizedInbound(ctx, "0x111", chains.BitcoinMainnet.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, "0x222", chains.BitcoinTestnet.ChainId, 0)) + require.True(t, k.IsFinalizedInbound(ctx, "0x333", chains.BitcoinTestnet.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 9bd6518c8c..e91badf028 100644 --- a/x/crosschain/migrations/v5/migrate.go +++ b/x/crosschain/migrations/v5/migrate.go @@ -81,7 +81,7 @@ func CurrentTestnetChains() []TestnetNonce { {chain: chains.GoerliChain, nonceHigh: 226841, nonceLow: 226841}, {chain: chains.MumbaiChain, nonceHigh: 200599, nonceLow: 200599}, {chain: chains.BscTestnet, nonceHigh: 110454, nonceLow: 110454}, - {chain: chains.BtcTestNetChain, nonceHigh: 4881, nonceLow: 4881}, + {chain: chains.BitcoinTestnet, nonceHigh: 4881, nonceLow: 4881}, } } diff --git a/x/crosschain/migrations/v5/migrate_test.go b/x/crosschain/migrations/v5/migrate_test.go index 7195f80e3b..3973820547 100644 --- a/x/crosschain/migrations/v5/migrate_test.go +++ b/x/crosschain/migrations/v5/migrate_test.go @@ -76,7 +76,7 @@ func TestResetTestnetNonce(t *testing.T) { chains.GoerliChain, chains.MumbaiChain, chains.BscTestnet, - chains.BtcTestNetChain, + chains.BitcoinTestnet, } mainnetChains := []chains.Chain{chains.Ethereum, chains.BscMainnet, chains.BitcoinMainnet} nonceLow := int64(1) @@ -112,10 +112,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.BscTestnet: 110454, - chains.BtcTestNetChain: 4881, + chains.GoerliChain: 226841, + chains.MumbaiChain: 200599, + chains.BscTestnet: 110454, + chains.BitcoinTestnet: 4881, } for _, chain := range testnetChains { @@ -163,7 +163,7 @@ func TestResetTestnetNonce(t *testing.T) { assertValuesSet := map[chains.Chain]int64{ chains.GoerliChain: 226841, } - assertValuesNotSet := []chains.Chain{chains.MumbaiChain, chains.BscTestnet, chains.BtcTestNetChain} + assertValuesNotSet := []chains.Chain{chains.MumbaiChain, chains.BscTestnet, chains.BitcoinTestnet} for _, chain := range testnetChains { pn, found := zk.ObserverKeeper.GetPendingNonces(ctx, tss.TssPubkey, chain.ChainId) diff --git a/x/crosschain/types/validate_test.go b/x/crosschain/types/validate_test.go index 957d3ab436..f335ad3513 100644 --- a/x/crosschain/types/validate_test.go +++ b/x/crosschain/types/validate_test.go @@ -95,7 +95,7 @@ func TestValidateHashForChain(t *testing.T) { t, types.ValidateHashForChain( "a0fa5a82f106fb192e4c503bfa8d54b2de20a821e09338094ab825cc9b275059", - chains.BtcTestNetChain.ChainId, + chains.BitcoinTestnet.ChainId, ), ) require.Error( diff --git a/x/observer/types/chain_params.go b/x/observer/types/chain_params.go index 7ea7a66128..0e02ff2a60 100644 --- a/x/observer/types/chain_params.go +++ b/x/observer/types/chain_params.go @@ -273,7 +273,7 @@ func GetDefaultMumbaiTestnetChainParams() *ChainParams { } func GetDefaultBtcTestnetChainParams() *ChainParams { return &ChainParams{ - ChainId: chains.BtcTestNetChain.ChainId, + ChainId: chains.BitcoinTestnet.ChainId, ConfirmationCount: 2, ZetaTokenContractAddress: zeroAddress, ConnectorContractAddress: zeroAddress, diff --git a/zetaclient/chains/bitcoin/observer/live_test.go b/zetaclient/chains/bitcoin/observer/live_test.go index abc0545db6..c7eb63de51 100644 --- a/zetaclient/chains/bitcoin/observer/live_test.go +++ b/zetaclient/chains/bitcoin/observer/live_test.go @@ -416,7 +416,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.BitcoinTestnet.ChainId { testnet = true } diff --git a/zetaclient/chains/bitcoin/observer/observer_test.go b/zetaclient/chains/bitcoin/observer/observer_test.go index a352378b45..dfba6b3dbc 100644 --- a/zetaclient/chains/bitcoin/observer/observer_test.go +++ b/zetaclient/chains/bitcoin/observer/observer_test.go @@ -74,7 +74,7 @@ func TestNewBitcoinObserver(t *testing.T) { appContext := context.NewAppContext(coreContext, cfg) chain := chains.BitcoinMainnet zetacoreClient := mocks.NewMockZetacoreClient() - tss := mocks.NewMockTSS(chains.BtcTestNetChain, sample.EthAddress().String(), "") + tss := mocks.NewMockTSS(chains.BitcoinTestnet, sample.EthAddress().String(), "") loggers := clientcommon.ClientLogger{} btcCfg := cfg.BitcoinConfig ts := metrics.NewTelemetryServer() diff --git a/zetaclient/chains/bitcoin/tx_script_test.go b/zetaclient/chains/bitcoin/tx_script_test.go index e9e907aae7..eea97fc7b5 100644 --- a/zetaclient/chains/bitcoin/tx_script_test.go +++ b/zetaclient/chains/bitcoin/tx_script_test.go @@ -476,7 +476,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.BitcoinTestnet receiver, amount, err := DecodeTSSVout(invalidVout, "bc1qulmx8ej27cj0xe20953cztr2excnmsqvuh0s5c", wrongChain) require.ErrorContains(t, err, "error decoding receiver") require.Empty(t, receiver) diff --git a/zetaclient/context/zetacore_context_test.go b/zetaclient/context/zetacore_context_test.go index e1e57b8f56..0ee7d5bc8a 100644 --- a/zetaclient/context/zetacore_context_test.go +++ b/zetaclient/context/zetacore_context_test.go @@ -277,7 +277,7 @@ func TestUpdateZetacoreContext(t *testing.T) { }, } - testBtcChain := chains.BtcTestNetChain + testBtcChain := chains.BitcoinTestnet btcChainParamsToUpdate := &observertypes.ChainParams{ ChainId: testBtcChain.ChainId, } diff --git a/zetaclient/orchestrator/orchestrator_test.go b/zetaclient/orchestrator/orchestrator_test.go index f0508d371f..4494829984 100644 --- a/zetaclient/orchestrator/orchestrator_test.go +++ b/zetaclient/orchestrator/orchestrator_test.go @@ -190,7 +190,7 @@ func Test_GetUpdatedChainObserver(t *testing.T) { orchestrator := MockOrchestrator(t, nil, evmChain, btcChain, evmChainParams, btcChainParams) coreContext := CreateCoreContext(btcChain, btcChain, evmChainParams, btcChainParamsNew) // BTC testnet chain observer should not be found - _, err := orchestrator.GetUpdatedChainObserver(coreContext, chains.BtcTestNetChain.ChainId) + _, err := orchestrator.GetUpdatedChainObserver(coreContext, chains.BitcoinTestnet.ChainId) require.ErrorContains(t, err, "chain observer not found") }) t.Run("chain params in btc chain observer should be updated successfully", func(t *testing.T) { From 063e4a413d73d3525539bee5e760b35513a6f0ab Mon Sep 17 00:00:00 2001 From: lumtis Date: Fri, 24 May 2024 10:24:54 +0200 Subject: [PATCH 11/22] amoy --- pkg/chains/chains.go | 6 +++--- pkg/chains/chains_test.go | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pkg/chains/chains.go b/pkg/chains/chains.go index 76e894d620..60f2154c29 100644 --- a/pkg/chains/chains.go +++ b/pkg/chains/chains.go @@ -132,8 +132,8 @@ var ( IsExternal: true, } - // AmoyChain is Polygon amoy testnet - AmoyChain = Chain{ + // Amoy is Polygon amoy testnet + Amoy = Chain{ ChainName: ChainName_amoy_testnet, ChainId: 80002, Network: Network_polygon, @@ -257,7 +257,7 @@ func DefaultChainsList() []*Chain { Ethereum, BitcoinTestnet, MumbaiChain, - AmoyChain, + Amoy, BscTestnet, GoerliChain, Sepolia, diff --git a/pkg/chains/chains_test.go b/pkg/chains/chains_test.go index fc400ad110..3b073794dd 100644 --- a/pkg/chains/chains_test.go +++ b/pkg/chains/chains_test.go @@ -32,7 +32,7 @@ func TestChainListByNetworkType(t *testing.T) { &ZetaChainTestnet, &BitcoinTestnet, &MumbaiChain, - &AmoyChain, + &Amoy, &BscTestnet, &GoerliChain, &Sepolia, @@ -87,7 +87,7 @@ func TestChainListByNetwork(t *testing.T) { { "Polygon", Network_polygon, - []*Chain{&Polygon, &MumbaiChain, &AmoyChain}, + []*Chain{&Polygon, &MumbaiChain, &Amoy}, }, { "Optimism", @@ -122,7 +122,7 @@ func TestChainListFunctions(t *testing.T) { &Ethereum, &BitcoinTestnet, &MumbaiChain, - &AmoyChain, + &Amoy, &BscTestnet, &GoerliChain, &Sepolia, @@ -148,7 +148,7 @@ func TestChainListFunctions(t *testing.T) { &Ethereum, &BitcoinTestnet, &MumbaiChain, - &AmoyChain, + &Amoy, &BscTestnet, &GoerliChain, &Sepolia, From d86c6ca35a0f6f639af7d1ca16aed5f367df9a5d Mon Sep 17 00:00:00 2001 From: lumtis Date: Fri, 24 May 2024 10:26:19 +0200 Subject: [PATCH 12/22] zetachain devnet --- pkg/chains/chain_test.go | 4 ++-- pkg/chains/chains.go | 10 +++++----- pkg/chains/chains_test.go | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/pkg/chains/chain_test.go b/pkg/chains/chain_test.go index ccd67efa84..8c5509feca 100644 --- a/pkg/chains/chain_test.go +++ b/pkg/chains/chain_test.go @@ -139,7 +139,7 @@ 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, ZetaDevnet.InChainList(ChainListByNetwork(Network_zeta))) require.True(t, ZetaPrivnetChain.InChainList(ChainListByNetwork(Network_zeta))) require.True(t, ZetaChainTestnet.InChainList(ChainListByNetwork(Network_zeta))) require.False(t, Ethereum.InChainList(ChainListByNetwork(Network_zeta))) @@ -153,7 +153,7 @@ func TestIsZetaChain(t *testing.T) { }{ {"Zeta Mainnet", ZetaChainMainnet.ChainId, true}, {"Zeta Testnet", ZetaChainTestnet.ChainId, true}, - {"Zeta Mocknet", ZetaMocknetChain.ChainId, true}, + {"Zeta Mocknet", ZetaDevnet.ChainId, true}, {"Zeta Privnet", ZetaPrivnetChain.ChainId, true}, {"Non-Zeta", Ethereum.ChainId, false}, } diff --git a/pkg/chains/chains.go b/pkg/chains/chains.go index 60f2154c29..2bbf22c4cf 100644 --- a/pkg/chains/chains.go +++ b/pkg/chains/chains.go @@ -169,9 +169,9 @@ var ( * Devnet chains */ - // ZetaMocknetChain is the mocknet chain for Zeta + // ZetaDevnet is the devnet chain for Zeta // used as live testing environment - ZetaMocknetChain = Chain{ + ZetaDevnet = Chain{ ChainName: ChainName_zeta_mainnet, ChainId: 70000, Network: Network_zeta, @@ -265,7 +265,7 @@ func DefaultChainsList() []*Chain { GoerliLocalnetChain, ZetaChainMainnet, ZetaChainTestnet, - ZetaMocknetChain, + ZetaDevnet, ZetaPrivnetChain, Polygon, OptimismMainnet, @@ -344,8 +344,8 @@ func ZetaChainFromChainID(chainID string) (Chain, error) { return ZetaChainMainnet, nil case ZetaChainTestnet.ChainId: return ZetaChainTestnet, nil - case ZetaMocknetChain.ChainId: - return ZetaMocknetChain, nil + case ZetaDevnet.ChainId: + return ZetaDevnet, 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 3b073794dd..33ebb51ffd 100644 --- a/pkg/chains/chains_test.go +++ b/pkg/chains/chains_test.go @@ -67,7 +67,7 @@ func TestChainListByNetwork(t *testing.T) { { "Zeta", Network_zeta, - []*Chain{&ZetaChainMainnet, &ZetaMocknetChain, &ZetaPrivnetChain, &ZetaChainTestnet}, + []*Chain{&ZetaChainMainnet, &ZetaDevnet, &ZetaPrivnetChain, &ZetaChainTestnet}, }, { "Btc", @@ -130,7 +130,7 @@ func TestChainListFunctions(t *testing.T) { &GoerliLocalnetChain, &ZetaChainMainnet, &ZetaChainTestnet, - &ZetaMocknetChain, + &ZetaDevnet, &ZetaPrivnetChain, &Polygon, &OptimismMainnet, @@ -191,9 +191,9 @@ func TestZetaChainFromChainID(t *testing.T) { wantErr: false, }, { - name: "ZetaMocknetChain", + name: "ZetaDevnet", chainID: "cosmoshub_70000-1", - expected: ZetaMocknetChain, + expected: ZetaDevnet, wantErr: false, }, { From c1d2be5879fa385535f31ef5e9b7797dc6605a21 Mon Sep 17 00:00:00 2001 From: lumtis Date: Fri, 24 May 2024 10:26:41 +0200 Subject: [PATCH 13/22] zetachain privnet --- pkg/chains/chain_test.go | 4 ++-- pkg/chains/chains.go | 10 +++++----- pkg/chains/chains_test.go | 10 +++++----- x/crosschain/keeper/gas_payment_test.go | 16 ++++++++-------- x/crosschain/keeper/process_inbound_test.go | 18 +++++++++--------- x/crosschain/migrations/v5/migrate_test.go | 2 +- x/lightclient/keeper/proof_test.go | 4 ++-- .../message_disable_verification_flags_test.go | 4 ++-- .../message_enable_verification_flags_test.go | 4 ++-- .../keeper/grpc_query_chain_params_test.go | 6 +++--- x/observer/keeper/vote_inbound_test.go | 14 +++++++------- x/observer/types/chain_params.go | 2 +- 12 files changed, 47 insertions(+), 47 deletions(-) diff --git a/pkg/chains/chain_test.go b/pkg/chains/chain_test.go index 8c5509feca..c70c73e8a6 100644 --- a/pkg/chains/chain_test.go +++ b/pkg/chains/chain_test.go @@ -140,7 +140,7 @@ func TestChain_DecodeAddress(t *testing.T) { func TestChain_InChainList(t *testing.T) { require.True(t, ZetaChainMainnet.InChainList(ChainListByNetwork(Network_zeta))) require.True(t, ZetaDevnet.InChainList(ChainListByNetwork(Network_zeta))) - require.True(t, ZetaPrivnetChain.InChainList(ChainListByNetwork(Network_zeta))) + require.True(t, ZetaPrivnet.InChainList(ChainListByNetwork(Network_zeta))) require.True(t, ZetaChainTestnet.InChainList(ChainListByNetwork(Network_zeta))) require.False(t, Ethereum.InChainList(ChainListByNetwork(Network_zeta))) } @@ -154,7 +154,7 @@ func TestIsZetaChain(t *testing.T) { {"Zeta Mainnet", ZetaChainMainnet.ChainId, true}, {"Zeta Testnet", ZetaChainTestnet.ChainId, true}, {"Zeta Mocknet", ZetaDevnet.ChainId, true}, - {"Zeta Privnet", ZetaPrivnetChain.ChainId, true}, + {"Zeta Privnet", ZetaPrivnet.ChainId, true}, {"Non-Zeta", Ethereum.ChainId, false}, } diff --git a/pkg/chains/chains.go b/pkg/chains/chains.go index 2bbf22c4cf..5b3639008d 100644 --- a/pkg/chains/chains.go +++ b/pkg/chains/chains.go @@ -185,8 +185,8 @@ var ( * Privnet chains */ - // ZetaPrivnetChain is the privnet chain for Zeta (localnet) - ZetaPrivnetChain = Chain{ + // ZetaPrivnet is the privnet chain for Zeta (localnet) + ZetaPrivnet = Chain{ ChainName: ChainName_zeta_mainnet, ChainId: 101, Network: Network_zeta, @@ -266,7 +266,7 @@ func DefaultChainsList() []*Chain { ZetaChainMainnet, ZetaChainTestnet, ZetaDevnet, - ZetaPrivnetChain, + ZetaPrivnet, Polygon, OptimismMainnet, OptimismSepolia, @@ -338,8 +338,8 @@ func ZetaChainFromChainID(chainID string) (Chain, error) { } switch ethChainID { - case ZetaPrivnetChain.ChainId: - return ZetaPrivnetChain, nil + case ZetaPrivnet.ChainId: + return ZetaPrivnet, nil case ZetaChainMainnet.ChainId: return ZetaChainMainnet, nil case ZetaChainTestnet.ChainId: diff --git a/pkg/chains/chains_test.go b/pkg/chains/chains_test.go index 33ebb51ffd..08d672dc60 100644 --- a/pkg/chains/chains_test.go +++ b/pkg/chains/chains_test.go @@ -44,7 +44,7 @@ func TestChainListByNetworkType(t *testing.T) { "privnet chains", NetworkType_privnet, []*Chain{ - &ZetaPrivnetChain, + &ZetaPrivnet, &BtcRegtestChain, &GoerliLocalnetChain, }, @@ -67,7 +67,7 @@ func TestChainListByNetwork(t *testing.T) { { "Zeta", Network_zeta, - []*Chain{&ZetaChainMainnet, &ZetaDevnet, &ZetaPrivnetChain, &ZetaChainTestnet}, + []*Chain{&ZetaChainMainnet, &ZetaDevnet, &ZetaPrivnet, &ZetaChainTestnet}, }, { "Btc", @@ -131,7 +131,7 @@ func TestChainListFunctions(t *testing.T) { &ZetaChainMainnet, &ZetaChainTestnet, &ZetaDevnet, - &ZetaPrivnetChain, + &ZetaPrivnet, &Polygon, &OptimismMainnet, &OptimismSepolia, @@ -197,9 +197,9 @@ func TestZetaChainFromChainID(t *testing.T) { wantErr: false, }, { - name: "ZetaPrivnetChain", + name: "ZetaPrivnet", chainID: "cosmoshub_101-1", - expected: ZetaPrivnetChain, + expected: ZetaPrivnet, wantErr: false, }, { diff --git a/x/crosschain/keeper/gas_payment_test.go b/x/crosschain/keeper/gas_payment_test.go index 23d1888669..8a4f62abd0 100644 --- a/x/crosschain/keeper/gas_payment_test.go +++ b/x/crosschain/keeper/gas_payment_test.go @@ -51,7 +51,7 @@ func TestKeeper_PayGasNativeAndUpdateCctx(t *testing.T) { }, OutboundParams: []*types.OutboundParams{ { - ReceiverChainId: chains.ZetaPrivnetChain.ChainId, + ReceiverChainId: chains.ZetaPrivnet.ChainId, CoinType: coin.CoinType_Gas, }, { @@ -109,7 +109,7 @@ func TestKeeper_PayGasNativeAndUpdateCctx(t *testing.T) { }, OutboundParams: []*types.OutboundParams{ { - ReceiverChainId: chains.ZetaPrivnetChain.ChainId, + ReceiverChainId: chains.ZetaPrivnet.ChainId, }, { ReceiverChainId: chainID, @@ -148,7 +148,7 @@ func TestKeeper_PayGasNativeAndUpdateCctx(t *testing.T) { }, OutboundParams: []*types.OutboundParams{ { - ReceiverChainId: chains.ZetaPrivnetChain.ChainId, + ReceiverChainId: chains.ZetaPrivnet.ChainId, }, { ReceiverChainId: chainID, @@ -211,7 +211,7 @@ func TestKeeper_PayGasInERC20AndUpdateCctx(t *testing.T) { }, OutboundParams: []*types.OutboundParams{ { - ReceiverChainId: chains.ZetaPrivnetChain.ChainId, + ReceiverChainId: chains.ZetaPrivnet.ChainId, }, { ReceiverChainId: chainID, @@ -273,7 +273,7 @@ func TestKeeper_PayGasInERC20AndUpdateCctx(t *testing.T) { }, OutboundParams: []*types.OutboundParams{ { - ReceiverChainId: chains.ZetaPrivnetChain.ChainId, + ReceiverChainId: chains.ZetaPrivnet.ChainId, }, { ReceiverChainId: chainID, @@ -315,7 +315,7 @@ func TestKeeper_PayGasInERC20AndUpdateCctx(t *testing.T) { }, OutboundParams: []*types.OutboundParams{ { - ReceiverChainId: chains.ZetaPrivnetChain.ChainId, + ReceiverChainId: chains.ZetaPrivnet.ChainId, }, { ReceiverChainId: chainID, @@ -367,7 +367,7 @@ func TestKeeper_PayGasInERC20AndUpdateCctx(t *testing.T) { }, OutboundParams: []*types.OutboundParams{ { - ReceiverChainId: chains.ZetaPrivnetChain.ChainId, + ReceiverChainId: chains.ZetaPrivnet.ChainId, }, { ReceiverChainId: chainID, @@ -425,7 +425,7 @@ func TestKeeper_PayGasInERC20AndUpdateCctx(t *testing.T) { }, OutboundParams: []*types.OutboundParams{ { - ReceiverChainId: chains.ZetaPrivnetChain.ChainId, + ReceiverChainId: chains.ZetaPrivnet.ChainId, }, { ReceiverChainId: chainID, diff --git a/x/crosschain/keeper/process_inbound_test.go b/x/crosschain/keeper/process_inbound_test.go index c091b75ad1..04472327b4 100644 --- a/x/crosschain/keeper/process_inbound_test.go +++ b/x/crosschain/keeper/process_inbound_test.go @@ -38,7 +38,7 @@ func TestKeeper_ProcessInboundZEVMDeposit(t *testing.T) { cctx := sample.CrossChainTx(t, "test") cctx.CctxStatus = &types.Status{Status: types.CctxStatus_PendingInbound} cctx.GetCurrentOutboundParam().Receiver = receiver.String() - cctx.GetCurrentOutboundParam().ReceiverChainId = chains.ZetaPrivnetChain.ChainId + cctx.GetCurrentOutboundParam().ReceiverChainId = chains.ZetaPrivnet.ChainId cctx.GetInboundParams().Amount = sdkmath.NewUintFromBigInt(amount) cctx.InboundParams.CoinType = coin.CoinType_Zeta cctx.GetInboundParams().SenderChainId = 0 @@ -65,7 +65,7 @@ func TestKeeper_ProcessInboundZEVMDeposit(t *testing.T) { cctx := sample.CrossChainTx(t, "test") cctx.CctxStatus = &types.Status{Status: types.CctxStatus_PendingInbound} cctx.GetCurrentOutboundParam().Receiver = receiver.String() - cctx.GetCurrentOutboundParam().ReceiverChainId = chains.ZetaPrivnetChain.ChainId + cctx.GetCurrentOutboundParam().ReceiverChainId = chains.ZetaPrivnet.ChainId cctx.GetInboundParams().Amount = sdkmath.NewUintFromBigInt(amount) cctx.InboundParams.CoinType = coin.CoinType_Zeta cctx.GetInboundParams().SenderChainId = 0 @@ -100,7 +100,7 @@ func TestKeeper_ProcessInboundZEVMDeposit(t *testing.T) { // call ProcessInbound cctx := GetERC20Cctx(t, receiver, *senderChain, "", amount) - cctx.GetCurrentOutboundParam().ReceiverChainId = chains.ZetaPrivnetChain.ChainId + cctx.GetCurrentOutboundParam().ReceiverChainId = chains.ZetaPrivnet.ChainId k.ProcessInbound(ctx, cctx) require.Equal(t, types.CctxStatus_Aborted, cctx.CctxStatus.Status) require.Equal( @@ -138,7 +138,7 @@ func TestKeeper_ProcessInboundZEVMDeposit(t *testing.T) { // call ProcessInbound cctx := GetERC20Cctx(t, receiver, *senderChain, asset, amount) - cctx.GetCurrentOutboundParam().ReceiverChainId = chains.ZetaPrivnetChain.ChainId + cctx.GetCurrentOutboundParam().ReceiverChainId = chains.ZetaPrivnet.ChainId k.ProcessInbound(ctx, cctx) require.Equal(t, types.CctxStatus_Aborted, cctx.CctxStatus.Status) require.Equal( @@ -181,7 +181,7 @@ func TestKeeper_ProcessInboundZEVMDeposit(t *testing.T) { // call ProcessInbound cctx := GetERC20Cctx(t, receiver, *senderChain, asset, amount) - cctx.GetCurrentOutboundParam().ReceiverChainId = chains.ZetaPrivnetChain.ChainId + cctx.GetCurrentOutboundParam().ReceiverChainId = chains.ZetaPrivnet.ChainId k.ProcessInbound(ctx, cctx) require.Equal(t, types.CctxStatus_Aborted, cctx.CctxStatus.Status) require.Equal( @@ -225,7 +225,7 @@ func TestKeeper_ProcessInboundZEVMDeposit(t *testing.T) { // call ProcessInbound cctx := GetERC20Cctx(t, receiver, *senderChain, asset, amount) - cctx.GetCurrentOutboundParam().ReceiverChainId = chains.ZetaPrivnetChain.ChainId + cctx.GetCurrentOutboundParam().ReceiverChainId = chains.ZetaPrivnet.ChainId k.ProcessInbound(ctx, cctx) require.Equal(t, types.CctxStatus_Aborted, cctx.CctxStatus.Status) require.Equal( @@ -270,7 +270,7 @@ func TestKeeper_ProcessInboundZEVMDeposit(t *testing.T) { // call ProcessInbound cctx := GetERC20Cctx(t, receiver, *senderChain, asset, amount) - cctx.GetCurrentOutboundParam().ReceiverChainId = chains.ZetaPrivnetChain.ChainId + cctx.GetCurrentOutboundParam().ReceiverChainId = chains.ZetaPrivnet.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") @@ -308,7 +308,7 @@ func TestKeeper_ProcessInboundZEVMDeposit(t *testing.T) { // call ProcessInbound cctx := GetERC20Cctx(t, receiver, *senderChain, asset, amount) - cctx.GetCurrentOutboundParam().ReceiverChainId = chains.ZetaPrivnetChain.ChainId + cctx.GetCurrentOutboundParam().ReceiverChainId = chains.ZetaPrivnet.ChainId k.ProcessInbound(ctx, cctx) require.Equal(t, types.CctxStatus_PendingRevert, cctx.CctxStatus.Status) require.Equal(t, errDeposit.Error(), cctx.CctxStatus.StatusMessage) @@ -344,7 +344,7 @@ func TestKeeper_ProcessInboundZEVMDeposit(t *testing.T) { // call ProcessInbound cctx := GetERC20Cctx(t, receiver, *senderChain, asset, amount) - cctx.GetCurrentOutboundParam().ReceiverChainId = chains.ZetaPrivnetChain.ChainId + cctx.GetCurrentOutboundParam().ReceiverChainId = chains.ZetaPrivnet.ChainId cctx.OutboundParams = append(cctx.OutboundParams, cctx.GetCurrentOutboundParam()) k.ProcessInbound(ctx, cctx) require.Equal(t, types.CctxStatus_Aborted, cctx.CctxStatus.Status) diff --git a/x/crosschain/migrations/v5/migrate_test.go b/x/crosschain/migrations/v5/migrate_test.go index 3973820547..6d869ffd19 100644 --- a/x/crosschain/migrations/v5/migrate_test.go +++ b/x/crosschain/migrations/v5/migrate_test.go @@ -228,7 +228,7 @@ func CrossChainTxList(count int) []crosschaintypes.CrossChainTx { OutboundParams: []*crosschaintypes.OutboundParams{{ Amount: math.ZeroUint(), CoinType: coin.CoinType_ERC20, - ReceiverChainId: chains.ZetaPrivnetChain.ChainId, + ReceiverChainId: chains.ZetaPrivnet.ChainId, }}, } } diff --git a/x/lightclient/keeper/proof_test.go b/x/lightclient/keeper/proof_test.go index 95e1ab3e6f..2491dc8f65 100644 --- a/x/lightclient/keeper/proof_test.go +++ b/x/lightclient/keeper/proof_test.go @@ -68,11 +68,11 @@ func TestKeeper_VerifyProof(t *testing.T) { }, }) - _, err := k.VerifyProof(ctx, &proofs.Proof{}, chains.ZetaPrivnetChain.ChainId, sample.Hash().String(), 1) + _, err := k.VerifyProof(ctx, &proofs.Proof{}, chains.ZetaPrivnet.ChainId, sample.Hash().String(), 1) require.ErrorContains( t, err, - fmt.Sprintf("proof verification is disabled for chain %d", chains.ZetaPrivnetChain.ChainId), + fmt.Sprintf("proof verification is disabled for chain %d", chains.ZetaPrivnet.ChainId), ) }) diff --git a/x/lightclient/types/message_disable_verification_flags_test.go b/x/lightclient/types/message_disable_verification_flags_test.go index 06f173ff4e..83eb923b0a 100644 --- a/x/lightclient/types/message_disable_verification_flags_test.go +++ b/x/lightclient/types/message_disable_verification_flags_test.go @@ -54,14 +54,14 @@ func TestMsgDisableHeaderVerification_ValidateBasic(t *testing.T) { name: "invalid chain id", msg: types.MsgDisableHeaderVerification{ Creator: sample.AccAddress(), - ChainIdList: []int64{chains.ZetaPrivnetChain.ChainId}, + ChainIdList: []int64{chains.ZetaPrivnet.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.ZetaPrivnetChain.ChainId), + fmt.Sprintf("invalid chain id header not supported (%d)", chains.ZetaPrivnet.ChainId), ) }, }, diff --git a/x/lightclient/types/message_enable_verification_flags_test.go b/x/lightclient/types/message_enable_verification_flags_test.go index 8062681984..5fd731c9d3 100644 --- a/x/lightclient/types/message_enable_verification_flags_test.go +++ b/x/lightclient/types/message_enable_verification_flags_test.go @@ -54,14 +54,14 @@ func TestMsgEnableHeaderVerification_ValidateBasic(t *testing.T) { name: "invalid chain id", msg: types.MsgEnableHeaderVerification{ Creator: sample.AccAddress(), - ChainIdList: []int64{chains.ZetaPrivnetChain.ChainId}, + ChainIdList: []int64{chains.ZetaPrivnet.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.ZetaPrivnetChain.ChainId), + fmt.Sprintf("invalid chain id header not supported (%d)", chains.ZetaPrivnet.ChainId), ) }, }, diff --git a/x/observer/keeper/grpc_query_chain_params_test.go b/x/observer/keeper/grpc_query_chain_params_test.go index c1ca70a9d3..b7ce955681 100644 --- a/x/observer/keeper/grpc_query_chain_params_test.go +++ b/x/observer/keeper/grpc_query_chain_params_test.go @@ -39,7 +39,7 @@ func TestKeeper_GetChainParamsForChain(t *testing.T) { list := types.ChainParamsList{ ChainParams: []*types.ChainParams{ { - ChainId: chains.ZetaPrivnetChain.ChainId, + ChainId: chains.ZetaPrivnet.ChainId, IsSupported: false, BallotThreshold: sdk.ZeroDec(), MinObserverDelegation: sdk.ZeroDec(), @@ -49,7 +49,7 @@ func TestKeeper_GetChainParamsForChain(t *testing.T) { k.SetChainParamsList(ctx, list) res, err := k.GetChainParamsForChain(wctx, &types.QueryGetChainParamsForChainRequest{ - ChainId: chains.ZetaPrivnetChain.ChainId, + ChainId: chains.ZetaPrivnet.ChainId, }) require.NoError(t, err) require.Equal(t, &types.QueryGetChainParamsForChainResponse{ @@ -84,7 +84,7 @@ func TestKeeper_GetChainParams(t *testing.T) { list := types.ChainParamsList{ ChainParams: []*types.ChainParams{ { - ChainId: chains.ZetaPrivnetChain.ChainId, + ChainId: chains.ZetaPrivnet.ChainId, IsSupported: false, BallotThreshold: sdk.ZeroDec(), MinObserverDelegation: sdk.ZeroDec(), diff --git a/x/observer/keeper/vote_inbound_test.go b/x/observer/keeper/vote_inbound_test.go index 7db8619205..366f79ec4f 100644 --- a/x/observer/keeper/vote_inbound_test.go +++ b/x/observer/keeper/vote_inbound_test.go @@ -25,7 +25,7 @@ func TestKeeper_VoteOnInboundBallot(t *testing.T) { _, _, err := k.VoteOnInboundBallot( ctx, getValidEthChainIDWithIndex(t, 0), - chains.ZetaPrivnetChain.ChainId, + chains.ZetaPrivnet.ChainId, coin.CoinType_ERC20, sample.AccAddress(), "index", @@ -47,7 +47,7 @@ func TestKeeper_VoteOnInboundBallot(t *testing.T) { _, _, err := k.VoteOnInboundBallot( ctx, getValidEthChainIDWithIndex(t, 0), - chains.ZetaPrivnetChain.ChainId, + chains.ZetaPrivnet.ChainId, coin.CoinType_ERC20, sample.AccAddress(), "index", @@ -69,7 +69,7 @@ func TestKeeper_VoteOnInboundBallot(t *testing.T) { _, _, err = k.VoteOnInboundBallot( ctx, getValidEthChainIDWithIndex(t, 0), - chains.ZetaPrivnetChain.ChainId, + chains.ZetaPrivnet.ChainId, coin.CoinType_ERC20, sample.AccAddress(), "index", @@ -98,7 +98,7 @@ func TestKeeper_VoteOnInboundBallot(t *testing.T) { _, _, err := k.VoteOnInboundBallot( ctx, getValidEthChainIDWithIndex(t, 0), - chains.ZetaPrivnetChain.ChainId, + chains.ZetaPrivnet.ChainId, coin.CoinType_ERC20, sample.AccAddress(), "index", @@ -135,7 +135,7 @@ func TestKeeper_VoteOnInboundBallot(t *testing.T) { _, _, err := k.VoteOnInboundBallot( ctx, getValidEthChainIDWithIndex(t, 0), - chains.ZetaPrivnetChain.ChainId, + chains.ZetaPrivnet.ChainId, coin.CoinType_ERC20, observer, "index", @@ -152,7 +152,7 @@ func TestKeeper_VoteOnInboundBallot(t *testing.T) { IsSupported: true, }, { - ChainId: chains.ZetaPrivnetChain.ChainId, + ChainId: chains.ZetaPrivnet.ChainId, IsSupported: false, }, }, @@ -163,7 +163,7 @@ func TestKeeper_VoteOnInboundBallot(t *testing.T) { _, _, err = k.VoteOnInboundBallot( ctx, getValidEthChainIDWithIndex(t, 0), - chains.ZetaPrivnetChain.ChainId, + chains.ZetaPrivnet.ChainId, coin.CoinType_ERC20, observer, "index", diff --git a/x/observer/types/chain_params.go b/x/observer/types/chain_params.go index 0e02ff2a60..1731ea741e 100644 --- a/x/observer/types/chain_params.go +++ b/x/observer/types/chain_params.go @@ -327,7 +327,7 @@ func GetDefaultGoerliLocalnetChainParams() *ChainParams { } func GetDefaultZetaPrivnetChainParams() *ChainParams { return &ChainParams{ - ChainId: chains.ZetaPrivnetChain.ChainId, + ChainId: chains.ZetaPrivnet.ChainId, ConfirmationCount: 1, ZetaTokenContractAddress: zeroAddress, ConnectorContractAddress: zeroAddress, From 2cf597f6b9295fa4e3baf46c4bc7485fc1cadca0 Mon Sep 17 00:00:00 2001 From: lumtis Date: Fri, 24 May 2024 10:29:39 +0200 Subject: [PATCH 14/22] bitcoin regnet --- cmd/zetaclientd/keygen_tss.go | 2 +- cmd/zetae2e/local/local.go | 2 +- ...test_bitcoin_withdraw_restricted_address.go | 2 +- .../test_zeta_withdraw_bitcoin_revert.go | 2 +- e2e/runner/bitcoin.go | 2 +- e2e/runner/setup_zeta.go | 2 +- e2e/txserver/zeta_tx_server.go | 2 +- pkg/chains/address_test.go | 18 +++++++++--------- pkg/chains/bitcoin.go | 6 +++--- pkg/chains/bitcoin_test.go | 8 ++++---- pkg/chains/chain_test.go | 2 +- pkg/chains/chains.go | 6 +++--- pkg/chains/chains_test.go | 8 ++++---- pkg/crypto/pubkey_test.go | 2 +- testutil/sample/fungible.go | 2 +- x/crosschain/keeper/utils_test.go | 2 +- x/crosschain/migrations/v4/migrate_test.go | 4 ++-- x/crosschain/types/rate_limiter_flags_test.go | 2 +- x/crosschain/types/validate_test.go | 4 ++-- x/observer/keeper/grpc_query_tss_test.go | 8 ++++---- x/observer/types/chain_params.go | 2 +- .../chains/bitcoin/observer/live_test.go | 2 +- 22 files changed, 45 insertions(+), 45 deletions(-) diff --git a/cmd/zetaclientd/keygen_tss.go b/cmd/zetaclientd/keygen_tss.go index 6f04ccdead..0e74d878ca 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.BitcoinRegtest.ChainId btcChain, _, btcEnabled := appContext.GetBTCChainAndConfig() if btcEnabled { bitcoinChainID = btcChain.ChainId diff --git a/cmd/zetae2e/local/local.go b/cmd/zetae2e/local/local.go index e9213e17b5..aa202b7bba 100644 --- a/cmd/zetae2e/local/local.go +++ b/cmd/zetae2e/local/local.go @@ -196,7 +196,7 @@ func localE2ETest(cmd *cobra.Command, _ []string) { if !skipHeaderProof { if err := deployerRunner.EnableHeaderVerification([]int64{ chains.GoerliLocalnetChain.ChainId, - chains.BtcRegtestChain.ChainId}); err != nil { + chains.BitcoinRegtest.ChainId}); err != nil { panic(err) } } diff --git a/e2e/e2etests/test_bitcoin_withdraw_restricted_address.go b/e2e/e2etests/test_bitcoin_withdraw_restricted_address.go index b33f724b90..918a4fe6e3 100644 --- a/e2e/e2etests/test_bitcoin_withdraw_restricted_address.go +++ b/e2e/e2etests/test_bitcoin_withdraw_restricted_address.go @@ -37,7 +37,7 @@ func withdrawBitcoinRestricted(r *runner.E2ERunner, amount *big.Int) { // use restricted BTC P2WPKH address addressRestricted, err := chains.DecodeBtcAddress( testutils.RestrictedBtcAddressTest, - chains.BtcRegtestChain.ChainId, + chains.BitcoinRegtest.ChainId, ) if err != nil { panic(err) diff --git a/e2e/e2etests/test_zeta_withdraw_bitcoin_revert.go b/e2e/e2etests/test_zeta_withdraw_bitcoin_revert.go index ac4525881b..151d140a97 100644 --- a/e2e/e2etests/test_zeta_withdraw_bitcoin_revert.go +++ b/e2e/e2etests/test_zeta_withdraw_bitcoin_revert.go @@ -48,7 +48,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.BitcoinRegtest.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 1d82c0334c..f1d10339fa 100644 --- a/e2e/runner/bitcoin.go +++ b/e2e/runner/bitcoin.go @@ -443,7 +443,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.BitcoinRegtest.ChainId, TxHash: txHash.String(), BlockHash: blockHash.String(), Proof: proofs.NewBitcoinProof(txBytes, path, index), diff --git a/e2e/runner/setup_zeta.go b/e2e/runner/setup_zeta.go index b5f454d38a..1f48acfe27 100644 --- a/e2e/runner/setup_zeta.go +++ b/e2e/runner/setup_zeta.go @@ -224,7 +224,7 @@ func (runner *E2ERunner) SetupETHZRC20() { func (runner *E2ERunner) SetupBTCZRC20() { BTCZRC20Addr, err := runner.SystemContract.GasCoinZRC20ByChainId( &bind.CallOpts{}, - big.NewInt(chains.BtcRegtestChain.ChainId), + big.NewInt(chains.BitcoinRegtest.ChainId), ) if err != nil { panic(err) diff --git a/e2e/txserver/zeta_tx_server.go b/e2e/txserver/zeta_tx_server.go index 6e6d12545e..217f477d87 100644 --- a/e2e/txserver/zeta_tx_server.go +++ b/e2e/txserver/zeta_tx_server.go @@ -356,7 +356,7 @@ func (zts ZetaTxServer) DeploySystemContractsAndZRC20( _, err = zts.BroadcastTx(account, fungibletypes.NewMsgDeployFungibleCoinZRC20( addr.String(), "", - chains.BtcRegtestChain.ChainId, + chains.BitcoinRegtest.ChainId, 8, "BTC", "tBTC", diff --git a/pkg/chains/address_test.go b/pkg/chains/address_test.go index a9e303e08c..cfdf53bd08 100644 --- a/pkg/chains/address_test.go +++ b/pkg/chains/address_test.go @@ -60,7 +60,7 @@ func TestDecodeBtcAddress(t *testing.T) { 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", BitcoinRegtest.ChainId) require.ErrorContains(t, err, "decode address failed") }) @@ -78,7 +78,7 @@ func TestDecodeBtcAddress(t *testing.T) { 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", BitcoinRegtest.ChainId) require.NoError(t, err) }) @@ -122,7 +122,7 @@ func Test_IsBtcAddressSupported_P2TR(t *testing.T) { { name: "regtest taproot address", addr: "bcrt1pqqqsyqcyq5rqwzqfpg9scrgwpugpzysnzs23v9ccrydpk8qarc0sj9hjuh", - chainId: BtcRegtestChain.ChainId, + chainId: BitcoinRegtest.ChainId, supported: true, }, } @@ -166,7 +166,7 @@ func Test_IsBtcAddressSupported_P2WSH(t *testing.T) { { name: "regtest P2WSH address", addr: "bcrt1qm9mzhyky4w853ft2ms6dtqdyyu3z2tmrq8jg8xglhyuv0dsxzmgs2f0sqy", - chainId: BtcRegtestChain.ChainId, + chainId: BitcoinRegtest.ChainId, supported: true, }, } @@ -209,7 +209,7 @@ func Test_IsBtcAddressSupported_P2WPKH(t *testing.T) { { name: "regtest P2WPKH address", addr: "bcrt1qy9pqmk2pd9sv63g27jt8r657wy0d9uee4x2dt2", - chainId: BtcRegtestChain.ChainId, + chainId: BitcoinRegtest.ChainId, supported: true, }, } @@ -259,13 +259,13 @@ func Test_IsBtcAddressSupported_P2SH(t *testing.T) { { name: "testnet P2SH address 1 should also be supported in regtest", addr: "2N6AoUj3KPS7wNGZXuCckh8YEWcSYNsGbqd", - chainId: BtcRegtestChain.ChainId, + chainId: BitcoinRegtest.ChainId, supported: true, }, { name: "testnet P2SH address 2 should also be supported in regtest", addr: "2MwbFpRpZWv4zREjbdLB9jVW3Q8xonpVeyE", - chainId: BtcRegtestChain.ChainId, + chainId: BitcoinRegtest.ChainId, supported: true, }, } @@ -315,13 +315,13 @@ func Test_IsBtcAddressSupported_P2PKH(t *testing.T) { { name: "testnet P2PKH address should also be supported in regtest", addr: "mxpYha3UJKUgSwsAz2qYRqaDSwAkKZ3YEY", - chainId: BtcRegtestChain.ChainId, + chainId: BitcoinRegtest.ChainId, supported: true, }, { name: "testnet P2PKH address should also be supported in regtest", addr: "n1gXcqxmzwqHmqmgobe1XXuJaweSu69tZz", - chainId: BtcRegtestChain.ChainId, + chainId: BitcoinRegtest.ChainId, supported: true, }, } diff --git a/pkg/chains/bitcoin.go b/pkg/chains/bitcoin.go index fd885e1db4..e145ef7668 100644 --- a/pkg/chains/bitcoin.go +++ b/pkg/chains/bitcoin.go @@ -15,7 +15,7 @@ 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 BitcoinRegtest.ChainId: return BitcoinRegnetParams, nil case BitcoinMainnet.ChainId: return BitcoinMainnetParams, nil @@ -30,7 +30,7 @@ func BitcoinNetParamsFromChainID(chainID int64) (*chaincfg.Params, error) { func BitcoinChainIDFromNetworkName(name string) (int64, error) { switch name { case BitcoinRegnetParams.Name: - return BtcRegtestChain.ChainId, nil + return BitcoinRegtest.ChainId, nil case BitcoinMainnetParams.Name: return BitcoinMainnet.ChainId, nil case BitcoinTestnetParams.Name: @@ -42,7 +42,7 @@ func BitcoinChainIDFromNetworkName(name string) (int64, error) { // IsBitcoinRegnet returns true if the chain id is for the regnet func IsBitcoinRegnet(chainID int64) bool { - return chainID == BtcRegtestChain.ChainId + return chainID == BitcoinRegtest.ChainId } // IsBitcoinMainnet returns true if the chain id is for the mainnet diff --git a/pkg/chains/bitcoin_test.go b/pkg/chains/bitcoin_test.go index 3a9c3413c2..592e6ad424 100644 --- a/pkg/chains/bitcoin_test.go +++ b/pkg/chains/bitcoin_test.go @@ -14,7 +14,7 @@ func TestBitcoinNetParamsFromChainID(t *testing.T) { expected *chaincfg.Params wantErr bool }{ - {"Regnet", BtcRegtestChain.ChainId, BitcoinRegnetParams, false}, + {"Regnet", BitcoinRegtest.ChainId, BitcoinRegnetParams, false}, {"Mainnet", BitcoinMainnet.ChainId, BitcoinMainnetParams, false}, {"Testnet", BitcoinTestnet.ChainId, BitcoinTestnetParams, false}, {"Unknown", -1, nil, true}, @@ -40,7 +40,7 @@ func TestBitcoinChainIDFromNetParams(t *testing.T) { expectedChainID int64 wantErr bool }{ - {"Regnet", BitcoinRegnetParams.Name, BtcRegtestChain.ChainId, false}, + {"Regnet", BitcoinRegnetParams.Name, BitcoinRegtest.ChainId, false}, {"Mainnet", BitcoinMainnetParams.Name, BitcoinMainnet.ChainId, false}, {"Testnet", BitcoinTestnetParams.Name, BitcoinTestnet.ChainId, false}, {"Unknown", "Unknown", 0, true}, @@ -61,13 +61,13 @@ func TestBitcoinChainIDFromNetParams(t *testing.T) { } func TestIsBitcoinRegnet(t *testing.T) { - require.True(t, IsBitcoinRegnet(BtcRegtestChain.ChainId)) + require.True(t, IsBitcoinRegnet(BitcoinRegtest.ChainId)) require.False(t, IsBitcoinRegnet(BitcoinMainnet.ChainId)) require.False(t, IsBitcoinRegnet(BitcoinTestnet.ChainId)) } func TestIsBitcoinMainnet(t *testing.T) { require.True(t, IsBitcoinMainnet(BitcoinMainnet.ChainId)) - require.False(t, IsBitcoinMainnet(BtcRegtestChain.ChainId)) + require.False(t, IsBitcoinMainnet(BitcoinRegtest.ChainId)) require.False(t, IsBitcoinMainnet(BitcoinTestnet.ChainId)) } diff --git a/pkg/chains/chain_test.go b/pkg/chains/chain_test.go index c70c73e8a6..b792aed42b 100644 --- a/pkg/chains/chain_test.go +++ b/pkg/chains/chain_test.go @@ -236,7 +236,7 @@ func TestIsBitcoinChain(t *testing.T) { }{ {"Bitcoin Mainnet", BitcoinMainnet.ChainId, true}, {"Bitcoin Testnet", BitcoinTestnet.ChainId, true}, - {"Bitcoin Regtest", BtcRegtestChain.ChainId, true}, + {"Bitcoin Regtest", BitcoinRegtest.ChainId, true}, {"Non-Bitcoin", Ethereum.ChainId, false}, {"Zeta Mainnet", ZetaChainMainnet.ChainId, false}, } diff --git a/pkg/chains/chains.go b/pkg/chains/chains.go index 5b3639008d..6c2c59e3ac 100644 --- a/pkg/chains/chains.go +++ b/pkg/chains/chains.go @@ -196,8 +196,8 @@ var ( IsExternal: false, } - // BtcRegtestChain is Bitcoin regtest (localnet) - BtcRegtestChain = Chain{ + // BitcoinRegtest is Bitcoin regtest (localnet) + BitcoinRegtest = Chain{ ChainName: ChainName_btc_regtest, ChainId: 18444, Network: Network_btc, @@ -261,7 +261,7 @@ func DefaultChainsList() []*Chain { BscTestnet, GoerliChain, Sepolia, - BtcRegtestChain, + BitcoinRegtest, GoerliLocalnetChain, ZetaChainMainnet, ZetaChainTestnet, diff --git a/pkg/chains/chains_test.go b/pkg/chains/chains_test.go index 08d672dc60..3d0c574876 100644 --- a/pkg/chains/chains_test.go +++ b/pkg/chains/chains_test.go @@ -45,7 +45,7 @@ func TestChainListByNetworkType(t *testing.T) { NetworkType_privnet, []*Chain{ &ZetaPrivnet, - &BtcRegtestChain, + &BitcoinRegtest, &GoerliLocalnetChain, }, }, @@ -72,7 +72,7 @@ func TestChainListByNetwork(t *testing.T) { { "Btc", Network_btc, - []*Chain{&BitcoinMainnet, &BitcoinTestnet, &BtcRegtestChain}, + []*Chain{&BitcoinMainnet, &BitcoinTestnet, &BitcoinRegtest}, }, { "Eth", @@ -126,7 +126,7 @@ func TestChainListFunctions(t *testing.T) { &BscTestnet, &GoerliChain, &Sepolia, - &BtcRegtestChain, + &BitcoinRegtest, &GoerliLocalnetChain, &ZetaChainMainnet, &ZetaChainTestnet, @@ -152,7 +152,7 @@ func TestChainListFunctions(t *testing.T) { &BscTestnet, &GoerliChain, &Sepolia, - &BtcRegtestChain, + &BitcoinRegtest, &GoerliLocalnetChain, &Polygon, &OptimismMainnet, diff --git a/pkg/crypto/pubkey_test.go b/pkg/crypto/pubkey_test.go index db7674cb40..70f26989fe 100644 --- a/pkg/crypto/pubkey_test.go +++ b/pkg/crypto/pubkey_test.go @@ -146,7 +146,7 @@ func (s *PubKeyTestSuite) TestPubKeyGetAddress(c *C) { c.Assert(err, IsNil) c.Assert(addrETH.String(), Equals, d.addrETH.mocknet) - addrETH, err = pk.GetAddress(chains.BtcRegtestChain) + addrETH, err = pk.GetAddress(chains.BitcoinRegtest) c.Assert(err, IsNil) c.Assert(addrETH, Equals, chains.NoAddress) } diff --git a/testutil/sample/fungible.go b/testutil/sample/fungible.go index 0d1cd09673..7f89dbd80f 100644 --- a/testutil/sample/fungible.go +++ b/testutil/sample/fungible.go @@ -26,7 +26,7 @@ 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 + btcChainID := chains.BitcoinRegtest.ChainId // add zrc20 ETH fcGas := ForeignCoins(t, zrc20ETH) diff --git a/x/crosschain/keeper/utils_test.go b/x/crosschain/keeper/utils_test.go index 48a1078ec6..fa1f544491 100644 --- a/x/crosschain/keeper/utils_test.go +++ b/x/crosschain/keeper/utils_test.go @@ -33,7 +33,7 @@ func getValidEthChain() *chains.Chain { } func getValidBTCChain() *chains.Chain { - btcRegNet := chains.BtcRegtestChain + btcRegNet := chains.BitcoinRegtest return &btcRegNet } diff --git a/x/crosschain/migrations/v4/migrate_test.go b/x/crosschain/migrations/v4/migrate_test.go index 51a38aca89..c27ac590aa 100644 --- a/x/crosschain/migrations/v4/migrate_test.go +++ b/x/crosschain/migrations/v4/migrate_test.go @@ -143,7 +143,7 @@ func TestSetBitcoinFinalizedInbound(t *testing.T) { k.SetCrossChainTx(ctx, types.CrossChainTx{ Index: "6", InboundParams: &types.InboundParams{ - SenderChainId: chains.BtcRegtestChain.ChainId, + SenderChainId: chains.BitcoinRegtest.ChainId, ObservedHash: "0x444", }, }) @@ -158,7 +158,7 @@ func TestSetBitcoinFinalizedInbound(t *testing.T) { require.True(t, k.IsFinalizedInbound(ctx, "0x111", chains.BitcoinMainnet.ChainId, 0)) require.True(t, k.IsFinalizedInbound(ctx, "0x222", chains.BitcoinTestnet.ChainId, 0)) require.True(t, k.IsFinalizedInbound(ctx, "0x333", chains.BitcoinTestnet.ChainId, 0)) - require.True(t, k.IsFinalizedInbound(ctx, "0x444", chains.BtcRegtestChain.ChainId, 0)) + require.True(t, k.IsFinalizedInbound(ctx, "0x444", chains.BitcoinRegtest.ChainId, 0)) }) } diff --git a/x/crosschain/types/rate_limiter_flags_test.go b/x/crosschain/types/rate_limiter_flags_test.go index 5ed627be6b..f0321f6325 100644 --- a/x/crosschain/types/rate_limiter_flags_test.go +++ b/x/crosschain/types/rate_limiter_flags_test.go @@ -237,7 +237,7 @@ func TestBuildAssetRateMapFromList(t *testing.T) { func TestConvertCctxValue(t *testing.T) { // chain IDs ethChainID := chains.GoerliLocalnetChain.ChainId - btcChainID := chains.BtcRegtestChain.ChainId + btcChainID := chains.BitcoinRegtest.ChainId // setup test asset rates assetETH := sample.EthAddress().Hex() diff --git a/x/crosschain/types/validate_test.go b/x/crosschain/types/validate_test.go index f335ad3513..4c0e807732 100644 --- a/x/crosschain/types/validate_test.go +++ b/x/crosschain/types/validate_test.go @@ -40,14 +40,14 @@ func TestValidateAddressForChain(t *testing.T) { t, types.ValidateAddressForChain("bcrt1qs758ursh4q9z627kt3pp5yysm78ddny6txaqgw", chains.BitcoinMainnet.ChainId), ) - require.Error(t, types.ValidateAddressForChain("", chains.BtcRegtestChain.ChainId)) + require.Error(t, types.ValidateAddressForChain("", chains.BitcoinRegtest.ChainId)) require.NoError( t, types.ValidateAddressForChain("bc1qysd4sp9q8my59ul9wsf5rvs9p387hf8vfwatzu", chains.BitcoinMainnet.ChainId), ) require.NoError( t, - types.ValidateAddressForChain("bcrt1qs758ursh4q9z627kt3pp5yysm78ddny6txaqgw", chains.BtcRegtestChain.ChainId), + types.ValidateAddressForChain("bcrt1qs758ursh4q9z627kt3pp5yysm78ddny6txaqgw", chains.BitcoinRegtest.ChainId), ) // test for zeta chain diff --git a/x/observer/keeper/grpc_query_tss_test.go b/x/observer/keeper/grpc_query_tss_test.go index 8565ff9349..372a271de9 100644 --- a/x/observer/keeper/grpc_query_tss_test.go +++ b/x/observer/keeper/grpc_query_tss_test.go @@ -147,10 +147,10 @@ func TestKeeper_GetTssAddress(t *testing.T) { k.SetTSS(ctx, tss) res, err := k.GetTssAddress(wctx, &types.QueryGetTssAddressRequest{ - BitcoinChainId: chains.BtcRegtestChain.ChainId, + BitcoinChainId: chains.BitcoinRegtest.ChainId, }) require.NoError(t, err) - expectedBitcoinParams, err := chains.BitcoinNetParamsFromChainID(chains.BtcRegtestChain.ChainId) + expectedBitcoinParams, err := chains.BitcoinNetParamsFromChainID(chains.BitcoinRegtest.ChainId) require.NoError(t, err) expectedBtcAddress, err := crypto.GetTssAddrBTC(tss.TssPubkey, expectedBitcoinParams) require.NoError(t, err) @@ -213,11 +213,11 @@ func TestKeeper_GetTssAddressByFinalizedHeight(t *testing.T) { } res, err := k.GetTssAddressByFinalizedHeight(wctx, &types.QueryGetTssAddressByFinalizedHeightRequest{ - BitcoinChainId: chains.BtcRegtestChain.ChainId, + BitcoinChainId: chains.BitcoinRegtest.ChainId, FinalizedZetaHeight: tssList[r].FinalizedZetaHeight, }) require.NoError(t, err) - expectedBitcoinParams, err := chains.BitcoinNetParamsFromChainID(chains.BtcRegtestChain.ChainId) + expectedBitcoinParams, err := chains.BitcoinNetParamsFromChainID(chains.BitcoinRegtest.ChainId) require.NoError(t, err) expectedBtcAddress, err := crypto.GetTssAddrBTC(tssList[r].TssPubkey, expectedBitcoinParams) require.NoError(t, err) diff --git a/x/observer/types/chain_params.go b/x/observer/types/chain_params.go index 1731ea741e..db4a88b3e0 100644 --- a/x/observer/types/chain_params.go +++ b/x/observer/types/chain_params.go @@ -291,7 +291,7 @@ func GetDefaultBtcTestnetChainParams() *ChainParams { } func GetDefaultBtcRegtestChainParams() *ChainParams { return &ChainParams{ - ChainId: chains.BtcRegtestChain.ChainId, + ChainId: chains.BitcoinRegtest.ChainId, ConfirmationCount: 1, ZetaTokenContractAddress: zeroAddress, ConnectorContractAddress: zeroAddress, diff --git a/zetaclient/chains/bitcoin/observer/live_test.go b/zetaclient/chains/bitcoin/observer/live_test.go index c7eb63de51..51bedbf1ef 100644 --- a/zetaclient/chains/bitcoin/observer/live_test.go +++ b/zetaclient/chains/bitcoin/observer/live_test.go @@ -48,7 +48,7 @@ func (suite *BitcoinObserverTestSuite) SetupTest() { PrivKey: privateKey, } appContext := clientcontext.NewAppContext(&clientcontext.ZetacoreContext{}, config.Config{}) - client, err := NewObserver(appContext, chains.BtcRegtestChain, nil, tss, tempSQLiteDbPath, + client, err := NewObserver(appContext, chains.BitcoinRegtest, nil, tss, tempSQLiteDbPath, clientcommon.DefaultLoggers(), config.BTCConfig{}, nil) suite.Require().NoError(err) suite.rpcClient, err = getRPCClient(18332) From 32ca841dafd8bf776794fdeb4c938e3ba1d5b1b9 Mon Sep 17 00:00:00 2001 From: lumtis Date: Fri, 24 May 2024 10:31:16 +0200 Subject: [PATCH 15/22] goerli localnet --- cmd/zetae2e/local/local.go | 2 +- e2e/runner/evm.go | 2 +- e2e/runner/setup_zeta.go | 2 +- e2e/txserver/zeta_tx_server.go | 4 +-- pkg/chains/chain_test.go | 2 +- pkg/chains/chains.go | 6 ++--- pkg/chains/chains_test.go | 8 +++--- testutil/sample/fungible.go | 2 +- .../keeper/rate_limiter_flags_test.go | 2 +- x/crosschain/keeper/utils_test.go | 4 +-- x/crosschain/migrations/v5/migrate_test.go | 2 +- x/crosschain/types/rate_limiter_flags_test.go | 2 +- x/lightclient/types/verification_flags.go | 2 +- .../types/verification_flags_test.go | 2 +- .../msg_server_reset_chain_nonces_test.go | 8 +++--- .../msg_server_vote_block_header_test.go | 26 +++++++++---------- x/observer/keeper/utils_test.go | 2 +- x/observer/types/chain_params.go | 2 +- .../chains/evm/observer/outbound_test.go | 4 +-- zetaclient/config/config_chain.go | 4 +-- 20 files changed, 44 insertions(+), 44 deletions(-) diff --git a/cmd/zetae2e/local/local.go b/cmd/zetae2e/local/local.go index aa202b7bba..c1ab0f4431 100644 --- a/cmd/zetae2e/local/local.go +++ b/cmd/zetae2e/local/local.go @@ -195,7 +195,7 @@ func localE2ETest(cmd *cobra.Command, _ []string) { if !skipHeaderProof { if err := deployerRunner.EnableHeaderVerification([]int64{ - chains.GoerliLocalnetChain.ChainId, + chains.GoerliLocalnet.ChainId, chains.BitcoinRegtest.ChainId}); err != nil { panic(err) } diff --git a/e2e/runner/evm.go b/e2e/runner/evm.go index cfa944418d..355b692ec5 100644 --- a/e2e/runner/evm.go +++ b/e2e/runner/evm.go @@ -254,7 +254,7 @@ func (runner *E2ERunner) ProveEthTransaction(receipt *ethtypes.Receipt) { TxIndex: int64(txIndex), TxHash: txHash.Hex(), Proof: proofs.NewEthereumProof(txProof), - ChainId: chains.GoerliLocalnetChain.ChainId, + ChainId: chains.GoerliLocalnet.ChainId, }) if err != nil { panic(err) diff --git a/e2e/runner/setup_zeta.go b/e2e/runner/setup_zeta.go index 1f48acfe27..ac24c02de2 100644 --- a/e2e/runner/setup_zeta.go +++ b/e2e/runner/setup_zeta.go @@ -204,7 +204,7 @@ func (runner *E2ERunner) SetZEVMContracts() { func (runner *E2ERunner) SetupETHZRC20() { ethZRC20Addr, err := runner.SystemContract.GasCoinZRC20ByChainId( &bind.CallOpts{}, - big.NewInt(chains.GoerliLocalnetChain.ChainId), + big.NewInt(chains.GoerliLocalnet.ChainId), ) if err != nil { panic(err) diff --git a/e2e/txserver/zeta_tx_server.go b/e2e/txserver/zeta_tx_server.go index 217f477d87..24478e78dd 100644 --- a/e2e/txserver/zeta_tx_server.go +++ b/e2e/txserver/zeta_tx_server.go @@ -341,7 +341,7 @@ func (zts ZetaTxServer) DeploySystemContractsAndZRC20( _, err = zts.BroadcastTx(account, fungibletypes.NewMsgDeployFungibleCoinZRC20( addr.String(), "", - chains.GoerliLocalnetChain.ChainId, + chains.GoerliLocalnet.ChainId, 18, "ETH", "gETH", @@ -371,7 +371,7 @@ func (zts ZetaTxServer) DeploySystemContractsAndZRC20( res, err = zts.BroadcastTx(account, fungibletypes.NewMsgDeployFungibleCoinZRC20( addr.String(), erc20Addr, - chains.GoerliLocalnetChain.ChainId, + chains.GoerliLocalnet.ChainId, 6, "USDT", "USDT", diff --git a/pkg/chains/chain_test.go b/pkg/chains/chain_test.go index b792aed42b..bf091187cb 100644 --- a/pkg/chains/chain_test.go +++ b/pkg/chains/chain_test.go @@ -193,7 +193,7 @@ func TestIsHeaderSupportedChain(t *testing.T) { }{ {"Ethereum Mainnet", Ethereum.ChainId, true}, {"Goerli Testnet", GoerliChain.ChainId, true}, - {"Goerli Localnet", GoerliLocalnetChain.ChainId, true}, + {"Goerli Localnet", GoerliLocalnet.ChainId, true}, {"Sepolia Testnet", Sepolia.ChainId, true}, {"BSC Testnet", BscTestnet.ChainId, true}, {"BSC Mainnet", BscMainnet.ChainId, true}, diff --git a/pkg/chains/chains.go b/pkg/chains/chains.go index 6c2c59e3ac..b17bb8bff7 100644 --- a/pkg/chains/chains.go +++ b/pkg/chains/chains.go @@ -207,8 +207,8 @@ var ( IsExternal: true, } - // GoerliLocalnetChain is Ethereum local goerli (localnet) - GoerliLocalnetChain = Chain{ + // GoerliLocalnet is Ethereum local goerli (localnet) + GoerliLocalnet = Chain{ ChainName: ChainName_goerli_localnet, ChainId: 1337, Network: Network_eth, @@ -262,7 +262,7 @@ func DefaultChainsList() []*Chain { GoerliChain, Sepolia, BitcoinRegtest, - GoerliLocalnetChain, + GoerliLocalnet, ZetaChainMainnet, ZetaChainTestnet, ZetaDevnet, diff --git a/pkg/chains/chains_test.go b/pkg/chains/chains_test.go index 3d0c574876..5159e2b623 100644 --- a/pkg/chains/chains_test.go +++ b/pkg/chains/chains_test.go @@ -46,7 +46,7 @@ func TestChainListByNetworkType(t *testing.T) { []*Chain{ &ZetaPrivnet, &BitcoinRegtest, - &GoerliLocalnetChain, + &GoerliLocalnet, }, }, } @@ -77,7 +77,7 @@ func TestChainListByNetwork(t *testing.T) { { "Eth", Network_eth, - []*Chain{&Ethereum, &GoerliChain, &Sepolia, &GoerliLocalnetChain}, + []*Chain{&Ethereum, &GoerliChain, &Sepolia, &GoerliLocalnet}, }, { "Bsc", @@ -127,7 +127,7 @@ func TestChainListFunctions(t *testing.T) { &GoerliChain, &Sepolia, &BitcoinRegtest, - &GoerliLocalnetChain, + &GoerliLocalnet, &ZetaChainMainnet, &ZetaChainTestnet, &ZetaDevnet, @@ -153,7 +153,7 @@ func TestChainListFunctions(t *testing.T) { &GoerliChain, &Sepolia, &BitcoinRegtest, - &GoerliLocalnetChain, + &GoerliLocalnet, &Polygon, &OptimismMainnet, &OptimismSepolia, diff --git a/testutil/sample/fungible.go b/testutil/sample/fungible.go index 7f89dbd80f..9d1892e29e 100644 --- a/testutil/sample/fungible.go +++ b/testutil/sample/fungible.go @@ -25,7 +25,7 @@ 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 + ethChainID := chains.GoerliLocalnet.ChainId btcChainID := chains.BitcoinRegtest.ChainId // add zrc20 ETH diff --git a/x/crosschain/keeper/rate_limiter_flags_test.go b/x/crosschain/keeper/rate_limiter_flags_test.go index cf7f829773..2e4ad7f92d 100644 --- a/x/crosschain/keeper/rate_limiter_flags_test.go +++ b/x/crosschain/keeper/rate_limiter_flags_test.go @@ -62,7 +62,7 @@ func TestKeeper_GetRateLimiterAssetRateList(t *testing.T) { k, ctx, _, zk := keepertest.CrosschainKeeper(t) // create test flags - chainID := chains.GoerliLocalnetChain.ChainId + chainID := chains.GoerliLocalnet.ChainId zrc20GasAddr := sample.EthAddress().Hex() zrc20ERC20Addr1 := sample.EthAddress().Hex() zrc20ERC20Addr2 := sample.EthAddress().Hex() diff --git a/x/crosschain/keeper/utils_test.go b/x/crosschain/keeper/utils_test.go index fa1f544491..ddd46801c6 100644 --- a/x/crosschain/keeper/utils_test.go +++ b/x/crosschain/keeper/utils_test.go @@ -28,7 +28,7 @@ func getValidEthChainID() int64 { // getValidEthChain() get a valid eth chain func getValidEthChain() *chains.Chain { - goerli := chains.GoerliLocalnetChain + goerli := chains.GoerliLocalnet return &goerli } @@ -45,7 +45,7 @@ func getValidBtcChainID() int64 { func getValidEthChainIDWithIndex(t *testing.T, index int) int64 { switch index { case 0: - return chains.GoerliLocalnetChain.ChainId + return chains.GoerliLocalnet.ChainId case 1: return chains.GoerliChain.ChainId default: diff --git a/x/crosschain/migrations/v5/migrate_test.go b/x/crosschain/migrations/v5/migrate_test.go index 6d869ffd19..f943a6dcf4 100644 --- a/x/crosschain/migrations/v5/migrate_test.go +++ b/x/crosschain/migrations/v5/migrate_test.go @@ -244,7 +244,7 @@ func CrossChainTxList(count int) []crosschaintypes.CrossChainTx { OutboundParams: []*crosschaintypes.OutboundParams{{ Amount: math.ZeroUint(), CoinType: coin.CoinType_ERC20, - ReceiverChainId: chains.GoerliLocalnetChain.ChainId, + ReceiverChainId: chains.GoerliLocalnet.ChainId, }}, } } diff --git a/x/crosschain/types/rate_limiter_flags_test.go b/x/crosschain/types/rate_limiter_flags_test.go index f0321f6325..3f15cb2895 100644 --- a/x/crosschain/types/rate_limiter_flags_test.go +++ b/x/crosschain/types/rate_limiter_flags_test.go @@ -236,7 +236,7 @@ func TestBuildAssetRateMapFromList(t *testing.T) { func TestConvertCctxValue(t *testing.T) { // chain IDs - ethChainID := chains.GoerliLocalnetChain.ChainId + ethChainID := chains.GoerliLocalnet.ChainId btcChainID := chains.BitcoinRegtest.ChainId // setup test asset rates diff --git a/x/lightclient/types/verification_flags.go b/x/lightclient/types/verification_flags.go index eecf819674..41046ff530 100644 --- a/x/lightclient/types/verification_flags.go +++ b/x/lightclient/types/verification_flags.go @@ -29,7 +29,7 @@ func DefaultHeaderSupportedChains() []HeaderSupportedChain { Enabled: false, }, { - ChainId: chains.GoerliLocalnetChain.ChainId, + ChainId: chains.GoerliLocalnet.ChainId, Enabled: false, }, { diff --git a/x/lightclient/types/verification_flags_test.go b/x/lightclient/types/verification_flags_test.go index a1e540d60b..58544068ef 100644 --- a/x/lightclient/types/verification_flags_test.go +++ b/x/lightclient/types/verification_flags_test.go @@ -21,7 +21,7 @@ func TestDefaultVerificationFlags(t *testing.T) { require.False(t, f.Enabled) case chains.BscTestnet.ChainId: require.False(t, f.Enabled) - case chains.GoerliLocalnetChain.ChainId: + case chains.GoerliLocalnet.ChainId: require.False(t, f.Enabled) case chains.GoerliChain.ChainId: require.False(t, f.Enabled) 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 adf11439e2..5306b98bcc 100644 --- a/x/observer/keeper/msg_server_reset_chain_nonces_test.go +++ b/x/observer/keeper/msg_server_reset_chain_nonces_test.go @@ -20,7 +20,7 @@ func TestMsgServer_ResetChainNonces(t *testing.T) { UseAuthorityMock: true, }) srv := keeper.NewMsgServerImpl(*k) - chainId := chains.GoerliLocalnetChain.ChainId + chainId := chains.GoerliLocalnet.ChainId admin := sample.AccAddress() authorityMock := keepertest.GetObserverAuthorityMock(t, k) @@ -45,7 +45,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.GoerliLocalnet.ChainId _, err := srv.ResetChainNonces(sdk.WrapSDKContext(ctx), &types.MsgResetChainNonces{ Creator: admin, ChainId: chainId, @@ -89,8 +89,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.GoerliLocalnet.ChainId + index := chains.GoerliLocalnet.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 8e51043ae2..0d41b1be0c 100644 --- a/x/observer/keeper/msg_server_vote_block_header_test.go +++ b/x/observer/keeper/msg_server_vote_block_header_test.go @@ -67,7 +67,7 @@ func TestMsgServer_VoteBlockHeader(t *testing.T) { k.SetChainParamsList(ctx, types.ChainParamsList{ ChainParams: []*types.ChainParams{ { - ChainId: chains.GoerliLocalnetChain.ChainId, + ChainId: chains.GoerliLocalnet.ChainId, IsSupported: true, BallotThreshold: one, }, @@ -76,7 +76,7 @@ func TestMsgServer_VoteBlockHeader(t *testing.T) { _, err := srv.VoteBlockHeader(ctx, &types.MsgVoteBlockHeader{ Creator: sample.AccAddress(), - ChainId: chains.GoerliLocalnetChain.ChainId, + ChainId: chains.GoerliLocalnet.ChainId, BlockHash: sample.Hash().Bytes(), Height: 42, Header: proofs.HeaderData{}, @@ -97,7 +97,7 @@ func TestMsgServer_VoteBlockHeader(t *testing.T) { k.SetChainParamsList(ctx, types.ChainParamsList{ ChainParams: []*types.ChainParams{ { - ChainId: chains.GoerliLocalnetChain.ChainId, + ChainId: chains.GoerliLocalnet.ChainId, IsSupported: true, BallotThreshold: one, }, @@ -114,7 +114,7 @@ func TestMsgServer_VoteBlockHeader(t *testing.T) { _, err := srv.VoteBlockHeader(ctx, &types.MsgVoteBlockHeader{ Creator: observer, - ChainId: chains.GoerliLocalnetChain.ChainId, + ChainId: chains.GoerliLocalnet.ChainId, BlockHash: sample.Hash().Bytes(), Height: 42, Header: proofs.HeaderData{}, @@ -135,7 +135,7 @@ func TestMsgServer_VoteBlockHeader(t *testing.T) { k.SetChainParamsList(ctx, types.ChainParamsList{ ChainParams: []*types.ChainParams{ { - ChainId: chains.GoerliLocalnetChain.ChainId, + ChainId: chains.GoerliLocalnet.ChainId, IsSupported: true, BallotThreshold: one, }, @@ -154,7 +154,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.GoerliLocalnet.ChainId, BlockHash: sample.Hash().Bytes(), Height: 42, Header: proofs.HeaderData{}, @@ -180,7 +180,7 @@ func TestMsgServer_VoteBlockHeader(t *testing.T) { k.SetChainParamsList(ctx, types.ChainParamsList{ ChainParams: []*types.ChainParams{ { - ChainId: chains.GoerliLocalnetChain.ChainId, + ChainId: chains.GoerliLocalnet.ChainId, IsSupported: true, BallotThreshold: one, }, @@ -197,7 +197,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.GoerliLocalnet.ChainId, BlockHash: blockHash, Height: 42, Header: proofs.HeaderData{}, @@ -213,7 +213,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.GoerliLocalnet.ChainId, BlockHash: blockHash, Height: 42, Header: proofs.HeaderData{}, @@ -230,7 +230,7 @@ func TestMsgServer_VoteBlockHeader(t *testing.T) { mockAddBlockHeader(lightclientMock) res, err = srv.VoteBlockHeader(ctx, &types.MsgVoteBlockHeader{ Creator: observer3, - ChainId: chains.GoerliLocalnetChain.ChainId, + ChainId: chains.GoerliLocalnet.ChainId, BlockHash: blockHash, Height: 42, Header: proofs.HeaderData{}, @@ -254,7 +254,7 @@ func TestMsgServer_VoteBlockHeader(t *testing.T) { k.SetChainParamsList(ctx, types.ChainParamsList{ ChainParams: []*types.ChainParams{ { - ChainId: chains.GoerliLocalnetChain.ChainId, + ChainId: chains.GoerliLocalnet.ChainId, IsSupported: true, BallotThreshold: one, }, @@ -272,7 +272,7 @@ func TestMsgServer_VoteBlockHeader(t *testing.T) { mockCheckNewBlockHeader(lightclientMock, nil) _, err := srv.VoteBlockHeader(ctx, &types.MsgVoteBlockHeader{ Creator: observer, - ChainId: chains.GoerliLocalnetChain.ChainId, + ChainId: chains.GoerliLocalnet.ChainId, BlockHash: blockHash, Height: 42, Header: proofs.HeaderData{}, @@ -285,7 +285,7 @@ func TestMsgServer_VoteBlockHeader(t *testing.T) { mockCheckNewBlockHeader(lightclientMock, nil) _, err = srv.VoteBlockHeader(ctx, &types.MsgVoteBlockHeader{ Creator: observer, - ChainId: chains.GoerliLocalnetChain.ChainId, + ChainId: chains.GoerliLocalnet.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 9e334cb9bf..99b3daf607 100644 --- a/x/observer/keeper/utils_test.go +++ b/x/observer/keeper/utils_test.go @@ -34,7 +34,7 @@ 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.GoerliLocalnet.ChainId case 1: return chains.GoerliChain.ChainId default: diff --git a/x/observer/types/chain_params.go b/x/observer/types/chain_params.go index db4a88b3e0..f89780baed 100644 --- a/x/observer/types/chain_params.go +++ b/x/observer/types/chain_params.go @@ -309,7 +309,7 @@ func GetDefaultBtcRegtestChainParams() *ChainParams { } func GetDefaultGoerliLocalnetChainParams() *ChainParams { return &ChainParams{ - ChainId: chains.GoerliLocalnetChain.ChainId, + ChainId: chains.GoerliLocalnet.ChainId, ConfirmationCount: 1, ZetaTokenContractAddress: "0x733aB8b06DDDEf27Eaa72294B0d7c9cEF7f12db9", ConnectorContractAddress: "0xD28D6A0b8189305551a0A8bd247a6ECa9CE781Ca", diff --git a/zetaclient/chains/evm/observer/outbound_test.go b/zetaclient/chains/evm/observer/outbound_test.go index 542afcea81..e0806d6086 100644 --- a/zetaclient/chains/evm/observer/outbound_test.go +++ b/zetaclient/chains/evm/observer/outbound_test.go @@ -298,7 +298,7 @@ func Test_ParseZetaReceived(t *testing.T) { func Test_ParseZetaReverted(t *testing.T) { // load archived outbound receipt that contains ZetaReverted event - chainID := chains.GoerliLocalnetChain.ChainId + chainID := chains.GoerliLocalnet.ChainId nonce := uint64(14) outboundHash := "0x1487e6a31dd430306667250b72bf15b8390b73108b69f3de5c1b2efe456036a7" connector := mocks.MockConnectorNonEth(t, chainID) @@ -460,7 +460,7 @@ func Test_ParseOutboundReceivedValue(t *testing.T) { t.Run("should parse and check ZetaReverted event from archived outbound receipt", func(t *testing.T) { // load archived outbound receipt that contains ZetaReverted event // use local network tx: 0x1487e6a31dd430306667250b72bf15b8390b73108b69f3de5c1b2efe456036a7 - localChainID := chains.GoerliLocalnetChain.ChainId + localChainID := chains.GoerliLocalnet.ChainId nonce := uint64(14) coinType := coin.CoinType_Zeta connectorLocal, connectorAddrLocal, custodyLocal, custodyAddrLocal := getContractsByChainID(t, localChainID) diff --git a/zetaclient/config/config_chain.go b/zetaclient/config/config_chain.go index 119911d3d9..2b28880a48 100644 --- a/zetaclient/config/config_chain.go +++ b/zetaclient/config/config_chain.go @@ -58,8 +58,8 @@ var evmChainsConfigs = map[int64]EVMConfig{ Chain: chains.MumbaiChain, Endpoint: "", }, - chains.GoerliLocalnetChain.ChainId: { - Chain: chains.GoerliLocalnetChain, + chains.GoerliLocalnet.ChainId: { + Chain: chains.GoerliLocalnet, Endpoint: "http://eth:8545", }, } From fc848652850f9edb204a8710b6554b6518d3fbff Mon Sep 17 00:00:00 2001 From: lumtis Date: Fri, 24 May 2024 10:32:36 +0200 Subject: [PATCH 16/22] deprecated chains --- pkg/chains/chain_test.go | 8 ++++---- pkg/chains/chains.go | 12 ++++++------ pkg/chains/chains_test.go | 16 ++++++++-------- pkg/crypto/pubkey_test.go | 6 +++--- testutil/sample/crosschain.go | 4 ++-- x/crosschain/keeper/process_outbound_test.go | 16 ++++++++-------- x/crosschain/keeper/utils_test.go | 2 +- x/crosschain/migrations/v4/migrate_test.go | 8 ++++---- x/crosschain/migrations/v5/migrate.go | 4 ++-- x/crosschain/migrations/v5/migrate_test.go | 14 +++++++------- x/crosschain/types/cctx_test.go | 8 ++++---- .../types/message_add_inbound_tracker_test.go | 14 +++++++------- x/crosschain/types/validate_test.go | 14 +++++++------- x/lightclient/types/verification_flags.go | 2 +- x/lightclient/types/verification_flags_test.go | 2 +- x/observer/keeper/utils_test.go | 2 +- x/observer/types/chain_params.go | 4 ++-- zetaclient/config/config_chain.go | 8 ++++---- 18 files changed, 72 insertions(+), 72 deletions(-) diff --git a/pkg/chains/chain_test.go b/pkg/chains/chain_test.go index bf091187cb..1856550b44 100644 --- a/pkg/chains/chain_test.go +++ b/pkg/chains/chain_test.go @@ -172,7 +172,7 @@ func TestIsEVMChain(t *testing.T) { want bool }{ {"Ethereum Mainnet", Ethereum.ChainId, true}, - {"Goerli Testnet", GoerliChain.ChainId, true}, + {"Goerli Testnet", Goerli.ChainId, true}, {"Sepolia Testnet", Sepolia.ChainId, true}, {"Non-EVM", BitcoinMainnet.ChainId, false}, {"Zeta Mainnet", ZetaChainMainnet.ChainId, false}, @@ -192,7 +192,7 @@ func TestIsHeaderSupportedChain(t *testing.T) { want bool }{ {"Ethereum Mainnet", Ethereum.ChainId, true}, - {"Goerli Testnet", GoerliChain.ChainId, true}, + {"Goerli Testnet", Goerli.ChainId, true}, {"Goerli Localnet", GoerliLocalnet.ChainId, true}, {"Sepolia Testnet", Sepolia.ChainId, true}, {"BSC Testnet", BscTestnet.ChainId, true}, @@ -255,7 +255,7 @@ func TestIsEthereumChain(t *testing.T) { want bool }{ {"Ethereum Mainnet", Ethereum.ChainId, true}, - {"Goerli Testnet", GoerliChain.ChainId, true}, + {"Goerli Testnet", Goerli.ChainId, true}, {"Sepolia Testnet", Sepolia.ChainId, true}, {"Non-Ethereum", BitcoinMainnet.ChainId, false}, {"Zeta Mainnet", ZetaChainMainnet.ChainId, false}, @@ -307,7 +307,7 @@ func TestChain_WitnessProgram(t *testing.T) { addr, err := btcutil.NewAddressWitnessPubKeyHash(pubKeyHash, &chaincfg.RegressionNetParams) require.NoError(t, err) - chain := GoerliChain + chain := Goerli _, err = chain.BTCAddressFromWitnessProgram(addr.WitnessProgram()) require.Error(t, err) }) diff --git a/pkg/chains/chains.go b/pkg/chains/chains.go index b17bb8bff7..4f7379d538 100644 --- a/pkg/chains/chains.go +++ b/pkg/chains/chains.go @@ -222,8 +222,8 @@ var ( * Deprecated chains */ - // GoerliChain is Ethereum goerli testnet (deprecated for sepolia) - GoerliChain = Chain{ + // Goerli is Ethereum goerli testnet (deprecated for sepolia) + Goerli = Chain{ ChainName: ChainName_goerli_testnet, ChainId: 5, Network: Network_eth, @@ -233,8 +233,8 @@ var ( IsExternal: true, } - // MumbaiChain is Polygon mumbai testnet (deprecated for amoy) - MumbaiChain = Chain{ + // Mumbai is Polygon mumbai testnet (deprecated for amoy) + Mumbai = Chain{ ChainName: ChainName_mumbai_testnet, ChainId: 80001, Network: Network_polygon, @@ -256,10 +256,10 @@ func DefaultChainsList() []*Chain { BscMainnet, Ethereum, BitcoinTestnet, - MumbaiChain, + Mumbai, Amoy, BscTestnet, - GoerliChain, + Goerli, Sepolia, BitcoinRegtest, GoerliLocalnet, diff --git a/pkg/chains/chains_test.go b/pkg/chains/chains_test.go index 5159e2b623..6153d5666e 100644 --- a/pkg/chains/chains_test.go +++ b/pkg/chains/chains_test.go @@ -31,10 +31,10 @@ func TestChainListByNetworkType(t *testing.T) { []*Chain{ &ZetaChainTestnet, &BitcoinTestnet, - &MumbaiChain, + &Mumbai, &Amoy, &BscTestnet, - &GoerliChain, + &Goerli, &Sepolia, &OptimismSepolia, &BaseSepolia, @@ -77,7 +77,7 @@ func TestChainListByNetwork(t *testing.T) { { "Eth", Network_eth, - []*Chain{&Ethereum, &GoerliChain, &Sepolia, &GoerliLocalnet}, + []*Chain{&Ethereum, &Goerli, &Sepolia, &GoerliLocalnet}, }, { "Bsc", @@ -87,7 +87,7 @@ func TestChainListByNetwork(t *testing.T) { { "Polygon", Network_polygon, - []*Chain{&Polygon, &MumbaiChain, &Amoy}, + []*Chain{&Polygon, &Mumbai, &Amoy}, }, { "Optimism", @@ -121,10 +121,10 @@ func TestChainListFunctions(t *testing.T) { &BscMainnet, &Ethereum, &BitcoinTestnet, - &MumbaiChain, + &Mumbai, &Amoy, &BscTestnet, - &GoerliChain, + &Goerli, &Sepolia, &BitcoinRegtest, &GoerliLocalnet, @@ -147,10 +147,10 @@ func TestChainListFunctions(t *testing.T) { &BscMainnet, &Ethereum, &BitcoinTestnet, - &MumbaiChain, + &Mumbai, &Amoy, &BscTestnet, - &GoerliChain, + &Goerli, &Sepolia, &BitcoinRegtest, &GoerliLocalnet, diff --git a/pkg/crypto/pubkey_test.go b/pkg/crypto/pubkey_test.go index 70f26989fe..8f1a46f393 100644 --- a/pkg/crypto/pubkey_test.go +++ b/pkg/crypto/pubkey_test.go @@ -132,17 +132,17 @@ 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.Goerli) 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.Goerli) 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.Goerli) c.Assert(err, IsNil) c.Assert(addrETH.String(), Equals, d.addrETH.mocknet) diff --git a/testutil/sample/crosschain.go b/testutil/sample/crosschain.go index 5e9a1f952c..67bfb608c7 100644 --- a/testutil/sample/crosschain.go +++ b/testutil/sample/crosschain.go @@ -147,7 +147,7 @@ func InboundParams(r *rand.Rand) *types.InboundParams { func InboundParamsValidChainID(r *rand.Rand) *types.InboundParams { return &types.InboundParams{ Sender: EthAddress().String(), - SenderChainId: chains.GoerliChain.ChainId, + SenderChainId: chains.Goerli.ChainId, TxOrigin: EthAddress().String(), Asset: StringRandom(r, 32), Amount: math.NewUint(uint64(r.Int63())), @@ -178,7 +178,7 @@ func OutboundParams(r *rand.Rand) *types.OutboundParams { func OutboundParamsValidChainID(r *rand.Rand) *types.OutboundParams { return &types.OutboundParams{ Receiver: EthAddress().String(), - ReceiverChainId: chains.GoerliChain.ChainId, + ReceiverChainId: chains.Goerli.ChainId, Amount: math.NewUint(uint64(r.Int63())), TssNonce: r.Uint64(), GasLimit: r.Uint64(), diff --git a/x/crosschain/keeper/process_outbound_test.go b/x/crosschain/keeper/process_outbound_test.go index a6f5dc81d7..ee734341df 100644 --- a/x/crosschain/keeper/process_outbound_test.go +++ b/x/crosschain/keeper/process_outbound_test.go @@ -73,7 +73,7 @@ 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.Goerli, "", big.NewInt(42)) cctx.InboundParams.CoinType = coin.CoinType_Zeta err := sdkk.EvmKeeper.SetAccount( ctx, @@ -90,7 +90,7 @@ 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.Goerli, "", big.NewInt(42)) cctx.InboundParams.CoinType = coin.CoinType_Zeta cctx.Index = "" cctx.InboundParams.SenderChainId = chains.ZetaChainMainnet.ChainId @@ -114,7 +114,7 @@ func TestKeeper_ProcessFailedOutbound(t *testing.T) { fungibleMock := keepertest.GetCrosschainFungibleMock(t, k) receiver := sample.EthAddress() errorFailedZETARevertAndCallContract := errors.New("test", 999, "failed ZETARevertAndCallContract") - cctx := GetERC20Cctx(t, receiver, chains.GoerliChain, "", big.NewInt(42)) + cctx := GetERC20Cctx(t, receiver, chains.Goerli, "", big.NewInt(42)) cctx.InboundParams.CoinType = coin.CoinType_Zeta cctx.InboundParams.SenderChainId = chains.ZetaChainMainnet.ChainId fungibleMock.On("ZETARevertAndCallContract", mock.Anything, @@ -133,7 +133,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.Goerli, "", big.NewInt(42)) cctx.InboundParams.CoinType = coin.CoinType_Zeta cctx.RelayedMessage = base64.StdEncoding.EncodeToString([]byte("sample message")) @@ -323,7 +323,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.Goerli, "", big.NewInt(42)) cctx.CctxStatus.Status = types.CctxStatus_PendingOutbound err := k.ProcessOutbound( ctx, @@ -339,7 +339,7 @@ func TestKeeper_ProcessOutbound(t *testing.T) { "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.Goerli, "", big.NewInt(42)) cctx.CctxStatus.Status = types.CctxStatus_PendingRevert err := k.ProcessOutbound( ctx, @@ -355,7 +355,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.Goerli, "", big.NewInt(42)) cctx.CctxStatus.Status = types.CctxStatus_PendingOutbound cctx.InboundParams.CoinType = coin.CoinType_Cmd err := k.ProcessOutbound( @@ -371,7 +371,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.Goerli, "", big.NewInt(42)) cctx.CctxStatus.Status = types.CctxStatus_PendingOutbound cctx.InboundParams = nil err := k.ProcessOutbound(ctx, cctx, observertypes.BallotStatus_BallotInProgress, sample.String()) diff --git a/x/crosschain/keeper/utils_test.go b/x/crosschain/keeper/utils_test.go index ddd46801c6..4539bd1637 100644 --- a/x/crosschain/keeper/utils_test.go +++ b/x/crosschain/keeper/utils_test.go @@ -47,7 +47,7 @@ func getValidEthChainIDWithIndex(t *testing.T, index int) int64 { case 0: return chains.GoerliLocalnet.ChainId case 1: - return chains.GoerliChain.ChainId + return chains.Goerli.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 c27ac590aa..26d5c0fffe 100644 --- a/x/crosschain/migrations/v4/migrate_test.go +++ b/x/crosschain/migrations/v4/migrate_test.go @@ -101,7 +101,7 @@ func TestSetBitcoinFinalizedInbound(t *testing.T) { k.SetCrossChainTx(ctx, types.CrossChainTx{ Index: "0", InboundParams: &types.InboundParams{ - SenderChainId: chains.GoerliChain.ChainId, + SenderChainId: chains.Goerli.ChainId, ObservedHash: "0xaaa", }, }) @@ -136,7 +136,7 @@ func TestSetBitcoinFinalizedInbound(t *testing.T) { k.SetCrossChainTx(ctx, types.CrossChainTx{ Index: "5", InboundParams: &types.InboundParams{ - SenderChainId: chains.MumbaiChain.ChainId, + SenderChainId: chains.Mumbai.ChainId, ObservedHash: "0xccc", }, }) @@ -152,9 +152,9 @@ 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, "0xaaa", chains.Goerli.ChainId, 0)) require.False(t, k.IsFinalizedInbound(ctx, "0xbbb", chains.Ethereum.ChainId, 0)) - require.False(t, k.IsFinalizedInbound(ctx, "0xccc", chains.MumbaiChain.ChainId, 0)) + require.False(t, k.IsFinalizedInbound(ctx, "0xccc", chains.Mumbai.ChainId, 0)) require.True(t, k.IsFinalizedInbound(ctx, "0x111", chains.BitcoinMainnet.ChainId, 0)) require.True(t, k.IsFinalizedInbound(ctx, "0x222", chains.BitcoinTestnet.ChainId, 0)) require.True(t, k.IsFinalizedInbound(ctx, "0x333", chains.BitcoinTestnet.ChainId, 0)) diff --git a/x/crosschain/migrations/v5/migrate.go b/x/crosschain/migrations/v5/migrate.go index e91badf028..58d33629da 100644 --- a/x/crosschain/migrations/v5/migrate.go +++ b/x/crosschain/migrations/v5/migrate.go @@ -78,8 +78,8 @@ type TestnetNonce struct { func CurrentTestnetChains() []TestnetNonce { return []TestnetNonce{ - {chain: chains.GoerliChain, nonceHigh: 226841, nonceLow: 226841}, - {chain: chains.MumbaiChain, nonceHigh: 200599, nonceLow: 200599}, + {chain: chains.Goerli, nonceHigh: 226841, nonceLow: 226841}, + {chain: chains.Mumbai, nonceHigh: 200599, nonceLow: 200599}, {chain: chains.BscTestnet, nonceHigh: 110454, nonceLow: 110454}, {chain: chains.BitcoinTestnet, nonceHigh: 4881, nonceLow: 4881}, } diff --git a/x/crosschain/migrations/v5/migrate_test.go b/x/crosschain/migrations/v5/migrate_test.go index f943a6dcf4..03ec78a1b7 100644 --- a/x/crosschain/migrations/v5/migrate_test.go +++ b/x/crosschain/migrations/v5/migrate_test.go @@ -73,8 +73,8 @@ 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.Goerli, + chains.Mumbai, chains.BscTestnet, chains.BitcoinTestnet, } @@ -112,8 +112,8 @@ 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.Goerli: 226841, + chains.Mumbai: 200599, chains.BscTestnet: 110454, chains.BitcoinTestnet: 4881, } @@ -140,7 +140,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.Goerli} nonceLow := int64(1) nonceHigh := int64(10) tss := sample.Tss() @@ -161,9 +161,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.Goerli: 226841, } - assertValuesNotSet := []chains.Chain{chains.MumbaiChain, chains.BscTestnet, chains.BitcoinTestnet} + assertValuesNotSet := []chains.Chain{chains.Mumbai, chains.BscTestnet, chains.BitcoinTestnet} for _, chain := range testnetChains { pn, found := zk.ObserverKeeper.GetPendingNonces(ctx, tss.TssPubkey, chain.ChainId) diff --git a/x/crosschain/types/cctx_test.go b/x/crosschain/types/cctx_test.go index 4e4833535e..34bfcbcd75 100644 --- a/x/crosschain/types/cctx_test.go +++ b/x/crosschain/types/cctx_test.go @@ -26,9 +26,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.Goerli sender := sample.EthAddress() - receiverChain := chains.GoerliChain + receiverChain := chains.Goerli receiver := sample.EthAddress() creator := sample.AccAddress() amount := sdkmath.NewUint(42) @@ -76,9 +76,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.Goerli sender := sample.EthAddress() - receiverChain := chains.GoerliChain + receiverChain := chains.Goerli receiver := sample.EthAddress() creator := sample.AccAddress() amount := sdkmath.NewUint(42) diff --git a/x/crosschain/types/message_add_inbound_tracker_test.go b/x/crosschain/types/message_add_inbound_tracker_test.go index 972b776cdb..6251990d63 100644 --- a/x/crosschain/types/message_add_inbound_tracker_test.go +++ b/x/crosschain/types/message_add_inbound_tracker_test.go @@ -25,7 +25,7 @@ func TestMsgAddInboundTracker_ValidateBasic(t *testing.T) { name: "invalid address", msg: types.NewMsgAddInboundTracker( "invalid_address", - chains.GoerliChain.ChainId, + chains.Goerli.ChainId, coin.CoinType_Gas, "hash", ), @@ -68,7 +68,7 @@ func TestMsgAddInboundTracker_ValidateBasic(t *testing.T) { name: "valid", msg: types.NewMsgAddInboundTracker( sample.AccAddress(), - chains.GoerliChain.ChainId, + chains.Goerli.ChainId, coin.CoinType_Gas, "hash", ), @@ -98,7 +98,7 @@ func TestMsgAddInboundTracker_GetSigners(t *testing.T) { name: "valid signer", msg: types.NewMsgAddInboundTracker( signer, - chains.GoerliChain.ChainId, + chains.Goerli.ChainId, coin.CoinType_Gas, "hash", ), @@ -108,7 +108,7 @@ func TestMsgAddInboundTracker_GetSigners(t *testing.T) { name: "invalid signer", msg: types.NewMsgAddInboundTracker( "invalid_address", - chains.GoerliChain.ChainId, + chains.Goerli.ChainId, coin.CoinType_Gas, "hash", ), @@ -133,7 +133,7 @@ func TestMsgAddInboundTracker_GetSigners(t *testing.T) { func TestMsgAddInboundTracker_Type(t *testing.T) { msg := types.NewMsgAddInboundTracker( sample.AccAddress(), - chains.GoerliChain.ChainId, + chains.Goerli.ChainId, coin.CoinType_Gas, "hash", ) @@ -143,7 +143,7 @@ func TestMsgAddInboundTracker_Type(t *testing.T) { func TestMsgAddInboundTracker_Route(t *testing.T) { msg := types.NewMsgAddInboundTracker( sample.AccAddress(), - chains.GoerliChain.ChainId, + chains.Goerli.ChainId, coin.CoinType_Gas, "hash", ) @@ -153,7 +153,7 @@ func TestMsgAddInboundTracker_Route(t *testing.T) { func TestMsgAddInboundTracker_GetSignBytes(t *testing.T) { msg := types.NewMsgAddInboundTracker( sample.AccAddress(), - chains.GoerliChain.ChainId, + chains.Goerli.ChainId, coin.CoinType_Gas, "hash", ) diff --git a/x/crosschain/types/validate_test.go b/x/crosschain/types/validate_test.go index 4c0e807732..0ab3e20885 100644 --- a/x/crosschain/types/validate_test.go +++ b/x/crosschain/types/validate_test.go @@ -12,12 +12,12 @@ 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.Error(t, types.ValidateAddressForChain("0x123", chains.Goerli.ChainId)) + require.Error(t, types.ValidateAddressForChain("", chains.Goerli.ChainId)) + require.Error(t, types.ValidateAddressForChain("%%%%", chains.Goerli.ChainId)) require.NoError( t, - types.ValidateAddressForChain("0x792c127Fa3AC1D52F904056Baf1D9257391e7D78", chains.GoerliChain.ChainId), + types.ValidateAddressForChain("0x792c127Fa3AC1D52F904056Baf1D9257391e7D78", chains.Goerli.ChainId), ) // test for btc chain @@ -73,15 +73,15 @@ func TestValidateHashForChain(t *testing.T) { t, types.ValidateHashForChain( "0x84bd5c9922b63c52d8a9ca686e0a57ff978150b71be0583514d01c27aa341910", - chains.GoerliChain.ChainId, + chains.Goerli.ChainId, ), ) - require.Error(t, types.ValidateHashForChain("", chains.GoerliChain.ChainId)) + require.Error(t, types.ValidateHashForChain("", chains.Goerli.ChainId)) require.Error( t, types.ValidateHashForChain( "a0fa5a82f106fb192e4c503bfa8d54b2de20a821e09338094ab825cc9b275059", - chains.GoerliChain.ChainId, + chains.Goerli.ChainId, ), ) require.NoError( diff --git a/x/lightclient/types/verification_flags.go b/x/lightclient/types/verification_flags.go index 41046ff530..a421e47479 100644 --- a/x/lightclient/types/verification_flags.go +++ b/x/lightclient/types/verification_flags.go @@ -33,7 +33,7 @@ func DefaultHeaderSupportedChains() []HeaderSupportedChain { Enabled: false, }, { - ChainId: chains.GoerliChain.ChainId, + ChainId: chains.Goerli.ChainId, Enabled: false, }, } diff --git a/x/lightclient/types/verification_flags_test.go b/x/lightclient/types/verification_flags_test.go index 58544068ef..2986d9ceef 100644 --- a/x/lightclient/types/verification_flags_test.go +++ b/x/lightclient/types/verification_flags_test.go @@ -23,7 +23,7 @@ func TestDefaultVerificationFlags(t *testing.T) { require.False(t, f.Enabled) case chains.GoerliLocalnet.ChainId: require.False(t, f.Enabled) - case chains.GoerliChain.ChainId: + case chains.Goerli.ChainId: require.False(t, f.Enabled) default: require.False(t, f.Enabled, "unexpected chain id") diff --git a/x/observer/keeper/utils_test.go b/x/observer/keeper/utils_test.go index 99b3daf607..5d3a14eae3 100644 --- a/x/observer/keeper/utils_test.go +++ b/x/observer/keeper/utils_test.go @@ -36,7 +36,7 @@ func getValidEthChainIDWithIndex(t *testing.T, index int) int64 { case 0: return chains.GoerliLocalnet.ChainId case 1: - return chains.GoerliChain.ChainId + return chains.Goerli.ChainId default: require.Fail(t, "invalid index") } diff --git a/x/observer/types/chain_params.go b/x/observer/types/chain_params.go index f89780baed..c60e9df4c7 100644 --- a/x/observer/types/chain_params.go +++ b/x/observer/types/chain_params.go @@ -218,7 +218,7 @@ func GetDefaultBtcMainnetChainParams() *ChainParams { } func GetDefaultGoerliTestnetChainParams() *ChainParams { return &ChainParams{ - ChainId: chains.GoerliChain.ChainId, + ChainId: chains.Goerli.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", @@ -255,7 +255,7 @@ func GetDefaultBscTestnetChainParams() *ChainParams { } func GetDefaultMumbaiTestnetChainParams() *ChainParams { return &ChainParams{ - ChainId: chains.MumbaiChain.ChainId, + ChainId: chains.Mumbai.ChainId, ConfirmationCount: 12, ZetaTokenContractAddress: zeroAddress, ConnectorContractAddress: zeroAddress, diff --git a/zetaclient/config/config_chain.go b/zetaclient/config/config_chain.go index 2b28880a48..12c889f6af 100644 --- a/zetaclient/config/config_chain.go +++ b/zetaclient/config/config_chain.go @@ -42,8 +42,8 @@ var evmChainsConfigs = map[int64]EVMConfig{ chains.BscMainnet.ChainId: { Chain: chains.BscMainnet, }, - chains.GoerliChain.ChainId: { - Chain: chains.GoerliChain, + chains.Goerli.ChainId: { + Chain: chains.Goerli, Endpoint: "", }, chains.Sepolia.ChainId: { @@ -54,8 +54,8 @@ var evmChainsConfigs = map[int64]EVMConfig{ Chain: chains.BscTestnet, Endpoint: "", }, - chains.MumbaiChain.ChainId: { - Chain: chains.MumbaiChain, + chains.Mumbai.ChainId: { + Chain: chains.Mumbai, Endpoint: "", }, chains.GoerliLocalnet.ChainId: { From ecaf8ad3ce71f3849c325f6f74685ec1923f48b1 Mon Sep 17 00:00:00 2001 From: lumtis Date: Fri, 24 May 2024 10:34:37 +0200 Subject: [PATCH 17/22] fix zeta -> zetachain naming --- pkg/chains/chain_test.go | 8 ++++---- pkg/chains/chains.go | 20 +++++++++---------- pkg/chains/chains_test.go | 16 +++++++-------- x/crosschain/keeper/gas_payment_test.go | 16 +++++++-------- x/crosschain/keeper/process_inbound_test.go | 18 ++++++++--------- x/crosschain/migrations/v5/migrate_test.go | 2 +- x/lightclient/keeper/proof_test.go | 4 ++-- ...message_disable_verification_flags_test.go | 4 ++-- .../message_enable_verification_flags_test.go | 4 ++-- .../keeper/grpc_query_chain_params_test.go | 6 +++--- x/observer/keeper/vote_inbound_test.go | 14 ++++++------- x/observer/types/chain_params.go | 2 +- 12 files changed, 57 insertions(+), 57 deletions(-) diff --git a/pkg/chains/chain_test.go b/pkg/chains/chain_test.go index 1856550b44..7bbb9de679 100644 --- a/pkg/chains/chain_test.go +++ b/pkg/chains/chain_test.go @@ -139,8 +139,8 @@ func TestChain_DecodeAddress(t *testing.T) { func TestChain_InChainList(t *testing.T) { require.True(t, ZetaChainMainnet.InChainList(ChainListByNetwork(Network_zeta))) - require.True(t, ZetaDevnet.InChainList(ChainListByNetwork(Network_zeta))) - require.True(t, ZetaPrivnet.InChainList(ChainListByNetwork(Network_zeta))) + require.True(t, ZetaChainDevnet.InChainList(ChainListByNetwork(Network_zeta))) + require.True(t, ZetaChainPrivnet.InChainList(ChainListByNetwork(Network_zeta))) require.True(t, ZetaChainTestnet.InChainList(ChainListByNetwork(Network_zeta))) require.False(t, Ethereum.InChainList(ChainListByNetwork(Network_zeta))) } @@ -153,8 +153,8 @@ func TestIsZetaChain(t *testing.T) { }{ {"Zeta Mainnet", ZetaChainMainnet.ChainId, true}, {"Zeta Testnet", ZetaChainTestnet.ChainId, true}, - {"Zeta Mocknet", ZetaDevnet.ChainId, true}, - {"Zeta Privnet", ZetaPrivnet.ChainId, true}, + {"Zeta Mocknet", ZetaChainDevnet.ChainId, true}, + {"Zeta Privnet", ZetaChainPrivnet.ChainId, true}, {"Non-Zeta", Ethereum.ChainId, false}, } diff --git a/pkg/chains/chains.go b/pkg/chains/chains.go index 4f7379d538..21718f874d 100644 --- a/pkg/chains/chains.go +++ b/pkg/chains/chains.go @@ -169,9 +169,9 @@ var ( * Devnet chains */ - // ZetaDevnet is the devnet chain for Zeta + // ZetaChainDevnet is the devnet chain for Zeta // used as live testing environment - ZetaDevnet = Chain{ + ZetaChainDevnet = Chain{ ChainName: ChainName_zeta_mainnet, ChainId: 70000, Network: Network_zeta, @@ -185,8 +185,8 @@ var ( * Privnet chains */ - // ZetaPrivnet is the privnet chain for Zeta (localnet) - ZetaPrivnet = Chain{ + // ZetaChainPrivnet is the privnet chain for Zeta (localnet) + ZetaChainPrivnet = Chain{ ChainName: ChainName_zeta_mainnet, ChainId: 101, Network: Network_zeta, @@ -265,8 +265,8 @@ func DefaultChainsList() []*Chain { GoerliLocalnet, ZetaChainMainnet, ZetaChainTestnet, - ZetaDevnet, - ZetaPrivnet, + ZetaChainDevnet, + ZetaChainPrivnet, Polygon, OptimismMainnet, OptimismSepolia, @@ -338,14 +338,14 @@ func ZetaChainFromChainID(chainID string) (Chain, error) { } switch ethChainID { - case ZetaPrivnet.ChainId: - return ZetaPrivnet, nil + case ZetaChainPrivnet.ChainId: + return ZetaChainPrivnet, nil case ZetaChainMainnet.ChainId: return ZetaChainMainnet, nil case ZetaChainTestnet.ChainId: return ZetaChainTestnet, nil - case ZetaDevnet.ChainId: - return ZetaDevnet, nil + case ZetaChainDevnet.ChainId: + return ZetaChainDevnet, 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 6153d5666e..dffb630086 100644 --- a/pkg/chains/chains_test.go +++ b/pkg/chains/chains_test.go @@ -44,7 +44,7 @@ func TestChainListByNetworkType(t *testing.T) { "privnet chains", NetworkType_privnet, []*Chain{ - &ZetaPrivnet, + &ZetaChainPrivnet, &BitcoinRegtest, &GoerliLocalnet, }, @@ -67,7 +67,7 @@ func TestChainListByNetwork(t *testing.T) { { "Zeta", Network_zeta, - []*Chain{&ZetaChainMainnet, &ZetaDevnet, &ZetaPrivnet, &ZetaChainTestnet}, + []*Chain{&ZetaChainMainnet, &ZetaChainDevnet, &ZetaChainPrivnet, &ZetaChainTestnet}, }, { "Btc", @@ -130,8 +130,8 @@ func TestChainListFunctions(t *testing.T) { &GoerliLocalnet, &ZetaChainMainnet, &ZetaChainTestnet, - &ZetaDevnet, - &ZetaPrivnet, + &ZetaChainDevnet, + &ZetaChainPrivnet, &Polygon, &OptimismMainnet, &OptimismSepolia, @@ -191,15 +191,15 @@ func TestZetaChainFromChainID(t *testing.T) { wantErr: false, }, { - name: "ZetaDevnet", + name: "ZetaChainDevnet", chainID: "cosmoshub_70000-1", - expected: ZetaDevnet, + expected: ZetaChainDevnet, wantErr: false, }, { - name: "ZetaPrivnet", + name: "ZetaChainPrivnet", chainID: "cosmoshub_101-1", - expected: ZetaPrivnet, + expected: ZetaChainPrivnet, wantErr: false, }, { diff --git a/x/crosschain/keeper/gas_payment_test.go b/x/crosschain/keeper/gas_payment_test.go index 8a4f62abd0..b80826aac7 100644 --- a/x/crosschain/keeper/gas_payment_test.go +++ b/x/crosschain/keeper/gas_payment_test.go @@ -51,7 +51,7 @@ func TestKeeper_PayGasNativeAndUpdateCctx(t *testing.T) { }, OutboundParams: []*types.OutboundParams{ { - ReceiverChainId: chains.ZetaPrivnet.ChainId, + ReceiverChainId: chains.ZetaChainPrivnet.ChainId, CoinType: coin.CoinType_Gas, }, { @@ -109,7 +109,7 @@ func TestKeeper_PayGasNativeAndUpdateCctx(t *testing.T) { }, OutboundParams: []*types.OutboundParams{ { - ReceiverChainId: chains.ZetaPrivnet.ChainId, + ReceiverChainId: chains.ZetaChainPrivnet.ChainId, }, { ReceiverChainId: chainID, @@ -148,7 +148,7 @@ func TestKeeper_PayGasNativeAndUpdateCctx(t *testing.T) { }, OutboundParams: []*types.OutboundParams{ { - ReceiverChainId: chains.ZetaPrivnet.ChainId, + ReceiverChainId: chains.ZetaChainPrivnet.ChainId, }, { ReceiverChainId: chainID, @@ -211,7 +211,7 @@ func TestKeeper_PayGasInERC20AndUpdateCctx(t *testing.T) { }, OutboundParams: []*types.OutboundParams{ { - ReceiverChainId: chains.ZetaPrivnet.ChainId, + ReceiverChainId: chains.ZetaChainPrivnet.ChainId, }, { ReceiverChainId: chainID, @@ -273,7 +273,7 @@ func TestKeeper_PayGasInERC20AndUpdateCctx(t *testing.T) { }, OutboundParams: []*types.OutboundParams{ { - ReceiverChainId: chains.ZetaPrivnet.ChainId, + ReceiverChainId: chains.ZetaChainPrivnet.ChainId, }, { ReceiverChainId: chainID, @@ -315,7 +315,7 @@ func TestKeeper_PayGasInERC20AndUpdateCctx(t *testing.T) { }, OutboundParams: []*types.OutboundParams{ { - ReceiverChainId: chains.ZetaPrivnet.ChainId, + ReceiverChainId: chains.ZetaChainPrivnet.ChainId, }, { ReceiverChainId: chainID, @@ -367,7 +367,7 @@ func TestKeeper_PayGasInERC20AndUpdateCctx(t *testing.T) { }, OutboundParams: []*types.OutboundParams{ { - ReceiverChainId: chains.ZetaPrivnet.ChainId, + ReceiverChainId: chains.ZetaChainPrivnet.ChainId, }, { ReceiverChainId: chainID, @@ -425,7 +425,7 @@ func TestKeeper_PayGasInERC20AndUpdateCctx(t *testing.T) { }, OutboundParams: []*types.OutboundParams{ { - ReceiverChainId: chains.ZetaPrivnet.ChainId, + ReceiverChainId: chains.ZetaChainPrivnet.ChainId, }, { ReceiverChainId: chainID, diff --git a/x/crosschain/keeper/process_inbound_test.go b/x/crosschain/keeper/process_inbound_test.go index 04472327b4..0286290cc4 100644 --- a/x/crosschain/keeper/process_inbound_test.go +++ b/x/crosschain/keeper/process_inbound_test.go @@ -38,7 +38,7 @@ func TestKeeper_ProcessInboundZEVMDeposit(t *testing.T) { cctx := sample.CrossChainTx(t, "test") cctx.CctxStatus = &types.Status{Status: types.CctxStatus_PendingInbound} cctx.GetCurrentOutboundParam().Receiver = receiver.String() - cctx.GetCurrentOutboundParam().ReceiverChainId = chains.ZetaPrivnet.ChainId + cctx.GetCurrentOutboundParam().ReceiverChainId = chains.ZetaChainPrivnet.ChainId cctx.GetInboundParams().Amount = sdkmath.NewUintFromBigInt(amount) cctx.InboundParams.CoinType = coin.CoinType_Zeta cctx.GetInboundParams().SenderChainId = 0 @@ -65,7 +65,7 @@ func TestKeeper_ProcessInboundZEVMDeposit(t *testing.T) { cctx := sample.CrossChainTx(t, "test") cctx.CctxStatus = &types.Status{Status: types.CctxStatus_PendingInbound} cctx.GetCurrentOutboundParam().Receiver = receiver.String() - cctx.GetCurrentOutboundParam().ReceiverChainId = chains.ZetaPrivnet.ChainId + cctx.GetCurrentOutboundParam().ReceiverChainId = chains.ZetaChainPrivnet.ChainId cctx.GetInboundParams().Amount = sdkmath.NewUintFromBigInt(amount) cctx.InboundParams.CoinType = coin.CoinType_Zeta cctx.GetInboundParams().SenderChainId = 0 @@ -100,7 +100,7 @@ func TestKeeper_ProcessInboundZEVMDeposit(t *testing.T) { // call ProcessInbound cctx := GetERC20Cctx(t, receiver, *senderChain, "", amount) - cctx.GetCurrentOutboundParam().ReceiverChainId = chains.ZetaPrivnet.ChainId + cctx.GetCurrentOutboundParam().ReceiverChainId = chains.ZetaChainPrivnet.ChainId k.ProcessInbound(ctx, cctx) require.Equal(t, types.CctxStatus_Aborted, cctx.CctxStatus.Status) require.Equal( @@ -138,7 +138,7 @@ func TestKeeper_ProcessInboundZEVMDeposit(t *testing.T) { // call ProcessInbound cctx := GetERC20Cctx(t, receiver, *senderChain, asset, amount) - cctx.GetCurrentOutboundParam().ReceiverChainId = chains.ZetaPrivnet.ChainId + cctx.GetCurrentOutboundParam().ReceiverChainId = chains.ZetaChainPrivnet.ChainId k.ProcessInbound(ctx, cctx) require.Equal(t, types.CctxStatus_Aborted, cctx.CctxStatus.Status) require.Equal( @@ -181,7 +181,7 @@ func TestKeeper_ProcessInboundZEVMDeposit(t *testing.T) { // call ProcessInbound cctx := GetERC20Cctx(t, receiver, *senderChain, asset, amount) - cctx.GetCurrentOutboundParam().ReceiverChainId = chains.ZetaPrivnet.ChainId + cctx.GetCurrentOutboundParam().ReceiverChainId = chains.ZetaChainPrivnet.ChainId k.ProcessInbound(ctx, cctx) require.Equal(t, types.CctxStatus_Aborted, cctx.CctxStatus.Status) require.Equal( @@ -225,7 +225,7 @@ func TestKeeper_ProcessInboundZEVMDeposit(t *testing.T) { // call ProcessInbound cctx := GetERC20Cctx(t, receiver, *senderChain, asset, amount) - cctx.GetCurrentOutboundParam().ReceiverChainId = chains.ZetaPrivnet.ChainId + cctx.GetCurrentOutboundParam().ReceiverChainId = chains.ZetaChainPrivnet.ChainId k.ProcessInbound(ctx, cctx) require.Equal(t, types.CctxStatus_Aborted, cctx.CctxStatus.Status) require.Equal( @@ -270,7 +270,7 @@ func TestKeeper_ProcessInboundZEVMDeposit(t *testing.T) { // call ProcessInbound cctx := GetERC20Cctx(t, receiver, *senderChain, asset, amount) - cctx.GetCurrentOutboundParam().ReceiverChainId = chains.ZetaPrivnet.ChainId + cctx.GetCurrentOutboundParam().ReceiverChainId = chains.ZetaChainPrivnet.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") @@ -308,7 +308,7 @@ func TestKeeper_ProcessInboundZEVMDeposit(t *testing.T) { // call ProcessInbound cctx := GetERC20Cctx(t, receiver, *senderChain, asset, amount) - cctx.GetCurrentOutboundParam().ReceiverChainId = chains.ZetaPrivnet.ChainId + cctx.GetCurrentOutboundParam().ReceiverChainId = chains.ZetaChainPrivnet.ChainId k.ProcessInbound(ctx, cctx) require.Equal(t, types.CctxStatus_PendingRevert, cctx.CctxStatus.Status) require.Equal(t, errDeposit.Error(), cctx.CctxStatus.StatusMessage) @@ -344,7 +344,7 @@ func TestKeeper_ProcessInboundZEVMDeposit(t *testing.T) { // call ProcessInbound cctx := GetERC20Cctx(t, receiver, *senderChain, asset, amount) - cctx.GetCurrentOutboundParam().ReceiverChainId = chains.ZetaPrivnet.ChainId + cctx.GetCurrentOutboundParam().ReceiverChainId = chains.ZetaChainPrivnet.ChainId cctx.OutboundParams = append(cctx.OutboundParams, cctx.GetCurrentOutboundParam()) k.ProcessInbound(ctx, cctx) require.Equal(t, types.CctxStatus_Aborted, cctx.CctxStatus.Status) diff --git a/x/crosschain/migrations/v5/migrate_test.go b/x/crosschain/migrations/v5/migrate_test.go index 03ec78a1b7..c95535a5b0 100644 --- a/x/crosschain/migrations/v5/migrate_test.go +++ b/x/crosschain/migrations/v5/migrate_test.go @@ -228,7 +228,7 @@ func CrossChainTxList(count int) []crosschaintypes.CrossChainTx { OutboundParams: []*crosschaintypes.OutboundParams{{ Amount: math.ZeroUint(), CoinType: coin.CoinType_ERC20, - ReceiverChainId: chains.ZetaPrivnet.ChainId, + ReceiverChainId: chains.ZetaChainPrivnet.ChainId, }}, } } diff --git a/x/lightclient/keeper/proof_test.go b/x/lightclient/keeper/proof_test.go index 2491dc8f65..b7d8be2101 100644 --- a/x/lightclient/keeper/proof_test.go +++ b/x/lightclient/keeper/proof_test.go @@ -68,11 +68,11 @@ func TestKeeper_VerifyProof(t *testing.T) { }, }) - _, err := k.VerifyProof(ctx, &proofs.Proof{}, chains.ZetaPrivnet.ChainId, sample.Hash().String(), 1) + _, err := k.VerifyProof(ctx, &proofs.Proof{}, chains.ZetaChainPrivnet.ChainId, sample.Hash().String(), 1) require.ErrorContains( t, err, - fmt.Sprintf("proof verification is disabled for chain %d", chains.ZetaPrivnet.ChainId), + fmt.Sprintf("proof verification is disabled for chain %d", chains.ZetaChainPrivnet.ChainId), ) }) diff --git a/x/lightclient/types/message_disable_verification_flags_test.go b/x/lightclient/types/message_disable_verification_flags_test.go index 83eb923b0a..6ccde4a12b 100644 --- a/x/lightclient/types/message_disable_verification_flags_test.go +++ b/x/lightclient/types/message_disable_verification_flags_test.go @@ -54,14 +54,14 @@ func TestMsgDisableHeaderVerification_ValidateBasic(t *testing.T) { name: "invalid chain id", msg: types.MsgDisableHeaderVerification{ Creator: sample.AccAddress(), - ChainIdList: []int64{chains.ZetaPrivnet.ChainId}, + ChainIdList: []int64{chains.ZetaChainPrivnet.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.ZetaPrivnet.ChainId), + fmt.Sprintf("invalid chain id header not supported (%d)", chains.ZetaChainPrivnet.ChainId), ) }, }, diff --git a/x/lightclient/types/message_enable_verification_flags_test.go b/x/lightclient/types/message_enable_verification_flags_test.go index 5fd731c9d3..0bda67f1b9 100644 --- a/x/lightclient/types/message_enable_verification_flags_test.go +++ b/x/lightclient/types/message_enable_verification_flags_test.go @@ -54,14 +54,14 @@ func TestMsgEnableHeaderVerification_ValidateBasic(t *testing.T) { name: "invalid chain id", msg: types.MsgEnableHeaderVerification{ Creator: sample.AccAddress(), - ChainIdList: []int64{chains.ZetaPrivnet.ChainId}, + ChainIdList: []int64{chains.ZetaChainPrivnet.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.ZetaPrivnet.ChainId), + fmt.Sprintf("invalid chain id header not supported (%d)", chains.ZetaChainPrivnet.ChainId), ) }, }, diff --git a/x/observer/keeper/grpc_query_chain_params_test.go b/x/observer/keeper/grpc_query_chain_params_test.go index b7ce955681..c417e19b56 100644 --- a/x/observer/keeper/grpc_query_chain_params_test.go +++ b/x/observer/keeper/grpc_query_chain_params_test.go @@ -39,7 +39,7 @@ func TestKeeper_GetChainParamsForChain(t *testing.T) { list := types.ChainParamsList{ ChainParams: []*types.ChainParams{ { - ChainId: chains.ZetaPrivnet.ChainId, + ChainId: chains.ZetaChainPrivnet.ChainId, IsSupported: false, BallotThreshold: sdk.ZeroDec(), MinObserverDelegation: sdk.ZeroDec(), @@ -49,7 +49,7 @@ func TestKeeper_GetChainParamsForChain(t *testing.T) { k.SetChainParamsList(ctx, list) res, err := k.GetChainParamsForChain(wctx, &types.QueryGetChainParamsForChainRequest{ - ChainId: chains.ZetaPrivnet.ChainId, + ChainId: chains.ZetaChainPrivnet.ChainId, }) require.NoError(t, err) require.Equal(t, &types.QueryGetChainParamsForChainResponse{ @@ -84,7 +84,7 @@ func TestKeeper_GetChainParams(t *testing.T) { list := types.ChainParamsList{ ChainParams: []*types.ChainParams{ { - ChainId: chains.ZetaPrivnet.ChainId, + ChainId: chains.ZetaChainPrivnet.ChainId, IsSupported: false, BallotThreshold: sdk.ZeroDec(), MinObserverDelegation: sdk.ZeroDec(), diff --git a/x/observer/keeper/vote_inbound_test.go b/x/observer/keeper/vote_inbound_test.go index 366f79ec4f..cfa1680d97 100644 --- a/x/observer/keeper/vote_inbound_test.go +++ b/x/observer/keeper/vote_inbound_test.go @@ -25,7 +25,7 @@ func TestKeeper_VoteOnInboundBallot(t *testing.T) { _, _, err := k.VoteOnInboundBallot( ctx, getValidEthChainIDWithIndex(t, 0), - chains.ZetaPrivnet.ChainId, + chains.ZetaChainPrivnet.ChainId, coin.CoinType_ERC20, sample.AccAddress(), "index", @@ -47,7 +47,7 @@ func TestKeeper_VoteOnInboundBallot(t *testing.T) { _, _, err := k.VoteOnInboundBallot( ctx, getValidEthChainIDWithIndex(t, 0), - chains.ZetaPrivnet.ChainId, + chains.ZetaChainPrivnet.ChainId, coin.CoinType_ERC20, sample.AccAddress(), "index", @@ -69,7 +69,7 @@ func TestKeeper_VoteOnInboundBallot(t *testing.T) { _, _, err = k.VoteOnInboundBallot( ctx, getValidEthChainIDWithIndex(t, 0), - chains.ZetaPrivnet.ChainId, + chains.ZetaChainPrivnet.ChainId, coin.CoinType_ERC20, sample.AccAddress(), "index", @@ -98,7 +98,7 @@ func TestKeeper_VoteOnInboundBallot(t *testing.T) { _, _, err := k.VoteOnInboundBallot( ctx, getValidEthChainIDWithIndex(t, 0), - chains.ZetaPrivnet.ChainId, + chains.ZetaChainPrivnet.ChainId, coin.CoinType_ERC20, sample.AccAddress(), "index", @@ -135,7 +135,7 @@ func TestKeeper_VoteOnInboundBallot(t *testing.T) { _, _, err := k.VoteOnInboundBallot( ctx, getValidEthChainIDWithIndex(t, 0), - chains.ZetaPrivnet.ChainId, + chains.ZetaChainPrivnet.ChainId, coin.CoinType_ERC20, observer, "index", @@ -152,7 +152,7 @@ func TestKeeper_VoteOnInboundBallot(t *testing.T) { IsSupported: true, }, { - ChainId: chains.ZetaPrivnet.ChainId, + ChainId: chains.ZetaChainPrivnet.ChainId, IsSupported: false, }, }, @@ -163,7 +163,7 @@ func TestKeeper_VoteOnInboundBallot(t *testing.T) { _, _, err = k.VoteOnInboundBallot( ctx, getValidEthChainIDWithIndex(t, 0), - chains.ZetaPrivnet.ChainId, + chains.ZetaChainPrivnet.ChainId, coin.CoinType_ERC20, observer, "index", diff --git a/x/observer/types/chain_params.go b/x/observer/types/chain_params.go index c60e9df4c7..d67aa520ba 100644 --- a/x/observer/types/chain_params.go +++ b/x/observer/types/chain_params.go @@ -327,7 +327,7 @@ func GetDefaultGoerliLocalnetChainParams() *ChainParams { } func GetDefaultZetaPrivnetChainParams() *ChainParams { return &ChainParams{ - ChainId: chains.ZetaPrivnet.ChainId, + ChainId: chains.ZetaChainPrivnet.ChainId, ConfirmationCount: 1, ZetaTokenContractAddress: zeroAddress, ConnectorContractAddress: zeroAddress, From 8333f23aa71b3115e437dffb856f33416f28c8ef Mon Sep 17 00:00:00 2001 From: lumtis Date: Fri, 24 May 2024 10:41:52 +0200 Subject: [PATCH 18/22] Makefile --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 1a0357854b..6508b07b50 100644 --- a/Makefile +++ b/Makefile @@ -199,7 +199,7 @@ mocks: .PHONY: mocks # generate also includes Go code formatting -generate: proto-gen openapi specs typescript docs-zetacored mocks fmt-import +generate: proto-gen openapi specs typescript docs-zetacored mocks fmt-import fmt-golines .PHONY: generate ############################################################################### From 7319451d57965f8e819c6935c3875e511952508c Mon Sep 17 00:00:00 2001 From: lumtis Date: Fri, 24 May 2024 10:50:19 +0200 Subject: [PATCH 19/22] changelog --- changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/changelog.md b/changelog.md index d3f774081d..9ce2487ef9 100644 --- a/changelog.md +++ b/changelog.md @@ -15,6 +15,7 @@ * [2152](https://github.com/zeta-chain/node/pull/2152) - custom priority nonce mempool * [2113](https://github.com/zeta-chain/node/pull/2113) - add zetaclientd-supervisor process * [2154](https://github.com/zeta-chain/node/pull/2154) - add `ibccrosschain` module +* [2258](https://github.com/zeta-chain/node/pull/2258) - add Optimism and Base in static chain information ### Refactor From 817fd4810429f5d28d0295ba4e3cc8ba96732b04 Mon Sep 17 00:00:00 2001 From: lumtis Date: Fri, 24 May 2024 11:04:58 +0200 Subject: [PATCH 20/22] fix tests --- zetaclient/zetacore/tx_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zetaclient/zetacore/tx_test.go b/zetaclient/zetacore/tx_test.go index e1b8c6e530..79ee10daac 100644 --- a/zetaclient/zetacore/tx_test.go +++ b/zetaclient/zetacore/tx_test.go @@ -249,8 +249,8 @@ func TestZetacore_UpdateZetacoreContext(t *testing.T) { Chains: []*chains.Chain{ { - chains.BitcoinMainnet.ChainName, chains.BitcoinMainnet.ChainId, + chains.BitcoinMainnet.ChainName, chains.BscMainnet.Network, chains.BscMainnet.NetworkType, chains.BscMainnet.Vm, @@ -258,8 +258,8 @@ func TestZetacore_UpdateZetacoreContext(t *testing.T) { chains.BscMainnet.IsExternal, }, { + chains.Ethereum.ChainI chains.Ethereum.ChainName, - chains.Ethereum.ChainId, chains.Ethereum.Network, chains.Ethereum.NetworkType, chains.Ethereum.Vm, From cb2e873739c9bb5369eba405790c4a4fa0e36f71 Mon Sep 17 00:00:00 2001 From: lumtis Date: Fri, 24 May 2024 11:08:09 +0200 Subject: [PATCH 21/22] fix tests 2 --- zetaclient/zetacore/tx_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zetaclient/zetacore/tx_test.go b/zetaclient/zetacore/tx_test.go index 79ee10daac..f12fcc8b6a 100644 --- a/zetaclient/zetacore/tx_test.go +++ b/zetaclient/zetacore/tx_test.go @@ -258,7 +258,7 @@ func TestZetacore_UpdateZetacoreContext(t *testing.T) { chains.BscMainnet.IsExternal, }, { - chains.Ethereum.ChainI + chains.Ethereum.ChainId, chains.Ethereum.ChainName, chains.Ethereum.Network, chains.Ethereum.NetworkType, From b3ce9fda74f8206eb780436e272d23bd912ef7e5 Mon Sep 17 00:00:00 2001 From: lumtis Date: Mon, 27 May 2024 13:00:29 +0200 Subject: [PATCH 22/22] comment --- e2e/e2etests/test_migrate_chain_support.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/e2e/e2etests/test_migrate_chain_support.go b/e2e/e2etests/test_migrate_chain_support.go index 052dc90742..4d0435623d 100644 --- a/e2e/e2etests/test_migrate_chain_support.go +++ b/e2e/e2etests/test_migrate_chain_support.go @@ -29,9 +29,9 @@ import ( // Therefore, we hardcode RPC urls and addresses for simplicity const EVM2RPCURL = "http://eth2:8545" -// EVM2ChainID is the chain ID for the additional EVM localnet +// EVMSepoliaChainID 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.Sepolia.ChainId +var EVMSepoliaChainID = chains.Sepolia.ChainId func TestMigrateChainSupport(r *runner.E2ERunner, _ []string) { // deposit most of the ZETA supply on ZetaChain @@ -309,7 +309,7 @@ func getNewEVMChainParams(r *runner.E2ERunner) *observertypes.ChainParams { chainParams := observertypes.GetDefaultGoerliLocalnetChainParams() // set the chain id to the new chain id - chainParams.ChainId = EVM2ChainID + chainParams.ChainId = EVMSepoliaChainID // set contracts chainParams.ConnectorContractAddress = r.ConnectorEthAddr.Hex()