Skip to content

Commit

Permalink
Fix anytrust fallback
Browse files Browse the repository at this point in the history
- Fix anytrust fallback issues
- Add `Type()` to dapWritter to differentiate which dapWritter is being used (`celestia` or `anytrust`)
- pin contracts branch and nitro testnode branch
  • Loading branch information
Ferret-san committed Dec 2, 2024
1 parent 6b363f5 commit 1ccf47b
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 5 deletions.
7 changes: 4 additions & 3 deletions arbnode/batch_poster.go
Original file line number Diff line number Diff line change
Expand Up @@ -1367,15 +1367,16 @@ func (b *BatchPoster) maybePostSequencerBatch(ctx context.Context) (bool, error)
}

// attempt to store data using one of the dapWriters, if it fails and fallbacks are disabled, return a hard error
seqMsg := sequencerMsg
for _, writer := range b.dapWriters {
// #nosec G115
sequencerMsg, err = writer.Store(ctx, sequencerMsg, uint64(time.Now().Add(config.DASRetentionPeriod).Unix()), config.DisableDapFallbackStoreDataOnChain)
log.Info("Attempting to store data with dapWriter", "type", writer.Type())
sequencerMsg, err = writer.Store(ctx, seqMsg, uint64(time.Now().Add(config.DASRetentionPeriod).Unix()), config.DisableDapFallbackStoreDataOnChain)
if err != nil {
if config.DisableDapFallbackStoreDataOnChain {
log.Error("Error while attempting to post batch and on chain fallback is disabled", "error", err)
return false, err
}
log.Error("Error when trying to store data with dapWriter", "error", err)
log.Error("Error when trying to store data with dapWriter", "type", writer.Type())
continue
}
// if we succesffuly posted a batch with a dapWriter, we move on and ignore the rest
Expand Down
2 changes: 2 additions & 0 deletions arbnode/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -733,12 +733,14 @@ func createNodeImpl(
nilWriter := false
switch strings.ToLower(providerName) {
case "anytrust":
log.Info("Adding DapWriter", "type", "anytrust")
if daWriter != nil {
dapWriters = append(dapWriters, daprovider.NewWriterForDAS(daWriter))
} else {
nilWriter = true
}
case "celestia":
log.Info("Adding DapWriter", "type", "celestia")
if celestiaWriter != nil {
dapWriters = append(dapWriters, celestiaTypes.NewWriterForCelestia(celestiaWriter))
} else {
Expand Down
7 changes: 7 additions & 0 deletions arbstate/daprovider/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ type Writer interface {
timeout uint64,
disableFallbackStoreDataOnChain bool,
) ([]byte, error)

// Identifies a Writer by type
Type() string
}

// DAProviderWriterForDAS is generally meant to be only used by nitro.
Expand All @@ -45,3 +48,7 @@ func (d *writerForDAS) Store(ctx context.Context, message []byte, timeout uint64
return Serialize(cert), nil
}
}

func (d *writerForDAS) Type() string {
return "anytrust"
}
4 changes: 4 additions & 0 deletions das/celestia/types/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@ func (c *writerForCelestia) Store(ctx context.Context, message []byte, timeout u
message = msg
return message, nil
}

func (d *writerForCelestia) Type() string {
return "celestia"
}

0 comments on commit 1ccf47b

Please sign in to comment.