-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Conversation
// 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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
type BlockRewardsFetcher interface { | ||
GetBlockRewardsData(context.Context, interfaces.ReadOnlySignedBeaconBlock) (*BlockRewards, *http2.DefaultErrorJson) | ||
GetStateForRewards(ctx context.Context, blk interfaces.ReadOnlySignedBeaconBlock) (state.BeaconState, *http2.DefaultErrorJson) | ||
} |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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.
Co-authored-by: Radosław Kapka <rkapka@wp.pl>
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 thetotal
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