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(hardfork): integration fixes #1205

Closed
8 changes: 1 addition & 7 deletions block/fork.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,12 @@ func (m *Manager) checkForkUpdate(ctx context.Context) error {
}

func (m *Manager) createInstruction(rollapp *types.Rollapp) error {
nextProposer, err := m.SLClient.GetNextProposer()
if err != nil {
return err
}

instruction := types.Instruction{
Revision: rollapp.Revision,
RevisionStartHeight: rollapp.RevisionStartHeight,
Sequencer: nextProposer.SettlementAddress,
}

err = types.PersistInstructionToDisk(m.RootDir, instruction)
err := types.PersistInstructionToDisk(m.RootDir, instruction)
if err != nil {
return err
}
Expand Down
3 changes: 3 additions & 0 deletions block/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ func NewManager(

// Start starts the block manager.
func (m *Manager) Start(ctx context.Context) error {
var err error

// Check if InitChain flow is needed
if m.State.IsGenesis() {
m.logger.Info("Running InitChain")
Expand Down Expand Up @@ -238,6 +240,7 @@ func (m *Manager) Start(ctx context.Context) error {
return fmt.Errorf("am i proposer on SL: %w", err)
}
amIProposer := amIProposerOnSL || m.AmIProposerOnRollapp()
m.RunMode = map[bool]uint{true: RunModeProposer, false: RunModeFullNode}[amIProposer]

m.logger.Info("starting block manager", "mode", map[bool]string{true: "proposer", false: "full node"}[amIProposer])

Expand Down
2 changes: 0 additions & 2 deletions block/modes.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
// setFraudHandler sets the fraud handler for the block manager.
func (m *Manager) runAsFullNode(ctx context.Context, eg *errgroup.Group) error {
m.logger.Info("starting block manager", "mode", "full node")
m.RunMode = RunModeFullNode
// update latest finalized height
err := m.updateLastFinalizedHeightFromSettlement()
if err != nil {
Expand All @@ -39,7 +38,6 @@ func (m *Manager) runAsFullNode(ctx context.Context, eg *errgroup.Group) error {

func (m *Manager) runAsProposer(ctx context.Context, eg *errgroup.Group) error {
m.logger.Info("starting block manager", "mode", "proposer")
m.RunMode = RunModeProposer
// Subscribe to batch events, to update last submitted height in case batch confirmation was lost. This could happen if the sequencer crash/restarted just after submitting a batch to the settlement and by the time we query the last batch, this batch wasn't accepted yet.
go uevent.MustSubscribe(ctx, m.Pubsub, "updateSubmittedHeightLoop", settlement.EventQueryNewSettlementBatchAccepted, m.UpdateLastSubmittedHeight, m.logger)

Expand Down
2 changes: 1 addition & 1 deletion block/produce.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (m *Manager) ProduceBlockLoop(ctx context.Context, bytesProducedC chan int)
return nil
case <-ticker.C:
// Only produce if I'm the current rollapp proposer.
if !m.AmIProposerOnRollapp() {
if m.RunMode != RunModeProposer {
Copy link
Contributor

Choose a reason for hiding this comment

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

why is this modified? is this runMode not always be the same after start? i mean if the produceblockloop is started it already means is the proposer... and the runmode is not updated after start i think.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so no reason to check against local keys each time again

Copy link
Contributor

@omritoptix omritoptix Nov 7, 2024

Choose a reason for hiding this comment

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

@mtsitrin this is for when you rotate.

during rotation you start as the proposer, but you shouldn't produce blocks after you produced your last block yet you should still send your last batch.

the code you introduced will make the proposer continue producing blocks while he's submitting his last batch in parallel to the new proposer.

i.e the "propoesr on the rollapp" can change while your in proposer mode.

continue
}

Expand Down
Loading