Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate FastBlock Flag #6792

Merged
merged 6 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ public interface ISyncConfig : IConfig
[ConfigItem(Description = "In Fast sync mode, the min height threshold limit up to which the Full sync, if already on, stays on when the chain is behind the network head. If the limit is exceeded, it switches back to Fast sync. For regular usage scenarios, setting this value lower than 32 is not recommended as this can cause issues with chain reorgs. Note that the last 2 blocks are always processed in Full sync, so setting it lower than 2 has no effect.", DefaultValue = "8192")]
long? FastSyncCatchUpHeightDelta { get; set; }

[ConfigItem(Description = "Whether to first download blocks from the provided pivot number downwards in the Fast sync mode. This allows for parallelization of requests with many sync peers and with no need to worry about syncing a valid branch (syncing downwards to 0). You need to provide the pivot block number, hash, and total difficulty from a trusted source (e.g., Etherscan) and confirm with other sources if you want to change it.", DefaultValue = "false")]
[Obsolete]
[ConfigItem(Description = "Deprecated.", DefaultValue = "false", HiddenFromDocs = true)]
bool FastBlocks { get; set; }

[ConfigItem(Description = "Whether to make smaller requests, in Fast Blocks mode, to avoid Geth from disconnecting. On the Geth-heavy networks (e.g., Mainnet), it's a desired behavior while on Nethermind- or OpenEthereum-heavy networks (Goerli, Aura), it slows down the sync by a factor of ~4.", DefaultValue = "true")]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited
// SPDX-License-Identifier: LGPL-3.0-only

using Nethermind.Config;
using Nethermind.Db;

Expand All @@ -13,10 +12,9 @@ public class SyncConfig : ISyncConfig
private bool _fastSync;

public static ISyncConfig Default { get; } = new SyncConfig();
public static ISyncConfig WithFullSyncOnly { get; } = new SyncConfig { FastSync = false, FastBlocks = false };
public static ISyncConfig WithFullSyncOnly { get; } = new SyncConfig { FastSync = false };
public static ISyncConfig WithFastSync { get; } = new SyncConfig { FastSync = true };
public static ISyncConfig WithFastBlocks { get; } = new SyncConfig { FastSync = true, FastBlocks = true };
public static ISyncConfig WithEth2Merge { get; } = new SyncConfig { FastSync = false, FastBlocks = false, BlockGossipEnabled = false };
public static ISyncConfig WithEth2Merge { get; } = new SyncConfig { FastSync = false, BlockGossipEnabled = false };

public bool NetworkingEnabled { get; set; } = true;

Expand All @@ -27,7 +25,7 @@ public bool SynchronizationEnabled
}

