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

[Merged by Bors] - Block v3 endpoint #4629

Closed
wants to merge 52 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
2cf2dec
block v3 endpoint init
eserilev Aug 14, 2023
cd36be5
block v3 flow
eserilev Aug 14, 2023
6515ce4
block v3 flow
eserilev Aug 14, 2023
a55e91d
continue refactor
eserilev Aug 15, 2023
5d984f0
the full flow...
eserilev Aug 16, 2023
48661b4
add api logic
eserilev Aug 16, 2023
ae690fb
add api logic
eserilev Aug 16, 2023
1802e45
add new endpoint version
eserilev Aug 16, 2023
281d88d
Merge branch 'unstable' of https://github.com/sigp/lighthouse into bl…
eserilev Aug 16, 2023
bac744e
added v3 endpoint
eserilev Aug 16, 2023
54860ac
some debugging
eserilev Aug 21, 2023
50b0d13
merge conflicts
eserilev Aug 31, 2023
17f00f3
merge v2 flow with v3
eserilev Aug 31, 2023
133c289
Merge branch 'unstable' of https://github.com/sigp/lighthouse into bl…
eserilev Sep 4, 2023
272cb76
debugging
eserilev Sep 4, 2023
682eb61
tests passing
eserilev Sep 4, 2023
03f442f
tests passing
eserilev Sep 4, 2023
877973e
revert cargo lock
eserilev Sep 4, 2023
5be3113
initial v3 test
eserilev Sep 4, 2023
ae2b1d3
blinded payload test case passing
eserilev Sep 5, 2023
0edfcbd
fix clippy issues
eserilev Sep 5, 2023
2599fec
cleanup
eserilev Sep 5, 2023
0f0c41e
cleanup
eserilev Sep 5, 2023
f285d16
remove dead code
eserilev Sep 5, 2023
8021687
fixed logs
eserilev Sep 6, 2023
a59a966
add block value
eserilev Sep 6, 2023
d5cb547
block value fix
eserilev Sep 6, 2023
36f863a
linting
eserilev Sep 6, 2023
6441c52
initial merge
eserilev Sep 25, 2023
c68e7af
merge unstable
eserilev Sep 27, 2023
df25083
refactor
eserilev Sep 27, 2023
91d37e9
add consensus block value
eserilev Sep 28, 2023
6878abe
lint
eserilev Sep 28, 2023
33254e7
Merge branch 'unstable' of https://github.com/sigp/lighthouse into bl…
eserilev Oct 1, 2023
8a674dd
update header name to consensus block value
eserilev Oct 1, 2023
4b1f396
prevent setting the participation flag
eserilev Oct 5, 2023
518c6a0
clone get_epoch_participation result
eserilev Oct 5, 2023
0a70967
fmt
eserilev Oct 5, 2023
1d7cbf0
clone epoch participation outside of the loop
eserilev Oct 6, 2023
dc746c4
Merge branch 'unstable' of https://github.com/sigp/lighthouse into bl…
eserilev Oct 7, 2023
1667b32
refactor based on feedback
eserilev Oct 14, 2023
4d3621e
update
eserilev Oct 14, 2023
7dc7ece
resolve merge conflicts
eserilev Oct 21, 2023
59e1a18
remove comments
eserilev Oct 21, 2023
34a08a1
refactor
eserilev Oct 21, 2023
219ad17
header bugfix
eserilev Oct 26, 2023
cb5f56e
fmt
eserilev Oct 26, 2023
d942285
Merge branch 'unstable' of https://github.com/sigp/lighthouse into bl…
eserilev Nov 1, 2023
e0b5680
changes based on feedback
eserilev Nov 1, 2023
2795024
spawn blocking
eserilev Nov 1, 2023
bde8b52
fix comments, remove unused error
eserilev Nov 2, 2023
4ce05d1
Restore comment
michaelsproul Nov 3, 2023
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
25 changes: 21 additions & 4 deletions beacon_node/beacon_chain/src/beacon_block_reward.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,17 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
state.build_committee_cache(RelativeEpoch::Previous, &self.spec)?;
state.build_committee_cache(RelativeEpoch::Current, &self.spec)?;

self.compute_beacon_block_reward_with_cache(block, block_root, state)
}

// This should only be called after a committee cache has been built
// for both the previous and current epoch
fn compute_beacon_block_reward_with_cache<Payload: AbstractExecPayload<T::EthSpec>>(
&self,
block: BeaconBlockRef<'_, T::EthSpec, Payload>,
block_root: Hash256,
state: &BeaconState<T::EthSpec>,
) -> Result<StandardBlockReward, BeaconChainError> {
let proposer_index = block.proposer_index();

let sync_aggregate_reward =
Expand Down Expand Up @@ -178,7 +189,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
>(
&self,
block: BeaconBlockRef<'_, T::EthSpec, Payload>,
state: &mut BeaconState<T::EthSpec>,
state: &BeaconState<T::EthSpec>,
) -> Result<BeaconBlockSubRewardValue, BeaconChainError> {
let total_active_balance = state.get_total_active_balance()?;
let base_reward_per_increment =
Expand All @@ -191,6 +202,9 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
.safe_mul(WEIGHT_DENOMINATOR)?
.safe_div(PROPOSER_WEIGHT)?;

let mut current_epoch_participation = state.current_epoch_participation()?.clone();
let mut previous_epoch_participation = state.previous_epoch_participation()?.clone();

for attestation in block.body().attestations() {
let data = &attestation.data;
let inclusion_delay = state.slot().safe_sub(data.slot)?.as_u64();
Expand All @@ -203,13 +217,16 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
)?;

let attesting_indices = get_attesting_indices_from_state(state, attestation)?;

let mut proposer_reward_numerator = 0;
for index in attesting_indices {
let index = index as usize;
for (flag_index, &weight) in PARTICIPATION_FLAG_WEIGHTS.iter().enumerate() {
let epoch_participation =
state.get_epoch_participation_mut(data.target.epoch)?;
let epoch_participation = if data.target.epoch == state.current_epoch() {
&mut current_epoch_participation
} else {
&mut previous_epoch_participation
};

let validator_participation = epoch_participation
.get_mut(index)
.ok_or(BeaconStateError::ParticipationOutOfBounds(index))?;
Expand Down
Loading
Loading