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

fix(rollapp,sequencer): rotation and liveness slash - hook onto all real sequencer changes #1477

Merged
merged 2 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions x/rollapp/keeper/hard_fork.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ func (k Keeper) HardFork(ctx sdk.Context, rollappID string, newRevisionHeight ui
// update revision number
rollapp.RevisionNumber += 1
rollapp.RevisionStartHeight = 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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong godoc

// 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 @@
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")

Check warning on line 97 in x/sequencer/keeper/rotation.go

View check run for this annotation

Codecov / codecov/patch

x/sequencer/keeper/rotation.go#L97

Added line #L97 was not covered by tests
}

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 @@
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 {

Check warning on line 14 in x/sequencer/types/hooks.go

View check run for this annotation

Codecov / codecov/patch

x/sequencer/types/hooks.go#L14

Added line #L14 was not covered by tests
return nil
}

Expand All @@ -27,9 +27,9 @@
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
Loading