diff --git a/.github/workflows/backend-publish-docker-staging.yml b/.github/workflows/backend-publish-docker-staging.yml new file mode 100644 index 000000000..3deb470c1 --- /dev/null +++ b/.github/workflows/backend-publish-docker-staging.yml @@ -0,0 +1,61 @@ +# +name: Backend docker image staging + +# Configures this workflow to run every time a change is pushed to the branch called `release`. +on: + push: + branches: + - staging-2 + - staging-3 + +# Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds. +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }}_backend + +# There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu. +jobs: + build-and-push-image: + runs-on: ubuntu-latest + # Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job. + permissions: + contents: read + packages: write + # + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Set version + run: | + echo "BEACONCHAIN_VERSION=$(TZ=UTC0 git show --quiet --date='format-local:%Y%m%d%H%M%S' --format="%cd" $GITHUB_SHA)-$(git describe $GITHUB_SHA --always --tags)" >> "$GITHUB_ENV" + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + # Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here. + - name: Log in to the Container registry + uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + # This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels. + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + ${{ env.BEACONCHAIN_VERSION }} + type=ref,event=branch + # This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages. + # It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository. + # It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step. + - name: Build and push Docker image + uses: docker/build-push-action@v5.1.0 + with: + context: . + file: backend/Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache + cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache,mode=max diff --git a/.github/workflows/backend-publish-docker.yml b/.github/workflows/backend-publish-docker.yml index f766263fc..adfb81822 100644 --- a/.github/workflows/backend-publish-docker.yml +++ b/.github/workflows/backend-publish-docker.yml @@ -10,7 +10,6 @@ on: branches: - main - staging - - staging-2 # Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds. env: diff --git a/.github/workflows/frontend-publish-docker-staging.yml b/.github/workflows/frontend-publish-docker-staging.yml new file mode 100644 index 000000000..cd2528503 --- /dev/null +++ b/.github/workflows/frontend-publish-docker-staging.yml @@ -0,0 +1,64 @@ +# +name: Frontend docker image staging + +# Configures this workflow to run every time a change is pushed to the branch called `release`. +on: + push: + branches: + - staging-2 + - staging-3 + +# Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds. +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }}_frontend + +# There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu. +jobs: + build-and-push-image: + runs-on: ubuntu-latest + # Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job. + permissions: + contents: read + packages: write + # + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Set version + run: | + echo "BEACONCHAIN_VERSION=$(TZ=UTC0 git show --quiet --date='format-local:%Y%m%d%H%M%S' --format="%cd" $GITHUB_SHA)-$(git describe $GITHUB_SHA --always --tags)" >> "$GITHUB_ENV" + # Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here. + - name: Log in to the Container registry + uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + # This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels. + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + ${{ env.BEACONCHAIN_VERSION }} + type=ref,event=branch + # This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages. + # It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository. + # It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step. + - name: Build and push Docker image + uses: docker/build-push-action@v5.1.0 + with: + context: "{{defaultContext}}:frontend" + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache + cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache,mode=max + secrets: | + NPMRC_FILE=${{ secrets.NPMRC_FILE }} + build-args: | + BEACONCHAIN_VERSION=${{ env.BEACONCHAIN_VERSION }} diff --git a/.github/workflows/frontend-publish-docker.yml b/.github/workflows/frontend-publish-docker.yml index b93c4b312..8c85468f9 100644 --- a/.github/workflows/frontend-publish-docker.yml +++ b/.github/workflows/frontend-publish-docker.yml @@ -10,7 +10,6 @@ on: branches: - main - staging - - staging-2 # Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds. env: diff --git a/backend/pkg/api/data_access/vdb_blocks.go b/backend/pkg/api/data_access/vdb_blocks.go index c37e06180..eb6daafc2 100644 --- a/backend/pkg/api/data_access/vdb_blocks.go +++ b/backend/pkg/api/data_access/vdb_blocks.go @@ -361,37 +361,22 @@ func (d *DataAccessService) GetValidatorDashboardBlocks(ctx context.Context, das Slot uint64 `db:"slot"` ClReward decimal.NullDecimal `db:"cl_reward"` }{} - if utils.Config.Chain.ClConfig.DepositChainID == 17000 { - clRewardsQuery := goqu.Dialect("postgres"). - From(goqu.T("consensus_payloads")). - Select( - goqu.C("slot"), - goqu.L("cl_attestations_reward + cl_sync_aggregate_reward + cl_slashing_inclusion_reward AS cl_reward"), - ).Where(goqu.C("slot").In(slots)) - clRewardsQuerySql, args, err := clRewardsQuery.Prepared(true).ToSQL() - if err != nil { - return nil, nil, err - } - err = d.alloyReader.SelectContext(ctx, &clRewardsData, clRewardsQuerySql, args...) - if err != nil { - return nil, nil, err - } - } else { - clRewardsQuery := goqu.Dialect("postgres"). - From(goqu.L("mainnet.validator_proposal_rewards_slot")). - Select( - goqu.C("slot"), - goqu.L("attestations_reward + sync_aggregate_reward + slasher_reward AS cl_reward"), - ).Where(goqu.C("slot").In(slots)) - clRewardsQuerySql, args, err := clRewardsQuery.Prepared(true).ToSQL() - if err != nil { - return nil, nil, err - } - err = d.clickhouseReader.SelectContext(ctx, &clRewardsData, clRewardsQuerySql, args...) - if err != nil { - return nil, nil, err - } + + clRewardsQuery := goqu.Dialect("postgres"). + From(goqu.L("validator_proposal_rewards_slot")). + Select( + goqu.C("slot"), + goqu.L("attestations_reward + sync_aggregate_reward + slasher_reward AS cl_reward"), + ).Where(goqu.C("slot").In(slots)) + clRewardsQuerySql, args, err := clRewardsQuery.Prepared(true).ToSQL() + if err != nil { + return nil, nil, err + } + err = d.clickhouseReader.SelectContext(ctx, &clRewardsData, clRewardsQuerySql, args...) + if err != nil { + return nil, nil, err } + clRewards := make(map[uint64]decimal.NullDecimal) for _, reward := range clRewardsData { clRewards[reward.Slot] = reward.ClReward diff --git a/backend/pkg/api/data_access/vdb_rewards.go b/backend/pkg/api/data_access/vdb_rewards.go index 1221f9596..4d4e4e266 100644 --- a/backend/pkg/api/data_access/vdb_rewards.go +++ b/backend/pkg/api/data_access/vdb_rewards.go @@ -86,9 +86,9 @@ func (d *DataAccessService) GetValidatorDashboardRewards(ctx context.Context, da With("validators", goqu.L("(SELECT validator_index as validator_index, group_id FROM users_val_dashboards_validators WHERE dashboard_id = ?)", dashboardId.Id)). Select( goqu.L("e.epoch"), - goqu.L(`SUM(COALESCE(e.attestations_reward, 0) + COALESCE(e.blocks_cl_reward, 0) + COALESCE(e.sync_rewards, 0)) AS cl_rewards`), + goqu.L(`SUM(COALESCE(e.attestations_reward, 0) + COALESCE(e.blocks_cl_reward, 0) + COALESCE(e.sync_reward, 0)) AS cl_rewards`), goqu.L("SUM(COALESCE(e.attestations_scheduled, 0)) AS attestations_scheduled"), - goqu.L("SUM(COALESCE(e.attestations_executed, 0)) AS attestations_executed"), + goqu.L("SUM(COALESCE(e.attestations_observed, 0)) AS attestations_observed"), goqu.L("SUM(COALESCE(e.blocks_scheduled, 0)) AS blocks_scheduled"), goqu.L("SUM(COALESCE(e.blocks_proposed, 0)) AS blocks_proposed"), goqu.L("SUM(COALESCE(e.sync_scheduled, 0)) AS sync_scheduled"), @@ -300,7 +300,7 @@ func (d *DataAccessService) GetValidatorDashboardRewards(ctx context.Context, da GroupId int64 `db:"result_group_id"` ClRewards int64 `db:"cl_rewards"` AttestationsScheduled uint64 `db:"attestations_scheduled"` - AttestationsExecuted uint64 `db:"attestations_executed"` + AttestationsExecuted uint64 `db:"attestations_observed"` BlocksScheduled uint64 `db:"blocks_scheduled"` BlocksProposed uint64 `db:"blocks_proposed"` SyncScheduled uint64 `db:"sync_scheduled"` @@ -539,15 +539,15 @@ func (d *DataAccessService) GetValidatorDashboardGroupRewards(ctx context.Contex goqu.L("COALESCE(e.attestations_inactivity_reward, 0) AS attestations_inactivity_reward"), goqu.L("COALESCE(e.attestations_inclusion_reward, 0) AS attestations_inclusion_reward"), goqu.L("COALESCE(e.attestations_scheduled, 0) AS attestations_scheduled"), - goqu.L("COALESCE(e.attestation_head_executed, 0) AS attestation_head_executed"), - goqu.L("COALESCE(e.attestation_source_executed, 0) AS attestation_source_executed"), - goqu.L("COALESCE(e.attestation_target_executed, 0) AS attestation_target_executed"), + goqu.L("COALESCE(e.attestations_head_executed, 0) AS attestations_head_executed"), + goqu.L("COALESCE(e.attestations_source_executed, 0) AS attestations_source_executed"), + goqu.L("COALESCE(e.attestations_target_executed, 0) AS attestations_target_executed"), goqu.L("COALESCE(e.blocks_scheduled, 0) AS blocks_scheduled"), goqu.L("COALESCE(e.blocks_proposed, 0) AS blocks_proposed"), goqu.L("COALESCE(e.blocks_cl_reward, 0) AS blocks_cl_reward"), goqu.L("COALESCE(e.sync_scheduled, 0) AS sync_scheduled"), goqu.L("COALESCE(e.sync_executed, 0) AS sync_executed"), - goqu.L("COALESCE(e.sync_rewards, 0) AS sync_rewards"), + goqu.L("COALESCE(e.sync_reward, 0) AS sync_reward"), goqu.L("(CASE WHEN e.slashed THEN 1 ELSE 0 END) AS slashed_in_epoch"), goqu.L("COALESCE(e.blocks_slashing_count, 0) AS slashed_amount"), goqu.L("COALESCE(e.blocks_cl_slasher_reward, 0) AS slasher_reward"), @@ -601,10 +601,10 @@ func (d *DataAccessService) GetValidatorDashboardGroupRewards(ctx context.Contex AttestationInactivitytReward decimal.Decimal `db:"attestations_inactivity_reward"` AttestationInclusionReward decimal.Decimal `db:"attestations_inclusion_reward"` - AttestationsScheduled int64 `db:"attestations_scheduled"` - AttestationHeadExecuted int64 `db:"attestation_head_executed"` - AttestationSourceExecuted int64 `db:"attestation_source_executed"` - AttestationTargetExecuted int64 `db:"attestation_target_executed"` + AttestationsScheduled int64 `db:"attestations_scheduled"` + AttestationsHeadExecuted int64 `db:"attestations_head_executed"` + AttestationsSourceExecuted int64 `db:"attestations_source_executed"` + AttestationsTargetExecuted int64 `db:"attestations_target_executed"` BlocksScheduled uint32 `db:"blocks_scheduled"` BlocksProposed uint32 `db:"blocks_proposed"` @@ -612,7 +612,7 @@ func (d *DataAccessService) GetValidatorDashboardGroupRewards(ctx context.Contex SyncScheduled uint32 `db:"sync_scheduled"` SyncExecuted uint32 `db:"sync_executed"` - SyncRewards decimal.Decimal `db:"sync_rewards"` + SyncReward decimal.Decimal `db:"sync_reward"` SlashedInEpoch bool `db:"slashed_in_epoch"` SlashedAmount uint32 `db:"slashed_amount"` @@ -662,16 +662,16 @@ func (d *DataAccessService) GetValidatorDashboardGroupRewards(ctx context.Contex for _, entry := range queryResult { ret.AttestationsHead.Income = ret.AttestationsHead.Income.Add(entry.AttestationHeadReward.Mul(gWei)) - ret.AttestationsHead.StatusCount.Success += uint64(entry.AttestationHeadExecuted) - ret.AttestationsHead.StatusCount.Failed += uint64(entry.AttestationsScheduled) - uint64(entry.AttestationHeadExecuted) + ret.AttestationsHead.StatusCount.Success += uint64(entry.AttestationsHeadExecuted) + ret.AttestationsHead.StatusCount.Failed += uint64(entry.AttestationsScheduled) - uint64(entry.AttestationsHeadExecuted) ret.AttestationsSource.Income = ret.AttestationsSource.Income.Add(entry.AttestationSourceReward.Mul(gWei)) - ret.AttestationsSource.StatusCount.Success += uint64(entry.AttestationSourceExecuted) - ret.AttestationsSource.StatusCount.Failed += uint64(entry.AttestationsScheduled) - uint64(entry.AttestationSourceExecuted) + ret.AttestationsSource.StatusCount.Success += uint64(entry.AttestationsSourceExecuted) + ret.AttestationsSource.StatusCount.Failed += uint64(entry.AttestationsScheduled) - uint64(entry.AttestationsSourceExecuted) ret.AttestationsTarget.Income = ret.AttestationsTarget.Income.Add(entry.AttestationTargetReward.Mul(gWei)) - ret.AttestationsTarget.StatusCount.Success += uint64(entry.AttestationTargetExecuted) - ret.AttestationsTarget.StatusCount.Failed += uint64(entry.AttestationsScheduled) - uint64(entry.AttestationTargetExecuted) + ret.AttestationsTarget.StatusCount.Success += uint64(entry.AttestationsTargetExecuted) + ret.AttestationsTarget.StatusCount.Failed += uint64(entry.AttestationsScheduled) - uint64(entry.AttestationsTargetExecuted) ret.Inactivity.Income = ret.Inactivity.Income.Add(entry.AttestationInactivitytReward.Mul(gWei)) if entry.AttestationInactivitytReward.LessThan(decimal.Zero) { @@ -684,7 +684,7 @@ func (d *DataAccessService) GetValidatorDashboardGroupRewards(ctx context.Contex ret.Proposal.StatusCount.Success += uint64(entry.BlocksProposed) ret.Proposal.StatusCount.Failed += uint64(entry.BlocksScheduled) - uint64(entry.BlocksProposed) - ret.Sync.Income = ret.Sync.Income.Add(entry.SyncRewards.Mul(gWei)) + ret.Sync.Income = ret.Sync.Income.Add(entry.SyncReward.Mul(gWei)) ret.Sync.StatusCount.Success += uint64(entry.SyncExecuted) ret.Sync.StatusCount.Failed += uint64(entry.SyncScheduled) - uint64(entry.SyncExecuted) @@ -725,7 +725,7 @@ func (d *DataAccessService) GetValidatorDashboardRewardsChart(ctx context.Contex rewardsDs := goqu.Dialect("postgres"). Select( goqu.L("e.epoch"), - goqu.L(`SUM(COALESCE(e.attestations_reward, 0) + COALESCE(e.blocks_cl_reward, 0) + COALESCE(e.sync_rewards, 0)) AS cl_rewards`)). + goqu.L(`SUM(COALESCE(e.attestations_reward, 0) + COALESCE(e.blocks_cl_reward, 0) + COALESCE(e.sync_reward, 0)) AS cl_rewards`)). From(goqu.L("validator_dashboard_data_epoch e")). With("validators", goqu.L("(SELECT validator_index as validator_index, group_id FROM users_val_dashboards_validators WHERE dashboard_id = ?)", dashboardId.Id)). Where(goqu.L("e.epoch_timestamp >= fromUnixTimestamp(?)", utils.EpochToTime(startEpoch).Unix())) @@ -958,15 +958,15 @@ func (d *DataAccessService) GetValidatorDashboardDuties(ctx context.Context, das Select( goqu.L("e.validator_index"), goqu.L("COALESCE(e.attestations_scheduled, 0) AS attestations_scheduled"), - goqu.L("COALESCE(e.attestation_source_executed, 0) AS attestation_source_executed"), + goqu.L("COALESCE(e.attestations_source_executed, 0) AS attestations_source_executed"), goqu.L("COALESCE(e.attestations_source_reward, 0) AS attestations_source_reward"), - goqu.L("COALESCE(e.attestation_target_executed, 0) AS attestation_target_executed"), + goqu.L("COALESCE(e.attestations_target_executed, 0) AS attestations_target_executed"), goqu.L("COALESCE(e.attestations_target_reward, 0) AS attestations_target_reward"), - goqu.L("COALESCE(e.attestation_head_executed, 0) AS attestation_head_executed"), + goqu.L("COALESCE(e.attestations_head_executed, 0) AS attestations_head_executed"), goqu.L("COALESCE(e.attestations_head_reward, 0) AS attestations_head_reward"), goqu.L("COALESCE(e.sync_scheduled, 0) AS sync_scheduled"), goqu.L("COALESCE(e.sync_executed, 0) AS sync_executed"), - goqu.L("COALESCE(e.sync_rewards, 0) AS sync_rewards"), + goqu.L("COALESCE(e.sync_reward, 0) AS sync_reward"), goqu.L("e.slashed AS slashed_in_epoch"), goqu.L("COALESCE(e.blocks_slashing_count, 0) AS slashed_amount"), goqu.L("COALESCE(e.blocks_cl_slasher_reward, 0) AS slasher_reward"), @@ -1044,15 +1044,15 @@ func (d *DataAccessService) GetValidatorDashboardDuties(ctx context.Context, das queryResult := []struct { ValidatorIndex uint64 `db:"validator_index"` AttestationsScheduled uint64 `db:"attestations_scheduled"` - AttestationsSourceExecuted uint64 `db:"attestation_source_executed"` + AttestationsSourceExecuted uint64 `db:"attestations_source_executed"` AttestationsSourceReward int64 `db:"attestations_source_reward"` - AttestationsTargetExecuted uint64 `db:"attestation_target_executed"` + AttestationsTargetExecuted uint64 `db:"attestations_target_executed"` AttestationsTargetReward int64 `db:"attestations_target_reward"` - AttestationsHeadExecuted uint64 `db:"attestation_head_executed"` + AttestationsHeadExecuted uint64 `db:"attestations_head_executed"` AttestationsHeadReward int64 `db:"attestations_head_reward"` SyncScheduled uint64 `db:"sync_scheduled"` SyncExecuted uint64 `db:"sync_executed"` - SyncRewards int64 `db:"sync_rewards"` + SyncRewards int64 `db:"sync_reward"` SlashedInEpoch bool `db:"slashed_in_epoch"` SlashedAmount uint64 `db:"slashed_amount"` SlasherReward int64 `db:"slasher_reward"` diff --git a/backend/pkg/api/data_access/vdb_summary.go b/backend/pkg/api/data_access/vdb_summary.go index a345b9768..da45182d4 100644 --- a/backend/pkg/api/data_access/vdb_summary.go +++ b/backend/pkg/api/data_access/vdb_summary.go @@ -103,7 +103,7 @@ func (d *DataAccessService) GetValidatorDashboardSummary(ctx context.Context, da ClRewards int64 `db:"cl_rewards"` AttestationReward decimal.Decimal `db:"attestations_reward"` AttestationIdealReward decimal.Decimal `db:"attestations_ideal_reward"` - AttestationsExecuted uint64 `db:"attestations_executed"` + AttestationsObserved uint64 `db:"attestations_observed"` AttestationsScheduled uint64 `db:"attestations_scheduled"` BlocksProposed uint64 `db:"blocks_proposed"` BlocksScheduled uint64 `db:"blocks_scheduled"` @@ -118,10 +118,17 @@ func (d *DataAccessService) GetValidatorDashboardSummary(ctx context.Context, da With("validators", goqu.L("(SELECT dashboard_id, group_id, validator_index FROM users_val_dashboards_validators WHERE dashboard_id = ?)", dashboardId.Id)). Select( goqu.L("ARRAY_AGG(r.validator_index) AS validator_indices"), - goqu.L("(SUM(COALESCE(r.balance_end,0)) + SUM(COALESCE(r.withdrawals_amount,0)) - SUM(COALESCE(r.deposits_amount,0)) - SUM(COALESCE(r.balance_start,0))) AS cl_rewards"), + goqu.L(` + ( + SUM(COALESCE(finalizeAggregation(r.balance_end), 0)) + + SUM(COALESCE(r.withdrawals_amount, 0)) - + SUM(COALESCE(r.deposits_amount, 0)) - + SUM(COALESCE(finalizeAggregation(r.balance_start), 0)) + ) AS cl_rewards + `), goqu.L("COALESCE(SUM(r.attestations_reward)::decimal, 0) AS attestations_reward"), goqu.L("COALESCE(SUM(r.attestations_ideal_reward)::decimal, 0) AS attestations_ideal_reward"), - goqu.L("COALESCE(SUM(r.attestations_executed), 0) AS attestations_executed"), + goqu.L("COALESCE(SUM(r.attestations_observed), 0) AS attestations_observed"), goqu.L("COALESCE(SUM(r.attestations_scheduled), 0) AS attestations_scheduled"), goqu.L("COALESCE(SUM(r.blocks_proposed), 0) AS blocks_proposed"), goqu.L("COALESCE(SUM(r.blocks_scheduled), 0) AS blocks_scheduled"), @@ -277,7 +284,7 @@ func (d *DataAccessService) GetValidatorDashboardSummary(ctx context.Context, da Validators t.VDBSummaryValidators AttestationReward decimal.Decimal AttestationIdealReward decimal.Decimal - AttestationsExecuted uint64 + AttestationsObserved uint64 AttestationsScheduled uint64 BlocksProposed uint64 BlocksScheduled uint64 @@ -338,8 +345,8 @@ func (d *DataAccessService) GetValidatorDashboardSummary(ctx context.Context, da total.Status.SlashedCount += resultEntry.Status.SlashedCount // Attestations - resultEntry.Attestations.Success = queryEntry.AttestationsExecuted - resultEntry.Attestations.Failed = queryEntry.AttestationsScheduled - queryEntry.AttestationsExecuted + resultEntry.Attestations.Success = queryEntry.AttestationsObserved + resultEntry.Attestations.Failed = queryEntry.AttestationsScheduled - queryEntry.AttestationsObserved // Proposals resultEntry.Proposals.Success = queryEntry.BlocksProposed @@ -372,7 +379,7 @@ func (d *DataAccessService) GetValidatorDashboardSummary(ctx context.Context, da // Add the duties info to the total total.AttestationReward = total.AttestationReward.Add(queryEntry.AttestationReward) total.AttestationIdealReward = total.AttestationIdealReward.Add(queryEntry.AttestationIdealReward) - total.AttestationsExecuted += queryEntry.AttestationsExecuted + total.AttestationsObserved += queryEntry.AttestationsObserved total.AttestationsScheduled += queryEntry.AttestationsScheduled total.BlocksProposed += queryEntry.BlocksProposed total.BlocksScheduled += queryEntry.BlocksScheduled @@ -466,8 +473,8 @@ func (d *DataAccessService) GetValidatorDashboardSummary(ctx context.Context, da } // Attestations - totalEntry.Attestations.Success = total.AttestationsExecuted - totalEntry.Attestations.Failed = total.AttestationsScheduled - total.AttestationsExecuted + totalEntry.Attestations.Success = total.AttestationsObserved + totalEntry.Attestations.Failed = total.AttestationsScheduled - total.AttestationsObserved // Proposals totalEntry.Proposals.Success = total.BlocksProposed @@ -581,10 +588,10 @@ func (d *DataAccessService) GetValidatorDashboardGroupSummary(ctx context.Contex goqu.L("attestations_reward"), goqu.L("attestations_ideal_reward"), goqu.L("attestations_scheduled"), - goqu.L("attestations_executed"), - goqu.L("attestation_head_executed"), - goqu.L("attestation_source_executed"), - goqu.L("attestation_target_executed"), + goqu.L("attestations_observed"), + goqu.L("attestations_head_executed"), + goqu.L("attestations_source_executed"), + goqu.L("attestations_target_executed"), goqu.L("blocks_scheduled"), goqu.L("blocks_proposed"), goqu.L("sync_scheduled"), @@ -612,11 +619,11 @@ func (d *DataAccessService) GetValidatorDashboardGroupSummary(ctx context.Contex AttestationReward int64 `db:"attestations_reward"` AttestationIdealReward int64 `db:"attestations_ideal_reward"` - AttestationsScheduled int64 `db:"attestations_scheduled"` - AttestationsExecuted int64 `db:"attestations_executed"` - AttestationHeadExecuted int64 `db:"attestation_head_executed"` - AttestationSourceExecuted int64 `db:"attestation_source_executed"` - AttestationTargetExecuted int64 `db:"attestation_target_executed"` + AttestationsScheduled int64 `db:"attestations_scheduled"` + AttestationsObserved int64 `db:"attestations_observed"` + AttestationsHeadExecuted int64 `db:"attestations_head_executed"` + AttestationsSourceExecuted int64 `db:"attestations_source_executed"` + AttestationsTargetExecuted int64 `db:"attestations_target_executed"` BlocksScheduled uint32 `db:"blocks_scheduled"` BlocksProposed uint32 `db:"blocks_proposed"` @@ -680,14 +687,14 @@ func (d *DataAccessService) GetValidatorDashboardGroupSummary(ctx context.Contex totalAttestationRewards += row.AttestationReward totalIdealAttestationRewards += row.AttestationIdealReward - ret.AttestationsHead.Success += uint64(row.AttestationHeadExecuted) - ret.AttestationsHead.Failed += uint64(row.AttestationsScheduled) - uint64(row.AttestationHeadExecuted) + ret.AttestationsHead.Success += uint64(row.AttestationsHeadExecuted) + ret.AttestationsHead.Failed += uint64(row.AttestationsScheduled) - uint64(row.AttestationsHeadExecuted) - ret.AttestationsSource.Success += uint64(row.AttestationSourceExecuted) - ret.AttestationsSource.Failed += uint64(row.AttestationsScheduled) - uint64(row.AttestationSourceExecuted) + ret.AttestationsSource.Success += uint64(row.AttestationsSourceExecuted) + ret.AttestationsSource.Failed += uint64(row.AttestationsScheduled) - uint64(row.AttestationsSourceExecuted) - ret.AttestationsTarget.Success += uint64(row.AttestationTargetExecuted) - ret.AttestationsTarget.Failed += uint64(row.AttestationsScheduled) - uint64(row.AttestationTargetExecuted) + ret.AttestationsTarget.Success += uint64(row.AttestationsTargetExecuted) + ret.AttestationsTarget.Failed += uint64(row.AttestationsScheduled) - uint64(row.AttestationsTargetExecuted) if row.ValidatorIndex == 0 && row.BlocksProposed > 0 && row.BlocksProposed != row.BlocksScheduled { row.BlocksProposed-- // subtract the genesis block from validator 0 (TODO: remove when fixed in the dashoard data exporter) @@ -732,7 +739,7 @@ func (d *DataAccessService) GetValidatorDashboardGroupSummary(ctx context.Contex totalSyncExpected += row.SyncCommitteesExpected if row.InclusionDelaySum > 0 { - totalInclusionDelayDivisor += row.AttestationsExecuted + totalInclusionDelayDivisor += row.AttestationsObserved } } @@ -857,8 +864,14 @@ func (d *DataAccessService) internal_getElClAPR(ctx context.Context, dashboardId goqu.L("MIN(epoch_start) AS epoch_start"), goqu.L("MAX(epoch_end) AS epoch_end"), goqu.L("COUNT(*) AS validator_count"), - goqu.L("(SUM(COALESCE(r.balance_end,0)) + SUM(COALESCE(r.withdrawals_amount,0)) - SUM(COALESCE(r.deposits_amount,0)) - SUM(COALESCE(r.balance_start,0))) AS reward")) - + goqu.L(` + ( + SUM(COALESCE(finalizeAggregation(r.balance_end), 0)) + + SUM(COALESCE(r.withdrawals_amount, 0)) - + SUM(COALESCE(r.deposits_amount, 0)) - + SUM(COALESCE(finalizeAggregation(r.balance_start), 0)) + ) AS reward + `)) if len(dashboardId.Validators) > 0 { rewardsDs = rewardsDs. Where(goqu.L("validator_index IN ?", dashboardId.Validators)) @@ -1000,13 +1013,13 @@ func (d *DataAccessService) GetValidatorDashboardSummaryChart(ctx context.Contex dateColumn = "epoch_timestamp" case enums.IntervalHourly: dataTable = "validator_dashboard_data_hourly" - dateColumn = "hour" + dateColumn = "t" case enums.IntervalDaily: dataTable = "validator_dashboard_data_daily" - dateColumn = "day" + dateColumn = "t" case enums.IntervalWeekly: dataTable = "validator_dashboard_data_weekly" - dateColumn = "week" + dateColumn = "t" default: return nil, fmt.Errorf("unexpected aggregation type: %v", aggregation) } @@ -1030,7 +1043,7 @@ func (d *DataAccessService) GetValidatorDashboardSummaryChart(ctx context.Contex SELECT %[2]s as ts, 0 AS group_id, - COALESCE(SUM(d.attestations_reward), 0) AS attestation_reward, + COALESCE(SUM(d.attestations_reward), 0) AS attestations_reward, COALESCE(SUM(d.attestations_ideal_reward), 0) AS attestations_ideal_reward, COALESCE(SUM(d.blocks_proposed), 0) AS blocks_proposed, COALESCE(SUM(d.blocks_scheduled), 0) AS blocks_scheduled, @@ -1052,7 +1065,7 @@ func (d *DataAccessService) GetValidatorDashboardSummaryChart(ctx context.Contex SELECT %[2]s as ts, v.group_id, - COALESCE(SUM(d.attestations_reward), 0) AS attestation_reward, + COALESCE(SUM(d.attestations_reward), 0) AS attestations_reward, COALESCE(SUM(d.attestations_ideal_reward), 0) AS attestations_ideal_reward, COALESCE(SUM(d.blocks_proposed), 0) AS blocks_proposed, COALESCE(SUM(d.blocks_scheduled), 0) AS blocks_scheduled, diff --git a/backend/pkg/api/types/data_access.go b/backend/pkg/api/types/data_access.go index 451e79652..a149bb6f2 100644 --- a/backend/pkg/api/types/data_access.go +++ b/backend/pkg/api/types/data_access.go @@ -275,7 +275,7 @@ type MobileSubscriptionTransactionGeneric struct { type VDBValidatorSummaryChartRow struct { Timestamp time.Time `db:"ts"` GroupId int64 `db:"group_id"` - AttestationReward float64 `db:"attestation_reward"` + AttestationReward float64 `db:"attestations_reward"` AttestationIdealReward float64 `db:"attestations_ideal_reward"` BlocksProposed float64 `db:"blocks_proposed"` BlocksScheduled float64 `db:"blocks_scheduled"` diff --git a/backend/pkg/exporter/modules/dashboard_data.go b/backend/pkg/exporter/modules/dashboard_data.go index 0f24b2ef4..55ca2ebd8 100644 --- a/backend/pkg/exporter/modules/dashboard_data.go +++ b/backend/pkg/exporter/modules/dashboard_data.go @@ -1588,16 +1588,16 @@ func (d *dashboardData) process(data *Data, domain []byte) ([]*validatorDashboar validatorsData[validator_index].AttestationIdealReward = utils.NullInt64(int64(idealRewardsOfValidator.Head + idealRewardsOfValidator.Source + idealRewardsOfValidator.Target + idealRewardsOfValidator.Inactivity + idealRewardsOfValidator.InclusionDelay)) if attestationReward.Head > 0 { - validatorsData[validator_index].AttestationHeadExecuted = utils.NullInt16(1) - validatorsData[validator_index].AttestationsExecuted = utils.NullInt16(1) + validatorsData[validator_index].AttestationsHeadExecuted = utils.NullInt16(1) + validatorsData[validator_index].AttestationsObserved = utils.NullInt16(1) } if attestationReward.Source > 0 { - validatorsData[validator_index].AttestationSourceExecuted = utils.NullInt16(1) - validatorsData[validator_index].AttestationsExecuted = utils.NullInt16(1) + validatorsData[validator_index].AttestationsSourceExecuted = utils.NullInt16(1) + validatorsData[validator_index].AttestationsObserved = utils.NullInt16(1) } if attestationReward.Target > 0 { - validatorsData[validator_index].AttestationTargetExecuted = utils.NullInt16(1) - validatorsData[validator_index].AttestationsExecuted = utils.NullInt16(1) + validatorsData[validator_index].AttestationsTargetExecuted = utils.NullInt16(1) + validatorsData[validator_index].AttestationsObserved = utils.NullInt16(1) } } @@ -1684,11 +1684,11 @@ type validatorDashboardDataRow struct { AttestationsIdealInclusionsReward sql.NullInt32 //done AttestationIdealReward sql.NullInt64 //done - AttestationsScheduled sql.NullInt16 //done - AttestationsExecuted sql.NullInt16 //done - AttestationHeadExecuted sql.NullInt16 //done - AttestationSourceExecuted sql.NullInt16 //done - AttestationTargetExecuted sql.NullInt16 //done + AttestationsScheduled sql.NullInt16 //done + AttestationsObserved sql.NullInt16 //done + AttestationsHeadExecuted sql.NullInt16 //done + AttestationsSourceExecuted sql.NullInt16 //done + AttestationsTargetExecuted sql.NullInt16 //done LastSubmittedDutyEpoch sql.NullInt32 // does not include sync committee duty slots diff --git a/backend/pkg/exporter/modules/dashboard_data_w_1_epoch.go b/backend/pkg/exporter/modules/dashboard_data_w_1_epoch.go index 9c18a2fe7..d363465f2 100644 --- a/backend/pkg/exporter/modules/dashboard_data_w_1_epoch.go +++ b/backend/pkg/exporter/modules/dashboard_data_w_1_epoch.go @@ -135,7 +135,7 @@ func (d *epochWriter) WriteEpochData(epoch uint64, data []*validatorDashboardDat "blocks_cl_reward", "sync_scheduled", "sync_executed", - "sync_rewards", + "sync_reward", "slashed", "balance_start", "balance_end", @@ -146,10 +146,10 @@ func (d *epochWriter) WriteEpochData(epoch uint64, data []*validatorDashboardDat "inclusion_delay_sum", "blocks_expected", "attestations_scheduled", - "attestations_executed", - "attestation_head_executed", - "attestation_source_executed", - "attestation_target_executed", + "attestations_observed", + "attestations_head_executed", + "attestations_source_executed", + "attestations_target_executed", "optimal_inclusion_delay_sum", "slashed_by", "slashed_violation", @@ -190,10 +190,10 @@ func (d *epochWriter) WriteEpochData(epoch uint64, data []*validatorDashboardDat data[i].InclusionDelaySum, data[i].BlocksExpectedThisEpoch, data[i].AttestationsScheduled, - data[i].AttestationsExecuted, - data[i].AttestationHeadExecuted, - data[i].AttestationSourceExecuted, - data[i].AttestationTargetExecuted, + data[i].AttestationsObserved, + data[i].AttestationsHeadExecuted, + data[i].AttestationsSourceExecuted, + data[i].AttestationsTargetExecuted, data[i].OptimalInclusionDelay, data[i].SlashedBy, data[i].SlashedViolation, diff --git a/backend/pkg/exporter/modules/dashboard_data_w_3_epoch_day.go b/backend/pkg/exporter/modules/dashboard_data_w_3_epoch_day.go index c0a216d66..61192600f 100644 --- a/backend/pkg/exporter/modules/dashboard_data_w_3_epoch_day.go +++ b/backend/pkg/exporter/modules/dashboard_data_w_3_epoch_day.go @@ -312,7 +312,7 @@ func (d *DayRollingAggregatorImpl) bootstrap(tx *sqlx.Tx, days int, tableName st SUM(blocks_cl_sync_aggregate_reward) as blocks_cl_sync_aggregate_reward, SUM(sync_scheduled) as sync_scheduled, SUM(sync_executed) as sync_executed, - SUM(sync_rewards) as sync_rewards, + SUM(sync_reward) as sync_reward, bool_or(slashed) as slashed, SUM(deposits_count) as deposits_count, SUM(deposits_amount) as deposits_amount, @@ -322,10 +322,10 @@ func (d *DayRollingAggregatorImpl) bootstrap(tx *sqlx.Tx, days int, tableName st SUM(blocks_expected) as blocks_expected, SUM(sync_committees_expected) as sync_committees_expected, SUM(attestations_scheduled) as attestations_scheduled, - SUM(attestations_executed) as attestations_executed, - SUM(attestation_head_executed) as attestation_head_executed, - SUM(attestation_source_executed) as attestation_source_executed, - SUM(attestation_target_executed) as attestation_target_executed, + SUM(attestations_observed) as attestations_observed, + SUM(attestations_head_executed) as attestations_head_executed, + SUM(attestations_source_executed) as attestations_source_executed, + SUM(attestations_target_executed) as attestations_target_executed, SUM(optimal_inclusion_delay_sum) as optimal_inclusion_delay_sum, SUM(slasher_reward) as slasher_reward, MAX(slashed_by) as slashed_by, @@ -358,7 +358,7 @@ func (d *DayRollingAggregatorImpl) bootstrap(tx *sqlx.Tx, days int, tableName st blocks_cl_sync_aggregate_reward, sync_scheduled, sync_executed, - sync_rewards, + sync_reward, slashed, balance_start, balance_end, @@ -370,10 +370,10 @@ func (d *DayRollingAggregatorImpl) bootstrap(tx *sqlx.Tx, days int, tableName st blocks_expected, sync_committees_expected, attestations_scheduled, - attestations_executed, - attestation_head_executed, - attestation_source_executed, - attestation_target_executed, + attestations_observed, + attestations_head_executed, + attestations_source_executed, + attestations_target_executed, optimal_inclusion_delay_sum, slasher_reward, slashed_by, @@ -403,7 +403,7 @@ func (d *DayRollingAggregatorImpl) bootstrap(tx *sqlx.Tx, days int, tableName st blocks_cl_sync_aggregate_reward, sync_scheduled, sync_executed, - sync_rewards, + sync_reward, slashed, balance_start, balance_end, @@ -415,10 +415,10 @@ func (d *DayRollingAggregatorImpl) bootstrap(tx *sqlx.Tx, days int, tableName st blocks_expected, sync_committees_expected, attestations_scheduled, - attestations_executed, - attestation_head_executed, - attestation_source_executed, - attestation_target_executed, + attestations_observed, + attestations_head_executed, + attestations_source_executed, + attestations_target_executed, optimal_inclusion_delay_sum, slasher_reward, slashed_by, diff --git a/backend/pkg/exporter/modules/dashboard_data_w_4_day_weekly-month-90d.go b/backend/pkg/exporter/modules/dashboard_data_w_4_day_weekly-month-90d.go index 9a3ad969c..821f430bb 100644 --- a/backend/pkg/exporter/modules/dashboard_data_w_4_day_weekly-month-90d.go +++ b/backend/pkg/exporter/modules/dashboard_data_w_4_day_weekly-month-90d.go @@ -208,7 +208,7 @@ func (d *MultipleDaysRollingAggregatorImpl) bootstrap(tx *sqlx.Tx, days int, tab SUM(blocks_cl_sync_aggregate_reward) as blocks_cl_sync_aggregate_reward, SUM(sync_scheduled) as sync_scheduled, SUM(sync_executed) as sync_executed, - SUM(sync_rewards) as sync_rewards, + SUM(sync_reward) as sync_reward, bool_or(slashed) as slashed, SUM(deposits_count) as deposits_count, SUM(deposits_amount) as deposits_amount, @@ -218,10 +218,10 @@ func (d *MultipleDaysRollingAggregatorImpl) bootstrap(tx *sqlx.Tx, days int, tab SUM(blocks_expected) as blocks_expected, SUM(sync_committees_expected) as sync_committees_expected, SUM(attestations_scheduled) as attestations_scheduled, - SUM(attestations_executed) as attestations_executed, - SUM(attestation_head_executed) as attestation_head_executed, - SUM(attestation_source_executed) as attestation_source_executed, - SUM(attestation_target_executed) as attestation_target_executed, + SUM(attestations_observed) as attestations_observed, + SUM(attestations_head_executed) as attestations_head_executed, + SUM(attestations_source_executed) as attestations_source_executed, + SUM(attestations_target_executed) as attestations_target_executed, SUM(optimal_inclusion_delay_sum) as optimal_inclusion_delay_sum, SUM(slasher_reward) as slasher_reward, MAX(slashed_by) as slashed_by, @@ -254,7 +254,7 @@ func (d *MultipleDaysRollingAggregatorImpl) bootstrap(tx *sqlx.Tx, days int, tab blocks_cl_sync_aggregate_reward, sync_scheduled, sync_executed, - sync_rewards, + sync_reward, slashed, balance_start, balance_end, @@ -266,10 +266,10 @@ func (d *MultipleDaysRollingAggregatorImpl) bootstrap(tx *sqlx.Tx, days int, tab blocks_expected, sync_committees_expected, attestations_scheduled, - attestations_executed, - attestation_head_executed, - attestation_source_executed, - attestation_target_executed, + attestations_observed, + attestations_head_executed, + attestations_source_executed, + attestations_target_executed, optimal_inclusion_delay_sum, slasher_reward, slashed_by, @@ -299,7 +299,7 @@ func (d *MultipleDaysRollingAggregatorImpl) bootstrap(tx *sqlx.Tx, days int, tab blocks_cl_sync_aggregate_reward, sync_scheduled, sync_executed, - sync_rewards, + sync_reward, slashed, balance_start, balance_end, @@ -311,10 +311,10 @@ func (d *MultipleDaysRollingAggregatorImpl) bootstrap(tx *sqlx.Tx, days int, tab blocks_expected, sync_committees_expected, attestations_scheduled, - attestations_executed, - attestation_head_executed, - attestation_source_executed, - attestation_target_executed, + attestations_observed, + attestations_head_executed, + attestations_source_executed, + attestations_target_executed, optimal_inclusion_delay_sum, slasher_reward, slashed_by, diff --git a/backend/pkg/exporter/modules/dashboard_data_w_rolling.go b/backend/pkg/exporter/modules/dashboard_data_w_rolling.go index e51c17fb0..69d0d3392 100644 --- a/backend/pkg/exporter/modules/dashboard_data_w_rolling.go +++ b/backend/pkg/exporter/modules/dashboard_data_w_rolling.go @@ -403,7 +403,7 @@ func AddToRollingCustom(tx *sqlx.Tx, custom CustomRolling) error { {{ .Agg.SUM }}blocks_cl_sync_aggregate_reward{{ .Agg.AGG_END }} as blocks_cl_sync_aggregate_reward, {{ .Agg.SUM }}sync_scheduled{{ .Agg.AGG_END }} as sync_scheduled, {{ .Agg.SUM }}sync_executed{{ .Agg.AGG_END }} as sync_executed, - {{ .Agg.SUM }}sync_rewards{{ .Agg.AGG_END }} as sync_rewards, + {{ .Agg.SUM }}sync_reward{{ .Agg.AGG_END }} as sync_reward, {{ .Agg.BOOL_OR }}slashed{{ .Agg.AGG_END }} as slashed, {{ .Agg.SUM }}deposits_count{{ .Agg.AGG_END }} as deposits_count, {{ .Agg.SUM }}deposits_amount{{ .Agg.AGG_END }} as deposits_amount, @@ -413,10 +413,10 @@ func AddToRollingCustom(tx *sqlx.Tx, custom CustomRolling) error { {{ .Agg.SUM }}blocks_expected{{ .Agg.AGG_END }} as blocks_expected, {{ .Agg.SUM }}sync_committees_expected{{ .Agg.AGG_END }} as sync_committees_expected, {{ .Agg.SUM }}attestations_scheduled{{ .Agg.AGG_END }} as attestations_scheduled, - {{ .Agg.SUM }}attestations_executed{{ .Agg.AGG_END }} as attestations_executed, - {{ .Agg.SUM }}attestation_head_executed{{ .Agg.AGG_END }} as attestation_head_executed, - {{ .Agg.SUM }}attestation_source_executed{{ .Agg.AGG_END }} as attestation_source_executed, - {{ .Agg.SUM }}attestation_target_executed{{ .Agg.AGG_END }} as attestation_target_executed, + {{ .Agg.SUM }}attestations_observed{{ .Agg.AGG_END }} as attestations_observed, + {{ .Agg.SUM }}attestations_head_executed{{ .Agg.AGG_END }} as attestations_head_executed, + {{ .Agg.SUM }}attestations_source_executed{{ .Agg.AGG_END }} as attestations_source_executed, + {{ .Agg.SUM }}attestations_target_executed{{ .Agg.AGG_END }} as attestations_target_executed, {{ .Agg.SUM }}optimal_inclusion_delay_sum{{ .Agg.AGG_END }} as optimal_inclusion_delay_sum, {{ .Agg.SUM }}slasher_reward{{ .Agg.AGG_END }} as slasher_reward, {{ .Agg.MAX }}slashed_by{{ .Agg.AGG_END }} as slashed_by, @@ -449,7 +449,7 @@ func AddToRollingCustom(tx *sqlx.Tx, custom CustomRolling) error { blocks_cl_sync_aggregate_reward, sync_scheduled, sync_executed, - sync_rewards, + sync_reward, slashed, balance_end, balance_start, @@ -461,10 +461,10 @@ func AddToRollingCustom(tx *sqlx.Tx, custom CustomRolling) error { blocks_expected, sync_committees_expected, attestations_scheduled, - attestations_executed, - attestation_head_executed, - attestation_source_executed, - attestation_target_executed, + attestations_observed, + attestations_head_executed, + attestations_source_executed, + attestations_target_executed, optimal_inclusion_delay_sum, slasher_reward, slashed_by, @@ -495,7 +495,7 @@ func AddToRollingCustom(tx *sqlx.Tx, custom CustomRolling) error { COALESCE(aggregate_head.blocks_cl_sync_aggregate_reward, 0) as blocks_cl_sync_aggregate_reward, COALESCE(aggregate_head.sync_scheduled, 0) as sync_scheduled, COALESCE(aggregate_head.sync_executed, 0) as sync_executed, - COALESCE(aggregate_head.sync_rewards, 0) as sync_rewards, + COALESCE(aggregate_head.sync_reward, 0) as , aggregate_head.slashed, balance_end, {{ .TailBalancesInsertColumnQuery }} -- balance_start @@ -507,10 +507,10 @@ func AddToRollingCustom(tx *sqlx.Tx, custom CustomRolling) error { COALESCE(aggregate_head.blocks_expected, 0) as blocks_expected, COALESCE(aggregate_head.sync_committees_expected, 0) as sync_committees_expected, COALESCE(aggregate_head.attestations_scheduled, 0) as attestations_scheduled, - COALESCE(aggregate_head.attestations_executed, 0) as attestations_executed, - COALESCE(aggregate_head.attestation_head_executed, 0) as attestation_head_executed, - COALESCE(aggregate_head.attestation_source_executed, 0) as attestation_source_executed, - COALESCE(aggregate_head.attestation_target_executed, 0) as attestation_target_executed, + COALESCE(aggregate_head.attestations_observed, 0) as attestations_observed, + COALESCE(aggregate_head.attestations_head_executed, 0) as attestations_head_executed, + COALESCE(aggregate_head.attestations_source_executed, 0) as attestations_source_executed, + COALESCE(aggregate_head.attestations_target_executed, 0) as attestations_target_executed, COALESCE(aggregate_head.optimal_inclusion_delay_sum, 0) as optimal_inclusion_delay_sum, COALESCE(aggregate_head.slasher_reward, 0) as slasher_reward, aggregate_head.slashed_by, @@ -539,7 +539,7 @@ func AddToRollingCustom(tx *sqlx.Tx, custom CustomRolling) error { blocks_cl_sync_aggregate_reward = NULLIF(COALESCE({{ .TableTo }}.blocks_cl_sync_aggregate_reward, 0) + EXCLUDED.blocks_cl_sync_aggregate_reward, 0), sync_scheduled = NULLIF(COALESCE({{ .TableTo }}.sync_scheduled, 0) + EXCLUDED.sync_scheduled, 0), sync_executed = NULLIF(COALESCE({{ .TableTo }}.sync_executed, 0) + EXCLUDED.sync_executed, 0), - sync_rewards = NULLIF(COALESCE({{ .TableTo }}.sync_rewards, 0) + EXCLUDED.sync_rewards, 0), + sync_reward = NULLIF(COALESCE({{ .TableTo }}.sync_reward, 0) + EXCLUDED.sync_reward, 0), slashed = EXCLUDED.slashed OR {{ .TableTo }}.slashed, balance_end = COALESCE(EXCLUDED.balance_end, {{ .TableTo }}.balance_end), deposits_count = NULLIF(COALESCE({{ .TableTo }}.deposits_count, 0) + EXCLUDED.deposits_count, 0), @@ -550,10 +550,10 @@ func AddToRollingCustom(tx *sqlx.Tx, custom CustomRolling) error { blocks_expected = NULLIF(COALESCE({{ .TableTo }}.blocks_expected, 0) + EXCLUDED.blocks_expected, 0), sync_committees_expected = NULLIF(COALESCE({{ .TableTo }}.sync_committees_expected, 0) + EXCLUDED.sync_committees_expected, 0), attestations_scheduled = NULLIF(COALESCE({{ .TableTo }}.attestations_scheduled, 0) + EXCLUDED.attestations_scheduled, 0), - attestations_executed = NULLIF(COALESCE({{ .TableTo }}.attestations_executed, 0) + EXCLUDED.attestations_executed, 0), - attestation_head_executed = NULLIF(COALESCE({{ .TableTo }}.attestation_head_executed, 0) + EXCLUDED.attestation_head_executed, 0), - attestation_source_executed = NULLIF(COALESCE({{ .TableTo }}.attestation_source_executed, 0) + EXCLUDED.attestation_source_executed, 0), - attestation_target_executed = NULLIF(COALESCE({{ .TableTo }}.attestation_target_executed, 0) + EXCLUDED.attestation_target_executed, 0), + attestations_observed = NULLIF(COALESCE({{ .TableTo }}.attestations_observed, 0) + EXCLUDED.attestations_observed, 0), + attestations_head_executed = NULLIF(COALESCE({{ .TableTo }}.attestations_head_executed, 0) + EXCLUDED.attestations_head_executed, 0), + attestations_source_executed = NULLIF(COALESCE({{ .TableTo }}.attestations_source_executed, 0) + EXCLUDED.attestations_source_executed, 0), + attestations_target_executed = NULLIF(COALESCE({{ .TableTo }}.attestation_target_executed, 0) + EXCLUDED.attestations_target_executed, 0), optimal_inclusion_delay_sum = NULLIF(COALESCE({{ .TableTo }}.optimal_inclusion_delay_sum, 0) + EXCLUDED.optimal_inclusion_delay_sum, 0), epoch_end = EXCLUDED.epoch_end, slasher_reward = NULLIF(COALESCE({{ .TableTo }}.slasher_reward, 0) + EXCLUDED.slasher_reward, 0), @@ -670,7 +670,7 @@ func (d *RollingAggregator) removeFromRolling(tx *sqlx.Tx, tableName string, sta SUM(blocks_cl_sync_aggregate_reward) as blocks_cl_sync_aggregate_reward, SUM(sync_scheduled) as sync_scheduled, SUM(sync_executed) as sync_executed, - SUM(sync_rewards) as sync_rewards, + SUM(sync_reward) as sync_reward, SUM(deposits_count) as deposits_count, SUM(deposits_amount) as deposits_amount, SUM(withdrawals_count) as withdrawals_count, @@ -679,10 +679,10 @@ func (d *RollingAggregator) removeFromRolling(tx *sqlx.Tx, tableName string, sta SUM(blocks_expected) as blocks_expected, SUM(sync_committees_expected) as sync_committees_expected, SUM(attestations_scheduled) as attestations_scheduled, - SUM(attestations_executed) as attestations_executed, - SUM(attestation_head_executed) as attestation_head_executed, - SUM(attestation_source_executed) as attestation_source_executed, - SUM(attestation_target_executed) as attestation_target_executed, + SUM(attestations_observed) as attestations_observed, + SUM(attestations_head_executed) as attestations_head_executed, + SUM(attestations_source_executed) as attestations_source_executed, + SUM(attestations_target_executed) as attestations_target_executed, SUM(optimal_inclusion_delay_sum) as optimal_inclusion_delay_sum, SUM(slasher_reward) as slasher_reward, MAX(last_executed_duty_epoch) as last_executed_duty_epoch @@ -713,7 +713,7 @@ func (d *RollingAggregator) removeFromRolling(tx *sqlx.Tx, tableName string, sta COALESCE(aggregate_tail.blocks_cl_sync_aggregate_reward, 0) as blocks_cl_sync_aggregate_reward, COALESCE(aggregate_tail.sync_scheduled, 0) as sync_scheduled, COALESCE(aggregate_tail.sync_executed, 0) as sync_executed, - COALESCE(aggregate_tail.sync_rewards, 0) as sync_rewards, + COALESCE(aggregate_tail.sync_reward, 0) as sync_reward, balance_start, COALESCE(aggregate_tail.deposits_count, 0) as deposits_count, COALESCE(aggregate_tail.deposits_amount, 0) as deposits_amount, @@ -723,10 +723,10 @@ func (d *RollingAggregator) removeFromRolling(tx *sqlx.Tx, tableName string, sta COALESCE(aggregate_tail.blocks_expected, 0) as blocks_expected, COALESCE(aggregate_tail.sync_committees_expected, 0) as sync_committees_expected, COALESCE(aggregate_tail.attestations_scheduled, 0) as attestations_scheduled, - COALESCE(aggregate_tail.attestations_executed, 0) as attestations_executed, - COALESCE(aggregate_tail.attestation_head_executed, 0) as attestation_head_executed, - COALESCE(aggregate_tail.attestation_source_executed, 0) as attestation_source_executed, - COALESCE(aggregate_tail.attestation_target_executed, 0) as attestation_target_executed, + COALESCE(aggregate_tail.attestations_observed, 0) as attestations_observed, + COALESCE(aggregate_tail.attestations_head_executed, 0) as attestations_head_executed, + COALESCE(aggregate_tail.attestations_source_executed, 0) as attestations_source_executed, + COALESCE(aggregate_tail.attestations_target_executed, 0) as attestations_target_executed, COALESCE(aggregate_tail.optimal_inclusion_delay_sum, 0) as optimal_inclusion_delay_sum, COALESCE(aggregate_tail.slasher_reward, 0) as slasher_reward, aggregate_tail.last_executed_duty_epoch @@ -753,7 +753,7 @@ func (d *RollingAggregator) removeFromRolling(tx *sqlx.Tx, tableName string, sta blocks_cl_sync_aggregate_reward = COALESCE(v.blocks_cl_sync_aggregate_reward, 0) - result.blocks_cl_sync_aggregate_reward, sync_scheduled = COALESCE(v.sync_scheduled, 0) - result.sync_scheduled, sync_executed = COALESCE(v.sync_executed, 0) - result.sync_executed, - sync_rewards = COALESCE(v.sync_rewards, 0) - result.sync_rewards, + sync_reward = COALESCE(v.sync_reward, 0) - result.sync_reward, balance_start = COALESCE(result.balance_start, v.balance_start), deposits_count = COALESCE(v.deposits_count, 0) - result.deposits_count, deposits_amount = COALESCE(v.deposits_amount, 0) - result.deposits_amount, @@ -763,10 +763,10 @@ func (d *RollingAggregator) removeFromRolling(tx *sqlx.Tx, tableName string, sta blocks_expected = COALESCE(v.blocks_expected, 0) - result.blocks_expected, sync_committees_expected = COALESCE(v.sync_committees_expected, 0) - result.sync_committees_expected, attestations_scheduled = COALESCE(v.attestations_scheduled, 0) - result.attestations_scheduled, - attestations_executed = COALESCE(v.attestations_executed, 0) - result.attestations_executed, - attestation_head_executed = COALESCE(v.attestation_head_executed, 0) - result.attestation_head_executed, - attestation_source_executed = COALESCE(v.attestation_source_executed, 0) - result.attestation_source_executed, - attestation_target_executed = COALESCE(v.attestation_target_executed, 0) - result.attestation_target_executed, + attestations_observed = COALESCE(v.attestations_observed, 0) - result.attestations_observed, + attestations_head_executed = COALESCE(v.attestations_head_executed, 0) - result.attestations_head_executed, + attestations_source_executed = COALESCE(v.attestations_source_executed, 0) - result.attestations_source_executed, + attestations_target_executed = COALESCE(v.attestations_target_executed, 0) - result.attestations_target_executed, optimal_inclusion_delay_sum = COALESCE(v.optimal_inclusion_delay_sum, 0) - result.optimal_inclusion_delay_sum, epoch_start = result.epoch_start, slasher_reward = COALESCE(v.slasher_reward, 0) - result.slasher_reward, diff --git a/backend/pkg/exporter/modules/execution_payloads_exporter.go b/backend/pkg/exporter/modules/execution_payloads_exporter.go index 6159708ef..e7f80bef1 100644 --- a/backend/pkg/exporter/modules/execution_payloads_exporter.go +++ b/backend/pkg/exporter/modules/execution_payloads_exporter.go @@ -133,9 +133,9 @@ func (d *executionPayloadsExporter) maintainTable() (err error) { minBlock := uint64(blocks.MinBlock.Int64) maxBlock := uint64(blocks.MaxBlock.Int64) - // limit to 1mil blocks to prevent reading too much from bigtable - if maxBlock-minBlock > 1e6 { - maxBlock = minBlock + 1e6 + // limit to 200k blocks to prevent reading too much from bigtable + if maxBlock-minBlock > 200_000 { + maxBlock = minBlock + 200_000 } log.Infof("min block: %v, max block: %v", blocks.MinBlock, blocks.MaxBlock)