Skip to content

Portal Client: Improve node status log #3327

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions portal/network/portal_node.nim
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import
./history/[history_network, history_content],
./state/[state_network, state_content]

from eth/p2p/discoveryv5/routing_table import logDistance

export
beacon_light_client, history_network, state_network, portal_protocol_config, forks

Expand Down Expand Up @@ -203,12 +205,18 @@ proc statusLogLoop(n: PortalNode) {.async: (raises: []).} =
# drop a lot when using the logbase2 scale, namely `/ 2` per 1 logaritmic
# radius drop.
# TODO: Get some float precision calculus?
let radiusPercentage = n.contentDB.dataRadius div (UInt256.high() div u256(100))
let
radius = n.contentDB.dataRadius
radiusPercentage = radius div (UInt256.high() div u256(100))
logRadius = logDistance(radius, u256(0))
logRadiusPercentage = (logRadius * 100) div 256

info "Portal node status",
dbSize = $(n.contentDB.size() div 1_000_000) & "MB",
logRadiusPercentage = $logRadiusPercentage & "%",
logRadius,
radiusPercentage = radiusPercentage.toString(10) & "%",
radius = n.contentDB.dataRadius.toHex(),
dbSize = $(n.contentDB.size() div 1000) & "kb"
radius = radius.toHex()

await sleepAsync(60.seconds)
except CancelledError:
Expand Down
Loading