Skip to content

Commit

Permalink
Aggregate in batches (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdehoog authored Nov 5, 2024
1 parent 0f6c0ae commit b00a8e7
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions op-proposer/proposer/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (
"github.com/ethereum/go-ethereum/log"
)

const aggregateBatchSize = 1000

var (
ErrProposerNotRunning = errors.New("proposer is not running")
)
Expand Down Expand Up @@ -295,16 +297,19 @@ func (l *L2OutputSubmitter) nextOutput(ctx context.Context, latestOutput binding
}
l.pending = l.pending[len(proposals):]

proposal := proposals[0]
if len(proposals) > 1 {
proposal, err = l.prover.Aggregate(ctx, latestOutput.OutputRoot, proposals)
for len(proposals) > 1 {
batchLength := min(len(proposals), aggregateBatchSize)
batch := proposals[:batchLength]
aggregated, err := l.prover.Aggregate(ctx, latestOutput.OutputRoot, batch)
if err != nil {
return nil, false, fmt.Errorf("failed to aggregate proofs: %w", err)
}
l.Log.Info("Aggregated proofs",
"output", proposal.Output.OutputRoot.String(), "blocks", len(proposals),
"withdrawals", proposal.Withdrawals, "from", proposal.From.Number, "to", proposal.To.Number)
"output", aggregated.Output.OutputRoot.String(), "blocks", batchLength, "remaining", len(proposals),
"withdrawals", aggregated.Withdrawals, "from", aggregated.From.Number, "to", aggregated.To.Number)
proposals = append([]*Proposal{aggregated}, proposals[batchLength:]...)
}
proposal := proposals[0]
l.pending = append([]*Proposal{proposal}, l.pending...)

if proposal.To.Hash != latestSafe.Hash {
Expand Down

0 comments on commit b00a8e7

Please sign in to comment.