From 664ac744848d09d4d0255f18e4870c8597446db3 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Thu, 13 Mar 2025 13:12:57 +0100 Subject: [PATCH] core/filtermaps: rename noHistory field -> disabled --- core/filtermaps/filtermaps.go | 10 ++++++++-- core/filtermaps/indexer.go | 4 ++-- core/filtermaps/indexer_test.go | 2 +- core/filtermaps/matcher_backend.go | 2 +- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/core/filtermaps/filtermaps.go b/core/filtermaps/filtermaps.go index b2b9e8aa45..9ff2182cc2 100644 --- a/core/filtermaps/filtermaps.go +++ b/core/filtermaps/filtermaps.go @@ -45,14 +45,20 @@ const ( // FilterMaps is the in-memory representation of the log index structure that is // responsible for building and updating the index according to the canonical // chain. +// // Note that FilterMaps implements the same data structure as proposed in EIP-7745 // without the tree hashing and consensus changes: // https://eips.ethereum.org/EIPS/eip-7745 type FilterMaps struct { + // If disabled is set, log indexing is fully disabled. + // This is configured by the --history.logs.disable Geth flag. + // We chose to implement disabling this way because it requires less special + // case logic in eth/filters. + disabled bool + closeCh chan struct{} closeWg sync.WaitGroup history, unindexLimit uint64 - noHistory bool exportFileName string Params @@ -191,7 +197,7 @@ func NewFilterMaps(db ethdb.KeyValueStore, initView *ChainView, params Params, c finalBlockCh: make(chan uint64, 1), blockProcessingCh: make(chan bool, 1), history: config.History, - noHistory: config.Disabled, + disabled: config.Disabled, exportFileName: config.ExportFileName, Params: params, indexedRange: filterMapsRange{ diff --git a/core/filtermaps/indexer.go b/core/filtermaps/indexer.go index 4f96d4660b..54a3687648 100644 --- a/core/filtermaps/indexer.go +++ b/core/filtermaps/indexer.go @@ -34,7 +34,7 @@ const ( func (f *FilterMaps) indexerLoop() { defer f.closeWg.Done() - if f.noHistory { + if f.disabled { f.reset() return } @@ -109,7 +109,7 @@ func (f *FilterMaps) SetBlockProcessing(blockProcessing bool) { // WaitIdle blocks until the indexer is in an idle state while synced up to the // latest targetView. func (f *FilterMaps) WaitIdle() { - if f.noHistory { + if f.disabled { f.closeWg.Wait() return } diff --git a/core/filtermaps/indexer_test.go b/core/filtermaps/indexer_test.go index 6411e2f807..17ad765e04 100644 --- a/core/filtermaps/indexer_test.go +++ b/core/filtermaps/indexer_test.go @@ -418,7 +418,7 @@ func (tc *testChain) setHead(headNum int) { func (tc *testChain) setTargetHead() { head := tc.CurrentBlock() if tc.ts.fm != nil { - if !tc.ts.fm.noHistory { + if !tc.ts.fm.disabled { //tc.ts.fm.targetViewCh <- NewChainView(tc, head.Number.Uint64(), head.Hash()) tc.ts.fm.SetTargetView(NewChainView(tc, head.Number.Uint64(), head.Hash())) } diff --git a/core/filtermaps/matcher_backend.go b/core/filtermaps/matcher_backend.go index b2a294bf83..66f95f2145 100644 --- a/core/filtermaps/matcher_backend.go +++ b/core/filtermaps/matcher_backend.go @@ -155,7 +155,7 @@ func (fm *FilterMapsMatcherBackend) synced() { // range that has not been changed and has been consistent with all states of the // chain since the previous SyncLogIndex or the creation of the matcher backend. func (fm *FilterMapsMatcherBackend) SyncLogIndex(ctx context.Context) (SyncRange, error) { - if fm.f.noHistory { + if fm.f.disabled { return SyncRange{HeadNumber: fm.f.targetView.headNumber}, nil }