From b58816eb6dc4f9dc41a246e1997eaf13714f4a4c Mon Sep 17 00:00:00 2001 From: Lucas Bertrand Date: Thu, 23 May 2024 15:08:06 +0200 Subject: [PATCH 1/3] refactor: reduce checks done in inbound and outbound validation (#2237) * rename index * refactor inbound * fix outbound * change tests * fix cctx test * format * test: removing zeta runner * reanble zeta test * Update x/crosschain/types/validate.go Co-authored-by: Charlie Chen <34498985+ws4charlie@users.noreply.github.com> --------- Co-authored-by: Charlie Chen <34498985+ws4charlie@users.noreply.github.com> --- ...message_passing_zevm_to_evm_revert_fail.go | 17 ------- x/crosschain/types/cctx.go | 20 ++++----- x/crosschain/types/cctx_test.go | 4 +- x/crosschain/types/inbound_params.go | 45 ++++++++++--------- x/crosschain/types/inbound_params_test.go | 38 +++++++++------- x/crosschain/types/keys.go | 3 +- .../types/message_abort_stuck_cctx.go | 2 +- x/crosschain/types/message_refund_aborted.go | 2 +- x/crosschain/types/outbound_params.go | 40 +++++++++-------- x/crosschain/types/outbound_params_test.go | 20 ++++++--- x/crosschain/types/validate.go | 8 ++-- x/crosschain/types/validate_test.go | 10 ++--- 12 files changed, 105 insertions(+), 104 deletions(-) diff --git a/e2e/e2etests/test_message_passing_zevm_to_evm_revert_fail.go b/e2e/e2etests/test_message_passing_zevm_to_evm_revert_fail.go index bf9c50a89c..b822199af6 100644 --- a/e2e/e2etests/test_message_passing_zevm_to_evm_revert_fail.go +++ b/e2e/e2etests/test_message_passing_zevm_to_evm_revert_fail.go @@ -75,10 +75,6 @@ func TestMessagePassingZEVMtoEVMRevertFail(r *runner.E2ERunner, args []string) { } // Get previous balances to check funds are not minted anywhere when aborted - previousBalanceEVM, err := r.ZetaEth.BalanceOf(&bind.CallOpts{}, r.EvmTestDAppAddr) - if err != nil { - panic(err) - } previousBalanceZEVM, err := r.WZeta.BalanceOf(&bind.CallOpts{}, testDappNoRevertAddr) if err != nil { panic(err) @@ -102,19 +98,6 @@ func TestMessagePassingZEVMtoEVMRevertFail(r *runner.E2ERunner, args []string) { panic("expected cctx to be reverted") } - // Check ZETA balance on EVM TestDApp and check new balance is previous balance - newBalanceEVM, err := r.ZetaEth.BalanceOf(&bind.CallOpts{}, r.EvmTestDAppAddr) - if err != nil { - panic(err) - } - if newBalanceEVM.Cmp(previousBalanceEVM) != 0 { - panic(fmt.Sprintf( - "expected new balance to be %s, got %s", - previousBalanceEVM.String(), - newBalanceEVM.String()), - ) - } - // Check the funds are not minted to the contract as the cctx has been aborted newBalanceZEVM, err := r.WZeta.BalanceOf(&bind.CallOpts{}, testDappNoRevertAddr) if err != nil { diff --git a/x/crosschain/types/cctx.go b/x/crosschain/types/cctx.go index 7feece0e1a..e3d448c746 100644 --- a/x/crosschain/types/cctx.go +++ b/x/crosschain/types/cctx.go @@ -52,7 +52,7 @@ func (m CrossChainTx) Validate() error { return fmt.Errorf("outbound tx params cannot be more than 2") } if m.Index != "" { - err := ValidateZetaIndex(m.Index) + err := ValidateCCTXIndex(m.Index) if err != nil { return err } @@ -70,16 +70,10 @@ func (m CrossChainTx) Validate() error { return nil } -/* -AddRevertOutbound does the following things in one function: - - 1. create a new OutboundTxParams for the revert - - 2. append the new OutboundTxParams to the current OutboundTxParams - - 3. update the TxFinalizationStatus of the current OutboundTxParams to Executed. -*/ - +// AddRevertOutbound does the following things in one function: +// 1. create a new OutboundTxParams for the revert +// 2. append the new OutboundTxParams to the current OutboundTxParams +// 3. update the TxFinalizationStatus of the current OutboundTxParams to Executed. func (m *CrossChainTx) AddRevertOutbound(gasLimit uint64) error { if m.IsCurrentOutboundRevert() { return fmt.Errorf("cannot revert a revert tx") @@ -223,9 +217,13 @@ func NewCCTX(ctx sdk.Context, msg MsgVoteInbound, tssPubkey string) (CrossChainT InboundParams: inboundParams, OutboundParams: []*OutboundParams{outBoundParams}, } + + // TODO: remove this validate call + // https://github.com/zeta-chain/node/issues/2236 err := cctx.Validate() if err != nil { return CrossChainTx{}, err } + return cctx, nil } diff --git a/x/crosschain/types/cctx_test.go b/x/crosschain/types/cctx_test.go index 8cfa773428..4e4833535e 100644 --- a/x/crosschain/types/cctx_test.go +++ b/x/crosschain/types/cctx_test.go @@ -92,7 +92,7 @@ func Test_InitializeCCTX(t *testing.T) { tss := sample.Tss() msg := types.MsgVoteInbound{ Creator: creator, - Sender: "invalid", + Sender: "", SenderChainId: senderChain.ChainId, Receiver: receiver.String(), ReceiverChain: receiverChain.ChainId, @@ -107,7 +107,7 @@ func Test_InitializeCCTX(t *testing.T) { EventIndex: eventIndex, } _, err := types.NewCCTX(ctx, msg, tss.TssPubkey) - require.ErrorContains(t, err, "invalid address") + require.ErrorContains(t, err, "sender cannot be empty") }) } diff --git a/x/crosschain/types/inbound_params.go b/x/crosschain/types/inbound_params.go index 782c57013c..f191d15e2d 100644 --- a/x/crosschain/types/inbound_params.go +++ b/x/crosschain/types/inbound_params.go @@ -3,8 +3,6 @@ package types import ( "fmt" - "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/zeta-chain/zetacore/pkg/chains" ) @@ -12,32 +10,35 @@ func (m InboundParams) Validate() error { if m.Sender == "" { return fmt.Errorf("sender cannot be empty") } + if chains.GetChainFromChainID(m.SenderChainId) == nil { return fmt.Errorf("invalid sender chain id %d", m.SenderChainId) } - err := ValidateAddressForChain(m.Sender, m.SenderChainId) - if err != nil { - return err - } - if m.TxOrigin != "" { - errTxOrigin := ValidateAddressForChain(m.TxOrigin, m.SenderChainId) - if errTxOrigin != nil { - return errTxOrigin - } - } if m.Amount.IsNil() { return fmt.Errorf("amount cannot be nil") } - err = ValidateHashForChain(m.ObservedHash, m.SenderChainId) - if err != nil { - return errors.Wrap(err, "invalid inbound tx observed hash") - } - if m.BallotIndex != "" { - err = ValidateZetaIndex(m.BallotIndex) - if err != nil { - return errors.Wrap(err, "invalid inbound tx ballot index") - } - } + + // Disabled checks + // TODO: Improve the checks, move the validation call to a new place and reenable + // https://github.com/zeta-chain/node/issues/2234 + // https://github.com/zeta-chain/node/issues/2235 + //if err := ValidateAddressForChain(m.Sender, m.SenderChainId) err != nil { + // return err + //} + //if m.TxOrigin != "" { + // errTxOrigin := ValidateAddressForChain(m.TxOrigin, m.SenderChainId) + // if errTxOrigin != nil { + // return errTxOrigin + // } + //} + //if err := ValidateHashForChain(m.ObservedHash, m.SenderChainId); err != nil { + // return errors.Wrap(err, "invalid inbound tx observed hash") + //} + //if m.BallotIndex != "" { + // if err := ValidateCCTXIndex(m.BallotIndex); err != nil { + // return errors.Wrap(err, "invalid inbound tx ballot index") + // } + //} return nil } diff --git a/x/crosschain/types/inbound_params_test.go b/x/crosschain/types/inbound_params_test.go index 4387e440b8..464f685475 100644 --- a/x/crosschain/types/inbound_params_test.go +++ b/x/crosschain/types/inbound_params_test.go @@ -7,38 +7,44 @@ import ( sdkmath "cosmossdk.io/math" "github.com/stretchr/testify/require" - "github.com/zeta-chain/zetacore/pkg/chains" "github.com/zeta-chain/zetacore/testutil/sample" ) func TestInboundTxParams_Validate(t *testing.T) { r := rand.New(rand.NewSource(42)) + inboundParams := sample.InboundParamsValidChainID(r) inboundParams.Sender = "" require.ErrorContains(t, inboundParams.Validate(), "sender cannot be empty") + inboundParams = sample.InboundParamsValidChainID(r) inboundParams.SenderChainId = 1000 require.ErrorContains(t, inboundParams.Validate(), "invalid sender chain id 1000") - inboundParams = sample.InboundParamsValidChainID(r) - inboundParams.SenderChainId = chains.GoerliChain.ChainId - inboundParams.Sender = "0x123" - require.ErrorContains(t, inboundParams.Validate(), "invalid address 0x123") - inboundParams = sample.InboundParamsValidChainID(r) - inboundParams.SenderChainId = chains.GoerliChain.ChainId - inboundParams.TxOrigin = "0x123" - require.ErrorContains(t, inboundParams.Validate(), "invalid address 0x123") + inboundParams = sample.InboundParamsValidChainID(r) inboundParams.Amount = sdkmath.Uint{} require.ErrorContains(t, inboundParams.Validate(), "amount cannot be nil") - inboundParams = sample.InboundParamsValidChainID(r) - inboundParams.ObservedHash = "12" - require.ErrorContains(t, inboundParams.Validate(), "hash must be a valid ethereum hash 12") - inboundParams = sample.InboundParamsValidChainID(r) - inboundParams.ObservedHash = sample.Hash().String() - inboundParams.BallotIndex = "12" - require.ErrorContains(t, inboundParams.Validate(), "invalid index length 2") + inboundParams = sample.InboundParamsValidChainID(r) inboundParams.ObservedHash = sample.Hash().String() inboundParams.BallotIndex = sample.ZetaIndex(t) require.NoError(t, inboundParams.Validate()) + + // Disabled checks + // TODO: Improve the checks, move the validation call to a new place and reenable + // https://github.com/zeta-chain/node/issues/2234 + // https://github.com/zeta-chain/node/issues/2235 + //inboundParams = sample.InboundParamsValidChainID(r) + //inboundParams.SenderChainId = chains.GoerliChain.ChainId + //inboundParams.Sender = "0x123" + //require.ErrorContains(t, inboundParams.Validate(), "invalid address 0x123") + // + //inboundParams = sample.InboundParamsValidChainID(r) + //inboundParams.ObservedHash = "12" + //require.ErrorContains(t, inboundParams.Validate(), "hash must be a valid ethereum hash 12") + // + //inboundParams = sample.InboundParamsValidChainID(r) + //inboundParams.ObservedHash = sample.Hash().String() + //inboundParams.BallotIndex = "12" + //require.ErrorContains(t, inboundParams.Validate(), "invalid index length 2") } diff --git a/x/crosschain/types/keys.go b/x/crosschain/types/keys.go index f47912f66c..dd5f8b496c 100644 --- a/x/crosschain/types/keys.go +++ b/x/crosschain/types/keys.go @@ -26,7 +26,8 @@ const ( //TssMigrationGasMultiplierEVM is multiplied to the median gas price to get the gas price for the tss migration . This is done to avoid the tss migration tx getting stuck in the mempool TssMigrationGasMultiplierEVM = "2.5" - ZetaIndexLength = 66 + // CCTXIndexLength is the length of a crosschain transaction index + CCTXIndexLength = 66 ) func GetProtocolFee() sdk.Uint { diff --git a/x/crosschain/types/message_abort_stuck_cctx.go b/x/crosschain/types/message_abort_stuck_cctx.go index 86a1f31ec6..aec9ab79de 100644 --- a/x/crosschain/types/message_abort_stuck_cctx.go +++ b/x/crosschain/types/message_abort_stuck_cctx.go @@ -43,7 +43,7 @@ func (msg *MsgAbortStuckCCTX) ValidateBasic() error { if err != nil { return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) } - if len(msg.CctxIndex) != ZetaIndexLength { + if len(msg.CctxIndex) != CCTXIndexLength { return ErrInvalidIndexValue } return nil diff --git a/x/crosschain/types/message_refund_aborted.go b/x/crosschain/types/message_refund_aborted.go index d019b8ea31..0908b6b010 100644 --- a/x/crosschain/types/message_refund_aborted.go +++ b/x/crosschain/types/message_refund_aborted.go @@ -45,7 +45,7 @@ func (msg *MsgRefundAbortedCCTX) ValidateBasic() error { if err != nil { return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) } - if len(msg.CctxIndex) != ZetaIndexLength { + if len(msg.CctxIndex) != CCTXIndexLength { return ErrInvalidIndexValue } if msg.RefundAddress != "" && !ethcommon.IsHexAddress(msg.RefundAddress) { diff --git a/x/crosschain/types/outbound_params.go b/x/crosschain/types/outbound_params.go index 466ef45756..34458763dd 100644 --- a/x/crosschain/types/outbound_params.go +++ b/x/crosschain/types/outbound_params.go @@ -4,8 +4,6 @@ import ( "fmt" "strconv" - "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/zeta-chain/zetacore/pkg/chains" ) @@ -22,27 +20,33 @@ func (m OutboundParams) Validate() error { if m.Receiver == "" { return fmt.Errorf("receiver cannot be empty") } + if chains.GetChainFromChainID(m.ReceiverChainId) == nil { return fmt.Errorf("invalid receiver chain id %d", m.ReceiverChainId) } - err := ValidateAddressForChain(m.Receiver, m.ReceiverChainId) - if err != nil { - return err - } + if m.Amount.IsNil() { return fmt.Errorf("amount cannot be nil") } - if m.BallotIndex != "" { - err = ValidateZetaIndex(m.BallotIndex) - if err != nil { - return errors.Wrap(err, "invalid outbound tx ballot index") - } - } - if m.Hash != "" { - err = ValidateHashForChain(m.Hash, m.ReceiverChainId) - if err != nil { - return errors.Wrap(err, "invalid outbound tx hash") - } - } + + // Disabled checks + // TODO: Improve the checks, move the validation call to a new place and reenable + // https://github.com/zeta-chain/node/issues/2234 + // https://github.com/zeta-chain/node/issues/2235 + //if err := ValidateAddressForChain(m.Receiver, m.ReceiverChainId); err != nil { + // return err + //} + //if m.BallotIndex != "" { + // + // if err := ValidateCCTXIndex(m.BallotIndex); err != nil { + // return errors.Wrap(err, "invalid outbound tx ballot index") + // } + //} + //if m.Hash != "" { + // if err := ValidateHashForChain(m.Hash, m.ReceiverChainId); err != nil { + // return errors.Wrap(err, "invalid outbound tx hash") + // } + //} + return nil } diff --git a/x/crosschain/types/outbound_params_test.go b/x/crosschain/types/outbound_params_test.go index 396a80ddcc..e5caa4b1b0 100644 --- a/x/crosschain/types/outbound_params_test.go +++ b/x/crosschain/types/outbound_params_test.go @@ -15,22 +15,30 @@ func TestOutboundParams_Validate(t *testing.T) { outTxParams := sample.OutboundParamsValidChainID(r) outTxParams.Receiver = "" require.ErrorContains(t, outTxParams.Validate(), "receiver cannot be empty") + outTxParams = sample.OutboundParamsValidChainID(r) outTxParams.ReceiverChainId = 1000 require.ErrorContains(t, outTxParams.Validate(), "invalid receiver chain id 1000") - outTxParams = sample.OutboundParamsValidChainID(r) - outTxParams.Receiver = "0x123" - require.ErrorContains(t, outTxParams.Validate(), "invalid address 0x123") + outTxParams = sample.OutboundParamsValidChainID(r) outTxParams.Amount = sdkmath.Uint{} require.ErrorContains(t, outTxParams.Validate(), "amount cannot be nil") - outTxParams = sample.OutboundParamsValidChainID(r) - outTxParams.BallotIndex = "12" - require.ErrorContains(t, outTxParams.Validate(), "invalid index length 2") + outTxParams = sample.OutboundParamsValidChainID(r) outTxParams.BallotIndex = sample.ZetaIndex(t) outTxParams.Hash = sample.Hash().String() require.NoError(t, outTxParams.Validate()) + + // Disabled checks + // TODO: Improve the checks, move the validation call to a new place and reenable + // https://github.com/zeta-chain/node/issues/2234 + // https://github.com/zeta-chain/node/issues/2235 + //outTxParams = sample.OutboundParamsValidChainID(r) + //outTxParams.Receiver = "0x123" + //require.ErrorContains(t, outTxParams.Validate(), "invalid address 0x123") + //outTxParams = sample.OutboundParamsValidChainID(r) + //outTxParams.BallotIndex = "12" + //require.ErrorContains(t, outTxParams.Validate(), "invalid index length 2") } func TestOutboundTxParams_GetGasPrice(t *testing.T) { diff --git a/x/crosschain/types/validate.go b/x/crosschain/types/validate.go index 46f36615f2..58305ffa02 100644 --- a/x/crosschain/types/validate.go +++ b/x/crosschain/types/validate.go @@ -11,10 +11,10 @@ import ( "github.com/zeta-chain/zetacore/pkg/chains" ) -// ValidateZetaIndex validates the zeta index -func ValidateZetaIndex(index string) error { - if len(index) != ZetaIndexLength { - return errors.Wrap(ErrInvalidIndexValue, fmt.Sprintf("invalid index length %d", len(index))) +// ValidateCCTXIndex validates the CCTX index +func ValidateCCTXIndex(index string) error { + if len(index) != CCTXIndexLength { + return errors.Wrapf(ErrInvalidIndexValue, "invalid index length %d, expected: %d", len(index), CCTXIndexLength) } return nil } diff --git a/x/crosschain/types/validate_test.go b/x/crosschain/types/validate_test.go index d146d67817..25c52518f3 100644 --- a/x/crosschain/types/validate_test.go +++ b/x/crosschain/types/validate_test.go @@ -61,11 +61,11 @@ func TestValidateAddressForChain(t *testing.T) { ) } -func TestValidateZetaIndex(t *testing.T) { - require.NoError(t, types.ValidateZetaIndex("0x84bd5c9922b63c52d8a9ca686e0a57ff978150b71be0583514d01c27aa341910")) - require.NoError(t, types.ValidateZetaIndex(sample.ZetaIndex(t))) - require.Error(t, types.ValidateZetaIndex("0")) - require.Error(t, types.ValidateZetaIndex("0x70e967acFcC17c3941E87562161406d41676FD83")) +func TestValidateCCTXIndex(t *testing.T) { + require.NoError(t, types.ValidateCCTXIndex("0x84bd5c9922b63c52d8a9ca686e0a57ff978150b71be0583514d01c27aa341910")) + require.NoError(t, types.ValidateCCTXIndex(sample.ZetaIndex(t))) + require.Error(t, types.ValidateCCTXIndex("0")) + require.Error(t, types.ValidateCCTXIndex("0x70e967acFcC17c3941E87562161406d41676FD83")) } func TestValidateHashForChain(t *testing.T) { From 803658d48ab07084fdca3474c2fe9c4bec189798 Mon Sep 17 00:00:00 2001 From: Alex Gartner Date: Thu, 23 May 2024 08:49:07 -0700 Subject: [PATCH 2/3] feat: enable restarting localnet containers (#2239) --- contrib/localnet/docker-compose-upgrade.yml | 4 +- contrib/localnet/scripts/start-zetaclientd.sh | 20 +++------ contrib/localnet/scripts/start-zetacored.sh | 43 +++++++++++-------- 3 files changed, 34 insertions(+), 33 deletions(-) diff --git a/contrib/localnet/docker-compose-upgrade.yml b/contrib/localnet/docker-compose-upgrade.yml index 43af2c6768..a7497db980 100644 --- a/contrib/localnet/docker-compose-upgrade.yml +++ b/contrib/localnet/docker-compose-upgrade.yml @@ -13,11 +13,11 @@ services: image: zetanode:old zetaclient0: - entrypoint: ["/root/start-zetaclientd.sh", "background"] + entrypoint: ["/root/start-zetaclientd.sh"] image: zetanode:old zetaclient1: - entrypoint: ["/root/start-zetaclientd.sh", "background"] + entrypoint: ["/root/start-zetaclientd.sh"] image: zetanode:old orchestrator: diff --git a/contrib/localnet/scripts/start-zetaclientd.sh b/contrib/localnet/scripts/start-zetaclientd.sh index 5a364aeb9a..32271a30b5 100755 --- a/contrib/localnet/scripts/start-zetaclientd.sh +++ b/contrib/localnet/scripts/start-zetaclientd.sh @@ -39,21 +39,22 @@ operator=$(cat $HOME/.zetacored/os.json | jq '.ObserverAddress' ) operatorAddress=$(echo "$operator" | tr -d '"') echo "operatorAddress: $operatorAddress" echo "Start zetaclientd" -if [ $HOSTNAME == "zetaclient0" ] +# skip initialization if the config file already exists (zetaclientd init has already been run) +if [[ $HOSTNAME == "zetaclient0" && ! -f ~/.zetacored/config/zetaclient_config.json ]] then rm ~/.tss/* MYIP=$(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) zetaclientd init --zetacore-url zetacore0 --chain-id athens_101-1 --operator "$operatorAddress" --log-format=text --public-ip "$MYIP" --keyring-backend "$BACKEND" # check if the option is additional-evm - # in this case, the additional evm is represented with the sepolia chain, we set manually the eth2 endpoint to the sepolia chain (11155111 -> http://eth2:8545) + # in this case, the additional evm is represented with the sepolia chain, we set manually the eth2 endpoint to the sepolia chain (11155111 -> http://eth2:8545) # in /root/.zetacored/config/zetaclient_config.json if [ "$OPTION" == "additional-evm" ]; then set_sepolia_endpoint fi - - zetaclientd-supervisor start < /root/password.file -else +fi +if [[ $HOSTNAME != "zetaclient0" && ! -f ~/.zetacored/config/zetaclient_config.json ]] +then num=$(echo $HOSTNAME | tr -dc '0-9') node="zetacore$num" MYIP=$(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) @@ -71,13 +72,6 @@ else if [ "$OPTION" == "additional-evm" ]; then set_sepolia_endpoint fi - - zetaclientd-supervisor start < /root/password.file fi -# check if the option is background -# in this case, we tail the zetaclientd log file -if [ "$OPTION" == "background" ]; then - sleep 3 - tail -f $HOME/zetaclient.log -fi +zetaclientd-supervisor start < /root/password.file \ No newline at end of file diff --git a/contrib/localnet/scripts/start-zetacored.sh b/contrib/localnet/scripts/start-zetacored.sh index 08e8b0ef01..278ecd778b 100755 --- a/contrib/localnet/scripts/start-zetacored.sh +++ b/contrib/localnet/scripts/start-zetacored.sh @@ -121,20 +121,24 @@ while [ ! -f ~/.ssh/authorized_keys ]; do sleep 1 done -# Init a new node to generate genesis file . -# Copy config files from existing folders which get copied via Docker Copy when building images -mkdir -p ~/.backup/config -zetacored init Zetanode-Localnet --chain-id=$CHAINID -rm -rf ~/.zetacored/config/app.toml -rm -rf ~/.zetacored/config/client.toml -rm -rf ~/.zetacored/config/config.toml -cp -r ~/zetacored/common/app.toml ~/.zetacored/config/ -cp -r ~/zetacored/common/client.toml ~/.zetacored/config/ -cp -r ~/zetacored/common/config.toml ~/.zetacored/config/ -sed -i -e "/moniker =/s/=.*/= \"$HOSTNAME\"/" "$HOME"/.zetacored/config/config.toml +# Skip init if it has already been completed (marked by presence of ~/.zetacored/init_complete file) +if [[ ! -f ~/.zetacored/init_complete ]] +then + # Init a new node to generate genesis file . + # Copy config files from existing folders which get copied via Docker Copy when building images + mkdir -p ~/.backup/config + zetacored init Zetanode-Localnet --chain-id=$CHAINID + rm -rf ~/.zetacored/config/app.toml + rm -rf ~/.zetacored/config/client.toml + rm -rf ~/.zetacored/config/config.toml + cp -r ~/zetacored/common/app.toml ~/.zetacored/config/ + cp -r ~/zetacored/common/client.toml ~/.zetacored/config/ + cp -r ~/zetacored/common/config.toml ~/.zetacored/config/ + sed -i -e "/moniker =/s/=.*/= \"$HOSTNAME\"/" "$HOME"/.zetacored/config/config.toml -# Add two new keys for operator and hotkey and create the required json structure for os_info -source ~/add-keys.sh + # Add two new keys for operator and hotkey and create the required json structure for os_info + source ~/add-keys.sh +fi # Pause other nodes so that the primary can node can do the genesis creation if [ $HOSTNAME != "zetacore0" ] @@ -143,8 +147,7 @@ then echo "Waiting for genesis.json file to exist..." sleep 1 done - # need to wait for zetacore0 to be up otherwise you get - # + # need to wait for zetacore0 to be up while ! curl -s -o /dev/null zetacore0:26657/status ; do echo "Waiting for zetacore0 rpc" sleep 1 @@ -160,8 +163,9 @@ fi # 6. Update Config in zetacore0 so that it has the correct persistent peer list # 7. Start the nodes -# Start of genesis creation . This is done only on zetacore0 -if [ $HOSTNAME == "zetacore0" ] +# Start of genesis creation . This is done only on zetacore0. +# Skip genesis if it has already been completed (marked by presence of ~/.zetacored/init_complete file) +if [[ $HOSTNAME == "zetacore0" && ! -f ~/.zetacored/init_complete ]] then # Misc : Copying the keyring to the client nodes so that they can sign the transactions ssh zetaclient0 mkdir -p ~/.zetacored/keyring-test/ @@ -266,7 +270,7 @@ fi # End of genesis creation steps . The steps below are common to all the nodes # Update persistent peers -if [ $HOSTNAME != "zetacore0" ] +if [[ $HOSTNAME != "zetacore0" && ! -f ~/.zetacored/init_complete ]] then # Misc : Copying the keyring to the client nodes so that they can sign the transactions ssh zetaclient"$INDEX" mkdir -p ~/.zetacored/keyring-test/ @@ -279,4 +283,7 @@ then sed -i -e "/persistent_peers =/s/=.*/= \"$pps\"/" "$HOME"/.zetacored/config/config.toml fi +# mark init completed so we skip it if container is restarted +touch ~/.zetacored/init_complete + cosmovisor run start --pruning=nothing --minimum-gas-prices=0.0001azeta --json-rpc.api eth,txpool,personal,net,debug,web3,miner --api.enable --home /root/.zetacored \ No newline at end of file From 1302dccb44b55ea0caf2fd3b1305dc5ff6f4f0d3 Mon Sep 17 00:00:00 2001 From: Charlie Chen <34498985+ws4charlie@users.noreply.github.com> Date: Thu, 23 May 2024 11:57:26 -0500 Subject: [PATCH 3/3] fix: don't skip unsupported chain param and let it update the `IsSupported` flag in context (#2233) * don't skip unsupported chain param and let it update the flag in zetacore context * added changelog entry --- changelog.md | 1 + zetaclient/zetacore/client.go | 4 ---- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/changelog.md b/changelog.md index ffb96c3be9..095b9ec6e4 100644 --- a/changelog.md +++ b/changelog.md @@ -42,6 +42,7 @@ * [1484](https://github.com/zeta-chain/node/issues/1484) - replaced hard-coded `MaxLookaheadNonce` with a default lookback factor * [2125](https://github.com/zeta-chain/node/pull/2125) - fix develop upgrade test * [2222](https://github.com/zeta-chain/node/pull/2222) - removed `maxHeightDiff` to let observer scan from Bitcoin height where it left off +* [2233](https://github.com/zeta-chain/node/pull/2233) - fix `IsSupported` flag not properly updated in zetaclient's context ### CI diff --git a/zetaclient/zetacore/client.go b/zetaclient/zetacore/client.go index 84ea0194d7..d64fd56db1 100644 --- a/zetaclient/zetacore/client.go +++ b/zetaclient/zetacore/client.go @@ -224,10 +224,6 @@ func (c *Client) UpdateZetacoreContext( // check and update chain params for each chain for _, chainParam := range chainParams { - if !chainParam.GetIsSupported() { - sampledLogger.Info().Msgf("Chain %d is not supported yet", chainParam.ChainId) - continue - } err := observertypes.ValidateChainParams(chainParam) if err != nil { sampledLogger.Warn().Err(err).Msgf("Invalid chain params for chain %d", chainParam.ChainId)