From 00799a0aeaaf3bf70552e03d1cf1ed2a06c8eb2f Mon Sep 17 00:00:00 2001 From: Daniel T <30197399+danwt@users.noreply.github.com> Date: Sat, 7 Dec 2024 18:42:08 +0000 Subject: [PATCH] fix(sequencer, lightclient): do not prevent unbond when canonical client not found (#1630) --- x/lightclient/keeper/keeper.go | 6 +++++- x/sequencer/keeper/msg_server_kick_proposer_test.go | 2 -- x/sequencer/keeper/util_test.go | 6 +++++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/x/lightclient/keeper/keeper.go b/x/lightclient/keeper/keeper.go index 74ea57fd9..8c3074bff 100644 --- a/x/lightclient/keeper/keeper.go +++ b/x/lightclient/keeper/keeper.go @@ -89,7 +89,11 @@ func NewKeeper( func (k Keeper) CanUnbond(ctx sdk.Context, seq sequencertypes.Sequencer) error { client, ok := k.GetCanonicalClient(ctx, seq.RollappId) if !ok { - return errorsmod.Wrap(sequencertypes.ErrUnbondNotAllowed, "no canonical client") + // It doesn't make sense to prevent unbonding here. If there is no canonical client, then + // there can have been no fraud that needs to be checked. + // Moreover, if we did prevent unbonding, it would lead to awkward situations where non proposer + // sequencers of early stage rollapps can't unbond, when the proposer is not doing his job. + return nil } rng := collections.NewSuperPrefixedTripleRange[string, string, uint64](seq.Address, client) return k.headerSigners.Walk(ctx, rng, func(key collections.Triple[string, string, uint64]) (stop bool, err error) { diff --git a/x/sequencer/keeper/msg_server_kick_proposer_test.go b/x/sequencer/keeper/msg_server_kick_proposer_test.go index 1fa4a416e..33256fba5 100644 --- a/x/sequencer/keeper/msg_server_kick_proposer_test.go +++ b/x/sequencer/keeper/msg_server_kick_proposer_test.go @@ -1,14 +1,12 @@ package keeper_test import ( - rollapptypes "github.com/dymensionxyz/dymension/v3/x/rollapp/types" "github.com/dymensionxyz/dymension/v3/x/sequencer/types" "github.com/dymensionxyz/gerr-cosmos/gerrc" "github.com/dymensionxyz/sdk-utils/utils/utest" ) func (s *SequencerTestSuite) TestKickProposerBasicFlow() { - s.App.RollappKeeper.SetHooks(rollapptypes.NewMultiRollappHooks(s.k().RollappHooks())) ra := s.createRollapp() seqAlice := s.createSequencerWithBond(s.Ctx, ra.RollappId, alice, bond) s.Require().True(s.k().IsProposer(s.Ctx, seqAlice)) diff --git a/x/sequencer/keeper/util_test.go b/x/sequencer/keeper/util_test.go index 866d2ff6c..591de1801 100644 --- a/x/sequencer/keeper/util_test.go +++ b/x/sequencer/keeper/util_test.go @@ -100,7 +100,11 @@ func (s *SequencerTestSuite) SetupTest() { // Overwrite to exclude any unblockers set by default in apptesting, to ensure // we are only testing our logic. - s.k().SetUnbondBlockers() + s.k().SetUnbondBlockers( + s.App.LightClientKeeper, + s.App.RollappKeeper, + ) + s.App.RollappKeeper.SetHooks(rollapptypes.NewMultiRollappHooks(s.k().RollappHooks())) } func (s *SequencerTestSuite) seq(pk cryptotypes.PubKey) types.Sequencer {