Skip to content

Commit

Permalink
feat: add Bitcoin Testnet4 static chain info (#2911)
Browse files Browse the repository at this point in the history
* add bitcoin Testnet4 static chain info

* add changelog entry

* remove integer based Signet and Testnet4 chain names as they're deprecated

* fix generated files

* fix compile error

* fix unit test
  • Loading branch information
ws4charlie authored Sep 25, 2024
1 parent 3e0b307 commit 2892114
Show file tree
Hide file tree
Showing 8 changed files with 117 additions and 107 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* [2870](https://github.com/zeta-chain/node/pull/2870) - support for multiple Bitcoin chains in the zetaclient
* [2883](https://github.com/zeta-chain/node/pull/2883) - add chain static information for btc signet testnet
* [2907](https://github.com/zeta-chain/node/pull/2907) - derive Bitcoin tss address by chain id and added more Signet static info
* [2911](https://github.com/zeta-chain/node/pull/2911) - add chain static information for btc testnet4

### Refactor

Expand Down
1 change: 0 additions & 1 deletion docs/openapi/openapi.swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56986,7 +56986,6 @@ definitions:
- solana_mainnet
- solana_devnet
- solana_localnet
- btc_signet_testnet
default: empty
title: |-
ChainName represents the name of the chain
Expand Down
15 changes: 14 additions & 1 deletion pkg/chains/chains.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ var (
Name: "btc_testnet",
}

// BitcoinSignetTestnet is Bitcoin Signet testnet
BitcoinSignetTestnet = Chain{
ChainName: ChainName_btc_signet_testnet,
ChainId: 18333,
Network: Network_btc,
NetworkType: NetworkType_testnet,
Expand All @@ -181,6 +181,18 @@ var (
Name: "btc_signet_testnet",
}

// BitcoinTestnet4 is Bitcoin testnet4
BitcoinTestnet4 = Chain{
ChainId: 18334,
Network: Network_btc,
NetworkType: NetworkType_testnet,
Vm: Vm_no_vm,
Consensus: Consensus_bitcoin,
IsExternal: true,
CctxGateway: CCTXGateway_observers,
Name: "btc_testnet4",
}

// Amoy is Polygon amoy testnet
Amoy = Chain{
ChainName: ChainName_amoy_testnet,
Expand Down Expand Up @@ -360,6 +372,7 @@ func DefaultChainsList() []Chain {
Ethereum,
BitcoinTestnet,
BitcoinSignetTestnet,
BitcoinTestnet4,
Mumbai,
Amoy,
BscTestnet,
Expand Down
189 changes: 93 additions & 96 deletions pkg/chains/chains.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion pkg/chains/chains_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import (
func TestChain_Name(t *testing.T) {
t.Run("new Name field is compatible with ChainName enum", func(t *testing.T) {
for _, chain := range chains.DefaultChainsList() {
require.EqualValues(t, chain.Name, chain.ChainName.String())
if chain.ChainName != chains.ChainName_empty {
require.EqualValues(t, chain.Name, chain.ChainName.String())
}
}
})
}
Expand Down Expand Up @@ -43,6 +45,7 @@ func TestChainListByNetworkType(t *testing.T) {
chains.ZetaChainTestnet,
chains.BitcoinTestnet,
chains.BitcoinSignetTestnet,
chains.BitcoinTestnet4,
chains.Mumbai,
chains.Amoy,
chains.BscTestnet,
Expand Down Expand Up @@ -95,6 +98,7 @@ func TestChainListByNetwork(t *testing.T) {
chains.BitcoinMainnet,
chains.BitcoinTestnet,
chains.BitcoinSignetTestnet,
chains.BitcoinTestnet4,
chains.BitcoinRegtest,
},
},
Expand Down Expand Up @@ -144,6 +148,7 @@ func TestDefaultChainList(t *testing.T) {
chains.Ethereum,
chains.BitcoinTestnet,
chains.BitcoinSignetTestnet,
chains.BitcoinTestnet4,
chains.Mumbai,
chains.Amoy,
chains.BscTestnet,
Expand Down Expand Up @@ -181,6 +186,7 @@ func TestChainListByGateway(t *testing.T) {
chains.Ethereum,
chains.BitcoinTestnet,
chains.BitcoinSignetTestnet,
chains.BitcoinTestnet4,
chains.Mumbai,
chains.Amoy,
chains.BscTestnet,
Expand Down Expand Up @@ -224,6 +230,7 @@ func TestExternalChainList(t *testing.T) {
chains.Ethereum,
chains.BitcoinTestnet,
chains.BitcoinSignetTestnet,
chains.BitcoinTestnet4,
chains.Mumbai,
chains.Amoy,
chains.BscTestnet,
Expand Down
2 changes: 0 additions & 2 deletions proto/zetachain/zetacore/pkg/chains/chains.proto
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ enum ChainName {
solana_mainnet = 21;
solana_devnet = 22;
solana_localnet = 23;

btc_signet_testnet = 24;
}

// Network represents the network of the chain
Expand Down
5 changes: 0 additions & 5 deletions typescript/zetachain/zetacore/pkg/chains/chains_pb.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,6 @@ export declare enum ChainName {
* @generated from enum value: solana_localnet = 23;
*/
solana_localnet = 23,

/**
* @generated from enum value: btc_signet_testnet = 24;
*/
btc_signet_testnet = 24,
}

/**
Expand Down
2 changes: 1 addition & 1 deletion zetaclient/config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ type BTCConfig struct {
RPCUsername string `mask:"filled"`
RPCPassword string `mask:"filled"`
RPCHost string `mask:"filled"`
RPCParams string // "regtest", "mainnet", "testnet3" , "signet"
RPCParams string // "regtest", "mainnet", "testnet3" , "signet", "testnet4"
RPCAlertLatency int64
}

Expand Down

0 comments on commit 2892114

Please sign in to comment.