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

Official release for Nitro v2.3.3 with Celestia DA #15

Merged
merged 20 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fallback to Anytrust + Noop CelestiaWriter
  • Loading branch information
Ferret-san committed May 31, 2024
commit 798c13ca9db0940933f9e92f1f9f5dc40e640a48
30 changes: 18 additions & 12 deletions arbnode/batch_poster.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,11 @@ const (
)

type BatchPosterConfig struct {
Enable bool `koanf:"enable"`
Enable bool `koanf:"enable"`
// TODO (Diego) rework the 3 configs below once unified writer interface is in
DisableDasFallbackStoreDataOnChain bool `koanf:"disable-das-fallback-store-data-on-chain" reload:"hot"`
DisableCelestiaFallbackStoreDataOnChain bool `koanf:"disable-celestia-fallback-store-data-on-chain" reload:"hot"`
DisableCelestiaFallbackStoreDataOnDAS bool `koanf:"disable-celestia-fallback-store-data-on-das" reload:"hot"`
// Max batch size.
MaxSize int `koanf:"max-size" reload:"hot"`
// Maximum 4844 blob enabled batch size.
Expand Down Expand Up @@ -1199,7 +1201,22 @@ func (b *BatchPoster) maybePostSequencerBatch(ctx context.Context) (bool, error)
return false, nil
}

if b.celestiaWriter != nil {
celestiaMsg, err := b.celestiaWriter.Store(ctx, sequencerMsg)
if err != nil {
if config.DisableCelestiaFallbackStoreDataOnChain && config.DisableCelestiaFallbackStoreDataOnDAS {
return false, errors.New("unable to post batch to Celestia and fallback storing data on chain and das is disabled")
}
log.Warn("Falling back to storing data on chain", "err", err)
} else {
sequencerMsg = celestiaMsg
}
}

if b.daWriter != nil {
if b.celestiaWriter != nil && config.DisableCelestiaFallbackStoreDataOnDAS {
return false, errors.New("found Celestia DA enabled and DAS, but fallbacks to DAS aredisabled")
}
if !b.redisLock.AttemptLock(ctx) {
return false, errAttemptLockFailed
}
Expand All @@ -1223,17 +1240,6 @@ func (b *BatchPoster) maybePostSequencerBatch(ctx context.Context) (bool, error)
} else {
sequencerMsg = das.Serialize(cert)
}
} else if b.celestiaWriter != nil {
celestiaMsg, err := b.celestiaWriter.Store(ctx, sequencerMsg)
if err != nil {
if config.DisableCelestiaFallbackStoreDataOnChain {
return false, errors.New("unable to post batch to Celestia and fallback storing data on chain is disabled")
}
log.Warn("Falling back to storing data on chain", "err", err)
} else {
sequencerMsg = celestiaMsg
}

}

data, kzgBlobs, err := b.encodeAddBatch(new(big.Int).SetUint64(batchPosition.NextSeqNum), batchPosition.MessageCount, b.building.msgCount, sequencerMsg, b.building.segments.delayedMsg, b.building.use4844)
Expand Down
5 changes: 5 additions & 0 deletions das/celestia/celestia.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type DAConfig struct {
Rpc string `koanf:"rpc"`
NamespaceId string `koanf:"namespace-id"`
AuthToken string `koanf:"auth-token"`
NoopWriter bool `koanf:"noop-writer" reload:"hot"`
ValidatorConfig *ValidatorConfig `koanf:"validator-config"`
}

Expand Down Expand Up @@ -146,6 +147,10 @@ func NewCelestiaDA(cfg *DAConfig, ethClient *ethclient.Client) (*CelestiaDA, err
}

func (c *CelestiaDA) Store(ctx context.Context, message []byte) ([]byte, error) {
if c.Cfg.NoopWriter {
log.Warn("NoopWriter enabled, falling back", "c.Cfg.NoopWriter", c.Cfg.NoopWriter)
return nil, errors.New("NoopWriter enabled")
}
// set a 5 minute timeout context on submissions
// if it takes longer than that to succesfully submit and verify a blob,
// then there's an issue with the connection to the celestia node
Expand Down