Skip to content

Commit

Permalink
Merge pull request #1 from nucleic-network/rollup
Browse files Browse the repository at this point in the history
Add implementation of rollup module
  • Loading branch information
tnv1 authored May 19, 2024
2 parents a7bc70e + d81ad96 commit 7b31f68
Show file tree
Hide file tree
Showing 77 changed files with 16,414 additions and 46 deletions.
80 changes: 43 additions & 37 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,12 @@ import (
ibctransferkeeper "github.com/cosmos/ibc-go/v8/modules/apps/transfer/keeper"
ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"
ibc "github.com/cosmos/ibc-go/v8/modules/core"
ibcclienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
ibcclienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" //nolint:staticcheck
ibcconnectiontypes "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types"
porttypes "github.com/cosmos/ibc-go/v8/modules/core/05-port/types"
ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported"
ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper"
ibctm "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint"
feeabsmodule "github.com/osmosis-labs/fee-abstraction/v8/x/feeabs"
feeabskeeper "github.com/osmosis-labs/fee-abstraction/v8/x/feeabs/keeper"
feeabstypes "github.com/osmosis-labs/fee-abstraction/v8/x/feeabs/types"
"github.com/osmosis-labs/tokenfactory"
"github.com/osmosis-labs/tokenfactory/bindings"
tokenfactorykeeper "github.com/osmosis-labs/tokenfactory/keeper"
Expand Down Expand Up @@ -151,6 +148,13 @@ import (
"github.com/CosmWasm/wasmd/x/wasm"
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"

"github.com/eve-network/eve/x/rollapp"
rollappkeeper "github.com/eve-network/eve/x/rollapp/keeper"
rollapptypes "github.com/eve-network/eve/x/rollapp/types"

denommetadatakeeper "github.com/eve-network/eve/x/denommetadata/keeper"
denommetadatatypes "github.com/eve-network/eve/x/denommetadata/types"
)

const appName = "EveApp"
Expand Down Expand Up @@ -205,7 +209,6 @@ var maccPerms = map[string][]string{
tokenfactorytypes.ModuleName: {authtypes.Minter, authtypes.Burner},
alliancemoduletypes.ModuleName: {authtypes.Minter, authtypes.Burner},
alliancemoduletypes.RewardsPoolName: nil,
feeabstypes.ModuleName: nil,
}

var (
Expand Down Expand Up @@ -245,7 +248,6 @@ type EveApp struct {
NFTKeeper nftkeeper.Keeper
ConsensusParamsKeeper consensusparamkeeper.Keeper
CircuitKeeper circuitkeeper.Keeper
FeeabsKeeper feeabskeeper.Keeper

IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly
IBCFeeKeeper ibcfeekeeper.Keeper
Expand All @@ -264,10 +266,13 @@ type EveApp struct {
ScopedTransferKeeper capabilitykeeper.ScopedKeeper
ScopedIBCFeeKeeper capabilitykeeper.ScopedKeeper
ScopedWasmKeeper capabilitykeeper.ScopedKeeper
ScopedFeeabsKeeper capabilitykeeper.ScopedKeeper

TokenFactoryKeeper tokenfactorykeeper.Keeper

RollappKeeper rollappkeeper.Keeper

DenomMetadataKeeper *denommetadatakeeper.Keeper

// the module manager
ModuleManager *module.Manager
BasicModuleManager module.BasicManager
Expand Down Expand Up @@ -332,7 +337,8 @@ func NewEveApp(
icacontrollertypes.StoreKey, tokenfactorytypes.StoreKey,
ibchookstypes.StoreKey,
alliancemoduletypes.StoreKey,
feeabstypes.StoreKey,
denommetadatatypes.ModuleName,
rollapptypes.StoreKey,
)

tkeys := storetypes.NewTransientStoreKeys(paramstypes.TStoreKey)
Expand Down Expand Up @@ -384,7 +390,7 @@ func NewEveApp(
scopedICAControllerKeeper := app.CapabilityKeeper.ScopeToModule(icacontrollertypes.SubModuleName)
scopedTransferKeeper := app.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName)
scopedWasmKeeper := app.CapabilityKeeper.ScopeToModule(wasmtypes.ModuleName)
scopedFeeabsKeeper := app.CapabilityKeeper.ScopeToModule(feeabstypes.ModuleName)

// add keepers

app.AccountKeeper = authkeeper.NewAccountKeeper(
Expand Down Expand Up @@ -565,8 +571,7 @@ func NewEveApp(
// See: https://docs.cosmos.network/main/modules/gov#proposal-messages
govRouter := govv1beta1.NewRouter()
govRouter.AddRoute(govtypes.RouterKey, govv1beta1.ProposalHandler).
AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)).AddRoute(alliancemoduletypes.RouterKey, alliancemodule.NewAllianceProposalHandler(app.AllianceKeeper)).
AddRoute(feeabstypes.RouterKey, feeabsmodule.NewHostZoneProposal(app.FeeabsKeeper))
AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)).AddRoute(alliancemoduletypes.RouterKey, alliancemodule.NewAllianceProposalHandler(app.AllianceKeeper))

govConfig := govtypes.DefaultConfig()
/*
Expand Down Expand Up @@ -613,20 +618,6 @@ func NewEveApp(
// If evidence needs to be handled for the app, set routes in router here and seal
app.EvidenceKeeper = *evidenceKeeper

app.FeeabsKeeper = feeabskeeper.NewKeeper(
appCodec,
app.keys[feeabstypes.StoreKey],
app.GetSubspace(feeabstypes.ModuleName),
&app.StakingKeeper,
app.AccountKeeper,
app.BankKeeper.BaseKeeper,
app.TransferKeeper,
app.IBCKeeper.ChannelKeeper,
app.IBCKeeper.PortKeeper,
scopedFeeabsKeeper,
)

feeabsIBCModule := feeabsmodule.NewIBCModule(appCodec, app.FeeabsKeeper)
// Create Interchain Accounts Stack
// SendPacket, since it is originating from the application to core IBC:
// icaAuthModuleKeeper.SendTx -> icaController.SendPacket -> fee.SendPacket -> channel.SendPacket
Expand Down Expand Up @@ -658,8 +649,7 @@ func NewEveApp(
AddRoute(ibctransfertypes.ModuleName, transferStack).
AddRoute(wasmtypes.ModuleName, wasmStack).
AddRoute(icacontrollertypes.SubModuleName, icaControllerStack).
AddRoute(icahosttypes.SubModuleName, icaHostStack).
AddRoute(feeabstypes.ModuleName, feeabsIBCModule)
AddRoute(icahosttypes.SubModuleName, icaHostStack)
app.IBCKeeper.SetRouter(ibcRouter)

app.IBCHooksKeeper = ibchookskeeper.NewKeeper(
Expand Down Expand Up @@ -716,6 +706,21 @@ func NewEveApp(
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

app.DenomMetadataKeeper = denommetadatakeeper.NewKeeper(app.BankKeeper)

app.RollappKeeper = *rollappkeeper.NewKeeper(
appCodec,
keys[rollapptypes.StoreKey],
keys[rollapptypes.MemStoreKey],
app.GetSubspace(rollapptypes.ModuleName),
app.IBCKeeper.ClientKeeper,
app.TransferKeeper,
app.IBCKeeper.ChannelKeeper,
app.BankKeeper,
app.DenomMetadataKeeper,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

wasmConfig, err := wasm.ReadWasmConfig(appOpts)
if err != nil {
panic(fmt.Sprintf("error while reading wasm config: %s", err))
Expand Down Expand Up @@ -788,7 +793,9 @@ func NewEveApp(
// sdk
crisis.NewAppModule(app.CrisisKeeper, skipGenesisInvariants, app.GetSubspace(crisistypes.ModuleName)), // always be last to make sure that it checks for all invariants and not only part of them,
tokenfactory.NewAppModule(app.TokenFactoryKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(tokenfactorytypes.ModuleName)),
feeabsmodule.NewAppModule(appCodec, app.FeeabsKeeper),

// nucleic module
rollapp.NewAppModule(appCodec, app.RollappKeeper),
)

// BasicModuleManager defines the module BasicManager is in charge of setting up basic,
Expand All @@ -802,9 +809,6 @@ func NewEveApp(
govtypes.ModuleName: gov.NewAppModuleBasic(
[]govclient.ProposalHandler{
paramsclient.ProposalHandler,
feeabsmodule.UpdateAddHostZoneClientProposalHandler,
feeabsmodule.UpdateDeleteHostZoneClientProposalHandler,
feeabsmodule.UpdateSetHostZoneClientProposalHandler,
},
),
alliancemoduletypes.ModuleName: alliancemodule.AppModuleBasic{},
Expand Down Expand Up @@ -844,7 +848,7 @@ func NewEveApp(
wasmtypes.ModuleName,
tokenfactorytypes.ModuleName,
alliancemoduletypes.ModuleName,
feeabstypes.ModuleName,
rollapptypes.ModuleName,
)

app.ModuleManager.SetOrderEndBlockers(
Expand All @@ -865,7 +869,7 @@ func NewEveApp(
wasmtypes.ModuleName,
tokenfactorytypes.ModuleName,
alliancemoduletypes.ModuleName,
feeabstypes.ModuleName,
rollapptypes.ModuleName,
)

// NOTE: The genutils module must occur after staking so that pools are
Expand Down Expand Up @@ -912,7 +916,8 @@ func NewEveApp(
tokenfactorytypes.ModuleName,
alliancemoduletypes.ModuleName,

feeabstypes.ModuleName,
denommetadatatypes.ModuleName,
rollapptypes.ModuleName,
}
app.ModuleManager.SetOrderInitGenesis(genesisModuleOrder...)
app.ModuleManager.SetOrderExportGenesis(genesisModuleOrder...)
Expand Down Expand Up @@ -983,7 +988,6 @@ func NewEveApp(
app.ScopedWasmKeeper = scopedWasmKeeper
app.ScopedICAHostKeeper = scopedICAHostKeeper
app.ScopedICAControllerKeeper = scopedICAControllerKeeper
app.ScopedFeeabsKeeper = scopedFeeabsKeeper

app.setPostHandler()

Expand Down Expand Up @@ -1050,7 +1054,6 @@ func (app *EveApp) setAnteHandler(txConfig client.TxConfig, wasmConfig wasmtypes
FeegrantKeeper: app.FeeGrantKeeper,
SigGasConsumer: ante.DefaultSigVerificationGasConsumer,
},
FeeAbskeeper: app.FeeabsKeeper,
IBCKeeper: app.IBCKeeper,
WasmConfig: &wasmConfig,
WasmKeeper: &app.WasmKeeper,
Expand Down Expand Up @@ -1307,7 +1310,10 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(tokenfactorytypes.ModuleName).WithKeyTable(tokenfactorytypes.ParamKeyTable())
paramsKeeper.Subspace(wasmtypes.ModuleName)
paramsKeeper.Subspace(alliancemoduletypes.ModuleName)
paramsKeeper.Subspace(feeabstypes.ModuleName)

// register nucleic module key tables
paramsKeeper.Subspace(denommetadatatypes.ModuleName)
paramsKeeper.Subspace(rollapptypes.ModuleName)

return paramsKeeper
}
2 changes: 1 addition & 1 deletion app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (app *EveApp) RegisterUpgradeHandlers() {
// register store loader for current upgrade
for _, upgrade := range Upgrades {
if upgradeInfo.Name == upgrade.UpgradeName {
app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &upgrade.StoreUpgrades)) // nolint:gosec
app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &upgrade.StoreUpgrades))
break
}
}
Expand Down
16 changes: 8 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ require (
github.com/cosmos/iavl v1.1.2 // indirect
github.com/cosmos/ics23/go v0.10.0 // indirect
github.com/dvsekhvalnov/jose2go v1.6.0 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/golang/protobuf v1.5.4
github.com/google/gofuzz v1.2.0 // indirect
github.com/gorilla/mux v1.8.1 // indirect
github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect
github.com/osmosis-labs/fee-abstraction/v8 v8.0.0
github.com/grpc-ecosystem/grpc-gateway v1.16.0
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_golang v1.19.0
github.com/spf13/cast v1.6.0
Expand All @@ -26,14 +25,15 @@ require (
github.com/stretchr/testify v1.9.0
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/grpc v1.63.2 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
google.golang.org/grpc v1.63.2
gopkg.in/yaml.v2 v2.4.0
)

require (
cosmossdk.io/api v0.7.5
cosmossdk.io/client/v2 v2.0.0-beta.1
cosmossdk.io/core v0.11.0
cosmossdk.io/core v0.12.0
cosmossdk.io/errors v1.0.1
cosmossdk.io/log v1.3.1
cosmossdk.io/math v1.3.0
cosmossdk.io/store v1.1.0
Expand All @@ -50,8 +50,10 @@ require (
github.com/cosmos/ibc-go/modules/capability v1.0.0
github.com/cosmos/ibc-go/modules/light-clients/08-wasm v0.0.0-20240422180908-6ceba47cfa6e
github.com/cosmos/ibc-go/v8 v8.2.0
github.com/osmosis-labs/fee-abstraction/v8 v8.0.0
github.com/osmosis-labs/tokenfactory v0.0.0-20240310155926-981fbeb0fe42
github.com/terra-money/alliance v0.4.3
google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de
)

require (
Expand All @@ -62,7 +64,6 @@ require (
cloud.google.com/go/storage v1.36.0 // indirect
cosmossdk.io/collections v0.4.0 // indirect
cosmossdk.io/depinject v1.0.0-alpha.4 // indirect
cosmossdk.io/errors v1.0.1 // indirect
filippo.io/edwards25519 v1.0.0 // indirect
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
github.com/99designs/keyring v1.2.2 // indirect
Expand Down Expand Up @@ -204,7 +205,6 @@ require (
golang.org/x/time v0.5.0 // indirect
google.golang.org/api v0.162.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
Expand Down
8 changes: 8 additions & 0 deletions proto/buf.gen.gogo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: v1
plugins:
- name: gocosmos
out: ..
opt: plugins=grpc,Mgoogle/protobuf/any.proto=github.com/cosmos/cosmos-sdk/codec/types
- name: grpc-gateway
out: ..
opt: logtostderr=true,allow_colon_final_segments=true
28 changes: 28 additions & 0 deletions proto/buf.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by buf. DO NOT EDIT.
version: v1
deps:
- remote: buf.build
owner: cosmos
repository: cosmos-proto
commit: 1935555c206d4afb9e94615dfd0fad31
digest: shake256:c74d91a3ac7ae07d579e90eee33abf9b29664047ac8816500cf22c081fec0d72d62c89ce0bebafc1f6fec7aa5315be72606717740ca95007248425102c365377
- remote: buf.build
owner: cosmos
repository: cosmos-sdk
commit: 5a6ab7bc14314acaa912d5e53aef1c2f
digest: shake256:02c00c73493720055f9b57553a35b5550023a3c1914123b247956288a78fb913aff70e66552777ae14d759467e119079d484af081264a5dd607a94d9fbc8116b
- remote: buf.build
owner: cosmos
repository: gogo-proto
commit: 34d970b699f84aa382f3c29773a60836
digest: shake256:3d3bee5229ba579e7d19ffe6e140986a228b48a8c7fe74348f308537ab95e9135210e81812489d42cd8941d33ff71f11583174ccc5972e86e6112924b6ce9f04
- remote: buf.build
owner: cosmos
repository: ics23
commit: 55085f7c710a45f58fa09947208eb70b
digest: shake256:9bf0bc495b5a11c88d163d39ef521bc4b00bc1374a05758c91d82821bdc61f09e8c2c51dda8452529bf80137f34d852561eacbe9550a59015d51cecb0dacb628
- remote: buf.build
owner: googleapis
repository: googleapis
commit: 8d7204855ec14631a499bd7393ce1970
digest: shake256:40bf4112960cad01281930beed85829910768e32e80e986791596853eccd42c0cbd9d96690b918f658020d2d427e16f8b6514e2ac7f4a10306fd32e77be44329
23 changes: 23 additions & 0 deletions proto/buf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
version: v1
name: buf.build/nucleic-network/nucleic
deps:
- buf.build/cosmos/cosmos-sdk:v0.50.0
- buf.build/cosmos/cosmos-proto:1935555c206d4afb9e94615dfd0fad31
- buf.build/cosmos/gogo-proto:a14993478f40695898ed8a86931094b6656e8a5d
- buf.build/googleapis/googleapis:8d7204855ec14631a499bd7393ce1970
- buf.build/cosmos/ics23:b1abd8678aab07165efd453c96796a179eb3131f
breaking:
use:
- FILE
lint:
use:
- DEFAULT
- COMMENTS
- FILE_LOWER_SNAKE_CASE
except:
- UNARY_RPC
- COMMENT_FIELD
- SERVICE_SUFFIX
- PACKAGE_VERSION_SUFFIX
- RPC_REQUEST_STANDARD_NAME
- PACKAGE_DIRECTORY_MATCH
8 changes: 8 additions & 0 deletions proto/nucleic/denommetadata/genesis.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
syntax = "proto3";
package nucleic.denommetadata;

option go_package = "github.com/nucleic-network/nucleic/x/denommetadata/types";

// GenesisState defines the denommetadata module's various parameters when first
// initialized
message GenesisState {}
23 changes: 23 additions & 0 deletions proto/nucleic/denommetadata/gov.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
syntax = "proto3";
package nucleic.denommetadata;

option go_package = "github.com/nucleic-network/nucleic/x/denommetadata/types";

import "gogoproto/gogo.proto";
import "cosmos/bank/v1beta1/bank.proto";

message CreateDenomMetadataProposal {
option (gogoproto.goproto_getters) = false;
option (gogoproto.goproto_stringer) = false;
string title = 1;
string description = 2;
repeated cosmos.bank.v1beta1.Metadata token_metadata = 3[ (gogoproto.nullable) = false ];
}

message UpdateDenomMetadataProposal {
option (gogoproto.goproto_getters) = false;
option (gogoproto.goproto_stringer) = false;
string title = 1;
string description = 2;
repeated cosmos.bank.v1beta1.Metadata token_metadata = 3[ (gogoproto.nullable) = false ];
}
Loading

0 comments on commit 7b31f68

Please sign in to comment.