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

[PoC] Pre-fetching blocks to download #12148

Closed
wants to merge 62 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
4a198c3
Fix some warnings
kiminuo Jan 4, 2024
455e3e4
Implement `ParallelBlockDownloadService`
kiminuo Jan 4, 2024
4ef8974
Merge commit '0b588849964ee1358aeec88070231ccba3f34e09' into feature/…
kiminuo Jan 6, 2024
876c26d
More tests
kiminuo Jan 6, 2024
65c9332
Merge branch 'master' into feature/2024-01-04-ParallelBlockDownloadin…
kiminuo Jan 9, 2024
3a60c17
WIP: Big merge and improvements
Jan 10, 2024
908b9fa
WIP: Test
Jan 11, 2024
4b51771
Merge branch 'master' into feature/2024-01-04-ParallelBlockDownloadin…
kiminuo Jan 11, 2024
c9dcfe7
Rename class
kiminuo Jan 11, 2024
1f22226
Re-design to work with priorities and refactor code
kiminuo Jan 11, 2024
721cec5
Merge branch 'master' into feature/2024-01-04-ParallelBlockDownloadin…
kiminuo Jan 11, 2024
5c042fc
Merge commit 'd724622604d14bc00e8db4e5849f99f7d04c61b2' into feature/…
kiminuo Jan 12, 2024
5a50ac1
Add results of operations
kiminuo Jan 12, 2024
37a7648
Improve
kiminuo Jan 12, 2024
7d81d7b
Remove `IRepository` and replace it with `IFileSystemBlockRepository`
kiminuo Jan 12, 2024
25e0f7f
Merge remote-tracking branch 'kiminuo/feature/2024-01-12-BlockReposit…
kiminuo Jan 12, 2024
373b516
Support for FileSystemBlockRepository
kiminuo Jan 12, 2024
96c9553
CF?
kiminuo Jan 12, 2024
f5237ea
Merge remote-tracking branch 'origin/master' into feature/2024-01-04-…
kiminuo Jan 12, 2024
1827f6a
Allow to set maximum number of requests
kiminuo Jan 13, 2024
467305a
Tests
kiminuo Jan 13, 2024
71fa3b2
WIP
kiminuo Jan 13, 2024
1396ba9
Integration test
kiminuo Jan 13, 2024
9dbc357
WIP
kiminuo Jan 13, 2024
0cc9959
Merge commit '7557f00e062693abd4adddb6c72d028c625d97f5' into feature/…
kiminuo Jan 15, 2024
390ab62
WIP
kiminuo Jan 16, 2024
e84724e
Merge commit 'a465c931cc9ef2e93a7a83e32d3cea0d3fc085e2' into feature/…
kiminuo Jan 16, 2024
e3b614d
Add sources and source data
kiminuo Jan 16, 2024
e600a50
rewire
kiminuo Jan 19, 2024
e102100
Remove `enqueue`
kiminuo Jan 19, 2024
c1d1c82
Add P2pSourceDataCode
kiminuo Jan 19, 2024
e1a7878
Use Clement's impl
kiminuo Jan 19, 2024
739f385
New P2p block provider overload
kiminuo Jan 19, 2024
aa525e4
No fallback. Maybe later.
kiminuo Jan 19, 2024
ee5599c
Merge commit '0afc02b697dadf149045f114775d5ee632da9404' into feature/…
kiminuo Jan 19, 2024
5ae2c8d
Add source request functionality
kiminuo Jan 21, 2024
7c48966
public -> internal
kiminuo Jan 22, 2024
1d95ba9
P2PNodesManager: Add DisconnectNode
kiminuo Jan 22, 2024
26e230b
Remove ^M
kiminuo Jan 22, 2024
47eb687
Fix nullability
kiminuo Jan 22, 2024
df095cc
P2PNodesManager: Use ConnectedNodesCount everywhere
kiminuo Jan 22, 2024
f7dd206
double l
kiminuo Jan 22, 2024
394c63c
better
kiminuo Jan 22, 2024
9c021b8
Remove try-catch
kiminuo Jan 22, 2024
43a960e
Clarify
kiminuo Jan 22, 2024
122272e
Merge branch 'pr/12184' into parallelDl3
Jan 23, 2024
30c3e26
Make ISourceRequest nullable in Request
Jan 23, 2024
15a7b64
Integrate BlockDownloadService
Jan 23, 2024
df64644
Update WalletWasabi/Wallets/FilterProcessor/BlockDownloadService.cs
kiminuo Jan 23, 2024
fbfb283
Remove block(s) from file cache when reorged
kiminuo Jan 23, 2024
3398ee5
`BlockFilterIterator`: Make `MaxNumberFiltersInMemory` public
kiminuo Jan 23, 2024
904270e
Simplify
kiminuo Jan 23, 2024
897b8d8
Remove max-attempts behavior, modify tests
kiminuo Jan 23, 2024
dca0ad7
Add NoSuchProviderResult
kiminuo Jan 24, 2024
e44d784
bigger timeout
kiminuo Jan 24, 2024
a27f2c9
Misc improvements and service starting
Jan 25, 2024
b8522cd
Add debug logs
Jan 25, 2024
511f7af
Set max filters in memory to 20000 for more impressive results on tes…
Jan 25, 2024
45be3e3
Improve parallel behavior
kiminuo Jan 25, 2024
9088c42
Merge commit '7137843fd202dc7ea95d6172a93b9184a22cf156' into feature/…
kiminuo Jan 25, 2024
2a890d7
Merge branch 'pr/12184' into parallelDl3
Jan 26, 2024
1501268
Merge latest changes
Jan 26, 2024
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
31 changes: 23 additions & 8 deletions WalletWasabi.Daemon/Global.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.Extensions.Caching.Memory;

