Skip to content

Commit

Permalink
Merge branch 'main' into kirill/1450-hard-fork-revisions
Browse files Browse the repository at this point in the history
  • Loading branch information
keruch committed Nov 15, 2024
2 parents 9f4a9fe + 1d7dad7 commit fa83b5d
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
4 changes: 4 additions & 0 deletions x/rollapp/keeper/hard_fork.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ func (k Keeper) HardFork(ctx sdk.Context, rollappID string, newRevisionHeight ui

// update revision number
rollapp.BumpRevision(newRevisionHeight)

// stop liveness events
k.ResetLivenessClock(ctx, &rollapp)

k.SetRollapp(ctx, rollapp)

// handle the sequencers, clean delayed packets, handle light client
Expand Down
2 changes: 1 addition & 1 deletion x/rollapp/keeper/sequencer_hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type SequencerHooks struct {

// AfterRecoveryFromHalt is called after a new sequencer is set the proposer for an halted rollapp.
// We assume the rollapp had forked once halted
func (h SequencerHooks) AfterRecoveryFromHalt(ctx sdk.Context, rollapp string, newSeq sequencertypes.Sequencer) error {
func (h SequencerHooks) AfterSetRealProposer(ctx sdk.Context, rollapp string, newSeq sequencertypes.Sequencer) error {
// Start the liveness clock from zero
// NOTE: it could make more sense if liveness was a property of the sequencer rather than the rollapp
// TODO: tech debt https://github.com/dymensionxyz/dymension/issues/1357
Expand Down
2 changes: 1 addition & 1 deletion x/sequencer/keeper/proposer.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (k Keeper) RecoverFromSentinel(ctx sdk.Context, rollapp string) error {
}
k.SetProposer(ctx, rollapp, successor.Address)

err = k.hooks.AfterRecoveryFromHalt(ctx, rollapp, successor)
err = k.hooks.AfterSetRealProposer(ctx, rollapp, successor)
if err != nil {
return errorsmod.Wrap(err, "recovery from halt callbacks")
}
Expand Down
4 changes: 3 additions & 1 deletion x/sequencer/keeper/rotation.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,14 @@ func (k Keeper) OnProposerLastBlock(ctx sdk.Context, proposer types.Sequencer) e
k.SetSuccessor(ctx, rollapp, types.SentinelSeqAddr) // clear successor
k.SetProposer(ctx, rollapp, successor.Address)

// if proposer is sentinel, prepare new revision for the rollapp
// if successor is sentinel, prepare new revision for the rollapp
if successor.Sentinel() {
err := k.rollappKeeper.HardForkToLatest(ctx, rollapp)
if err != nil {
return errorsmod.Wrap(err, "hard fork to latest")
}
} else if err := k.hooks.AfterSetRealProposer(ctx, rollapp, successor); err != nil {
return errorsmod.Wrap(err, "after set real sequencer")
}

ctx.EventManager().EmitEvent(
Expand Down
8 changes: 4 additions & 4 deletions x/sequencer/types/hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ package types
import sdk "github.com/cosmos/cosmos-sdk/types"

type Hooks interface {
AfterRecoveryFromHalt(ctx sdk.Context, rollapp string, newProposer Sequencer) error
AfterSetRealProposer(ctx sdk.Context, rollapp string, newProposer Sequencer) error
AfterKickProposer(ctx sdk.Context, kicked Sequencer) error
}

var _ Hooks = NoOpHooks{}

type NoOpHooks struct{}

func (n NoOpHooks) AfterRecoveryFromHalt(ctx sdk.Context, rollapp string, newProposer Sequencer) error {
func (n NoOpHooks) AfterSetRealProposer(ctx sdk.Context, rollapp string, newProposer Sequencer) error {
return nil
}

Expand All @@ -27,9 +27,9 @@ func NewMultiHooks(hooks ...Hooks) MultiHooks {
return MultiHooks(hooks)
}

func (m MultiHooks) AfterRecoveryFromHalt(ctx sdk.Context, rollapp string, newProposer Sequencer) error {
func (m MultiHooks) AfterSetRealProposer(ctx sdk.Context, rollapp string, newProposer Sequencer) error {
for _, h := range m {
err := h.AfterRecoveryFromHalt(ctx, rollapp, newProposer)
err := h.AfterSetRealProposer(ctx, rollapp, newProposer)
if err != nil {
return err
}
Expand Down

0 comments on commit fa83b5d

Please sign in to comment.