Skip to content

Commit

Permalink
Merge branch 'develop' into fix-cli-args
Browse files Browse the repository at this point in the history
  • Loading branch information
ws4charlie authored Feb 13, 2024
2 parents 9fbb998 + 52ffaa8 commit 265cdff
Show file tree
Hide file tree
Showing 75 changed files with 8,127 additions and 2,743 deletions.
71 changes: 71 additions & 0 deletions .github/actions/build-docker-images-generic/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: 'Build Docker Images'
description: 'Builds Docker images and pushes them to any repository.'
inputs:
DOCKER_FILENAME:
description: 'Name of the docker file to use for the build'
required: true
REPOSITORY_NAME:
description: 'Name of the Repository'
required: true
IMAGE_TAG:
description: 'Image Tag'
required: true
REGISTRY:
description: 'Docker or ORG you want to push to.'
required: true
DOCKER_ORG:
description: 'Docker ORG you want to push to.'
required: false
USERNAME:
description: 'Username for GitHub Container Registry'
required: true
TOKEN:
description: 'Token for GitHub Container Registry'
required: true
DOCKER_FILE_DIRECTORY:
description: 'Directory for your Dockerfile'
required: true
DOCKER_BUILD_KIT:
description: "whether or not to use docker build kit."
required: true
TAG_LATEST:
description: "should the pipeline tag latest"
required: true
runs:
using: "composite"

steps:
- name: Set Environment Variables"
run: |
echo "DOCKER_BUILDKIT=${{ inputs.DOCKER_BUILD_KIT }}" >> $GITHUB_ENV
shell: bash

- name: Log in to the Docker Registry
uses: docker/login-action@v2
with:
registry: ${{ inputs.REGISTRY }}
username: ${{ inputs.USERNAME }}
password: ${{ inputs.TOKEN }}

- name: Build, tag, and push images
shell: bash
working-directory: ${{ inputs.DOCKER_FILE_DIRECTORY }}
run: |
if [ ! -z "${{ inputs.DOCKER_ORG }}" ]; then
echo "DOCKER ORG SPECIFIED SO USE DOCKER HUB"
docker build -f ${{ inputs.DOCKER_FILENAME }} -t ${{ inputs.DOCKER_ORG }}/${{ inputs.REPOSITORY_NAME }}:${{ inputs.IMAGE_TAG }} .
docker push ${{ inputs.DOCKER_ORG }}/${{ inputs.REPOSITORY_NAME }}:${{ inputs.IMAGE_TAG }}
if [ "${{ inputs.TAG_LATEST }}" == "true" ]; then
docker tag ${{ inputs.DOCKER_ORG }}/${{ inputs.REPOSITORY_NAME }}:${{ inputs.IMAGE_TAG }} ${{ inputs.DOCKER_ORG }}/${{ inputs.REPOSITORY_NAME }}:latest
docker push ${{ inputs.DOCKER_ORG }}/${{ inputs.REPOSITORY_NAME }}:latest
fi
else
echo "DOCKER REGISTRY SPECIFIED WITH NO DOCKER_ORG USE NON ORG REGISTRIES"
docker build -f ${{ inputs.DOCKER_FILENAME }} -t ${{ inputs.REGISTRY }}/${{ inputs.REPOSITORY_NAME }}:${{ inputs.IMAGE_TAG }} .
docker push ${{ inputs.REGISTRY }}/${{ inputs.REPOSITORY_NAME }}:${{ inputs.IMAGE_TAG }}
if [ "${{ inputs.TAG_LATEST }}" == "true" ]; then
docker tag ${{ inputs.REGISTRY }}/${{ inputs.REPOSITORY_NAME }}:${{ inputs.IMAGE_TAG }} ${{ inputs.REGISTRY }}/${{ inputs.REPOSITORY_NAME }}:latest
docker push ${{ inputs.REGISTRY }}/${{ inputs.REPOSITORY_NAME }}:latest
fi
fi
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,6 @@ jobs:
- name: Clean Up Workspace
if: always()
shell: bash
run: rm -rf *
run: sudo rm -rf *


120 changes: 120 additions & 0 deletions .github/workflows/docker-build-and-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
name: Zetacored-Docker-Build

on:
pull_request:
types:
- closed
branches:
- 'main'
workflow_dispatch:
inputs:
version:
description: 'Docker Tag Version For Manual Execution'
required: false
default: ''

concurrency:
group: Zetacored-Docker-Build
cancel-in-progress: false

env:
DOCKER_REPO: "zeatcored"
DOCKER_ORG: "zetachain"
DOCKER_REGISTRY: "https://index.docker.io/v1/"

jobs:
docker_build_ubuntu:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set Version from the PR title.
if: github.event_name == 'pull_request'
run: |
echo "GITHUB_TAG_MAJOR_VERSION=${{ github.event.pull_request.title }}" >> ${GITHUB_ENV}
- name: Set Version for Hotfix Release from Input.
if: github.event_name != 'pull_request'
run: |
echo "GITHUB_TAG_MAJOR_VERSION=${{ github.event.inputs.version }}" >> ${GITHUB_ENV}
- name: "BUILD:PUSH:MONITORING:DOCKER:IMAGE"
uses: ./.github/actions/build-docker-images-generic
with:
DOCKER_FILENAME: "Dockerfile"
REPOSITORY_NAME: "${{ env.DOCKER_REPO }}"
IMAGE_TAG: "ubuntu-${{ env.GITHUB_TAG_MAJOR_VERSION }}"
REGISTRY: "${{ env.DOCKER_REGISTRY }}"
DOCKER_ORG: "${{ env.DOCKER_ORG }}"
USERNAME: "${{ secrets.DOCKER_HUB_USERNAME }}"
TOKEN: "${{ secrets.DOCKERHUB_TOKEN }}"
DOCKER_FILE_DIRECTORY: "./"
DOCKER_BUILD_KIT: "0"
TAG_LATEST: "true"

docker_build_mac:
runs-on: macos-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set Version from the PR title.
if: github.event_name == 'pull_request'
run: |
echo "GITHUB_TAG_MAJOR_VERSION=${{ github.event.pull_request.title }}" >> ${GITHUB_ENV}
- name: Set Version for Hotfix Release from Input.
if: github.event_name != 'pull_request'
run: |
echo "GITHUB_TAG_MAJOR_VERSION=${{ github.event.inputs.version }}" >> ${GITHUB_ENV}
- name: "BUILD:PUSH:MONITORING:DOCKER:IMAGE"
uses: ./.github/actions/build-docker-images-generic
with:
DOCKER_FILENAME: "Dockerfile"
REPOSITORY_NAME: "${{ env.DOCKER_REPO }}"
IMAGE_TAG: "mac-${{ env.GITHUB_TAG_MAJOR_VERSION }}"
REGISTRY: "${{ env.DOCKER_REGISTRY }}"
DOCKER_ORG: "${{ env.DOCKER_ORG }}"
USERNAME: "${{ secrets.DOCKER_HUB_USERNAME }}"
TOKEN: "${{ secrets.DOCKERHUB_TOKEN }}"
DOCKER_FILE_DIRECTORY: "./"
DOCKER_BUILD_KIT: "0"
TAG_LATEST: "false"