Check notice on line 1 in WalletWasabi.Daemon/Global.cs

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (master)

ℹ Getting worse: Overall Code Complexity

The mean cyclomatic complexity increases from 5.00 to 5.09, threshold = 4. This file has many conditional statements (e.g. if, for, while) across its implementation, leading to lower code health. Avoid adding more conditionals.
using NBitcoin;
using Nito.AsyncEx;
using System;
Expand Down Expand Up @@ -32,6 +32,7 @@
using WalletWasabi.WabiSabi.Client.Banning;
using WalletWasabi.WabiSabi.Client.RoundStateAwaiters;
using WalletWasabi.Wallets;
using WalletWasabi.Wallets.FilterProcessor;
using WalletWasabi.WebClients.BlockstreamInfo;
using WalletWasabi.WebClients.Wasabi;

Expand Down Expand Up @@ -111,14 +112,18 @@

// Block providers.
SpecificNodeBlockProvider = new SpecificNodeBlockProvider(Network, Config.ServiceConfiguration, HttpClientFactory.TorEndpoint);
var blockProvider = new SmartBlockProvider(
BitcoinStore.BlockRepository,
BitcoinCoreNode?.RpcClient is null ? null : new RpcBlockProvider(BitcoinCoreNode.RpcClient),
SpecificNodeBlockProvider,
new P2PBlockProvider(Network, HostedServices.Get<P2pNetwork>().Nodes, HttpClientFactory.IsTorEnabled),
Cache);

WalletManager = new WalletManager(config.Network, DataDir, new WalletDirectories(Config.Network, DataDir), BitcoinStore, wasabiSynchronizer, HostedServices.Get<HybridFeeProvider>(), blockProvider, config.ServiceConfiguration);
P2PNodesManager = new P2PNodesManager(Network, HostedServices.Get<P2pNetwork>().Nodes, HttpClientFactory.IsTorEnabled);

var trustedFullNodeBlockProviders = BitcoinCoreNode?.RpcClient is null
? new IBlockProvider[] { SpecificNodeBlockProvider }
: new IBlockProvider[] { new RpcBlockProvider(BitcoinCoreNode.RpcClient), SpecificNodeBlockProvider };

BlockDownloadService = new BlockDownloadService(
fileSystemBlockRepository: BitcoinStore.BlockRepository,
trustedFullNodeBlockProviders: trustedFullNodeBlockProviders,
new P2PBlockProvider(P2PNodesManager));

WalletManager = new WalletManager(config.Network, DataDir, new WalletDirectories(Config.Network, DataDir), BitcoinStore, wasabiSynchronizer, HostedServices.Get<HybridFeeProvider>(), BlockDownloadService, config.ServiceConfiguration);
TransactionBroadcaster = new TransactionBroadcaster(Network, BitcoinStore, HttpClientFactory, WalletManager);

