Skip to content

Commit

Permalink
Merge branch 'develop' into fix-inbound-index
Browse files Browse the repository at this point in the history
  • Loading branch information
kingpinXD authored Jan 11, 2024
2 parents 5547674 + 361fcaf commit f6ba8ed
Show file tree
Hide file tree
Showing 41 changed files with 1,316 additions and 350 deletions.
16 changes: 10 additions & 6 deletions .github/workflows/publish-typescript.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,20 @@ jobs:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'

- name: Install buf
run: |
curl -sSL https://github.com/bufbuild/buf/releases/download/v1.28.1/buf-Linux-x86_64 -o /usr/local/bin/buf
chmod +x /usr/local/bin/buf
- name: Generate
run: |
make typescript
- name: Set Version
working-directory: typescript
run: |
version=$(cat app/setup_handlers.go | grep "const releaseVersion" | cut -d ' ' -f4 | tr -d '"')
version=$(cat ../app/setup_handlers.go | grep "const releaseVersion" | cut -d ' ' -f4 | tr -d '"')
npm version ${version}
sed -i 's/@zetachain\/blockchain-types/@zetachain\/node-types/' package.json
- name: Install dependencies and build 🔧
working-directory: typescript
run: npm ci && npm run build
- name: Publish package on NPM 📦
run: npm publish
Expand Down
5 changes: 1 addition & 4 deletions Dockerfile-versioned
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.19-alpine
FROM golang:1.20-alpine3.18

ENV GOPATH /go
ENV GOOS=linux
Expand Down Expand Up @@ -38,10 +38,7 @@ RUN cp $GOPATH/bin/smoketest $GOPATH/bin/old/
RUN git clone https://github.com/zeta-chain/cosmos-sdk.git
RUN cd cosmos-sdk && git checkout zetavisor-v0.1.5
RUN cd cosmos-sdk/cosmovisor && make zetavisor
#
#FROM golang:1.19-alpine

#RUN apk --no-cache add openssh jq tmux vim curl bash
RUN ssh-keygen -A
WORKDIR /root

Expand Down
23 changes: 8 additions & 15 deletions Dockerfile-versioned-source
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.19-alpine
FROM golang:1.20-alpine3.18

ENV GOPATH /go
ENV GOOS=linux
Expand All @@ -9,51 +9,44 @@ ARG old_version
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 ""

# Build cosmovisor
RUN go install cosmossdk.io/tools/cosmovisor/cmd/[email protected]

WORKDIR /go/delivery/zeta-node

RUN mkdir -p $GOPATH/bin/old
RUN mkdir -p $GOPATH/bin/new

ENV NEW_VERSION=v42.0.0
ENV NEW_VERSION=v12.0.0

# 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-smoketest
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 cp $GOPATH/bin/smoketest $GOPATH/bin/new/

# Checkout and build old binary
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 cd node && make install-smoketest
RUN cp $GOPATH/bin/zetacored $GOPATH/bin/old/
RUN cp $GOPATH/bin/zetaclientd $GOPATH/bin/old/
RUN cp $GOPATH/bin/smoketest $GOPATH/bin/old/

RUN git clone https://github.com/zeta-chain/cosmos-sdk.git
RUN cd cosmos-sdk && git checkout zetavisor-v0.1.5
RUN cd cosmos-sdk/cosmovisor && make zetavisor
#
#FROM golang:1.19-alpine

#RUN apk --no-cache add openssh jq tmux vim curl bash
RUN ssh-keygen -A
WORKDIR /root

RUN cp /root/.ssh/localtest.pem.pub /root/.ssh/authorized_keys

RUN cp /go/bin/zetaclientd /usr/local/bin
RUN cp /go/bin/zetacored /usr/local/bin
RUN cp /go/bin/smoketest /usr/local/bin
RUN cp /go/bin/zetavisor /usr/local/bin
RUN cp /go/bin/zetae2e /usr/local/bin
RUN cp /go/bin/cosmovisor /usr/local/bin

