Skip to content

Commit

Permalink
feat: EigenDA failover - updated terminology and fixed bug in replay …
Browse files Browse the repository at this point in the history
…script logic
  • Loading branch information
epociask committed Nov 4, 2024
1 parent 92a13f0 commit c940fdc
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 20 deletions.
47 changes: 31 additions & 16 deletions arbnode/batch_poster.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ var (
batchPosterDALastSuccessfulActionGauge = metrics.NewRegisteredGauge("arb/batchPoster/action/da_last_success", nil)
batchPosterDASuccessCounter = metrics.NewRegisteredCounter("arb/batchPoster/action/da_success", nil)
batchPosterDAFailureCounter = metrics.NewRegisteredCounter("arb/batchPoster/action/da_failure", nil)
batchPosterDAFailoverCount = metrics.NewRegisteredCounter("arb/batchPoster/action/da_failover", nil)

batchPosterFailureCounter = metrics.NewRegisteredCounter("arb/batchPoster/action/failure", nil)

Expand Down Expand Up @@ -122,10 +123,10 @@ type BatchPoster struct {
backlog atomic.Uint64
lastHitL1Bounds time.Time // The last time we wanted to post a message but hit the L1 bounds

batchReverted atomic.Bool // indicates whether data poster batch was reverted
nextRevertCheckBlock int64 // the last parent block scanned for reverting batches
postedFirstBatch bool // indicates if batch poster has posted the first batch
failoverETHDA bool // indicates if batch poster should failover to ETHDA
batchReverted atomic.Bool // indicates whether data poster batch was reverted
nextRevertCheckBlock int64 // the last parent block scanned for reverting batches
postedFirstBatch bool // indicates if batch poster has posted the first batch
eigenDAFailoverToETHDA bool // indicates if batch poster should failover to ETHDA

accessList func(SequencerInboxAccs, AfterDelayedMessagesRead uint64) types.AccessList
}
Expand All @@ -149,7 +150,7 @@ type BatchPosterDangerousConfig struct {
type BatchPosterConfig struct {
Enable bool `koanf:"enable"`
DisableDapFallbackStoreDataOnChain bool `koanf:"disable-dap-fallback-store-data-on-chain" reload:"hot"`
EnableEigenDAFailover bool `koanf:"eigenda-failover-to-anytrust" reload:"hot"`
EnableEigenDAFailover bool `koanf:"eigenda-failover" reload:"hot"`
// Max batch size.
MaxSize int `koanf:"max-size" reload:"hot"`
// Maximum 4844 blob enabled batch size.
Expand Down Expand Up @@ -216,7 +217,7 @@ type BatchPosterConfigFetcher func() *BatchPosterConfig
func BatchPosterConfigAddOptions(prefix string, f *pflag.FlagSet) {
f.Bool(prefix+".enable", DefaultBatchPosterConfig.Enable, "enable posting batches to l1")
f.Bool(prefix+".disable-dap-fallback-store-data-on-chain", DefaultBatchPosterConfig.DisableDapFallbackStoreDataOnChain, "If unable to batch to DA provider, disable fallback storing data on chain")
f.Bool(prefix+".eigenda-failover-to-anytrust", DefaultBatchPosterConfig.EnableEigenDAFailover, "If EigenDA fails, failover to AnyTrust")
f.Bool(prefix+".eigenda-failover", DefaultBatchPosterConfig.EnableEigenDAFailover, "If EigenDA fails, failover to AnyTrust (if enabled) or native ETH DA")
f.Int(prefix+".max-size", DefaultBatchPosterConfig.MaxSize, "maximum batch size")
f.Int(prefix+".max-4844-batch-size", DefaultBatchPosterConfig.Max4844BatchSize, "maximum 4844 blob enabled batch size")
f.Int(prefix+".max-eigenda-batch-size", DefaultBatchPosterConfig.MaxEigenDABatchSize, "maximum EigenDA blob enabled batch size")
Expand Down Expand Up @@ -1253,7 +1254,7 @@ func (b *BatchPoster) maybePostSequencerBatch(ctx context.Context) (bool, error)
}

var useEigenDA bool
if b.eigenDAWriter != nil && !b.failoverETHDA {
if b.eigenDAWriter != nil && !b.eigenDAFailoverToETHDA {
useEigenDA = true
}

Expand Down Expand Up @@ -1458,7 +1459,7 @@ func (b *BatchPoster) maybePostSequencerBatch(ctx context.Context) (bool, error)
eigenDADispersed := false
failOver := false

if b.eigenDAWriter != nil && !b.failoverETHDA {
if b.eigenDAWriter != nil && !b.eigenDAFailoverToETHDA {
if !b.redisLock.AttemptLock(ctx) {
return false, errAttemptLockFailed
}
Expand All @@ -1482,20 +1483,34 @@ func (b *BatchPoster) maybePostSequencerBatch(ctx context.Context) (bool, error)

if err != nil && errors.Is(err, eigenda.SvcUnavailableErr) && b.config().EnableEigenDAFailover && b.dapWriter == nil { // Failover to ETH DA if enabled
// when failing over to ETHDA (i.e 4844, calldata), we may need to re-encode the batch. To do this in compliance with the existing code, it's easiest
// to update an internal field and retrigger the poster's event loop. Since this update should be down across batch posters on a distributed cluster, we
// must also
// to update an internal field and retrigger the poster's event loop. Since the batch poster can be distributed across mulitple nodes, there could be
// degraded temporary performance as each batch poster will re-encode the batch on another event loop tick using the coordination lock which could worst case
// could require every batcher instance to fail dispersal to EigenDA.
// However, this is a rare event and the performance impact is minimal.

log.Error("EigenDA service is unavailable and anytrust is disabled, failing over to ETH DA")
b.failoverETHDA = true
b.building = nil
return false, nil
b.eigenDAFailoverToETHDA = true

// // if the batch's size exceeds the native DA max size limit, we must re-encode the batch to accomodate the AnyTrust, calldata, and 4844 size limits
if (len(sequencerMsg) > b.config().MaxSize && !b.building.use4844) || (len(sequencerMsg) > b.config().Max4844BatchSize && b.building.use4844) {
batchPosterDAFailureCounter.Inc(1)
batchPosterDAFailoverCount.Inc(1)

b.building = nil
return false, nil
}

}

if err != nil && !failOver { //
if err != nil {
batchPosterDAFailureCounter.Inc(1)
return false, err
}

if failOver {
batchPosterDAFailoverCount.Inc(1)
}

if err == nil {

Check failure on line 1514 in arbnode/batch_poster.go

View workflow job for this annotation

GitHub Actions / Go Tests (defaults)

nilness: tautological condition: nil == nil (govet)

Check failure on line 1514 in arbnode/batch_poster.go

View workflow job for this annotation

GitHub Actions / Go Tests (race)

nilness: tautological condition: nil == nil (govet)

Check failure on line 1514 in arbnode/batch_poster.go

View workflow job for this annotation

GitHub Actions / Go Tests (challenge)

nilness: tautological condition: nil == nil (govet)

Check failure on line 1514 in arbnode/batch_poster.go

View workflow job for this annotation

GitHub Actions / Go Tests (stylus)

nilness: tautological condition: nil == nil (govet)

Check failure on line 1514 in arbnode/batch_poster.go

View workflow job for this annotation

GitHub Actions / Go Tests (long)

nilness: tautological condition: nil == nil (govet)
batchPosterDASuccessCounter.Inc(1)
batchPosterDALastSuccessfulActionGauge.Update(time.Now().Unix())
Expand Down Expand Up @@ -1586,8 +1601,8 @@ func (b *BatchPoster) maybePostSequencerBatch(ctx context.Context) (bool, error)
return false, err
}

if !b.building.useEigenDA && b.failoverETHDA {
b.failoverETHDA = false
if !b.building.useEigenDA && b.eigenDAFailoverToETHDA {
b.eigenDAFailoverToETHDA = false
}

if config.CheckBatchCorrectness {
Expand Down
4 changes: 2 additions & 2 deletions arbnode/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -587,8 +587,8 @@ func createNodeImpl(
return nil, errors.New("eigenDA and anytrust cannot both be enabled without EnableEigenDAFailover=true in batch poster config")
}

if config.EigenDA.Enable { // anytrust is enabled as an EigenDA failover
log.Info("EigenDA enabled")
if config.EigenDA.Enable {
log.Info("EigenDA enabled", "failover", config.BatchPoster.EnableEigenDAFailover, "anytrust", config.DataAvailability.Enable)
eigenDAService, err := eigenda.NewEigenDA(&config.EigenDA)
if err != nil {
return nil, err
Expand Down
4 changes: 3 additions & 1 deletion cmd/replay/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,9 @@ func main() {
// DAS batch and keysets are all together in the same preimage binary.
dasReader = &PreimageDASReader{}
dasKeysetFetcher = &PreimageDASReader{}
} else if eigenDAEnabled {
}

if eigenDAEnabled {
eigenDAReader = &EigenDAPreimageReader{}
}
backend := WavmInbox{}
Expand Down
1 change: 0 additions & 1 deletion system_tests/eigenda_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,6 @@ func TestEigenDAProxyFailOverToAnyTrust(t *testing.T) {
Require(t, err)

builder.L2.ConsensusNode.BatchPoster.SetEigenDAWriter(eigenWriter)

checkEigenDABatchPosting(t, ctx, builder.L1.Client, builder.L2.Client, builder.L1Info, builder.L2Info, big.NewInt(1e12*3), l2B.Client)

err = restServer.Shutdown()
Expand Down

0 comments on commit c940fdc

Please sign in to comment.