Skip to content

Commit

Permalink
Merge branch 'develop' into test/e2e-panics
Browse files Browse the repository at this point in the history
# Conflicts:
#	cmd/zetae2e/local/local.go
  • Loading branch information
swift1337 committed Jun 21, 2024
2 parents 904c161 + f9ca2be commit d0fa305
Show file tree
Hide file tree
Showing 135 changed files with 2,173 additions and 1,691 deletions.
5 changes: 3 additions & 2 deletions Dockerfile-localnet
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ RUN mkdir -p /root/.zetacored/cosmovisor/genesis/bin && \
ENV PATH /root/.zetacored/cosmovisor/current/bin/:/root/.zetaclientd/upgrades/current/:${PATH}

COPY contrib/localnet/scripts /root
COPY contrib/localnet/ssh_config /root/.ssh/config
COPY contrib/localnet/ssh_config /etc/ssh/ssh_config.d/localnet.conf
COPY contrib/localnet/zetacored /root/zetacored

RUN chmod 755 /root/*.sh
RUN chmod 755 /root/*.sh && \
chmod 644 /etc/ssh/ssh_config.d/localnet.conf

WORKDIR /usr/local/bin
EXPOSE 22
Expand Down
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,11 @@ start-localnet-skip-build:
cd contrib/localnet/ && $(DOCKER) compose -f docker-compose.yml -f docker-compose-setup-only.yml up -d

stop-localnet:
start-e2e-import-mainnet-test: zetanode
@echo "--> Starting e2e import-data test"
cd contrib/localnet/ && ./scripts/import-data.sh mainnet && $(DOCKER) compose -f docker-compose.yml -f docker-compose-import-data.yml up -d

stop-test:
cd contrib/localnet/ && $(DOCKER) compose down --remove-orphans

###############################################################################
Expand Down
9 changes: 0 additions & 9 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ import (

"github.com/zeta-chain/zetacore/app/ante"
"github.com/zeta-chain/zetacore/docs/openapi"
"github.com/zeta-chain/zetacore/pkg/chains"
zetamempool "github.com/zeta-chain/zetacore/pkg/mempool"
srvflags "github.com/zeta-chain/zetacore/server/flags"
authoritymodule "github.com/zeta-chain/zetacore/x/authority"
Expand Down Expand Up @@ -598,14 +597,6 @@ func New(
app.LightclientKeeper,
)

// initializing map of cctx gateways so crosschain module can decide which one to use
// based on chain info of destination chain
cctxGateways := map[chains.CCTXGateway]crosschainkeeper.CCTXGateway{
chains.CCTXGateway_observers: crosschainkeeper.NewCCTXGatewayObservers(app.CrosschainKeeper),
chains.CCTXGateway_zevm: crosschainkeeper.NewCCTXGatewayZEVM(app.CrosschainKeeper),
}
app.CrosschainKeeper.SetCCTXGateways(cctxGateways)

// initialize ibccrosschain keeper and set it to the crosschain keeper
// there is a circular dependency between the two keepers, crosschain keeper must be initialized first

Expand Down
121 changes: 63 additions & 58 deletions changelog.md

Large diffs are not rendered by default.

5 changes: 0 additions & 5 deletions cmd/zetaclientd/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package main
import (
"context"
"fmt"
"io"
"strconv"
"strings"
"sync"
Expand All @@ -13,7 +12,6 @@ import (
ethcommon "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/onrik/ethrpc"
"github.com/rs/zerolog"
"github.com/spf13/cobra"

"github.com/zeta-chain/zetacore/pkg/chains"
Expand Down Expand Up @@ -61,7 +59,6 @@ func DebugCmd() *cobra.Command {
}
inboundHash := args[0]
var ballotIdentifier string
chainLogger := zerolog.New(io.Discard).Level(zerolog.Disabled)

// create a new zetacore client
client, err := zetacore.NewClient(
Expand Down Expand Up @@ -93,7 +90,6 @@ func DebugCmd() *cobra.Command {
Mu: &sync.Mutex{},
}
evmObserver.WithZetacoreClient(client)
evmObserver.WithLogger(chainLogger)
var ethRPC *ethrpc.EthRPC
var client *ethclient.Client
coinType := coin.CoinType_Cmd
Expand Down Expand Up @@ -172,7 +168,6 @@ func DebugCmd() *cobra.Command {
Mu: &sync.Mutex{},
}
btcObserver.WithZetacoreClient(client)
btcObserver.WithLogger(chainLogger)
btcObserver.WithChain(*chains.GetChainFromChainID(chainID))
connCfg := &rpcclient.ConnConfig{
Host: cfg.BitcoinConfig.RPCHost,
Expand Down
40 changes: 40 additions & 0 deletions cmd/zetaclientd/gen_pre_params.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package main

import (
"encoding/json"
"fmt"
"os"
"time"

"github.com/binance-chain/tss-lib/ecdsa/keygen"
"github.com/spf13/cobra"
)

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

var GenPrePramsCmd = &cobra.Command{
Use: "gen-pre-params <path>",
Short: "Generate pre parameters for TSS",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
startTime := time.Now()
preParams, err := keygen.GeneratePreParams(time.Second * 300)
if err != nil {
return err
}

file, err := os.OpenFile(args[0], os.O_RDWR|os.O_CREATE, 0600)
if err != nil {
return err
}
defer file.Close()
err = json.NewEncoder(file).Encode(preParams)
if err != nil {
return err
}
fmt.Printf("Generated new pre-parameters in %v\n", time.Since(startTime))
return nil
},
}
17 changes: 9 additions & 8 deletions cmd/zetaclientd/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,22 @@ func CreateZetacoreClient(
return client, nil
}

// CreateSignerMap creates a map of ChainSigners for all chains in the config
func CreateSignerMap(
appContext *context.AppContext,
tss interfaces.TSSSigner,
logger base.Logger,
ts *metrics.TelemetryServer,
) (map[int64]interfaces.ChainSigner, error) {
coreContext := appContext.ZetacoreContext()
zetacoreContext := appContext.ZetacoreContext()
signerMap := make(map[int64]interfaces.ChainSigner)

// EVM signers
for _, evmConfig := range appContext.Config().GetAllEVMConfigs() {
if evmConfig.Chain.IsZetaChain() {
continue
}
evmChainParams, found := coreContext.GetEVMChainParams(evmConfig.Chain.ChainId)
evmChainParams, found := zetacoreContext.GetEVMChainParams(evmConfig.Chain.ChainId)
if !found {
logger.Std.Error().Msgf("ChainParam not found for chain %s", evmConfig.Chain.String())
continue
Expand All @@ -77,15 +78,15 @@ func CreateSignerMap(
erc20CustodyAddress := ethcommon.HexToAddress(evmChainParams.Erc20CustodyContractAddress)
signer, err := evmsigner.NewSigner(
evmConfig.Chain,
evmConfig.Endpoint,
zetacoreContext,
tss,
ts,
logger,
evmConfig.Endpoint,
config.GetConnectorABI(),
config.GetERC20CustodyABI(),
mpiAddress,
erc20CustodyAddress,
coreContext,
logger,
ts)
erc20CustodyAddress)
if err != nil {
logger.Std.Error().Err(err).Msgf("NewEVMSigner error for chain %s", evmConfig.Chain.String())
continue
Expand All @@ -95,7 +96,7 @@ func CreateSignerMap(
// BTC signer
btcChain, btcConfig, enabled := appContext.GetBTCChainAndConfig()
if enabled {
signer, err := btcsigner.NewSigner(btcConfig, tss, logger, ts, coreContext)
signer, err := btcsigner.NewSigner(btcChain, zetacoreContext, tss, ts, logger, btcConfig)
if err != nil {
logger.Std.Error().Err(err).Msgf("NewBTCSigner error for chain %s", btcChain.String())
} else {
Expand Down
46 changes: 34 additions & 12 deletions cmd/zetacored/parse_genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ const MaxItemsForList = 10
// Copy represents a set of modules for which, the entire state is copied without any modifications
var Copy = map[string]bool{
slashingtypes.ModuleName: true,
govtypes.ModuleName: true,
crisistypes.ModuleName: true,
feemarkettypes.ModuleName: true,
paramstypes.ModuleName: true,
Expand All @@ -50,24 +49,37 @@ var Copy = map[string]bool{
vestingtypes.ModuleName: true,
fungibletypes.ModuleName: true,
emissionstypes.ModuleName: true,
authz.ModuleName: true,
}

// Skip represents a set of modules for which, the entire state is skipped and nothing gets imported
var Skip = map[string]bool{
evmtypes.ModuleName: true,
stakingtypes.ModuleName: true,
genutiltypes.ModuleName: true,
authtypes.ModuleName: true,
banktypes.ModuleName: true,
// Skipping evm this is done to reduce the size of the genesis file evm module uses the majority of the space due to smart contract data
evmtypes.ModuleName: true,
// Skipping staking as new validators would be created for the new chain
stakingtypes.ModuleName: true,
// Skipping genutil as new gentxs would be created
genutiltypes.ModuleName: true,
// Skipping auth as new accounts would be created for the new chain. This also needs to be done as we are skipping evm module
authtypes.ModuleName: true,
// Skipping bank module as it is not used when starting a new chain this is done to make sure the total supply invariant is maintained.
// This would need modification but might be possible to add in non evm based modules in the future
banktypes.ModuleName: true,
// Skipping distribution module as it is not used when starting a new chain , rewards are based on validators and delegators , and so rewards from a different chain do not hold any value
distributiontypes.ModuleName: true,
group.ModuleName: true,
// Skipping group module as it is not used when starting a new chain, new groups should be created based on the validator operator keys
group.ModuleName: true,
// Skipping authz as it is not used when starting a new chain, new grants should be created based on the validator hotkeys abd operator keys
authz.ModuleName: true,
// Skipping fungible module as new fungible tokens would be created and system contract would be deployed
fungibletypes.ModuleName: true,
// Skipping gov types as new parameters are set for the new chain
govtypes.ModuleName: true,
}

// Modify represents a set of modules for which, the state is modified before importing. Each Module should have a corresponding Modify function
var Modify = map[string]bool{
crosschaintypes.ModuleName: true,
observertypes.ModuleName: true,
crosschaintypes.ModuleName: true,
}

func CmdParseGenesisFile() *cobra.Command {
Expand All @@ -78,6 +90,10 @@ func CmdParseGenesisFile() *cobra.Command {
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.GetClientContextFromCmd(cmd)
cdc := clientCtx.Codec
modifyEnabled, err := cmd.Flags().GetBool("modify")
if err != nil {
return err
}
genesisFilePath := filepath.Join(app.DefaultNodeHome, "config", "genesis.json")
if len(args) == 2 {
genesisFilePath = args[1]
Expand All @@ -90,7 +106,7 @@ func CmdParseGenesisFile() *cobra.Command {
if err != nil {
return err
}
err = ImportDataIntoFile(genDoc, importData, cdc)
err = ImportDataIntoFile(genDoc, importData, cdc, modifyEnabled)
if err != nil {
return err
}
Expand All @@ -103,10 +119,16 @@ func CmdParseGenesisFile() *cobra.Command {
return nil
},
}
cmd.PersistentFlags().Bool("modify", false, "Modify the genesis file before importing")
return cmd
}

func ImportDataIntoFile(genDoc *types.GenesisDoc, importFile *types.GenesisDoc, cdc codec.Codec) error {
func ImportDataIntoFile(
genDoc *types.GenesisDoc,
importFile *types.GenesisDoc,
cdc codec.Codec,
modifyEnabled bool,
) error {

appState, err := genutiltypes.GenesisStateFromGenDoc(*genDoc)
if err != nil {
Expand All @@ -124,7 +146,7 @@ func ImportDataIntoFile(genDoc *types.GenesisDoc, importFile *types.GenesisDoc,
if Copy[m] {
appState[m] = importAppState[m]
}
if Modify[m] {
if Modify[m] && modifyEnabled {
switch m {
case crosschaintypes.ModuleName:
err := ModifyCrosschainState(appState, importAppState, cdc)
Expand Down
Loading

0 comments on commit d0fa305

Please sign in to comment.