COPY contrib/localnet/scripts /root
COPY contrib/localnet/preparams /root/preparams
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ stateful-upgrade:

stateful-upgrade-source:
@echo "--> Starting stateful smoketest"
$(DOCKER) build --build-arg old_version=v10.1.7 -t zetanode -f ./Dockerfile-versioned-source .
$(DOCKER) build --build-arg old_version=v11.0.0-patch-core-params -t zetanode -f ./Dockerfile-versioned-source .
$(DOCKER) build -t orchestrator -f contrib/localnet/orchestrator/Dockerfile-upgrade.fastbuild .
cd contrib/localnet/ && $(DOCKER) compose -f docker-compose-stateful.yml up -d

Expand Down
2 changes: 1 addition & 1 deletion app/setup_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
observertypes "github.com/zeta-chain/zetacore/x/observer/types"
)

const releaseVersion = "v11.0.0"
const releaseVersion = "v12.0.0"

func SetupHandlers(app *App) {
app.UpgradeKeeper.SetUpgradeHandler(releaseVersion, func(ctx sdk.Context, plan types.Plan, vm module.VersionMap) (module.VersionMap, error) {
Expand Down
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

### Fixes

* [1516](https://github.com/zeta-chain/node/issues/1516) - Unprivileged outtx tracker removal
* [1537](https://github.com/zeta-chain/node/issues/1537) - Sanity check events of ZetaSent/ZetaReceived/ZetaRevertedWithdrawn/Deposited
* [1530](https://github.com/zeta-chain/node/pull/1530) - Outbound tx confirmation/inclusion enhancement
* [1496](https://github.com/zeta-chain/node/issues/1496) - post block header for enabled EVM chains only
* [1518](https://github.com/zeta-chain/node/pull/1518) - Avoid duplicate keysign if an outTx is already pending
Expand Down Expand Up @@ -51,6 +53,7 @@
* Remove chain id from the index for observer mapper and rename it to observer set.
* Add logger to smoke tests
* [1521](https://github.com/zeta-chain/node/pull/1521) - replace go-tss lib version with one that reverts back to thorchain tss-lib
* Update --ledger flag hint

### Chores
* [1446](https://github.com/zeta-chain/node/pull/1446) - renamed file `zetaclientd/aux.go` to `zetaclientd/utils.go` to avoid complaints from go package resolver.
Expand All @@ -60,6 +63,8 @@

### Tests

* [1538](https://github.com/zeta-chain/node/pull/1538) - improve stateful e2e testing

### CI
* Removed private runners and unused GitHub Action

Expand Down
6 changes: 3 additions & 3 deletions cmd/zetaclientd/start_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,18 @@ func validatePeer(seedPeer string) error {
parsedPeer := strings.Split(seedPeer, "/")

if len(parsedPeer) < 7 {
return errors.New("seed peer missing IP or ID")
return errors.New("seed peer missing IP or ID or both, seed: " + seedPeer)
}

seedIP := parsedPeer[2]
seedID := parsedPeer[6]

if net.ParseIP(seedIP) == nil {
return errors.New("invalid seed IP address")
return errors.New("invalid seed IP address format, seed: " + seedPeer)
}

if len(seedID) == 0 {
return errors.New("seed id is empty")
return errors.New("seed id is empty, seed: " + seedPeer)
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion cmd/zetacored/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func processError(err error) {
if strings.Contains(err.Error(), "cannot set custom bip32 path with ledger") {
printNotice([]string{
"note: --ledger flag can't be used with Ethereum HD path (used by default)",
"use --hd-path=\"\" in the command to use Cosmos HD path",
"Please set a blank path with --hd-path=\"\" to use Cosmos HD path instead.",
})
os.Exit(1)
}
Expand Down
21 changes: 21 additions & 0 deletions cmd/zetae2e/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,24 @@ func RunnerFromConfig(

return sm, err
}

// ExportContractsFromRunner export contracts from the runner to config using a source config
func ExportContractsFromRunner(sm *runner.SmokeTestRunner, conf config.Config) config.Config {
// copy contracts from deployer runner
conf.Contracts.EVM.ZetaEthAddress = sm.ZetaEthAddr.Hex()
conf.Contracts.EVM.ConnectorEthAddr = sm.ConnectorEthAddr.Hex()
conf.Contracts.EVM.CustodyAddr = sm.ERC20CustodyAddr.Hex()
conf.Contracts.EVM.USDT = sm.USDTERC20Addr.Hex()

conf.Contracts.ZEVM.SystemContractAddr = sm.SystemContractAddr.Hex()
conf.Contracts.ZEVM.ETHZRC20Addr = sm.ETHZRC20Addr.Hex()
conf.Contracts.ZEVM.USDTZRC20Addr = sm.USDTZRC20Addr.Hex()
conf.Contracts.ZEVM.BTCZRC20Addr = sm.BTCZRC20Addr.Hex()
conf.Contracts.ZEVM.UniswapFactoryAddr = sm.UniswapV2FactoryAddr.Hex()
conf.Contracts.ZEVM.UniswapRouterAddr = sm.UniswapV2RouterAddr.Hex()
conf.Contracts.ZEVM.ZEVMSwapAppAddr = sm.ZEVMSwapAppAddr.Hex()
conf.Contracts.ZEVM.ContextAppAddr = sm.ContextAppAddr.Hex()
conf.Contracts.ZEVM.TestDappAddr = sm.TestDAppAddr.Hex()

return conf
}
28 changes: 28 additions & 0 deletions cmd/zetae2e/config/contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ import (
"github.com/zeta-chain/protocol-contracts/pkg/uniswap/v2-core/contracts/uniswapv2factory.sol"
uniswapv2router "github.com/zeta-chain/protocol-contracts/pkg/uniswap/v2-periphery/contracts/uniswapv2router02.sol"
"github.com/zeta-chain/zetacore/contrib/localnet/orchestrator/smoketest/config"
"github.com/zeta-chain/zetacore/contrib/localnet/orchestrator/smoketest/contracts/contextapp"
"github.com/zeta-chain/zetacore/contrib/localnet/orchestrator/smoketest/contracts/erc20"
"github.com/zeta-chain/zetacore/contrib/localnet/orchestrator/smoketest/contracts/zevmswap"
"github.com/zeta-chain/zetacore/contrib/localnet/orchestrator/smoketest/runner"
)

Expand Down Expand Up @@ -133,6 +135,32 @@ func setContractsFromConfig(r *runner.SmokeTestRunner, conf config.Config) error
return err
}
}
if c := conf.Contracts.ZEVM.ZEVMSwapAppAddr; c != "" {
if !ethcommon.IsHexAddress(c) {
return fmt.Errorf("invalid ZEVMSwapAppAddr: %s", c)
}
r.ZEVMSwapAppAddr = ethcommon.HexToAddress(c)
r.ZEVMSwapApp, err = zevmswap.NewZEVMSwapApp(r.ZEVMSwapAppAddr, r.ZevmClient)
if err != nil {
return err
}
}
if c := conf.Contracts.ZEVM.ContextAppAddr; c != "" {
if !ethcommon.IsHexAddress(c) {
return fmt.Errorf("invalid ContextAppAddr: %s", c)
}
r.ContextAppAddr = ethcommon.HexToAddress(c)
r.ContextApp, err = contextapp.NewContextApp(r.ContextAppAddr, r.ZevmClient)
if err != nil {
return err
}
}
if c := conf.Contracts.ZEVM.TestDappAddr; c != "" {
if !ethcommon.IsHexAddress(c) {
return fmt.Errorf("invalid TestDappAddr: %s", c)
}
r.TestDAppAddr = ethcommon.HexToAddress(c)
}

return nil
}
83 changes: 73 additions & 10 deletions cmd/zetae2e/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ package local
import (
"context"
"os"
"path/filepath"
"time"

"github.com/fatih/color"
"github.com/spf13/cobra"
zetae2econfig "github.com/zeta-chain/zetacore/cmd/zetae2e/config"
"github.com/zeta-chain/zetacore/contrib/localnet/orchestrator/smoketest/config"
"github.com/zeta-chain/zetacore/contrib/localnet/orchestrator/smoketest/runner"
"github.com/zeta-chain/zetacore/contrib/localnet/orchestrator/smoketest/utils"
"golang.org/x/sync/errgroup"
Expand All @@ -21,6 +23,9 @@ const (
flagTestAdmin = "test-admin"
flagTestCustom = "test-custom"
flagSkipRegular = "skip-regular"
flagSetupOnly = "setup-only"
flagConfigOut = "config-out"
flagSkipSetup = "skip-setup"
)

var (
Expand Down Expand Up @@ -70,6 +75,21 @@ func NewLocalCmd() *cobra.Command {
false,
"set to true to skip regular tests",
)
cmd.Flags().Bool(
flagSetupOnly,
false,
"set to true to only setup the networks",
)
cmd.Flags().String(
flagConfigOut,
"",
"config file to write the deployed contracts from the setup",
)
cmd.Flags().Bool(
flagSkipSetup,
false,
"set to true to skip setup",
)

return cmd
}
Expand Down Expand Up @@ -101,6 +121,18 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
if err != nil {
panic(err)
}
setupOnly, err := cmd.Flags().GetBool(flagSetupOnly)
if err != nil {
panic(err)
}
configOut, err := cmd.Flags().GetString(flagConfigOut)
if err != nil {
panic(err)
}
skipSetup, err := cmd.Flags().GetBool(flagSkipSetup)
if err != nil {
panic(err)
}

testStartTime := time.Now()
logger.Print("starting tests")
Expand Down Expand Up @@ -130,8 +162,11 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
setCosmosConfig()

// wait for Genesis
logger.Print("⏳ wait 70s for genesis")
time.Sleep(70 * time.Second)
// if setup is skipp, we assume that the genesis is already created
if !skipSetup {
logger.Print("⏳ wait 70s for genesis")
time.Sleep(70 * time.Second)
}

// initialize deployer runner with config
deployerRunner, err := zetae2econfig.RunnerFromConfig(
Expand All @@ -150,17 +185,45 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
}

// wait for keygen to be completed
waitKeygenHeight(ctx, deployerRunner.CctxClient, logger)
// if setup is skipped, we assume that the keygen is already completed
if !skipSetup {
waitKeygenHeight(ctx, deployerRunner.CctxClient, logger)
}

// query and set the TSS
deployerRunner.SetTSSAddresses()

// setting up the networks
logger.Print("⚙️ setting up networks")
startTime := time.Now()
if !skipSetup {
logger.Print("⚙️ setting up networks")
startTime := time.Now()
deployerRunner.SetupEVM(contractsDeployed)
deployerRunner.SetZEVMContracts()
deployerRunner.MintUSDTOnEvm(10000)
logger.Print("✅ setup completed in %s", time.Since(startTime))
deployerRunner.PrintContractAddresses()
}

deployerRunner.SetTSSAddresses()
deployerRunner.SetupEVM(contractsDeployed)
deployerRunner.SetZEVMContracts()
deployerRunner.MintUSDTOnEvm(10000)
logger.Print("✅ setup completed in %s", time.Since(startTime))
// if a config output is specified, write the config
if configOut != "" {
newConfig := zetae2econfig.ExportContractsFromRunner(deployerRunner, conf)
configOut, err := filepath.Abs(configOut)
if err != nil {
panic(err)
}

// write config into stdout
if err := config.WriteConfig(configOut, newConfig); err != nil {
panic(err)
}

logger.Print("✅ config file written in %s", configOut)
}

// if setup only, quit
if setupOnly {
os.Exit(0)
}

// run tests
var eg errgroup.Group
Expand Down
Loading

0 comments on commit f6ba8ed

Please sign in to comment.