mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-01-09 22:06:21 +00:00
make message_router.routeSignedBeaconBlock blob-aware (#4537)
* make message_router.outeSignedBeaconBlock blob-aware * Update beacon_chain/spec/forks.nim * Update beacon_chain/spec/forks.nim
This commit is contained in:
parent
a57cec56cb
commit
96dfe18a3d
@ -2653,23 +2653,13 @@ proc broadcastBeaconBlock*(
|
|||||||
let topic = getBeaconBlocksTopic(node.forkDigests.capella)
|
let topic = getBeaconBlocksTopic(node.forkDigests.capella)
|
||||||
node.broadcast(topic, blck)
|
node.broadcast(topic, blck)
|
||||||
|
|
||||||
|
proc broadcastBeaconBlockAndBlobsSidecar*(
|
||||||
|
node: Eth2Node, blck: eip4844.SignedBeaconBlockAndBlobsSidecar): Future[SendResult] =
|
||||||
|
let topic = getBeaconBlockAndBlobsSidecarTopic(node.forkDigests.eip4844)
|
||||||
|
node.broadcast(topic, blck)
|
||||||
|
|
||||||
from ../spec/datatypes/eip4844 import SignedBeaconBlock
|
from ../spec/datatypes/eip4844 import SignedBeaconBlock
|
||||||
|
|
||||||
proc broadcastBeaconBlock*(
|
|
||||||
node: Eth2Node, blck: eip4844.SignedBeaconBlock): Future[SendResult] =
|
|
||||||
debugRaiseAssert $eip4844ImplementationMissing & ": eth2_network.nim:broadcastBeaconBlock EIP4844 uses different approach (1)"
|
|
||||||
|
|
||||||
proc broadcastBeaconBlock*(
|
|
||||||
node: Eth2Node, forked: ForkedSignedBeaconBlock): Future[SendResult] =
|
|
||||||
withBlck(forked):
|
|
||||||
when stateFork == BeaconStateFork.EIP4844:
|
|
||||||
debugRaiseAssert $eip4844ImplementationMissing & ": eth2_network.nim:broadcastBeaconBlock EIP4844 uses different approach (2)"
|
|
||||||
let f = newFuture[SendResult]()
|
|
||||||
f.fail(new CatchableError)
|
|
||||||
f
|
|
||||||
else:
|
|
||||||
node.broadcastBeaconBlock(blck)
|
|
||||||
|
|
||||||
proc broadcastSyncCommitteeMessage*(
|
proc broadcastSyncCommitteeMessage*(
|
||||||
node: Eth2Node, msg: SyncCommitteeMessage,
|
node: Eth2Node, msg: SyncCommitteeMessage,
|
||||||
subcommitteeIdx: SyncSubcommitteeIndex): Future[SendResult] =
|
subcommitteeIdx: SyncSubcommitteeIndex): Future[SendResult] =
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
import
|
import
|
||||||
stew/assign2,
|
stew/assign2,
|
||||||
|
stew/results,
|
||||||
chronicles,
|
chronicles,
|
||||||
../extras,
|
../extras,
|
||||||
"."/[
|
"."/[
|
||||||
@ -272,6 +273,14 @@ template toSignedBeaconBlock*(b: ForkySignedBeaconBlockMaybeBlobs): ForkySignedB
|
|||||||
else:
|
else:
|
||||||
b
|
b
|
||||||
|
|
||||||
|
func optBlobs*(b: ForkySignedBeaconBlockMaybeBlobs):
|
||||||
|
Opt[eip4844.BlobsSidecar] =
|
||||||
|
when b is phase0.SignedBeaconBlock or b is altair.SignedBeaconBlock or
|
||||||
|
b is bellatrix.SignedBeaconBlock or b is capella.SignedBeaconBlock:
|
||||||
|
Opt.none(eip4844.BlobsSidecar)
|
||||||
|
elif b is eip4844.SignedBeaconBlockAndBlobsSidecar:
|
||||||
|
Opt.some(b.blobs_sidecar)
|
||||||
|
|
||||||
template toFork*[T: phase0.BeaconState | phase0.HashedBeaconState](
|
template toFork*[T: phase0.BeaconState | phase0.HashedBeaconState](
|
||||||
t: type T): BeaconStateFork =
|
t: type T): BeaconStateFork =
|
||||||
BeaconStateFork.Phase0
|
BeaconStateFork.Phase0
|
||||||
|
@ -107,7 +107,12 @@ proc routeSignedBeaconBlock*(
|
|||||||
# The block passed basic gossip validation - we can "safely" broadcast it
|
# The block passed basic gossip validation - we can "safely" broadcast it
|
||||||
# now. In fact, per the spec, we should broadcast it even if it later fails
|
# now. In fact, per the spec, we should broadcast it even if it later fails
|
||||||
# to apply to our state.
|
# to apply to our state.
|
||||||
res = await router[].network.broadcastBeaconBlock(blck)
|
|
||||||
|
let res =
|
||||||
|
when blckAndBlobs is eip4844.SignedBeaconBlockAndBlobsSidecar:
|
||||||
|
await router[].network.broadcastBeaconBlockAndBlobsSidecar(blckAndBlobs)
|
||||||
|
else:
|
||||||
|
await router[].network.broadcastBeaconBlock(blck)
|
||||||
|
|
||||||
if res.isOk():
|
if res.isOk():
|
||||||
beacon_blocks_sent.inc()
|
beacon_blocks_sent.inc()
|
||||||
@ -121,9 +126,8 @@ proc routeSignedBeaconBlock*(
|
|||||||
blockRoot = shortLog(blck.root), blck = shortLog(blck.message),
|
blockRoot = shortLog(blck.root), blck = shortLog(blck.message),
|
||||||
signature = shortLog(blck.signature), error = res.error()
|
signature = shortLog(blck.signature), error = res.error()
|
||||||
|
|
||||||
let
|
let newBlockRef = await router[].blockProcessor.storeBlock(
|
||||||
newBlockRef = await router[].blockProcessor.storeBlock(
|
MsgSource.api, sendTime, blck, optBlobs(blckAndBlobs))
|
||||||
MsgSource.api, sendTime, blck, Opt.none(eip4844.BlobsSidecar))
|
|
||||||
|
|
||||||
# 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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user