Skip to content

Commit

Permalink
Merge branch 'master' into crashGracefully
Browse files Browse the repository at this point in the history
# Conflicts:
#	WalletWasabi.Fluent.Desktop/Program.cs
  • Loading branch information
turbolay committed Mar 14, 2024
2 parents 5c7a143 + 92e4921 commit d7669e8
Show file tree
Hide file tree
Showing 401 changed files with 25,804 additions and 13,304 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -299,3 +299,6 @@ dotnet_diagnostic.CA1822.severity = none

# CA1868: Unnecessary call to Set.Contains(item)
dotnet_diagnostic.CA1868.severity = warning

# xUnit1030: Do not call ConfigureAwait in test method
dotnet_diagnostic.xUnit1030.severity = warning
88 changes: 88 additions & 0 deletions .github/notify-users-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
{
"files_to_watch": [
{
"path": "WalletWasabi/Wallets/IWallet.cs",
"users": ["@Kukks"]
},
{
"path": "WalletWasabi/Blockchain/Analysis/BlockchainAnalyzer.cs",
"users": ["@onvej-sl"]
},
{
"path": "WalletWasabi/Blockchain/Keys/HdPubKey.cs",
"users": ["@onvej-sl"]
},
{
"path": "WalletWasabi/Blockchain/TransactionOutputs/SmartCoin.cs",
"users": ["@onvej-sl"]
},
{
"path": "WalletWasabi/Blockchain/TransactionOutputs/ISmartCoin.cs",
"users": ["@onvej-sl"]
},
{
"path": "WalletWasabi/Blockchain/Transactions/SmartTransaction.cs",
"users": ["@onvej-sl"]
},
{
"path": "WalletWasabi/Helpers/NBitcoinHelpers.cs",
"users": ["@onvej-sl"]
},
{
"path": "WalletWasabi/WabiSabi/Backend/Rounds/UtxoSelectionParameters.cs",
"users": ["@onvej-sl"]
},
{
"path": "WalletWasabi/WabiSabi/Client/AmountDecomposer.cs",
"users": ["@onvej-sl"]
},
{
"path": "WalletWasabi/WabiSabi/Client/LiquidityClueProvider.cs",
"users": ["@onvej-sl"]
},
{
"path": "WalletWasabi/WabiSabi/Client/CoinJoinCoinSelector.cs",
"users": ["@onvej-sl"]
},
{
"path": "WalletWasabi/WabiSabi/Client/Decomposer.cs",
"users": ["@onvej-sl"]
},
{
"path": "WalletWasabi/WabiSabi/Client/AmountDecomposer.cs",
"users": ["@onvej-sl"]
},
{
"path": "WalletWasabi/WabiSabi/Client/Output.cs",
"users": ["@onvej-sl"]
},
{
"path": "WalletWasabi/WabiSabi/Backend/Rounds/UtxoSelectionParameters.cs",
"users": ["@onvej-sl"]
},
{
"path": "WalletWasabi/Blockchain/TransactionOutputs/ISmartCoin.cs",
"users": ["@onvej-sl"]
},
{
"path": "WalletWasabi/WabiSabi/Client/CoinJoinCoinSelector.cs",
"users": ["@onvej-sl"]
},
{
"path": "WalletWasabi/Blockchain/Analysis/BlockchainAnalyzer.cs",
"users": ["@onvej-sl"]
},
{
"path": "WalletWasabi/WabiSabi/Client/LiquidityClueProvider.cs",
"users": ["@onvej-sl"]
},
{
"path": "WalletWasabi/Affiliation/",
"users": ["@onvej-sl"]
},
{
"path": ".github/notify-users-config.json",
"users": ["@molnard"]
}
]
}
88 changes: 88 additions & 0 deletions .github/workflows/mention_users_on_filechange.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Mention Users on Specific File Change in PR

on:
pull_request:

jobs:
mention-users:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v2

