Skip to content

Commit

Permalink
Merge branch 'develop' into authorization-list-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kingpinXD authored Jun 20, 2024
2 parents 0b586c6 + 2bb6f7b commit e83e188
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 21 deletions.
5 changes: 3 additions & 2 deletions Dockerfile-localnet
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ RUN mkdir -p /root/.zetacored/cosmovisor/genesis/bin && \
ENV PATH /root/.zetacored/cosmovisor/current/bin/:/root/.zetaclientd/upgrades/current/:${PATH}

COPY contrib/localnet/scripts /root
COPY contrib/localnet/ssh_config /root/.ssh/config
COPY contrib/localnet/ssh_config /etc/ssh/ssh_config.d/localnet.conf
COPY contrib/localnet/zetacored /root/zetacored

RUN chmod 755 /root/*.sh
RUN chmod 755 /root/*.sh && \
chmod 644 /etc/ssh/ssh_config.d/localnet.conf

WORKDIR /usr/local/bin
EXPOSE 22
Expand Down
40 changes: 40 additions & 0 deletions cmd/zetaclientd/gen_pre_params.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package main

import (
"encoding/json"
"fmt"
"os"
"time"

"github.com/binance-chain/tss-lib/ecdsa/keygen"
"github.com/spf13/cobra"
)

func init() {
RootCmd.AddCommand(GenPrePramsCmd)
}

var GenPrePramsCmd = &cobra.Command{
Use: "gen-pre-params <path>",
Short: "Generate pre parameters for TSS",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
startTime := time.Now()
preParams, err := keygen.GeneratePreParams(time.Second * 300)
if err != nil {
return err
}

file, err := os.OpenFile(args[0], os.O_RDWR|os.O_CREATE, 0600)
if err != nil {
return err
}
defer file.Close()
err = json.NewEncoder(file).Encode(preParams)
if err != nil {
return err
}
fmt.Printf("Generated new pre-parameters in %v\n", time.Since(startTime))
return nil
},
}
9 changes: 1 addition & 8 deletions cmd/zetae2e/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,6 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
// set account prefix to zeta
setCosmosConfig()

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

zetaTxServer, err := txserver.NewZetaTxServer(
conf.RPCs.ZetaCoreRPC,
[]string{utils.FungibleAdminName},
Expand Down Expand Up @@ -399,7 +392,7 @@ func waitKeygenHeight(
logger *runner.Logger,
) {
// wait for keygen to be completed
keygenHeight := int64(60)
keygenHeight := int64(35)
logger.Print("⏳ wait height %v for keygen to be completed", keygenHeight)
for {
time.Sleep(2 * time.Second)
Expand Down
19 changes: 16 additions & 3 deletions contrib/localnet/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ services:
- "26657:26657"
- "6060:6060"
- "9090:9090"
healthcheck:
# use the zevm endpoint for the healthcheck as it is the slowest to come up
test: ["CMD", "curl", "-f", "-X", "POST", "--data", '{"jsonrpc":"2.0","method":"web3_clientVersion","params":[],"id":67}', "-H", "Content-Type: application/json", "http://localhost:8545"]
interval: 30s
timeout: 10s
retries: 3
start_period: 30s
start_interval: 1s
networks:
mynetwork:
ipv4_address: 172.20.0.11
Expand Down Expand Up @@ -78,6 +86,7 @@ services:
- HOTKEY_PASSWORD=password # test purposes only
volumes:
- ssh:/root/.ssh
- preparams:/root/preparams

zetaclient1:
image: zetanode:latest
Expand All @@ -93,6 +102,7 @@ services:
- HOTKEY_PASSWORD=password # test purposes only
volumes:
- ssh:/root/.ssh
- preparams:/root/preparams

eth:
image: ethereum/client-go:v1.10.26
Expand Down Expand Up @@ -127,8 +137,10 @@ services:
tty: true
container_name: orchestrator
depends_on:
- zetacore0
- eth
zetacore0:
condition: service_healthy
eth:
condition: service_started
hostname: orchestrator
networks:
mynetwork:
Expand All @@ -137,4 +149,5 @@ services:
volumes:
- ssh:/root/.ssh
volumes:
ssh:
ssh:
preparams:
13 changes: 10 additions & 3 deletions contrib/localnet/scripts/start-zetaclientd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ set_sepolia_endpoint() {
jq '.EVMChainConfigs."11155111".Endpoint = "http://eth2:8545"' /root/.zetacored/config/zetaclient_config.json > tmp.json && mv tmp.json /root/.zetacored/config/zetaclient_config.json
}

# generate pre-params as early as possible
# to reach keygen height on schedule
PREPARAMS_PATH="/root/preparams/${HOSTNAME}.json"
if [ ! -f "$PREPARAMS_PATH" ]; then
zetaclientd gen-pre-params "$PREPARAMS_PATH"
fi

# Wait for authorized_keys file to exist (generated by zetacore0)
while [ ! -f ~/.ssh/authorized_keys ]; do
echo "Waiting for authorized_keys file to exist..."
Expand Down Expand Up @@ -42,7 +49,7 @@ echo "Start zetaclientd"
if [[ $HOSTNAME == "zetaclient0" && ! -f ~/.zetacored/config/zetaclient_config.json ]]
then
MYIP=$(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1)
zetaclientd init --zetacore-url zetacore0 --chain-id athens_101-1 --operator "$operatorAddress" --log-format=text --public-ip "$MYIP" --keyring-backend "$BACKEND"
zetaclientd init --zetacore-url zetacore0 --chain-id athens_101-1 --operator "$operatorAddress" --log-format=text --public-ip "$MYIP" --keyring-backend "$BACKEND" --pre-params "$PREPARAMS_PATH"

# check if the option is additional-evm
# in this case, the additional evm is represented with the sepolia chain, we set manually the eth2 endpoint to the sepolia chain (11155111 -> http://eth2:8545)
Expand All @@ -59,9 +66,9 @@ then
SEED=""
while [ -z "$SEED" ]
do
SEED=$(curl --retry 10 --retry-delay 5 --retry-connrefused -s zetaclient0:8123/p2p)
SEED=$(curl --retry 30 --retry-delay 1 --max-time 1 --retry-connrefused -s zetaclient0:8123/p2p)
done
zetaclientd init --peer "/ip4/172.20.0.21/tcp/6668/p2p/${SEED}" --zetacore-url "$node" --chain-id athens_101-1 --operator "$operatorAddress" --log-format=text --public-ip "$MYIP" --log-level 1 --keyring-backend "$BACKEND"
zetaclientd init --peer "/ip4/172.20.0.21/tcp/6668/p2p/${SEED}" --zetacore-url "$node" --chain-id athens_101-1 --operator "$operatorAddress" --log-format=text --public-ip "$MYIP" --log-level 1 --keyring-backend "$BACKEND" --pre-params "$PREPARAMS_PATH"

# check if the option is additional-evm
# in this case, the additional evm is represented with the sepolia chain, we set manually the eth2 endpoint to the sepolia chain (11155111 -> http://eth2:8545)
Expand Down
2 changes: 1 addition & 1 deletion contrib/localnet/scripts/start-zetacored.sh
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ then

# 2. Add the observers, authorizations, required params and accounts to the genesis.json
zetacored collect-observer-info
zetacored add-observer-list --keygen-block 55
zetacored add-observer-list --keygen-block 25

# Check for the existence of "AddToOutTxTracker" string in the genesis file
# If this message is found in the genesis, it means add-observer-list has been run with the v16 binary for upgrade tests
Expand Down
4 changes: 1 addition & 3 deletions contrib/localnet/ssh_config
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@

Host *
StrictHostKeyChecking no
IdentityFile ~/.ssh/localtest.pem
StrictHostKeyChecking no
3 changes: 2 additions & 1 deletion zetaclient/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,10 @@ func GetPath(inputPath string) string {
return ""
}
path[0] = home
return filepath.Join(path...)
}
}
return filepath.Join(path...)
return inputPath
}

// ContainRestrictedAddress returns true if any one of the addresses is restricted
Expand Down

0 comments on commit e83e188

Please sign in to comment.