public long? FastSyncCatchUpHeightDelta { get; set; } = 8192;
public bool FastBlocks { get; set; }
bool ISyncConfig.FastBlocks { get; set; }
public bool UseGethLimitsInFastBlocks { get; set; } = true;
public bool FastSync { get => _fastSync || SnapSync; set => _fastSync = value; }
public bool DownloadHeadersInFastSync { get; set; } = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ public void IsSyncing_ReturnsFalseOnFastSyncWithoutPivot(long bestHeader, long c
{
FastSync = true,
SnapSync = true,
FastBlocks = true,
PivotNumber = "0", // Equivalent to not having a pivot
};
EthSyncingInfo ethSyncingInfo = new(blockTree, receiptStorage, syncConfig,
Expand Down
2 changes: 1 addition & 1 deletion src/Nethermind/Nethermind.Init/MemoryHintMan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ private void AssignTxPoolMemory(ITxPoolConfig txPoolConfig)

private void AssignFastBlocksMemory(ISyncConfig syncConfig)
{
if (syncConfig.FastBlocks)
if (syncConfig.FastSync)
{
if (!syncConfig.DownloadBodiesInFastSync && !syncConfig.DownloadReceiptsInFastSync)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,6 @@ public async Task Blocks_before_pivots_should_not_be_added_if_node_has_never_bee
ISyncConfig syncConfig = new SyncConfig
{
FastSync = true,
FastBlocks = true,
PivotNumber = syncedBlockTree.Head?.Number.ToString() ?? "",
PivotHash = syncedBlockTree.HeadHash?.ToString() ?? "",
PivotTotalDifficulty = syncedBlockTree.Head?.TotalDifficulty?.ToString() ?? ""
Expand All @@ -865,7 +864,6 @@ public async Task Blocks_before_pivots_should_not_be_added_if_node_has_been_sync
ISyncConfig syncConfig = new SyncConfig
{
FastSync = true,
FastBlocks = true,
PivotNumber = syncedBlockTree.Head?.Number.ToString() ?? "",
PivotHash = syncedBlockTree.HeadHash?.ToString() ?? "",
PivotTotalDifficulty = syncedBlockTree.Head?.TotalDifficulty?.ToString() ?? ""
Expand All @@ -891,7 +889,6 @@ public async Task Maintain_correct_pointers_for_beacon_sync_in_fast_sync()
ISyncConfig syncConfig = new SyncConfig
{
FastSync = true,
FastBlocks = true,
PivotNumber = syncedBlockTree.Head?.Number.ToString() ?? "",
PivotHash = syncedBlockTree.HeadHash?.ToString() ?? "",
PivotTotalDifficulty = syncedBlockTree.Head?.TotalDifficulty?.ToString() ?? ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ public async Task Can_keep_returning_nulls_after_all_batches_were_prepared()
SyncConfig = new SyncConfig
{
FastSync = true,
FastBlocks = true,
PivotNumber = "1000",
PivotHash = Keccak.Zero.ToString(),
PivotTotalDifficulty = "1000"
Expand Down Expand Up @@ -184,7 +183,6 @@ public async Task Finishes_when_all_downloaded()
ISyncConfig syncConfig = new SyncConfig
{
FastSync = true,
FastBlocks = true,
PivotNumber = "1000",
PivotHash = Keccak.Zero.ToString(),
PivotTotalDifficulty = "1000"
Expand Down Expand Up @@ -221,7 +219,6 @@ public void Feed_able_to_sync_when_new_pivot_is_set()
ISyncConfig syncConfig = new SyncConfig
{
FastSync = true,
FastBlocks = true,
PivotNumber = "500",
PivotHash = Keccak.Zero.ToString(),
PivotTotalDifficulty = "1000000" // default difficulty in block tree builder
Expand Down Expand Up @@ -308,7 +305,6 @@ public async Task When_pivot_changed_during_header_sync_after_chain_merged__do_n
ISyncConfig syncConfig = new SyncConfig
{
FastSync = true,
FastBlocks = true,
PivotNumber = "0",
PivotHash = Keccak.Zero.ToString(),
PivotTotalDifficulty = "0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public void Setup()
_syncConfig = new SyncConfig
{
FastSync = true,
FastBlocks = true,
PivotNumber = "1000",
PivotHash = Keccak.Zero.ToString(),
PivotTotalDifficulty = "1000"
Expand Down
14 changes: 7 additions & 7 deletions src/Nethermind/Nethermind.Runner.Test/ConfigFilesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ public void Required_config_files_exist(string configWildcard)
}
}

[TestCase("validators", true, true)]
[TestCase("poacore_validator.cfg", true, true)]
[TestCase("spaceneth", false, false)]
[TestCase("archive", false, false)]
[TestCase("fast", true, true)]
public void Sync_defaults_are_correct(string configWildcard, bool fastSyncEnabled, bool fastBlocksEnabled)
// maybe leave in test since deprecation has not fully happened?
[TestCase("validators", true)]
[TestCase("poacore_validator.cfg", true)]
[TestCase("spaceneth", false)]
[TestCase("archive", false)]
[TestCase("fast", true)]
public void Sync_defaults_are_correct(string configWildcard, bool fastSyncEnabled)
{
Test<ISyncConfig, bool>(configWildcard, c => c.FastSync, fastSyncEnabled);
Test<ISyncConfig, bool>(configWildcard, c => c.FastBlocks, fastBlocksEnabled);
}

[TestCase("archive")]
Expand Down
5 changes: 1 addition & 4 deletions src/Nethermind/Nethermind.Runner.Test/MemoryHintManTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,12 @@ public void Db_size_are_computed_correctly(
[Values(256 * MB, 512 * MB, 1 * GB, 4 * GB, 6 * GB, 16 * GB, 32 * GB, 64 * GB, 128 * GB)]
long memoryHint,
[Values(1u, 2u, 3u, 4u, 8u, 32u)] uint cpuCount,
[Values(true, false)] bool fastSync,
[Values(true, false)] bool fastBlocks)
[Values(true, false)] bool fastSync)
{
// OK to throw here
if (memoryHint == 256.MB())
{
_txPoolConfig.Size = 128;
_syncConfig.FastBlocks = false;
_initConfig.DiagnosticMode = DiagnosticMode.MemDb;
}

Expand All @@ -95,7 +93,6 @@ public void Db_size_are_computed_correctly(

SyncConfig syncConfig = new SyncConfig();
syncConfig.FastSync = fastSync;
syncConfig.FastBlocks = fastBlocks;

IDbConfig dbConfig = _dbConfig;

Expand Down
3 changes: 1 addition & 2 deletions src/Nethermind/Nethermind.Runner/configs/chiado.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
},
"Sync": {
"FastSync": true,
"FastBlocks": true,
"PivotNumber": 8260000,
"PivotHash": "0x980fc3d226c606ca126e06a34c3cbb4ff01be055309a7d4e9f29396096d6ef76",
"PivotTotalDifficulty": "231708131825107706987652208063906496124457284",
Expand Down Expand Up @@ -43,4 +42,4 @@
16
]
}
}
}
3 changes: 1 addition & 2 deletions src/Nethermind/Nethermind.Runner/configs/joc-testnet.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"Sync": {
"FastSync": true,
"SnapSync": true,
"FastBlocks": true,
"PivotNumber": 3300000,
"PivotHash": "0x58fbbcd0d0e8e5856c205385c922dd9e2b0b711060b001a960f327cf7b6608dc",
"PivotTotalDifficulty": "6599797"
Expand All @@ -28,4 +27,4 @@
"Merge": {
"Enabled": false
}
}
}
3 changes: 1 addition & 2 deletions src/Nethermind/Nethermind.Runner/configs/kovan.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"PivotNumber": 34000000,
"PivotHash": "0xaace54dd10cada02c236bd8182489cc7f9520dedceb1795f9f716e66d86921cb",
"PivotTotalDifficulty": "11519157357521914760869389464249041320958641825",
"FastBlocks": true,
"UseGethLimitsInFastBlocks": false,
"FastSyncCatchUpHeightDelta": 10000000000
},
Expand All @@ -31,4 +30,4 @@
16
]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"PivotNumber": 13200000,
"PivotHash": "0xa7a12fb5ec74204dbeed8630a5c762fa5875ea1e492d8199a15807316d4a8347",
"PivotTotalDifficulty": "4491727243356387717716544818000000000000000000",
"FastBlocks": true,
"UseGethLimitsInFastBlocks": false,
"FastSyncCatchUpHeightDelta": 10000000000
},
Expand Down
3 changes: 1 addition & 2 deletions src/Nethermind/Nethermind.Runner/configs/sepolia.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
},
"Sync": {
"FastSync": true,
"FastBlocks": true,
"SnapSync": true,
"UseGethLimitsInFastBlocks": true,
"PivotNumber": 5300000,
Expand All @@ -38,4 +37,4 @@
"Merge": {
"Enabled": true
}
}
}
3 changes: 1 addition & 2 deletions src/Nethermind/Nethermind.Runner/configs/volta.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"PivotNumber": 26680000,
"PivotHash": "0x038403ed7351bf180066ea7b6396daec13e6bb13163334ac9fab8ee3de19d471",
"PivotTotalDifficulty": "9078733549450638205202834526279575881277928465",
"FastBlocks": true,
"UseGethLimitsInFastBlocks": false,
"FastSyncCatchUpHeightDelta": 10000000000
},
Expand All @@ -34,4 +33,4 @@
"Merge": {
"Enabled": false
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ public void Setup()
PivotHash = _pivotBlock.Hash!.ToString(),
PivotNumber = _pivotBlock.Number.ToString(),
AncientBodiesBarrier = 0,
FastBlocks = true,
DownloadBodiesInFastSync = true,
};

Expand Down
Loading
Loading