Skip to content

Commit

Permalink
Merge branch 'develop' into ci-add-local-development-testing-node-syn…
Browse files Browse the repository at this point in the history
…c-docker-compose
  • Loading branch information
gzukel authored May 1, 2024
2 parents e82a7d7 + 0e91dcf commit b87ecd3
Show file tree
Hide file tree
Showing 135 changed files with 3,368 additions and 1,911 deletions.
40 changes: 22 additions & 18 deletions Dockerfile-upgrade
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.20-alpine3.18
FROM golang:1.20-alpine3.18 as base

# Purpose: This Dockerfile creates an environment for performing an upgrade test on ZetaChain
# It contains the ZetaChain and ZetaClient binaries for two different versions of ZetaChain
Expand All @@ -8,6 +8,7 @@ FROM golang:1.20-alpine3.18
ENV GOPATH /go
ENV GOOS=linux
ENV CGO_ENABLED=1
ENV GOCACHE=/root/.cache/go-build

RUN apk --no-cache add git make build-base jq openssh libusb-dev linux-headers bash curl tmux
RUN ssh-keygen -b 2048 -t rsa -f /root/.ssh/localtest.pem -q -N ""
Expand All @@ -20,32 +21,35 @@ WORKDIR /go/delivery/zeta-node
RUN mkdir -p $GOPATH/bin/old
RUN mkdir -p $GOPATH/bin/new

ARG OLD_VERSION=v14.0.0
ENV NEW_VERSION=v15

# Build new release from the current source
COPY go.mod /go/delivery/zeta-node/
COPY go.sum /go/delivery/zeta-node/
RUN cd /go/delivery/zeta-node/ && go mod download
COPY . /go/delivery/zeta-node/
RUN cd /go/delivery/zeta-node/ && make install
RUN cd /go/delivery/zeta-node/ && make install-zetae2e
RUN cp $GOPATH/bin/zetacored $GOPATH/bin/new/
RUN cp $GOPATH/bin/zetaclientd $GOPATH/bin/new/
RUN ssh-keygen -A
RUN cp /root/.ssh/localtest.pem.pub /root/.ssh/authorized_keys

# Checkout and build old binary
FROM base as oldbuild
ARG OLD_VERSION
RUN git clone https://github.com/zeta-chain/node.git
RUN cd node && git fetch

RUN cd node && git checkout ${OLD_VERSION}
RUN cd node && make install
RUN cp $GOPATH/bin/zetacored $GOPATH/bin/old/
RUN cp $GOPATH/bin/zetaclientd $GOPATH/bin/old/

RUN ssh-keygen -A
WORKDIR /root
# Build new release from the current source
FROM base
ARG NEW_VERSION
ENV NEW_VERSION=${NEW_VERSION}
COPY go.mod /go/delivery/zeta-node/
COPY go.sum /go/delivery/zeta-node/
RUN cd /go/delivery/zeta-node/ && go mod download
COPY . /go/delivery/zeta-node/
RUN --mount=type=cache,target="/root/.cache/go-build" cd /go/delivery/zeta-node/ && make install
RUN --mount=type=cache,target="/root/.cache/go-build" cd /go/delivery/zeta-node/ && make install-zetae2e
RUN cp $GOPATH/bin/zetacored $GOPATH/bin/new/ && \
cp $GOPATH/bin/zetaclientd $GOPATH/bin/new/

RUN cp /root/.ssh/localtest.pem.pub /root/.ssh/authorized_keys
COPY --from=oldbuild $GOPATH/bin/zetacored $GOPATH/bin/zetaclientd $GOPATH/bin/
COPY --from=oldbuild $GOPATH/bin/zetacored $GOPATH/bin/zetaclientd $GOPATH/bin/old

WORKDIR /root

RUN cp /go/bin/zetaclientd /usr/local/bin
RUN cp /go/bin/zetacored /usr/local/bin
Expand Down
14 changes: 8 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -214,16 +214,18 @@ start-stress-test: zetanode
@echo "--> Starting stress test"
cd contrib/localnet/ && $(DOCKER) compose -f docker-compose.yml -f docker-compose-stresstest.yml up -d

start-upgrade-test:
@echo "--> Starting upgrade test"
$(DOCKER) build -t zetanode -f ./Dockerfile-upgrade .
zetanode-upgrade:
@echo "Building zetanode-upgrade"
$(DOCKER) build -t zetanode -f ./Dockerfile-upgrade --build-arg OLD_VERSION=v14.0.0 --build-arg NEW_VERSION=v15 .
$(DOCKER) build -t orchestrator -f contrib/localnet/orchestrator/Dockerfile.fastbuild .
.PHONY: zetanode-upgrade

start-upgrade-test: zetanode-upgrade
@echo "--> Starting upgrade test"
cd contrib/localnet/ && $(DOCKER) compose -f docker-compose.yml -f docker-compose-upgrade.yml up -d

start-upgrade-test-light:
start-upgrade-test-light: zetanode-upgrade
@echo "--> Starting light upgrade test (no ZetaChain state populating before upgrade)"
$(DOCKER) build -t zetanode -f ./Dockerfile-upgrade .
$(DOCKER) build -t orchestrator -f contrib/localnet/orchestrator/Dockerfile.fastbuild .
cd contrib/localnet/ && $(DOCKER) compose -f docker-compose.yml -f docker-compose-upgrade-light.yml up -d

start-localnet: zetanode
Expand Down
13 changes: 10 additions & 3 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# CHANGELOG

## Unreleased

### Refactor

* [2032](https://github.com/zeta-chain/node/pull/2032) - improve some general structure of the ZetaClient codebase

## Unreleased
### Breaking Changes

Expand Down Expand Up @@ -44,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 @@ -88,11 +95,12 @@

* [1861](https://github.com/zeta-chain/node/pull/1861) - fix `ObserverSlashAmount` invalid read
* [1880](https://github.com/zeta-chain/node/issues/1880) - lower the gas price multiplier for EVM chains.
* [1883](https://github.com/zeta-chain/node/issues/1883) - zetaclient should check 'IsSupported' flag to pause/unpause a specific chain
* [1883](https://github.com/zeta-chain/node/issues/1883) - zetaclient should check `IsSupported` flag to pause/unpause a specific chain
* [1633](https://github.com/zeta-chain/node/issues/1633) - zetaclient should be able to pick up new connector and erc20Custody addresses
* [1944](https://github.com/zeta-chain/node/pull/1944) - fix evm signer unit tests
* [1888](https://github.com/zeta-chain/node/issues/1888) - zetaclient should stop inbound/outbound txs according to cross-chain flags
* [1970](https://github.com/zeta-chain/node/issues/1970) - remove the timeout in the evm outtx tracker processing thread
* [1484](https://github.com/zeta-chain/node/issues/1484) - replaced hard-coded `MaxLookaheadNonce` with a default lookback factor

### Chores

Expand All @@ -112,8 +120,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
4 changes: 2 additions & 2 deletions contrib/localnet/scripts/start-zetacored.sh
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,8 @@ else
sleep 7
/root/.zetacored/cosmovisor/genesis/bin/zetacored query gov proposal 1

# We use tail -f to keep the container running
tail -f zetanode.log
# We use tail -f to keep the container running. Use -n999999 to ensure we get all the context.
tail -n999999 -f zetanode.log

fi

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

0 comments on commit b87ecd3

Please sign in to comment.