Skip to content

Commit

Permalink
Merge branch 'develop' into feat/pkg-ticker
Browse files Browse the repository at this point in the history
# Conflicts:
#	zetaclient/chains/evm/observer/inbound.go
  • Loading branch information
swift1337 committed Aug 6, 2024
2 parents 5cb4839 + eb61f2d commit b99bd95
Show file tree
Hide file tree
Showing 109 changed files with 5,018 additions and 2,747 deletions.
17 changes: 13 additions & 4 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,26 @@ concurrency:
cancel-in-progress: false

jobs:
check_branch:
check-branch:
if: ${{ (startsWith(github.ref, 'refs/heads/release/v') || startsWith(github.ref, 'refs/heads/hotfix/v')) }}
runs-on: ubuntu-22.04
steps:
- name: Branch
run: |
echo "${{ github.ref }}"
check-goreleaser:
needs:
- check-branch
runs-on: ubuntu-22.04
steps:
- name: Branch
run: |
make release-dry-run
check-changelog:
needs:
- check_branch
- check-branch
runs-on: ubuntu-22.04
steps:

Expand Down Expand Up @@ -75,7 +84,7 @@ jobs:
check-upgrade-handler-updated:
needs:
- check_branch
- check-branch
runs-on: ubuntu-22.04
timeout-minutes: 10
steps:
Expand Down Expand Up @@ -114,7 +123,7 @@ jobs:
needs:
- check-changelog
- check-upgrade-handler-updated
- check_branch
- check-branch
runs-on: ubuntu-22.04
timeout-minutes: 60
environment: release
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ start-upgrade-import-mainnet-test: zetanode-upgrade
###############################################################################

PACKAGE_NAME := github.com/zeta-chain/node
GOLANG_CROSS_VERSION ?= v1.20.7
GOLANG_CROSS_VERSION ?= v1.22.4
GOPATH ?= '$(HOME)/go'
release-dry-run:
docker run \
Expand All @@ -334,7 +334,7 @@ release-dry-run:
-v ${GOPATH}/pkg:/go/pkg \
-w /go/src/$(PACKAGE_NAME) \
ghcr.io/goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \
--clean --skip-validate --skip-publish --snapshot
--clean --skip=validate --skip=publish --snapshot

