Skip to content

Add Blob Gossip#12413

Merged
terencechain merged 10 commits intodeneb-integrationfrom
gossip-blob
May 18, 2023
Merged

Add Blob Gossip#12413
terencechain merged 10 commits intodeneb-integrationfrom
gossip-blob

Conversation

@terencechain
Copy link
Collaborator

This PR

@terencechain terencechain self-assigned this May 17, 2023
@terencechain terencechain requested a review from a team as a code owner May 17, 2023 02:28
@terencechain terencechain requested review from kasey, potuz and rauljordan and removed request for a team May 17, 2023 02:28

denebForkDigest, err := forks.ForkDigestFromEpoch(params.BeaconConfig().DenebForkEpoch, s.genesisValidatorsRoot)
if err != nil {
log.WithError(err).Error("Could not determine Capella fork digest")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
log.WithError(err).Error("Could not determine Capella fork digest")
log.WithError(err).Error("Could not determine Deneb fork digest")

return []*eth.SignedBlobSidecar{}
}
bs, ok := value.([]*eth.SignedBlobSidecar)
if !ok {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we log something here? Something very strange is happening if we have the wrong object in the cache.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

func (s *Service) addPendingBlobToCache(b *eth.SignedBlobSidecar) error {
blobs := s.pendingBlobsInCache(b.Message.Slot)

blobs = append(blobs, b)
Copy link
Contributor

@rkapka rkapka May 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible that we accidentally append a blob that has been already cached, resulting in having the same blob twice?

Looking at the way we use it, I would say yes, meaning that someone can spam the cache with one blob for an nonexistant block.

if !s.cfg.chain.HasBlock(ctx, parentRoot) {
		if err := s.addPendingBlobToCache(sBlob)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch! dbdf385


const rangeLimit = 1024
const seenBlockSize = 1000
const seenBlobSize = 4000 // Each block can have max 4 blobs. Worst case 164kB for cache.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const seenBlobSize = 4000 // Each block can have max 4 blobs. Worst case 164kB for cache.
`const seenBlobSize = seenBlockSize * 4` // Each block can have max 4 blobs. Worst case 164kB for cache.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s.validateBlob, /* validator */
s.blobSubscriber, /* message handler */
digest,
params.BeaconConfig().MaxBlobsPerBlock,
Copy link
Contributor

@rkapka rkapka May 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should have a BlobsSubnetCount value in the network config for symmetry with AttestationSubnetCount. The two can possibly be different in the future, I guess...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return pubsub.ValidationIgnore, err
}

// [IGNORE] The blob's block's parent (defined by sidecar.block_parent_root) has been seen (via both gossip and non-gossip sources)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// [IGNORE] The blob's block's parent (defined by sidecar.block_parent_root) has been seen (via both gossip and non-gossip sources)
// [IGNORE] The sidecars's block's parent (defined by sidecar.block_parent_root) has been seen (via both gossip and non-gossip sources)

Nitpick :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parentRoot := bytesutil.ToBytes32(blob.BlockParentRoot)
if !s.cfg.chain.HasBlock(ctx, parentRoot) {
if err := s.addPendingBlobToCache(sBlob); err != nil {
log.WithError(err).WithFields(blobFields(blob)).Error("Failed to add blob to queue")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
log.WithError(err).WithFields(blobFields(blob)).Error("Failed to add blob to queue")
log.WithError(err).WithFields(blobFields(blob)).Error("Failed to add blob to cache")

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

// [REJECT] The sidecar's block's parent (defined by sidecar.block_parent_root) passes validation.
blk, err := s.cfg.chain.GetBlock(ctx, parentRoot)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this enough for "passes validation"?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's enough. We only put validated object in the DB or initial sync cache

// is valid with respect to the sidecar.proposer_index pubkey.
parentState, err := s.cfg.stateGen.StateByRoot(ctx, parentRoot)
if err != nil {
return pubsub.ValidationIgnore, err
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we reject here? After all we are unable to verify the signature.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are not able to get the parent state, which does not mean we cannot verify the signature. In this case, we probably shouldn't penalize the peer, but we do drop the object

"github.com/sirupsen/logrus"
)

func (s *Service) validateBlob(ctx context.Context, pid peer.ID, msg *pubsub.Message) (pubsub.ValidationResult, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see a little inconsistency in this function with regards to logging. We usually log before returning on ignore/reject, but not always.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I'm only putting them in the relevant parts. I just fixed it and only use debug

ReceiveBlock(ctx context.Context, block interfaces.ReadOnlySignedBeaconBlock, blockRoot [32]byte) error
ReceiveBlockBatch(ctx context.Context, blocks []interfaces.ReadOnlySignedBeaconBlock, blkRoots [][32]byte) error
HasBlock(ctx context.Context, root [32]byte) bool
GetResentBlockSlot(root [32]byte) (primitives.Slot, error)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the purpose of using the word Resent here? Was it supposed to be Recent?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed it to ResentBlockSlot :)

terencechain and others added 10 commits May 18, 2023 07:52
Co-authored-by: Sammy Rosso <15244892+saolyn@users.noreply.github.com>
Co-authored-by: Sammy Rosso <15244892+saolyn@users.noreply.github.com>
Co-authored-by: Sammy Rosso <15244892+saolyn@users.noreply.github.com>
@terencechain terencechain merged commit 6e9f6fd into deneb-integration May 18, 2023
@terencechain terencechain deleted the gossip-blob branch May 18, 2023 16:13
terencechain added a commit that referenced this pull request May 18, 2023
kasey pushed a commit that referenced this pull request May 19, 2023
kasey pushed a commit that referenced this pull request May 22, 2023
terencechain added a commit that referenced this pull request May 31, 2023
terencechain added a commit that referenced this pull request May 31, 2023
terencechain added a commit that referenced this pull request Jun 7, 2023
terencechain added a commit that referenced this pull request Jun 12, 2023
terencechain added a commit that referenced this pull request Jun 12, 2023
terencechain added a commit that referenced this pull request Jun 16, 2023
terencechain added a commit that referenced this pull request Jun 27, 2023
terencechain added a commit that referenced this pull request Jul 7, 2023
terencechain added a commit that referenced this pull request Jul 9, 2023
terencechain added a commit that referenced this pull request Jul 10, 2023
kasey pushed a commit that referenced this pull request Jul 20, 2023
james-prysm pushed a commit that referenced this pull request Aug 4, 2023
terencechain added a commit that referenced this pull request Aug 16, 2023
kasey pushed a commit that referenced this pull request Aug 21, 2023
kasey pushed a commit that referenced this pull request Aug 22, 2023
kasey pushed a commit that referenced this pull request Aug 22, 2023
kasey pushed a commit that referenced this pull request Aug 22, 2023
kasey pushed a commit that referenced this pull request Aug 23, 2023
kasey pushed a commit that referenced this pull request Aug 23, 2023
kasey pushed a commit that referenced this pull request Aug 23, 2023
kasey pushed a commit that referenced this pull request Aug 24, 2023
kasey pushed a commit that referenced this pull request Aug 24, 2023
prestonvanloon pushed a commit that referenced this pull request Aug 24, 2023
prestonvanloon pushed a commit that referenced this pull request Aug 24, 2023
prestonvanloon pushed a commit that referenced this pull request Aug 24, 2023
prestonvanloon pushed a commit that referenced this pull request Aug 24, 2023
james-prysm pushed a commit that referenced this pull request Aug 25, 2023
prestonvanloon pushed a commit that referenced this pull request Aug 30, 2023
prestonvanloon pushed a commit that referenced this pull request Aug 30, 2023
prestonvanloon pushed a commit that referenced this pull request Aug 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants