mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-02-28 06:00:39 +00:00
don't consider attempt to route duplicate block an error (#4904)
This commit is contained in:
parent
53436c2b9b
commit
8f9bb391a3
@ -78,7 +78,7 @@ template blockProcessor(router: MessageRouter): ref BlockProcessor =
|
|||||||
template getCurrentBeaconTime(router: MessageRouter): BeaconTime =
|
template getCurrentBeaconTime(router: MessageRouter): BeaconTime =
|
||||||
router.processor[].getCurrentBeaconTime()
|
router.processor[].getCurrentBeaconTime()
|
||||||
|
|
||||||
type RouteBlockResult* = Result[Opt[BlockRef], cstring]
|
type RouteBlockResult = Result[Opt[BlockRef], cstring]
|
||||||
proc routeSignedBeaconBlock*(
|
proc routeSignedBeaconBlock*(
|
||||||
router: ref MessageRouter, blck: ForkySignedBeaconBlock):
|
router: ref MessageRouter, blck: ForkySignedBeaconBlock):
|
||||||
Future[RouteBlockResult] {.async.} =
|
Future[RouteBlockResult] {.async.} =
|
||||||
@ -126,10 +126,21 @@ proc routeSignedBeaconBlock*(
|
|||||||
# The boolean we return tells the caller whether the block was integrated
|
# The boolean we return tells the caller whether the block was integrated
|
||||||
# into the chain
|
# into the chain
|
||||||
if newBlockRef.isErr():
|
if newBlockRef.isErr():
|
||||||
|
return if newBlockRef.error()[0] != VerifierError.Duplicate:
|
||||||
warn "Unable to add routed block to block pool",
|
warn "Unable to add routed block to block pool",
|
||||||
blockRoot = shortLog(blck.root), blck = shortLog(blck.message),
|
blockRoot = shortLog(blck.root), blck = shortLog(blck.message),
|
||||||
signature = shortLog(blck.signature), err = newBlockRef.error()
|
signature = shortLog(blck.signature), err = newBlockRef.error()
|
||||||
return ok(Opt.none(BlockRef))
|
ok(Opt.none(BlockRef))
|
||||||
|
else:
|
||||||
|
# If it's duplicate, there's an existing BlockRef to return. The block
|
||||||
|
# shouldn't be finalized already because that requires a couple epochs
|
||||||
|
# before occurring, so only check non-finalized resolved blockrefs.
|
||||||
|
let blockRef = router[].dag.getBlockRef(blck.root)
|
||||||
|
if blockRef.isErr:
|
||||||
|
warn "Unable to add routed duplicate block to block pool",
|
||||||
|
blockRoot = shortLog(blck.root), blck = shortLog(blck.message),
|
||||||
|
signature = shortLog(blck.signature), err = newBlockRef.error()
|
||||||
|
ok(blockRef)
|
||||||
|
|
||||||
return ok(Opt.some(newBlockRef.get()))
|
return ok(Opt.some(newBlockRef.get()))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user