release:
@if [ ! -f ".release-env" ]; then \
Expand All @@ -350,7 +350,7 @@ 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 ###
Expand Down Expand Up @@ -430,4 +430,4 @@ filter-missed-eth: install-zetatool
zetatool filterdeposit eth \
--config ./tool/filter_missed_deposits/zetatool_config.json \
--evm-max-range 1000 \
--evm-start-block 19464041
--evm-start-block 19464041
5 changes: 4 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@
* [2518](https://github.com/zeta-chain/node/pull/2518) - add support for Solana address in zetacore
* [2483](https://github.com/zeta-chain/node/pull/2483) - add priorityFee (gasTipCap) gas to the state
* [2567](https://github.com/zeta-chain/node/pull/2567) - add sign latency metric to zetaclient (zetaclient_sign_latency)
* [2524](https://github.com/zeta-chain/node/pull/2524) - add inscription envolop parsing
* [2524](https://github.com/zeta-chain/node/pull/2524) - add inscription envelop parsing
* [2560](https://github.com/zeta-chain/node/pull/2560) - add support for Solana SOL token withdraw
* [2533](https://github.com/zeta-chain/node/pull/2533) - parse memo from both OP_RETURN and inscription

### Refactor

Expand Down Expand Up @@ -78,6 +80,7 @@
* [2542](https://github.com/zeta-chain/node/pull/2542) - adjust permissions to be more restrictive
* [2572](https://github.com/zeta-chain/node/pull/2572) - turn off IBC modules
* [2556](https://github.com/zeta-chain/node/pull/2556) - refactor migrator length check to use consensus type
* [2568](https://github.com/zeta-chain/node/pull/2568) - improve AppContext by converging chains, chainParams, enabledChains, and additionalChains into a single zctx.Chain

### Tests

Expand Down
93 changes: 46 additions & 47 deletions cmd/zetaclientd/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ package main
import (
"context"
"fmt"
"os"
"strconv"
"strings"

"cosmossdk.io/errors"
"github.com/btcsuite/btcd/rpcclient"
sdk "github.com/cosmos/cosmos-sdk/types"
ethcommon "github.com/ethereum/go-ethereum/common"
Expand All @@ -14,10 +16,8 @@ import (
"github.com/rs/zerolog"
"github.com/spf13/cobra"

"github.com/zeta-chain/zetacore/pkg/chains"
"github.com/zeta-chain/zetacore/pkg/coin"
"github.com/zeta-chain/zetacore/testutil/sample"
observertypes "github.com/zeta-chain/zetacore/x/observer/types"
btcobserver "github.com/zeta-chain/zetacore/zetaclient/chains/bitcoin/observer"
evmobserver "github.com/zeta-chain/zetacore/zetaclient/chains/evm/observer"
"github.com/zeta-chain/zetacore/zetaclient/config"
Expand All @@ -35,11 +35,14 @@ type debugArguments struct {
}

func init() {
RootCmd.AddCommand(DebugCmd())
DebugCmd().Flags().
StringVar(&debugArgs.zetaCoreHome, "core-home", "/Users/tanmay/.zetacored", "peer address, e.g. /dns/tss1/tcp/6668/ipfs/16Uiu2HAmACG5DtqmQsHtXg4G2sLS65ttv84e7MrL4kapkjfmhxAp")
DebugCmd().Flags().StringVar(&debugArgs.zetaNode, "node", "46.4.15.110", "public ip address")
DebugCmd().Flags().StringVar(&debugArgs.zetaChainID, "chain-id", "athens_7001-1", "pre-params file path")
defaultHomeDir := os.ExpandEnv("$HOME/.zetacored")

cmd := DebugCmd()
cmd.Flags().StringVar(&debugArgs.zetaCoreHome, "core-home", defaultHomeDir, "zetacore home directory")
cmd.Flags().StringVar(&debugArgs.zetaNode, "node", "46.4.15.110", "public ip address")
cmd.Flags().StringVar(&debugArgs.zetaChainID, "chain-id", "athens_7001-1", "pre-params file path")

RootCmd.AddCommand(cmd)
}

func DebugCmd() *cobra.Command {
Expand All @@ -54,20 +57,16 @@ func debugCmd(_ *cobra.Command, args []string) error {
cobra.ExactArgs(2)
cfg, err := config.Load(debugArgs.zetaCoreHome)
if err != nil {
return err
return errors.Wrap(err, "failed to load config")
}

appContext := zctx.New(cfg, zerolog.Nop())
ctx := zctx.WithAppContext(context.Background(), appContext)
inboundHash := args[0]

chainID, err := strconv.ParseInt(args[1], 10, 64)
if err != nil {
return err
return errors.Wrap(err, "failed to parse chain id")
}

inboundHash := args[0]
var ballotIdentifier string

// create a new zetacore client
client, err := zetacore.NewClient(
&keys.Keys{OperatorAddress: sdk.MustAccAddressFromBech32(sample.AccAddress())},
Expand All @@ -80,21 +79,30 @@ func debugCmd(_ *cobra.Command, args []string) error {
if err != nil {
return err
}
chainParams, err := client.GetChainParams(ctx)
if err != nil {
return err

appContext := zctx.New(cfg, zerolog.Nop())
ctx := zctx.WithAppContext(context.Background(), appContext)

if err := client.UpdateAppContext(ctx, appContext, zerolog.Nop()); err != nil {
return errors.Wrap(err, "failed to update app context")
}

var ballotIdentifier string

tssEthAddress, err := client.GetEVMTSSAddress(ctx)
if err != nil {
return err
}
chain, found := chains.GetChainFromChainID(chainID, appContext.GetAdditionalChains())
if !found {
return fmt.Errorf("invalid chain id")

chain, err := appContext.GetChain(chainID)
if err != nil {
return err
}

chainProto := chain.RawChain()

// get ballot identifier according to the chain type
if chains.IsEVMChain(chain.ChainId, appContext.GetAdditionalChains()) {
if chain.IsEVM() {
evmObserver := evmobserver.Observer{}
evmObserver.WithZetacoreClient(client)
var ethRPC *ethrpc.EthRPC
Expand All @@ -109,43 +117,34 @@ func debugCmd(_ *cobra.Command, args []string) error {
}
evmObserver.WithEvmClient(client)
evmObserver.WithEvmJSONRPC(ethRPC)
evmObserver.WithChain(chain)
evmObserver.WithChain(*chainProto)
}
}
hash := ethcommon.HexToHash(inboundHash)
tx, isPending, err := evmObserver.TransactionByHash(inboundHash)
if err != nil {
return fmt.Errorf("tx not found on chain %s , %d", err.Error(), chain.ChainId)
return fmt.Errorf("tx not found on chain %s, %d", err.Error(), chain.ID())
}

if isPending {
return fmt.Errorf("tx is still pending")
}

receipt, err := client.TransactionReceipt(context.Background(), hash)
if err != nil {
return fmt.Errorf("tx receipt not found on chain %s, %d", err.Error(), chain.ChainId)
return fmt.Errorf("tx receipt not found on chain %s, %d", err.Error(), chain.ID())
}

for _, chainParams := range chainParams {
if chainParams.ChainId == chainID {
evmObserver.SetChainParams(observertypes.ChainParams{
ChainId: chainID,
ConnectorContractAddress: chainParams.ConnectorContractAddress,
ZetaTokenContractAddress: chainParams.ZetaTokenContractAddress,
Erc20CustodyContractAddress: chainParams.Erc20CustodyContractAddress,
})
evmChainParams, found := appContext.GetEVMChainParams(chainID)
if !found {
return fmt.Errorf("missing chain params for chain %d", chainID)
}
evmChainParams.ZetaTokenContractAddress = chainParams.ZetaTokenContractAddress
if strings.EqualFold(tx.To, chainParams.ConnectorContractAddress) {
coinType = coin.CoinType_Zeta
} else if strings.EqualFold(tx.To, chainParams.Erc20CustodyContractAddress) {
coinType = coin.CoinType_ERC20
} else if strings.EqualFold(tx.To, tssEthAddress) {
coinType = coin.CoinType_Gas
}
}
params := chain.Params()

evmObserver.SetChainParams(*params)

if strings.EqualFold(tx.To, params.ConnectorContractAddress) {
coinType = coin.CoinType_Zeta
} else if strings.EqualFold(tx.To, params.Erc20CustodyContractAddress) {
coinType = coin.CoinType_ERC20
} else if strings.EqualFold(tx.To, tssEthAddress) {
coinType = coin.CoinType_Gas
}

switch coinType {
Expand All @@ -170,10 +169,10 @@ func debugCmd(_ *cobra.Command, args []string) error {
fmt.Println("CoinType not detected")
}
fmt.Println("CoinType : ", coinType)
} else if chains.IsBitcoinChain(chain.ChainId, appContext.GetAdditionalChains()) {
} else if chain.IsUTXO() {
btcObserver := btcobserver.Observer{}
btcObserver.WithZetacoreClient(client)
btcObserver.WithChain(chain)
btcObserver.WithChain(*chainProto)
connCfg := &rpcclient.ConnConfig{
Host: cfg.BitcoinConfig.RPCHost,
User: cfg.BitcoinConfig.RPCUsername,
Expand Down
14 changes: 13 additions & 1 deletion cmd/zetaclientd/init.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package main

import (
"path"

"github.com/rs/zerolog"
"github.com/spf13/cobra"

Expand Down Expand Up @@ -36,6 +38,7 @@ type initArguments struct {
KeyringBackend string
HsmMode bool
HsmHotKey string
SolanaKey string
}

func init() {
Expand Down Expand Up @@ -69,6 +72,7 @@ func init() {
InitCmd.Flags().BoolVar(&initArgs.HsmMode, "hsm-mode", false, "enable hsm signer, default disabled")
InitCmd.Flags().
StringVar(&initArgs.HsmHotKey, "hsm-hotkey", "hsm-hotkey", "name of hotkey associated with hardware security module")
InitCmd.Flags().StringVar(&initArgs.SolanaKey, "solana-key", "solana-key.json", "solana key file name")
}

func Initialize(_ *cobra.Command, _ []string) error {
Expand Down Expand Up @@ -106,8 +110,16 @@ func Initialize(_ *cobra.Command, _ []string) error {
configData.KeyringBackend = config.KeyringBackend(initArgs.KeyringBackend)
configData.HsmMode = initArgs.HsmMode
configData.HsmHotKey = initArgs.HsmHotKey
configData.SolanaKeyFile = initArgs.SolanaKey
configData.ComplianceConfig = testutils.ComplianceConfigTest()

//Save config file
// Save solana test fee payer key file
keyFile := path.Join(rootArgs.zetaCoreHome, initArgs.SolanaKey)
err = createSolanaTestKeyFile(keyFile)
if err != nil {
return err
}

// Save config file
return config.Save(&configData, rootArgs.zetaCoreHome)
}
37 changes: 37 additions & 0 deletions cmd/zetaclientd/solana_test_key.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package main

import (
"encoding/json"
"os"
)

// solanaTestKey is a local test private key for Solana
// TODO: use separate keys for each zetaclient in Solana E2E tests
// https://github.com/zeta-chain/node/issues/2614
var solanaTestKey = []uint8{
199, 16, 63, 28, 125, 103, 131, 13, 6, 94, 68, 109, 13, 68, 132, 17,
71, 33, 216, 51, 49, 103, 146, 241, 245, 162, 90, 228, 71, 177, 32, 199,
31, 128, 124, 2, 23, 207, 48, 93, 141, 113, 91, 29, 196, 95, 24, 137,
170, 194, 90, 4, 124, 113, 12, 222, 166, 209, 119, 19, 78, 20, 99, 5,
}

// createSolanaTestKeyFile creates a solana test key json file
func createSolanaTestKeyFile(keyFile string) error {
// marshal the byte array to JSON
keyBytes, err := json.Marshal(solanaTestKey)
if err != nil {
return err
}

// create file (or overwrite if it already exists)
// #nosec G304 -- for E2E testing purposes only
file, err := os.Create(keyFile)
if err != nil {
return err
}
defer file.Close()

// write the key bytes to the file
_, err = file.Write(keyBytes)
return err
}
Loading

0 comments on commit b99bd95

Please sign in to comment.