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

feat(manager): allow starting node when sequencer is sentinel #1275

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
8 changes: 6 additions & 2 deletions block/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,9 @@ func (m *Manager) Start(ctx context.Context) error {
if m.State.GetProposer() == nil {
m.logger.Info("No proposer on the rollapp, fallback to the hub proposer, if available")
err := m.UpdateProposerFromSL()
if err != nil {
if errors.Is(err, settlement.ErrProposerIsSentinel) {
m.freezeNode(fmt.Errorf("unable to start without new proposer at height %d", m.State.NextHeight()))
Copy link
Contributor

Choose a reason for hiding this comment

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

why u need it here? if u allow starting as full node anyway?

} else if err != nil {
return err
}
_, err = m.Store.SaveState(m.State, nil)
Expand All @@ -246,7 +248,9 @@ func (m *Manager) Start(ctx context.Context) error {
// for this case, 2 nodes will get `true` for `AmIProposer` so the l2 proposer can produce blocks and the hub proposer can submit his last batch.
// The hub proposer, after sending the last state update, will panic and restart as full node.
amIProposerOnSL, err := m.AmIProposerOnSL()
Copy link
Contributor

Choose a reason for hiding this comment

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

u can add

if errors.Is(err, settlement.ErrProposerIsSentinel) {
		return false, nil

into m.AmIProposerOnSL()

if err != nil {
if errors.Is(err, settlement.ErrProposerIsSentinel) {
amIProposerOnSL = false
} else if err != nil {
return fmt.Errorf("am i proposer on SL: %w", err)
}

Expand Down
4 changes: 3 additions & 1 deletion block/modes.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ func (m *Manager) runAsProposer(ctx context.Context, eg *errgroup.Group) error {

// it is checked again whether the node is the active proposer, since this could have changed after syncing.
amIProposerOnSL, err := m.AmIProposerOnSL()
if err != nil {
if errors.Is(err, settlement.ErrProposerIsSentinel) {
amIProposerOnSL = false
} else if err != nil {
return fmt.Errorf("am i proposer on SL: %w", err)
}
if !amIProposerOnSL {
Expand Down
9 changes: 8 additions & 1 deletion block/sequencers.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ package block
import (
"bytes"
"context"
"errors"
"fmt"
"time"

"github.com/dymensionxyz/dymint/settlement"
)

const (
Expand Down Expand Up @@ -94,7 +97,11 @@ func (m *Manager) ShouldRotate() (bool, error) {
// At this point we know that there is a next proposer,
// so we should rotate only if we are the current proposer on the hub
amIProposerOnSL, err := m.AmIProposerOnSL()
if err != nil {

// if no proposer assigned, return false without error
if errors.Is(err, settlement.ErrProposerIsSentinel) {
return false, nil
} else if err != nil {
return false, fmt.Errorf("am i proposer on SL: %w", err)
}
return amIProposerOnSL, nil
Expand Down
1 change: 1 addition & 0 deletions p2p/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ func (b *BlockData) FromProto(other *pb.BlockData) error {

// Validate run basic validation on the p2p block received
func (b *BlockData) Validate(proposerPubKey tmcrypto.PubKey) error {

if err := b.Block.ValidateBasic(); err != nil {
return err
}
Expand Down
6 changes: 3 additions & 3 deletions settlement/dymension/dymension.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,8 @@ func (c *Client) GetProposerAtHeight(height int64) (*types.Sequencer, error) {
}
}

if proposerAddr == SENTINEL_PROPOSER {
return nil, fmt.Errorf("proposer is sentinel")
if proposerAddr == "" || proposerAddr == SENTINEL_PROPOSER {
return nil, settlement.ErrProposerIsSentinel
}

// Find and return the matching sequencer
Expand Down Expand Up @@ -538,7 +538,7 @@ func (c *Client) GetNextProposer() (*types.Sequencer, error) {
if !found {
return nil, nil
}
if nextAddr == SENTINEL_PROPOSER {
if nextAddr == "" || nextAddr == SENTINEL_PROPOSER {
return &types.Sequencer{}, nil
}

Expand Down
3 changes: 3 additions & 0 deletions settlement/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import (
// ErrBatchNotAccepted is returned when a batch is not accepted by the settlement layer.
var ErrBatchNotAccepted = fmt.Errorf("batch not accepted: %w", gerrc.ErrUnknown)

// ErrProposerIsSentinel is returned when a rollapp has no sequencer assigned.
var ErrProposerIsSentinel = fmt.Errorf("proposer is sentinel")

type ErrNextSequencerAddressFraud struct {
Expected string
Actual string
Expand Down
Loading