Eip4844 sync fixes (#4577)

* fixes

* Make some log messages blob-aware

* remove redundant optBlobs()
This commit is contained in:
henridf 2023-02-01 15:14:50 +01:00 committed by GitHub
parent d7316ac863
commit 94837caa2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 12 deletions

View File

@ -196,11 +196,13 @@ proc processSignedBeaconBlock*(
wallTime = self.getCurrentBeaconTime() wallTime = self.getCurrentBeaconTime()
(afterGenesis, wallSlot) = wallTime.toSlot() (afterGenesis, wallSlot) = wallTime.toSlot()
signedBlock = toSignedBeaconBlock(signedBlockAndBlobs) signedBlock = toSignedBeaconBlock(signedBlockAndBlobs)
blobs = optBlobs(signedBlockAndBlobs)
logScope: logScope:
blockRoot = shortLog(signedBlock.root) blockRoot = shortLog(signedBlock.root)
blck = shortLog(signedBlock.message) blck = shortLog(signedBlock.message)
signature = shortLog(signedBlock.signature) signature = shortLog(signedBlock.signature)
hasBlobs = blobs.isSome
wallSlot wallSlot
if not afterGenesis: if not afterGenesis:
@ -227,7 +229,7 @@ proc processSignedBeaconBlock*(
self.blockProcessor[].addBlock( self.blockProcessor[].addBlock(
src, ForkedSignedBeaconBlock.init(signedBlock), src, ForkedSignedBeaconBlock.init(signedBlock),
Opt.none(eip4844.BlobsSidecar), blobs,
validationDur = nanoseconds( validationDur = nanoseconds(
(self.getCurrentBeaconTime() - wallTime).nanoseconds)) (self.getCurrentBeaconTime() - wallTime).nanoseconds))

View File

@ -374,11 +374,8 @@ proc validateBeaconBlock*(
# validation. # validation.
return errReject("BeaconBlock: rejected, parent from unviable fork") return errReject("BeaconBlock: rejected, parent from unviable fork")
let blobs = let blobs = optBlobs(signed_beacon_block_and_blobs)
when signed_beacon_block is eip4844.SignedBeaconBlockAndBlobsSidecar:
Opt.some(signed_beacon_block.blobs_sidecar)
else:
Opt.none(eip4844.BlobsSidecar)
# When the parent is missing, we can't validate the block - we'll queue it # When the parent is missing, we can't validate the block - we'll queue it
# in the quarantine for later processing # in the quarantine for later processing
if not quarantine[].addOrphan( if not quarantine[].addOrphan(

View File

@ -170,8 +170,8 @@ proc fetchAncestorBlocksAndBlobsFromNetwork(rman: RequestManager,
var peer: Peer var peer: Peer
try: try:
peer = await rman.network.peerPool.acquire() peer = await rman.network.peerPool.acquire()
debug "Requesting blocks by root", peer = peer, blocks = shortLog(items), debug "Requesting blocks and sidecars by root",
peer_score = peer.getScore() peer = peer, blocks = shortLog(items), peer_score = peer.getScore()
let blocks = (await beaconBlockAndBlobsSidecarByRoot_v1(peer, BlockRootsList items)) let blocks = (await beaconBlockAndBlobsSidecarByRoot_v1(peer, BlockRootsList items))
@ -203,7 +203,7 @@ proc fetchAncestorBlocksAndBlobsFromNetwork(rman: RequestManager,
of VerifierError.Invalid: of VerifierError.Invalid:
# We stop processing blocks because peer is either sending us # We stop processing blocks because peer is either sending us
# junk or working a different fork # junk or working a different fork
notice "Received invalid block", notice "Received invalid block and blobs",
peer = peer, blocks = shortLog(items), peer = peer, blocks = shortLog(items),
peer_score = peer.getScore() peer_score = peer.getScore()
peer.updateScore(PeerScoreBadValues) peer.updateScore(PeerScoreBadValues)
@ -213,7 +213,7 @@ proc fetchAncestorBlocksAndBlobsFromNetwork(rman: RequestManager,
gotGoodBlock = true gotGoodBlock = true
if gotUnviableBlock: if gotUnviableBlock:
notice "Received blocks from an unviable fork", notice "Received blocks and blobs from an unviable fork",
peer = peer, blocks = shortLog(items), peer = peer, blocks = shortLog(items),
peer_score = peer.getScore() peer_score = peer.getScore()
peer.updateScore(PeerScoreUnviableFork) peer.updateScore(PeerScoreUnviableFork)
@ -240,7 +240,7 @@ proc fetchAncestorBlocksAndBlobsFromNetwork(rman: RequestManager,
raise exc raise exc
except CatchableError as exc: except CatchableError as exc:
peer.updateScore(PeerScoreNoValues) peer.updateScore(PeerScoreNoValues)
debug "Error while fetching ancestor blocks", exc = exc.msg, debug "Error while fetching ancestor blocks and blobs", exc = exc.msg,
items = shortLog(items), peer = peer, peer_score = peer.getScore() items = shortLog(items), peer = peer, peer_score = peer.getScore()
raise exc raise exc
finally: finally:

View File

@ -877,7 +877,6 @@ proc proposeBlock(node: BeaconNode,
withBlck(forkedBlck): withBlck(forkedBlck):
var blobs_sidecar = eip4844.BlobsSidecar( var blobs_sidecar = eip4844.BlobsSidecar(
beacon_block_root: hash_tree_root(blck),
beacon_block_slot: slot, beacon_block_slot: slot,
) )
when blck is eip4844.BeaconBlock and const_preset != "minimal": when blck is eip4844.BeaconBlock and const_preset != "minimal":
@ -912,6 +911,7 @@ proc proposeBlock(node: BeaconNode,
.slashingProtection .slashingProtection
.registerBlock(validator_index, validator.pubkey, slot, signingRoot) .registerBlock(validator_index, validator.pubkey, slot, signingRoot)
blobs_sidecar.beacon_block_root = blockRoot
if notSlashable.isErr: if notSlashable.isErr:
warn "Slashing protection activated for block proposal", warn "Slashing protection activated for block proposal",
blockRoot = shortLog(blockRoot), blck = shortLog(blck), blockRoot = shortLog(blockRoot), blck = shortLog(blck),