-
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
Deprecate store in blockchain pkg #10903
Merged
Merged
Changes from 11 commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
e06df41
Deprecate store WIP
potuz a1dc423
Merge remote-tracking branch 'origin/develop' into deprecate_store_4
potuz 19d8a06
fix spectests build
potuz 34aaec5
mock right interface
potuz 950c589
sync tests build
potuz 2b9595c
more tests builds
potuz e72799e
blockchain tests
potuz 79ae441
Merge remote-tracking branch 'origin/develop' into deprecate_store_4
potuz fcd384a
more blockchain tests
potuz ea4eabe
update best justified from genesis
potuz 1761b12
Merge remote-tracking branch 'origin/develop' into deprecate_store_4
potuz 9736f63
deal with nil head on saveHead
potuz edcfebb
initialize prev justified checkpoint
potuz e37c835
update finalization correctly
potuz d0d8b48
update finalization logic
potuz f6ea696
update finalization logic
potuz 18542f7
Merge branch 'develop' into deprecate_store_4
potuz 968c0b5
track the wall clock on forkchoice spectests
potuz 84a152c
Merge branch 'wall_clock_spectests' into deprecate_store_4
potuz 289a62b
Merge remote-tracking branch 'origin/develop' into deprecate_store_4
potuz 6ad9c0c
export copies of checkpoints from blockchain package
potuz 58be2c9
do not use forkchoice's head on HeadRoot
potuz 081024d
Remove debug remain
potuz 27abeb6
terence's review
potuz 64cec72
Merge branch 'develop' into deprecate_store_4
potuz 7170d79
add forkchoice types deps
potuz 61abba3
wtf
potuz 02191e6
debugging
potuz 64edcad
init-sync: update justified and finalized checkpoints on db
potuz fe856f3
call updateFinalized instead of only DB
potuz 21b1c7b
remove debug symbols
potuz caee5eb
Merge branch 'develop' into deprecate_store_4
terencechain e111a15
safe copy headroot
potuz 1588a3d
Merge remote-tracking branch 'origin/develop' into deprecate_store_4
potuz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,8 +4,6 @@ import ( | |
"context" | ||
"time" | ||
|
||
"github.com/pkg/errors" | ||
"github.com/prysmaticlabs/prysm/beacon-chain/blockchain/store" | ||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" | ||
"github.com/prysmaticlabs/prysm/beacon-chain/forkchoice" | ||
doublylinkedtree "github.com/prysmaticlabs/prysm/beacon-chain/forkchoice/doubly-linked-tree" | ||
|
@@ -81,9 +79,9 @@ type CanonicalFetcher interface { | |
// FinalizationFetcher defines a common interface for methods in blockchain service which | ||
// directly retrieve finalization and justification related data. | ||
type FinalizationFetcher interface { | ||
FinalizedCheckpt() (*ethpb.Checkpoint, error) | ||
CurrentJustifiedCheckpt() (*ethpb.Checkpoint, error) | ||
PreviousJustifiedCheckpt() (*ethpb.Checkpoint, error) | ||
FinalizedCheckpt() *ethpb.Checkpoint | ||
CurrentJustifiedCheckpt() *ethpb.Checkpoint | ||
PreviousJustifiedCheckpt() *ethpb.Checkpoint | ||
VerifyFinalizedBlkDescendant(ctx context.Context, blockRoot [32]byte) error | ||
} | ||
|
||
|
@@ -94,47 +92,27 @@ type OptimisticModeFetcher interface { | |
} | ||
|
||
// FinalizedCheckpt returns the latest finalized checkpoint from chain store. | ||
func (s *Service) FinalizedCheckpt() (*ethpb.Checkpoint, error) { | ||
cp, err := s.store.FinalizedCheckpt() | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return ethpb.CopyCheckpoint(cp), nil | ||
func (s *Service) FinalizedCheckpt() *ethpb.Checkpoint { | ||
cp := s.ForkChoicer().FinalizedCheckpoint() | ||
return ðpb.Checkpoint{Epoch: cp.Epoch, Root: cp.Root[:]} | ||
} | ||
|
||
// CurrentJustifiedCheckpt returns the current justified checkpoint from chain store. | ||
func (s *Service) CurrentJustifiedCheckpt() (*ethpb.Checkpoint, error) { | ||
cp, err := s.store.JustifiedCheckpt() | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return ethpb.CopyCheckpoint(cp), nil | ||
// PreviousJustifiedCheckpt returns the current justified checkpoint from chain store. | ||
func (s *Service) PreviousJustifiedCheckpt() *ethpb.Checkpoint { | ||
cp := s.ForkChoicer().PreviousJustifiedCheckpoint() | ||
return ðpb.Checkpoint{Epoch: cp.Epoch, Root: cp.Root[:]} | ||
} | ||
|
||
// PreviousJustifiedCheckpt returns the previous justified checkpoint from chain store. | ||
func (s *Service) PreviousJustifiedCheckpt() (*ethpb.Checkpoint, error) { | ||
cp, err := s.store.PrevJustifiedCheckpt() | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return ethpb.CopyCheckpoint(cp), nil | ||
// CurrentJustifiedCheckpt returns the current justified checkpoint from chain store. | ||
func (s *Service) CurrentJustifiedCheckpt() *ethpb.Checkpoint { | ||
cp := s.ForkChoicer().JustifiedCheckpoint() | ||
return ðpb.Checkpoint{Epoch: cp.Epoch, Root: cp.Root[:]} | ||
} | ||
|
||
// BestJustifiedCheckpt returns the best justified checkpoint from store. | ||
func (s *Service) BestJustifiedCheckpt() (*ethpb.Checkpoint, error) { | ||
cp, err := s.store.BestJustifiedCheckpt() | ||
if err != nil { | ||
// If there is no best justified checkpoint, return the checkpoint with root as zeros to be used for genesis cases. | ||
if errors.Is(err, store.ErrNilCheckpoint) { | ||
return ðpb.Checkpoint{Root: params.BeaconConfig().ZeroHash[:]}, nil | ||
} | ||
return nil, err | ||
} | ||
|
||
return ethpb.CopyCheckpoint(cp), nil | ||
func (s *Service) BestJustifiedCheckpt() *ethpb.Checkpoint { | ||
cp := s.ForkChoicer().BestJustifiedCheckpoint() | ||
return ðpb.Checkpoint{Epoch: cp.Epoch, Root: cp.Root[:]} | ||
} | ||
|
||
// HeadSlot returns the slot of the head of the chain. | ||
|
@@ -154,9 +132,13 @@ func (s *Service) HeadRoot(ctx context.Context) ([]byte, error) { | |
s.headLock.RLock() | ||
defer s.headLock.RUnlock() | ||
|
||
if s.headRoot() != params.BeaconConfig().ZeroHash { | ||
r := s.headRoot() | ||
return r[:], nil | ||
if s.head != nil && s.head.root != params.BeaconConfig().ZeroHash { | ||
return s.head.root[:], nil | ||
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. we should return a copy here. By taking the slice, you still reference the root in 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. Thanks this is right I think. |
||
} | ||
|
||
root := s.ForkChoicer().CachedHeadRoot() | ||
if root != params.BeaconConfig().ZeroHash { | ||
return root[:], nil | ||
} | ||
|
||
b, err := s.cfg.BeaconDB.HeadBlock(ctx) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
We will move all these to
*forkchoicetypes.Checkpoint
in a future PR