Skip to content

Commit

Permalink
Merge branch 'develop' into feat/bank-precompile
Browse files Browse the repository at this point in the history
  • Loading branch information
Francisco de Borja Aranda Castillejo authored Sep 25, 2024
2 parents de990fa + 2892114 commit f74194a
Show file tree
Hide file tree
Showing 106 changed files with 6,326 additions and 1,147 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/semgrep.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Semgrep
on:
workflow_dispatch: {}
pull_request: {}
push:
branches:
- develop
schedule:
# random HH:MM to avoid a load spike on GitHub Actions at 00:00
- cron: '56 22 * * *'
jobs:
semgrep:
name: semgrep/ci
runs-on: ubuntu-20.04
env:
SEMGREP_APP_TOKEN: ${{ secrets.SEMGREP_APP_TOKEN }}
container:
image: semgrep/semgrep
if: (github.actor != 'dependabot[bot]')
steps:
- uses: actions/checkout@v4
- run: semgrep ci
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,5 @@ contrib/localnet/grafana/addresses.txt
contrib/localnet/addresses.txt

# Config for e2e tests
e2e_conf*
e2e_conf*
contrib/localnet/scripts/extra-evm-chains.json
9 changes: 5 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ VERSION := $(shell ./version.sh)
COMMIT := $(shell [ -z "${COMMIT_ID}" ] && git log -1 --format='%H' || echo ${COMMIT_ID} )
BUILDTIME := $(shell date -u +"%Y%m%d.%H%M%S" )
DOCKER ?= docker
# allow setting of DOCKER_COMPOSE_ARGS to pass additional args to docker compose
# useful for setting profiles
DOCKER_COMPOSE ?= $(DOCKER) compose $(COMPOSE_ARGS)
# allow setting of NODE_COMPOSE_ARGS to pass additional args to docker compose
# useful for setting profiles and/ort optional overlays
# example: NODE_COMPOSE_ARGS="--profile monitoring -f docker-compose-persistent.yml"
DOCKER_COMPOSE ?= $(DOCKER) compose $(NODE_COMPOSE_ARGS)
DOCKER_BUF := $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace bufbuild/buf
GOFLAGS := ""
GOLANG_CROSS_VERSION ?= v1.22.4
Expand Down Expand Up @@ -224,7 +225,7 @@ start-localnet-skip-build:

# stop-localnet should include all profiles so other containers are also removed
stop-localnet:
cd contrib/localnet/ && $(DOCKER_COMPOSE) --profile all down --remove-orphans
cd contrib/localnet/ && $(DOCKER_COMPOSE) --profile all -f docker-compose.yml down --remove-orphans

###############################################################################
### E2E tests ###
Expand Down
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,17 @@
* [2860](https://github.com/zeta-chain/node/pull/2860) - bank precompiled contract
* [2870](https://github.com/zeta-chain/node/pull/2870) - support for multiple Bitcoin chains in the zetaclient
* [2883](https://github.com/zeta-chain/node/pull/2883) - add chain static information for btc signet testnet
* [2907](https://github.com/zeta-chain/node/pull/2907) - derive Bitcoin tss address by chain id and added more Signet static info
* [2911](https://github.com/zeta-chain/node/pull/2911) - add chain static information for btc testnet4

### Refactor

* [2749](https://github.com/zeta-chain/node/pull/2749) - fix all lint errors from govet
* [2725](https://github.com/zeta-chain/node/pull/2725) - refactor SetCctxAndNonceToCctxAndInboundHashToCctx to receive tsspubkey as an argument
* [2802](https://github.com/zeta-chain/node/pull/2802) - set default liquidity cap for new ZRC20s
* [2826](https://github.com/zeta-chain/node/pull/2826) - remove unused code from emissions module and add new parameter for fixed block reward amount
* [2890](https://github.com/zeta-chain/node/pull/2890) - refactor `MsgUpdateChainInfo` to accept a single chain, and add `MsgRemoveChainInfo` to remove a chain
* [2899](https://github.com/zeta-chain/node/pull/2899) - remove btc deposit fee v1 and improve unit tests

### Tests

Expand Down
2 changes: 1 addition & 1 deletion cmd/zetaclientd/gen_pre_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"os"
"time"

"github.com/bnb-chain/tss-lib/ecdsa/keygen"
"github.com/spf13/cobra"
"gitlab.com/thorchain/tss/tss-lib/ecdsa/keygen"
)

func init() {
Expand Down
3 changes: 1 addition & 2 deletions cmd/zetaclientd/keygen_tss.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,7 @@ func keygenTSS(
keygenLogger zerolog.Logger,
) (string, error) {
keygenLogger.Info().Msgf("Keygen at blocknum %d , TSS signers %s ", keyGen.BlockNumber, keyGen.GranteePubkeys)
var req keygen.Request
req = keygen.NewRequest(keyGen.GranteePubkeys, keyGen.BlockNumber, "0.14.0")
req := keygen.NewRequest(keyGen.GranteePubkeys, keyGen.BlockNumber, "0.14.0", tsscommon.ECDSA)
res, err := tssServer.Keygen(req)
if res.Status != tsscommon.Success || res.PubKey == "" {
keygenLogger.Error().Msgf("keygen fail: reason %s blame nodes %s", res.Blame.FailReason, res.Blame.BlameNodes)
Expand Down
2 changes: 1 addition & 1 deletion cmd/zetaclientd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import (
"os"
"time"

ecdsakeygen "github.com/bnb-chain/tss-lib/ecdsa/keygen"
"github.com/cosmos/cosmos-sdk/server"
svrcmd "github.com/cosmos/cosmos-sdk/server/cmd"
"github.com/cosmos/cosmos-sdk/types"
ecdsakeygen "gitlab.com/thorchain/tss/tss-lib/ecdsa/keygen"

"github.com/zeta-chain/node/app"
"github.com/zeta-chain/node/cmd"
Expand Down
34 changes: 13 additions & 21 deletions cmd/zetaclientd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"time"

"github.com/cometbft/cometbft/crypto/secp256k1"
ethcommon "github.com/ethereum/go-ethereum/common"
maddr "github.com/multiformats/go-multiaddr"
"github.com/pkg/errors"
"github.com/rs/zerolog/log"
Expand Down Expand Up @@ -230,21 +229,10 @@ func start(_ *cobra.Command, _ []string) error {
return err
}

btcChains := appContext.FilterChains(zctx.Chain.IsBitcoin)
switch {
case len(btcChains) == 0:
return errors.New("no BTC chains found")
case len(btcChains) > 1:
// In the future we might support multiple UTXO chains;
// right now we only support BTC. Let's make sure there are no surprises.
return errors.New("more than one BTC chain found")
}

tss, err := mc.NewTSS(
ctx,
zetacoreClient,
tssHistoricalList,
btcChains[0].ID(),
hotkeyPass,
server,
)
Expand Down Expand Up @@ -280,16 +268,20 @@ func start(_ *cobra.Command, _ []string) error {
return err
}

// Defensive check: Make sure the tss address is set to the current TSS address and not the newly generated one
// Filter supported BTC chain IDs
btcChains := appContext.FilterChains(zctx.Chain.IsBitcoin)
btcChainIDs := make([]int64, len(btcChains))
for i, chain := range btcChains {
btcChainIDs[i] = chain.ID()
}

// Make sure the TSS EVM/BTC addresses are well formed.
// Zetaclient should not start if TSS addresses cannot be properly derived.
tss.CurrentPubkey = currentTss.TssPubkey
if tss.EVMAddress() == (ethcommon.Address{}) || tss.BTCAddress() == "" {
startLogger.Error().Msg("TSS address is not set in zetacore")
} else {
startLogger.Info().
Str("tss.eth", tss.EVMAddress().String()).
Str("tss.btc", tss.BTCAddress()).
Str("tss.pub_key", tss.CurrentPubkey).
Msg("Current TSS")
err = tss.ValidateAddresses(btcChainIDs)
if err != nil {
startLogger.Error().Err(err).Msg("TSS address validation failed")
return err
}

if len(appContext.ListChainIDs()) == 0 {
Expand Down
71 changes: 71 additions & 0 deletions contrib/localnet/docker-compose-persistent.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# This docker-compose updates the services to use a persistent data directory
# clear these volumes with this command: docker volume rm $(docker volume ls -q | grep -- '-persist$')

services:
zetacore0:
volumes:
- zetacore0-zetacored-persist:/root/.zetacored

zetacore1:
volumes:
- zetacore1-zetacored-persist:/root/.zetacored

zetacore2:
volumes:
- zetacore2-zetacored-persist:/root/.zetacored

zetacore3:
volumes:
- zetacore3-zetacored-persist:/root/.zetacored

zetaclient0:
volumes:
- zetaclient0-zetacored-persist:/root/.zetacored
- zetaclient0-tss-persist:/root/.tss
- zetaclient0-zetaclient-persist:/root/.zetaclient

zetaclient1:
volumes:
- zetaclient1-zetacored-persist:/root/.zetacored
- zetaclient1-tss-persist:/root/.tss
- zetaclient1-zetaclient-persist:/root/.zetaclient

zetaclient2:
volumes:
- zetaclient2-zetacored-persist:/root/.zetacored
- zetaclient2-tss-persist:/root/.tss
- zetaclient2-zetaclient-persist:/root/.zetaclient

zetaclient3:
volumes:
- zetaclient3-zetacored-persist:/root/.zetacored
- zetaclient3-tss-persist:/root/.tss
- zetaclient3-zetaclient-persist:/root/.zetaclient

eth:
volumes:
- eth-data-persist:/root/data

orchestrator:
volumes:
- orchestrator-state-persist:/root/state

volumes:
zetacore0-zetacored-persist:
zetacore1-zetacored-persist:
zetacore2-zetacored-persist:
zetacore3-zetacored-persist:
zetaclient0-zetacored-persist:
zetaclient0-tss-persist:
zetaclient0-zetaclient-persist:
zetaclient1-zetacored-persist:
zetaclient1-tss-persist:
zetaclient1-zetaclient-persist:
zetaclient2-zetacored-persist:
zetaclient2-tss-persist:
zetaclient2-zetaclient-persist:
zetaclient3-zetacored-persist:
zetaclient3-tss-persist:
zetaclient3-zetaclient-persist:
eth-data-persist:
orchestrator-state-persist:
5 changes: 3 additions & 2 deletions contrib/localnet/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ services:
networks:
mynetwork:
ipv4_address: 172.20.0.100
entrypoint: ["geth", "--dev", "--http", "--http.addr", "172.20.0.100", "--http.vhosts", "*", "--http.api", "eth,web3,net", "--http.corsdomain", "https://remix.ethereum.org", "--dev.period", "2"]
entrypoint: ["geth", "--dev", "--datadir", "/root/data", "--http", "--http.addr", "172.20.0.100", "--http.vhosts", "*", "--http.api", "eth,web3,net", "--http.corsdomain", "https://remix.ethereum.org", "--dev.period", "2", "--"]

eth2:
build:
Expand Down Expand Up @@ -313,7 +313,7 @@ services:
- ssh:/root/.ssh

grafana:
image: grafana/grafana:9.1.7
image: grafana/grafana:11.2.0
container_name: grafana
hostname: grafana
profiles:
Expand All @@ -322,6 +322,7 @@ services:
volumes:
- ./grafana/datasource.yaml:/etc/grafana/provisioning/datasources/datasource.yaml
- ./grafana/dashboards/:/etc/grafana/provisioning/dashboards
- ./grafana/grafana.ini:/etc/grafana/grafana.ini
- grafana_storage:/var/lib/grafana
ports:
- "3000:3000"
Expand Down
5 changes: 5 additions & 0 deletions contrib/localnet/grafana/grafana.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[auth.anonymous]
enabled = true

org_id = 1
org_role = Editor
28 changes: 16 additions & 12 deletions contrib/localnet/orchestrator/start-zetae2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,18 @@ if host ton > /dev/null; then
./wait-for-ton.sh
fi

# need to make the directory if it was not mounted as a volume
mkdir -p /root/state
deployed_config_path=/root/state/deployed.yml

### Run zetae2e command depending on the option passed

# Mode migrate is used to run the e2e tests before and after the TSS migration
# It runs the e2e tests with the migrate flag which triggers a TSS migration at the end of the tests. Once the migrationis done the first e2e test is complete
# The second e2e test is run after the migration to ensure the network is still working as expected with the new tss address
if [ "$LOCALNET_MODE" == "tss-migrate" ]; then
if [[ ! -f deployed.yml ]]; then
zetae2e local $E2E_ARGS --setup-only --config config.yml --config-out deployed.yml --skip-header-proof
if [[ ! -f "$deployed_config_path" ]]; then
zetae2e local $E2E_ARGS --setup-only --config config.yml --config-out "$deployed_config_path" --skip-header-proof
if [ $? -ne 0 ]; then
echo "e2e setup failed"
exit 1
Expand All @@ -167,7 +171,7 @@ if [ "$LOCALNET_MODE" == "tss-migrate" ]; then
fi

echo "running e2e test before migrating TSS"
zetae2e local $E2E_ARGS --skip-setup --config deployed.yml --skip-header-proof
zetae2e local $E2E_ARGS --skip-setup --config "$deployed_config_path" --skip-header-proof
if [ $? -ne 0 ]; then
echo "first e2e failed"
exit 1
Expand All @@ -176,7 +180,7 @@ if [ "$LOCALNET_MODE" == "tss-migrate" ]; then
echo "waiting 10 seconds for node to restart"
sleep 10

zetae2e local --skip-setup --config deployed.yml --skip-bitcoin-setup --light --skip-header-proof
zetae2e local --skip-setup --config "$deployed_config_path" --skip-bitcoin-setup --light --skip-header-proof
ZETAE2E_EXIT_CODE=$?
if [ $ZETAE2E_EXIT_CODE -eq 0 ]; then
echo "E2E passed after migration"
Expand All @@ -200,8 +204,8 @@ if [ "$LOCALNET_MODE" == "upgrade" ]; then
OLD_VERSION=$(get_zetacored_version)
COMMON_ARGS="--skip-header-proof --skip-tracker-check"

if [[ ! -f deployed.yml ]]; then
zetae2e local $E2E_ARGS --setup-only --config config.yml --config-out deployed.yml ${COMMON_ARGS}
if [[ ! -f "$deployed_config_path" ]]; then
zetae2e local $E2E_ARGS --setup-only --config config.yml --config-out "$deployed_config_path" ${COMMON_ARGS}
if [ $? -ne 0 ]; then
echo "e2e setup failed"
exit 1
Expand All @@ -215,7 +219,7 @@ if [ "$LOCALNET_MODE" == "upgrade" ]; then
echo "running E2E command to setup the networks and populate the state..."

# Use light flag to ensure tests can complete before the upgrade height
zetae2e local $E2E_ARGS --skip-setup --config deployed.yml --light --skip-precompiles ${COMMON_ARGS}
zetae2e local $E2E_ARGS --skip-setup --config "$deployed_config_path" --light --skip-precompiles ${COMMON_ARGS}
if [ $? -ne 0 ]; then
echo "first e2e failed"
exit 1
Expand Down Expand Up @@ -254,9 +258,9 @@ if [ "$LOCALNET_MODE" == "upgrade" ]; then
# When the upgrade height is greater than 100 for upgrade test, the Bitcoin tests have been run once, therefore the Bitcoin wallet is already set up
# Use light flag to skip advanced tests
if [ "$UPGRADE_HEIGHT" -lt 100 ]; then
zetae2e local $E2E_ARGS --skip-setup --config deployed.yml --light ${COMMON_ARGS}
zetae2e local $E2E_ARGS --skip-setup --config "$deployed_config_path" --light ${COMMON_ARGS}
else
zetae2e local $E2E_ARGS --skip-setup --config deployed.yml --skip-bitcoin-setup --light ${COMMON_ARGS}
zetae2e local $E2E_ARGS --skip-setup --config "$deployed_config_path" --skip-bitcoin-setup --light ${COMMON_ARGS}
fi

ZETAE2E_EXIT_CODE=$?
Expand All @@ -272,8 +276,8 @@ else
# If no mode is passed, run the e2e tests normally
echo "running e2e setup..."

if [[ ! -f deployed.yml ]]; then
zetae2e local $E2E_ARGS --config config.yml --setup-only --config-out deployed.yml
if [[ ! -f "$deployed_config_path" ]]; then
zetae2e local $E2E_ARGS --config config.yml --setup-only --config-out "$deployed_config_path"
if [ $? -ne 0 ]; then
echo "e2e setup failed"
exit 1
Expand All @@ -288,7 +292,7 @@ else

echo "running e2e tests with arguments: $E2E_ARGS"

zetae2e local $E2E_ARGS --skip-setup --config deployed.yml
zetae2e local $E2E_ARGS --skip-setup --config "$deployed_config_path"
ZETAE2E_EXIT_CODE=$?

# if e2e passed, exit with 0, otherwise exit with 1
Expand Down
6 changes: 6 additions & 0 deletions contrib/localnet/scripts/start-zetaclientd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,10 @@ then
fi
fi

# merge extra-evm-chains.json into zetaclient_config.json if specified
if [[ -f /root/extra-evm-chains.json ]]; then
jq '.EVMChainConfigs *= input' /root/.zetacored/config/zetaclient_config.json /root/extra-evm-chains.json > /tmp/merged_config.json
mv /tmp/merged_config.json /root/.zetacored/config/zetaclient_config.json
fi

zetaclientd-supervisor start < /root/password.file
Loading

0 comments on commit f74194a

Please sign in to comment.