Skip to content

Commit

Permalink
feat(sequencer): conditional unbonding + kick for liveness (#1343)
Browse files Browse the repository at this point in the history
Co-authored-by: Omri <[email protected]>
  • Loading branch information
danwt and omritoptix authored Nov 5, 2024
1 parent 5386029 commit 76aa1e1
Show file tree
Hide file tree
Showing 163 changed files with 6,521 additions and 6,137 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ build/
.DS_Store
proposal.json
.go-version
**/testdata/rapid/
**/testdata/rapid/
**/__debug_bin*
1 change: 0 additions & 1 deletion app/apptesting/test_suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ func (s *KeeperTestHelper) CreateDefaultRollappAndProposer() (string, string) {
return rollappId, proposer
}

// creates a rollapp and return its rollappID
func (s *KeeperTestHelper) CreateDefaultRollapp() string {
rollappId := urand.RollappID()
s.CreateRollappByName(rollappId)
Expand Down
7 changes: 5 additions & 2 deletions app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ type AppKeepers struct {
ScopedTransferKeeper capabilitykeeper.ScopedKeeper

RollappKeeper *rollappmodulekeeper.Keeper
SequencerKeeper sequencermodulekeeper.Keeper
SequencerKeeper *sequencermodulekeeper.Keeper
SponsorshipKeeper sponsorshipkeeper.Keeper
StreamerKeeper streamermodulekeeper.Keeper
EIBCKeeper eibckeeper.Keeper
Expand Down Expand Up @@ -363,7 +363,7 @@ func (a *AppKeepers) InitKeepers(
nil,
)

a.SequencerKeeper = *sequencermodulekeeper.NewKeeper(
a.SequencerKeeper = sequencermodulekeeper.NewKeeper(
appCodec,
a.keys[sequencermoduletypes.StoreKey],
a.BankKeeper,
Expand All @@ -379,6 +379,9 @@ func (a *AppKeepers) InitKeepers(
a.RollappKeeper,
)

a.SequencerKeeper.SetUnbondBlockers(a.RollappKeeper, a.LightClientKeeper)
a.SequencerKeeper.SetHooks(sequencermoduletypes.MultiHooks{rollappmodulekeeper.SequencerHooks{Keeper: a.RollappKeeper}})

groupConfig := grouptypes.Config{
MaxExecutionPeriod: 0,
MaxMetadataLen: 0,
Expand Down
4 changes: 2 additions & 2 deletions app/upgrades/v4/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ func migrateRollapps(ctx sdk.Context, rollappkeeper *rollappkeeper.Keeper) error
return nil
}

func migrateSequencers(ctx sdk.Context, sequencerkeeper sequencerkeeper.Keeper) {
list := sequencerkeeper.GetAllSequencers(ctx)
func migrateSequencers(ctx sdk.Context, sequencerkeeper *sequencerkeeper.Keeper) {
list := sequencerkeeper.AllSequencers(ctx)
for _, oldSequencer := range list {
newSequencer := ConvertOldSequencerToNew(oldSequencer)
sequencerkeeper.SetSequencer(ctx, newSequencer)
Expand Down
12 changes: 6 additions & 6 deletions app/upgrades/v4/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ func (s *UpgradeTestSuite) validateSequencersMigration(numSeq int) error {
for i, sequencer := range testSeqs {
expectSequencers[i] = v4.ConvertOldSequencerToNew(sequencer)
}
sequencers := s.App.SequencerKeeper.GetAllSequencers(s.Ctx)
sequencers := s.App.SequencerKeeper.AllSequencers(s.Ctx)
s.Require().Len(sequencers, len(expectSequencers))

sort.Slice(sequencers, func(i, j int) bool {
Expand All @@ -256,9 +256,9 @@ func (s *UpgradeTestSuite) validateSequencersMigration(numSeq int) error {

for i, sequencer := range sequencers {
// check that the sequencer can be retrieved by address
_, ok := s.App.SequencerKeeper.GetSequencer(s.Ctx, sequencer.Address)
if !ok {
return fmt.Errorf("sequencer by address not migrated")
_, err := s.App.SequencerKeeper.RealSequencer(s.Ctx, sequencer.Address)
if err != nil {
return err
}

seq := s.App.AppCodec().MustMarshalJSON(&sequencer)
Expand All @@ -269,8 +269,8 @@ func (s *UpgradeTestSuite) validateSequencersMigration(numSeq int) error {

// check proposer
for _, rollapp := range s.App.RollappKeeper.GetAllRollapps(s.Ctx) {
_, found := s.App.SequencerKeeper.GetProposer(s.Ctx, rollapp.RollappId)
s.Assert().True(found)
p := s.App.SequencerKeeper.GetProposer(s.Ctx, rollapp.RollappId)
s.Require().False(p.Sentinel())
}

return nil
Expand Down
5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ require (
github.com/decred/dcrd/dcrec/edwards v1.0.0
github.com/dustin/go-humanize v1.0.1
github.com/dymensionxyz/gerr-cosmos v1.1.0
github.com/dymensionxyz/sdk-utils v0.2.10
github.com/dymensionxyz/sdk-utils v0.2.12
github.com/ethereum/go-ethereum v1.10.26
github.com/evmos/ethermint v0.22.0
github.com/gogo/protobuf v1.3.3
Expand Down Expand Up @@ -237,6 +237,7 @@ require (
replace (
// for collections
cosmossdk.io/api => cosmossdk.io/api v0.3.1

// use dymension forks
github.com/evmos/ethermint => github.com/dymensionxyz/ethermint v0.22.0-dymension-v0.4.1.0.20241013112411-5ef491708a2d
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
Expand All @@ -245,6 +246,6 @@ replace (

// broken goleveldb
github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7

github.com/tendermint/tendermint => github.com/cometbft/cometbft v0.34.29
golang.org/x/exp => golang.org/x/exp v0.0.0-20230711153332-06a737ee72cb
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -508,8 +508,8 @@ github.com/dymensionxyz/osmosis/osmomath v0.0.6-dymension-v0.1.0.20240820121212-
github.com/dymensionxyz/osmosis/osmomath v0.0.6-dymension-v0.1.0.20240820121212-c0e21fa21e43/go.mod h1:SdGCL9CZb14twRAJUSzb7bRE0OoopRpF2Hnd1UhJpFU=
github.com/dymensionxyz/osmosis/v15 v15.2.1-0.20241030075435-24ccb7025a59 h1:xuo5OCex6XT3HmL8O9l/+jsbT0D+Ib0LzTXQbNrDOOQ=
github.com/dymensionxyz/osmosis/v15 v15.2.1-0.20241030075435-24ccb7025a59/go.mod h1:2rsnXAdjYfXtyEw0mNwAdOiAccALYjAPvINGUf9Qg7Y=
github.com/dymensionxyz/sdk-utils v0.2.10 h1:dvUVzIpsdWGr5Ex+ltl/x1Abi+7sliwsGM1xAx/0p0k=
github.com/dymensionxyz/sdk-utils v0.2.10/go.mod h1:it9owYOpnIe17+ftTATQNDN4z+mBQx20/2Jm8SK15Rk=
github.com/dymensionxyz/sdk-utils v0.2.12 h1:wrcof+IP0AJQ7vvMRVpSekNNwa6B7ghAspHRjp/k+Lk=
github.com/dymensionxyz/sdk-utils v0.2.12/go.mod h1:it9owYOpnIe17+ftTATQNDN4z+mBQx20/2Jm8SK15Rk=
github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs=
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU=
github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I=
Expand Down
Loading

0 comments on commit 76aa1e1

Please sign in to comment.