Skip to content

Commit

Permalink
conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
lumtis committed Mar 15, 2024
2 parents 7dfb5b8 + 0361a91 commit 891d0e4
Show file tree
Hide file tree
Showing 258 changed files with 7,477 additions and 2,685 deletions.
15 changes: 12 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ WORKDIR /go/delivery/zeta-node
# Copy module files and download dependencies
COPY go.mod .
COPY go.sum .

RUN go mod download

# Copy the rest of the source code and build the application
Expand All @@ -24,15 +25,23 @@ RUN make install
# Run Stage
FROM alpine:3.18

ENV COSMOVISOR_CHECKSUM="626dfc58c266b85f84a7ed8e2fe0e2346c15be98cfb9f9b88576ba899ed78cdc"
ENV COSMOVISOR_VERSION="v1.5.0"
# Copy Start Script Helpers
COPY contrib/docker-scripts/* /scripts/

# Install runtime dependencies
RUN apk --no-cache add git jq bash curl python3 libusb-dev linux-headers make build-base wget py3-pip qemu-img qemu-system-x86_64 && \
RUN apk --no-cache add git jq bash curl nano vim tmux python3 libusb-dev linux-headers make build-base bind-tools psmisc coreutils wget py3-pip qemu-img qemu-system-x86_64 && \
pip install requests && \
chmod a+x -R /scripts && \
wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.31-r0/glibc-2.31-r0.apk && \
apk add --force-overwrite --allow-untrusted glibc-2.31-r0.apk
apk add --force-overwrite --allow-untrusted glibc-2.31-r0.apk && \
curl https://dl.google.com/dl/cloudsdk/release/google-cloud-sdk.tar.gz > /tmp/google-cloud-sdk.tar.gz && \
mkdir -p /usr/local/gcloud && \
tar -C /usr/local/gcloud -xvf /tmp/google-cloud-sdk.tar.gz && \
/usr/local/gcloud/google-cloud-sdk/install.sh --quiet && \
ln -s /usr/local/gcloud/google-cloud-sdk/bin/gcloud /usr/bin/gcloud && \
python /scripts/install_cosmovisor.py

# Copy the binaries from the build stage
COPY --from=builder /go/bin/zetaclientd /usr/local/bin/zetaclientd
Expand All @@ -50,4 +59,4 @@ EXPOSE 8545
EXPOSE 8546
EXPOSE 9090
EXPOSE 26657
EXPOSE 9091
EXPOSE 9091
4 changes: 2 additions & 2 deletions Dockerfile-upgrade
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ WORKDIR /go/delivery/zeta-node
RUN mkdir -p $GOPATH/bin/old
RUN mkdir -p $GOPATH/bin/new

ARG OLD_VERSION=v13.0.0
ENV NEW_VERSION=v14
ARG OLD_VERSION=v14.0.0
ENV NEW_VERSION=v15

# Build new release from the current source
COPY go.mod /go/delivery/zeta-node/
Expand Down
34 changes: 21 additions & 13 deletions LOCAL_TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,26 @@ $ make zetanode

This Makefile rule builds the zetanode image. **Rebuild if zetacored/zetaclientd code is updated**.
```bash
# in zeta-node/
$ docker build -t zetanode .
```

### Run e2e tests

Now we have built all the docker images, we can run the e2e test with make command:
```bash
# in zeta-node/
make start-e2e-test
```

#### Run admin functions e2e tests

We define e2e tests allowing to test admin functionalities (emergency network pause for example).
Since these tests interact with the network functionalities, these can't be run concurrently with the regular e2e tests.
Moreover, these tests test scoped functionalities of the protocol, and won't be tested in the same pipeline as the regular e2e tests.
Therefore, we provide a separate command to run e2e admin functions tests:
```bash
make start-e2e-admin-test
```

### Run upgrade tests

Upgrade tests run the E2E tests with an older version, upgrade the nodes to the new version, and run the E2E tests again.
Expand All @@ -46,18 +54,22 @@ NOTE: We only specify the major version for `NEW_VERSION` since we use major ver

The upgrade tests can be run with the following command:
```bash
# in zeta-node/
make start-upgrade-test
```

The test the upgrade script faster a light version of the upgrade test can be run with the following command:
```bash
make start-upgrade-test-light
```
This command will run the upgrade test with a lower height and will not populate the state.

### Run stress tests

Stress tests run the E2E tests with a larger number of nodes and clients to test the performance of the network.
It also stresses the network by sending a large number of cross-chain transactions.

The stress tests can be run with the following command:
```bash
# in zeta-node/
make start-stress-test
```

Expand All @@ -68,15 +80,14 @@ If everything works fine, it should finish without panic.

The logs can be observed with the following command:
```bash
# in zeta-node/contrib/localnet/orchestrator
# in node/contrib/localnet/orchestrator
$ docker logs -f orchestrator
```

### Stop tests

To stop the tests,
```bash
# in zeta-node/
make stop-test
```

Expand All @@ -86,7 +97,6 @@ Before starting the monitoring setup, make sure the Zetacore API is up at http:/
You can also add any additional ETH addresses to monitor in `zeta-node/contrib/localnet/grafana/addresses.txt` file

```bash
# in zeta-node/
make start-monitoring
```

Expand All @@ -97,7 +107,6 @@ The Grafana default credentials are admin:admin. The dashboards are located at h
### Stop monitoring setup

```bash
# in zeta-node/
make stop-monitoring
```

Expand All @@ -108,7 +117,6 @@ In addition to running automated tests, you can also interact with the localnet
The localnet can be started without running tests with the following command:

```bash
# in zeta-node/
make start-localnet
```

Expand Down Expand Up @@ -193,8 +201,8 @@ type E2ETestFunc func(*E2ERunner)
The test can interact with the different networks using the runned object:
```go
type E2ERunner struct {
ZevmClient *ethclient.Client
GoerliClient *ethclient.Client
ZEVMClient *ethclient.Client
EVMClient *ethclient.Client
BtcRPCClient *rpcclient.Client

CctxClient crosschaintypes.QueryClient
Expand All @@ -204,8 +212,8 @@ type E2ERunner struct {
ObserverClient observertypes.QueryClient
ZetaTxServer txserver.ZetaTxServer

GoerliAuth *bind.TransactOpts
ZevmAuth *bind.TransactOpts
EVMAuth *bind.TransactOpts
ZEVMAuth *bind.TransactOpts

// ...
}
Expand Down
21 changes: 18 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -192,20 +192,35 @@ install-zetae2e: go.sum
@go install -mod=readonly $(BUILD_FLAGS) ./cmd/zetae2e
.PHONY: install-zetae2e

start-e2e-test:
start-e2e-test: zetanode
@echo "--> Starting e2e test"
cd contrib/localnet/ && $(DOCKER) compose up -d

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

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

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 --build-arg -t zetanode -f ./Dockerfile-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.yml up -d

start-localnet:
start-upgrade-test-light:
@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
@echo "--> Starting localnet"
cd contrib/localnet/ && $(DOCKER) compose -f docker-compose.yml -f docker-compose-setup-only.yml up -d

Expand Down
9 changes: 5 additions & 4 deletions app/setup_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/x/upgrade/types"
crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types"
authoritytypes "github.com/zeta-chain/zetacore/x/authority/types"
observertypes "github.com/zeta-chain/zetacore/x/observer/types"
)

const releaseVersion = "v14"
const releaseVersion = "v15"

func SetupHandlers(app *App) {
app.UpgradeKeeper.SetUpgradeHandler(releaseVersion, func(ctx sdk.Context, plan types.Plan, vm module.VersionMap) (module.VersionMap, error) {
Expand All @@ -17,7 +18,7 @@ func SetupHandlers(app *App) {
for m, mb := range app.mm.Modules {
vm[m] = mb.ConsensusVersion()
}
VersionMigrator{v: vm}.TriggerMigration(crosschaintypes.ModuleName)
VersionMigrator{v: vm}.TriggerMigration(observertypes.ModuleName)

return app.mm.RunMigrations(ctx, app.configurator, vm)
})
Expand All @@ -28,7 +29,7 @@ func SetupHandlers(app *App) {
}
if upgradeInfo.Name == releaseVersion && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
storeUpgrades := storetypes.StoreUpgrades{
// Added: []string{},
Added: []string{authoritytypes.ModuleName},
}
// Use upgrade store loader for the initial loading of all stores when app starts,
// it checks if version == upgradeHeight and applies store upgrades before loading the stores,
Expand Down
16 changes: 15 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
* [1783](https://github.com/zeta-chain/node/pull/1783) - refactor zetaclient metrics naming and structure
* [1774](https://github.com/zeta-chain/node/pull/1774) - split params and config in zetaclient
* [1831](https://github.com/zeta-chain/node/pull/1831) - removing unnecessary pointers in context structure
* [1864](https://github.com/zeta-chain/node/pull/1864) - prevent panic in param management
* [1848](https://github.com/zeta-chain/node/issues/1848) - create a method to observe deposits to tss address in one evm block
* [1885](https://github.com/zeta-chain/node/pull/1885) - change important metrics on port 8123 to be prometheus compatible
* [1863](https://github.com/zeta-chain/node/pull/1863) - remove duplicate ValidateChainParams function

### Features

Expand All @@ -30,6 +34,11 @@
* [1787](https://github.com/zeta-chain/node/pull/1787) - add unit tests for cross-chain evm hooks and e2e test failed withdraw to BTC legacy address
* [1840](https://github.com/zeta-chain/node/pull/1840) - fix code coverage test failures ignored in CI
* [1870](https://github.com/zeta-chain/node/pull/1870) - enable emissions pool in local e2e testing
* [1868](https://github.com/zeta-chain/node/pull/1868) - run e2e btc tests locally
* [1851](https://github.com/zeta-chain/node/pull/1851) - rename usdt to erc20 in e2e tests
* [1872](https://github.com/zeta-chain/node/pull/1872) - remove usage of RPC in unit test
* [1805](https://github.com/zeta-chain/node/pull/1805) - add admin and performance test and fix upgrade test
* [1879](https://github.com/zeta-chain/node/pull/1879) - full coverage for messages in types packages

### Fixes

Expand All @@ -39,6 +48,12 @@

* [1814](https://github.com/zeta-chain/node/pull/1814) - fix code coverage ignore for protobuf generated files

### CI

* [1867](https://github.com/zeta-chain/node/pull/1867) - default restore_type for full node docker-compose to snapshot instead of statesync for reliability.
* [1891](https://github.com/zeta-chain/node/pull/1891) - fix typo that was introduced to docker-compose and a typo in start.sh for the docker start script for full nodes.
* [1894](https://github.com/zeta-chain/node/pull/1894) - added download binaries and configs to the start sequence so it will download binaries that don't exist

## Version: v14

- [1817](https://github.com/zeta-chain/node/pull/1817) - Add migration script to fix pending and chain nonces on testnet
Expand Down Expand Up @@ -88,7 +103,6 @@
* [1584](https://github.com/zeta-chain/node/pull/1584) - allow to run E2E tests on any networks
* [1746](https://github.com/zeta-chain/node/pull/1746) - rename smoke tests to e2e tests
* [1753](https://github.com/zeta-chain/node/pull/1753) - fix gosec errors on usage of rand package

* [1762](https://github.com/zeta-chain/node/pull/1762) - improve coverage for fungibile module
* [1782](https://github.com/zeta-chain/node/pull/1782) - improve coverage for fungibile module system contract

Expand Down
7 changes: 5 additions & 2 deletions cmd/zetaclientd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,15 @@ func start(_ *cobra.Command, _ []string) error {
}
}

metrics, err := metrics.NewMetrics()
m, err := metrics.NewMetrics()
if err != nil {
log.Error().Err(err).Msg("NewMetrics")
return err
}
metrics.Start()
m.Start()

metrics.Info.WithLabelValues(common.Version).Set(1)
metrics.LastStartTime.SetToCurrentTime()

var tssHistoricalList []observerTypes.TSS
tssHistoricalList, err = zetaBridge.GetTssHistory()
Expand Down
22 changes: 9 additions & 13 deletions cmd/zetae2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,30 +43,28 @@ contracts:
zevm:
system_contract: "0xEdf1c3275d13489aCdC6cD6eD246E72458B8795B"
eth_zrc20: "0x13A0c5930C028511Dc02665E7285134B6d11A5f4"
usdt_zrc20: "0x0cbe0dF132a6c6B4a2974Fa1b7Fb953CF0Cc798a"
erc20_zrc20: "0x0cbe0dF132a6c6B4a2974Fa1b7Fb953CF0Cc798a"
btc_zrc20: "0x65a45c57636f9BcCeD4fe193A602008578BcA90b"
uniswap_factory: "0x9fd96203f7b22bCF72d9DCb40ff98302376cE09c"
uniswap_router: "0x2ca7d64A7EFE2D62A725E2B35Cf7230D6677FfEe"
evm:
zeta_eth: "0x0000c304d2934c00db1d51995b9f6996affd17c0"
connector_eth: "0x00005e3125aba53c5652f9f0ce1a4cf91d8b15ea"
custody: "0x000047f11c6e42293f433c82473532e869ce4ec5"
usdt: "0x07865c6e87b9f70255377e024ace6630c1eaa37f"
erc20: "0x07865c6e87b9f70255377e024ace6630c1eaa37f"
```

### Bitcoin setup
Interaction with the Bitcoin node will require setting up a specific node tracking the address. It can be set locally following the guide [Using Bitcoin Docker Image for Local Development](https://www.notion.so/Using-Bitcoin-Docker-Image-for-Local-Development-bf7e84c58f22431fb52f17a471997e1f?pvs=21)

If an error occurs mention that wallets are not loaded. The following commands might need to be run in the Docker container:
If an error occurs mention that wallets are not loaded, this command can be run to set it up:

```go
docker exec -it <container> bash

bitcoin-cli -testnet -rpcuser=${bitcoin_username} -rpcpassword=${bitcoin_password} -named createwallet wallet_name=${WALLET_NAME} disable_private_keys=false load_on_startup=true
bitcoin-cli -testnet -rpcuser=${bitcoin_username} -rpcpassword=${bitcoin_password} importaddress "${WALLET_ADDRESS}" "${WALLET_NAME}" true
bitcoin-cli -testnet -rpcuser=${bitcoin_username} -rpcpassword=${bitcoin_password} importprivkey "your_private_key" "${WALLET_NAME}" false
zetae2e setup-bitcoin [config]
```

Note: This command is intended for local testing only and won't work on live networks, where a node with an enabled wallet should already be set up.

### Commands

Show the balances of the accounts used on the different networks:
Expand Down Expand Up @@ -126,9 +124,7 @@ contracts:
One of the tests can be commented out in case only a deposit or a withdrawal is to be tested.
Testing an ERC20 ZRC20 from an EVM chain

Testing ZRC20 requires the same config as for the gas tokens, but must include the `usdt` field that contains the address of the ERC20 on the evm chain and `usdt_zrc20` on ZetaChain.

It is currently named USDT because it was the defacto ERC20 tested in local tests, this field will be renamed into a more generic name in the future
Testing ZRC20 requires the same config as for the gas tokens, but must include the `erc20` field that contains the address of the ERC20 on the evm chain and `erc20_zrc20` on ZetaChain.

```go
zeta_chain_id
Expand All @@ -142,9 +138,9 @@ rpcs:
zetacore_rpc
contracts:
zevm:
usdt_zrc20
erc20_zrc20
evm:
usdt
erc20
```

### Testing a ZRC20 from a Bitcoin chain
Expand Down
9 changes: 4 additions & 5 deletions cmd/zetae2e/config/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func getClientsFromConfig(ctx context.Context, conf config.Config, evmPrivKey st
if err != nil {
return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, fmt.Errorf("failed to get btc client: %w", err)
}
goerliClient, goerliAuth, err := getEVMClient(ctx, conf.RPCs.EVM, evmPrivKey)
evmClient, evmAuth, err := getEVMClient(ctx, conf.RPCs.EVM, evmPrivKey)
if err != nil {
return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, fmt.Errorf("failed to get evm client: %w", err)
}
Expand All @@ -48,8 +48,8 @@ func getClientsFromConfig(ctx context.Context, conf config.Config, evmPrivKey st
return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, fmt.Errorf("failed to get zevm client: %w", err)
}
return btcRPCClient,
goerliClient,
goerliAuth,
evmClient,
evmAuth,
cctxClient,
fungibleClient,
authClient,
Expand Down Expand Up @@ -80,12 +80,11 @@ func getBtcClient(rpcConf config.BitcoinRPC) (*rpcclient.Client, error) {
HTTPPostMode: rpcConf.HTTPPostMode,
DisableTLS: rpcConf.DisableTLS,
Params: param,
//Endpoint: "/wallet/user",
}
return rpcclient.New(connCfg, nil)
}

// getEVMClient get goerli client
// getEVMClient get evm client
func getEVMClient(ctx context.Context, rpc, privKey string) (*ethclient.Client, *bind.TransactOpts, error) {
evmClient, err := ethclient.Dial(rpc)
if err != nil {
Expand Down
Loading

0 comments on commit 891d0e4

Please sign in to comment.