Today
Date: Tue, 31 Oct 2023 15:06:40 +0100
Subject: [PATCH 51/53] fix typo
---
src/app/components/dashboard/dashboard.component.html | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/app/components/dashboard/dashboard.component.html b/src/app/components/dashboard/dashboard.component.html
index 994e9d49..84b81852 100644
--- a/src/app/components/dashboard/dashboard.component.html
+++ b/src/app/components/dashboard/dashboard.component.html
@@ -301,7 +301,7 @@
Today
Today
Date: Fri, 3 Nov 2023 08:04:33 +0100
Subject: [PATCH 52/53] replace hardcoded slots and epoch data with config
---
android/app/build.gradle | 2 +-
.../dashboard/dashboard.component.ts | 2 +-
src/app/controllers/OverviewController.ts | 71 +++++++++++--------
src/app/models/StorageTypes.ts | 1 +
.../validatordetail/validatordetail.page.ts | 6 +-
src/app/tab-dashboard/tab-dashboard.page.ts | 3 +-
src/app/utils/BlockUtils.ts | 2 +-
src/app/utils/NetworkData.ts | 7 ++
8 files changed, 60 insertions(+), 34 deletions(-)
diff --git a/android/app/build.gradle b/android/app/build.gradle
index 23aa535b..ee949e5f 100644
--- a/android/app/build.gradle
+++ b/android/app/build.gradle
@@ -8,7 +8,7 @@ android {
namespace "in.beaconcha.mobile"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
- versionCode 105
+ versionCode 107
versionName "4.5.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
diff --git a/src/app/components/dashboard/dashboard.component.ts b/src/app/components/dashboard/dashboard.component.ts
index 57dd3cdc..c1a94a10 100644
--- a/src/app/components/dashboard/dashboard.component.ts
+++ b/src/app/components/dashboard/dashboard.component.ts
@@ -217,7 +217,7 @@ export class DashboardComponent implements OnInit {
epochToTimestamp(epoch: number) {
const network = this.api.getNetwork()
- return (network.genesisTs + epoch * 32 * 12) * 1000
+ return (network.genesisTs + epoch * network.slotPerEpoch * network.slotsTime) * 1000
}
updateActiveSyncCommitteeMessage(committee: SyncCommitteeResponse) {
diff --git a/src/app/controllers/OverviewController.ts b/src/app/controllers/OverviewController.ts
index 2ac0f95b..ccbea2a7 100644
--- a/src/app/controllers/OverviewController.ts
+++ b/src/app/controllers/OverviewController.ts
@@ -25,6 +25,7 @@ import { getValidatorQueryString, ValidatorState, Validator } from '../utils/Val
import { formatDate } from '@angular/common'
import { SyncCommitteesStatistics, SyncCommitteesStatisticsResponse } from '../requests/requests'
import { UnitconvService } from '../services/unitconv.service'
+import { ApiNetwork } from '../models/StorageTypes'
export type OverviewData = {
overallBalance: BigNumber
@@ -130,13 +131,14 @@ export default class OverviewController {
validators: Validator[],
currentEpoch: EpochResponse,
syncCommitteesStatsResponse = null,
- proposalLuckResponse: ProposalLuckResponse = null
+ proposalLuckResponse: ProposalLuckResponse = null,
+ network: ApiNetwork
) {
- return this.process(validators, currentEpoch, false, syncCommitteesStatsResponse, proposalLuckResponse)
+ return this.process(validators, currentEpoch, false, syncCommitteesStatsResponse, proposalLuckResponse, network)
}
- public processDetail(validators: Validator[], currentEpoch: EpochResponse) {
- return this.process(validators, currentEpoch, true, null, null)
+ public processDetail(validators: Validator[], currentEpoch: EpochResponse, network: ApiNetwork) {
+ return this.process(validators, currentEpoch, true, null, null, network)
}
private process(
@@ -144,7 +146,8 @@ export default class OverviewController {
currentEpoch: EpochResponse,
foreignValidator = false,
syncCommitteesStatsResponse = null,
- proposalLuckResponse: ProposalLuckResponse = null
+ proposalLuckResponse: ProposalLuckResponse = null,
+ network: ApiNetwork
): OverviewData {
if (!validators || validators.length <= 0 || currentEpoch == null) return null
@@ -261,7 +264,7 @@ export default class OverviewController {
consensusPerformance: consensusPerf,
executionPerformance: executionPerf,
combinedPerformance: combinedPerf,
- dashboardState: this.getDashboardState(validators, currentEpoch, foreignValidator),
+ dashboardState: this.getDashboardState(validators, currentEpoch, foreignValidator, network),
lazyLoadChart: true,
lazyChartValidators: getValidatorQueryString(validators, 2000, this.userMaxValidators - 1),
foreignValidator: foreignValidator,
@@ -272,7 +275,7 @@ export default class OverviewController {
apr: combinedPerf.apr,
currentSyncCommittee: currentSync ? currentSync.currentSyncCommittee : null,
nextSyncCommittee: nextSync ? nextSync.nextSyncCommittee : null,
- syncCommitteesStats: this.calculateSyncCommitteeStats(syncCommitteesStatsResponse),
+ syncCommitteesStats: this.calculateSyncCommitteeStats(syncCommitteesStatsResponse, network),
proposalLuckResponse: proposalLuckResponse,
withdrawalsEnabledForAll:
validators.filter((cur) => (cur.data.withdrawalcredentials.startsWith('0x01') ? true : false)).length == validatorCount,
@@ -567,7 +570,7 @@ export default class OverviewController {
return new BigNumber(performance.toString()).multipliedBy('1177').dividedBy(validatorDepositActive).decimalPlaces(1).toNumber()
}
- private getDashboardState(validators: Validator[], currentEpoch: EpochResponse, foreignValidator): DashboardStatus {
+ private getDashboardState(validators: Validator[], currentEpoch: EpochResponse, foreignValidator, network: ApiNetwork): DashboardStatus {
// collect data
const validatorCount = validators.length
const activeValidators = this.getActiveValidators(validators)
@@ -597,7 +600,7 @@ export default class OverviewController {
// The first one that matches will set the icon and its css as well as, if only one state matches, the extendedDescription
// handle slashed validators
- this.updateStateSlashed(dashboardStatus, slashedCount, validatorCount, foreignValidator, slashedValidators[0]?.data, currentEpoch)
+ this.updateStateSlashed(dashboardStatus, slashedCount, validatorCount, foreignValidator, slashedValidators[0]?.data, currentEpoch, network)
// handle offline validators
const offlineCount = validatorCount - activeValidatorCount - exitedValidatorsCount - slashedCount - awaitingCount - eligibilityCount
@@ -605,19 +608,27 @@ export default class OverviewController {
// handle awaiting activation validators
if (awaitingCount > 0) {
- this.updateStateAwaiting(dashboardStatus, awaitingCount, validatorCount, foreignValidator, awaitingActivation[0].data, currentEpoch)
+ this.updateStateAwaiting(dashboardStatus, awaitingCount, validatorCount, foreignValidator, awaitingActivation[0].data, currentEpoch, network)
}
// handle eligable validators
if (eligibilityCount > 0) {
- this.updateStateEligibility(dashboardStatus, eligibilityCount, validatorCount, foreignValidator, activationEligibility[0].data, currentEpoch)
+ this.updateStateEligibility(
+ dashboardStatus,
+ eligibilityCount,
+ validatorCount,
+ foreignValidator,
+ activationEligibility[0].data,
+ currentEpoch,
+ network
+ )
}
// handle exited validators
this.updateExitedState(dashboardStatus, exitedValidatorsCount, validatorCount, foreignValidator)
// handle ok state, always call last
- this.updateStateOk(dashboardStatus, activeValidatorCount, validatorCount, foreignValidator, activeValidators[0]?.data, currentEpoch)
+ this.updateStateOk(dashboardStatus, activeValidatorCount, validatorCount, foreignValidator, activeValidators[0]?.data, currentEpoch, network)
if (dashboardStatus.state == StateType.mixed) {
// remove extended description if more than one state is shown
@@ -632,12 +643,12 @@ export default class OverviewController {
return foreignValidator ? foreignText : myText
}
- private getExitingDescription(validatorResp: ValidatorResponse, currentEpoch: EpochResponse): Description {
+ private getExitingDescription(validatorResp: ValidatorResponse, currentEpoch: EpochResponse, network: ApiNetwork): Description {
if (!validatorResp.exitepoch) return { extendedDescriptionPre: null, extendedDescription: null }
const exitDiff = validatorResp.exitepoch - currentEpoch.epoch
const isExiting = exitDiff >= 0 && exitDiff < 6480 // ~ 1 month
- const exitingDate = isExiting ? this.getEpochDate(validatorResp.exitepoch, currentEpoch) : null
+ const exitingDate = isExiting ? this.getEpochDate(validatorResp.exitepoch, currentEpoch, network) : null
return {
extendedDescriptionPre: isExiting ? 'Exiting on ' : null,
@@ -659,7 +670,8 @@ export default class OverviewController {
validatorCount: number,
foreignValidator: boolean,
validatorResp: ValidatorResponse,
- currentEpoch: EpochResponse
+ currentEpoch: EpochResponse,
+ network: ApiNetwork
) {
if (slashedCount == 0) {
return
@@ -668,7 +680,7 @@ export default class OverviewController {
if (dashboardStatus.state == StateType.none) {
dashboardStatus.icon = 'alert-circle-outline'
dashboardStatus.iconCss = 'err'
- const exitingDescription = this.getExitingDescription(validatorResp, currentEpoch)
+ const exitingDescription = this.getExitingDescription(validatorResp, currentEpoch, network)
dashboardStatus.extendedDescriptionPre = exitingDescription.extendedDescriptionPre
dashboardStatus.extendedDescription = exitingDescription.extendedDescription
dashboardStatus.state = StateType.slashed
@@ -690,14 +702,15 @@ export default class OverviewController {
validatorCount: number,
foreignValidator: boolean,
awaitingActivation: ValidatorResponse,
- currentEpoch: EpochResponse
+ currentEpoch: EpochResponse,
+ network: ApiNetwork
) {
if (awaitingCount == 0) {
return
}
if (dashboardStatus.state == StateType.none) {
- const estEta = this.getEpochDate(awaitingActivation.activationeligibilityepoch, currentEpoch)
+ const estEta = this.getEpochDate(awaitingActivation.activationeligibilityepoch, currentEpoch, network)
dashboardStatus.icon = 'timer-outline'
dashboardStatus.iconCss = 'waiting'
@@ -724,13 +737,14 @@ export default class OverviewController {
validatorCount: number,
foreignValidator: boolean,
eligbleState: ValidatorResponse,
- currentEpoch: EpochResponse
+ currentEpoch: EpochResponse,
+ network: ApiNetwork
) {
if (eligibilityCount == 0) {
return
}
- const estEta = this.getEpochDate(eligbleState.activationeligibilityepoch, currentEpoch)
+ const estEta = this.getEpochDate(eligbleState.activationeligibilityepoch, currentEpoch, network)
if (dashboardStatus.state == StateType.none) {
dashboardStatus.icon = 'timer-outline'
@@ -804,7 +818,8 @@ export default class OverviewController {
validatorCount: number,
foreignValidator: boolean,
validatorResp: ValidatorResponse,
- currentEpoch: EpochResponse
+ currentEpoch: EpochResponse,
+ network: ApiNetwork
) {
if (dashboardStatus.state != StateType.mixed && dashboardStatus.state != StateType.none) {
return
@@ -818,14 +833,14 @@ export default class OverviewController {
highlight: true,
})
- const exitingDescription = this.getExitingDescription(validatorResp, currentEpoch)
+ const exitingDescription = this.getExitingDescription(validatorResp, currentEpoch, network)
dashboardStatus.extendedDescriptionPre = exitingDescription.extendedDescriptionPre
dashboardStatus.extendedDescription = exitingDescription.extendedDescription
dashboardStatus.state = StateType.online
}
}
- private getEpochDate(activationEpoch: number, currentEpoch: EpochResponse) {
+ private getEpochDate(activationEpoch: number, currentEpoch: EpochResponse, network: ApiNetwork) {
try {
const diff = activationEpoch - currentEpoch.epoch
if (diff <= 0) {
@@ -835,7 +850,7 @@ export default class OverviewController {
const date = new Date(currentEpoch.lastCachedTimestamp)
- const inEpochOffset = (32 - currentEpoch.scheduledblocks) * 12 // block time 12s
+ const inEpochOffset = (network.slotPerEpoch - currentEpoch.scheduledblocks) * network.slotsTime // block time 12s
date.setSeconds(diff * 6.4 * 60 - inEpochOffset)
@@ -883,15 +898,15 @@ export default class OverviewController {
})
}
- private calculateSyncCommitteeStats(stats: SyncCommitteesStatisticsResponse): SyncCommitteesStatistics {
+ private calculateSyncCommitteeStats(stats: SyncCommitteesStatisticsResponse, network: ApiNetwork): SyncCommitteesStatistics {
if (stats) {
// if no slots where expected yet, don't show any statistic as either no validator is subscribed or they have not been active in the selected timeframe
if (stats.expectedSlots > 0) {
const slotsTotal = stats.participatedSlots + stats.missedSlots
- const slotsPerSyncPeriod = 32 * 256
+ const slotsPerSyncPeriod = network.slotPerEpoch * network.epochsPerSyncPeriod
const r: SyncCommitteesStatistics = {
- committeesParticipated: Math.ceil(slotsTotal / 32 / 256),
- committeesExpected: Math.round((stats.expectedSlots * 100) / 32 / 256) / 100,
+ committeesParticipated: Math.ceil(slotsTotal / network.slotPerEpoch / network.epochsPerSyncPeriod),
+ committeesExpected: Math.round((stats.expectedSlots * 100) / network.slotPerEpoch / network.epochsPerSyncPeriod) / 100,
slotsPerSyncCommittee: slotsPerSyncPeriod,
slotsLeftInSyncCommittee: slotsPerSyncPeriod - stats.scheduledSlots,
slotsParticipated: stats.participatedSlots,
diff --git a/src/app/models/StorageTypes.ts b/src/app/models/StorageTypes.ts
index d9d16c35..be7660c4 100644
--- a/src/app/models/StorageTypes.ts
+++ b/src/app/models/StorageTypes.ts
@@ -38,6 +38,7 @@ export interface ApiNetwork {
clCurrency: NetworkMainCurrency
slotPerEpoch: number
slotsTime: number
+ epochsPerSyncPeriod: number
name: string
}
diff --git a/src/app/pages/validatordetail/validatordetail.page.ts b/src/app/pages/validatordetail/validatordetail.page.ts
index 01dc390e..2fb125fb 100644
--- a/src/app/pages/validatordetail/validatordetail.page.ts
+++ b/src/app/pages/validatordetail/validatordetail.page.ts
@@ -25,6 +25,7 @@ import OverviewController, { OverviewData } from '../../controllers/OverviewCont
import { fromEvent, Subscription } from 'rxjs'
import { MerchantUtils } from 'src/app/utils/MerchantUtils'
import { UnitconvService } from 'src/app/services/unitconv.service'
+import { ApiService } from 'src/app/services/api.service'
@Component({
selector: 'app-validatordetail',
@@ -49,7 +50,8 @@ export class ValidatordetailPage implements OnInit {
private validatorUtils: ValidatorUtils,
private modalCtrl: ModalController,
private merchant: MerchantUtils,
- private unit: UnitconvService
+ private unit: UnitconvService,
+ private api: ApiService
) {}
setInput(validator: Validator) {
@@ -94,7 +96,7 @@ export class ValidatordetailPage implements OnInit {
const epoch = await this.validatorUtils.getRemoteCurrentEpoch()
const overviewController = new OverviewController(null, await this.merchant.getCurrentPlanMaxValidator(), this.unit)
- this.data = overviewController.processDetail([item], epoch)
+ this.data = overviewController.processDetail([item], epoch, this.api.getNetwork())
}
tag() {
diff --git a/src/app/tab-dashboard/tab-dashboard.page.ts b/src/app/tab-dashboard/tab-dashboard.page.ts
index 7155533e..c47ff596 100644
--- a/src/app/tab-dashboard/tab-dashboard.page.ts
+++ b/src/app/tab-dashboard/tab-dashboard.page.ts
@@ -134,7 +134,8 @@ export class Tab1Page {
validators,
epoch,
this.validatorUtils.syncCommitteesStatsResponse,
- this.validatorUtils.proposalLuckResponse
+ this.validatorUtils.proposalLuckResponse,
+ this.api.getNetwork()
)
this.lastRefreshTs = this.getUnixSeconds()
}
diff --git a/src/app/utils/BlockUtils.ts b/src/app/utils/BlockUtils.ts
index 312fbad4..00ea5d0b 100644
--- a/src/app/utils/BlockUtils.ts
+++ b/src/app/utils/BlockUtils.ts
@@ -82,7 +82,7 @@ export class BlockUtils {
luckPercentage: proposalLuckStats.proposal_luck,
timeFrameName: proposalLuckStats.time_frame_name,
userValidators: valis.length,
- expectedBlocksPerMonth: MONTH / (proposalLuckStats.average_proposal_interval * 12),
+ expectedBlocksPerMonth: MONTH / (proposalLuckStats.average_proposal_interval * this.api.getNetwork().slotsTime),
nextBlockEstimate: proposalLuckStats.next_proposal_estimate_ts * 1000,
} as Luck
}
diff --git a/src/app/utils/NetworkData.ts b/src/app/utils/NetworkData.ts
index a4f347cf..2376b16b 100644
--- a/src/app/utils/NetworkData.ts
+++ b/src/app/utils/NetworkData.ts
@@ -35,6 +35,7 @@ export const MAP: ApiNetwork[] = [
elCurrency: NetworkMainCurrency.ETH,
slotPerEpoch: 32,
slotsTime: 12,
+ epochsPerSyncPeriod: 256,
name: 'Ethereum',
},
{
@@ -51,6 +52,7 @@ export const MAP: ApiNetwork[] = [
elCurrency: NetworkMainCurrency.xDAI,
slotPerEpoch: 16,
slotsTime: 5,
+ epochsPerSyncPeriod: 512,
name: 'Gnosis',
},
{
@@ -67,6 +69,7 @@ export const MAP: ApiNetwork[] = [
elCurrency: NetworkMainCurrency.ETH,
slotPerEpoch: 32,
slotsTime: 12,
+ epochsPerSyncPeriod: 256,
name: 'Ethereum',
},
{
@@ -83,6 +86,7 @@ export const MAP: ApiNetwork[] = [
elCurrency: NetworkMainCurrency.ETH,
slotPerEpoch: 32,
slotsTime: 12,
+ epochsPerSyncPeriod: 256,
name: 'Ethereum',
},
{
@@ -99,6 +103,7 @@ export const MAP: ApiNetwork[] = [
elCurrency: NetworkMainCurrency.ETH,
slotPerEpoch: 32,
slotsTime: 12,
+ epochsPerSyncPeriod: 256,
name: 'Ethereum',
},
{
@@ -115,6 +120,7 @@ export const MAP: ApiNetwork[] = [
elCurrency: NetworkMainCurrency.ETH,
slotPerEpoch: 32,
slotsTime: 12,
+ epochsPerSyncPeriod: 256,
name: 'Ethereum',
},
{
@@ -131,6 +137,7 @@ export const MAP: ApiNetwork[] = [
elCurrency: NetworkMainCurrency.ETH,
slotPerEpoch: 32,
slotsTime: 12,
+ epochsPerSyncPeriod: 256,
name: 'Ethereum',
},
]
From 47c9902cad6f989252005757921377298184d9c2 Mon Sep 17 00:00:00 2001
From: D13ce
Date: Fri, 3 Nov 2023 08:56:01 +0100
Subject: [PATCH 53/53] Remove deprecated comment
---
src/app/controllers/OverviewController.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/app/controllers/OverviewController.ts b/src/app/controllers/OverviewController.ts
index ccbea2a7..5ab41a48 100644
--- a/src/app/controllers/OverviewController.ts
+++ b/src/app/controllers/OverviewController.ts
@@ -850,7 +850,7 @@ export default class OverviewController {
const date = new Date(currentEpoch.lastCachedTimestamp)
- const inEpochOffset = (network.slotPerEpoch - currentEpoch.scheduledblocks) * network.slotsTime // block time 12s
+ const inEpochOffset = (network.slotPerEpoch - currentEpoch.scheduledblocks) * network.slotsTime
date.setSeconds(diff * 6.4 * 60 - inEpochOffset)