Skip to content

Commit 1170171

Browse files
authored
Frontend - Sentry sync events & transactions fix model #965
Frontend - Sentry sync events & transactions fix model
2 parents 78f59bb + 5bd5d9a commit 1170171

24 files changed

+354
-57
lines changed

frontend/package-lock.json

Lines changed: 75 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "frontend",
3-
"version": "1.0.44",
3+
"version": "1.0.59",
44
"scripts": {
55
"install:deps": "npm install",
66
"start": "npm install && ng serve --configuration local --open",
@@ -53,6 +53,7 @@
5353
"eigen": "^0.2.2",
5454
"express": "^4.18.2",
5555
"firebase": "^11.0.1",
56+
"jszip": "^3.10.1",
5657
"mathjs": "^12.3.0",
5758
"mina-signer": "^3.0.7",
5859
"ngx-json-viewer": "^3.2.1",

frontend/src/app/core/helpers/file-progress.helper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class AssetMonitor {
3232
url: resource.toString(),
3333
startTime,
3434
progress: 0,
35-
totalSize: 27355980,
35+
totalSize: 30111552,
3636
status: 'pending',
3737
endTime: 0,
3838
duration: 0,

frontend/src/app/core/services/rust.service.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ export class RustService {
1818
this.node = node;
1919
}
2020

21+
get activeNodeIsWebNode(): boolean {
22+
return this.node.isWebNode;
23+
}
24+
2125
get URL(): string {
2226
return this.node.url;
2327
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import { inject, Injectable } from '@angular/core';
2+
import { NodesOverviewLedger, NodesOverviewLedgerStepState } from '@shared/types/nodes/dashboard/nodes-overview-ledger.type';
3+
import * as Sentry from '@sentry/angular';
4+
import { NodesOverviewBlock, NodesOverviewNodeBlockStatus } from '@shared/types/nodes/dashboard/nodes-overview-block.type';
5+
import { lastItem, ONE_BILLION } from '@openmina/shared';
6+
import { RustService } from '@core/services/rust.service';
7+
8+
@Injectable({
9+
providedIn: 'root',
10+
})
11+
export class SentryService {
12+
13+
private ledgerIsSynced: boolean = false;
14+
private blockIsSynced: boolean = false;
15+
private rustService: RustService = inject(RustService);
16+
17+
updateLedgerSyncStatus(ledger: NodesOverviewLedger): void {
18+
if (this.ledgerIsSynced) {
19+
return;
20+
}
21+
if (ledger.rootStaged.state === NodesOverviewLedgerStepState.SUCCESS) {
22+
this.ledgerIsSynced = true;
23+
const syncDetails = {
24+
stakingLedger: {
25+
fetchHashes: ledger.stakingEpoch.snarked.fetchHashesDuration + 's',
26+
fetchAccounts: ledger.stakingEpoch.snarked.fetchAccountsDuration + 's',
27+
},
28+
nextEpochLedger: {
29+
fetchHashes: ledger.nextEpoch.snarked.fetchHashesDuration + 's',
30+
fetchAccounts: ledger.nextEpoch.snarked.fetchAccountsDuration + 's',
31+
},
32+
snarkedRootLedger: {
33+
fetchHashes: ledger.rootSnarked.snarked.fetchHashesDuration + 's',
34+
fetchAccounts: ledger.rootSnarked.snarked.fetchAccountsDuration + 's',
35+
},
36+
stagedRootLedger: {
37+
fetchParts: ledger.rootStaged.staged.fetchPartsDuration + 's',
38+
reconstruct: ledger.rootStaged.staged.reconstructDuration + 's',
39+
},
40+
};
41+
42+
const syncedIn = Math.round((ledger.rootStaged.staged.reconstructEnd - ledger.stakingEpoch.snarked.fetchHashesStart) / ONE_BILLION);
43+
44+
Sentry.captureMessage(`Ledger synced in ${syncedIn}s`, {
45+
level: 'info',
46+
tags: { type: 'webnode', subType: 'sync.ledger' },
47+
contexts: { ledger: syncDetails },
48+
});
49+
}
50+
}
51+
52+
updateBlockSyncStatus(blocks: NodesOverviewBlock[], startTime: number): void {
53+
if (this.blockIsSynced || !this.rustService.activeNodeIsWebNode) {
54+
return;
55+
}
56+
57+
const blocksSynced = blocks.every(b => b.status === NodesOverviewNodeBlockStatus.APPLIED);
58+
if (blocksSynced && blocks[0]) {
59+
this.blockIsSynced = true;
60+
blocks = blocks.slice(1);
61+
const bestTipBlock = blocks[0].height;
62+
const root = lastItem(blocks).height;
63+
Sentry.captureMessage(`Last 290 blocks synced in ${Math.round((Date.now() - startTime) / 1000)}s`, {
64+
level: 'info',
65+
tags: { type: 'webnode', subType: 'sync.block' },
66+
contexts: { blocks: { bestTipBlock, root } },
67+
});
68+
}
69+
}
70+
}

frontend/src/app/features/benchmarks/wallets/benchmarks-wallets.component.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
<mina-benchmarks-wallets-toolbar></mina-benchmarks-wallets-toolbar>
22
<div class="h-minus-xl flex-column">
3-
<mina-benchmarks-wallets-zkapp-toolbar *ngIf="!isWebNode"></mina-benchmarks-wallets-zkapp-toolbar>
4-
<div [class.h-minus-xl]="!isWebNode"
3+
@if (!isWebNode) {
4+
<mina-benchmarks-wallets-zkapp-toolbar></mina-benchmarks-wallets-zkapp-toolbar>
5+
}
6+
<div [ngClass]="isWebNode ? 'h-100' : 'h-minus-xl'"
57
class="flex-column">
68
<mina-benchmarks-wallets-table></mina-benchmarks-wallets-table>
79
</div>

frontend/src/app/features/benchmarks/wallets/benchmarks-wallets.effects.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Injectable } from '@angular/core';
22
import { MinaState, selectMinaState } from '@app/app.setup';
33
import { Actions, createEffect, ofType } from '@ngrx/effects';
44
import { Effect } from '@openmina/shared';
5-
import { EMPTY, forkJoin, map, switchMap } from 'rxjs';
5+
import { combineLatest, EMPTY, map, switchMap } from 'rxjs';
66
import { Store } from '@ngrx/store';
77
import {
88
BENCHMARKS_WALLETS_CLOSE,
@@ -11,8 +11,11 @@ import {
1111
BENCHMARKS_WALLETS_GET_WALLETS,
1212
BENCHMARKS_WALLETS_GET_WALLETS_SUCCESS,
1313
BENCHMARKS_WALLETS_SEND_TX_SUCCESS,
14-
BENCHMARKS_WALLETS_SEND_TXS, BENCHMARKS_WALLETS_SEND_ZKAPPS, BENCHMARKS_WALLETS_SEND_ZKAPPS_SUCCESS,
15-
BenchmarksWalletsActions, BenchmarksWalletsClose,
14+
BENCHMARKS_WALLETS_SEND_TXS,
15+
BENCHMARKS_WALLETS_SEND_ZKAPPS,
16+
BENCHMARKS_WALLETS_SEND_ZKAPPS_SUCCESS,
17+
BenchmarksWalletsActions,
18+
BenchmarksWalletsClose,
1619
BenchmarksWalletsGetWallets,
1720
BenchmarksWalletsSendTxs,
1821
} from '@benchmarks/wallets/benchmarks-wallets.actions';
@@ -74,7 +77,7 @@ export class BenchmarksWalletsEffects extends MinaRustBaseEffect<BenchmarksWalle
7477
this.getAllTxs$ = createEffect(() => this.actions$.pipe(
7578
ofType(BENCHMARKS_WALLETS_GET_ALL_TXS),
7679
switchMap(() =>
77-
forkJoin([
80+
combineLatest([
7881
this.mempoolService.getTransactionPool(),
7982
this.benchmarksService.getAllIncludedTransactions(),
8083
]),

frontend/src/app/features/block-production/won-slots/block-production-won-slots.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@if (isPending || nodeIsBootstrapping || isCalculatingVRF || isLoading) {
1+
@if ((isPending || nodeIsBootstrapping || isCalculatingVRF || isLoading) && emptySlots) {
22
<div class="w-100 h-100 fx-col-full-cent"
33
@fadeInOut>
44
<mina-loading-spinner [size]="50" [borderWidth]="2"></mina-loading-spinner>

frontend/src/app/features/block-production/won-slots/block-production-won-slots.component.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export class BlockProductionWonSlotsComponent extends StoreDispatcher implements
3838
total: number;
3939
};
4040
epoch: number;
41-
emptySlots: boolean = false;
41+
emptySlots: boolean = true;
4242
isLoading: boolean = true;
4343

4444
constructor(protected el: ElementRef) { super(); }
@@ -82,8 +82,9 @@ export class BlockProductionWonSlotsComponent extends StoreDispatcher implements
8282

8383
private listenToActiveEpoch(): void {
8484
this.select(BlockProductionWonSlotsSelectors.epoch, (activeEpoch) => {
85-
this.epoch = activeEpoch.epochNumber;
85+
this.epoch = activeEpoch?.epochNumber;
8686
this.vrfStats = activeEpoch.vrfStats;
87+
this.isCalculatingVRF = activeEpoch.vrfStats?.evaluated < activeEpoch.vrfStats?.total;
8788
this.detect();
8889
});
8990
}

frontend/src/app/features/block-production/won-slots/block-production-won-slots.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export class BlockProductionWonSlotsService {
2626
}
2727
const attemptsSlots = response.attempts.map((attempt: Attempt) => {
2828
attempt.won_slot.slot_time = Math.floor(attempt.won_slot.slot_time / ONE_MILLION); // converted to milliseconds
29-
attempt.active = BlockProductionWonSlotsService.getActive(attempt);
29+
attempt.active = this.getActive(attempt);
3030
let slot = {
3131
epoch: attempt.won_slot.epoch,
3232
message: this.getMessage(attempt),
@@ -114,7 +114,7 @@ export class BlockProductionWonSlotsService {
114114
);
115115
}
116116

117-
private static getActive(attempt: Attempt): boolean {
117+
private getActive(attempt: Attempt): boolean {
118118
const slotTime = attempt.won_slot.slot_time;
119119
const now = Date.now();
120120
return slotTime <= now && (now < 3 * 60 * 1000 + slotTime) && !attempt.times?.discarded;

0 commit comments

Comments
 (0)