-
Notifications
You must be signed in to change notification settings - Fork 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
Capella beacon state #11141
Capella beacon state #11141
Changes from 16 commits
d56db46
657b897
fffa376
ed6c73a
2b8a8da
6d303f6
d21d437
f061dab
00a840b
a8c9125
6790b1c
b1ba747
0b7cfbd
437c265
c5deedb
8af7855
d5e8c25
f98e90b
8b4b3cf
d2aabcf
e74ad33
e21ab9c
c96303e
50ba24b
70c74ba
525066f
686d14c
5926230
b05ed63
bfeff5e
a995186
5d84931
ad28693
a311c89
6326523
d7de7c7
2647b1f
bcae282
fb6b1d1
0df2f33
a117e0b
0b00e1e
1a43b53
5548f0f
6a49722
54e519c
ae78e88
2ab4908
872245c
f437cd8
6266ce2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package state_native | ||
|
||
import ( | ||
types "github.com/prysmaticlabs/prysm/consensus-types/primitives" | ||
enginev1 "github.com/prysmaticlabs/prysm/proto/engine/v1" | ||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" | ||
"github.com/prysmaticlabs/prysm/runtime/version" | ||
) | ||
|
||
// WithdrawalQueue returns the list of pending withdrawals. | ||
func (b *BeaconState) WithdrawalQueue() ([]*enginev1.Withdrawal, error) { | ||
if b.version < version.Capella { | ||
return nil, errNotSupported("WithdrawalQueue", b.version) | ||
} | ||
|
||
b.lock.RLock() | ||
defer b.lock.RUnlock() | ||
|
||
return b.withdrawalQueueVal(), nil | ||
} | ||
|
||
func (b *BeaconState) withdrawalQueueVal() []*enginev1.Withdrawal { | ||
return ethpb.CopyWithdrawalSlice(b.withdrawalQueue) | ||
} | ||
|
||
// NextWithdrawalIndex returns the index that will be assigned to the next withdrawal. | ||
func (b *BeaconState) NextWithdrawalIndex() (uint64, error) { | ||
if b.version < version.Capella { | ||
return 0, errNotSupported("NextWithdrawalIndex", b.version) | ||
} | ||
|
||
b.lock.RLock() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we want a lock to read the version? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Version? This is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think @potuz refers to |
||
defer b.lock.RUnlock() | ||
|
||
return b.nextWithdrawalIndex, nil | ||
} | ||
|
||
// NextPartialWithdrawalValidatorIndex returns the index of the validator which is | ||
// next in line for a partial withdrawal. | ||
func (b *BeaconState) NextPartialWithdrawalValidatorIndex() (types.ValidatorIndex, error) { | ||
if b.version < version.Capella { | ||
return 0, errNotSupported("NextPartialWithdrawalValidatorIndex", b.version) | ||
} | ||
|
||
b.lock.RLock() | ||
defer b.lock.RUnlock() | ||
|
||
return b.nextPartialWithdrawalValidatorIndex, 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.
This case switch is a good candidate for simplification using generics since all cases are the same function based on pbState.
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.
Yes, this was my impression too. But I didn't want to refactor existing code in this PR.
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.
There isn't even a need for generics if we can just pass in fastssz.Marshaler as an interface (beacon state satisfies this)