Skip to content

Commit

Permalink
Merge branch 'celestiaorg:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
ninabarbakadze authored Apr 25, 2024
2 parents 72ffbd5 + a00db2b commit c01e862
Show file tree
Hide file tree
Showing 22 changed files with 548 additions and 186 deletions.
93 changes: 47 additions & 46 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,24 @@ import (
"io"
"slices"

"github.com/celestiaorg/celestia-app/v2/app/ante"
"github.com/celestiaorg/celestia-app/v2/app/encoding"
"github.com/celestiaorg/celestia-app/v2/app/module"
"github.com/celestiaorg/celestia-app/v2/app/posthandler"
appv1 "github.com/celestiaorg/celestia-app/v2/pkg/appconsts/v1"
appv2 "github.com/celestiaorg/celestia-app/v2/pkg/appconsts/v2"
"github.com/celestiaorg/celestia-app/v2/pkg/proof"
blobkeeper "github.com/celestiaorg/celestia-app/v2/x/blob/keeper"
blobtypes "github.com/celestiaorg/celestia-app/v2/x/blob/types"
blobstreamkeeper "github.com/celestiaorg/celestia-app/v2/x/blobstream/keeper"
blobstreamtypes "github.com/celestiaorg/celestia-app/v2/x/blobstream/types"
"github.com/celestiaorg/celestia-app/v2/x/minfee"
mintkeeper "github.com/celestiaorg/celestia-app/v2/x/mint/keeper"
minttypes "github.com/celestiaorg/celestia-app/v2/x/mint/types"
"github.com/celestiaorg/celestia-app/v2/x/paramfilter"
"github.com/celestiaorg/celestia-app/v2/x/signal"
signaltypes "github.com/celestiaorg/celestia-app/v2/x/signal/types"
"github.com/celestiaorg/celestia-app/v2/x/tokenfilter"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"
nodeservice "github.com/cosmos/cosmos-sdk/client/grpc/node"
Expand Down Expand Up @@ -54,44 +67,27 @@ import (
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
"github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v6/packetforward"
packetforwardkeeper "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v6/packetforward/keeper"
packetforwardtypes "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v6/packetforward/types"
icahost "github.com/cosmos/ibc-go/v6/modules/apps/27-interchain-accounts/host"
icahostkeeper "github.com/cosmos/ibc-go/v6/modules/apps/27-interchain-accounts/host/keeper"
icahosttypes "github.com/cosmos/ibc-go/v6/modules/apps/27-interchain-accounts/host/types"
icatypes "github.com/cosmos/ibc-go/v6/modules/apps/27-interchain-accounts/types"
"github.com/cosmos/ibc-go/v6/modules/apps/transfer"
ibctransferkeeper "github.com/cosmos/ibc-go/v6/modules/apps/transfer/keeper"
ibctransfertypes "github.com/cosmos/ibc-go/v6/modules/apps/transfer/types"
ibcclienttypes "github.com/cosmos/ibc-go/v6/modules/core/02-client/types"
ibcporttypes "github.com/cosmos/ibc-go/v6/modules/core/05-port/types"
ibchost "github.com/cosmos/ibc-go/v6/modules/core/24-host"
ibckeeper "github.com/cosmos/ibc-go/v6/modules/core/keeper"
ibctestingtypes "github.com/cosmos/ibc-go/v6/testing/types"
"github.com/spf13/cast"
abci "github.com/tendermint/tendermint/abci/types"
tmjson "github.com/tendermint/tendermint/libs/json"
"github.com/tendermint/tendermint/libs/log"
tmos "github.com/tendermint/tendermint/libs/os"
dbm "github.com/tendermint/tm-db"

"github.com/celestiaorg/celestia-app/v2/app/ante"
"github.com/celestiaorg/celestia-app/v2/app/encoding"
appv1 "github.com/celestiaorg/celestia-app/v2/pkg/appconsts/v1"
appv2 "github.com/celestiaorg/celestia-app/v2/pkg/appconsts/v2"
"github.com/celestiaorg/celestia-app/v2/pkg/proof"
blobkeeper "github.com/celestiaorg/celestia-app/v2/x/blob/keeper"
blobtypes "github.com/celestiaorg/celestia-app/v2/x/blob/types"
"github.com/celestiaorg/celestia-app/v2/x/paramfilter"
"github.com/celestiaorg/celestia-app/v2/x/tokenfilter"

blobstreamkeeper "github.com/celestiaorg/celestia-app/v2/x/blobstream/keeper"
blobstreamtypes "github.com/celestiaorg/celestia-app/v2/x/blobstream/types"
"github.com/celestiaorg/celestia-app/v2/x/signal"
signaltypes "github.com/celestiaorg/celestia-app/v2/x/signal/types"
ibctestingtypes "github.com/cosmos/ibc-go/v6/testing/types"

"github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v6/packetforward"
packetforwardkeeper "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v6/packetforward/keeper"
packetforwardtypes "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v6/packetforward/types"

icahost "github.com/cosmos/ibc-go/v6/modules/apps/27-interchain-accounts/host"
icahostkeeper "github.com/cosmos/ibc-go/v6/modules/apps/27-interchain-accounts/host/keeper"
icahosttypes "github.com/cosmos/ibc-go/v6/modules/apps/27-interchain-accounts/host/types"
icatypes "github.com/cosmos/ibc-go/v6/modules/apps/27-interchain-accounts/types"
)

// maccPerms is short for module account permissions.
Expand Down Expand Up @@ -153,18 +149,18 @@ type App struct {
FeeGrantKeeper feegrantkeeper.Keeper
ICAHostKeeper icahostkeeper.Keeper
PacketForwardKeeper *packetforwardkeeper.Keeper
BlobKeeper blobkeeper.Keeper
BlobstreamKeeper blobstreamkeeper.Keeper

ScopedIBCKeeper capabilitykeeper.ScopedKeeper // This keeper is public for test purposes
ScopedTransferKeeper capabilitykeeper.ScopedKeeper // This keeper is public for test purposes
ScopedICAHostKeeper capabilitykeeper.ScopedKeeper // This keeper is public for test purposes

BlobKeeper blobkeeper.Keeper
BlobstreamKeeper blobstreamkeeper.Keeper

mm *module.Manager
configurator module.Configurator
// used as a coordination mechanism for height based upgrades
upgradeHeight int64
// upgradeHeightV2 is used as a coordination mechanism for the height-based
// upgrade from v1 to v2.
upgradeHeightV2 int64
// used to define what messages are accepted for a given app version
MsgGateKeeper *ante.MsgVersioningGateKeeper
}
Expand All @@ -180,7 +176,7 @@ func New(
traceStore io.Writer,
invCheckPeriod uint,
encodingConfig encoding.Config,
upgradeHeight int64,
upgradeHeightV2 int64,
appOpts servertypes.AppOptions,
baseAppOptions ...func(*baseapp.BaseApp),
) *App {
Expand All @@ -207,6 +203,7 @@ func New(
keys: keys,
tkeys: tkeys,
memKeys: memKeys,
upgradeHeightV2: upgradeHeightV2,
}

app.ParamsKeeper = initParamsKeeper(appCodec, cdc, keys[paramstypes.StoreKey], tkeys[paramstypes.TStoreKey])
Expand Down Expand Up @@ -259,7 +256,6 @@ func New(
// upgrade. This keeper is not used for the actual upgrades but merely for compatibility reasons. Ideally IBC has their own upgrade module
// for performing IBC based upgrades. Note, as we use rolling upgrades, IBC technically never needs this functionality.
app.UpgradeKeeper = upgradekeeper.NewKeeper(nil, keys[upgradetypes.StoreKey], appCodec, "", app.BaseApp, authtypes.NewModuleAddress(govtypes.ModuleName).String())
app.upgradeHeight = upgradeHeight

app.BlobstreamKeeper = *blobstreamkeeper.NewKeeper(
appCodec,
Expand All @@ -268,10 +264,11 @@ func New(
&stakingKeeper,
)

// register the staking hooks
// NOTE: stakingKeeper above is passed by reference, so that it will contain these hooks
// Register the staking hooks. NOTE: stakingKeeper is passed by reference
// above so that it will contain these hooks.
app.StakingKeeper = *stakingKeeper.SetHooks(
stakingtypes.NewMultiStakingHooks(app.DistrKeeper.Hooks(),
stakingtypes.NewMultiStakingHooks(
app.DistrKeeper.Hooks(),
app.SlashingKeeper.Hooks(),
app.BlobstreamKeeper.Hooks(),
),
Expand Down Expand Up @@ -341,18 +338,23 @@ func New(
packetforwardkeeper.DefaultRefundTransferPacketTimeoutTimestamp, // refund timeout
)

// Create evidence Keeper for to register the IBC light client misbehaviour evidence route
evidenceKeeper := evidencekeeper.NewKeeper(
appCodec, keys[evidencetypes.StoreKey], &app.StakingKeeper, app.SlashingKeeper,
app.EvidenceKeeper = *evidencekeeper.NewKeeper(
appCodec,
keys[evidencetypes.StoreKey],
&app.StakingKeeper,
app.SlashingKeeper,
)
// If evidence needs to be handled for the app, set routes in router here and seal
app.EvidenceKeeper = *evidenceKeeper

govConfig := govtypes.DefaultConfig()

app.GovKeeper = govkeeper.NewKeeper(
appCodec, keys[govtypes.StoreKey], app.GetSubspace(govtypes.ModuleName), app.AccountKeeper, app.BankKeeper,
&stakingKeeper, govRouter, bApp.MsgServiceRouter(), govConfig,
appCodec,
keys[govtypes.StoreKey],
app.GetSubspace(govtypes.ModuleName),
app.AccountKeeper,
app.BankKeeper,
&stakingKeeper,
govRouter,
bApp.MsgServiceRouter(),
govtypes.DefaultConfig(),
)

app.BlobKeeper = *blobkeeper.NewKeeper(
Expand Down Expand Up @@ -399,7 +401,6 @@ func New(
app.MountTransientStores(tkeys)
app.MountMemoryStores(memKeys)

// initialize BaseApp
app.SetInitChainer(app.InitChainer)
app.SetBeginBlocker(app.BeginBlocker)
app.SetEndBlocker(app.EndBlocker)
Expand Down Expand Up @@ -446,7 +447,7 @@ func (app *App) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.Respo
// For v1 only we upgrade using a agreed upon height known ahead of time
if currentVersion == v1 {
// check that we are at the height before the upgrade
if req.Height == app.upgradeHeight-1 {
if req.Height == app.upgradeHeightV2-1 {
app.SetInitialAppVersionInConsensusParams(ctx, v2)
app.SetAppVersion(ctx, v2)
}
Expand Down
9 changes: 9 additions & 0 deletions app/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ func TestNew(t *testing.T) {
t.Run("initializes ScopedICAHostKeeper", func(t *testing.T) {
assert.NotNil(t, got.ScopedICAHostKeeper)
})
t.Run("initializes StakingKeeper", func(t *testing.T) {
assert.NotNil(t, got.StakingKeeper)
})
t.Run("should have set StakingKeeper hooks", func(t *testing.T) {
// StakingKeeper doesn't expose a GetHooks method so this checks if
// hooks have been set by verifying the a subsequent call to SetHooks
// will panic.
assert.Panics(t, func() { got.StakingKeeper.SetHooks(nil) })
})
}

// NoopWriter is a no-op implementation of a writer.
Expand Down
40 changes: 20 additions & 20 deletions app/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,39 +307,39 @@ func versionedStoreKeys() map[uint64][]string {
authtypes.StoreKey,
authzkeeper.StoreKey,
banktypes.StoreKey,
stakingtypes.StoreKey,
minttypes.StoreKey,
blobstreamtypes.StoreKey,
blobtypes.StoreKey,
capabilitytypes.StoreKey,
distrtypes.StoreKey,
slashingtypes.StoreKey,
govtypes.StoreKey,
upgradetypes.StoreKey,
feegrant.StoreKey,
evidencetypes.StoreKey,
capabilitytypes.StoreKey,
blobstreamtypes.StoreKey,
ibctransfertypes.StoreKey,
feegrant.StoreKey,
govtypes.StoreKey,
ibchost.StoreKey,
blobtypes.StoreKey,
ibctransfertypes.StoreKey,
minttypes.StoreKey,
slashingtypes.StoreKey,
stakingtypes.StoreKey,
upgradetypes.StoreKey,
},
2: {
authtypes.StoreKey,
authzkeeper.StoreKey,
banktypes.StoreKey,
stakingtypes.StoreKey,
minttypes.StoreKey,
blobstreamtypes.StoreKey,
capabilitytypes.StoreKey,
distrtypes.StoreKey,
slashingtypes.StoreKey,
govtypes.StoreKey,
upgradetypes.StoreKey,
feegrant.StoreKey,
evidencetypes.StoreKey,
capabilitytypes.StoreKey,
blobstreamtypes.StoreKey,
ibctransfertypes.StoreKey,
feegrant.StoreKey,
govtypes.StoreKey,
ibchost.StoreKey,
packetforwardtypes.StoreKey,
ibctransfertypes.StoreKey,
icahosttypes.StoreKey,
minttypes.StoreKey,
packetforwardtypes.StoreKey,
signaltypes.StoreKey,
slashingtypes.StoreKey,
stakingtypes.StoreKey,
upgradetypes.StoreKey,
},
}
}
Expand Down
20 changes: 10 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ require (
github.com/cosmos/cosmos-sdk v0.46.16
github.com/cosmos/gogoproto v1.4.12
github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v6 v6.1.2
github.com/cosmos/ibc-go/v6 v6.3.0
github.com/ethereum/go-ethereum v1.13.15
github.com/cosmos/ibc-go/v6 v6.3.1
github.com/ethereum/go-ethereum v1.14.0
github.com/gogo/protobuf v1.3.3
github.com/golang/mock v1.6.0
github.com/golang/protobuf v1.5.4
Expand Down Expand Up @@ -74,7 +74,7 @@ require (
github.com/cosmos/gorocksdb v1.2.0 // indirect
github.com/cosmos/iavl v0.19.6 // indirect
github.com/cosmos/ledger-cosmos-go v0.13.2 // indirect
github.com/crate-crypto/go-kzg-4844 v0.7.0 // indirect
github.com/crate-crypto/go-kzg-4844 v1.0.0 // indirect
github.com/creachadair/taskgroup v0.3.2 // indirect
github.com/danieljoos/wincred v1.1.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
Expand All @@ -92,7 +92,7 @@ require (
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/dvsekhvalnov/jose2go v1.6.0 // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/ethereum/c-kzg-4844 v0.4.0 // indirect
github.com/ethereum/c-kzg-4844 v1.0.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-kit/kit v0.12.0 // indirect
Expand Down Expand Up @@ -225,16 +225,16 @@ require (
go.uber.org/atomic v1.11.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.24.0 // indirect
golang.org/x/crypto v0.21.0 // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/net v0.23.0 // indirect
golang.org/x/crypto v0.22.0 // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.24.0 // indirect
golang.org/x/oauth2 v0.17.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/term v0.18.0 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/term v0.19.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.17.0 // indirect
golang.org/x/tools v0.20.0 // indirect
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect
google.golang.org/api v0.162.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
Expand Down
Loading

0 comments on commit c01e862

Please sign in to comment.