- name: Read configuration and mention users
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs');
// Read the configuration file
const configPath = '.github/notify-users-config.json';
const configFile = fs.readFileSync(configPath, 'utf8');
const config = JSON.parse(configFile);
// Extract PR number
const prNumber = context.issue.number;
// Async function to handle API calls and logic
async function run() {
// Fetch list of files changed in the PR
const listFilesResponse = await github.rest.pulls.listFiles({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: prNumber,
});
const changedFiles = listFilesResponse.data.map(file => file.filename);
// Fetch all comments from the PR
const commentsResponse = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
});
const comments = commentsResponse.data.map(comment => comment.body);
// Combine all comments into a single string to search for user mentions
const commentsText = comments.join(" ");
let message = "Changes have been detected in:";
let hasMentionedFiles = false;
let mentionedUsers = new Set();
// Check if the PR contains changes to the files or folders specified in the configuration
for (const item of config.files_to_watch) {
const isFolder = item.path.endsWith('/');
for (const changedFile of changedFiles) {
if (isFolder ? changedFile.startsWith(item.path) : changedFile === item.path) {
// Filter out users who have already been mentioned
const usersToMention = item.users.filter(user => !commentsText.includes(user));
if (usersToMention.length > 0) {
// Add users to the set of mentioned users to avoid duplicates
usersToMention.forEach(user => mentionedUsers.add(user));
if (!hasMentionedFiles) {
// First time adding to the message, change the flag
hasMentionedFiles = true;
}
message += `\n- \`${item.path}\` (Pinging ${usersToMention.join(', ')} for review).`;
}
}
}
}
// Post the comment on the PR if there are any files or folders to mention
if (hasMentionedFiles) {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
body: message
});
} else {
console.log("No configured files or folders were changed in this PR, or users have already been mentioned.");
}
}
// Execute the async function
run().catch(err => core.setFailed(`Unhandled error: ${err}`));
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -279,3 +279,4 @@ lcov.info

