Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: add chain static info to chain struct #2071

Merged
merged 19 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
* [1989](https://github.com/zeta-chain/node/pull/1989) - simplify `IsSendOutTxProcessed` method and add unit tests
* [2013](https://github.com/zeta-chain/node/pull/2013) - rename `GasPriceVoter` message to `VoteGasPrice`
* [2059](https://github.com/zeta-chain/node/pull/2059) - Remove unused params from all functions in zetanode
* [2071](https://github.com/zeta-chain/node/pull/2071) - Modify chains struct to add all chain related information

### Features

Expand Down Expand Up @@ -117,8 +118,7 @@
## Version: v15.0.0

### Features

*[1912](https://github.com/zeta-chain/node/pull/1912) - add reset chain nonces msg
* [1912](https://github.com/zeta-chain/node/pull/1912) - add reset chain nonces msg

## Version: v14.0.1

Expand Down
6 changes: 3 additions & 3 deletions cmd/zetaclientd/keygen_tss.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func GenerateTss(
// Bitcoin chain ID is currently used for using the correct signature format
// TODO: remove this once we have a better way to determine the signature format
// https://github.com/zeta-chain/node/issues/1397
bitcoinChainID := chains.BtcRegtestChain().ChainId
bitcoinChainID := chains.BtcRegtestChain.ChainId
btcChain, _, btcEnabled := appContext.GetBTCChainAndConfig()
if btcEnabled {
bitcoinChainID = btcChain.ChainId
Expand Down Expand Up @@ -109,7 +109,7 @@ func GenerateTss(
err = keygenTss(keyGen, tss, keygenLogger)
if err != nil {
keygenLogger.Error().Err(err).Msg("keygenTss error")
tssFailedVoteHash, err := zetaBridge.SetTSS("", keyGen.BlockNumber, chains.ReceiveStatus_Failed)
tssFailedVoteHash, err := zetaBridge.SetTSS("", keyGen.BlockNumber, chains.ReceiveStatus_failed)
if err != nil {
keygenLogger.Error().Err(err).Msg("Failed to broadcast Failed TSS Vote to zetacore")
return nil, err
Expand All @@ -127,7 +127,7 @@ func GenerateTss(
}

// If TSS is successful , broadcast the vote to zetacore and set Pubkey
tssSuccessVoteHash, err := zetaBridge.SetTSS(newTss.CurrentPubkey, keyGen.BlockNumber, chains.ReceiveStatus_Success)
tssSuccessVoteHash, err := zetaBridge.SetTSS(newTss.CurrentPubkey, keyGen.BlockNumber, chains.ReceiveStatus_success)
if err != nil {
keygenLogger.Error().Err(err).Msg("TSS successful but unable to broadcast vote to zeta-core")
return nil, err
Expand Down
1 change: 0 additions & 1 deletion cmd/zetacored/parsers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ func TestParsefileToObserverMapper(t *testing.T) {

func createObserverList(fp string) {
var listReader []ObserverInfoReader
//listChainID := []int64{common.GoerliLocalNetChain().ChainId, common.BtcRegtestChain().ChainId, common.ZetaChain().ChainId}
commonGrantAddress := sdk.AccAddress(crypto.AddressHash([]byte("ObserverGranteeAddress")))
observerAddress := sdk.AccAddress(crypto.AddressHash([]byte("ObserverAddress")))
validatorAddress := sdk.ValAddress(crypto.AddressHash([]byte("ValidatorAddress")))
Expand Down
57 changes: 52 additions & 5 deletions docs/openapi/openapi.swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53592,6 +53592,18 @@ definitions:
chain_id:
type: string
format: int64
network:
$ref: '#/definitions/chainsNetwork'
network_type:
$ref: '#/definitions/chainsNetworkType'
vm:
$ref: '#/definitions/chainsVm'
consensus:
$ref: '#/definitions/chainsConsensus'
is_external:
type: boolean
is_header_supported:
type: boolean
chainsChainName:
type: string
enum:
Expand All @@ -53613,14 +53625,49 @@ definitions:
- btc_regtest
- amoy_testnet
default: empty
title: ChainName represents the name of the chain
chainsConsensus:
type: string
enum:
- ethereum
- tendermint
- bitcoin
default: ethereum
title: Consensus represents the consensus algorithm used by the chain
chainsNetwork:
type: string
enum:
- eth
- zeta
- btc
- polygon
- bsc
default: eth
title: Network represents the network type of the chain
chainsNetworkType:
type: string
enum:
- mainnet
- testnet
- privnet
- devnet
default: mainnet
title: NetworkType represents the network type of the chain
chainsReceiveStatus:
type: string
enum:
- Created
- Success
- Failed
default: Created
title: '- Created: some observer sees inbound tx'
- created
- success
- failed
default: created
title: '- created: some observer sees inbound tx'
chainsVm:
type: string
enum:
- no_vm
- evm
default: no_vm
title: Vm represents the virtual machine type of the chain to support smart contracts
coinCoinType:
type: string
enum:
Expand Down
8 changes: 4 additions & 4 deletions e2e/e2etests/test_bitcoin_withdraw.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,12 @@ func parseBitcoinWithdrawArgs(args []string, defaultReceiver string) (btcutil.Ad
var receiver btcutil.Address
if args[0] == "" {
// use the default receiver
receiver, err = chains.DecodeBtcAddress(defaultReceiver, chains.BtcRegtestChain().ChainId)
receiver, err = chains.DecodeBtcAddress(defaultReceiver, chains.BtcRegtestChain.ChainId)
if err != nil {
panic("Invalid default receiver address specified for TestBitcoinWithdraw.")
}
} else {
receiver, err = chains.DecodeBtcAddress(args[0], chains.BtcRegtestChain().ChainId)
receiver, err = chains.DecodeBtcAddress(args[0], chains.BtcRegtestChain.ChainId)
if err != nil {
panic("Invalid receiver address specified for TestBitcoinWithdraw.")
}
Expand Down Expand Up @@ -224,7 +224,7 @@ func withdrawBTCZRC20(r *runner.E2ERunner, to btcutil.Address, amount *big.Int)

func withdrawBitcoinRestricted(r *runner.E2ERunner, amount *big.Int) {
// use restricted BTC P2WPKH address
addressRestricted, err := chains.DecodeBtcAddress(testutils.RestrictedBtcAddressTest, chains.BtcRegtestChain().ChainId)
addressRestricted, err := chains.DecodeBtcAddress(testutils.RestrictedBtcAddressTest, chains.BtcRegtestChain.ChainId)
if err != nil {
panic(err)
}
Expand All @@ -246,7 +246,7 @@ func withdrawBitcoinRestricted(r *runner.E2ERunner, amount *big.Int) {
// amount := big.NewInt(int64(0.1 * 1e8 / float64(repeat)))
//
// // check if the deposit is successful
// BTCZRC20Addr, err := r.SystemContract.GasCoinZRC20ByChainId(&bind.CallOpts{}, big.NewInt(common.BtcRegtestChain().ChainId))
// BTCZRC20Addr, err := r.SystemContract.GasCoinZRC20ByChainId(&bind.CallOpts{}, big.NewInt(common.BtcRegtestChain.ChainId))
// if err != nil {
// panic(err)
// }
Expand Down
4 changes: 2 additions & 2 deletions e2e/e2etests/test_migrate_chain_support.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const EVM2RPCURL = "http://eth2:8545"

// EVM2ChainID is the chain ID for the additional EVM localnet
// We set Sepolia testnet although the value is not important, only used to differentiate
var EVM2ChainID = chains.SepoliaChain().ChainId
var EVM2ChainID = chains.SepoliaChain.ChainId

func TestMigrateChainSupport(r *runner.E2ERunner, _ []string) {
// deposit most of the ZETA supply on ZetaChain
Expand Down Expand Up @@ -170,7 +170,7 @@ func TestMigrateChainSupport(r *runner.E2ERunner, _ []string) {
res, err := newRunner.ZetaTxServer.BroadcastTx(utils.FungibleAdminName, crosschaintypes.NewMsgWhitelistERC20(
adminAddr,
newRunner.ERC20Addr.Hex(),
chains.SepoliaChain().ChainId,
chains.SepoliaChain.ChainId,
"USDT",
"USDT",
18,
Expand Down
2 changes: 1 addition & 1 deletion e2e/e2etests/test_zeta_withdraw.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func TestZetaWithdrawBTCRevert(r *runner.E2ERunner, args []string) {

lessThanAmount := amount.Div(amount, big.NewInt(10)) // 1/10 of amount
tx, err = r.ConnectorZEVM.Send(r.ZEVMAuth, connectorzevm.ZetaInterfacesSendInput{
DestinationChainId: big.NewInt(chains.BtcRegtestChain().ChainId),
DestinationChainId: big.NewInt(chains.BtcRegtestChain.ChainId),
DestinationAddress: r.DeployerAddress.Bytes(),
DestinationGasLimit: big.NewInt(400_000),
Message: nil,
Expand Down
2 changes: 1 addition & 1 deletion e2e/runner/bitcoin.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ func (runner *E2ERunner) ProveBTCTransaction(txHash *chainhash.Hash) {

// verify merkle proof through RPC
res, err := runner.LightclientClient.Prove(runner.Ctx, &lightclienttypes.QueryProveRequest{
ChainId: chains.BtcRegtestChain().ChainId,
ChainId: chains.BtcRegtestChain.ChainId,
TxHash: txHash.String(),
BlockHash: blockHash.String(),
Proof: proofs.NewBitcoinProof(txBytes, path, index),
Expand Down
2 changes: 1 addition & 1 deletion e2e/runner/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ func (runner *E2ERunner) ProveEthTransaction(receipt *ethtypes.Receipt) {
TxIndex: int64(txIndex),
TxHash: txHash.Hex(),
Proof: proofs.NewEthereumProof(txProof),
ChainId: chains.GoerliLocalnetChain().ChainId,
ChainId: chains.GoerliLocalnetChain.ChainId,
})
if err != nil {
panic(err)
Expand Down
4 changes: 2 additions & 2 deletions e2e/runner/setup_zeta.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func (runner *E2ERunner) SetZEVMContracts() {

// SetupETHZRC20 sets up the ETH ZRC20 in the runner from the values queried from the chain
func (runner *E2ERunner) SetupETHZRC20() {
ethZRC20Addr, err := runner.SystemContract.GasCoinZRC20ByChainId(&bind.CallOpts{}, big.NewInt(chains.GoerliLocalnetChain().ChainId))
ethZRC20Addr, err := runner.SystemContract.GasCoinZRC20ByChainId(&bind.CallOpts{}, big.NewInt(chains.GoerliLocalnetChain.ChainId))
if err != nil {
panic(err)
}
Expand All @@ -201,7 +201,7 @@ func (runner *E2ERunner) SetupETHZRC20() {

// SetupBTCZRC20 sets up the BTC ZRC20 in the runner from the values queried from the chain
func (runner *E2ERunner) SetupBTCZRC20() {
BTCZRC20Addr, err := runner.SystemContract.GasCoinZRC20ByChainId(&bind.CallOpts{}, big.NewInt(chains.BtcRegtestChain().ChainId))
BTCZRC20Addr, err := runner.SystemContract.GasCoinZRC20ByChainId(&bind.CallOpts{}, big.NewInt(chains.BtcRegtestChain.ChainId))
if err != nil {
panic(err)
}
Expand Down
6 changes: 3 additions & 3 deletions e2e/txserver/zeta_tx_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ func (zts ZetaTxServer) DeploySystemContractsAndZRC20(account, erc20Addr string)
_, err = zts.BroadcastTx(account, fungibletypes.NewMsgDeployFungibleCoinZRC20(
addr.String(),
"",
chains.GoerliLocalnetChain().ChainId,
chains.GoerliLocalnetChain.ChainId,
18,
"ETH",
"gETH",
Expand All @@ -342,7 +342,7 @@ func (zts ZetaTxServer) DeploySystemContractsAndZRC20(account, erc20Addr string)
_, err = zts.BroadcastTx(account, fungibletypes.NewMsgDeployFungibleCoinZRC20(
addr.String(),
"",
chains.BtcRegtestChain().ChainId,
chains.BtcRegtestChain.ChainId,
8,
"BTC",
"tBTC",
Expand All @@ -357,7 +357,7 @@ func (zts ZetaTxServer) DeploySystemContractsAndZRC20(account, erc20Addr string)
res, err = zts.BroadcastTx(account, fungibletypes.NewMsgDeployFungibleCoinZRC20(
addr.String(),
erc20Addr,
chains.GoerliLocalnetChain().ChainId,
chains.GoerliLocalnetChain.ChainId,
6,
"USDT",
"USDT",
Expand Down
Loading
Loading