CoinPrison = CoinPrison.CreateOrLoadFromFile(DataDir);
Expand Down Expand Up @@ -150,6 +155,8 @@
public TransactionBroadcaster TransactionBroadcaster { get; set; }
public CoinJoinProcessor? CoinJoinProcessor { get; set; }
private SpecificNodeBlockProvider SpecificNodeBlockProvider { get; }
private BlockDownloadService BlockDownloadService { get; }
private P2PNodesManager P2PNodesManager { get; }
private TorProcessManager? TorManager { get; set; }
public CoreNode? BitcoinCoreNode { get; private set; }
public TorStatusChecker TorStatusChecker { get; set; }
Expand Down Expand Up @@ -247,6 +254,8 @@

await StartRpcServerAsync(terminateService, cancel).ConfigureAwait(false);

await BlockDownloadService.StartAsync(cancel).ConfigureAwait(false);

WalletManager.Initialize();
}
finally
Expand Down Expand Up @@ -436,6 +445,12 @@
Logger.LogInfo($"{nameof(SpecificNodeBlockProvider)} is disposed.");
}

if (BlockDownloadService is { } blockDownloadService)
{
blockDownloadService.Dispose();
Logger.LogInfo($"{nameof(BlockDownloadService)} is disposed.");
}

Check warning on line 453 in WalletWasabi.Daemon/Global.cs

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (master)

❌ Getting worse: Complex Method