# This file is created by an F# VS Code plugin
.ionide/symbolCache.db
**/launchSettings.json
25 changes: 15 additions & 10 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
- Avoid working on a UI or UX feature without first seeing a conclusion from a UX meeting.
- Consider filing a new issue or explaining in an opened issue the change that you want to make, and wait for concept ACKs to work on the implementation.
- For backend, the [Relevance Realization Buffet](https://github.com/orgs/zkSNACKs/projects/18/views/48) view is a list of tasks that has to be investigated or tackled. You can assign yourself to an issue or just make the pull request.
- Feel free to join the [zkSNACKs Slack Server](https://join.slack.com/t/tumblebit/shared_invite/enQtNjQ1MTQ2NzQ1ODI0LWIzOTg5YTM3YmNkOTg1NjZmZTQ3NmM1OTAzYmQyYzk1M2M0MTdlZDk2OTQwNzFiNTg1ZmExNzM0NjgzY2M0Yzg) to discuss with other contributors.
- Feel free to join the [zkSNACKs Slack Server](https://join.slack.com/t/tumblebit/shared_invite/enQtNjQ1MTQ2NzQ1ODI0LWIzOTg5YTM3YmNkOTg1NjZmZTQ3NmM1OTAzYmQyYzk1M2M0MTdlZDk2OTQwNzFiNTg1ZmExNzM0NjgzY2M0Yzg) to discuss with other contributors.
- [Status calls](meet.zksnacks.com/research) are held on Mondays at 15:00 UTC to discuss what we did, and [peer programming calls](https://meet.zksnacks.com/code) on Thursdays at 13:30 UTC for coding together.

## Automatic code clean up

Expand All @@ -32,14 +33,22 @@ And also enable `Enable EditorConfig support` in `Settings -> Editor -> Code Sty

Not only CodeMaid, but Visual Studio also enforces consistent coding style through [`.editorconfig`](https://github.com/zkSNACKs/WalletWasabi/blob/master/.editorconfig) file.

If you are using Visual Studio Code make sure to add the following settings to your settings file:
If you are using Visual Studio Code make sure to install "C# Dev Kit" extension and add the following settings to your settings file:

```json
"omnisharp.enableEditorConfigSupport": true,
"omnisharp.enableRoslynAnalyzers": true,
"editor.formatOnSave": true,
"editor.formatOnSave": true
```

## Technologies and scope

- [.NET SDK](https://dotnet.microsoft.com/en-us/): free, open-source, cross-platform framework for building apps. SDK version path: [WalletWasabi/global.json](https://github.com/zkSNACKs/WalletWasabi/blob/master/global.json).
- [C#](https://dotnet.microsoft.com/en-us/languages/csharp): open-source programming language.
- Model-View-ViewModel architecture (MVVM).
- [Avalonia UI](https://www.avaloniaui.net/): framework to create cross-platform UI.
- [xUnit](https://xunit.net/): create unit tests.
- Dependencies path: [WalletWasabi/Directory.Packages.props](https://github.com/zkSNACKs/WalletWasabi/blob/master/Directory.Packages.props).
- Developer's documentation path: [WalletWasabi/WalletWasabi.Documentation/](https://github.com/zkSNACKs/WalletWasabi/tree/master/WalletWasabi.Documentation).

# Code conventions

## Refactoring
Expand Down Expand Up @@ -377,8 +386,4 @@ If you absolutely must reference `UiContext` in the constructor, you can create
}
```

In this case, no additional constructors will be generated, and the analyzer will be satisfied.




In this case, no additional constructors will be generated, and the analyzer will be satisfied.
1 change: 1 addition & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
<Nullable>enable</Nullable>
<Deterministic>true</Deterministic>
<InvariantGlobalization>true</InvariantGlobalization>
<WarningsAsErrors>false</WarningsAsErrors>
</PropertyGroup>
</Project>
6 changes: 3 additions & 3 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<AvaloniaVersion>11.0.8</AvaloniaVersion>
<AvaloniaVersion>11.0.999-cibuild0044755-beta</AvaloniaVersion>
</PropertyGroup>
<ItemGroup>
<!-- AspNetCore. -->
Expand Down Expand Up @@ -50,7 +50,7 @@
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageVersion Include="Moq" Version="[4.18.4]" />
<PackageVersion Include="xunit" Version="2.5.0" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.5.0" />
<PackageVersion Include="xunit" Version="2.6.6" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.5.6" />
</ItemGroup>
</Project>
10 changes: 10 additions & 0 deletions NuGet.Config
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,15 @@
<packageSources>
<clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="avalonia-all" value="https://nuget-feed-all.avaloniaui.net/v3/index.json" />
</packageSources>

<packageSourceMapping>
<packageSource key="avalonia-all">
<package pattern="*"/>
</packageSource>
<packageSource key="nuget.org">
<package pattern="*"/>
</packageSource>
</packageSourceMapping>
</configuration>
1 change: 0 additions & 1 deletion WalletWasabi.Backend/Controllers/BlockchainController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,6 @@ public async Task<IActionResult> BroadcastAsync([FromBody, Required] string hex,
/// </remarks>
/// <param name="bestKnownBlockHash">The best block hash the client knows its filter.</param>
/// <param name="count">The number of filters to return.</param>
/// <param name="indexType">Type of index. Valid values: segwittaproot, taproot.</param>
/// <returns>The best height and an array of block hash : element count : filter pairs.</returns>
/// <response code="200">The best height and an array of block hash : element count : filter pairs.</response>
/// <response code="204">When the provided hash is the tip.</response>
Expand Down
55 changes: 38 additions & 17 deletions WalletWasabi.Daemon/Global.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
using WalletWasabi.Wallets;
using WalletWasabi.WebClients.BlockstreamInfo;
using WalletWasabi.WebClients.Wasabi;
using WalletWasabi.BuyAnything;
using WalletWasabi.WebClients.BuyAnything;
using WalletWasabi.WebClients.ShopWare;

namespace WalletWasabi.Daemon;

Expand Down Expand Up @@ -111,14 +114,17 @@ public Global(string dataDir, string configFilePath, Config config)

// Block providers.
SpecificNodeBlockProvider = new SpecificNodeBlockProvider(Network, Config.ServiceConfiguration, HttpClientFactory.TorEndpoint);
P2PNodesManager = new P2PNodesManager(Network, HostedServices.Get<P2pNetwork>().Nodes, HttpClientFactory.IsTorEnabled);

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),
new P2PBlockProvider(P2PNodesManager),
Cache);

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

CoinPrison = CoinPrison.CreateOrLoadFromFile(DataDir);
Expand Down Expand Up @@ -150,6 +156,7 @@ public Global(string dataDir, string configFilePath, Config config)
public TransactionBroadcaster TransactionBroadcaster { get; set; }
public CoinJoinProcessor? CoinJoinProcessor { get; set; }
private SpecificNodeBlockProvider SpecificNodeBlockProvider { get; }
private P2PNodesManager P2PNodesManager { get; }
private TorProcessManager? TorManager { get; set; }
public CoreNode? BitcoinCoreNode { get; private set; }
public TorStatusChecker TorStatusChecker { get; set; }
Expand All @@ -173,7 +180,7 @@ public Global(string dataDir, string configFilePath, Config config)
Config.UseTor ? TorSettings.SocksEndpoint : null,
backendUriGetter);

public async Task InitializeNoWalletAsync(TerminateService terminateService, CancellationToken cancellationToken)
public async Task InitializeNoWalletAsync(bool initializeSleepInhibitor, TerminateService terminateService, CancellationToken cancellationToken)
{
using CancellationTokenSource linkedCts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, StoppingCts.Token);
CancellationToken cancel = linkedCts.Token;
Expand Down Expand Up @@ -202,12 +209,6 @@ public async Task InitializeNoWalletAsync(TerminateService terminateService, Can
{
await bitcoinStoreInitTask.ConfigureAwait(false);

// ToDo: Temporary to fix https://github.com/zkSNACKs/WalletWasabi/pull/12137#issuecomment-1879798750
if (AllTransactionStore.MempoolStore.NeedResync || AllTransactionStore.ConfirmedStore.NeedResync)
{
WalletManager.ResyncToBefore12137();
}

// Make sure that TurboSyncHeight is not higher than BestHeight
WalletManager.EnsureTurboSyncHeightConsistency();

Expand All @@ -225,16 +226,22 @@ public async Task InitializeNoWalletAsync(TerminateService terminateService, Can

RegisterCoinJoinComponents();

SleepInhibitor? sleepInhibitor = await SleepInhibitor.CreateAsync(HostedServices.Get<CoinJoinManager>()).ConfigureAwait(false);

if (sleepInhibitor is not null)
if (initializeSleepInhibitor)
{
HostedServices.Register<SleepInhibitor>(() => sleepInhibitor, "Sleep Inhibitor");
}
else
{
Logger.LogInfo("Sleep Inhibitor is not available on this platform.");
await CreateSleepInhibitorAsync().ConfigureAwait(false);
}

bool useTestApi = Network != Network.Main;
var apiKey = useTestApi ? "SWSCVTGZRHJOZWF0MTJFTK9ZSG" : "SWSCU3LIYWVHVXRVYJJNDLJZBG";
var uri = useTestApi ? new Uri("https://shopinbit.solution360.dev/store-api/") : new Uri("https://shopinbit.com/store-api/");
ShopWareApiClient shopWareApiClient = new(HttpClientFactory.NewHttpClient(() => uri, Mode.DefaultCircuit), apiKey);

BuyAnythingClient buyAnythingClient = new(shopWareApiClient, useTestApi);
HostedServices.Register<BuyAnythingManager>(() => new BuyAnythingManager(DataDir, TimeSpan.FromSeconds(5), buyAnythingClient, useTestApi), "BuyAnythingManager");
var buyAnythingManager = HostedServices.Get<BuyAnythingManager>();
await buyAnythingManager.EnsureConversationsAreLoadedAsync(cancel).ConfigureAwait(false);
await buyAnythingManager.EnsureCountriesAreLoadedAsync(cancel).ConfigureAwait(false);

await HostedServices.StartAllAsync(cancel).ConfigureAwait(false);

Logger.LogInfo("Start synchronizing filters...");
Expand All @@ -253,6 +260,20 @@ public async Task InitializeNoWalletAsync(TerminateService terminateService, Can
}
}

private async Task CreateSleepInhibitorAsync()
{
SleepInhibitor? sleepInhibitor = await SleepInhibitor.CreateAsync(HostedServices.Get<CoinJoinManager>()).ConfigureAwait(false);

if (sleepInhibitor is not null)
{
HostedServices.Register<SleepInhibitor>(() => sleepInhibitor, "Sleep Inhibitor");
}
else
{
Logger.LogInfo("Sleep Inhibitor is not available on this platform.");
}
}

private async Task StartRpcServerAsync(TerminateService terminateService, CancellationToken cancel)
{
// HttpListener doesn't support onion services as prefix and for that reason we have no alternative
Expand Down

0 comments on commit d7669e8

Please sign in to comment.