Skip to content

Commit

Permalink
Removes HardReorg config from InboxReader
Browse files Browse the repository at this point in the history
  • Loading branch information
diegoximenes committed Jul 31, 2024
1 parent ac2603a commit 0d584ee
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 182 deletions.
153 changes: 0 additions & 153 deletions arbnode/delayed_seq_reorg_test.go

This file was deleted.

13 changes: 2 additions & 11 deletions arbnode/inbox_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
type InboxReaderConfig struct {
DelayBlocks uint64 `koanf:"delay-blocks" reload:"hot"`
CheckDelay time.Duration `koanf:"check-delay" reload:"hot"`
HardReorg bool `koanf:"hard-reorg" reload:"hot"`
MinBlocksToRead uint64 `koanf:"min-blocks-to-read" reload:"hot"`
DefaultBlocksToRead uint64 `koanf:"default-blocks-to-read" reload:"hot"`
TargetMessagesRead uint64 `koanf:"target-messages-read" reload:"hot"`
Expand All @@ -50,7 +49,6 @@ func (c *InboxReaderConfig) Validate() error {
func InboxReaderConfigAddOptions(prefix string, f *flag.FlagSet) {
f.Uint64(prefix+".delay-blocks", DefaultInboxReaderConfig.DelayBlocks, "number of latest blocks to ignore to reduce reorgs")
f.Duration(prefix+".check-delay", DefaultInboxReaderConfig.CheckDelay, "the maximum time to wait between inbox checks (if not enough new blocks are found)")
f.Bool(prefix+".hard-reorg", DefaultInboxReaderConfig.HardReorg, "erase future transactions in addition to overwriting existing ones on reorg")
f.Uint64(prefix+".min-blocks-to-read", DefaultInboxReaderConfig.MinBlocksToRead, "the minimum number of blocks to read at once (when caught up lowers load on L1)")
f.Uint64(prefix+".default-blocks-to-read", DefaultInboxReaderConfig.DefaultBlocksToRead, "the default number of blocks to read at once (will vary based on traffic by default)")
f.Uint64(prefix+".target-messages-read", DefaultInboxReaderConfig.TargetMessagesRead, "if adjust-blocks-to-read is enabled, the target number of messages to read at once")
Expand All @@ -61,7 +59,6 @@ func InboxReaderConfigAddOptions(prefix string, f *flag.FlagSet) {
var DefaultInboxReaderConfig = InboxReaderConfig{
DelayBlocks: 0,
CheckDelay: time.Minute,
HardReorg: false,
MinBlocksToRead: 1,
DefaultBlocksToRead: 100,
TargetMessagesRead: 500,
Expand All @@ -72,7 +69,6 @@ var DefaultInboxReaderConfig = InboxReaderConfig{
var TestInboxReaderConfig = InboxReaderConfig{
DelayBlocks: 0,
CheckDelay: time.Millisecond * 10,
HardReorg: false,
MinBlocksToRead: 1,
DefaultBlocksToRead: 100,
TargetMessagesRead: 500,
Expand Down Expand Up @@ -337,7 +333,7 @@ func (r *InboxReader) run(ctx context.Context, hadError bool) error {
missingDelayed = true
} else if ourLatestDelayedCount > checkingDelayedCount {
log.Info("backwards reorg of delayed messages", "from", ourLatestDelayedCount, "to", checkingDelayedCount)
err = r.tracker.ReorgDelayedTo(checkingDelayedCount, config.HardReorg)
err = r.tracker.ReorgDelayedTo(checkingDelayedCount)
if err != nil {
return err
}
Expand Down Expand Up @@ -372,11 +368,6 @@ func (r *InboxReader) run(ctx context.Context, hadError bool) error {
if ourLatestBatchCount < checkingBatchCount {
checkingBatchCount = ourLatestBatchCount
missingSequencer = true
} else if ourLatestBatchCount > checkingBatchCount && config.HardReorg {
err = r.tracker.ReorgBatchesTo(checkingBatchCount)
if err != nil {
return err
}
}
if checkingBatchCount > 0 {
checkingBatchSeqNum := checkingBatchCount - 1
Expand Down Expand Up @@ -564,7 +555,7 @@ func (r *InboxReader) run(ctx context.Context, hadError bool) error {
}

func (r *InboxReader) addMessages(ctx context.Context, sequencerBatches []*SequencerInboxBatch, delayedMessages []*DelayedInboxMessage) (bool, error) {
err := r.tracker.AddDelayedMessages(delayedMessages, r.config().HardReorg)
err := r.tracker.AddDelayedMessages(delayedMessages)
if err != nil {
return false, err
}
Expand Down
24 changes: 11 additions & 13 deletions arbnode/inbox_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ func (t *InboxTracker) GetDelayedMessageBytes(ctx context.Context, seqNum uint64
return msg.Serialize()
}

func (t *InboxTracker) AddDelayedMessages(messages []*DelayedInboxMessage, hardReorg bool) error {
func (t *InboxTracker) AddDelayedMessages(messages []*DelayedInboxMessage) error {
var nextAcc common.Hash
firstDelayedMsgToKeep := uint64(0)
if len(messages) == 0 {
Expand Down Expand Up @@ -439,17 +439,15 @@ func (t *InboxTracker) AddDelayedMessages(messages []*DelayedInboxMessage, hardR
t.mutex.Lock()
defer t.mutex.Unlock()

if !hardReorg {
// This math is safe to do as we know len(messages) > 0
haveLastAcc, err := t.GetDelayedAcc(pos + uint64(len(messages)) - 1)
if err == nil {
if haveLastAcc == messages[len(messages)-1].AfterInboxAcc() {
// We already have these delayed messages
return nil
}
} else if !errors.Is(err, AccumulatorNotFoundErr) {
return err
// This math is safe to do as we know len(messages) > 0
haveLastAcc, err := t.GetDelayedAcc(pos + uint64(len(messages)) - 1)
if err == nil {
if haveLastAcc == messages[len(messages)-1].AfterInboxAcc() {
// We already have these delayed messages
return nil
}
} else if !errors.Is(err, AccumulatorNotFoundErr) {
return err
}

if pos > firstDelayedMsgToKeep {
Expand Down Expand Up @@ -848,7 +846,7 @@ func (t *InboxTracker) AddSequencerBatches(ctx context.Context, client arbutil.L
return nil
}

func (t *InboxTracker) ReorgDelayedTo(count uint64, canReorgBatches bool) error {
func (t *InboxTracker) ReorgDelayedTo(count uint64) error {
t.mutex.Lock()
defer t.mutex.Unlock()

Expand All @@ -863,7 +861,7 @@ func (t *InboxTracker) ReorgDelayedTo(count uint64, canReorgBatches bool) error
return errors.New("attempted to reorg to future delayed count")
}

return t.setDelayedCountReorgAndWriteBatch(t.db.NewBatch(), count, canReorgBatches)
return t.setDelayedCountReorgAndWriteBatch(t.db.NewBatch(), count, false)
}

func (t *InboxTracker) ReorgBatchesTo(count uint64) error {
Expand Down
4 changes: 0 additions & 4 deletions cmd/nitro/nitro.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,6 @@ func mainImpl() int {
nodeConfig.Node.ParentChainReader.Enable = true
}

if nodeConfig.Execution.Sequencer.Enable && nodeConfig.Node.ParentChainReader.Enable && nodeConfig.Node.InboxReader.HardReorg {
flag.Usage()
log.Crit("hard reorgs cannot safely be enabled with sequencer mode enabled")
}
if nodeConfig.Execution.Sequencer.Enable != nodeConfig.Node.Sequencer {
log.Error("consensus and execution must agree if sequencing is enabled or not", "Execution.Sequencer.Enable", nodeConfig.Execution.Sequencer.Enable, "Node.Sequencer", nodeConfig.Node.Sequencer)
}
Expand Down
1 change: 0 additions & 1 deletion system_tests/seqinbox_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ func testSequencerInboxReaderImpl(t *testing.T, validator bool) {
defer cancel()

builder := NewNodeBuilder(ctx).DefaultConfig(t, true)
builder.nodeConfig.InboxReader.HardReorg = true
if validator {
builder.nodeConfig.BlockValidator.Enable = true
}
Expand Down

0 comments on commit 0d584ee

Please sign in to comment.