DisposeAsync increases in cyclomatic complexity from 20 to 21, threshold = 9. This function has many conditional statements (e.g. if, for, while), leading to lower code health. Avoid adding more conditionals and code to it without refactoring.
if (CoinJoinProcessor is { } coinJoinProcessor)
{
coinJoinProcessor.Dispose();
Expand Down
110 changes: 110 additions & 0 deletions WalletWasabi.Tests/IntegrationTests/BlockDownloadTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
using Moq;
using NBitcoin;
using NBitcoin.Protocol;
using NBitcoin.Protocol.Behaviors;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using WalletWasabi.Helpers;
using WalletWasabi.Logging;
using WalletWasabi.Tests.Helpers;
using WalletWasabi.Wallets;
using WalletWasabi.Wallets.BlockProvider;
using WalletWasabi.Wallets.FilterProcessor;
using Xunit;
using static WalletWasabi.Wallets.FilterProcessor.BlockDownloadService;

namespace WalletWasabi.Tests.IntegrationTests;

/// <summary>
/// Integration tests for <see cref="BlockDownloadService"/>.
/// </summary>
public class BlockDownloadTests
{
public static readonly SortedDictionary<uint, uint256> HeightToBlockHash = new()
{
{ 610_000, new uint256("0000000000000000000a6f607f74db48dae0a94022c10354536394c17672b7f7") },
{ 610_001, new uint256("0000000000000000000b9cfe321443cb2ced7a4182b8594f077ee4e23d6c2ae2") },
{ 610_002, new uint256("0000000000000000000aef4754dfc99fed93f40d8b90d06037075bc59af3ab4d") },
{ 610_003, new uint256("00000000000000000012afa0710628d1c504f1d40e1fc1b71c8cc66982547d0b") },
{ 610_004, new uint256("000000000000000000081bb924d567c05c39dabc7feda74b02a1327dc376634d") },
{ 610_005, new uint256("0000000000000000000f68159a871ea320691afcb3e0b7e8e3e03f53c0c0d58d") },
{ 610_006, new uint256("0000000000000000000571a7383c5679bf6967b6eb43efa807167ea3d1761e84") },
{ 610_007, new uint256("0000000000000000000ab3657ecbfa7e4e555d58f4fe6a0279bee8ea29ae2df7") },
{ 610_008, new uint256("000000000000000000157e58b222e0097afee38d6920f0750e177c0d02a5d593") },
{ 610_009, new uint256("00000000000000000003354e9f48af4b5850fd884f38886d00b92bfd4a015d54") },
};

[Fact]
public async Task BlockDownloadingTestAsync()
{
using CancellationTokenSource testCts = new(TimeSpan.FromMinutes(10));

Mock<IFileSystemBlockRepository> mockFileSystemBlockRepository = new(MockBehavior.Strict);
_ = mockFileSystemBlockRepository.Setup(c => c.TryGetAsync(It.IsAny<uint256>(), It.IsAny<CancellationToken>()))
.ReturnsAsync((Block?)null);
_ = mockFileSystemBlockRepository.Setup(c => c.SaveAsync(It.IsAny<Block>(), It.IsAny<CancellationToken>()))
.Returns(Task.CompletedTask);

RuntimeParams.SetDataDir(Path.Combine(Common.DataDir, "RegTests", "Backend"));
await RuntimeParams.LoadAsync();

string roamingDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);

string addressManagerFilePath = Path.Combine(roamingDir, "WalletWasabi", "Client", "BitcoinP2pNetwork", $"AddressManager{Network.Main}.dat");
AddressManager addressManager = AddressManager.LoadPeerFile(addressManagerFilePath);
AddressManagerBehavior addressManagerBehavior = new(addressManager)
{
Mode = AddressManagerBehaviorMode.Discover
};

using NodesGroup nodes = new(Network.Main);
nodes.NodeConnectionParameters.TemplateBehaviors.Add(addressManagerBehavior);
nodes.Connect();

while (nodes.ConnectedNodes.Count == 0)
{
await Task.Delay(1000, testCts.Token);
}

P2PBlockProvider p2PBlockProvider = new(Network.Main, nodes, isTorEnabled: false);
using BlockDownloadService blockDownloadService = new(mockFileSystemBlockRepository.Object, trustedFullNodeBlockProviders: [], p2PBlockProvider);

try
{
await blockDownloadService.StartAsync(testCts.Token);

Stopwatch stopwatch = Stopwatch.StartNew();

List<Task<IResult>> tasks = [];

foreach ((uint height, uint256 blockHash) in HeightToBlockHash)
{
Task<IResult> taskCompletionSource = blockDownloadService.TryGetBlockAsync(P2pSourceRequest.Automatic, blockHash, new Priority(SyncType.Complete, height), testCts.Token);
tasks.Add(taskCompletionSource);
}

await Task.WhenAll(tasks);

uint blockHeight = HeightToBlockHash.First().Key;

foreach (Task<IResult> task in tasks)
{
IResult result = await task;
Logger.LogInfo($"Block #{blockHeight} finished with result: {result}");

blockHeight++;
}

stopwatch.Stop();
Logger.LogInfo($"Test finished in {stopwatch.ElapsedMilliseconds} ms");
}
finally
{
await blockDownloadService.StopAsync(testCts.Token);
}
}
}
20 changes: 10 additions & 10 deletions WalletWasabi.Tests/IntegrationTests/P2pTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
using WalletWasabi.Stores;
using WalletWasabi.Tests.Helpers;
using WalletWasabi.Wallets;
using WalletWasabi.Wallets.BlockProvider;
using WalletWasabi.Wallets.FilterProcessor;
using WalletWasabi.WebClients.Wasabi;
using Xunit;

Expand Down Expand Up @@ -112,12 +114,10 @@
IFileSystemBlockRepository blockRepository = bitcoinStore.BlockRepository;
await using SpecificNodeBlockProvider specificNodeBlockProvider = new(network, serviceConfig, httpClientFactory.TorEndpoint);

IBlockProvider blockProvider = new SmartBlockProvider(
blockRepository,
rpcBlockProvider: null,
specificNodeBlockProvider,
new P2PBlockProvider(network, nodes, httpClientFactory.IsTorEnabled),
cache);
var blockDownloadService = new BlockDownloadService(
bitcoinStore.BlockRepository,
new IBlockProvider[] { specificNodeBlockProvider },
new P2PBlockProvider(network, nodes, httpClientFactory.IsTorEnabled));

using Wallet wallet = Wallet.CreateAndRegisterServices(
network,
Expand All @@ -127,7 +127,7 @@
dataDir,
new ServiceConfiguration(new IPEndPoint(IPAddress.Loopback, network.DefaultPort), Money.Coins(Constants.DefaultDustThreshold)),
feeProvider,
blockProvider);
blockDownloadService);
Assert.True(Directory.Exists(blocks.BlocksFolderPath));

