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

Deneb: Produce Block V3 - adding consensus block value #12948

Merged
merged 23 commits into from
Oct 10, 2023

Conversation

james-prysm
Copy link
Contributor

@james-prysm james-prysm commented Sep 22, 2023

What type of PR is this?
Feature

What does this PR do? Why is it needed?

This PR adds the consensus block value to the produce block v3 /eth/v3/validator/blocks/{slot} which is the same value as the total field from the /eth/v1/beacon/rewards/blocks/{block_id} endpoint. To do this I have introduced a new interface and service to isolate testing on reward responses and the produce block v3 setup.

Which issues(s) does this PR fix?

Fixes # ethereum/beacon-APIs#358 for prysm

@james-prysm james-prysm added API Api related tasks Breaking Changes Breaking changes for a major release Deneb PRs or issues for the Deneb upgrade labels Sep 22, 2023
@james-prysm james-prysm self-assigned this Sep 22, 2023
Comment on lines 167 to 169
// We want to run several block processing functions that update the proposer's balance.
// This will allow us to calculate proposer rewards for each operation (atts, slashings etc).
// To do this, we replay the state up to the block's slot, but before processing the block.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment should be placed before the call to this function in BlockRewards because it is accurate only in that function context.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the produceblockv3 needs to do the same , it should be accurate to the context of the block passed in as an argument right?

Comment on lines 13 to 16
type BlockRewardsFetcher interface {
GetBlockRewardsData(context.Context, interfaces.ReadOnlySignedBeaconBlock) (*BlockRewards, *http2.DefaultErrorJson)
GetStateForRewards(ctx context.Context, blk interfaces.ReadOnlySignedBeaconBlock) (state.BeaconState, *http2.DefaultErrorJson)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: one function has named params, the other one doesn't

http2 "github.com/prysmaticlabs/prysm/v4/network/http"
)

// BlockRewardsFetcher retrieves the Consensus Payload ( aka block rewards) of the passed in block
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest making this comment more generic because GetStateForRewards doesn't retrieve the consensus payload

switch b := i.(type) {
case *eth.GenericBeaconBlock_Phase0:
//ignore for phase0
return nil, nil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of returning nil here and then checking for nil outside, I think it makes more sense to support all types here and skip the function call when we have a phase0 block. This will make the function more usable and someone reading produceBlockV3 will understand the intent better, without having to navigate here to figure out why the result can be nil.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i changed it to its own function and made it more apparent.

}

// GetBlockRewardsData returns the BlockRewards Object which is used for the BlockRewardsResponse and ProduceBlockV3
func (rs *BlockRewardService) GetBlockRewardsData(ctx context.Context, blk interfaces.ReadOnlySignedBeaconBlock) (*BlockRewards, *http2.DefaultErrorJson) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should place the interface, the service struct and its methods in a new file.

@james-prysm james-prysm marked this pull request as ready for review September 25, 2023 19:37
@james-prysm james-prysm requested a review from a team as a code owner September 25, 2023 19:37
@james-prysm james-prysm changed the title Deneb: Produce Block V3 - adding consensus payload Deneb: Produce Block V3 - adding consensus block value Oct 9, 2023
@prylabs-bulldozer prylabs-bulldozer bot merged commit af70677 into develop Oct 10, 2023
@prylabs-bulldozer prylabs-bulldozer bot deleted the deneb-blockv3-change branch October 10, 2023 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Api related tasks Breaking Changes Breaking changes for a major release Deneb PRs or issues for the Deneb upgrade
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants