Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add ibc-crosschain module #2154

Merged
merged 23 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 39 additions & 8 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ import (
observermodule "github.com/zeta-chain/zetacore/x/observer"
observerkeeper "github.com/zeta-chain/zetacore/x/observer/keeper"
observertypes "github.com/zeta-chain/zetacore/x/observer/types"

"github.com/zeta-chain/zetacore/x/ibccrosschain"
ibccrosschainkeeper "github.com/zeta-chain/zetacore/x/ibccrosschain/keeper"
ibccrosschaintypes "github.com/zeta-chain/zetacore/x/ibccrosschain/types"
)

const Name = "zetacore"
Expand Down Expand Up @@ -207,6 +211,7 @@ var (
authoritymodule.AppModuleBasic{},
lightclientmodule.AppModuleBasic{},
crosschainmodule.AppModuleBasic{},
ibccrosschain.AppModuleBasic{},
observermodule.AppModuleBasic{},
fungiblemodule.AppModuleBasic{},
emissionsmodule.AppModuleBasic{},
Expand All @@ -223,6 +228,7 @@ var (
govtypes.ModuleName: {authtypes.Burner},
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
crosschaintypes.ModuleName: {authtypes.Minter, authtypes.Burner},
ibccrosschaintypes.ModuleName: nil,
evmtypes.ModuleName: {authtypes.Minter, authtypes.Burner},
fungibletypes.ModuleName: {authtypes.Minter, authtypes.Burner},
emissionstypes.ModuleName: nil,
Expand Down Expand Up @@ -284,20 +290,22 @@ type App struct {
ConsensusParamsKeeper consensusparamkeeper.Keeper

// scoped keepers
ScopedIBCKeeper capabilitykeeper.ScopedKeeper
ScopedTransferKeeper capabilitykeeper.ScopedKeeper
ScopedIBCKeeper capabilitykeeper.ScopedKeeper
ScopedTransferKeeper capabilitykeeper.ScopedKeeper
ScopedIBCCrosschainKeeper capabilitykeeper.ScopedKeeper

// evm keepers
EvmKeeper *evmkeeper.Keeper
FeeMarketKeeper feemarketkeeper.Keeper

// zetachain keepers
AuthorityKeeper authoritykeeper.Keeper
LightclientKeeper lightclientkeeper.Keeper
CrosschainKeeper crosschainkeeper.Keeper
ObserverKeeper *observerkeeper.Keeper
FungibleKeeper fungiblekeeper.Keeper
EmissionsKeeper emissionskeeper.Keeper
AuthorityKeeper authoritykeeper.Keeper
LightclientKeeper lightclientkeeper.Keeper
CrosschainKeeper crosschainkeeper.Keeper
IBCCrosschainKeeper ibccrosschainkeeper.Keeper
ObserverKeeper *observerkeeper.Keeper
FungibleKeeper fungiblekeeper.Keeper
EmissionsKeeper emissionskeeper.Keeper

transferModule transfer.AppModule
}
Expand Down Expand Up @@ -345,6 +353,7 @@ func New(
authoritytypes.StoreKey,
lightclienttypes.StoreKey,
crosschaintypes.StoreKey,
ibccrosschaintypes.StoreKey,
observertypes.StoreKey,
fungibletypes.StoreKey,
emissionstypes.StoreKey,
Expand Down Expand Up @@ -586,6 +595,25 @@ func New(
app.AuthorityKeeper,
app.LightclientKeeper,
)

// 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

scopedIBCCrosschainKeeper := app.CapabilityKeeper.ScopeToModule(ibccrosschaintypes.ModuleName)
app.ScopedIBCCrosschainKeeper = scopedIBCCrosschainKeeper

app.IBCCrosschainKeeper = *ibccrosschainkeeper.NewKeeper(
appCodec,
keys[ibccrosschaintypes.StoreKey],
keys[ibccrosschaintypes.MemStoreKey],
&app.CrosschainKeeper,
app.TransferKeeper,
)

ibcRouter.AddRoute(ibccrosschaintypes.ModuleName, ibccrosschain.NewIBCModule(app.IBCCrosschainKeeper))

app.CrosschainKeeper.SetIBCCrosschainKeeper(app.IBCCrosschainKeeper)

app.GroupKeeper = groupkeeper.NewKeeper(
keys[group.StoreKey],
appCodec,
Expand Down Expand Up @@ -670,6 +698,7 @@ func New(
authoritymodule.NewAppModule(appCodec, app.AuthorityKeeper),
lightclientmodule.NewAppModule(appCodec, app.LightclientKeeper),
crosschainmodule.NewAppModule(appCodec, app.CrosschainKeeper),
ibccrosschain.NewAppModule(appCodec, app.IBCCrosschainKeeper),
observermodule.NewAppModule(appCodec, *app.ObserverKeeper),
fungiblemodule.NewAppModule(appCodec, app.FungibleKeeper),
emissionsmodule.NewAppModule(appCodec, app.EmissionsKeeper, app.GetSubspace(emissionstypes.ModuleName)),
Expand Down Expand Up @@ -700,6 +729,7 @@ func New(
ibctransfertypes.ModuleName,
feemarkettypes.ModuleName,
crosschaintypes.ModuleName,
ibccrosschaintypes.ModuleName,
observertypes.ModuleName,
fungibletypes.ModuleName,
emissionstypes.ModuleName,
Expand Down Expand Up @@ -728,6 +758,7 @@ func New(
evmtypes.ModuleName,
feemarkettypes.ModuleName,
crosschaintypes.ModuleName,
ibccrosschaintypes.ModuleName,
observertypes.ModuleName,
fungibletypes.ModuleName,
emissionstypes.ModuleName,
Expand Down
2 changes: 2 additions & 0 deletions app/init_genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types"
emissionsModuleTypes "github.com/zeta-chain/zetacore/x/emissions/types"
fungibleModuleTypes "github.com/zeta-chain/zetacore/x/fungible/types"
ibccrosschaintypes "github.com/zeta-chain/zetacore/x/ibccrosschain/types"
lightclienttypes "github.com/zeta-chain/zetacore/x/lightclient/types"
observertypes "github.com/zeta-chain/zetacore/x/observer/types"
)
Expand Down Expand Up @@ -52,6 +53,7 @@ func InitGenesisModuleList() []string {
vestingtypes.ModuleName,
observertypes.ModuleName,
crosschaintypes.ModuleName,
ibccrosschaintypes.ModuleName,
fungibleModuleTypes.ModuleName,
emissionsModuleTypes.ModuleName,
authz.ModuleName,
Expand Down
2 changes: 2 additions & 0 deletions app/setup_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported"
"github.com/zeta-chain/zetacore/pkg/constant"
emissionstypes "github.com/zeta-chain/zetacore/x/emissions/types"
ibccrosschaintypes "github.com/zeta-chain/zetacore/x/ibccrosschain/types"
)

func SetupHandlers(app *App) {
Expand Down Expand Up @@ -88,6 +89,7 @@ func SetupHandlers(app *App) {
capabilitytypes.ModuleName,
ibcexported.ModuleName,
ibctransfertypes.ModuleName,
ibccrosschaintypes.ModuleName,
},
}
// Use upgrade store loader for the initial loading of all stores when app starts,
Expand Down
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* [2145](https://github.com/zeta-chain/node/pull/2145) - add `ibc` and `ibc-transfer` modules
* [2135](https://github.com/zeta-chain/node/pull/2135) - add develop build version logic
* [2113](https://github.com/zeta-chain/node/pull/2113) - add zetaclientd-supervisor process
* [2154](https://github.com/zeta-chain/node/pull/2154) - add `ibccrosschain` module

### Refactor

Expand Down
1 change: 1 addition & 0 deletions docs/cli/zetacored/zetacored_query.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,5 @@ zetacored query [flags]
* [zetacored query tx](zetacored_query_tx.md) - Query for a transaction by hash, "[addr]/[seq]" combination or comma-separated signatures in a committed block
* [zetacored query txs](zetacored_query_txs.md) - Query for paginated transactions that match a set of events
* [zetacored query upgrade](zetacored_query_upgrade.md) - Querying commands for the upgrade module
* [zetacored query zetaibccrosschain](zetacored_query_zetaibccrosschain.md) - Querying commands for the zetaibccrosschain module

29 changes: 29 additions & 0 deletions docs/cli/zetacored/zetacored_query_zetaibccrosschain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# query zetaibccrosschain

Querying commands for the zetaibccrosschain module

```
zetacored query zetaibccrosschain [flags]
```

### Options

```
-h, --help help for zetaibccrosschain
```

### Options inherited from parent commands

```
--chain-id string The network chain ID
--home string directory for config and data
--log_format string The logging format (json|plain)
--log_level string The logging level (trace|debug|info|warn|error|fatal|panic)
--log_no_color Disable colored logs
--trace print out full stack trace on errors
```

### SEE ALSO

* [zetacored query](zetacored_query.md) - Querying subcommands

1 change: 1 addition & 0 deletions docs/cli/zetacored/zetacored_tx.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,5 @@ zetacored tx [flags]
* [zetacored tx staking](zetacored_tx_staking.md) - Staking transaction subcommands
* [zetacored tx validate-signatures](zetacored_tx_validate-signatures.md) - validate transactions signatures
* [zetacored tx vesting](zetacored_tx_vesting.md) - Vesting transaction subcommands
* [zetacored tx zetaibccrosschain](zetacored_tx_zetaibccrosschain.md) - zetaibccrosschain transactions subcommands

29 changes: 29 additions & 0 deletions docs/cli/zetacored/zetacored_tx_zetaibccrosschain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# tx zetaibccrosschain

zetaibccrosschain transactions subcommands

```
zetacored tx zetaibccrosschain [flags]
```

### Options

```
-h, --help help for zetaibccrosschain
```

### Options inherited from parent commands

```
--chain-id string The network chain ID
--home string directory for config and data
--log_format string The logging format (json|plain)
--log_level string The logging level (trace|debug|info|warn|error|fatal|panic)
--log_no_color Disable colored logs
--trace print out full stack trace on errors
```

### SEE ALSO

* [zetacored tx](zetacored_tx.md) - Transactions subcommands

9 changes: 9 additions & 0 deletions proto/zetachain/zetacore/ibccrosschain/genesis.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
syntax = "proto3";
package zetachain.zetacore.ibccrosschain;

import "gogoproto/gogo.proto";

option go_package = "github.com/zeta-chain/zetacore/x/ibccrosschain/types";

// GenesisState defines the ibccrosschain module's genesis state.
message GenesisState {}
7 changes: 7 additions & 0 deletions proto/zetachain/zetacore/ibccrosschain/query.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
syntax = "proto3";
package zetachain.zetacore.ibccrosschain;

option go_package = "github.com/zeta-chain/zetacore/x/ibccrosschain/types";

// Query defines the gRPC querier service.
service Query {}
9 changes: 9 additions & 0 deletions proto/zetachain/zetacore/ibccrosschain/tx.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
syntax = "proto3";
package zetachain.zetacore.ibccrosschain;

import "gogoproto/gogo.proto";

option go_package = "github.com/zeta-chain/zetacore/x/ibccrosschain/types";

// Msg defines the Msg service.
service Msg {}
Loading
Loading