Block backfilling (#12968)

* backfill service

* fix bug where origin state is never unlocked

* support mvslice states

* use renamed interface

* refactor db code to skip block cache for backfill

* lint

* add test for verifier.verify

* enable service in service init test

* cancellation cleanup

* adding nil checks to configset juggling

* assume blocks are available by default

As long as we're sure the AvailableBlocker is initialized correctly
during node startup, defaulting to assuming we aren't in a checkpoint
sync simplifies things greatly for tests.

* block saving path refactor and bugfix

* fix fillback test

* fix BackfillStatus init tests

---------

Co-authored-by: Kasey Kirkham <kasey@users.noreply.github.com>
This commit is contained in:
kasey
2024-01-23 01:54:30 -06:00
committed by GitHub
parent 3187a05a76
commit 1df173e701
59 changed files with 2886 additions and 536 deletions

View File

@@ -20,6 +20,14 @@ func (b ROBlock) Root() [32]byte {
return b.root
}
// RootSlice returns a slice of the value returned by Root(). This is convenient because slicing the result of a func
// is not allowed, so only offering a fixed-length array version results in boilerplate code to
func (b ROBlock) RootSlice() []byte {
r := make([]byte, 32)
copy(r, b.root[:])
return r
}
// NewROBlockWithRoot creates an ROBlock embedding the given block with its root. It accepts the root as parameter rather than
// computing it internally, because in some cases a block is retrieved by its root and recomputing it is a waste.
func NewROBlockWithRoot(b interfaces.ReadOnlySignedBeaconBlock, root [32]byte) (ROBlock, error) {
@@ -42,6 +50,20 @@ func NewROBlock(b interfaces.ReadOnlySignedBeaconBlock) (ROBlock, error) {
return ROBlock{ReadOnlySignedBeaconBlock: b, root: root}, nil
}
// NewROBlockSlice is a helper method for converting a slice of the ReadOnlySignedBeaconBlock interface
// to a slice of ROBlock.
func NewROBlockSlice(blks []interfaces.ReadOnlySignedBeaconBlock) ([]ROBlock, error) {
robs := make([]ROBlock, len(blks))
var err error
for i := range blks {
robs[i], err = NewROBlock(blks[i])
if err != nil {
return nil, err
}
}
return robs, nil
}
// ROBlockSlice implements sort.Interface so that slices of ROBlocks can be easily sorted.
// A slice of ROBlock is sorted first by slot, with ties broken by cached block roots.
type ROBlockSlice []ROBlock