Skip to content

Commit

Permalink
Merge branch 'develop' into docs-add-codeowner
Browse files Browse the repository at this point in the history
  • Loading branch information
ws4charlie authored Feb 13, 2024
2 parents f5c5cc0 + 8a3fb92 commit 1356e82
Show file tree
Hide file tree
Showing 22 changed files with 41,220 additions and 98 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
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: 10 additions & 2 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
## Unreleased

* `zetaclientd start` : 2 inputs required from stdin
* Added docker-compose and make commands for launching full nodes. `make mainnet-zetarpc-node` `make mainnet-bitcoind-node`

### Features

* [1698](https://github.com/zeta-chain/node/issues/1698) - bitcoin dynamic depositor fee

### Docs

Expand All @@ -16,21 +19,26 @@

### 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
* [1753](https://github.com/zeta-chain/node/pull/1753) - fix gosec errors on usage of rand package

### 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
Expand Down
10 changes: 10 additions & 0 deletions common/bitcoin.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,13 @@ func BitcoinNetParamsFromChainID(chainID int64) (*chaincfg.Params, error) {
return nil, fmt.Errorf("no Bitcoin net params for chain ID: %d", chainID)
}
}

// IsBitcoinRegnet returns true if the chain id is for the regnet
func IsBitcoinRegnet(chainID int64) bool {
return chainID == BtcRegtestChain().ChainId
}

// IsBitcoinMainnet returns true if the chain id is for the mainnet
func IsBitcoinMainnet(chainID int64) bool {
return chainID == BtcMainnetChain().ChainId
}
6 changes: 6 additions & 0 deletions common/constant.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package common

const (
// DefaultGasPriceMultiplier is the default gas price multiplier for outbond txs
DefaultGasPriceMultiplier = 2
)
14 changes: 6 additions & 8 deletions contrib/localnet/orchestrator/smoketest/runner/bitcoin.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (sm *SmokeTestRunner) DepositBTCWithAmount(amount float64) (txHash *chainha
sm.Logger.Info(" spendableUTXOs: %d", spendableUTXOs)
sm.Logger.Info("Now sending two txs to TSS address...")

amount = amount + zetabitcoin.BtcDepositorFeeMin
amount = amount + zetabitcoin.DefaultDepositorFee
txHash, err = sm.SendToTSSFromDeployerToDeposit(sm.BTCTSSAddress, amount, utxos, sm.BtcRPCClient, sm.BTCDeployerAddress)
if err != nil {
panic(err)
Expand Down Expand Up @@ -101,12 +101,12 @@ func (sm *SmokeTestRunner) DepositBTC(testHeader bool) {
sm.Logger.Info("Now sending two txs to TSS address...")

// send two transactions to the TSS address
amount1 := 1.1 + zetabitcoin.BtcDepositorFeeMin
amount1 := 1.1 + zetabitcoin.DefaultDepositorFee
txHash1, err := sm.SendToTSSFromDeployerToDeposit(sm.BTCTSSAddress, amount1, utxos[:2], btc, sm.BTCDeployerAddress)
if err != nil {
panic(err)
}
amount2 := 0.05 + zetabitcoin.BtcDepositorFeeMin
amount2 := 0.05 + zetabitcoin.DefaultDepositorFee
txHash2, err := sm.SendToTSSFromDeployerToDeposit(sm.BTCTSSAddress, amount2, utxos[2:4], btc, sm.BTCDeployerAddress)
if err != nil {
panic(err)
Expand Down Expand Up @@ -266,16 +266,14 @@ func (sm *SmokeTestRunner) SendToTSSFromDeployerWithMemo(
panic(err)
}

btcChainID, err := common.GetBTCChainIDFromChainParams(sm.BitcoinParams)
if err != nil {
panic(err)
}
depositorFee := zetabitcoin.DefaultDepositorFee
events := zetabitcoin.FilterAndParseIncomingTx(
[]btcjson.TxRawResult{*rawtx},
0,
sm.BTCTSSAddress.EncodeAddress(),
&log.Logger,
btcChainID,
sm.BitcoinParams,
depositorFee,
)
sm.Logger.Info("bitcoin intx events:")
for _, event := range events {
Expand Down
2 changes: 1 addition & 1 deletion x/crosschain/client/cli/cli_out_tx_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func CmdShowOutTxTracker() *cobra.Command {
cmd := &cobra.Command{
Use: "show-out-tx-tracker [chainId] [nonce]",
Short: "shows a OutTxTracker",
Args: cobra.ExactArgs(1),
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) (err error) {
clientCtx := client.GetClientContextFromCmd(cmd)

Expand Down
48 changes: 30 additions & 18 deletions x/emissions/client/tests/suite.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package querytests

import (
"math/rand"
"crypto/rand"
"math/big"
"strconv"
"testing"

sdk "github.com/cosmos/cosmos-sdk/types"
ethcfg "github.com/evmos/ethermint/cmd/config"
Expand Down Expand Up @@ -52,7 +54,7 @@ func (s *CliTestSuite) SetupSuite() {
"zeta1e9fyaulgntkrnqnl0es4nyxghp3petpn2ntu3t",
}
network.SetupZetaGenesisState(s.T(), s.cfg.GenesisState, s.cfg.Codec, observerList, false)
s.ballots = RandomBallotGenerator(20, observerList)
s.ballots = RandomBallotGenerator(s.T(), 20, observerList)
network.AddObserverData(s.T(), 2, s.cfg.GenesisState, s.cfg.Codec, s.ballots)

net, err := network.New(s.T(), app.NodeDir, s.cfg)
Expand All @@ -63,32 +65,42 @@ func (s *CliTestSuite) SetupSuite() {

}

func CreateRandomVoteList(numberOfVotes int) []observerTypes.VoteType {
func CreateRandomVoteList(t *testing.T, numberOfVotes int) []observerTypes.VoteType {
voteOptions := []observerTypes.VoteType{observerTypes.VoteType_SuccessObservation, observerTypes.VoteType_FailureObservation, observerTypes.VoteType_NotYetVoted}
min := 0
max := len(voteOptions) - 1
minVoterOptions := 0
maxBoterOptions := len(voteOptions) - 1

randomVoteOptions, err := rand.Int(rand.Reader, big.NewInt(int64(maxBoterOptions-minVoterOptions)))
if err != nil {
t.Fatal(err)
}

voteList := make([]observerTypes.VoteType, numberOfVotes)
for i := 0; i < numberOfVotes; i++ {
voteList[i] = voteOptions[rand.Intn(max-min)+min] // #nosec G404
voteList[i] = voteOptions[randomVoteOptions.Int64()]
}
return voteList
}
func RandomBallotGenerator(numberOfBallots int, voterList []string) []*observerTypes.Ballot {
func RandomBallotGenerator(t *testing.T, numberOfBallots int, voterList []string) []*observerTypes.Ballot {
ballots := make([]*observerTypes.Ballot, numberOfBallots)
ballotStatus := []observerTypes.BallotStatus{observerTypes.BallotStatus_BallotFinalized_FailureObservation, observerTypes.BallotStatus_BallotFinalized_SuccessObservation}
min := 0
max := len(ballotStatus) - 1
// #nosec G404 randomness is not a security issue here
minBallotStatus := 0
maxBallotStatus := len(ballotStatus) - 1

randomBallotStatus, err := rand.Int(rand.Reader, big.NewInt(int64(maxBallotStatus-minBallotStatus)))
if err != nil {
t.Fatal(err)
}

for i := 0; i < numberOfBallots; i++ {
ballots[i] = &observerTypes.Ballot{
Index: "",
BallotIdentifier: "TestBallot" + strconv.Itoa(i),
VoterList: voterList,
Votes: CreateRandomVoteList(len(voterList)),
ObservationType: observerTypes.ObservationType_InBoundTx,
BallotThreshold: sdk.MustNewDecFromStr("0.66"),
// #nosec G404 randomness used for testing
BallotStatus: ballotStatus[rand.Intn(max-min)+min],
Index: "",
BallotIdentifier: "TestBallot" + strconv.Itoa(i),
VoterList: voterList,
Votes: CreateRandomVoteList(t, len(voterList)),
ObservationType: observerTypes.ObservationType_InBoundTx,
BallotThreshold: sdk.MustNewDecFromStr("0.66"),
BallotStatus: ballotStatus[randomBallotStatus.Int64()],
BallotCreationHeight: 0,
}
}
Expand Down
Loading

0 comments on commit 1356e82

Please sign in to comment.