Skip to content

Commit 61d5018

Browse files
authored
fix(rollapp): fix packet lookup for non-rollapp chain-id (#1243)
1 parent 5601240 commit 61d5018

27 files changed

+134
-160
lines changed

app/keepers/keepers.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,7 @@ func (a *AppKeepers) InitKeepers(
357357
nil,
358358
a.BankKeeper,
359359
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
360+
nil,
360361
)
361362

362363
a.SequencerKeeper = *sequencermodulekeeper.NewKeeper(
@@ -376,6 +377,7 @@ func (a *AppKeepers) InitKeepers(
376377
)
377378

378379
a.RollappKeeper.SetSequencerKeeper(a.SequencerKeeper)
380+
a.RollappKeeper.SetCanonicalClientKeeper(a.LightClientKeeper)
379381

380382
a.IncentivesKeeper = incentiveskeeper.NewKeeper(
381383
a.keys[incentivestypes.StoreKey],

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ require (
2020
github.com/cosmos/ics23/go v0.10.0
2121
github.com/decred/dcrd/dcrec/edwards v1.0.0
2222
github.com/dustin/go-humanize v1.0.1
23-
github.com/dymensionxyz/gerr-cosmos v1.0.0
23+
github.com/dymensionxyz/gerr-cosmos v1.1.0
2424
github.com/dymensionxyz/sdk-utils v0.2.9
2525
github.com/ethereum/go-ethereum v1.10.26
2626
github.com/evmos/ethermint v0.22.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -502,8 +502,8 @@ github.com/dvsekhvalnov/jose2go v1.6.0 h1:Y9gnSnP4qEI0+/uQkHvFXeD2PLPJeXEL+ySMEA
502502
github.com/dvsekhvalnov/jose2go v1.6.0/go.mod h1:QsHjhyTlD/lAVqn/NSbVZmSCGeDehTB/mPZadG+mhXU=
503503
github.com/dymensionxyz/ethermint v0.22.0-dymension-v0.4.1.0.20240625101522-b1506ae83050 h1:1mtlo6bDOdBihHWbDpOaai0NMC/4xHCkCHGCqdLT8WM=
504504
github.com/dymensionxyz/ethermint v0.22.0-dymension-v0.4.1.0.20240625101522-b1506ae83050/go.mod h1:aokD0im7cUMMtR/khzNsmcGtINtxCpBfcgRvJdmLymA=
505-
github.com/dymensionxyz/gerr-cosmos v1.0.0 h1:oi91rgOkpJWr41oX9JOyjvvBnhGY54tj513x8VlDAEc=
506-
github.com/dymensionxyz/gerr-cosmos v1.0.0/go.mod h1:n+0olxPogzWqFKba45mCpvrHLGmeS8W9UZjggHnWk6c=
505+
github.com/dymensionxyz/gerr-cosmos v1.1.0 h1:IW/P7HCB/iP9kgk3VXaWUoMoyx3vD76YO6p1fnubHVc=
506+
github.com/dymensionxyz/gerr-cosmos v1.1.0/go.mod h1:n+0olxPogzWqFKba45mCpvrHLGmeS8W9UZjggHnWk6c=
507507
github.com/dymensionxyz/osmosis/osmomath v0.0.6-dymension-v0.1.0.20240820121212-c0e21fa21e43 h1:EskhZ6ILN3vwJ6l8gPWPZ49RFSB52WghT5v+pmzrNCI=
508508
github.com/dymensionxyz/osmosis/osmomath v0.0.6-dymension-v0.1.0.20240820121212-c0e21fa21e43/go.mod h1:SdGCL9CZb14twRAJUSzb7bRE0OoopRpF2Hnd1UhJpFU=
509509
github.com/dymensionxyz/osmosis/v15 v15.2.1-0.20240820121212-c0e21fa21e43 h1:ugbpHwwlckB4W/aNXUTEsxaakPFgXi+LAsCtvfJ200Q=

ibctesting/bridging_fee_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ func (s *bridgingFeeSuite) TestBridgingFee() {
5050
s.fundSenderAccount()
5151
s.createRollappWithFinishedGenesis(path.EndpointA.ChannelID)
5252
s.registerSequencer()
53+
s.setRollappLightClientID(s.rollappCtx().ChainID(), path.EndpointA.ClientID)
5354

5455
rollappEndpoint := path.EndpointB
5556
rollappIBCKeeper := s.rollappChain().App.GetIBCKeeper()

ibctesting/delayed_ack_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ func (s *delayedAckSuite) TestTransferRollappToHubNotFinalized() {
9797
hubIBCKeeper := s.hubChain().App.GetIBCKeeper()
9898

9999
s.createRollappWithFinishedGenesis(path.EndpointA.ChannelID)
100+
s.setRollappLightClientID(s.rollappCtx().ChainID(), path.EndpointA.ClientID)
100101
s.registerSequencer()
101102
s.updateRollappState(uint64(s.rollappCtx().BlockHeight()))
102103

@@ -139,6 +140,7 @@ func (s *delayedAckSuite) TestTransferRollappToHubFinalization() {
139140
rollappIBCKeeper := s.rollappChain().App.GetIBCKeeper()
140141

141142
s.createRollappWithFinishedGenesis(path.EndpointA.ChannelID)
143+
s.setRollappLightClientID(s.rollappCtx().ChainID(), path.EndpointA.ClientID)
142144
s.registerSequencer()
143145

144146
// Update rollapp state
@@ -191,6 +193,7 @@ func (s *delayedAckSuite) TestHubToRollappTimeout() {
191193
hubIBCKeeper := s.hubChain().App.GetIBCKeeper()
192194
// Create rollapp and update its initial state
193195
s.createRollappWithFinishedGenesis(path.EndpointA.ChannelID)
196+
s.setRollappLightClientID(s.rollappCtx().ChainID(), path.EndpointA.ClientID)
194197
s.registerSequencer()
195198
s.updateRollappState(uint64(s.rollappCtx().BlockHeight()))
196199
// Set the timeout height

ibctesting/eibc_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ func (s *eibcSuite) SetupTest() {
5858
// Register sequencer
5959
s.registerSequencer()
6060
s.path = path
61+
s.setRollappLightClientID(s.rollappChain().ChainID, path.EndpointA.ClientID)
6162
}
6263

6364
func (s *eibcSuite) TestEIBCDemandOrderCreation() {

ibctesting/utils_test.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,12 @@ func (s *utilSuite) createRollapp(transfersEnabled bool, channelID *string) {
164164
}
165165
}
166166

167+
// necessary for tests which do not execute the entire light client flow, and just need to make transfers work
168+
// (all tests except the light client tests themselves)
169+
func (s *utilSuite) setRollappLightClientID(chainID, clientID string) {
170+
s.hubApp().LightClientKeeper.SetCanonicalClient(s.hubCtx(), chainID, clientID)
171+
}
172+
167173
func (s *utilSuite) registerSequencer() {
168174
bond := sequencertypes.DefaultParams().MinBond
169175
// fund account
@@ -197,7 +203,7 @@ func (s *utilSuite) updateRollappState(endHeight uint64) {
197203
stateInfo, found := rollappKeeper.GetStateInfo(s.hubCtx(), rollappChainID(), latestStateInfoIndex.Index)
198204
startHeight := uint64(1)
199205
if found {
200-
startHeight = stateInfo.StartHeight + stateInfo.NumBlocks
206+
startHeight = stateInfo.LastHeight() + 1
201207
}
202208
numBlocks := endHeight - startHeight + 1
203209
// populate the block descriptors
@@ -231,7 +237,8 @@ func (s *utilSuite) finalizeRollappState(index uint64, endHeight uint64) (sdk.Ev
231237
stateInfoIdx := rollapptypes.StateInfoIndex{RollappId: rollappChainID(), Index: index}
232238
stateInfo, found := rollappKeeper.GetStateInfo(ctx, rollappChainID(), stateInfoIdx.Index)
233239
s.Require().True(found)
234-
stateInfo.NumBlocks = endHeight - stateInfo.StartHeight + 1
240+
// this is a hack to increase the finalized height by modifying the last state info instead of submitting a new one
241+
stateInfo = stateInfo.WithNumBlocks(endHeight - stateInfo.StartHeight + 1)
235242
stateInfo.Status = common.Status_FINALIZED
236243
// update the status of the stateInfo
237244
rollappKeeper.SetStateInfo(ctx, stateInfo)

proto/dymensionxyz/dymension/rollapp/state_info.proto

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ message StateInfo {
3434
string sequencer = 2;
3535
// startHeight is the block height of the first block in the batch
3636
uint64 startHeight = 3;
37-
// numBlocks is the number of blocks included in this batch update
38-
uint64 numBlocks = 4;
37+
reserved 4; // used to be num blocks, deprecating in favour of counting len of BDs
3938
// DAPath is the description of the location on the DA layer
4039
string DAPath = 5;
4140

testutil/keeper/dymns.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ func DymNSKeeper(t testing.TB) (dymnskeeper.Keeper, dymnstypes.BankKeeper, rolla
9696
nil, nil, nil,
9797
bankKeeper,
9898
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
99+
nil,
99100
)
100101

101102
k := dymnskeeper.NewKeeper(cdc,

testutil/keeper/rollapp.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func RollappKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) {
4040
memStoreKey,
4141
"RollappParams",
4242
)
43-
k := keeper.NewKeeper(cdc, storeKey, paramsSubspace, nil, nil, nil, nil, authtypes.NewModuleAddress(govtypes.ModuleName).String())
43+
k := keeper.NewKeeper(cdc, storeKey, paramsSubspace, nil, nil, nil, nil, authtypes.NewModuleAddress(govtypes.ModuleName).String(), nil)
4444

4545
ctx := sdk.NewContext(stateStore, cometbftproto.Header{}, false, log.NewNopLogger())
4646

0 commit comments

Comments
 (0)