Skip to content

Commit

Permalink
fix(assets): allow native chain to be registered (#200)
Browse files Browse the repository at this point in the history
* fix(assets): allow native chain to be registered

* fix(test): remove invalid test
  • Loading branch information
MaxMustermann2 authored Sep 30, 2024
1 parent dd6a144 commit e4a954e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 24 deletions.
4 changes: 4 additions & 0 deletions precompiles/assets/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
8 changes: 0 additions & 8 deletions x/assets/types/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
16 changes: 0 additions & 16 deletions x/assets/types/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down

0 comments on commit e4a954e

Please sign in to comment.