Skip to content

Commit 06aa86b

Browse files
committed
Nethermind UI
1 parent 7d51c08 commit 06aa86b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+26253
-28
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,3 +404,5 @@ FodyWeavers.xsd
404404
## Nethermind
405405
keystore/
406406
/.githooks
407+
bundle.js
408+
src/Nethermind/Nethermind.Runner/wwwroot/js.map

Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ ARG CI
99
ARG COMMIT_HASH
1010
ARG TARGETARCH
1111

12+
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
13+
RUN apt-get install -y nodejs
14+
RUN npm install -g yarn
15+
1216
COPY src/Nethermind src/Nethermind
1317

1418
RUN arch=$([ "$TARGETARCH" = "amd64" ] && echo "x64" || echo "$TARGETARCH") && \

Dockerfile.chiseled

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ ARG CI
99
ARG COMMIT_HASH
1010
ARG TARGETARCH
1111

12+
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
13+
RUN apt-get install -y nodejs
14+
RUN npm install -g yarn
15+
1216
COPY src/Nethermind src/Nethermind
1317

1418
RUN arch=$([ "$TARGETARCH" = "amd64" ] && echo "x64" || echo "$TARGETARCH") && \

src/Nethermind/Nethermind.Blockchain/BlockTree.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1580,6 +1580,7 @@ void SetTotalDifficultyDeep(BlockHeader current)
15801580
public event EventHandler<BlockEventArgs>? NewSuggestedBlock;
15811581

15821582
public event EventHandler<BlockEventArgs>? NewHeadBlock;
1583+
public event EventHandler<IBlockTree.ForkChoice>? OnForkChoiceUpdated;
15831584

15841585
/// <summary>
15851586
/// Can delete a slice of the chain (usually invoked when the chain is corrupted in the DB).
@@ -1704,6 +1705,11 @@ public void ForkChoiceUpdated(Hash256? finalizedBlockHash, Hash256? safeBlockHas
17041705
_metadataDb.Set(MetadataDbKeys.FinalizedBlockHash, Rlp.Encode(FinalizedHash!).Bytes);
17051706
_metadataDb.Set(MetadataDbKeys.SafeBlockHash, Rlp.Encode(SafeHash!).Bytes);
17061707
}
1708+
1709+
var finalizedNumber = FindHeader(FinalizedHash, BlockTreeLookupOptions.DoNotCreateLevelIfMissing)?.Number;
1710+
var safeNumber = FindHeader(safeBlockHash, BlockTreeLookupOptions.DoNotCreateLevelIfMissing)?.Number;
1711+
1712+
OnForkChoiceUpdated?.Invoke(this, new(Head, safeNumber ?? 0, finalizedNumber ?? 0));
17071713
}
17081714
}
17091715
}

src/Nethermind/Nethermind.Blockchain/BlockTreeOverlay.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,21 @@ public event EventHandler<OnUpdateMainChainArgs>? OnUpdateMainChain
217217
}
218218
}
219219

220+
public event EventHandler<IBlockTree.ForkChoice> OnForkChoiceUpdated
221+
{
222+
add
223+
{
224+
_baseTree.OnForkChoiceUpdated += value;
225+
_overlayTree.OnForkChoiceUpdated += value;
226+
}
227+
228+
remove
229+
{
230+
_baseTree.OnForkChoiceUpdated -= value;
231+
_overlayTree.OnForkChoiceUpdated -= value;
232+
}
233+
}
234+
220235
public int DeleteChainSlice(in long startNumber, long? endNumber = null, bool force = false) =>
221236
_overlayTree.DeleteChainSlice(startNumber, endNumber, force);
222237

