-
Notifications
You must be signed in to change notification settings - Fork 1.3k
sync blobs in initial-sync #12522
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
sync blobs in initial-sync #12522
Changes from all commits
bdbf0f9
49287cd
ebce6c7
9e1e675
aa6a0da
2076738
f9216d1
d0b4313
27a7fc7
953bd68
e3d61a7
b814d46
27d2eca
bc45439
3de8fe7
7ee5e7f
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 |
|---|---|---|
|
|
@@ -151,19 +151,14 @@ func getStateVersionAndPayload(st state.BeaconState) (int, interfaces.ExecutionD | |
| return preStateVersion, preStateHeader, nil | ||
| } | ||
|
|
||
| func (s *Service) onBlockBatch(ctx context.Context, blks []interfaces.ReadOnlySignedBeaconBlock, | ||
| blockRoots [][32]byte) error { | ||
| func (s *Service) onBlockBatch(ctx context.Context, blks []consensusblocks.ROBlock) error { | ||
| ctx, span := trace.StartSpan(ctx, "blockChain.onBlockBatch") | ||
| defer span.End() | ||
|
|
||
| if len(blks) == 0 || len(blockRoots) == 0 { | ||
| if len(blks) == 0 { | ||
| return errors.New("no blocks provided") | ||
| } | ||
|
|
||
| if len(blks) != len(blockRoots) { | ||
| return errWrongBlockCount | ||
| } | ||
|
|
||
| if err := consensusblocks.BeaconBlockIsNil(blks[0]); err != nil { | ||
| return invalidBlock{error: err} | ||
| } | ||
|
|
@@ -213,7 +208,7 @@ func (s *Service) onBlockBatch(ctx context.Context, blks []interfaces.ReadOnlySi | |
| } | ||
| // Save potential boundary states. | ||
| if slots.IsEpochStart(preState.Slot()) { | ||
| boundaries[blockRoots[i]] = preState.Copy() | ||
| boundaries[b.Root()] = preState.Copy() | ||
| } | ||
| jCheckpoints[i] = preState.CurrentJustifiedCheckpoint() | ||
| fCheckpoints[i] = preState.FinalizedCheckpoint() | ||
|
|
@@ -246,11 +241,12 @@ func (s *Service) onBlockBatch(ctx context.Context, blks []interfaces.ReadOnlySi | |
| pendingNodes := make([]*forkchoicetypes.BlockAndCheckpoints, len(blks)) | ||
| var isValidPayload bool | ||
| for i, b := range blks { | ||
| root := b.Root() | ||
| isValidPayload, err = s.notifyNewPayload(ctx, | ||
| postVersionAndHeaders[i].version, | ||
| postVersionAndHeaders[i].header, b) | ||
| if err != nil { | ||
| return s.handleInvalidExecutionError(ctx, err, blockRoots[i], b.Block().ParentRoot()) | ||
| return s.handleInvalidExecutionError(ctx, err, root, b.Block().ParentRoot()) | ||
| } | ||
| if isValidPayload { | ||
| if err := s.validateMergeTransitionBlock(ctx, preVersionAndHeaders[i].version, | ||
|
|
@@ -262,13 +258,13 @@ func (s *Service) onBlockBatch(ctx context.Context, blks []interfaces.ReadOnlySi | |
| JustifiedCheckpoint: jCheckpoints[i], | ||
| FinalizedCheckpoint: fCheckpoints[i]} | ||
| pendingNodes[len(blks)-i-1] = args | ||
| if err := s.saveInitSyncBlock(ctx, blockRoots[i], b); err != nil { | ||
| if err := s.saveInitSyncBlock(ctx, root, b); err != nil { | ||
|
Contributor
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. This function can now be modified to not take the root and use b itself.
Contributor
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. +1 , although better to have it as a follow up. Also on another note the ROBlock should go into develop directly and we implement all these changes there
Collaborator
Author
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.
Contributor
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 guess more on changing the block type from |
||
| tracing.AnnotateError(span, err) | ||
| return err | ||
| } | ||
| if err := s.cfg.BeaconDB.SaveStateSummary(ctx, ðpb.StateSummary{ | ||
| Slot: b.Block().Slot(), | ||
| Root: blockRoots[i][:], | ||
| Root: root[:], | ||
| }); err != nil { | ||
| tracing.AnnotateError(span, err) | ||
| return err | ||
|
|
@@ -292,8 +288,9 @@ func (s *Service) onBlockBatch(ctx context.Context, blks []interfaces.ReadOnlySi | |
| return err | ||
| } | ||
| } | ||
| lastB := blks[len(blks)-1] | ||
| lastBR := lastB.Root() | ||
| // Also saves the last post state which to be used as pre state for the next batch. | ||
| lastBR := blockRoots[len(blks)-1] | ||
| if err := s.cfg.StateGen.SaveState(ctx, lastBR, preState); err != nil { | ||
| return err | ||
| } | ||
|
|
@@ -311,7 +308,6 @@ func (s *Service) onBlockBatch(ctx context.Context, blks []interfaces.ReadOnlySi | |
| return errors.Wrap(err, "could not set optimistic block to valid") | ||
| } | ||
| } | ||
| lastB := blks[len(blks)-1] | ||
| arg := ¬ifyForkchoiceUpdateArg{ | ||
| headState: preState, | ||
| headRoot: lastBR, | ||
|
|
||
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 is not related to this PR, but I would prefer the type to signal that the block is signed.
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 this can be another PR against
developif we decide to go with RO block route here