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

feat: add endpoint for Altair block reward #6178

Merged
merged 28 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
6679119
Add block rewards api
ensi321 Dec 5, 2023
f67421b
Add test
ensi321 Dec 5, 2023
0b030f2
Add unit test
ensi321 Dec 11, 2023
5e3f0f5
Lint
ensi321 Dec 11, 2023
c2da457
Address comment
ensi321 Dec 12, 2023
1e47858
Reduce code redundancy
ensi321 Dec 12, 2023
ac9bb42
Read reward cache first before calculate
ensi321 Dec 27, 2023
1fc3201
Lint
ensi321 Dec 27, 2023
f702c2b
Partially address comments
ensi321 Jan 11, 2024
6c14d0c
Accept optional postState to get the reward cache
ensi321 Jan 11, 2024
f331e5a
Update test
ensi321 Jan 11, 2024
db5cc41
lint
ensi321 Jan 11, 2024
edc8c3c
Update packages/beacon-node/src/chain/rewards/blockRewards.ts
ensi321 Jan 22, 2024
f543045
Update packages/beacon-node/src/chain/rewards/blockRewards.ts
ensi321 Jan 22, 2024
b605529
Update packages/beacon-node/src/chain/rewards/blockRewards.ts
ensi321 Jan 22, 2024
45734fa
Update packages/beacon-node/src/chain/rewards/blockRewards.ts
ensi321 Jan 22, 2024
f80daf4
Rename proposerRewards to blockRewards. Fix import
ensi321 Jan 22, 2024
3f8d42c
Remove getBlockRewards from api ignore list
ensi321 Jan 22, 2024
f2bbe95
Fix test
ensi321 Jan 23, 2024
cde10e9
Rename state to preState
ensi321 Jan 25, 2024
a6e2fc4
Add description to fields in BlockRewards
ensi321 Jan 25, 2024
ee42dde
Clean up imports
ensi321 Jan 25, 2024
b6f68d0
Use jsdoc to document properties
nflaig Jan 25, 2024
5c10acf
Apply suggestions from code review
wemeetagain Jan 25, 2024
47e9650
Merge branch 'ChainSafe:unstable' into rewards-api
ensi321 Jan 30, 2024
719ab1d
Add `getPreStateSync()`
ensi321 Jan 30, 2024
51bbf5e
fix: clone states to compute block rewards
twoeths Feb 20, 2024
eceea02
Merge pull request #2 from tuyennhv/tuyennhv/rewards-api
ensi321 Feb 20, 2024
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
Prev Previous commit
Next Next commit
Clean up imports
  • Loading branch information
ensi321 committed Jan 25, 2024
commit ee42dded59d8701746c0398f11c3dedd48c2a89d
1 change: 0 additions & 1 deletion packages/api/src/beacon/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import type {Api} from "./routes/index.js";
export * as routes from "./routes/index.js";
export {getClient} from "./client/index.js";
export type {Api};
export type {BlockRewards} from "./routes/index.js";

// Declare namespaces for CLI options
export type ApiNamespace = keyof Api;
Expand Down
2 changes: 0 additions & 2 deletions packages/api/src/beacon/routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ export type Api = {
validator: ValidatorApi;
};

export type {BlockRewards} from "./beacon/index.js";

// Reasoning of the API definitions
// ================================
//
Expand Down
3 changes: 1 addition & 2 deletions packages/beacon-node/src/chain/chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import {ProcessShutdownCallback} from "@lodestar/validator";
import {Logger, gweiToWei, isErrorAborted, pruneSetToMax, sleep, toHex} from "@lodestar/utils";
import {ForkSeq, SLOTS_PER_EPOCH} from "@lodestar/params";

import {type BlockRewards} from "@lodestar/api";
import {GENESIS_EPOCH, ZERO_HASH} from "../constants/index.js";
import {IBeaconDb} from "../db/index.js";
import {Metrics} from "../metrics/index.js";
Expand Down Expand Up @@ -77,7 +76,7 @@ import {BlockAttributes, produceBlockBody, produceCommonBlockBody} from "./produ
import {computeNewStateRoot} from "./produceBlock/computeNewStateRoot.js";
import {BlockInput} from "./blocks/types.js";
import {SeenAttestationDatas} from "./seenCache/seenAttestationData.js";
import {computeBlockRewards} from "./rewards/blockRewards.js";
import {BlockRewards, computeBlockRewards} from "./rewards/blockRewards.js";
import {ShufflingCache} from "./shufflingCache.js";
import {StateContextCache} from "./stateCache/stateContextCache.js";
import {SeenGossipBlockInput} from "./seenCache/index.js";
Expand Down
2 changes: 1 addition & 1 deletion packages/beacon-node/src/chain/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import {BeaconConfig} from "@lodestar/config";
import {Logger} from "@lodestar/utils";

import {IForkChoice, ProtoBlock} from "@lodestar/fork-choice";
import {type BlockRewards} from "@lodestar/api";
import {IEth1ForBlockProduction} from "../eth1/index.js";
import {IExecutionEngine, IExecutionBuilder} from "../execution/index.js";
import {Metrics} from "../metrics/metrics.js";
Expand Down Expand Up @@ -53,6 +52,7 @@ import {AssembledBlockType, BlockAttributes, BlockType} from "./produceBlock/pro
import {SeenAttestationDatas} from "./seenCache/seenAttestationData.js";
import {SeenGossipBlockInput} from "./seenCache/index.js";
import {ShufflingCache} from "./shufflingCache.js";
import {BlockRewards} from "./rewards/blockRewards.js";

export {BlockType, type AssembledBlockType};
export {type ProposerPreparationData};
Expand Down
3 changes: 2 additions & 1 deletion packages/beacon-node/src/chain/rewards/blockRewards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import {
} from "@lodestar/state-transition";
import {allForks, altair, phase0} from "@lodestar/types";
import {ForkName, WHISTLEBLOWER_REWARD_QUOTIENT} from "@lodestar/params";
import {type BlockRewards} from "@lodestar/api";
import {routes} from "@lodestar/api";

export type BlockRewards = routes.beacon.BlockRewards;
type SubRewardValue = number; // All reward values should be integer

/**
Expand Down
Loading