src/Nethermind/Nethermind.Blockchain/IBlockTree.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ AddBlockResult Insert(Block block, BlockTreeInsertBlockOptions insertBlockOption
178178
/// the whole branch.
179179
/// </summary>
180180
event EventHandler<OnUpdateMainChainArgs> OnUpdateMainChain;
181+
event EventHandler<ForkChoice> OnForkChoiceUpdated;
181182

182183
int DeleteChainSlice(in long startNumber, long? endNumber = null, bool force = false);
183184

@@ -195,5 +196,12 @@ AddBlockResult Insert(Block block, BlockTreeInsertBlockOptions insertBlockOption
195196
/// Before sync pivot, there is no guarantee that blocks and receipts are available or continuous.
196197
/// </summary>
197198
(long BlockNumber, Hash256 BlockHash) SyncPivot { get; set; }
199+
200+
public readonly struct ForkChoice(Block? head, long safe, long finalized)
201+
{
202+
public readonly Block? Head => head;
203+
public readonly long Safe => safe;
204+
public readonly long Finalized => finalized;
205+
}
198206
}
199207
}

src/Nethermind/Nethermind.Blockchain/ReadOnlyBlockTree.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,12 @@ public event EventHandler<OnUpdateMainChainArgs>? OnUpdateMainChain
153153
remove { }
154154
}
155155

156+
event EventHandler<IBlockTree.ForkChoice> IBlockTree.OnForkChoiceUpdated
157+
{
158+
add { }
159+
remove { }
160+
}
161+
156162
public int DeleteChainSlice(in long startNumber, long? endNumber = null, bool force = false)
157163
{
158164
var bestKnownNumber = BestKnownNumber;

src/Nethermind/Nethermind.Consensus/Processing/BlockchainProcessor.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ public sealed class BlockchainProcessor : IBlockchainProcessor, IBlockProcessing
7777
private readonly Stopwatch _stopwatch = new();
7878

7979
public event EventHandler<IBlockchainProcessor.InvalidBlockEventArgs>? InvalidBlock;
80+
public event EventHandler<BlockStatistics>? NewProcessingStatistics;
8081

8182
/// <summary>
8283
///
@@ -106,8 +107,12 @@ public BlockchainProcessor(
106107
_blockTree.NewHeadBlock += OnNewHeadBlock;
107108

108109
_stats = new ProcessingStats(stateReader, _logger);
110+
_stats.NewProcessingStatistics += OnNewProcessingStatistics;
109111
}
110112

113+
private void OnNewProcessingStatistics(object? sender, BlockStatistics stats)
114+
=> NewProcessingStatistics?.Invoke(sender, stats);
115+
111116
private void OnNewHeadBlock(object? sender, BlockEventArgs e)
112117
{
113118
_lastProcessedBlock = DateTime.UtcNow;
@@ -704,6 +709,7 @@ private bool RunSimpleChecksAheadOfProcessing(Block suggestedBlock, ProcessingOp
704709
public void Dispose()
705710
{
706711
_recoveryComplete = true;
712+
_stats.NewProcessingStatistics -= OnNewProcessingStatistics;
707713
_recoveryQueue.Writer.TryComplete();
708714
_blockQueue.Writer.TryComplete();
709715
_loopCancellationSource?.Dispose();

src/Nethermind/Nethermind.Consensus/Processing/IBlockchainProcessor.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public interface IBlockchainProcessor : IDisposable
2121
bool IsProcessingBlocks(ulong? maxProcessingInterval);
2222

2323
event EventHandler<InvalidBlockEventArgs> InvalidBlock;
24+
event EventHandler<BlockStatistics> NewProcessingStatistics;
2425

2526
public class InvalidBlockEventArgs : EventArgs
2627
{

src/Nethermind/Nethermind.Consensus/Processing/OneTimeProcessor.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public bool IsProcessingBlocks(ulong? maxProcessingInterval)
5252
public event EventHandler<BlockProcessedEventArgs> BlockProcessed;
5353
public event EventHandler<BlockProcessedEventArgs> BlockInvalid;
5454
public event EventHandler<IBlockchainProcessor.InvalidBlockEventArgs>? InvalidBlock;
55+
public event EventHandler<BlockStatistics> NewProcessingStatistics;
5556
#pragma warning restore 67
5657

5758
public void Dispose()

0 commit comments

Comments
 (0)