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 canonical light client for Rollapps #1098

Merged
merged 88 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
c4116c7
adding light client module
spoo-bar Aug 12, 2024
9340d9e
implement msgcreateclient antehandler
spoo-bar Aug 12, 2024
dfc1a24
implement ante handler for submit misbehaviour
spoo-bar Aug 12, 2024
c1a3f7e
implement msg update client ante
spoo-bar Aug 12, 2024
d56cf50
adding posthandler
spoo-bar Aug 13, 2024
11a0ad4
adding block timestamp to block descriptor
spoo-bar Aug 13, 2024
37bb6cf
implementing AfterUpdateState hook on rollapp update state
spoo-bar Aug 13, 2024
6c12f56
adding AfterUpdateState hook
spoo-bar Aug 13, 2024
bf6575a
refactoring the state check logic to also handle when nextBD is in a …
spoo-bar Aug 16, 2024
5a2c348
app wiring
spoo-bar Aug 16, 2024
7315362
adding migrations
spoo-bar Aug 19, 2024
4663878
implementing ibc msg channel open ack
spoo-bar Aug 19, 2024
cceb5f7
adding light client keeper testutil
spoo-bar Aug 19, 2024
7f33588
Adding `AfterUpdateState` hook test
spoo-bar Aug 19, 2024
454c514
Create ibc_msg_submit_misbehaviour_test.go
spoo-bar Aug 20, 2024
4f7fff4
refactoring IBC keepers
spoo-bar Aug 20, 2024
03072c5
implementing ibc_msg_channel_open_ack test
spoo-bar Aug 20, 2024
ca2e201
adding posthandler msg_create_client test
spoo-bar Aug 20, 2024
a5d2159
refactor mock rollapp keeper
spoo-bar Aug 20, 2024
fcbf125
adding ibc_msg_create_client test
spoo-bar Aug 20, 2024
0e557c0
adding ibc msg update client ante tests
spoo-bar Aug 20, 2024
ec04717
adding state compatibility check tests
spoo-bar Aug 20, 2024
c01a72f
perform data transform to get tm pubkeys from cosmos pubkeys for sequ…
spoo-bar Aug 20, 2024
763538d
fixing create client test
spoo-bar Aug 20, 2024
9000976
fixing state compatibility tests
spoo-bar Aug 21, 2024
14ef084
ensuring canon client params matches expected values
spoo-bar Aug 21, 2024
188e17f
add case for when timestamp is not present as rollapp is not upgraded
spoo-bar Aug 21, 2024
9376117
cleaning up the code
spoo-bar Aug 21, 2024
09e9d00
cleanup tests
spoo-bar Aug 22, 2024
0d45045
Merge branch 'main' into spoorthi/rollapp-light-client
spoo-bar Aug 22, 2024
93c1235
addressing updates from main
spoo-bar Aug 22, 2024
52659df
linting 🧹
spoo-bar Aug 22, 2024
346b146
more linting 🧹
spoo-bar Aug 22, 2024
3f7d4cc
more linting 🧹
spoo-bar Aug 22, 2024
afb5347
fixing potential out of bounds errors
spoo-bar Aug 22, 2024
662be5c
setting canonical client if conditions match in afterstateupdatehook
spoo-bar Aug 23, 2024
92f6ebe
adding tests for setting canonical client automatically
spoo-bar Aug 23, 2024
686ee8b
fixing test
spoo-bar Aug 23, 2024
198fd42
removing the ante & post for msg create client to set canonical clien…
spoo-bar Aug 23, 2024
009df2d
adding some code comments
spoo-bar Aug 23, 2024
8052844
reverting the wrong code pushed
spoo-bar Aug 24, 2024
38a6ee8
using sequencer keeper for getting the pubkey instead of the account …
spoo-bar Aug 26, 2024
88c0687
addressing some PR review comments
spoo-bar Aug 26, 2024
a03ba98
typo fix
spoo-bar Aug 26, 2024
1e177f5
linting 🧹
spoo-bar Aug 26, 2024
b12d33e
using binary search when looking up FindStateInfoByHeight
spoo-bar Aug 27, 2024
f0f6809
refactor state_test to move valid inputs to top and modify the error …
spoo-bar Aug 27, 2024
589a7ff
refactor state_test to check Error.Is instead of error string match
spoo-bar Aug 27, 2024
61527b8
using validlatorhash instead of proposeaddress in checking state comp…
spoo-bar Aug 27, 2024
255d251
addressing more pr review comments
spoo-bar Aug 27, 2024
d7818b0
refactor canonical client check to early exit
spoo-bar Aug 27, 2024
3e18292
using pubkey in state comparision instead of byte array
spoo-bar Aug 27, 2024
6e7cdb7
implementing init/export genesis
spoo-bar Aug 28, 2024
29b8a39
registering invariants
spoo-bar Aug 28, 2024
cf3e8c7
wiring up genesis actions in module
spoo-bar Aug 28, 2024
af005e1
moving the timestamp upgrade logic to rollapp keeper
spoo-bar Aug 28, 2024
faf8603
addressing some more PR review comments
spoo-bar Aug 28, 2024
3abe951
modify the state compatibility conditions to ignore current val hash …
spoo-bar Aug 28, 2024
ad38fdf
implement the timestamp toggle behaviour + tests in rollapp keeper
spoo-bar Aug 28, 2024
0b761a3
adding detailed comment on state compatibility criteria
spoo-bar Aug 28, 2024
e4a1089
calling rollappkeeper.HandleFraud instead of sequencerkeeper.JailSequ…
spoo-bar Aug 28, 2024
8cda6be
in msgupdateclient, run FindStateInfoByHeight twice instead of micro …
spoo-bar Aug 28, 2024
0c512ff
smol cleanup
spoo-bar Aug 28, 2024
4a1c63d
adding docstring GetProspectiveCanonicalClient
spoo-bar Aug 28, 2024
47f1520
modifying the afterstateupdate hook to compare at h-1
spoo-bar Aug 28, 2024
e10cd20
adding TestFindStateInfoByHeight
spoo-bar Aug 28, 2024
9fa4d97
update GetProspectiveCanonicalClient to fetch all existing ibc consen…
spoo-bar Aug 28, 2024
5424b09
linting 🧹
spoo-bar Aug 28, 2024
efaa792
store block proposer as bech32 address
spoo-bar Aug 28, 2024
a551f9e
linting 🧹
spoo-bar Aug 28, 2024
74c94fc
adding docstring for proto
spoo-bar Aug 29, 2024
d7a5b7f
using `IterateClientStates` instead of `GetAllGenesisClients`
spoo-bar Aug 29, 2024
fb92c66
SetCanonicalClient e2e tests
spoo-bar Aug 29, 2024
c5a14f9
linting 🧹
spoo-bar Aug 29, 2024
5bfa143
use block valhash instead of proposer address for fraud punishment
spoo-bar Aug 29, 2024
abce59c
adding e2e test for updating client optimistically when stateinfo doe…
spoo-bar Aug 29, 2024
81161c0
linting 🧹
spoo-bar Aug 29, 2024
3e18afa
adding e2e tests for update client ante
spoo-bar Aug 30, 2024
110dc26
removing the canonical channel hack and updating tests
spoo-bar Aug 30, 2024
d0cf491
adding e2e tests for afterstatupdate hook
spoo-bar Aug 30, 2024
219dad2
linting 🧹
spoo-bar Aug 30, 2024
af10515
linting 🧹
spoo-bar Aug 30, 2024
a1f6b2e
using ibctm.ConsensusState instead of custom ibc state type
spoo-bar Aug 30, 2024
6229eca
add check to ensure if first stateupdate, timestamps exist
spoo-bar Aug 30, 2024
5659bfb
fixing the issue in canonical client setting where it was using wrong…
spoo-bar Aug 30, 2024
cef5693
using GetSequencerbyRollapp instead of GetAllSequencers
spoo-bar Aug 30, 2024
ce42631
update the genesis field from signer to blockvalhash
spoo-bar Aug 30, 2024
200a7fd
dont attempt state check for last height as h+1 wont exist anyway
spoo-bar Aug 30, 2024
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
5 changes: 5 additions & 0 deletions app/ante/ante_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing"
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper"
lightclientkeeper "github.com/dymensionxyz/dymension/v3/x/lightclient/keeper"
rollappkeeper "github.com/dymensionxyz/dymension/v3/x/rollapp/keeper"
ethante "github.com/evmos/ethermint/app/ante"

