From e4a954efdadfbdfc7bf578e9e3dd698da98576f2 Mon Sep 17 00:00:00 2001 From: Max <82761650+MaxMustermann2@users.noreply.github.com> Date: Mon, 30 Sep 2024 08:52:23 +0530 Subject: [PATCH] fix(assets): allow native chain to be registered (#200) * fix(assets): allow native chain to be registered * fix(test): remove invalid test --- precompiles/assets/tx.go | 4 ++++ x/assets/types/genesis.go | 8 -------- x/assets/types/genesis_test.go | 16 ---------------- 3 files changed, 4 insertions(+), 24 deletions(-) diff --git a/precompiles/assets/tx.go b/precompiles/assets/tx.go index 983e09c87..4a220fb57 100644 --- a/precompiles/assets/tx.go +++ b/precompiles/assets/tx.go @@ -216,6 +216,10 @@ func (p Precompile) IsRegisteredClientChain( if err != nil { return nil, err } + if clientChainID == 0 { + // explicitly return false for client chain ID 0 to prevent `setPeer` calls + return method.Outputs.Pack(true, false) + } exists := p.assetsKeeper.ClientChainExists(ctx, uint64(clientChainID)) return method.Outputs.Pack(true, exists) } diff --git a/x/assets/types/genesis.go b/x/assets/types/genesis.go index 5ead232cd..2b8175c33 100644 --- a/x/assets/types/genesis.go +++ b/x/assets/types/genesis.go @@ -45,14 +45,6 @@ func (gs GenesisState) ValidateClientChains() (map[uint64]struct{}, error) { i, ) } - // this is our primary method of cross-chain communication. - if info.LayerZeroChainID == 0 { - return errorsmod.Wrapf( - ErrInvalidGenesisData, - "nil LayerZeroChainID for chain %s", - info.Name, - ) - } // the address length is used to convert from bytes32 to address. if info.AddressLength == 0 { return errorsmod.Wrapf( diff --git a/x/assets/types/genesis_test.go b/x/assets/types/genesis_test.go index 3ae8dda39..c798801b0 100644 --- a/x/assets/types/genesis_test.go +++ b/x/assets/types/genesis_test.go @@ -105,22 +105,6 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { }, expPass: false, }, - { - name: "invalid genesis due to zero layer zero chain id", - genState: &types.GenesisState{ - Params: types.DefaultParams(), - ClientChains: []types.ClientChainInfo{ - ethClientChain, - }, - }, - malleate: func(gs *types.GenesisState) { - gs.ClientChains[0].LayerZeroChainID = 0 - }, - unmalleate: func(gs *types.GenesisState) { - gs.ClientChains[0].LayerZeroChainID = 101 - }, - expPass: false, - }, { name: "invalid genesis due to zero address length", genState: &types.GenesisState{