Skip to content

Commit

Permalink
remove preFetchReceiptsEnable logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Welkin committed Sep 21, 2023
1 parent e5c92ff commit db5d4ed
Show file tree
Hide file tree
Showing 8 changed files with 1 addition and 64 deletions.
2 changes: 0 additions & 2 deletions op-node/rollup/derive/attributes.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ type L1ReceiptsFetcher interface {
InfoByHash(ctx context.Context, hash common.Hash) (eth.BlockInfo, error)
InfoAndTxsByHash(ctx context.Context, hash common.Hash) (eth.BlockInfo, types.Transactions, error)
FetchReceipts(ctx context.Context, blockHash common.Hash) (eth.BlockInfo, types.Receipts, error)
EnablePreFetchReceipts()
DisablePreFetchReceipts()
GoOrUpdatePreFetchReceipts(ctx context.Context, l1StartBlock uint64) error
}

Expand Down
8 changes: 0 additions & 8 deletions op-node/rollup/derive/engine_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -766,11 +766,3 @@ func (eq *EngineQueue) UnsafeL2SyncTarget() eth.L2BlockRef {
return eth.L2BlockRef{}
}
}

func (eq *EngineQueue) EnablePreFetchReceipts() {
eq.l1Fetcher.EnablePreFetchReceipts()
}

func (eq *EngineQueue) DisablePreFetchReceipts() {
eq.l1Fetcher.DisablePreFetchReceipts()
}
10 changes: 0 additions & 10 deletions op-node/rollup/derive/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ type EngineQueueStage interface {
AddUnsafePayload(payload *eth.ExecutionPayload)
UnsafeL2SyncTarget() eth.L2BlockRef
Step(context.Context) error
EnablePreFetchReceipts()
DisablePreFetchReceipts()
}

// DerivationPipeline is updated with new L1 data, and the Step() function can be iterated on to keep the L2 Engine in sync.
Expand Down Expand Up @@ -207,11 +205,3 @@ func (dp *DerivationPipeline) Step(ctx context.Context) error {
return nil
}
}

func (dp *DerivationPipeline) EnablePreFetchReceipts() {
dp.eng.EnablePreFetchReceipts()
}

func (dp *DerivationPipeline) DisablePreFetchReceipts() {
dp.eng.DisablePreFetchReceipts()
}
6 changes: 0 additions & 6 deletions op-node/rollup/driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ type DerivationPipeline interface {
UnsafeL2Head() eth.L2BlockRef
Origin() eth.L1BlockRef
EngineReady() bool
EnablePreFetchReceipts()
DisablePreFetchReceipts()
}

type L1StateIface interface {
Expand Down Expand Up @@ -117,10 +115,6 @@ func NewDriver(driverCfg *Config, cfg *rollup.Config, l2 L2Chain, l1 L1Chain, al
meteredEngine := NewMeteredEngine(cfg, engine, metrics, log)
sequencer := NewSequencer(log, cfg, meteredEngine, attrBuilder, findL1Origin, metrics)

if driverCfg.SequencerEnabled && !driverCfg.SequencerStopped {
derivationPipeline.EnablePreFetchReceipts()
}

return &Driver{
l1State: l1State,
derivation: derivationPipeline,
Expand Down
10 changes: 0 additions & 10 deletions op-node/rollup/driver/metered_l1fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,6 @@ func (m *MeteredL1Fetcher) recordTime(method string) func() {
}
}

func (m *MeteredL1Fetcher) EnablePreFetchReceipts() {
defer m.recordTime("EnablePreFetchReceipts")()
m.inner.EnablePreFetchReceipts()
}

func (m *MeteredL1Fetcher) DisablePreFetchReceipts() {
defer m.recordTime("DisablePreFetchReceipts")()
m.inner.DisablePreFetchReceipts()
}

func (m *MeteredL1Fetcher) GoOrUpdatePreFetchReceipts(ctx context.Context, l1StartBlock uint64) error {
defer m.recordTime("GoOrUpdatePreFetchReceipts")()
return m.inner.GoOrUpdatePreFetchReceipts(ctx, l1StartBlock)
Expand Down
2 changes: 0 additions & 2 deletions op-node/rollup/driver/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,6 @@ func (s *Driver) eventLoop() {
} else {
s.log.Info("Sequencer has been started")
s.driverConfig.SequencerStopped = false
s.derivation.EnablePreFetchReceipts()
close(resp.err)
planSequencerAction() // resume sequencing
}
Expand All @@ -346,7 +345,6 @@ func (s *Driver) eventLoop() {
} else {
s.log.Warn("Sequencer has been stopped")
s.driverConfig.SequencerStopped = true
s.derivation.DisablePreFetchReceipts()
respCh <- hashAndError{hash: s.derivation.UnsafeL2Head().Hash}
}
case <-s.done:
Expand Down
19 changes: 1 addition & 18 deletions op-node/sources/l1_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ type L1Client struct {
preFetchReceiptsOnce sync.Once
//start block for pre-fetch receipts
preFetchReceiptsStartBlockChan chan uint64
//pre-fetch receipts enable(We don't need atomic, because the bool here does not need strict visibility guarantees)
preFetchReceiptsEnable bool
}

// NewL1Client wraps a RPC with bindings to fetch L1 data, while logging errors, tracking metrics (optional), and caching.
Expand Down Expand Up @@ -132,11 +130,6 @@ func (s *L1Client) GoOrUpdatePreFetchReceipts(ctx context.Context, l1Start uint6
go func() {
var currentL1Block uint64
for {
if !s.preFetchReceiptsEnable {
s.log.Debug("pre fetch receipts is disabled")
time.Sleep(1 * time.Second)
continue
}
select {
case currentL1Block = <-s.preFetchReceiptsStartBlockChan:
s.log.Debug("pre-fetching receipts currentL1Block changed", "block", currentL1Block)
Expand All @@ -159,16 +152,6 @@ func (s *L1Client) GoOrUpdatePreFetchReceipts(ctx context.Context, l1Start uint6
}
}()
})
if s.preFetchReceiptsEnable {
s.preFetchReceiptsStartBlockChan <- l1Start
}
s.preFetchReceiptsStartBlockChan <- l1Start
return nil
}

func (s *L1Client) EnablePreFetchReceipts() {
s.preFetchReceiptsEnable = true
}

func (s *L1Client) DisablePreFetchReceipts() {
s.preFetchReceiptsEnable = false
}
8 changes: 0 additions & 8 deletions op-node/testutils/mock_l1.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,6 @@ func (m *MockL1Source) ExpectL1BlockRefByHash(hash common.Hash, ref eth.L1BlockR
m.Mock.On("L1BlockRefByHash", hash).Once().Return(ref, &err)
}

func (m *MockL1Source) EnablePreFetchReceipts() {
m.Mock.On("EnablePreFetchReceipts")
}

func (m *MockL1Source) DisablePreFetchReceipts() {
m.Mock.On("DisablePreFetchReceipts")
}

func (m *MockL1Source) GoOrUpdatePreFetchReceipts(ctx context.Context, l1StartBlock uint64) error {
out := m.Mock.MethodCalled("GoOrUpdatePreFetchReceipts", ctx, l1StartBlock)
return *out[0].(*error)
Expand Down

0 comments on commit db5d4ed

Please sign in to comment.