-
Notifications
You must be signed in to change notification settings - Fork 922
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
Add functionality to retrieve all pending items from pools #7530
Conversation
func (p *Pool) PendingAttesterSlashings(ctx context.Context, state *beaconstate.BeaconState) []*ethpb.AttesterSlashing { | ||
// This method will return all pending attester slashings unless the `block` parameter is set to true | ||
// to indicate the request is for a block. | ||
func (p *Pool) PendingAttesterSlashings(ctx context.Context, state *beaconstate.BeaconState, block bool) []*ethpb.AttesterSlashing { |
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.
block bool is ambiguous, it sounds like you want the function to block. Perhaps we can call for forProposal
? or forBlockProposal
?
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.
Maybe we can call it noLimit
?
@@ -407,7 +416,7 @@ func TestPool_PendingProposerSlashings_Slashed(t *testing.T) { | |||
p := &Pool{ | |||
pendingProposerSlashing: tt.fields.pending, | |||
} | |||
assert.DeepEqual(t, tt.want, p.PendingProposerSlashings(context.Background(), beaconState)) | |||
assert.DeepEqual(t, tt.want, p.PendingProposerSlashings(context.Background(), beaconState, false /*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.
Change comment here if we change the input arg name to something else
if !block { | ||
maxSlashings = uint64(len(p.pendingAttesterSlashing)) | ||
} | ||
pending := make([]*ethpb.AttesterSlashing, 0, maxSlashings) | ||
for i := 0; i < len(p.pendingAttesterSlashing); i++ { | ||
slashing := p.pendingAttesterSlashing[i] |
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.
Can you move slashing := ...
after the break check?
if !block { | ||
maxSlashings = uint64(len(p.pendingProposerSlashing)) | ||
} | ||
pending := make([]*ethpb.ProposerSlashing, 0, maxSlashings) | ||
for i := 0; i < len(p.pendingProposerSlashing); i++ { | ||
slashing := p.pendingProposerSlashing[i] |
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.
Can you move slashing := ...
after the break check?
@@ -26,25 +25,30 @@ func NewPool() *Pool { | |||
} | |||
|
|||
// PendingAttesterSlashings returns attester slashings that are able to be included into a block. | |||
// This method will not return more than the block enforced MaxAttesterSlashings. | |||
func (p *Pool) PendingAttesterSlashings(ctx context.Context, state *beaconstate.BeaconState) []*ethpb.AttesterSlashing { | |||
p.lock.RLock() |
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.
Not sure why this was a RLock when this functin mutates.
What type of PR is this?
This PR adds functionality to the slashings and exits pools to allow retrieving all pending items, as their only available action prior was to return only the max allowed per block.
This PR is needed for #7525