try
Expand All @@ -144,18 +144,18 @@

nodes.Connect();

var downloadTasks = new List<Task<Block>>();
var downloadTasks = new List<Task<BlockDownloadService.IResult>>();
using var cts = new CancellationTokenSource(TimeSpan.FromMinutes(4));
foreach (var hash in blocksToDownload)
{
downloadTasks.Add(blockProvider.GetBlockAsync(hash, cts.Token));
downloadTasks.Add(blockDownloadService.TryGetBlockAsync(P2pSourceRequest.Automatic, hash, new Priority(SyncType.Complete), uint.MaxValue, cts.Token));

Check failure on line 151 in WalletWasabi.Tests/IntegrationTests/P2pTests.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

No overload for method 'TryGetBlockAsync' takes 5 arguments

Check failure on line 151 in WalletWasabi.Tests/IntegrationTests/P2pTests.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

No overload for method 'TryGetBlockAsync' takes 5 arguments

Check failure on line 151 in WalletWasabi.Tests/IntegrationTests/P2pTests.cs

View check run for this annotation

Azure Pipelines / Wasabi.Linux

WalletWasabi.Tests/IntegrationTests/P2pTests.cs#L151

WalletWasabi.Tests/IntegrationTests/P2pTests.cs(151,44): Error CS1501: No overload for method 'TryGetBlockAsync' takes 5 arguments

Check failure on line 151 in WalletWasabi.Tests/IntegrationTests/P2pTests.cs

View check run for this annotation

Azure Pipelines / Wasabi.Osx

WalletWasabi.Tests/IntegrationTests/P2pTests.cs#L151

WalletWasabi.Tests/IntegrationTests/P2pTests.cs(151,44): Error CS1501: No overload for method 'TryGetBlockAsync' takes 5 arguments
}

await nodeConnectionAwaiter.WaitAsync(TimeSpan.FromMinutes(3));

var i = 0;
var hashArray = blocksToDownload.ToArray();
foreach (var block in await Task.WhenAll(downloadTasks))
foreach (var result in await Task.WhenAll(downloadTasks))
{
Assert.True(File.Exists(Path.Combine(blocks.BlocksFolderPath, hashArray[i].ToString())));
i++;
Expand Down
11 changes: 5 additions & 6 deletions WalletWasabi.Tests/RegressionTests/BuildTransactionReorgsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
using WalletWasabi.Stores;
using WalletWasabi.Tests.XunitConfiguration;
using WalletWasabi.Wallets;
using WalletWasabi.Wallets.FilterProcessor;
using WalletWasabi.WebClients.Wasabi;
using Xunit;

Expand Down Expand Up @@ -75,14 +76,12 @@
using MemoryCache cache = CreateMemoryCache();
await using SpecificNodeBlockProvider specificNodeBlockProvider = new(network, serviceConfiguration, httpClientFactory.TorEndpoint);

var blockProvider = new SmartBlockProvider(
var blockDownloadService = new BlockDownloadService(
bitcoinStore.BlockRepository,
rpcBlockProvider: null,
specificNodeBlockProvider,
new P2PBlockProvider(network, nodes, httpClientFactory.IsTorEnabled),
cache);
new IBlockProvider[] { specificNodeBlockProvider },
new P2PBlockProvider(network, nodes, httpClientFactory.IsTorEnabled));

WalletManager walletManager = new(network, workDir, new WalletDirectories(network, workDir), bitcoinStore, synchronizer, feeProvider, blockProvider, serviceConfiguration);
WalletManager walletManager = new(network, workDir, new WalletDirectories(network, workDir), bitcoinStore, synchronizer, feeProvider, blockDownloadService, serviceConfiguration);

Check notice on line 84 in WalletWasabi.Tests/RegressionTests/BuildTransactionReorgsTest.cs

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (master)

✅ Getting better: Large Method

BuildTransactionReorgsTestAsync decreases from 179 to 177 lines of code, threshold = 70. Large functions with many lines of code are generally harder to understand and lower the code health. Avoid adding more lines to this function.
walletManager.Initialize();

var baseTip = await rpc.GetBestBlockHashAsync();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
using WalletWasabi.Stores;
using WalletWasabi.Tests.XunitConfiguration;
using WalletWasabi.Wallets;
using WalletWasabi.Wallets.FilterProcessor;
using WalletWasabi.WebClients.Wasabi;
using Xunit;

Expand Down Expand Up @@ -74,14 +75,12 @@
using MemoryCache cache = CreateMemoryCache();
await using SpecificNodeBlockProvider specificNodeBlockProvider = new(network, serviceConfiguration, httpClientFactory.TorEndpoint);

var blockProvider = new SmartBlockProvider(
var blockDownloadService = new BlockDownloadService(
bitcoinStore.BlockRepository,
rpcBlockProvider: null,
specificNodeBlockProvider,
p2PBlockProvider: new P2PBlockProvider(network, nodes, httpClientFactory.IsTorEnabled),
cache);
new IBlockProvider[] { specificNodeBlockProvider },
new P2PBlockProvider(network, nodes, httpClientFactory.IsTorEnabled));

using var wallet = Wallet.CreateAndRegisterServices(network, bitcoinStore, keyManager, synchronizer, workDir, serviceConfiguration, feeProvider, blockProvider);
using var wallet = Wallet.CreateAndRegisterServices(network, bitcoinStore, keyManager, synchronizer, workDir, serviceConfiguration, feeProvider, blockDownloadService);

Check notice on line 83 in WalletWasabi.Tests/RegressionTests/BuildTransactionValidationsTest.cs

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (master)

✅ Getting better: Large Method

BuildTransactionValidationsTestAsync decreases from 107 to 105 lines of code, threshold = 70. Large functions with many lines of code are generally harder to understand and lower the code health. Avoid adding more lines to this function.
wallet.NewFiltersProcessed += setup.Wallet_NewFiltersProcessed;

using Key key = new();
Expand Down
11 changes: 5 additions & 6 deletions WalletWasabi.Tests/RegressionTests/CancelTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
using WalletWasabi.Helpers;
using WalletWasabi.Logging;
using WalletWasabi.Tests.Helpers;
using WalletWasabi.Wallets.FilterProcessor;

namespace WalletWasabi.Tests.RegressionTests;

Expand Down Expand Up @@ -73,14 +74,12 @@ public async Task CancelTestsAsync()
using MemoryCache cache = BitcoinFactory.CreateMemoryCache();
await using SpecificNodeBlockProvider specificNodeBlockProvider = new(network, serviceConfiguration, httpClientFactory.TorEndpoint);

var blockProvider = new SmartBlockProvider(
var blockDownloadService = new BlockDownloadService(
bitcoinStore.BlockRepository,
rpcBlockProvider: null,
specificNodeBlockProvider,
new P2PBlockProvider(network, nodes, httpClientFactory.IsTorEnabled),
cache);
new IBlockProvider[] { specificNodeBlockProvider },
new P2PBlockProvider(network, nodes, httpClientFactory.IsTorEnabled));

WalletManager walletManager = new(network, workDir, new WalletDirectories(network, workDir), bitcoinStore, synchronizer, feeProvider, blockProvider, serviceConfiguration);
WalletManager walletManager = new(network, workDir, new WalletDirectories(network, workDir), bitcoinStore, synchronizer, feeProvider, blockDownloadService, serviceConfiguration);
walletManager.Initialize();

// Get some money, make it confirm.
Expand Down
11 changes: 5 additions & 6 deletions WalletWasabi.Tests/RegressionTests/MaxFeeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
using WalletWasabi.Tests.Helpers;
using WalletWasabi.Tests.XunitConfiguration;
using WalletWasabi.Wallets;
using WalletWasabi.Wallets.FilterProcessor;
using WalletWasabi.WebClients.Wasabi;
using Xunit;

Expand Down Expand Up @@ -73,14 +74,12 @@ public async Task CalculateMaxFeeTestAsync()
using MemoryCache cache = BitcoinFactory.CreateMemoryCache();
await using SpecificNodeBlockProvider specificNodeBlockProvider = new(network, serviceConfiguration, httpClientFactory.TorEndpoint);

var blockProvider = new SmartBlockProvider(
var blockDownloadService = new BlockDownloadService(
bitcoinStore.BlockRepository,
rpcBlockProvider: null,
specificNodeBlockProvider,
new P2PBlockProvider(network, nodes, httpClientFactory.IsTorEnabled),
cache);
new IBlockProvider[] { specificNodeBlockProvider },
new P2PBlockProvider(network, nodes, httpClientFactory.IsTorEnabled));

WalletManager walletManager = new(network, workDir, new WalletDirectories(network, workDir), bitcoinStore, synchronizer, feeProvider, blockProvider, serviceConfiguration);
WalletManager walletManager = new(network, workDir, new WalletDirectories(network, workDir), bitcoinStore, synchronizer, feeProvider, blockDownloadService, serviceConfiguration);
walletManager.Initialize();

// Get some money, make it confirm.
Expand Down
11 changes: 5 additions & 6 deletions WalletWasabi.Tests/RegressionTests/ReceiveSpeedupTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
using WalletWasabi.Helpers;
using WalletWasabi.Blockchain.Transactions;
using WalletWasabi.Exceptions;
using WalletWasabi.Wallets.FilterProcessor;

namespace WalletWasabi.Tests.RegressionTests;

Expand Down Expand Up @@ -75,14 +76,12 @@ public async Task ReceiveSpeedupTestsAsync()
using MemoryCache cache = BitcoinFactory.CreateMemoryCache();
await using SpecificNodeBlockProvider specificNodeBlockProvider = new(network, serviceConfiguration, httpClientFactory.TorEndpoint);

var blockProvider = new SmartBlockProvider(
var blockDownloadService = new BlockDownloadService(
bitcoinStore.BlockRepository,
rpcBlockProvider: null,
specificNodeBlockProvider,
new P2PBlockProvider(network, nodes, httpClientFactory.IsTorEnabled),
cache);
new IBlockProvider[] { specificNodeBlockProvider },
new P2PBlockProvider(network, nodes, httpClientFactory.IsTorEnabled));

WalletManager walletManager = new(network, workDir, new WalletDirectories(network, workDir), bitcoinStore, synchronizer, feeProvider, blockProvider, serviceConfiguration);
WalletManager walletManager = new(network, workDir, new WalletDirectories(network, workDir), bitcoinStore, synchronizer, feeProvider, blockDownloadService, serviceConfiguration);
walletManager.Initialize();

try
Expand Down
12 changes: 5 additions & 7 deletions WalletWasabi.Tests/RegressionTests/ReplaceByFeeTxTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
using WalletWasabi.WebClients.Wasabi;
using Xunit;
using WalletWasabi.Tests.Helpers;
using WalletWasabi.Wallets.FilterProcessor;

namespace WalletWasabi.Tests.RegressionTests;

Expand Down Expand Up @@ -67,18 +68,15 @@

// 5. Create wallet service.
var workDir = Common.GetWorkDir();

using MemoryCache cache = BitcoinFactory.CreateMemoryCache();
await using SpecificNodeBlockProvider specificNodeBlockProvider = new(network, serviceConfiguration, httpClientFactory.TorEndpoint);

var blockProvider = new SmartBlockProvider(
var blockDownloadService = new BlockDownloadService(
bitcoinStore.BlockRepository,
rpcBlockProvider: null,
specificNodeBlockProvider,
new P2PBlockProvider(network, nodes, httpClientFactory.IsTorEnabled),
cache);
new IBlockProvider[] { specificNodeBlockProvider },
new P2PBlockProvider(network, nodes, httpClientFactory.IsTorEnabled));

using var wallet = Wallet.CreateAndRegisterServices(network, bitcoinStore, keyManager, synchronizer, workDir, serviceConfiguration, feeProvider, blockProvider);
using var wallet = Wallet.CreateAndRegisterServices(network, bitcoinStore, keyManager, synchronizer, workDir, serviceConfiguration, feeProvider, blockDownloadService);

Check notice on line 79 in WalletWasabi.Tests/RegressionTests/ReplaceByFeeTxTest.cs

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (master)

✅ Getting better: Large Method

ReplaceByFeeTxTestAsync decreases from 80 to 77 lines of code, threshold = 70. Large functions with many lines of code are generally harder to understand and lower the code health. Avoid adding more lines to this function.
wallet.NewFiltersProcessed += setup.Wallet_NewFiltersProcessed;

Assert.Empty(wallet.Coins);
Expand Down
Loading
Loading