Skip to content

Commit

Permalink
Merge pull request #22 from Layr-Labs/epociask--larger-batches
Browse files Browse the repository at this point in the history
feat:  larger batches for EigenDA
  • Loading branch information
epociask authored Aug 8, 2024
2 parents 2980742 + 7ee4b50 commit 5b37117
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
12 changes: 10 additions & 2 deletions arbnode/batch_poster.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ type BatchPosterConfig struct {
MaxSize int `koanf:"max-size" reload:"hot"`
// Maximum 4844 blob enabled batch size.
Max4844BatchSize int `koanf:"max-4844-batch-size" reload:"hot"`
// Maximum EigenDA blob enabled batch size.
MaxEigenDABatchSize int `koanf:"max-eigenda-batch-size" reload:"hot"`
// Max batch post delay.
MaxDelay time.Duration `koanf:"max-delay" reload:"hot"`
// Wait for max BatchPost delay.
Expand Down Expand Up @@ -210,6 +212,7 @@ func BatchPosterConfigAddOptions(prefix string, f *pflag.FlagSet) {
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.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")
f.Duration(prefix+".max-delay", DefaultBatchPosterConfig.MaxDelay, "maximum batch posting delay")
f.Bool(prefix+".wait-for-max-delay", DefaultBatchPosterConfig.WaitForMaxDelay, "wait for the max batch delay, even if the batch is full")
f.Duration(prefix+".poll-interval", DefaultBatchPosterConfig.PollInterval, "how long to wait after no batches are ready to be posted before checking again")
Expand All @@ -236,6 +239,7 @@ var DefaultBatchPosterConfig = BatchPosterConfig{
DisableDapFallbackStoreDataOnChain: false,
// This default is overridden for L3 chains in applyChainParameters in cmd/nitro/nitro.go
MaxSize: 100000,
MaxEigenDABatchSize: 2_000_000,
// Try to fill 3 blobs per batch
Max4844BatchSize: blobs.BlobEncodableData*(params.MaxBlobGasPerBlock/params.BlobTxBlobGasPerBlob)/2 - 2000,
PollInterval: time.Second * 10,
Expand Down Expand Up @@ -270,6 +274,7 @@ var TestBatchPosterConfig = BatchPosterConfig{
Enable: true,
MaxSize: 100000,
Max4844BatchSize: DefaultBatchPosterConfig.Max4844BatchSize,
MaxEigenDABatchSize: DefaultBatchPosterConfig.MaxEigenDABatchSize,
PollInterval: time.Millisecond * 10,
ErrorDelay: time.Millisecond * 10,
MaxDelay: 0,
Expand All @@ -293,6 +298,7 @@ var EigenDABatchPosterConfig = BatchPosterConfig{
Enable: true,
MaxSize: 100000,
Max4844BatchSize: DefaultBatchPosterConfig.Max4844BatchSize,
MaxEigenDABatchSize: DefaultBatchPosterConfig.MaxEigenDABatchSize,
PollInterval: time.Millisecond * 10,
ErrorDelay: time.Millisecond * 10,
MaxDelay: 0,
Expand Down Expand Up @@ -707,10 +713,12 @@ type buildingBatch struct {
useEigenDA bool
}

func newBatchSegments(firstDelayed uint64, config *BatchPosterConfig, backlog uint64, use4844 bool) *batchSegments {
func newBatchSegments(firstDelayed uint64, config *BatchPosterConfig, backlog uint64, use4844 bool, useEigenDA bool) *batchSegments {
maxSize := config.MaxSize
if use4844 {
maxSize = config.Max4844BatchSize
} else if useEigenDA {
maxSize = config.MaxEigenDABatchSize
} else {
if maxSize <= 40 {
panic("Maximum batch size too small")
Expand Down Expand Up @@ -1236,7 +1244,7 @@ func (b *BatchPoster) maybePostSequencerBatch(ctx context.Context) (bool, error)
}

b.building = &buildingBatch{
segments: newBatchSegments(batchPosition.DelayedMessageCount, b.config(), b.GetBacklogEstimate(), use4844),
segments: newBatchSegments(batchPosition.DelayedMessageCount, b.config(), b.GetBacklogEstimate(), use4844, useEigenDA),
msgCount: batchPosition.MessageCount,
startMsgCount: batchPosition.MessageCount,
use4844: use4844,
Expand Down
12 changes: 12 additions & 0 deletions cmd/nitro/nitro.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import (
"github.com/offchainlabs/nitro/cmd/genericconf"
"github.com/offchainlabs/nitro/cmd/util"
"github.com/offchainlabs/nitro/cmd/util/confighelpers"
"github.com/offchainlabs/nitro/eigenda"
"github.com/offchainlabs/nitro/execution/gethexec"
_ "github.com/offchainlabs/nitro/execution/nodeInterface"
"github.com/offchainlabs/nitro/solgen/go/bridgegen"
Expand Down Expand Up @@ -601,6 +602,17 @@ func mainImpl() int {
return 1
}
}

// NOTE: since the SRS is stored within the arbitrator and predetermines the max batch size
// supported for proving stateless execution - it could be possible to read from dynamically
// otherwise it maybe best to expose the max supported batch size from the disperser directly
// to ensure dynamically adaptability within the rollup.
if nodeConfig.Node.BatchPoster.Enable && nodeConfig.Node.EigenDA.Enable {
if nodeConfig.Node.BatchPoster.MaxEigenDABatchSize > eigenda.MaxBatchSize {
log.Error("batchPoster's MaxEigenDABatchSize too large.", "MaxEigenDABatchSize", eigenda.MaxBatchSize)
return 1
}
}
// If sequencer is enabled, validate MaxTxDataSize to be at least 5kB below the batch poster's MaxSize to allow space for headers and such.
// And since batchposter's MaxSize is to be at least 10kB below the sequencer inbox’s maxDataSize, this leads to another condition of atlest 15kB below the sequencer inbox’s maxDataSize.
if nodeConfig.Execution.Sequencer.Enable {
Expand Down
Loading

0 comments on commit 5b37117

Please sign in to comment.