Skip to content

Commit

Permalink
Merge pull request #3 from Lazychain/gjermund/rappdk
Browse files Browse the repository at this point in the history
feat: integrate sequencer and staking from rappdk
  • Loading branch information
gjermundgaraba authored Jul 8, 2024
2 parents f6f3c06 + e8f5974 commit ab45a2a
Show file tree
Hide file tree
Showing 9 changed files with 309 additions and 211 deletions.
42 changes: 20 additions & 22 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ import (
ibcfeekeeper "github.com/cosmos/ibc-go/v8/modules/apps/29-fee/keeper"
ibctransferkeeper "github.com/cosmos/ibc-go/v8/modules/apps/transfer/keeper"
ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper"
sequencerkeeper "github.com/decentrio/rollkit-sdk/x/sequencer/keeper"
rollkitstakingkeeper "github.com/decentrio/rollkit-sdk/x/staking/keeper"

_ "cosmossdk.io/api/cosmos/tx/config/v1" // import for side-effects
_ "cosmossdk.io/x/circuit" // import for side-effects
_ "cosmossdk.io/x/evidence" // import for side-effects
_ "cosmossdk.io/x/feegrant/module" // import for side-effects
_ "cosmossdk.io/x/upgrade" // import for side-effects
_ "github.com/cosmos/cosmos-sdk/x/auth/tx/config" // import for side-effects
Expand All @@ -24,19 +25,18 @@ import (
_ "github.com/cosmos/cosmos-sdk/x/consensus" // import for side-effects
_ "github.com/cosmos/cosmos-sdk/x/crisis" // import for side-effects
_ "github.com/cosmos/cosmos-sdk/x/distribution" // import for side-effects
_ "github.com/cosmos/cosmos-sdk/x/mint" // import for side-effects
_ "github.com/cosmos/cosmos-sdk/x/params" // import for side-effects
_ "github.com/cosmos/cosmos-sdk/x/slashing" // import for side-effects
_ "github.com/cosmos/cosmos-sdk/x/staking" // import for side-effects
_ "github.com/cosmos/ibc-go/modules/capability" // import for side-effects
_ "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts" // import for side-effects
_ "github.com/cosmos/ibc-go/v8/modules/apps/29-fee" // import for side-effects
_ "github.com/decentrio/rollkit-sdk/x/sequencer" // import for side-effects
_ "github.com/decentrio/rollkit-sdk/x/staking" // import for side-effects

"cosmossdk.io/depinject"
"cosmossdk.io/log"
storetypes "cosmossdk.io/store/types"
circuitkeeper "cosmossdk.io/x/circuit/keeper"
evidencekeeper "cosmossdk.io/x/evidence/keeper"
feegrantkeeper "cosmossdk.io/x/feegrant/keeper"
upgradekeeper "cosmossdk.io/x/upgrade/keeper"

Expand All @@ -61,11 +61,13 @@ import (
distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper"
"github.com/cosmos/cosmos-sdk/x/genutil"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
mintkeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper"
"github.com/cosmos/cosmos-sdk/x/gov"
govclient "github.com/cosmos/cosmos-sdk/x/gov/client"
govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
paramsclient "github.com/cosmos/cosmos-sdk/x/params/client"
paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"

tmproto "github.com/cometbft/cometbft/proto/tendermint/types"

Expand Down Expand Up @@ -98,17 +100,15 @@ type LazyApp struct {
// keepers
AccountKeeper authkeeper.AccountKeeper
BankKeeper bankkeeper.Keeper
StakingKeeper *stakingkeeper.Keeper
StakingKeeper *rollkitstakingkeeper.Keeper
DistrKeeper distrkeeper.Keeper
GovKeeper *govkeeper.Keeper
ConsensusParamsKeeper consensuskeeper.Keeper

SlashingKeeper slashingkeeper.Keeper
MintKeeper mintkeeper.Keeper
CrisisKeeper *crisiskeeper.Keeper
UpgradeKeeper *upgradekeeper.Keeper
ParamsKeeper paramskeeper.Keeper
AuthzKeeper authzkeeper.Keeper
EvidenceKeeper evidencekeeper.Keeper
FeeGrantKeeper feegrantkeeper.Keeper
CircuitBreakerKeeper circuitkeeper.Keeper

Expand All @@ -126,6 +126,8 @@ type LazyApp struct {
WasmKeeper wasmkeeper.Keeper
ScopedWasmKeeper capabilitykeeper.ScopedKeeper

SequencerKeeper sequencerkeeper.Keeper

// this line is used by starport scaffolding # stargate/app/keeperDeclaration

// simulation manager
Expand All @@ -151,6 +153,11 @@ func Config() depinject.Config {
// supply custom module basics
map[string]module.AppModuleBasic{
genutiltypes.ModuleName: genutil.NewAppModuleBasic(genutiltypes.DefaultMessageValidator),
govtypes.ModuleName: gov.NewAppModuleBasic(
[]govclient.ProposalHandler{
paramsclient.ProposalHandler,
},
),
// this line is used by starport scaffolding # stargate/appConfig/moduleBasic
},
),
Expand Down Expand Up @@ -215,14 +222,6 @@ func New(
//
// func() runtime.ValidatorAddressCodec { return <- custom validator address codec type -> }
// func() runtime.ConsensusAddressCodec { return <- custom consensus address codec type -> }

//
// MINT
//

// For providing a custom inflation function for x/mint add here your
// custom function that implements the minttypes.InflationCalculationFn
// interface.
),
)
)
Expand All @@ -237,16 +236,15 @@ func New(
&app.BankKeeper,
&app.StakingKeeper,
&app.DistrKeeper,
&app.GovKeeper,
&app.ConsensusParamsKeeper,
&app.SlashingKeeper,
&app.MintKeeper,
&app.CrisisKeeper,
&app.UpgradeKeeper,
&app.ParamsKeeper,
&app.AuthzKeeper,
&app.EvidenceKeeper,
&app.FeeGrantKeeper,
&app.CircuitBreakerKeeper,
&app.SequencerKeeper,
// this line is used by starport scaffolding # stargate/app/keeperDefinition
); err != nil {
panic(err)
Expand Down
46 changes: 17 additions & 29 deletions app/app_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
ibcfeetypes "github.com/cosmos/ibc-go/v8/modules/apps/29-fee/types"
ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"
ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported"
sequencerv1 "github.com/decentrio/rollkit-sdk/api/rollkitsdk/sequencer/module"
sequencertypes "github.com/decentrio/rollkit-sdk/x/sequencer/types"

runtimev1alpha1 "cosmossdk.io/api/cosmos/app/runtime/v1alpha1"
appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1"
Expand All @@ -16,20 +18,17 @@ import (
consensusmodulev1 "cosmossdk.io/api/cosmos/consensus/module/v1"
crisismodulev1 "cosmossdk.io/api/cosmos/crisis/module/v1"
distrmodulev1 "cosmossdk.io/api/cosmos/distribution/module/v1"
evidencemodulev1 "cosmossdk.io/api/cosmos/evidence/module/v1"
feegrantmodulev1 "cosmossdk.io/api/cosmos/feegrant/module/v1"
genutilmodulev1 "cosmossdk.io/api/cosmos/genutil/module/v1"
mintmodulev1 "cosmossdk.io/api/cosmos/mint/module/v1"
govmodulev1 "cosmossdk.io/api/cosmos/gov/module/v1"
paramsmodulev1 "cosmossdk.io/api/cosmos/params/module/v1"
slashingmodulev1 "cosmossdk.io/api/cosmos/slashing/module/v1"
stakingmodulev1 "cosmossdk.io/api/cosmos/staking/module/v1"
txconfigv1 "cosmossdk.io/api/cosmos/tx/config/v1"
upgrademodulev1 "cosmossdk.io/api/cosmos/upgrade/module/v1"
vestingmodulev1 "cosmossdk.io/api/cosmos/vesting/module/v1"
"cosmossdk.io/core/appconfig"
"cosmossdk.io/depinject"
circuittypes "cosmossdk.io/x/circuit/types"
evidencetypes "cosmossdk.io/x/evidence/types"
"cosmossdk.io/x/feegrant"
upgradetypes "cosmossdk.io/x/upgrade/types"

Expand All @@ -42,9 +41,8 @@ import (
crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types"
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
)

Expand All @@ -61,13 +59,12 @@ var (
authtypes.ModuleName,
banktypes.ModuleName,
distrtypes.ModuleName,
sequencertypes.ModuleName,
stakingtypes.ModuleName,
slashingtypes.ModuleName,
minttypes.ModuleName,
govtypes.ModuleName,
crisistypes.ModuleName,
ibcexported.ModuleName,
genutiltypes.ModuleName,
evidencetypes.ModuleName,
authz.ModuleName,
ibctransfertypes.ModuleName,
ibcfeetypes.ModuleName,
Expand All @@ -82,17 +79,11 @@ var (
// this line is used by starport scaffolding # stargate/app/initGenesis
}

// During begin block slashing happens after distr.BeginBlocker so that
// there is nothing left over in the validator fee pool, so as to keep the
// CanWithdrawInvariant invariant.
// NOTE: staking module is required if HistoricalEntries param > 0
// NOTE: capability module's beginblocker must come before any modules using capabilities (e.g. IBC)
beginBlockers = []string{
// cosmos sdk modules
minttypes.ModuleName,
distrtypes.ModuleName,
slashingtypes.ModuleName,
evidencetypes.ModuleName,
stakingtypes.ModuleName,
authz.ModuleName,
genutiltypes.ModuleName,
Expand All @@ -109,6 +100,8 @@ var (
endBlockers = []string{
// cosmos sdk modules
crisistypes.ModuleName,
govtypes.ModuleName,
sequencertypes.ModuleName,
stakingtypes.ModuleName,
feegrant.ModuleName,
genutiltypes.ModuleName,
Expand All @@ -131,9 +124,9 @@ var (
moduleAccPerms = []*authmodulev1.ModuleAccountPermission{
{Account: authtypes.FeeCollectorName},
{Account: distrtypes.ModuleName},
{Account: minttypes.ModuleName, Permissions: []string{authtypes.Minter}},
{Account: stakingtypes.BondedPoolName, Permissions: []string{authtypes.Burner, stakingtypes.ModuleName}},
{Account: stakingtypes.NotBondedPoolName, Permissions: []string{authtypes.Burner, stakingtypes.ModuleName}},
{Account: govtypes.ModuleName, Permissions: []string{authtypes.Burner}},
{Account: ibctransfertypes.ModuleName, Permissions: []string{authtypes.Minter, authtypes.Burner}},
{Account: ibcfeetypes.ModuleName},
{Account: wasmtypes.ModuleName, Permissions: []string{authtypes.Burner}},
Expand All @@ -144,7 +137,6 @@ var (
blockAccAddrs = []string{
authtypes.FeeCollectorName,
distrtypes.ModuleName,
minttypes.ModuleName,
stakingtypes.BondedPoolName,
stakingtypes.NotBondedPoolName,
}
Expand Down Expand Up @@ -205,10 +197,6 @@ func appConfig() depinject.Config {
Bech32PrefixConsensus: AccountAddressPrefix + "valcons",
}),
},
{
Name: slashingtypes.ModuleName,
Config: appconfig.WrapAny(&slashingmodulev1.Module{}),
},
{
Name: paramstypes.ModuleName,
Config: appconfig.WrapAny(&paramsmodulev1.Module{}),
Expand All @@ -233,18 +221,14 @@ func appConfig() depinject.Config {
Name: distrtypes.ModuleName,
Config: appconfig.WrapAny(&distrmodulev1.Module{}),
},
{
Name: evidencetypes.ModuleName,
Config: appconfig.WrapAny(&evidencemodulev1.Module{}),
},
{
Name: minttypes.ModuleName,
Config: appconfig.WrapAny(&mintmodulev1.Module{}),
},
{
Name: feegrant.ModuleName,
Config: appconfig.WrapAny(&feegrantmodulev1.Module{}),
},
{
Name: govtypes.ModuleName,
Config: appconfig.WrapAny(&govmodulev1.Module{}),
},
{
Name: crisistypes.ModuleName,
Config: appconfig.WrapAny(&crisismodulev1.Module{}),
Expand All @@ -257,6 +241,10 @@ func appConfig() depinject.Config {
Name: circuittypes.ModuleName,
Config: appconfig.WrapAny(&circuitmodulev1.Module{}),
},
{
Name: sequencertypes.ModuleName,
Config: appconfig.WrapAny(&sequencerv1.Module{}),
},
// this line is used by starport scaffolding # stargate/app/moduleConfig
},
})
Expand Down
17 changes: 1 addition & 16 deletions app/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (

servertypes "github.com/cosmos/cosmos-sdk/server/types"
sdk "github.com/cosmos/cosmos-sdk/types"
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
"github.com/cosmos/cosmos-sdk/x/staking"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"

Expand Down Expand Up @@ -40,7 +39,7 @@ func (app *LazyApp) ExportAppStateAndValidators(forZeroHeight bool, jailAllowedA
return servertypes.ExportedApp{}, err
}

validators, err := staking.WriteValidators(ctx, app.StakingKeeper)
validators, err := staking.WriteValidators(ctx, &app.StakingKeeper.Keeper)
return servertypes.ExportedApp{
AppState: appState,
Validators: validators,
Expand Down Expand Up @@ -229,18 +228,4 @@ func (app *LazyApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs [
if err != nil {
log.Fatal(err)
}

/* Handle slashing state. */

// reset start height on signing infos
if err := app.SlashingKeeper.IterateValidatorSigningInfos(
ctx,
func(addr sdk.ConsAddress, info slashingtypes.ValidatorSigningInfo) (stop bool) {
info.StartHeight = 0
_ = app.SlashingKeeper.SetValidatorSigningInfo(ctx, addr, info)
return false
},
); err != nil {
log.Fatal(err)
}
}
4 changes: 2 additions & 2 deletions cmd/lazychaind/cmd/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,15 @@ func newApp(
) servertypes.Application {
baseappOptions := server.DefaultBaseappOptions(appOpts)

slothApp, err := app.New(
lazyApp, err := app.New(
logger, db, traceStore, true,
appOpts,
baseappOptions...,
)
if err != nil {
panic(err)
}
return slothApp
return lazyApp
}

// appExport creates a new app (optionally at a given height) and exports state.
Expand Down
2 changes: 1 addition & 1 deletion cmd/lazychaind/cmd/tia/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func TransferCmd() *cobra.Command {
}

now := time.Now()
fiveMinutesLater := now.Add(5 * time.Minute) // TODO: Maybe more...
fiveMinutesLater := now.Add(10 * time.Minute) // TODO: Maybe more...
msg := transfertypes.NewMsgTransfer("transfer", ics20Channel, sdk.NewCoin(denom, sdkmath.NewInt(amount)), from, to, clienttypes.Height{}, uint64(fiveMinutesLater.UnixNano()), "")

if err := cmd.Flags().Set(sdkflags.FlagFrom, from); err != nil {
Expand Down
Loading

0 comments on commit ab45a2a

Please sign in to comment.