From d8294746f215eb0668e497d08bdbf09c8e2cd71f Mon Sep 17 00:00:00 2001 From: tchardin Date: Tue, 12 Mar 2024 11:56:47 -0600 Subject: [PATCH] fix: use l1 fetcher and check pq length --- op-node/rollup/derive/data_source.go | 6 ++---- op-node/rollup/derive/plasma_data_source.go | 4 ++-- op-plasma/dastate.go | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/op-node/rollup/derive/data_source.go b/op-node/rollup/derive/data_source.go index 45b4e3a63c9a..2a1dbd7c00de 100644 --- a/op-node/rollup/derive/data_source.go +++ b/op-node/rollup/derive/data_source.go @@ -19,8 +19,6 @@ type DataIter interface { type L1TransactionFetcher interface { InfoAndTxsByHash(ctx context.Context, hash common.Hash) (eth.BlockInfo, types.Transactions, error) - FetchReceipts(ctx context.Context, blockHash common.Hash) (eth.BlockInfo, types.Receipts, error) - L1BlockRefByNumber(context.Context, uint64) (eth.L1BlockRef, error) } type L1BlobsFetcher interface { @@ -47,13 +45,13 @@ type PlasmaInputFetcher interface { type DataSourceFactory struct { log log.Logger dsCfg DataSourceConfig - fetcher L1TransactionFetcher + fetcher L1Fetcher blobsFetcher L1BlobsFetcher plasmaFetcher PlasmaInputFetcher ecotoneTime *uint64 } -func NewDataSourceFactory(log log.Logger, cfg *rollup.Config, fetcher L1TransactionFetcher, blobsFetcher L1BlobsFetcher, plasmaFetcher PlasmaInputFetcher) *DataSourceFactory { +func NewDataSourceFactory(log log.Logger, cfg *rollup.Config, fetcher L1Fetcher, blobsFetcher L1BlobsFetcher, plasmaFetcher PlasmaInputFetcher) *DataSourceFactory { config := DataSourceConfig{ l1Signer: cfg.L1Signer(), batchInboxAddress: cfg.BatchInboxAddress, diff --git a/op-node/rollup/derive/plasma_data_source.go b/op-node/rollup/derive/plasma_data_source.go index d5eb552beb49..c1b5121128bf 100644 --- a/op-node/rollup/derive/plasma_data_source.go +++ b/op-node/rollup/derive/plasma_data_source.go @@ -16,13 +16,13 @@ type PlasmaDataSource struct { log log.Logger src DataIter fetcher PlasmaInputFetcher - l1 L1TransactionFetcher + l1 L1Fetcher id eth.BlockID // keep track of a pending commitment so we can keep trying to fetch the input. comm plasma.Keccak256Commitment } -func NewPlasmaDataSource(log log.Logger, src DataIter, l1 L1TransactionFetcher, fetcher PlasmaInputFetcher, id eth.BlockID) *PlasmaDataSource { +func NewPlasmaDataSource(log log.Logger, src DataIter, l1 L1Fetcher, fetcher PlasmaInputFetcher, id eth.BlockID) *PlasmaDataSource { return &PlasmaDataSource{ log: log, src: src, diff --git a/op-plasma/dastate.go b/op-plasma/dastate.go index b36471d4db61..465eefe9ff9f 100644 --- a/op-plasma/dastate.go +++ b/op-plasma/dastate.go @@ -176,7 +176,7 @@ func (s *State) Prune(bn uint64) { } // only first element is the highest priority (lowest block number). // next highest priority is swapped to the first position after a Pop. - for s.comms[0].blockNumber < bn { + for s.comms.Len() > 0 && s.comms[0].blockNumber < bn { c := heap.Pop(&s.comms).(*Commitment) s.log.Debug("prune commitment", "expiresAt", c.expiresAt, "blockNumber", c.blockNumber) delete(s.commsByKey, string(c.key))