Expand All @@ -26,6 +27,7 @@ type HandlerOptions struct {
MaxTxGasWanted uint64
ExtensionOptionChecker ante.ExtensionOptionChecker
RollappKeeper rollappkeeper.Keeper
LightClientKeeper *lightclientkeeper.Keeper
}

func (options HandlerOptions) validate() error {
Expand All @@ -47,5 +49,8 @@ func (options HandlerOptions) validate() error {
if options.TxFeesKeeper == nil {
return errorsmod.Wrap(errortypes.ErrLogic, "tx fees keeper is required for AnteHandler")
}
if options.LightClientKeeper == nil {
return errorsmod.Wrap(errortypes.ErrLogic, "light client keeper is required for AnteHandler")
}
return nil
}
17 changes: 9 additions & 8 deletions app/ante/ante_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,15 @@ func (s *AnteTestSuite) SetupTestCheckTx(isCheckTx bool) {

anteHandler, err := ante.NewAnteHandler(
ante.HandlerOptions{
AccountKeeper: &s.app.AccountKeeper,
BankKeeper: s.app.BankKeeper,
IBCKeeper: s.app.IBCKeeper,
EvmKeeper: s.app.EvmKeeper,
FeeMarketKeeper: s.app.FeeMarketKeeper,
TxFeesKeeper: s.app.TxFeesKeeper,
FeegrantKeeper: s.app.FeeGrantKeeper,
SignModeHandler: txConfig.SignModeHandler(),
AccountKeeper: &s.app.AccountKeeper,
BankKeeper: s.app.BankKeeper,
IBCKeeper: s.app.IBCKeeper,
EvmKeeper: s.app.EvmKeeper,
FeeMarketKeeper: s.app.FeeMarketKeeper,
TxFeesKeeper: s.app.TxFeesKeeper,
FeegrantKeeper: s.app.FeeGrantKeeper,
SignModeHandler: txConfig.SignModeHandler(),
LightClientKeeper: &s.app.LightClientKeeper,
},
)

Expand Down
3 changes: 3 additions & 0 deletions app/ante/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
evmtypes "github.com/evmos/ethermint/x/evm/types"

delayedack "github.com/dymensionxyz/dymension/v3/x/delayedack"
lightclientante "github.com/dymensionxyz/dymension/v3/x/lightclient/ante"
)

func newEthAnteHandler(options HandlerOptions) sdk.AnteHandler {
Expand Down Expand Up @@ -70,6 +71,7 @@ func newLegacyCosmosAnteHandlerEip712(options HandlerOptions) sdk.AnteHandler {
// Note: signature verification uses EIP instead of the cosmos signature validator
NewLegacyEip712SigVerificationDecorator(options.AccountKeeper, options.SignModeHandler),
ante.NewIncrementSequenceDecorator(options.AccountKeeper),
lightclientante.NewIBCMessagesDecorator(*options.LightClientKeeper, options.IBCKeeper.ClientKeeper, options.IBCKeeper.ChannelKeeper, options.RollappKeeper),
delayedack.NewIBCProofHeightDecorator(),
ibcante.NewRedundantRelayDecorator(options.IBCKeeper),
ethante.NewGasWantedDecorator(options.EvmKeeper, options.FeeMarketKeeper),
Expand Down Expand Up @@ -107,6 +109,7 @@ func newCosmosAnteHandler(options HandlerOptions) sdk.AnteHandler {
ante.NewSigVerificationDecorator(options.AccountKeeper, options.SignModeHandler),
ante.NewIncrementSequenceDecorator(options.AccountKeeper),
delayedack.NewIBCProofHeightDecorator(),
lightclientante.NewIBCMessagesDecorator(*options.LightClientKeeper, options.IBCKeeper.ClientKeeper, options.IBCKeeper.ChannelKeeper, options.RollappKeeper),
ibcante.NewRedundantRelayDecorator(options.IBCKeeper),
ethante.NewGasWantedDecorator(options.EvmKeeper, options.FeeMarketKeeper),

Expand Down
3 changes: 2 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (

simappparams "cosmossdk.io/simapp/params"
"github.com/cosmos/cosmos-sdk/runtime"
"github.com/cosmos/cosmos-sdk/x/auth/posthandler"

"github.com/dymensionxyz/dymension/v3/app/keepers"
"github.com/dymensionxyz/dymension/v3/app/upgrades"
Expand Down Expand Up @@ -46,6 +45,7 @@ import (
"github.com/cosmos/cosmos-sdk/types/module"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
"github.com/cosmos/cosmos-sdk/version"
"github.com/cosmos/cosmos-sdk/x/auth/posthandler"
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"

"github.com/cosmos/cosmos-sdk/x/crisis"
Expand Down Expand Up @@ -217,6 +217,7 @@ func New(
MaxTxGasWanted: maxGasWanted,
ExtensionOptionChecker: nil, // uses default
RollappKeeper: *app.RollappKeeper,
LightClientKeeper: &app.LightClientKeeper,
})
if err != nil {
panic(err)
Expand Down
3 changes: 2 additions & 1 deletion app/apptesting/test_suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package apptesting

import (
"strings"
"time"

bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"

Expand Down Expand Up @@ -109,7 +110,7 @@ func (s *KeeperTestHelper) PostStateUpdate(ctx sdk.Context, rollappId, seqAddr s
var bds rollapptypes.BlockDescriptors
bds.BD = make([]rollapptypes.BlockDescriptor, numOfBlocks)
for k := 0; k < int(numOfBlocks); k++ {
bds.BD[k] = rollapptypes.BlockDescriptor{Height: startHeight + uint64(k)}
bds.BD[k] = rollapptypes.BlockDescriptor{Height: startHeight + uint64(k), Timestamp: time.Now().UTC()}
}

updateState := rollapptypes.MsgUpdateState{
Expand Down
13 changes: 12 additions & 1 deletion app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ import (
eibcmoduletypes "github.com/dymensionxyz/dymension/v3/x/eibc/types"
incentiveskeeper "github.com/dymensionxyz/dymension/v3/x/incentives/keeper"
incentivestypes "github.com/dymensionxyz/dymension/v3/x/incentives/types"
lightclientmodulekeeper "github.com/dymensionxyz/dymension/v3/x/lightclient/keeper"
lightclientmoduletypes "github.com/dymensionxyz/dymension/v3/x/lightclient/types"
rollappmodule "github.com/dymensionxyz/dymension/v3/x/rollapp"
rollappmodulekeeper "github.com/dymensionxyz/dymension/v3/x/rollapp/keeper"
"github.com/dymensionxyz/dymension/v3/x/rollapp/transfergenesis"
Expand Down Expand Up @@ -143,6 +145,7 @@ type AppKeepers struct {
SponsorshipKeeper sponsorshipkeeper.Keeper
StreamerKeeper streamermodulekeeper.Keeper
EIBCKeeper eibckeeper.Keeper
LightClientKeeper lightclientmodulekeeper.Keeper

DelayedAckKeeper delayedackkeeper.Keeper
DenomMetadataKeeper *denommetadatamodulekeeper.Keeper
Expand Down Expand Up @@ -360,6 +363,14 @@ func (a *AppKeepers) InitKeepers(
a.RollappKeeper,
)

a.LightClientKeeper = *lightclientmodulekeeper.NewKeeper(
appCodec,
a.keys[lightclientmoduletypes.StoreKey],
a.IBCKeeper.ClientKeeper,
a.SequencerKeeper,
a.RollappKeeper,
)

a.RollappKeeper.SetSequencerKeeper(a.SequencerKeeper)

a.IncentivesKeeper = incentiveskeeper.NewKeeper(
Expand Down Expand Up @@ -501,7 +512,6 @@ func (a *AppKeepers) InitTransferStack() {
)
a.TransferStack = a.delayedAckMiddleware
a.TransferStack = transfergenesis.NewIBCModule(a.TransferStack, a.DelayedAckKeeper, *a.RollappKeeper, a.TransferKeeper, a.DenomMetadataKeeper)
a.TransferStack = transfergenesis.NewIBCModuleCanonicalChannelHack(a.TransferStack, *a.RollappKeeper, a.IBCKeeper.ChannelKeeper)

// Create static IBC router, add transfer route, then set and seal it
ibcRouter := ibcporttypes.NewRouter()
Expand Down Expand Up @@ -575,6 +585,7 @@ func (a *AppKeepers) SetupHooks() {
a.delayedAckMiddleware,
a.StreamerKeeper.Hooks(),
a.DymNSKeeper.GetRollAppHooks(),
a.LightClientKeeper.RollappHooks(),
))
}

Expand Down
2 changes: 2 additions & 0 deletions app/keepers/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
delayedacktypes "github.com/dymensionxyz/dymension/v3/x/delayedack/types"
eibcmoduletypes "github.com/dymensionxyz/dymension/v3/x/eibc/types"
incentivestypes "github.com/dymensionxyz/dymension/v3/x/incentives/types"
lightcliendmoduletypes "github.com/dymensionxyz/dymension/v3/x/lightclient/types"
rollappmoduletypes "github.com/dymensionxyz/dymension/v3/x/rollapp/types"
sequencermoduletypes "github.com/dymensionxyz/dymension/v3/x/sequencer/types"
sponsorshiptypes "github.com/dymensionxyz/dymension/v3/x/sponsorship/types"
Expand Down Expand Up @@ -130,4 +131,5 @@ var KVStoreKeys = sdk.NewKVStoreKeys(
poolmanagertypes.StoreKey,
incentivestypes.StoreKey,
txfeestypes.StoreKey,
lightcliendmoduletypes.StoreKey,
)
7 changes: 7 additions & 0 deletions app/keepers/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ import (
incentivestypes "github.com/dymensionxyz/dymension/v3/x/incentives/types"
"github.com/dymensionxyz/dymension/v3/x/rollapp"

lightclientmodule "github.com/dymensionxyz/dymension/v3/x/lightclient"
lightclientmoduletypes "github.com/dymensionxyz/dymension/v3/x/lightclient/types"
rollappmoduleclient "github.com/dymensionxyz/dymension/v3/x/rollapp/client"
rollappmoduletypes "github.com/dymensionxyz/dymension/v3/x/rollapp/types"
"github.com/dymensionxyz/dymension/v3/x/sequencer"
Expand Down Expand Up @@ -150,6 +152,7 @@ var ModuleBasics = module.NewBasicManager(
delayedack.AppModuleBasic{},
eibc.AppModuleBasic{},
dymnsmodule.AppModuleBasic{},
lightclientmodule.AppModuleBasic{},

// Ethermint modules
evm.AppModuleBasic{},
Expand Down Expand Up @@ -202,6 +205,7 @@ func (a *AppKeepers) SetupModules(
denommetadatamodule.NewAppModule(a.DenomMetadataKeeper, *a.EvmKeeper, a.BankKeeper),
eibcmodule.NewAppModule(appCodec, a.EIBCKeeper, a.AccountKeeper, a.BankKeeper),
dymnsmodule.NewAppModule(appCodec, a.DymNSKeeper),
lightclientmodule.NewAppModule(appCodec, a.LightClientKeeper),

// Ethermint app modules
evm.NewAppModule(a.EvmKeeper, a.AccountKeeper, a.BankKeeper, a.GetSubspace(evmtypes.ModuleName).WithKeyTable(evmtypes.ParamKeyTable())),
Expand Down Expand Up @@ -289,6 +293,7 @@ var BeginBlockers = []string{
incentivestypes.ModuleName,
txfeestypes.ModuleName,
consensusparamtypes.ModuleName,
lightclientmoduletypes.ModuleName,
}

var EndBlockers = []string{
Expand Down Expand Up @@ -328,6 +333,7 @@ var EndBlockers = []string{
incentivestypes.ModuleName,
txfeestypes.ModuleName,
consensusparamtypes.ModuleName,
lightclientmoduletypes.ModuleName,
}

var InitGenesis = []string{
Expand Down Expand Up @@ -367,4 +373,5 @@ var InitGenesis = []string{
incentivestypes.ModuleName,
txfeestypes.ModuleName,
consensusparamtypes.ModuleName,
lightclientmoduletypes.ModuleName,
}
2 changes: 2 additions & 0 deletions app/upgrades/v4/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types"
crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types"
"github.com/dymensionxyz/dymension/v3/app/upgrades"
lightclienttypes "github.com/dymensionxyz/dymension/v3/x/lightclient/types"
)

const (
Expand All @@ -18,6 +19,7 @@ var Upgrade = upgrades.Upgrade{
Added: []string{
consensustypes.ModuleName,
crisistypes.ModuleName,
lightclienttypes.ModuleName,
},
},
}
23 changes: 23 additions & 0 deletions app/upgrades/v4/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import (
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types"
ibcchannelkeeper "github.com/cosmos/ibc-go/v7/modules/core/04-channel/keeper"

evmtypes "github.com/evmos/ethermint/x/evm/types"
feemarkettypes "github.com/evmos/ethermint/x/feemarket/types"
Expand All @@ -26,6 +28,7 @@ import (
"github.com/dymensionxyz/dymension/v3/app/upgrades"
delayedackkeeper "github.com/dymensionxyz/dymension/v3/x/delayedack/keeper"
delayedacktypes "github.com/dymensionxyz/dymension/v3/x/delayedack/types"
lightclientkeeper "github.com/dymensionxyz/dymension/v3/x/lightclient/keeper"
rollappkeeper "github.com/dymensionxyz/dymension/v3/x/rollapp/keeper"
rollapptypes "github.com/dymensionxyz/dymension/v3/x/rollapp/types"
sequencerkeeper "github.com/dymensionxyz/dymension/v3/x/sequencer/keeper"
Expand All @@ -49,6 +52,7 @@ func CreateUpgradeHandler(
return nil, err
}
migrateSequencers(ctx, keepers.SequencerKeeper)
migrateRollappLightClients(ctx, keepers.RollappKeeper, keepers.LightClientKeeper, keepers.IBCKeeper.ChannelKeeper)

// TODO: create rollapp gauges for each existing rollapp (https://github.com/dymensionxyz/dymension/issues/1005)

Expand Down Expand Up @@ -136,6 +140,25 @@ func migrateSequencers(ctx sdk.Context, sequencerkeeper sequencerkeeper.Keeper)
}
}

func migrateRollappLightClients(ctx sdk.Context, rollappkeeper *rollappkeeper.Keeper, lightClientKeeper lightclientkeeper.Keeper, ibcChannelKeeper ibcchannelkeeper.Keeper) {
list := rollappkeeper.GetAllRollapps(ctx)
for _, rollapp := range list {
// check if the rollapp has a canonical channel already
if rollapp.ChannelId == "" {
return
}
// get the client ID the channel belongs to
_, connection, err := ibcChannelKeeper.GetChannelConnection(ctx, ibctransfertypes.PortID, rollapp.ChannelId)
if err != nil {
// if could not find a connection, skip the canonical client assignment
return
}
clientID := connection.GetClientID()
// store the rollapp to canonical light client ID mapping
lightClientKeeper.SetCanonicalClient(ctx, rollapp.RollappId, clientID)
}
}

func ConvertOldRollappToNew(oldRollapp rollapptypes.Rollapp) rollapptypes.Rollapp {
return rollapptypes.Rollapp{
RollappId: oldRollapp.RollappId,
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ require (
github.com/cosmos/gogoproto v1.4.10
github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7 v7.1.3
github.com/cosmos/ibc-go/v7 v7.5.1
github.com/cosmos/ics23/go v0.10.0
github.com/decred/dcrd/dcrec/edwards v1.0.0
github.com/dustin/go-humanize v1.0.1
github.com/dymensionxyz/gerr-cosmos v1.0.0
Expand Down Expand Up @@ -84,7 +85,6 @@ require (
github.com/cosmos/go-bip39 v1.0.0 // indirect
github.com/cosmos/gogogateway v1.2.0 // indirect
github.com/cosmos/iavl v0.20.1 // indirect
github.com/cosmos/ics23/go v0.10.0 // indirect
github.com/cosmos/ledger-cosmos-go v0.12.4 // indirect
github.com/cosmos/rosetta-sdk-go v0.10.0 // indirect
github.com/creachadair/taskgroup v0.4.2 // indirect
Expand Down
5 changes: 4 additions & 1 deletion ibctesting/genesis_transfer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,13 @@ func TestTransferGenesisTestSuite(t *testing.T) {
func (s *transferGenesisSuite) SetupTest() {
s.utilSuite.SetupTest()
path := s.newTransferPath(s.hubChain(), s.rollappChain())
s.coordinator.Setup(path)
s.coordinator.SetupConnections(path)
s.createRollapp(false, nil) // genesis protocol is not finished yet
s.registerSequencer()
s.path = path
// set the canonical client before creating channels
s.hubApp().LightClientKeeper.SetCanonicalClient(s.hubCtx(), rollappChainID(), s.path.EndpointA.ClientID)
s.coordinator.CreateChannels(path)

// set hooks to avoid actually creating VFC contract, as this places extra requirements on the test setup
// we assume that if the denom metadata was created (checked below), then the hooks ran correctly
Expand Down
Loading
Loading