Skip to content
Merged
Show file tree
Hide file tree
Changes from 75 commits
Commits
Show all changes
477 commits
Select commit Hold shift + click to select a range
1ce0b71
Adjust `OnReceiptsInserted` logging
alexb5dh Aug 25, 2025
5e74181
Naming
alexb5dh Aug 26, 2025
034e452
Normalize block number formatting
alexb5dh Aug 26, 2025
cd8468e
Build fix
alexb5dh Aug 26, 2025
da6afd0
Code cleanup
alexb5dh Aug 26, 2025
0631693
Use ancient receipts barrier for backwards sync target & include targ…
alexb5dh Aug 26, 2025
fedcda2
Adjust logging and waiting times
alexb5dh Aug 26, 2025
fa37e02
Fresh start fix
alexb5dh Aug 26, 2025
a3ef48d
Adjust min target block calculation
alexb5dh Aug 26, 2025
471e1e4
Fix repeated completion logging
alexb5dh Aug 26, 2025
acd75e0
Merge remote-tracking branch 'origin/master' into feature/log-index-2
alexb5dh Aug 28, 2025
2a9fe01
Temporary more logging again
alexb5dh Aug 28, 2025
c699c69
Try recover receipts
alexb5dh Aug 29, 2025
e4e89ea
Optimize processing of no-tx blocks
alexb5dh Sep 2, 2025
c722af7
Fir out-of-range error
alexb5dh Sep 2, 2025
c7d0d38
Fix receipts deletion (#9231)
Marchhill Sep 2, 2025
065ea2e
`logIndex_blockNumbers` RPC
alexb5dh Sep 2, 2025
7a7d80e
Logging tweaks
alexb5dh Sep 2, 2025
9713c54
[WIP] Support for topic index
alexb5dh Sep 5, 2025
d118316
Remove key size dependencies
alexb5dh Sep 7, 2025
27eff95
Try compress key in both DBs
alexb5dh Sep 7, 2025
d825464
Separate merge operator per column family
alexb5dh Sep 8, 2025
0a3c1e8
Fixes
alexb5dh Sep 9, 2025
e995a76
Remove possible collisions as causing invalid merge order
alexb5dh Sep 9, 2025
c9c944e
More fixes
alexb5dh Sep 9, 2025
c2419d0
Constant db key postfix size & fixes
alexb5dh Sep 10, 2025
e4cc092
Screw this, use separate DB per topic index
alexb5dh Sep 14, 2025
9e36329
Get rid of generic iterator interface
alexb5dh Sep 16, 2025
4550629
Fixes for seeking, but getting block numbers is now much slower
alexb5dh Sep 16, 2025
1537c9b
Code cleanup
alexb5dh Sep 16, 2025
8607f25
Do not remove leading zeroes & revert seeking
alexb5dh Sep 16, 2025
db59f42
Fix filter matching
alexb5dh Sep 16, 2025
3b5901b
Tests fixes
alexb5dh Sep 17, 2025
92c5a7e
Move filter tests to separate class & code formatting
alexb5dh Sep 17, 2025
58a75f6
Support for concurrent forward/backward sync & tests
alexb5dh Sep 18, 2025
ba14b43
Fixes for concurrent sync & more aggresive test
alexb5dh Sep 19, 2025
dd8bfe3
Code cleanup
alexb5dh Sep 19, 2025
f721f45
Fix log index syncing blocking other tasks
alexb5dh Sep 19, 2025
84e8417
Refactor syncing for better concurrency
alexb5dh Sep 21, 2025
18a13d5
Increase receipts cache size to 1024
alexb5dh Sep 21, 2025
de552f7
Log receipts loading time
alexb5dh Sep 21, 2025
143360d
Adjust parallelism values
alexb5dh Sep 21, 2025
75fbde5
Track backward/forward syncing stats separately
alexb5dh Sep 22, 2025
f2437e6
Revert "Increase receipts cache size to 1024"
alexb5dh Sep 22, 2025
9b17096
Set DB version
alexb5dh Sep 23, 2025
daf6110
Option to delay compressor start
alexb5dh Sep 23, 2025
56a0cf0
Include index version and reset data if version is invalid
alexb5dh Sep 23, 2025
171bac5
Log index compaction RPC
alexb5dh Sep 23, 2025
3169513
todo
alexb5dh Sep 23, 2025
027989b
Merge remote-tracking branch 'origin/master' into feature/log-index-2
alexb5dh Sep 25, 2025
1a20215
Add missing service registration
alexb5dh Sep 25, 2025
d421990
Remove "waiting for block" trace logging
alexb5dh Sep 25, 2025
2040d05
Do start indexing before DB initialization
alexb5dh Sep 25, 2025
9adb3d5
Code cleanup
alexb5dh Sep 25, 2025
f9b6c61
Fix double DB initialization
alexb5dh Sep 25, 2025
746521f
Fix aggressive memory usage
alexb5dh Sep 25, 2025
86aa4f9
Stop on error
alexb5dh Sep 25, 2025
5a4a05f
todos
alexb5dh Sep 25, 2025
bf03643
Formatting
alexb5dh Sep 25, 2025
6295428
Configuration for log-index & support for disabling/resetting index v…
alexb5dh Sep 26, 2025
5770cc1
Updates to logIndex_status, include status, last-update-data, and las…
alexb5dh Sep 27, 2025
74db195
Replace last-update with `DateTimeOffset`
alexb5dh Sep 27, 2025
9d6fd50
Typo fix
alexb5dh Sep 28, 2025
7187e30
Syncing service small refactoring, fixes, and basic tests
alexb5dh Sep 28, 2025
ee1eb85
Fix repeated completion logging
alexb5dh Sep 28, 2025
b4005f9
Adjust default `SyncFetchBatchParallelism`
alexb5dh Sep 29, 2025
9d4c9f3
TurboPFor updates to match package version
alexb5dh Sep 29, 2025
cc39645
Build fix
alexb5dh Sep 30, 2025
98c11ad
Configurable compression algorithm, handle if unsupported
alexb5dh Sep 30, 2025
b4ce56f
Support for `IWriteBatch` clearing
alexb5dh Oct 1, 2025
69d545f
Remove `RequireCommitWriteBatch`
alexb5dh Oct 1, 2025
26a21ee
Throw if stopped
alexb5dh Oct 1, 2025
bdbe0bd
Simplify `GetDbSize`
alexb5dh Oct 1, 2025
c7e1edd
Prevent DB corruption in case of mid-sync error & tests
alexb5dh Oct 1, 2025
1ec8d01
Remove stopping on error for now
alexb5dh Oct 1, 2025
f85af54
Updated compression-algo-change tests
alexb5dh Oct 1, 2025
1530ad0
Formatting
alexb5dh Oct 1, 2025
7f7dfd0
Small logging fix
alexb5dh Oct 1, 2025
f3f631f
~Temporary log completion time
alexb5dh Oct 2, 2025
62ba82a
Configurable logging details
alexb5dh Oct 6, 2025
425eac7
Fix for invalid ranges concatenation
alexb5dh Oct 7, 2025
d340b29
Revert "~Temporary log completion time"
alexb5dh Oct 9, 2025
2573607
Additional check to prevent using block 0 as pivot
alexb5dh Oct 9, 2025
78a4e33
Flag to verify eth_getLogs responses from index
alexb5dh Oct 9, 2025
fdf6004
Merge remote-tracking branch 'origin/master' into feature/log-index-2
alexb5dh Oct 10, 2025
6eedec7
Build fix
alexb5dh Oct 10, 2025
593271f
Switch to nuget package for TurboPFor
alexb5dh Oct 10, 2025
ca9da0e
Parallelize `LogIndexStorageFilterTests`
alexb5dh Oct 10, 2025
550d5f4
Formatting
alexb5dh Oct 10, 2025
943d34c
Try fix `LogIndexServiceTests`
alexb5dh Oct 10, 2025
3324a3a
TurboPFor package update
alexb5dh Oct 10, 2025
b391fef
Fix immediate backward sync completion
alexb5dh Oct 12, 2025
bff4b6a
Tests for `LogFinder` index range calculation
alexb5dh Oct 12, 2025
e346359
Min number of blocks to use index
alexb5dh Oct 12, 2025
f59f330
PR cleanup
alexb5dh Oct 12, 2025
0600a3c
Better handle write attempt during stopping
alexb5dh Oct 13, 2025
38ee693
Temporary fix for missing Nuget dependency
alexb5dh Oct 13, 2025
7566f44
PR cleanup
alexb5dh Oct 13, 2025
d81f46c
Revert attempt to use `OneTimeTearDown`
alexb5dh Oct 13, 2025
abafc70
Optimize compressor memory usage
alexb5dh Oct 13, 2025
b00741a
Fail log index on background job error
alexb5dh Oct 14, 2025
28fb75b
Dependency fix
alexb5dh Oct 14, 2025
e889f76
Take in-progress into account when waiting for compression
alexb5dh Oct 14, 2025
4f22265
Use array pool for compression
alexb5dh Oct 14, 2025
cd4309f
Adjust background exception handling
alexb5dh Oct 14, 2025
c4a35d1
Adjust exception handling
alexb5dh Oct 14, 2025
7e946f0
Move registrations
alexb5dh Oct 14, 2025
b365cd9
Take sync direction from aggregation
alexb5dh Oct 14, 2025
9369a2d
Remove first-block-added notification
alexb5dh Oct 14, 2025
8c1885e
Remove testing methods
alexb5dh Oct 14, 2025
3069e24
Remove unused code & PR cleanup
alexb5dh Oct 14, 2025
df5ac22
Formatting
alexb5dh Oct 14, 2025
7b50fbf
PR cleanup
alexb5dh Oct 14, 2025
75fda9a
Namespace update
alexb5dh Oct 14, 2025
ace54be
PR cleanup
alexb5dh Oct 14, 2025
e33aedc
Builder code cleanup
alexb5dh Oct 14, 2025
9554df0
Config update
alexb5dh Oct 14, 2025
9f820dd
Remove RPC response verification
alexb5dh Oct 14, 2025
cf3cb10
PR cleanup
alexb5dh Oct 14, 2025
e61a68f
Merge remote-tracking branch 'origin/master' into feature/log-index-2
alexb5dh Oct 14, 2025
7354430
Tests fix
alexb5dh Oct 14, 2025
e2ce952
Disable index by default
alexb5dh Oct 14, 2025
edfca14
Tests fix
alexb5dh Oct 14, 2025
ceac0d0
Fix compaction being disabled
alexb5dh Oct 14, 2025
1ebfb2a
Increase compaction logging level
alexb5dh Oct 14, 2025
e6e8e96
Make compression optional
alexb5dh Oct 14, 2025
c7e4e46
Remove completed TODO
alexb5dh Oct 14, 2025
abb8a34
Logging updates
alexb5dh Oct 14, 2025
d2f7298
Return RPC response verification flag with proper checks
alexb5dh Oct 14, 2025
157d4e2
Build fix
alexb5dh Oct 14, 2025
2166fca
PR cleanup
alexb5dh Oct 14, 2025
8657f8c
Merge remote-tracking branch 'origin/master' into feature/log-index-2
alexb5dh Oct 15, 2025
c3aba75
Naming update to match existing signatures
alexb5dh Oct 15, 2025
574cb9f
Partial test run fix
alexb5dh Oct 15, 2025
a7580d8
Logging tweak
alexb5dh Oct 15, 2025
c35eadb
PR cleanup
alexb5dh Oct 15, 2025
590a5f2
PR cleanup
alexb5dh Oct 16, 2025
80bc469
Move Merge to separate interface
alexb5dh Oct 16, 2025
5e47352
PR feedback
alexb5dh Oct 16, 2025
e7e6514
Storage stability improvements & enable `OneTimeTearDown` in integrat…
alexb5dh Oct 17, 2025
e8fce7b
Receipts events renaming
alexb5dh Oct 17, 2025
163b888
PR feedback
alexb5dh Oct 17, 2025
545b2eb
Formatting
alexb5dh Oct 18, 2025
a83ce88
Code cleanup
alexb5dh Oct 18, 2025
a140e91
Code cleanup
alexb5dh Oct 18, 2025
2708b70
Try make storage disposing thread-safe
alexb5dh Oct 18, 2025
387dd6e
Do not throw from merge operator
alexb5dh Oct 18, 2025
c4b1e11
Disable `OneTimeTearDown` again
alexb5dh Oct 18, 2025
8c099bd
Fix missing DB config
alexb5dh Oct 18, 2025
3db8944
Fix disposing in case of error in ctor
alexb5dh Oct 18, 2025
0172ca4
Use sorted view instead of iterator
alexb5dh Oct 18, 2025
3af56f3
Do not publicly expose iterator
alexb5dh Oct 18, 2025
8253f0b
Code cleanup
alexb5dh Oct 18, 2025
0600885
Revert changes to DB config reading
alexb5dh Oct 18, 2025
c0f734a
PR feedback
alexb5dh Oct 19, 2025
32f8101
PR feedback
alexb5dh Oct 19, 2025
414d48c
PR feedback
alexb5dh Oct 20, 2025
2cf5769
Merge remote-tracking branch 'origin/master' into feature/log-index-2
alexb5dh Dec 25, 2025
ee22402
Build fix
alexb5dh Dec 25, 2025
8303576
Cherry-pick updates
alexb5dh Dec 25, 2025
89450de
Commit all columns via single batch, store metadata in separate table
alexb5dh Dec 26, 2025
3483635
Fix saving redundant data to range bound
alexb5dh Dec 26, 2025
23a9df3
DB config fix
alexb5dh Dec 26, 2025
a9fb07b
Code formatting
alexb5dh Dec 26, 2025
ee539b2
Tests fix
alexb5dh Dec 26, 2025
b6cb0a8
[WIP] block number enumerator (nested)
alexb5dh Dec 30, 2025
a841eaf
[WIP] Fixing enumerator
alexb5dh Jan 4, 2026
57f2d2b
[WIP] Fixing enumerator
alexb5dh Jan 4, 2026
720936f
Fixes, code cleanup & use array pool for enumerator value
alexb5dh Jan 5, 2026
2450e71
Code cleanup
alexb5dh Jan 5, 2026
e2e405d
Visitor tests cleanup
alexb5dh Jan 5, 2026
5b5741d
Formatting
alexb5dh Jan 5, 2026
6789e28
Simplify filter/expression updates
alexb5dh Jan 5, 2026
15a613e
Code cleanup
alexb5dh Jan 5, 2026
0b7f6ba
Merge remote-tracking branch 'origin/master' into feature/log-index-2
alexb5dh Jan 5, 2026
8651168
Build fix
alexb5dh Jan 5, 2026
a4bd00f
Merge remote-tracking branch 'origin/master' into feature/log-index-2
alexb5dh Jan 5, 2026
019c5d7
Tests fix
alexb5dh Jan 5, 2026
8fea961
Code cleanup
alexb5dh Jan 6, 2026
56f17a9
Merge remote-tracking branch 'origin/master' into feature/log-index-2
alexb5dh Jan 7, 2026
f7a85c4
Remove `AscListHelper` as not needed
alexb5dh Jan 8, 2026
5b72543
Inline `UnionEnumerator`, v1
alexb5dh Jan 8, 2026
86b66f0
Revert "Inline `UnionEnumerator`, v1"
alexb5dh Jan 8, 2026
89f7e0a
More merge operator tests
alexb5dh Jan 8, 2026
7418782
Code cleanup
alexb5dh Jan 8, 2026
f549245
Merge remote-tracking branch 'NethermindEth/master' into feature/log-…
alexb5dh Jan 8, 2026
2d6ba46
Update TurboPFor package
alexb5dh Jan 8, 2026
6f8fe0d
Simplify `LogFinder`
alexb5dh Jan 8, 2026
817a4e3
Build fix attempt
alexb5dh Jan 8, 2026
675dce9
Make `LogIndexFilterVisitor` enumerators internal
alexb5dh Jan 9, 2026
02855aa
Remove unused parameter
alexb5dh Jan 9, 2026
ae8b745
Merge remote-tracking branch 'origin/master' into feature/log-index-2
alexb5dh Jan 9, 2026
602d5ef
Code cleanup
alexb5dh Jan 10, 2026
c6f572d
Merge remote-tracking branch 'origin/master' into feature/log-index-2
alexb5dh Jan 11, 2026
6a91fa8
Formatting
alexb5dh Jan 11, 2026
20bf747
Spelling
alexb5dh Jan 11, 2026
d343392
Try make cspell happy
alexb5dh Jan 11, 2026
b23e2f8
Try make cspell happy
alexb5dh Jan 11, 2026
5cf7f30
Try make cspell happy
alexb5dh Jan 11, 2026
1965694
Try make cspell happy
alexb5dh Jan 11, 2026
001f4b0
PR fixes
alexb5dh Jan 14, 2026
be1d736
Merge remote-tracking branch 'origin/master' into feature/log-index-2
alexb5dh Jan 21, 2026
dd8744f
Test build fix
alexb5dh Jan 21, 2026
824b25d
PR fixes
alexb5dh Jan 30, 2026
f4c7fef
Merge remote-tracking branch 'origin/master' into feature/log-index-2
alexb5dh Jan 30, 2026
34ccfdf
Merge remote-tracking branch 'origin/master' into feature/log-index-2
alexb5dh Jan 31, 2026
daa4d84
Move log-index features to inherited `IndexedLogFinder`
alexb5dh Jan 31, 2026
6dc82ea
Simplify `filter_all_logs_iteratively` test
alexb5dh Feb 1, 2026
792c264
Formatting
alexb5dh Feb 1, 2026
1aac074
Simplify `StartLogIndex` step
alexb5dh Feb 1, 2026
74b6a46
Block numbers copying optimization (little-endian only)
alexb5dh Feb 1, 2026
1b74bc6
Merge remote-tracking branch 'origin/master' into feature/log-index-2
alexb5dh Feb 1, 2026
a952904
Test fix
alexb5dh Feb 1, 2026
35981eb
Detailed in-code docs
alexb5dh Feb 4, 2026
42ef2d2
Merge remote-tracking branch 'origin/master' into feature/log-index-2
alexb5dh Feb 4, 2026
6a51c48
Doc tweaks
alexb5dh Feb 4, 2026
f5fdd28
More doc tweaks
alexb5dh Feb 4, 2026
95f033a
PR cleanup
alexb5dh Feb 6, 2026
8cbb97d
Merge remote-tracking branch 'origin/master' into feature/log-index-2
alexb5dh Feb 6, 2026
4b3a179
Make `GetBlockReceipts` a bit more explicit
alexb5dh Feb 6, 2026
f139c67
Build fix
alexb5dh Feb 6, 2026
f6f314d
Spelling
alexb5dh Feb 6, 2026
0325b2b
minor refactors
LukaszRozmej Feb 5, 2026
2f7957a
more minor refactors
LukaszRozmej Feb 6, 2026
dfab30d
minor refactor of Compressor - add alternative lookup to avoid alloca…
LukaszRozmej Feb 6, 2026
918690f
simplifications in LogIndexStorage
LukaszRozmej Feb 6, 2026
ee66430
simplify semaphores
LukaszRozmej Feb 6, 2026
7dc941f
move to stackalloc in LogIndexStorage where possible
LukaszRozmej Feb 6, 2026
2235554
simplify merge operators to inline array
LukaszRozmej Feb 6, 2026
dd88dc1
correctly dispose ArrayPoolList in Merge tests
LukaszRozmej Feb 6, 2026
ff5d35e
more simple refactors
LukaszRozmej Feb 6, 2026
e49fb27
In LogIndexBuilder replace Dictionaries iwth Direction
LukaszRozmej Feb 6, 2026
bdb35f9
Simplify UnionEnumerator
LukaszRozmej Feb 6, 2026
f519cba
Removed linq from IndexedLogFinder
LukaszRozmej Feb 6, 2026
072c408
Merge branch 'master' into feature/log-index-2
LukaszRozmej Feb 6, 2026
a728ed3
Code cleanup
alexb5dh Feb 7, 2026
43468cd
Simplify DBs initialization
alexb5dh Feb 7, 2026
cd4cd19
Code cleanup
alexb5dh Feb 7, 2026
88c2c2c
PR feedback
alexb5dh Feb 7, 2026
352d31f
Code cleanup
alexb5dh Feb 7, 2026
6a2af05
Merge remote-tracking branch 'origin/master' into feature/log-index-2
alexb5dh Feb 7, 2026
a575a42
Remove `storage` parameter from `LogIndexEnumerator`
alexb5dh Feb 8, 2026
e939518
Add complex LogIndex integration tests (#10425)
LukaszRozmej Feb 9, 2026
39e0f35
Simplify Compactor concurrency with Channel<T> (#10424)
LukaszRozmej Feb 12, 2026
f30a30a
Merge remote-tracking branch 'origin/master' into feature/log-index-2
alexb5dh Feb 13, 2026
01c781e
[WIP] use `PruningConfig.PruningBoundary` as default reorg depth
alexb5dh Feb 14, 2026
30cb63c
Use `PruningConfig.PruningBoundary` as default reorg depth
alexb5dh Feb 14, 2026
38453fd
Take `PruningBoundary` before it's overwritten via `SnapServingMaxDepth`
alexb5dh Feb 14, 2026
f3c51ce
Revert test change
alexb5dh Feb 14, 2026
6124118
Flaky test fix
alexb5dh Feb 14, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Nethermind/Nethermind.Api/IApiWithStores.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Nethermind.Blockchain.Receipts;
using Nethermind.Consensus;
using Nethermind.Crypto;
using Nethermind.Db;
using Nethermind.Db.Blooms;
using Nethermind.Facade.Find;
using Nethermind.State.Repositories;
Expand All @@ -21,6 +22,7 @@ public interface IApiWithStores : IBasicApi
IBloomStorage? BloomStorage { get; set; }
IChainLevelInfoRepository? ChainLevelInfoRepository { get; set; }
ILogFinder? LogFinder { get; set; }
ILogIndexStorage? LogIndexStorage { get; set; }
ISigner? EngineSigner { get; set; }
ISignerStore? EngineSignerStore { get; set; }
IProtectedPrivateKey? NodeKey { get; set; }
Expand Down
1 change: 1 addition & 0 deletions src/Nethermind/Nethermind.Api/NethermindApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ public IBlockchainBridge CreateBlockchainBridge()
public IKeyStore? KeyStore { get; set; }
public IPasswordProvider? PasswordProvider { get; set; }
public ILogFinder? LogFinder { get; set; }
public ILogIndexStorage? LogIndexStorage { get; set; }
public ILogManager LogManager => _dependencies.LogManager;
public IMessageSerializationService MessageSerializationService { get; } = new MessageSerializationService();
public IGossipPolicy GossipPolicy { get; set; } = Policy.FullGossip;
Expand Down
20 changes: 13 additions & 7 deletions src/Nethermind/Nethermind.Blockchain.Test/Find/LogFinderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class LogFinderTests
private IBloomStorage _bloomStorage = null!;
private IReceiptsRecovery _receiptsRecovery = null!;
private Block _headTestBlock = null!;
private ILogIndexStorage _logIndexStorage = null!;

[SetUp]
public void SetUp()
Expand All @@ -43,7 +44,11 @@ public void SetUp()
}

[TearDown]
public void TearDown() => _bloomStorage?.Dispose();
public async Task TearDown()
{
_bloomStorage?.Dispose();
await _logIndexStorage.DisposeAsync();
}

private void SetUp(bool allowReceiptIterator)
{
Expand All @@ -57,7 +62,8 @@ private void SetUp(bool allowReceiptIterator)
_blockTree = _rawBlockTree;
_bloomStorage = new BloomStorage(new BloomConfig(), new MemDb(), new InMemoryDictionaryFileStoreFactory());
_receiptsRecovery = Substitute.For<IReceiptsRecovery>();
_logFinder = new LogFinder(_blockTree, _receiptStorage, _receiptStorage, _bloomStorage, LimboLogs.Instance, _receiptsRecovery);
_logIndexStorage = Substitute.For<ILogIndexStorage>();
_logFinder = new LogFinder(_blockTree, _receiptStorage, _receiptStorage, _bloomStorage, LimboLogs.Instance, _receiptsRecovery, _logIndexStorage);
}

private void SetupHeadWithNoTransaction()
Expand Down Expand Up @@ -145,7 +151,7 @@ public void throw_exception_when_receipts_are_missing([ValueSource(nameof(WithBl
{
StoreTreeBlooms(withBloomDb);
_receiptStorage = NullReceiptStorage.Instance;
_logFinder = new LogFinder(_blockTree, _receiptStorage, _receiptStorage, _bloomStorage, LimboLogs.Instance, _receiptsRecovery);
_logFinder = new LogFinder(_blockTree, _receiptStorage, _receiptStorage, _bloomStorage, LimboLogs.Instance, _receiptsRecovery, _logIndexStorage);

var logFilter = AllBlockFilter().Build();

Expand All @@ -158,7 +164,7 @@ public void throw_exception_when_receipts_are_missing([ValueSource(nameof(WithBl
public void when_receipts_are_missing_and_header_has_no_receipt_root_do_not_throw_exception_()
{
_receiptStorage = NullReceiptStorage.Instance;
_logFinder = new LogFinder(_blockTree, _receiptStorage, _receiptStorage, _bloomStorage, LimboLogs.Instance, _receiptsRecovery);
_logFinder = new LogFinder(_blockTree, _receiptStorage, _receiptStorage, _bloomStorage, LimboLogs.Instance, _receiptsRecovery, _logIndexStorage);

SetupHeadWithNoTransaction();

Expand All @@ -174,7 +180,7 @@ public void filter_all_logs_should_throw_when_to_block_is_not_found([ValueSource
{
StoreTreeBlooms(withBloomDb);
var blockFinder = Substitute.For<IBlockFinder>();
_logFinder = new LogFinder(blockFinder, _receiptStorage, _receiptStorage, _bloomStorage, LimboLogs.Instance, _receiptsRecovery);
_logFinder = new LogFinder(blockFinder, _receiptStorage, _receiptStorage, _bloomStorage, LimboLogs.Instance, _receiptsRecovery, _logIndexStorage);
var logFilter = AllBlockFilter().Build();
var action = new Func<IEnumerable<FilterLog>>(() => _logFinder.FindLogs(logFilter));
action.Should().Throw<ResourceNotFoundException>();
Expand Down Expand Up @@ -277,7 +283,7 @@ public void filter_by_blocks(LogFilter filter, int expectedCount, bool withBloom
public void filter_by_blocks_with_limit([ValueSource(nameof(WithBloomValues))] bool withBloomDb)
{
StoreTreeBlooms(withBloomDb);
_logFinder = new LogFinder(_blockTree, _receiptStorage, _receiptStorage, _bloomStorage, LimboLogs.Instance, _receiptsRecovery, 2);
_logFinder = new LogFinder(_blockTree, _receiptStorage, _receiptStorage, _bloomStorage, LimboLogs.Instance, _receiptsRecovery, _logIndexStorage);
var filter = FilterBuilder.New().FromLatestBlock().ToLatestBlock().Build();
var logs = _logFinder.FindLogs(filter).ToArray();

Expand Down Expand Up @@ -323,7 +329,7 @@ public async Task Throw_log_finder_operation_canceled_after_given_timeout([Value
CancellationToken cancellationToken = cancellationTokenSource.Token;

StoreTreeBlooms(true);
_logFinder = new LogFinder(_blockTree, _receiptStorage, _receiptStorage, _bloomStorage, LimboLogs.Instance, _receiptsRecovery);
_logFinder = new LogFinder(_blockTree, _receiptStorage, _receiptStorage, _bloomStorage, LimboLogs.Instance, _receiptsRecovery, _logIndexStorage);
var logFilter = AllBlockFilter().Build();
var logs = _logFinder.FindLogs(logFilter, cancellationToken);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ public interface IReceiptConfig : IConfig
[ConfigItem(Description = "Whether to migrate the receipts database to the new schema.", DefaultValue = "false")]
bool ReceiptsMigration { get; set; }

[ConfigItem(Description = "The degree of parallelism during receipt migration.", DefaultValue = "0", HiddenFromDocs = true)]
int ReceiptsMigrationDegreeOfParallelism { get; set; }
[ConfigItem(Description = "The degree of IO operations parallelism during receipts migration.", DefaultValue = "32", HiddenFromDocs = true)]
int ReceiptsMigrationIOParallelism { get; set; }

[ConfigItem(Description = "Force receipt recovery if its not able to detect it.", DefaultValue = "false", HiddenFromDocs = true)]
bool ForceReceiptsMigration { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class ReceiptConfig : IReceiptConfig
{
public bool StoreReceipts { get; set; } = true;
public bool ReceiptsMigration { get; set; } = false;
public int ReceiptsMigrationDegreeOfParallelism { get; set; } = 0;
public int ReceiptsMigrationIOParallelism { get; set; } = 16; // TODO: add validation
public bool ForceReceiptsMigration { get; set; } = false;
public bool CompactReceiptStore { get; set; } = true;
public bool CompactTxIndex { get; set; } = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,8 @@ protected virtual async Task<TestBlockchain> Build(ISpecProvider? specProvider =

BloomStorage bloomStorage = new(new BloomConfig(), new MemDb(), new InMemoryDictionaryFileStoreFactory());
ReceiptsRecovery receiptsRecovery = new(new EthereumEcdsa(SpecProvider.ChainId), SpecProvider);
LogFinder = new LogFinder(BlockTree, ReceiptStorage, ReceiptStorage, bloomStorage, LimboLogs.Instance, receiptsRecovery);
LogIndexStorage logIndexStorage = new(DbProvider.LogIndexDb, LogManager.GetClassLogger<LogIndexStorage>(), "test-db", ioParallelism: 8);
LogFinder = new LogFinder(BlockTree, ReceiptStorage, ReceiptStorage, bloomStorage, LimboLogs.Instance, receiptsRecovery, logIndexStorage);
BlockProcessor = CreateBlockProcessor(WorldStateManager.GlobalWorldState);

BlockchainProcessor chainProcessor = new(BlockTree, BlockProcessor, BlockPreprocessorStep, StateReader, LogManager, Consensus.Processing.BlockchainProcessor.Options.Default);
Expand Down
18 changes: 18 additions & 0 deletions src/Nethermind/Nethermind.Core/Collections/CollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: LGPL-3.0-only

using System;
using System.Buffers;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq.Expressions;
Expand Down Expand Up @@ -87,6 +88,23 @@ public static bool NoResizeClear<TKey, TValue>(this ConcurrentDictionary<TKey, T
return true;
}

public static TValue GetOrAdd<TKey, TValue>(this Dictionary<TKey, TValue> dictionary, TKey key, Func<TKey, TValue> factory)
where TKey : notnull
{
if (dictionary.TryGetValue(key, out TValue? value))
{
return value;
}
else
{
value = factory(key);
dictionary.Add(key, value);
return value;
}
}

public static Span<T> RentSpan<T>(this ArrayPool<T> pool, int length) => pool.Rent(length).AsSpan(length);

private static class ClearCache<TKey, TValue> where TKey : notnull
{
public static readonly Action<ConcurrentDictionary<TKey, TValue>> Clear = CreateNoResizeClearExpression();
Expand Down
10 changes: 7 additions & 3 deletions src/Nethermind/Nethermind.Core/Extensions/IntExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,14 @@ public static UInt256 GWei(this int @this)
return (uint)@this * Unit.GWei;
}

public static byte[] ToByteArray(this int value)
public static byte[] ToLittleEndianByteArray(this int value)
{
byte[] bytes = new byte[sizeof(int)];
BinaryPrimitives.WriteInt32BigEndian(bytes, value);
byte[] bytes = BitConverter.GetBytes(value);
if (!BitConverter.IsLittleEndian)
{
Array.Reverse(bytes);
}

return bytes;
}

Expand Down
9 changes: 9 additions & 0 deletions src/Nethermind/Nethermind.Core/Extensions/TaskExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,13 @@ public static bool HasTimeoutException(this Task? task)
return exception.InnerException is TimeoutException
|| exception.InnerExceptions.Any(static ex => ex is TimeoutException);
}

public static Task IgnoreException(this Task task)
{
return task.ContinueWith(_ => { });
}

public static T WaitResult<T>(this ValueTask<T> task) => task.Preserve().GetAwaiter().GetResult();

public static void Wait(this ValueTask task) => task.Preserve().GetAwaiter().GetResult();
}
22 changes: 21 additions & 1 deletion src/Nethermind/Nethermind.Db.Rocks/ColumnDb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ public void PutSpan(ReadOnlySpan<byte> key, ReadOnlySpan<byte> value, WriteFlags
_mainDb.SetWithColumnFamily(key, _columnFamily, value, writeFlags);
}

public void Merge(ReadOnlySpan<byte> key, ReadOnlySpan<byte> value, WriteFlags writeFlags = WriteFlags.None)
{
_mainDb.MergeWithColumnFamily(key, _columnFamily, value, writeFlags);
}

public KeyValuePair<byte[], byte[]?>[] this[byte[][] keys] =>
_rocksDb.MultiGet(keys, keys.Select(k => _columnFamily).ToArray());

Expand Down Expand Up @@ -115,6 +120,11 @@ public void PutSpan(ReadOnlySpan<byte> key, ReadOnlySpan<byte> value, WriteFlags
{
_underlyingWriteBatch.Set(key, value, _columnDb._columnFamily, flags);
}

public void Merge(ReadOnlySpan<byte> key, ReadOnlySpan<byte> value, WriteFlags flags = WriteFlags.None)
{
_underlyingWriteBatch.Merge(key, value, _columnDb._columnFamily, flags);
}
}

public void Remove(ReadOnlySpan<byte> key)
Expand All @@ -130,7 +140,7 @@ public bool KeyExists(ReadOnlySpan<byte> key)

public void Flush(bool onlyWal)
{
_mainDb.Flush(onlyWal);
_mainDb.FlushWithColumnFamily(_columnFamily);
Comment thread
alexb5dh marked this conversation as resolved.
Outdated
}

public void Compact()
Expand All @@ -151,4 +161,14 @@ public void DangerousReleaseMemory(in ReadOnlySpan<byte> span)
{
_mainDb.DangerousReleaseMemory(span);
}

public IIterator<byte[], byte[]> GetIterator(bool isTailing = false)
{
return _mainDb.GetIterator(isTailing, _columnFamily);
}

public IIterator<byte[], byte[]> GetIterator(ref IteratorOptions options)
{
return _mainDb.GetIterator(ref options, _columnFamily);
}
}
11 changes: 11 additions & 0 deletions src/Nethermind/Nethermind.Db.Rocks/Config/DbConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -239,4 +239,15 @@ public class DbConfig : IDbConfig
public string L1OriginDbRocksDbOptions { get; set; } = "";

public string? L1OriginDbAdditionalRocksDbOptions { get; set; }

// TODO: cleanup & optimize settings
public string? LogIndexStorageDbRocksDbOptions { get; set; } =
"merge_operator=LogIndexStorage.Merge;";
public string? LogIndexStorageDbAdditionalRocksDbOptions { get; set; } = "";
public string? LogIndexStorageDefaultDbRocksDbOptions { get; set; } = "";
public string? LogIndexStorageDefaultDbAdditionalRocksDbOptions { get; set; } = "";
public string? LogIndexStorageAddressesDbRocksDbOptions { get; set; } = "";
public string? LogIndexStorageAddressesDbAdditionalRocksDbOptions { get; set; } = "";
public string? LogIndexStorageTopicsDbRocksDbOptions { get; set; } = "";
public string? LogIndexStorageTopicsDbAdditionalRocksDbOptions { get; set; } = "";
}
9 changes: 9 additions & 0 deletions src/Nethermind/Nethermind.Db.Rocks/Config/IDbConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,13 @@ public interface IDbConfig : IConfig

string L1OriginDbRocksDbOptions { get; set; }
string? L1OriginDbAdditionalRocksDbOptions { get; set; }

string? LogIndexStorageDbRocksDbOptions { get; set; }
string? LogIndexStorageDbAdditionalRocksDbOptions { get; set; }
string? LogIndexStorageDefaultDbRocksDbOptions { get; set; }
string? LogIndexStorageDefaultDbAdditionalRocksDbOptions { get; set; }
string? LogIndexStorageAddressesDbRocksDbOptions { get; set; }
string? LogIndexStorageAddressesDbAdditionalRocksDbOptions { get; set; }
string? LogIndexStorageTopicsDbRocksDbOptions { get; set; }
string? LogIndexStorageTopicsDbAdditionalRocksDbOptions { get; set; }
}
13 changes: 9 additions & 4 deletions src/Nethermind/Nethermind.Db.Rocks/Config/PerTableDbConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ private void EnsureConfigIsAvailable(string propertyName)
foreach (var prefix in _prefixes)
{
string prefixed = string.Concat(prefix, propertyName);
if (type.GetProperty(prefixed, BindingFlags.Public | BindingFlags.Instance) is null)
if (GetPrefixedConfigProperty(type, prefixed) is null)
{
throw new InvalidConfigurationException($"Configuration {propertyName} not available with prefix {prefix}. Add {prefix}{propertyName} to {nameof(IDbConfig)}.", -1);
}
Expand Down Expand Up @@ -92,13 +92,14 @@ private static string ReadRocksdbOptions(IDbConfig dbConfig, string propertyName
Type type = dbConfig.GetType();
PropertyInfo? propertyInfo;

// TODO: clarify if this can be case-insensitive
string val = (string)type.GetProperty(propertyName, BindingFlags.Public | BindingFlags.Instance)!.GetValue(dbConfig)!;

foreach (var prefix in prefixes)
{
string prefixed = string.Concat(prefix, propertyName);

propertyInfo = type.GetProperty(prefixed, BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance);
propertyInfo = GetPrefixedConfigProperty(type, prefixed);
if (propertyInfo is not null)
{
string? valObj = (string?)propertyInfo.GetValue(dbConfig);
Expand All @@ -124,7 +125,7 @@ private static string ReadRocksdbOptions(IDbConfig dbConfig, string propertyName
{
string prefixed = string.Concat(prefix, propertyName);

propertyInfo = type.GetProperty(prefixed, BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance);
propertyInfo = GetPrefixedConfigProperty(type, prefixed);
if (propertyInfo is not null)
{
if (propertyInfo.PropertyType.CanBeAssignedNull())
Expand All @@ -149,7 +150,7 @@ private static string ReadRocksdbOptions(IDbConfig dbConfig, string propertyName
}

// Use generic one even if its available
propertyInfo = type.GetProperty(propertyName, BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance);
propertyInfo = GetPrefixedConfigProperty(type, propertyName);
return (T?)propertyInfo?.GetValue(dbConfig);
}
catch (Exception e)
Expand All @@ -158,4 +159,8 @@ private static string ReadRocksdbOptions(IDbConfig dbConfig, string propertyName
}
}

private static PropertyInfo? GetPrefixedConfigProperty(Type type, string name)
{
return type.GetProperty(name, BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance);
}
}
Loading