Skip to content

Commit

Permalink
fixes after merge
Browse files Browse the repository at this point in the history
  • Loading branch information
jonastheis committed Oct 23, 2024
1 parent 6464296 commit 79842f8
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 179 deletions.
3 changes: 0 additions & 3 deletions core/rawdb/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,6 @@ var (
// Scroll da syncer store
daSyncedL1BlockNumberKey = []byte("LastDASyncedL1BlockNumber")

// Scroll da syncer store
daSyncedL1BlockNumberKey = []byte("LastDASyncedL1BlockNumber")

// Row consumption
rowConsumptionPrefix = []byte("rc") // rowConsumptionPrefix + hash -> row consumption by block

Expand Down
3 changes: 2 additions & 1 deletion eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ import (
"github.com/scroll-tech/go-ethereum/rlp"
"github.com/scroll-tech/go-ethereum/rollup/ccc"
"github.com/scroll-tech/go-ethereum/rollup/da_syncer"
"github.com/scroll-tech/go-ethereum/rollup/l1"
"github.com/scroll-tech/go-ethereum/rollup/rollup_sync_service"
"github.com/scroll-tech/go-ethereum/rollup/sync_service"
"github.com/scroll-tech/go-ethereum/rpc"
Expand Down Expand Up @@ -114,7 +115,7 @@ type Ethereum struct {

// New creates a new Ethereum object (including the
// initialisation of the common Ethereum object)
func New(stack *node.Node, config *ethconfig.Config, l1Client sync_service.EthClient) (*Ethereum, error) {
func New(stack *node.Node, config *ethconfig.Config, l1Client l1.Client) (*Ethereum, error) {
// Ensure configuration values are compatible and sane
if config.SyncMode == downloader.LightSync {
return nil, errors.New("can't run eth.Ethereum in light sync mode, use les.LightEthereum")
Expand Down
4 changes: 2 additions & 2 deletions rollup/da_syncer/blob_client/blob_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ func NewBlobClients(blobClients ...BlobClient) *BlobClients {
}
}

func (c *BlobClients) GetBlobByVersionedHashAndBlockNumber(ctx context.Context, versionedHash common.Hash, blockNumber uint64) (*kzg4844.Blob, error) {
func (c *BlobClients) GetBlobByVersionedHashAndBlockTime(ctx context.Context, versionedHash common.Hash, blockTime uint64) (*kzg4844.Blob, error) {
if len(c.list) == 0 {
return nil, fmt.Errorf("BlobClients.GetBlobByVersionedHash: list of BlobClients is empty")
}

for i := 0; i < len(c.list); i++ {
blob, err := c.list[c.curPos].GetBlobByVersionedHashAndBlockNumber(ctx, versionedHash, blockNumber)
blob, err := c.list[c.curPos].GetBlobByVersionedHashAndBlockTime(ctx, versionedHash, blockTime)
if err == nil {
return blob, nil
}
Expand Down
65 changes: 0 additions & 65 deletions rollup/da_syncer/blob_client/blob_client_list.go

This file was deleted.

18 changes: 8 additions & 10 deletions rollup/da_syncer/da/calldata_blob_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@ import (
"fmt"

"github.com/scroll-tech/da-codec/encoding"

"github.com/scroll-tech/go-ethereum/accounts/abi"
"github.com/scroll-tech/go-ethereum/common"
"github.com/scroll-tech/go-ethereum/core/types"
"github.com/scroll-tech/go-ethereum/ethdb"
"github.com/scroll-tech/go-ethereum/log"
"github.com/scroll-tech/go-ethereum/rollup/da_syncer/blob_client"
"github.com/scroll-tech/go-ethereum/rollup/da_syncer/serrors"
"github.com/scroll-tech/go-ethereum/rollup/rollup_sync_service"
"github.com/scroll-tech/go-ethereum/rollup/l1"
)

Expand All @@ -35,7 +33,7 @@ var (

type CalldataBlobSource struct {
ctx context.Context
l1Reader *l1.Reader
l1Reader *l1.Reader
blobClient blob_client.BlobClient
l1height uint64
scrollChainABI *abi.ABI
Expand All @@ -54,7 +52,7 @@ func NewCalldataBlobSource(ctx context.Context, l1height uint64, l1Reader *l1.Re
}
return &CalldataBlobSource{
ctx: ctx,
l1Reader: l1Reader,
l1Reader: l1Reader,
blobClient: blobClient,
l1height: l1height,
scrollChainABI: scrollChainABI,
Expand Down Expand Up @@ -89,7 +87,7 @@ func (ds *CalldataBlobSource) NextData() (Entries, error) {
if err != nil {
return nil, serrors.NewTemporaryError(fmt.Errorf("cannot get rollup events, l1height: %d, error: %v", ds.l1height, err))
}
da, err := ds.processLogsToDA(logs)
da, err := ds.processRollupEventsToDA(rollupEvents)
if err != nil {
return nil, serrors.NewTemporaryError(fmt.Errorf("failed to process rollup events to DA, error: %v", err))
}
Expand Down Expand Up @@ -175,7 +173,7 @@ func (ds *CalldataBlobSource) getCommitBatchDA(batchIndex uint64, commitEvent *l

txData, err := ds.l1Reader.FetchTxData(commitEvent.TxHash(), commitEvent.BlockHash())
if err != nil {
return nil, fmt.Errorf("failed to fetch tx data, tx hash: %v, err: %w", vLog.TxHash.Hex(), err)
return nil, fmt.Errorf("failed to fetch tx data, tx hash: %v, err: %w", commitEvent.TxHash().Hex(), err)
}
if len(txData) < methodIDLength {
return nil, fmt.Errorf("transaction data is too short, length of tx data: %v, minimum length required: %v", len(txData), methodIDLength)
Expand All @@ -202,9 +200,9 @@ func (ds *CalldataBlobSource) getCommitBatchDA(batchIndex uint64, commitEvent *l
}
switch args.Version {
case 0:
return NewCommitBatchDAV0(ds.db, codec, args.Version, batchIndex, args.ParentBatchHeader, args.Chunks, args.SkippedL1MessageBitmap, vLog.BlockNumber)
return NewCommitBatchDAV0(ds.db, codec, args.Version, batchIndex, args.ParentBatchHeader, args.Chunks, args.SkippedL1MessageBitmap, commitEvent.BlockNumber())
case 1, 2:
return NewCommitBatchDAWithBlob(ds.ctx, ds.db, codec, ds.l1Client, ds.blobClient, vLog, args.Version, batchIndex, args.ParentBatchHeader, args.Chunks, args.SkippedL1MessageBitmap)
return NewCommitBatchDAWithBlob(ds.ctx, ds.db, codec, ds.l1Reader, ds.blobClient, commitEvent, args.Version, batchIndex, args.ParentBatchHeader, args.Chunks, args.SkippedL1MessageBitmap)
default:
return nil, fmt.Errorf("failed to decode DA, codec version is unknown: codec version: %d", args.Version)
}
Expand All @@ -220,7 +218,7 @@ func (ds *CalldataBlobSource) getCommitBatchDA(batchIndex uint64, commitEvent *l
}
switch args.Version {
case 3, 4:
return NewCommitBatchDAWithBlob(ds.ctx, ds.db, codec, ds.l1Client, ds.blobClient, vLog, args.Version, batchIndex, args.ParentBatchHeader, args.Chunks, args.SkippedL1MessageBitmap)
return NewCommitBatchDAWithBlob(ds.ctx, ds.db, codec, ds.l1Reader, ds.blobClient, commitEvent, args.Version, batchIndex, args.ParentBatchHeader, args.Chunks, args.SkippedL1MessageBitmap)
default:
return nil, fmt.Errorf("failed to decode DA, codec version is unknown: codec version: %d", args.Version)
}
Expand Down
21 changes: 2 additions & 19 deletions rollup/da_syncer/da/commitV1.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,11 @@ import (
"fmt"

"github.com/scroll-tech/da-codec/encoding"
"github.com/scroll-tech/da-codec/encoding/codecv0"
"github.com/scroll-tech/da-codec/encoding/codecv1"

"github.com/scroll-tech/go-ethereum/rollup/da_syncer/blob_client"
"github.com/scroll-tech/go-ethereum/rollup/rollup_sync_service"
"github.com/scroll-tech/go-ethereum/rollup/l1"

"github.com/scroll-tech/go-ethereum/common"
"github.com/scroll-tech/go-ethereum/core/types"
"github.com/scroll-tech/go-ethereum/crypto/kzg4844"
"github.com/scroll-tech/go-ethereum/ethdb"
)
Expand All @@ -23,7 +19,7 @@ type CommitBatchDAV1 struct {
*CommitBatchDAV0
}

func NewCommitBatchDAV1(ctx context.Context, db ethdb.Database,
func NewCommitBatchDAWithBlob(ctx context.Context, db ethdb.Database,
codec encoding.Codec,
l1Reader *l1.Reader,
blobClient blob_client.BlobClient,
Expand All @@ -33,19 +29,6 @@ func NewCommitBatchDAV1(ctx context.Context, db ethdb.Database,
parentBatchHeader []byte,
chunks [][]byte,
skippedL1MessageBitmap []byte,
) (*CommitBatchDAV1, error) {
return NewCommitBatchDAV1WithBlobDecodeFunc(ctx, db, l1Reader, blobClient, commitEvent, version, batchIndex, parentBatchHeader, chunks, skippedL1MessageBitmap, codecv1.DecodeTxsFromBlob)
}

func NewCommitBatchDAV1WithBlobDecodeFunc(ctx context.Context, db ethdb.Database,
l1Reader *l1.Reader,
blobClient blob_client.BlobClient,
commitEvent *l1.CommitBatchEvent,
version uint8,
batchIndex uint64,
parentBatchHeader []byte,
chunks [][]byte,
skippedL1MessageBitmap []byte,
) (*CommitBatchDAV1, error) {
decodedChunks, err := codec.DecodeDAChunksRawTx(chunks)
if err != nil {
Expand Down Expand Up @@ -89,7 +72,7 @@ func NewCommitBatchDAV1WithBlobDecodeFunc(ctx context.Context, db ethdb.Database
return nil, fmt.Errorf("decodedChunks is nil after decoding")
}

v0, err := NewCommitBatchDAV0WithChunks(db, version, batchIndex, parentBatchHeader, decodedChunks, skippedL1MessageBitmap, vLog.BlockNumber)
v0, err := NewCommitBatchDAV0WithChunks(db, version, batchIndex, parentBatchHeader, decodedChunks, skippedL1MessageBitmap, commitEvent.BlockNumber())
if err != nil {
return nil, err
}
Expand Down
38 changes: 0 additions & 38 deletions rollup/da_syncer/da/commitV2.go

This file was deleted.

38 changes: 0 additions & 38 deletions rollup/da_syncer/da/commitV4.go

This file was deleted.

4 changes: 1 addition & 3 deletions rollup/da_syncer/syncing_pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ import (
"github.com/scroll-tech/go-ethereum/params"
"github.com/scroll-tech/go-ethereum/rollup/da_syncer/blob_client"
"github.com/scroll-tech/go-ethereum/rollup/da_syncer/serrors"
"github.com/scroll-tech/go-ethereum/rollup/rollup_sync_service"
"github.com/scroll-tech/go-ethereum/rollup/sync_service"
"github.com/scroll-tech/go-ethereum/rollup/l1"
)

Expand Down Expand Up @@ -54,7 +52,7 @@ func NewSyncingPipeline(ctx context.Context, blockchain *core.BlockChain, genesi
return nil, fmt.Errorf("failed to initialize l1.Reader, err = %w", err)
}

blobClientList := blob_client.NewBlobClientList()
blobClientList := blob_client.NewBlobClients()
if config.BeaconNodeAPIEndpoint != "" {
beaconNodeClient, err := blob_client.NewBeaconNodeClient(config.BeaconNodeAPIEndpoint)
if err != nil {
Expand Down

0 comments on commit 79842f8

Please sign in to comment.