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

Created Dkg Web Node #25

Merged
merged 7 commits into from
Jul 13, 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
51 changes: 45 additions & 6 deletions dkg-nodes.sln
Original file line number Diff line number Diff line change
Expand Up @@ -13,44 +13,83 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "dkgLibrary", "dkg\dkgLibrar
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "dkgNodesTests", "dkgNodesTests\dkgNodesTests.csproj", "{598AFFF1-61B6-43FD-B170-9E44CC6D7EC4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dkgNodeLibrary", "dkgNodeLibrary\dkgNodeLibrary.csproj", "{B84032D8-E234-4AE6-9381-894EDC2847C3}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "dkgNodeLibrary", "dkgNodeLibrary\dkgNodeLibrary.csproj", "{B84032D8-E234-4AE6-9381-894EDC2847C3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dkgNode", "dkgNode\dkgNode.csproj", "{3E85DFC2-CD63-432F-A924-0E2EA6A754BC}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "dkgNode", "dkgNode\dkgNode.csproj", "{3E85DFC2-CD63-432F-A924-0E2EA6A754BC}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "dkgWebNode", "dkgWebNode\dkgWebNode.csproj", "{B72F9CFC-6565-4009-814B-D3BBD4F26964}"
ProjectSection(ProjectDependencies) = postProject
{B84032D8-E234-4AE6-9381-894EDC2847C3} = {B84032D8-E234-4AE6-9381-894EDC2847C3}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D26E4904-CD44-4E64-9044-158C48D520BD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D26E4904-CD44-4E64-9044-158C48D520BD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D26E4904-CD44-4E64-9044-158C48D520BD}.Debug|x64.ActiveCfg = Debug|Any CPU
{D26E4904-CD44-4E64-9044-158C48D520BD}.Debug|x64.Build.0 = Debug|Any CPU
{D26E4904-CD44-4E64-9044-158C48D520BD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D26E4904-CD44-4E64-9044-158C48D520BD}.Release|Any CPU.Build.0 = Release|Any CPU
{357381D9-5241-448F-A5AC-40E90D2A19AB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{357381D9-5241-448F-A5AC-40E90D2A19AB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{357381D9-5241-448F-A5AC-40E90D2A19AB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{357381D9-5241-448F-A5AC-40E90D2A19AB}.Release|Any CPU.Build.0 = Release|Any CPU
{D26E4904-CD44-4E64-9044-158C48D520BD}.Release|x64.ActiveCfg = Release|x64
{D26E4904-CD44-4E64-9044-158C48D520BD}.Release|x64.Build.0 = Release|x64
{357381D9-5241-448F-A5AC-40E90D2A19AB}.Debug|Any CPU.ActiveCfg = Debug|x64
{357381D9-5241-448F-A5AC-40E90D2A19AB}.Debug|x64.ActiveCfg = Debug|x64
{357381D9-5241-448F-A5AC-40E90D2A19AB}.Release|Any CPU.ActiveCfg = Release|x64
{357381D9-5241-448F-A5AC-40E90D2A19AB}.Release|x64.ActiveCfg = Release|x64
{ABF1E862-AE0A-47BC-9A3C-60C9C9ACBAA9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{ABF1E862-AE0A-47BC-9A3C-60C9C9ACBAA9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ABF1E862-AE0A-47BC-9A3C-60C9C9ACBAA9}.Debug|x64.ActiveCfg = Debug|Any CPU
{ABF1E862-AE0A-47BC-9A3C-60C9C9ACBAA9}.Debug|x64.Build.0 = Debug|Any CPU
{ABF1E862-AE0A-47BC-9A3C-60C9C9ACBAA9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ABF1E862-AE0A-47BC-9A3C-60C9C9ACBAA9}.Release|Any CPU.Build.0 = Release|Any CPU
{ABF1E862-AE0A-47BC-9A3C-60C9C9ACBAA9}.Release|x64.ActiveCfg = Release|Any CPU
{ABF1E862-AE0A-47BC-9A3C-60C9C9ACBAA9}.Release|x64.Build.0 = Release|Any CPU
{8C58697D-1A09-40EB-B840-CDB9BBE49FA4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8C58697D-1A09-40EB-B840-CDB9BBE49FA4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8C58697D-1A09-40EB-B840-CDB9BBE49FA4}.Debug|x64.ActiveCfg = Debug|Any CPU
{8C58697D-1A09-40EB-B840-CDB9BBE49FA4}.Debug|x64.Build.0 = Debug|Any CPU
{8C58697D-1A09-40EB-B840-CDB9BBE49FA4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8C58697D-1A09-40EB-B840-CDB9BBE49FA4}.Release|Any CPU.Build.0 = Release|Any CPU
{8C58697D-1A09-40EB-B840-CDB9BBE49FA4}.Release|x64.ActiveCfg = Release|Any CPU
{8C58697D-1A09-40EB-B840-CDB9BBE49FA4}.Release|x64.Build.0 = Release|Any CPU
{598AFFF1-61B6-43FD-B170-9E44CC6D7EC4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{598AFFF1-61B6-43FD-B170-9E44CC6D7EC4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{598AFFF1-61B6-43FD-B170-9E44CC6D7EC4}.Debug|x64.ActiveCfg = Debug|Any CPU
{598AFFF1-61B6-43FD-B170-9E44CC6D7EC4}.Debug|x64.Build.0 = Debug|Any CPU
{598AFFF1-61B6-43FD-B170-9E44CC6D7EC4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{598AFFF1-61B6-43FD-B170-9E44CC6D7EC4}.Release|Any CPU.Build.0 = Release|Any CPU
{598AFFF1-61B6-43FD-B170-9E44CC6D7EC4}.Release|x64.ActiveCfg = Release|Any CPU
{598AFFF1-61B6-43FD-B170-9E44CC6D7EC4}.Release|x64.Build.0 = Release|Any CPU
{B84032D8-E234-4AE6-9381-894EDC2847C3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B84032D8-E234-4AE6-9381-894EDC2847C3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B84032D8-E234-4AE6-9381-894EDC2847C3}.Debug|x64.ActiveCfg = Debug|Any CPU
{B84032D8-E234-4AE6-9381-894EDC2847C3}.Debug|x64.Build.0 = Debug|Any CPU
{B84032D8-E234-4AE6-9381-894EDC2847C3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B84032D8-E234-4AE6-9381-894EDC2847C3}.Release|Any CPU.Build.0 = Release|Any CPU
{B84032D8-E234-4AE6-9381-894EDC2847C3}.Release|x64.ActiveCfg = Release|Any CPU
{B84032D8-E234-4AE6-9381-894EDC2847C3}.Release|x64.Build.0 = Release|Any CPU
{3E85DFC2-CD63-432F-A924-0E2EA6A754BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3E85DFC2-CD63-432F-A924-0E2EA6A754BC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3E85DFC2-CD63-432F-A924-0E2EA6A754BC}.Debug|x64.ActiveCfg = Debug|Any CPU
{3E85DFC2-CD63-432F-A924-0E2EA6A754BC}.Debug|x64.Build.0 = Debug|Any CPU
{3E85DFC2-CD63-432F-A924-0E2EA6A754BC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3E85DFC2-CD63-432F-A924-0E2EA6A754BC}.Release|Any CPU.Build.0 = Release|Any CPU
{3E85DFC2-CD63-432F-A924-0E2EA6A754BC}.Release|x64.ActiveCfg = Release|Any CPU
{3E85DFC2-CD63-432F-A924-0E2EA6A754BC}.Release|x64.Build.0 = Release|Any CPU
{B72F9CFC-6565-4009-814B-D3BBD4F26964}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B72F9CFC-6565-4009-814B-D3BBD4F26964}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B72F9CFC-6565-4009-814B-D3BBD4F26964}.Debug|x64.ActiveCfg = Debug|x64
{B72F9CFC-6565-4009-814B-D3BBD4F26964}.Debug|x64.Build.0 = Debug|x64
{B72F9CFC-6565-4009-814B-D3BBD4F26964}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B72F9CFC-6565-4009-814B-D3BBD4F26964}.Release|Any CPU.Build.0 = Release|Any CPU
{B72F9CFC-6565-4009-814B-D3BBD4F26964}.Release|x64.ActiveCfg = Release|x64
{B72F9CFC-6565-4009-814B-D3BBD4F26964}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.

namespace dkgServiceNode.Constants
namespace dkgCommon.Constants
{
public enum RStatus
{
Expand Down
12 changes: 3 additions & 9 deletions dkgNode/Worker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,10 @@

namespace dkgNode
{
public class DkgNodeWorker : BackgroundService
public class DkgNodeWorker(DkgNodeConfig config, ILogger<DkgNodeService> logger, bool dos2 = false, bool dos3 = false) : BackgroundService
{
internal DkgNodeService Service;
internal int PollingInterval;

public DkgNodeWorker(DkgNodeConfig config, ILogger<DkgNodeService> logger, bool dos2 = false, bool dos3 = false)
{
PollingInterval = config.PollingInterval;
Service = new DkgNodeService(config, logger,dos2, dos3);
}
internal DkgNodeService Service = new(config, logger, dos2, dos3);
internal int PollingInterval = config.PollingInterval;

protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
Expand Down
13 changes: 10 additions & 3 deletions dkgNodeLibrary/Services/DkgNodeService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
using System.Text;
using System.Text.Json;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.DependencyInjection;

using dkg.share;
using dkg.group;
Expand All @@ -50,16 +51,19 @@
public void SetStatus(NStatus status)
{
Status = status;
NotifyDkgStateChanged();
}
public void SetStatusAndRound(NStatus status, int round)
{
Status = status;
Round = round;
NotifyDkgStateChanged();
}
public void SetStatusClearRound(NStatus status)
{
Status = status;
Round = null;
NotifyDkgStateChanged();
}

// ...
Expand Down Expand Up @@ -92,15 +96,17 @@
internal bool dieOnStep2 = false;
internal bool dieOnStep3 = false;

public DkgNodeService(DkgNodeConfig config, ILogger<DkgNodeService> logger, bool dos2 = false, bool dos3 = false)
public event Action? OnDkgChange;
private void NotifyDkgStateChanged() => OnDkgChange?.Invoke();
public DkgNodeService(DkgNodeConfig config, ILogger logger, bool dos2 = false, bool dos3 = false)

Check warning on line 101 in dkgNodeLibrary/Services/DkgNodeService.cs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest

Non-nullable property 'PrivateKey' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 101 in dkgNodeLibrary/Services/DkgNodeService.cs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest

Non-nullable property 'PublicKey' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 101 in dkgNodeLibrary/Services/DkgNodeService.cs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest

Non-nullable property 'PrivateKey' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 101 in dkgNodeLibrary/Services/DkgNodeService.cs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest

Non-nullable property 'PublicKey' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 101 in dkgNodeLibrary/Services/DkgNodeService.cs

View workflow job for this annotation

GitHub Actions / Test on windows-latest

Non-nullable property 'PrivateKey' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 101 in dkgNodeLibrary/Services/DkgNodeService.cs

View workflow job for this annotation

GitHub Actions / Test on windows-latest

Non-nullable property 'PublicKey' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 101 in dkgNodeLibrary/Services/DkgNodeService.cs

View workflow job for this annotation

GitHub Actions / Test on windows-latest

Non-nullable property 'PrivateKey' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 101 in dkgNodeLibrary/Services/DkgNodeService.cs

View workflow job for this annotation

GitHub Actions / Test on windows-latest

Non-nullable property 'PublicKey' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 101 in dkgNodeLibrary/Services/DkgNodeService.cs

View workflow job for this annotation

GitHub Actions / Test on macos-latest

Non-nullable property 'PrivateKey' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 101 in dkgNodeLibrary/Services/DkgNodeService.cs

View workflow job for this annotation

GitHub Actions / Test on macos-latest

Non-nullable property 'PublicKey' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 101 in dkgNodeLibrary/Services/DkgNodeService.cs

View workflow job for this annotation

GitHub Actions / Test on macos-latest

Non-nullable property 'PrivateKey' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 101 in dkgNodeLibrary/Services/DkgNodeService.cs

View workflow job for this annotation

GitHub Actions / Test on macos-latest

Non-nullable property 'PublicKey' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
{
dieOnStep2 = dos2;
dieOnStep3 = dos3;

Config = config;
Logger = logger;

logger.LogInformation("'{Name}': creating", Name);
logger.LogInformation("'{Name}' created.", Name);

G = new Secp256k1Group();

Expand Down Expand Up @@ -315,7 +321,8 @@

public async Task<StatusResponse> ReportStatus(HttpClient httpClient, string[]? data)
{
var statusResponse = new StatusResponse((int)(Round == null ? 0 : Round), Failed);
int roundId = (int)(Round == null ? 0 : Round);
var statusResponse = new StatusResponse(roundId, Failed);
string r = $"[status '{NodeStatusConstants.GetNodeStatusById(Status).Name}', round '{(Round == null ? 0: Round)}']";

var report = new StatusReport(Config.PublicKey!, Name, Round ?? 0, Status);
Expand Down
2 changes: 1 addition & 1 deletion dkgNodesTests/RoundStatus.Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.

using dkgServiceNode.Constants;
using dkgCommon.Constants;

namespace dkgNodesTests
{
Expand Down
3 changes: 1 addition & 2 deletions dkgServiceNode/Controllers/NodesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

using dkgCommon.Constants;
using dkgCommon.Models;
using dkgServiceNode.Constants;
using dkgServiceNode.Data;
using dkgServiceNode.Models;
using dkgServiceNode.Services.Authorization;
Expand All @@ -34,7 +33,7 @@
using Microsoft.EntityFrameworkCore;
using System.Text;
using static dkgCommon.Constants.NodeStatusConstants;
using static dkgServiceNode.Constants.RoundStatusConstants;
using static dkgCommon.Constants.RoundStatusConstants;

using Solnet.Wallet;
using System.Xml.Linq;
Expand Down
1 change: 0 additions & 1 deletion dkgServiceNode/Controllers/RoundsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

using dkgCommon.Constants;
using dkgCommon.Models;
using dkgServiceNode.Constants;
using dkgServiceNode.Data;
using dkgServiceNode.Models;
using dkgServiceNode.Services.NodeComparer;
Expand Down
2 changes: 1 addition & 1 deletion dkgServiceNode/Models/Round.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.

using dkgServiceNode.Constants;
using dkgCommon.Constants;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text.Json.Serialization;
Expand Down
1 change: 1 addition & 0 deletions dkgServiceNode/dkgServiceNode.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<UserSecretsId>31a6b209-5ed4-4ef7-8ee7-1dd105702a4e</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath>
<Platforms>AnyCPU;x64</Platforms>
</PropertyGroup>

<ItemGroup>
Expand Down
5 changes: 5 additions & 0 deletions dkgWebNode/App.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@using dkgWebNode.Pages
<LayoutView Layout="@typeof(MainLayout)">
<Home />
</LayoutView>

11 changes: 11 additions & 0 deletions dkgWebNode/Layout/MainLayout.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@inherits LayoutComponentBase
<div class="page">
<main>
<article class="content px-4">
@Body
</article>
</main>
</div>

<MudThemeProvider />
<MudDialogProvider />
77 changes: 77 additions & 0 deletions dkgWebNode/Layout/MainLayout.razor.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
.page {
position: relative;
display: flex;
flex-direction: column;
}

main {
flex: 1;
}

.sidebar {
background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%);
}

.top-row {
background-color: #f7f7f7;
border-bottom: 1px solid #d6d5d5;
justify-content: flex-end;
height: 3.5rem;
display: flex;
align-items: center;
}

.top-row ::deep a, .top-row ::deep .btn-link {
white-space: nowrap;
margin-left: 1.5rem;
text-decoration: none;
}

.top-row ::deep a:hover, .top-row ::deep .btn-link:hover {
text-decoration: underline;
}

.top-row ::deep a:first-child {
overflow: hidden;
text-overflow: ellipsis;
}

@media (max-width: 640.98px) {
.top-row {
justify-content: space-between;
}

.top-row ::deep a, .top-row ::deep .btn-link {
margin-left: 0;
}
}

@media (min-width: 641px) {
.page {
flex-direction: row;
}

.sidebar {
width: 250px;
height: 100vh;
position: sticky;
top: 0;
}

.top-row {
position: sticky;
top: 0;
z-index: 1;
}

.top-row.auth ::deep a:first-child {
flex: 1;
text-align: right;
width: 0;
}

.top-row, article {
padding-left: 2rem !important;
padding-right: 1.5rem !important;
}
}
8 changes: 8 additions & 0 deletions dkgWebNode/Models/DkgState.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace dkgWebNode.Models
{
public class DkgState
{
public string NodeState { get; set; } = "Unknown";
public string RoundId { get; set; } = "Unknown";
}
}
Loading
Loading