Skip to content

Commit

Permalink
conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
lumtis committed Jan 9, 2024
2 parents 1ff2a34 + 179799d commit 279bebe
Show file tree
Hide file tree
Showing 155 changed files with 4,668 additions and 3,648 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,12 @@ jobs:
skip_aws_cli: "true"
skip_docker_compose: "false"

# - name: Login to Docker Hub
# uses: docker/login-action@v2
# if: github.event.repository.full_name == 'zetachain-chain/node'
# with:
# username: ${{ secrets.DOCKER_HUB_USERNAME }}
# password: ${{ secrets.DOCKER_HUB_READ_ONLY }}
- name: Login to Docker Hub
uses: docker/login-action@v2
if: github.event.repository.full_name == 'zetachain-chain/node'
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_READ_ONLY }}

- name: Build zetanode
run: |
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/publish-typescript.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Publish Typescript to NPM
on:
workflow_dispatch:
release:
types: [created]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'

- name: Set Version
working-directory: typescript
run: |
version=$(cat app/setup_handlers.go | grep "const releaseVersion" | cut -d ' ' -f4 | tr -d '"')
npm version ${version}
sed -i 's/@zetachain\/blockchain-types/@zetachain\/node-types/' package.json
- name: Install dependencies and build 🔧
working-directory: typescript
run: npm ci && npm run build

- name: Publish package on NPM 📦
run: npm publish
working-directory: typescript
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
4 changes: 3 additions & 1 deletion app/setup_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/x/upgrade/types"
crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types"
observertypes "github.com/zeta-chain/zetacore/x/observer/types"
)

const releaseVersion = "v12.0.0"
Expand All @@ -17,7 +18,8 @@ func SetupHandlers(app *App) {
for m, mb := range app.mm.Modules {
vm[m] = mb.ConsensusVersion()
}
vm[crosschaintypes.ModuleName] = vm[crosschaintypes.ModuleName] - 1
vm[crosschaintypes.ModuleName] = 3
vm[observertypes.ModuleName] = 4
return app.mm.RunMigrations(ctx, app.configurator, vm)
})

Expand Down
8 changes: 8 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@

## Unreleased

* ci: adding typescript publishing pipeline.

### Breaking Changes

* PendingNonces :Changed from `/zeta-chain/crosschain/pendingNonces/{chain_id}/{address}` to `/zeta-chain/observer/pendingNonces/{chain_id}/{address}` . It returns all the pending nonces for a chain id and address. This returns the current pending nonces for the chain.
* ChainNonces : Changed from `/zeta-chain/criosschain/chainNonces/{chain_id}` to`/zeta-chain/observer/chainNonces/{chain_id}` . It returns all the chain nonces for a chain id. This returns the current nonce oof the TSS address for the chain.
* ChainNoncesAll :Changed from `/zeta-chain/observer/chainNonces` to `/zeta-chain/observer/chainNonces` . It returns all the chain nonces for all chains. This returns the current nonce of the TSS address for all chains.

### Features

