mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-30 08:33:45 +00:00
* port changes from #1013 * port changes from #1068 * go.mod tidy * fix compile error * fix goimports * fix log * address review comments * upgrade golang.org/x/net to 0.23.0 * port changes from #1018 * fix tests and linter errors * address review comments * refactor rollup sync service / verifier to use CalldataBlobSource to retrieve data from L1 * add configuration and initialize blob clients * fix unit tests * remove unused code * address review comments * address more review comments * implement first version of new da-codec and to handle multiple batches submitted in one transaction * add CommitBatchDAV7 and handle multiple commit events submitted in a single transactions * fix bug due to previous batch being empty when processing the first batch within a set of batches * Allow using MPT * update to latest da-codec * add field to CommittedBatchMeta to store LastL1MessageQueueHash for CodecV7 batches * adjust rollup verifier to support CodecV7 batches * address review comments * fix issues after merge * go mod tidy * fix unit tests * update da-codec * add test TestValidateBatchCodecV7 * go mod tidy * do not log error on shutdown * add sanity check for version to deserialization of committedBatchMetaV7 * port changes from #1073 * chore: auto version bump [bot] * address review comments * add more logs * disable ENRUpdater if DA sync mode is enabled * exit pipeline if context is cancelled * correctly handle override by setting the head of the chain to the parent's height so that created blocks will always become part of canonical chain * fix error with genesis event being nil * chore: auto version bump [bot] * chore: auto version bump [bot] * goimports --------- Co-authored-by: Ömer Faruk Irmak <omerfirmak@gmail.com> Co-authored-by: Thegaram <Thegaram@users.noreply.github.com> Co-authored-by: jonastheis <jonastheis@users.noreply.github.com> Co-authored-by: Péter Garamvölgyi <peter@scroll.io>
93 lines
2 KiB
Go
93 lines
2 KiB
Go
package da_syncer
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
|
|
"github.com/scroll-tech/go-ethereum/log"
|
|
"github.com/scroll-tech/go-ethereum/rollup/da_syncer/da"
|
|
"github.com/scroll-tech/go-ethereum/rollup/da_syncer/serrors"
|
|
)
|
|
|
|
// DAQueue is a pipeline stage that reads DA entries from a DataSource and provides them to the next stage.
|
|
type DAQueue struct {
|
|
l1height uint64
|
|
initialBatch uint64
|
|
|
|
dataSourceFactory *DataSourceFactory
|
|
dataSource DataSource
|
|
da da.Entries
|
|
}
|
|
|
|
func NewDAQueue(l1height uint64, initialBatch uint64, dataSourceFactory *DataSourceFactory) *DAQueue {
|
|
return &DAQueue{
|
|
l1height: l1height,
|
|
initialBatch: initialBatch,
|
|
dataSourceFactory: dataSourceFactory,
|
|
dataSource: nil,
|
|
da: make(da.Entries, 0),
|
|
}
|
|
}
|
|
|
|
func (dq *DAQueue) NextDA(ctx context.Context) (da.Entry, error) {
|
|
for {
|
|
select {
|
|
case <-ctx.Done():
|
|
return nil, ctx.Err()
|
|
default:
|
|
}
|
|
|
|
for len(dq.da) == 0 {
|
|
err := dq.getNextData(ctx)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
|
|
daEntry := dq.da[0]
|
|
dq.da = dq.da[1:]
|
|
|
|
if daEntry.BatchIndex() < dq.initialBatch {
|
|
log.Debug("Skipping DA entry due to initial batch requirement", "batchIndex", daEntry.BatchIndex(), "initialBatch", dq.initialBatch)
|
|
continue
|
|
}
|
|
|
|
return daEntry, nil
|
|
}
|
|
}
|
|
|
|
func (dq *DAQueue) getNextData(ctx context.Context) error {
|
|
var err error
|
|
if dq.dataSource == nil {
|
|
dq.dataSource, err = dq.dataSourceFactory.OpenDataSource(ctx, dq.l1height)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
}
|
|
|
|
dq.da, err = dq.dataSource.NextData()
|
|
if err == nil {
|
|
return nil
|
|
}
|
|
|
|
// previous dataSource has been exhausted, create new
|
|
if errors.Is(err, da.ErrSourceExhausted) {
|
|
dq.l1height = dq.dataSource.L1Height()
|
|
dq.dataSource = nil
|
|
|
|
// we return EOFError to be handled in pipeline
|
|
return serrors.EOFError
|
|
}
|
|
|
|
return err
|
|
}
|
|
|
|
func (dq *DAQueue) DataSource() DataSource {
|
|
return dq.dataSource
|
|
}
|
|
|
|
func (dq *DAQueue) Reset(height uint64) {
|
|
dq.l1height = height
|
|
dq.dataSource = nil
|
|
dq.da = make(da.Entries, 0)
|
|
}
|