mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-01-27 20:45:48 +00:00
Fluffy State Bridge: Support skipping gossip when content is found in the network (#2867)
This commit is contained in:
parent
e64e5c77b3
commit
78c5770b2f
@ -191,6 +191,13 @@ type
|
|||||||
name: "verify-gossip"
|
name: "verify-gossip"
|
||||||
.}: bool
|
.}: bool
|
||||||
|
|
||||||
|
skipGossipForExisting* {.
|
||||||
|
desc:
|
||||||
|
"Enable skipping gossip of each content value which is successfully fetched from the network",
|
||||||
|
defaultValue: true,
|
||||||
|
name: "skip-gossip-for-existing"
|
||||||
|
.}: bool
|
||||||
|
|
||||||
gossipWorkersCount* {.
|
gossipWorkersCount* {.
|
||||||
desc:
|
desc:
|
||||||
"The number of workers to use for gossiping the state into the portal network",
|
"The number of workers to use for gossiping the state into the portal network",
|
||||||
|
@ -263,6 +263,7 @@ proc runBackfillGossipBlockOffersLoop(
|
|||||||
portalRpcUrl: JsonRpcUrl,
|
portalRpcUrl: JsonRpcUrl,
|
||||||
portalNodeId: NodeId,
|
portalNodeId: NodeId,
|
||||||
verifyGossip: bool,
|
verifyGossip: bool,
|
||||||
|
skipGossipForExisting: bool,
|
||||||
workerId: int,
|
workerId: int,
|
||||||
) {.async: (raises: [CancelledError]).} =
|
) {.async: (raises: [CancelledError]).} =
|
||||||
info "Starting state backfill gossip block offers loop", workerId
|
info "Starting state backfill gossip block offers loop", workerId
|
||||||
@ -304,6 +305,17 @@ proc runBackfillGossipBlockOffersLoop(
|
|||||||
|
|
||||||
var retryGossip = false
|
var retryGossip = false
|
||||||
for k, v in offersMap:
|
for k, v in offersMap:
|
||||||
|
var gossipContent = true
|
||||||
|
if skipGossipForExisting:
|
||||||
|
try:
|
||||||
|
let contentInfo = await portalClient.portal_stateGetContent(k.to0xHex())
|
||||||
|
if contentInfo.content.len() > 0:
|
||||||
|
gossipContent = false
|
||||||
|
except CatchableError as e:
|
||||||
|
warn "Failed to find content with key: ",
|
||||||
|
contentKey = k.to0xHex(), error = e.msg, workerId
|
||||||
|
|
||||||
|
if gossipContent:
|
||||||
try:
|
try:
|
||||||
let numPeers = await portalClient.portal_stateGossip(k.to0xHex(), v.to0xHex())
|
let numPeers = await portalClient.portal_stateGossip(k.to0xHex(), v.to0xHex())
|
||||||
if numPeers > 0:
|
if numPeers > 0:
|
||||||
@ -425,7 +437,8 @@ proc runState*(config: PortalBridgeConf) =
|
|||||||
|
|
||||||
for workerId in 1 .. config.gossipWorkersCount.int:
|
for workerId in 1 .. config.gossipWorkersCount.int:
|
||||||
asyncSpawn runBackfillGossipBlockOffersLoop(
|
asyncSpawn runBackfillGossipBlockOffersLoop(
|
||||||
blockOffersQueue, config.portalRpcUrl, portalNodeId, config.verifyGossip, workerId
|
blockOffersQueue, config.portalRpcUrl, portalNodeId, config.verifyGossip,
|
||||||
|
config.skipGossipForExisting, workerId,
|
||||||
)
|
)
|
||||||
|
|
||||||
asyncSpawn runBackfillMetricsLoop(blockDataQueue, blockOffersQueue)
|
asyncSpawn runBackfillMetricsLoop(blockDataQueue, blockOffersQueue)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user