* [1395](https://github.com/zeta-chain/node/pull/1395) - Add state variable to track aborted zeta amount
* [1410](https://github.com/zeta-chain/node/pull/1410) - `snapshots` commands
* enable zetaclients to use dynamic gas price on zetachain - enables >0 min_gas_price in feemarket module
Expand All @@ -17,6 +20,7 @@

### Fixes

* [1496](https://github.com/zeta-chain/node/issues/1496) - post block header for enabled EVM chains only
* [1518](https://github.com/zeta-chain/node/pull/1518) - Avoid duplicate keysign if an outTx is already pending
* fix Code4rena issue - zetaclients potentially miss inTx when PostSend (or other RPC) fails
* fix go-staticcheck warnings for zetaclient
Expand All @@ -26,7 +30,9 @@
* add check to verify new tss has been produced when triggering tss funds migration
* fix Athens-3 log print issue - avoid posting uncessary outtx confirmation
* fix docker build issues with version: golang:1.20-alpine3.18
* [1525](https://github.com/zeta-chain/node/pull/1525) - relax EVM chain block header length check 1024->4096
* [1522](https://github.com/zeta-chain/node/pull/1522/files) - block `distribution` module account from receiving zeta
* [1528](https://github.com/zeta-chain/node/pull/1528) - fix panic caused on decoding malformed BTC addresses

### Refactoring

Expand All @@ -39,6 +45,8 @@
* Add pagination to queries which iterate over large data sets InTxTrackerAll ,PendingNoncesAll ,AllBlameRecord ,TssHistory
* GetTssAddress now returns only the current tss address for ETH and BTC
* Add a new query GetTssAddressesByFinalizedBlockHeight to get any other tss addresses for a finalized block height
* Move observer params into core params
* Remove chain id from the index for observer mapper and rename it to observer set.
* Add logger to smoke tests
* [1521](https://github.com/zeta-chain/node/pull/1521) - replace go-tss lib version with one that reverts back to thorchain tss-lib

Expand Down
20 changes: 10 additions & 10 deletions cmd/zetaclientd/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func DebugCmd() *cobra.Command {
if err != nil {
return err
}
coreParams, err := bridge.GetCoreParams()
chainParams, err := bridge.GetChainParams()
if err != nil {
return err
}
Expand Down Expand Up @@ -115,19 +115,19 @@ func DebugCmd() *cobra.Command {
return fmt.Errorf("tx is still pending")
}

for _, chainCoreParams := range coreParams {
if chainCoreParams.ChainId == chainID {
ob.WithParams(observertypes.CoreParams{
for _, chainParams := range chainParams {
if chainParams.ChainId == chainID {
ob.WithParams(observertypes.ChainParams{
ChainId: chainID,
ConnectorContractAddress: chainCoreParams.ConnectorContractAddress,
ZetaTokenContractAddress: chainCoreParams.ZetaTokenContractAddress,
Erc20CustodyContractAddress: chainCoreParams.Erc20CustodyContractAddress,
ConnectorContractAddress: chainParams.ConnectorContractAddress,
ZetaTokenContractAddress: chainParams.ZetaTokenContractAddress,
Erc20CustodyContractAddress: chainParams.Erc20CustodyContractAddress,
})
cfg.EVMChainConfigs[chainID].ZetaTokenContractAddress = chainCoreParams.ZetaTokenContractAddress
cfg.EVMChainConfigs[chainID].ZetaTokenContractAddress = chainParams.ZetaTokenContractAddress
ob.SetConfig(cfg)
if strings.EqualFold(tx.To().Hex(), chainCoreParams.ConnectorContractAddress) {
if strings.EqualFold(tx.To().Hex(), chainParams.ConnectorContractAddress) {
coinType = common.CoinType_Zeta
} else if strings.EqualFold(tx.To().Hex(), chainCoreParams.Erc20CustodyContractAddress) {
} else if strings.EqualFold(tx.To().Hex(), chainParams.Erc20CustodyContractAddress) {
coinType = common.CoinType_ERC20
} else if strings.EqualFold(tx.To().Hex(), tssEthAddress) {
coinType = common.CoinType_Gas
Expand Down
2 changes: 1 addition & 1 deletion cmd/zetaclientd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func start(_ *cobra.Command, _ []string) error {
startLogger.Error().Msgf("No chains enabled in updated config %s ", cfg.String())
}

observerList, err := zetaBridge.GetObserverList(cfg.ChainsEnabled[0])
observerList, err := zetaBridge.GetObserverList()
if err != nil {
startLogger.Error().Err(err).Msg("GetObserverList error")
return err
Expand Down
6 changes: 3 additions & 3 deletions cmd/zetaclientd/start_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ func maskCfg(cfg *config.Config) string {
maskedCfg.EVMChainConfigs = map[int64]*config.EVMConfig{}
for key, val := range cfg.EVMChainConfigs {
maskedCfg.EVMChainConfigs[key] = &config.EVMConfig{
CoreParams: val.CoreParams,
Chain: val.Chain,
Endpoint: val.Endpoint,
ChainParams: val.ChainParams,
Chain: val.Chain,
Endpoint: val.Endpoint,
}
}

Expand Down
4 changes: 2 additions & 2 deletions cmd/zetaclientd/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ func CreateSignerMap(
if evmConfig.Chain.IsZetaChain() {
continue
}
mpiAddress := ethcommon.HexToAddress(evmConfig.CoreParams.ConnectorContractAddress)
erc20CustodyAddress := ethcommon.HexToAddress(evmConfig.CoreParams.Erc20CustodyContractAddress)
mpiAddress := ethcommon.HexToAddress(evmConfig.ChainParams.ConnectorContractAddress)
erc20CustodyAddress := ethcommon.HexToAddress(evmConfig.ChainParams.Erc20CustodyContractAddress)
signer, err := zetaclient.NewEVMSigner(evmConfig.Chain, evmConfig.Endpoint, tss, config.GetConnectorABI(), config.GetERC20CustodyABI(), mpiAddress, erc20CustodyAddress, logger, ts)
if err != nil {
logger.Error().Err(err).Msgf("NewEVMSigner error for chain %s", evmConfig.Chain.String())
Expand Down
25 changes: 5 additions & 20 deletions cmd/zetacored/observer_accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,11 @@ func AddObserverAccountsCmd() *cobra.Command {
if err != nil {
return err
}
var observerMapper []*types.ObserverMapper
var observerSet types.ObserverSet
var grantAuthorizations []authz.GrantAuthorization
var nodeAccounts []*types.NodeAccount
var keygenPubKeys []string
observersForChain := map[int64][]string{}

// DefaultChainsList is based on Build Flags
supportedChains := common.DefaultChainsList()
var balances []banktypes.Balance
validatorTokens, ok := sdk.NewIntFromString(ValidatorTokens)
if !ok {
Expand Down Expand Up @@ -115,9 +112,8 @@ func AddObserverAccountsCmd() *cobra.Command {
panic("ZetaClientGranteeAddress or ObserverAddress is empty")
}
grantAuthorizations = append(grantAuthorizations, generateGrants(info)...)
for _, chain := range supportedChains {
observersForChain[chain.ChainId] = append(observersForChain[chain.ChainId], info.ObserverAddress)
}

observerSet.ObserverList = append(observerSet.ObserverList, info.ObserverAddress)
if info.ZetaClientGranteePubKey != "" {
pubkey, err := common.NewPubKey(info.ZetaClientGranteePubKey)
if err != nil {
Expand All @@ -143,17 +139,6 @@ func AddObserverAccountsCmd() *cobra.Command {
keygenPubKeys = append(keygenPubKeys, info.ZetaClientGranteePubKey)
}

// Generate observer mappers for each chain
for chainID, observers := range observersForChain {
observers = removeDuplicate(observers)
chain := common.GetChainFromChainID(chainID)
mapper := types.ObserverMapper{
ObserverChain: chain,
ObserverList: observers,
}
observerMapper = append(observerMapper, &mapper)
}

genFile := serverConfig.GenesisFile()
appState, genDoc, err := genutiltypes.GenesisStateFromGenFile(genFile)
if err != nil {
Expand All @@ -176,10 +161,10 @@ func AddObserverAccountsCmd() *cobra.Command {
KeyGenZetaHeight: 0,
}
}

observerSet.ObserverList = removeDuplicate(observerSet.ObserverList)
// Add observers to observer genesis state
zetaObserverGenState := types.GetGenesisStateFromAppState(cdc, appState)
zetaObserverGenState.Observers = observerMapper
zetaObserverGenState.Observers = observerSet
zetaObserverGenState.NodeAccountList = nodeAccounts
zetaObserverGenState.Tss = &tss
keyGenStatus := types.KeygenStatus_PendingKeygen
Expand Down
37 changes: 37 additions & 0 deletions common/address.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package common

import (
"errors"
"fmt"
"strings"

"github.com/btcsuite/btcutil"
eth "github.com/ethereum/go-ethereum/common"
"github.com/zeta-chain/zetacore/common/cosmos"
)
Expand Down Expand Up @@ -41,3 +44,37 @@ func (addr Address) IsEmpty() bool {
func (addr Address) String() string {
return string(addr)
}

func ConvertRecoverToError(r interface{}) error {
switch x := r.(type) {
case string:
return errors.New(x)
case error:
return x
default:
return fmt.Errorf("%v", x)
}
}

func DecodeBtcAddress(inputAddress string, chainID int64) (address btcutil.Address, err error) {
defer func() {
if r := recover(); r != nil {
err = ConvertRecoverToError(r)
err = fmt.Errorf("input address:%s, chainId:%d, err:%s", inputAddress, chainID, err.Error())
return
}
}()
chainParams, err := GetBTCChainParams(chainID)
if err != nil {
return nil, err
}
if chainParams == nil {
return nil, fmt.Errorf("chain params not found")
}
address, err = btcutil.DecodeAddress(inputAddress, chainParams)
ok := address.IsForNet(chainParams)
if !ok {
return nil, fmt.Errorf("address is not for network %s", chainParams.Name)
}
return
}
20 changes: 20 additions & 0 deletions common/address_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,23 @@ func TestAddress(t *testing.T) {
addr = NewAddress("0x90f2b1ae50e6018230e90a33f98c7844a0ab635a")
require.EqualValuesf(t, "0x90f2b1ae50e6018230e90a33f98c7844a0ab635a", addr.String(), "address string should be equal")
}

func TestDecodeBtcAddress(t *testing.T) {
t.Run("invalid string", func(t *testing.T) {
_, err := DecodeBtcAddress("�U�ڷ���i߭����꿚�l", 18332)
require.ErrorContains(t, err, "runtime error: index out of range")
})
t.Run("invalid chain", func(t *testing.T) {
_, err := DecodeBtcAddress("14CEjTd5ci3228J45GdnGeUKLSSeCWUQxK", 0)
require.ErrorContains(t, err, "is not a Bitcoin chain")
})
t.Run("nil pointer dereference", func(t *testing.T) {
_, err := DecodeBtcAddress("tb1qy9pqmk2pd9sv63g27jt8r657wy0d9uee4x2dt2", 18332)
require.ErrorContains(t, err, "runtime error: invalid memory address or nil pointer dereference")
})
t.Run("valid address", func(t *testing.T) {
_, err := DecodeBtcAddress("bcrt1qy9pqmk2pd9sv63g27jt8r657wy0d9uee4x2dt2", 18444)
require.NoError(t, err)
})

}
10 changes: 1 addition & 9 deletions common/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (chain Chain) EncodeAddress(b []byte) (string, error) {
if err != nil {
return "", err
}
addr, err := btcutil.DecodeAddress(addrStr, chainParams)
addr, err := DecodeBtcAddress(addrStr, chain.ChainId)
if err != nil {
return "", err
}
Expand Down Expand Up @@ -189,14 +189,6 @@ func GetChainFromChainID(chainID int64) *Chain {
return nil
}

func GetChainNameFromChainID(chainID int64) (string, error) {
chain := GetChainFromChainID(chainID)
if chain == nil {
return "", fmt.Errorf("chain %d not found", chainID)
}
return chain.GetChainName().String(), nil
}

func GetBTCChainParams(chainID int64) (*chaincfg.Params, error) {
switch chainID {
case 18444:
Expand Down
2 changes: 1 addition & 1 deletion common/headers.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func (h HeaderData) Validate(blockHash []byte, chainID int64, height int64) erro
// validateEthereumHeader performs a basic validation of the Ethereum header
func validateEthereumHeader(headerBytes []byte, blockHash []byte, height int64) error {
// on ethereum the block header is ~538 bytes in RLP encoding
if len(headerBytes) > 1024 {
if len(headerBytes) > 4096 {
return fmt.Errorf("header too long (%d)", len(headerBytes))
}

Expand Down
3 changes: 2 additions & 1 deletion contrib/localnet/orchestrator/smoketest/runner/setup_zeta.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ func (sm *SmokeTestRunner) SetTSSAddresses() {
}

tssAddress := ethcommon.HexToAddress(res.Eth)
btcTSSAddress, err := btcutil.DecodeAddress(res.Btc, common.BitcoinRegnetParams)

btcTSSAddress, err := common.DecodeBtcAddress(res.Btc, common.BtcRegtestChain().ChainId)
if err != nil {
panic(err)
}
Expand Down
Loading

0 comments on commit 279bebe

Please sign in to comment.