docker_build_arm:
runs-on: buildjet-4vcpu-ubuntu-2204-arm
timeout-minutes: 30
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set Version from the PR title.
if: github.event_name == 'pull_request'
run: |
echo "GITHUB_TAG_MAJOR_VERSION=${{ github.event.pull_request.title }}" >> ${GITHUB_ENV}
- name: Set Version for Hotfix Release from Input.
if: github.event_name != 'pull_request'
run: |
echo "GITHUB_TAG_MAJOR_VERSION=${{ github.event.inputs.version }}" >> ${GITHUB_ENV}
- name: "BUILD:PUSH:MONITORING:DOCKER:IMAGE"
uses: ./.github/actions/build-docker-images-generic
with:
DOCKER_FILENAME: "Dockerfile"
REPOSITORY_NAME: "${{ env.DOCKER_REPO }}"
IMAGE_TAG: "arm-${{ env.GITHUB_TAG_MAJOR_VERSION }}"
REGISTRY: "${{ env.DOCKER_REGISTRY }}"
DOCKER_ORG: "${{ env.DOCKER_ORG }}"
USERNAME: "${{ secrets.DOCKER_HUB_USERNAME }}"
TOKEN: "${{ secrets.DOCKERHUB_TOKEN }}"
DOCKER_FILE_DIRECTORY: "./"
DOCKER_BUILD_KIT: "0"
TAG_LATEST: "false"
12 changes: 11 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -293,4 +293,14 @@ release:
-v `pwd`:/go/src/$(PACKAGE_NAME) \
-w /go/src/$(PACKAGE_NAME) \
ghcr.io/goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \
release --clean --skip-validate
release --clean --skip-validate

###############################################################################
### Local Mainnet Development ###
###############################################################################

mainnet-zetarpc-node:
cd contrib/local-mainnet/zetacored && docker-compose up

mainnet-bitcoind-node:
cd contrib/local-mainnet/bitcoind && docker-compose up
15 changes: 14 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,38 @@

* `zetaclientd start` : 2 inputs required from stdin

### Docs

* [1731](https://github.com/zeta-chain/node/pull/1731) added doc for hotkey and tss key-share password prompts.

### Refactor

* [1630](https://github.com/zeta-chain/node/pull/1630) added password prompts for hotkey and tss keyshare in zetaclient
Starting zetaclient now requires two passwords to be input; one for the hotkey and another for the tss key-share.

### Fixes

* [1678](https://github.com/zeta-chain/node/issues/1678) - clean cached stale block to fix evm outtx hash mismatch
* [1690](https://github.com/zeta-chain/node/issues/1690) - double watched gas prices and fix btc scheduler
* [1687](https://github.com/zeta-chain/node/pull/1687) - only use EVM supported chains for gas stability pool
* [1692](https://github.com/zeta-chain/node/pull/1692) - fix get params query for emissions module
* [1706](https://github.com/zeta-chain/node/pull/1706) - fix CLI crosschain show-out-tx-tracker
* [1707](https://github.com/zeta-chain/node/issues/1707) - fix bitcoin fee rate estimation
* [1712](https://github.com/zeta-chain/node/issues/1712) - increase EVM outtx inclusion timeout to 20 minutes
* [1733](https://github.com/zeta-chain/node/pull/1733)) - remove the unnecessary 2x multiplier in the convertGasToZeta RPC
* [1733](https://github.com/zeta-chain/node/pull/1733) - remove the unnecessary 2x multiplier in the convertGasToZeta RPC
* [1721](https://github.com/zeta-chain/node/issues/1721) - zetaclient should provide bitcoin_chain_id when querying TSS address
* [1744](https://github.com/zeta-chain/node/pull/1744) - added cmd to encrypt tss keyshare file, allowing empty tss password for backward compatibility.

### Tests

* [1584](https://github.com/zeta-chain/node/pull/1584) - allow to run E2E tests on any networks

### CI

* CI: adding pipeline to build and push docker images into dockerhub on release for ubuntu and macos.
* Added docker-compose and make commands for launching full nodes. `make mainnet-zetarpc-node` `make mainnet-bitcoind-node`
* [1736](https://github.com/zeta-chain/node/pull/1736) - chore: add Ethermint endpoints to OpenAPI

### Chores

* [1729](https://github.com/zeta-chain/node/pull/1729) - add issue templates
Expand Down Expand Up @@ -77,6 +89,7 @@
### Refactoring

* [1628](https://github.com/zeta-chain/node/pull/1628) optimize return and simplify code
* [1640](https://github.com/zeta-chain/node/pull/1640) reorganize zetaclient into subpackages

### Refactoring
* [1619](https://github.com/zeta-chain/node/pull/1619) - Add evm fee calculation to tss migration of evm chains
Expand Down
17 changes: 11 additions & 6 deletions cmd/zetaclientd/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ import (
"strings"
"sync"

"github.com/zeta-chain/zetacore/zetaclient/bitcoin"
"github.com/zeta-chain/zetacore/zetaclient/evm"
"github.com/zeta-chain/zetacore/zetaclient/keys"
"github.com/zeta-chain/zetacore/zetaclient/metrics"
"github.com/zeta-chain/zetacore/zetaclient/zetabridge"

"github.com/btcsuite/btcd/rpcclient"
sdk "github.com/cosmos/cosmos-sdk/types"
ethcommon "github.com/ethereum/go-ethereum/common"
Expand All @@ -17,7 +23,6 @@ import (
"github.com/zeta-chain/zetacore/common"
"github.com/zeta-chain/zetacore/testutil/sample"
observertypes "github.com/zeta-chain/zetacore/x/observer/types"
"github.com/zeta-chain/zetacore/zetaclient"
"github.com/zeta-chain/zetacore/zetaclient/config"
)

Expand Down Expand Up @@ -54,16 +59,16 @@ func DebugCmd() *cobra.Command {
var ballotIdentifier string
chainLogger := zerolog.New(io.Discard).Level(zerolog.Disabled)

telemetryServer := zetaclient.NewTelemetryServer()
telemetryServer := metrics.NewTelemetryServer()
go func() {
err := telemetryServer.Start()
if err != nil {
panic("telemetryServer error")
}
}()

bridge, err := zetaclient.NewZetaCoreBridge(
&zetaclient.Keys{OperatorAddress: sdk.MustAccAddressFromBech32(sample.AccAddress())},
bridge, err := zetabridge.NewZetaCoreBridge(
&keys.Keys{OperatorAddress: sdk.MustAccAddressFromBech32(sample.AccAddress())},
debugArgs.zetaNode,
"",
debugArgs.zetaChainID,
Expand All @@ -89,7 +94,7 @@ func DebugCmd() *cobra.Command {

if common.IsEVMChain(chain.ChainId) {

ob := zetaclient.EVMChainClient{
ob := evm.ChainClient{
Mu: &sync.Mutex{},
}
ob.WithZetaClient(bridge)
Expand Down Expand Up @@ -159,7 +164,7 @@ func DebugCmd() *cobra.Command {
}
fmt.Println("CoinType : ", coinType)
} else if common.IsBitcoinChain(chain.ChainId) {
obBtc := zetaclient.BitcoinChainClient{
obBtc := bitcoin.BTCChainClient{
Mu: &sync.Mutex{},
}
obBtc.WithZetaClient(bridge)
Expand Down
67 changes: 67 additions & 0 deletions cmd/zetaclientd/encrypt_tss.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package main

import (
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"crypto/sha256"
"encoding/json"
"errors"
"io"
"os"
"path/filepath"

"github.com/spf13/cobra"
)

var encTssCmd = &cobra.Command{
Use: "tss-encrypt [file-path] [secret-key]",
Short: "Utility command to encrypt existing tss key-share file",
Args: cobra.ExactArgs(2),
RunE: EncryptTSSFile,
}

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

func EncryptTSSFile(_ *cobra.Command, args []string) error {
filePath := args[0]
secretKey := args[1]

filePath = filepath.Clean(filePath)
data, err := os.ReadFile(filePath)
if err != nil {
return err
}

if !json.Valid(data) {
return errors.New("file does not contain valid json, may already be encrypted")
}

block, err := aes.NewCipher(getFragmentSeed(secretKey))
if err != nil {
return err
}

// Creating GCM mode
gcm, err := cipher.NewGCM(block)
if err != nil {
return err
}
// Generating random nonce
nonce := make([]byte, gcm.NonceSize())
if _, err := io.ReadFull(rand.Reader, nonce); err != nil {
return err
}

cipherText := gcm.Seal(nonce, nonce, data, nil)
return os.WriteFile(filePath, cipherText, 0o600)
}

func getFragmentSeed(password string) []byte {
h := sha256.New()
h.Write([]byte(password))
seed := h.Sum(nil)
return seed
}
Loading

0 comments on commit 265cdff

Please sign in to comment.