Further fluffy code clean-up from warnings/hints (#1987)
This commit is contained in:
parent
54644fa3cb
commit
3199857ed5
|
@ -1,5 +1,5 @@
|
||||||
# Fluffy
|
# Fluffy
|
||||||
# Copyright (c) 2021-2023 Status Research & Development GmbH
|
# Copyright (c) 2021-2024 Status Research & Development GmbH
|
||||||
# Licensed and distributed under either of
|
# Licensed and distributed under either of
|
||||||
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
||||||
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
||||||
|
@ -260,9 +260,10 @@ proc run(config: PortalConf) {.raises: [CatchableError].} =
|
||||||
lc.start()
|
lc.start()
|
||||||
|
|
||||||
proc onSecond(time: Moment) =
|
proc onSecond(time: Moment) =
|
||||||
let wallSlot = lc.getBeaconTime().slotOrZero()
|
discard
|
||||||
# TODO:
|
# TODO:
|
||||||
# Figure out what to do with this one.
|
# Figure out what to do with this one.
|
||||||
|
# let wallSlot = lc.getBeaconTime().slotOrZero()
|
||||||
# lc.updateGossipStatus(wallSlot + 1)
|
# lc.updateGossipStatus(wallSlot + 1)
|
||||||
|
|
||||||
proc runOnSecondLoop() {.async.} =
|
proc runOnSecondLoop() {.async.} =
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# Nimbus
|
# fluffy
|
||||||
# Copyright (c) 2022-2023 Status Research & Development GmbH
|
# Copyright (c) 2022-2024 Status Research & Development GmbH
|
||||||
# Licensed and distributed under either of
|
# Licensed and distributed under either of
|
||||||
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
||||||
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
||||||
|
@ -101,7 +101,7 @@ proc initBestUpdatesStore(
|
||||||
delStmt: delStmt
|
delStmt: delStmt
|
||||||
)
|
)
|
||||||
|
|
||||||
func close(store: var BestLightClientUpdateStore) =
|
func close*(store: var BestLightClientUpdateStore) =
|
||||||
store.getStmt.disposeSafe()
|
store.getStmt.disposeSafe()
|
||||||
store.getBulkStmt.disposeSafe()
|
store.getBulkStmt.disposeSafe()
|
||||||
store.putStmt.disposeSafe()
|
store.putStmt.disposeSafe()
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# Nimbus - Portal Network
|
# fluffy
|
||||||
# Copyright (c) 2022-2024 Status Research & Development GmbH
|
# Copyright (c) 2022-2024 Status Research & Development GmbH
|
||||||
# Licensed and distributed under either of
|
# Licensed and distributed under either of
|
||||||
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
||||||
|
@ -18,25 +18,19 @@ import
|
||||||
type
|
type
|
||||||
NetworkInitData* = object
|
NetworkInitData* = object
|
||||||
clock*: BeaconClock
|
clock*: BeaconClock
|
||||||
metaData*: Eth2NetworkMetadata
|
metadata*: Eth2NetworkMetadata
|
||||||
forks*: ForkDigests
|
forks*: ForkDigests
|
||||||
genesis_validators_root*: Eth2Digest
|
genesis_validators_root*: Eth2Digest
|
||||||
|
|
||||||
proc loadNetworkData*(
|
proc loadNetworkData*(networkName: string): NetworkInitData =
|
||||||
networkName: string): NetworkInitData {.raises: [CatchableError].} =
|
|
||||||
let
|
let
|
||||||
metadata =
|
metadata = loadEth2Network(some("mainnet"))
|
||||||
try:
|
|
||||||
loadEth2Network(some("mainnet"))
|
|
||||||
except CatchableError as exc:
|
|
||||||
raiseAssert(exc.msg)
|
|
||||||
|
|
||||||
genesisState =
|
genesisState =
|
||||||
try:
|
try:
|
||||||
template genesisData(): auto = metadata.genesis.bakedBytes
|
template genesisData(): auto = metadata.genesis.bakedBytes
|
||||||
newClone(readSszForkedHashedBeaconState(
|
newClone(readSszForkedHashedBeaconState(
|
||||||
metadata.cfg, genesisData.toOpenArray(genesisData.low, genesisData.high)))
|
metadata.cfg, genesisData.toOpenArray(genesisData.low, genesisData.high)))
|
||||||
except CatchableError as err:
|
except SerializationError as err:
|
||||||
raiseAssert "Invalid baked-in state: " & err.msg
|
raiseAssert "Invalid baked-in state: " & err.msg
|
||||||
|
|
||||||
genesisTime = getStateField(genesisState[], genesis_time)
|
genesisTime = getStateField(genesisState[], genesis_time)
|
||||||
|
@ -51,7 +45,7 @@ proc loadNetworkData*(
|
||||||
|
|
||||||
return NetworkInitData(
|
return NetworkInitData(
|
||||||
clock: beaconClock,
|
clock: beaconClock,
|
||||||
metaData: metaData,
|
metadata: metadata,
|
||||||
forks: forks[],
|
forks: forks[],
|
||||||
genesis_validators_root: genesis_validators_root
|
genesis_validators_root: genesis_validators_root
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# beacon hain light client
|
# fluffy
|
||||||
# Copyright (c) 2022-2023 Status Research & Development GmbH
|
# Copyright (c) 2022-2024 Status Research & Development GmbH
|
||||||
# Licensed and distributed under either of
|
# Licensed and distributed under either of
|
||||||
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
||||||
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
||||||
|
@ -275,41 +275,6 @@ proc query[E](
|
||||||
# requests however, see: https://github.com/status-im/nimbus-eth1/issues/1769
|
# requests however, see: https://github.com/status-im/nimbus-eth1/issues/1769
|
||||||
self.workerTask(e, key)
|
self.workerTask(e, key)
|
||||||
|
|
||||||
template query[E](
|
|
||||||
self: LightClientManager,
|
|
||||||
e: typedesc[E]
|
|
||||||
): Future[bool] =
|
|
||||||
self.query(e, Nothing())
|
|
||||||
|
|
||||||
type SchedulingMode = enum
|
|
||||||
Soon,
|
|
||||||
CurrentPeriod,
|
|
||||||
NextPeriod
|
|
||||||
|
|
||||||
func fetchTime(
|
|
||||||
self: LightClientManager,
|
|
||||||
wallTime: BeaconTime,
|
|
||||||
schedulingMode: SchedulingMode
|
|
||||||
): BeaconTime =
|
|
||||||
let
|
|
||||||
remainingTime =
|
|
||||||
case schedulingMode:
|
|
||||||
of Soon:
|
|
||||||
chronos.seconds(0)
|
|
||||||
of CurrentPeriod:
|
|
||||||
let
|
|
||||||
wallPeriod = wallTime.slotOrZero().sync_committee_period
|
|
||||||
deadlineSlot = (wallPeriod + 1).start_slot - 1
|
|
||||||
deadline = deadlineSlot.start_beacon_time()
|
|
||||||
chronos.nanoseconds((deadline - wallTime).nanoseconds)
|
|
||||||
of NextPeriod:
|
|
||||||
chronos.seconds(
|
|
||||||
(SLOTS_PER_SYNC_COMMITTEE_PERIOD * SECONDS_PER_SLOT).int64)
|
|
||||||
minDelay = max(remainingTime div 8, chronos.seconds(10))
|
|
||||||
jitterSeconds = (minDelay * 2).seconds
|
|
||||||
jitterDelay = chronos.seconds(self.rng[].rand(jitterSeconds).int64)
|
|
||||||
return wallTime + minDelay + jitterDelay
|
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/light-client.md#light-client-sync-process
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/light-client.md#light-client-sync-process
|
||||||
proc loop(self: LightClientManager) {.async.} =
|
proc loop(self: LightClientManager) {.async.} =
|
||||||
var nextSyncTaskTime = self.getBeaconTime()
|
var nextSyncTaskTime = self.getBeaconTime()
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# Fluffy
|
# Fluffy
|
||||||
# Copyright (c) 2021-2023 Status Research & Development GmbH
|
# Copyright (c) 2021-2024 Status Research & Development GmbH
|
||||||
# Licensed and distributed under either of
|
# Licensed and distributed under either of
|
||||||
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
||||||
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
||||||
|
@ -291,7 +291,9 @@ func truncateEnrs(
|
||||||
for n in nodes:
|
for n in nodes:
|
||||||
let enr = ByteList.init(n.record.raw)
|
let enr = ByteList.init(n.record.raw)
|
||||||
if totalSize + enr.len() + enrOverhead <= maxSize:
|
if totalSize + enr.len() + enrOverhead <= maxSize:
|
||||||
let res = enrs.add(enr) # 32 limit will not be reached
|
let res = enrs.add(enr)
|
||||||
|
# With max payload of discv5 and the sizes of ENRs this should not occur.
|
||||||
|
doAssert(res, "32 limit will not be reached")
|
||||||
totalSize = totalSize + enr.len()
|
totalSize = totalSize + enr.len()
|
||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
|
@ -857,6 +859,8 @@ proc offer(p: PortalProtocol, o: OfferRequest):
|
||||||
# No point in trying to continue writing data
|
# No point in trying to continue writing data
|
||||||
socket.close()
|
socket.close()
|
||||||
return err("Error writing requested data")
|
return err("Error writing requested data")
|
||||||
|
|
||||||
|
trace "Offered content item send", dataWritten = dataWritten
|
||||||
of Database:
|
of Database:
|
||||||
for i, b in m.contentKeys:
|
for i, b in m.contentKeys:
|
||||||
if b:
|
if b:
|
||||||
|
@ -884,6 +888,7 @@ proc offer(p: PortalProtocol, o: OfferRequest):
|
||||||
socket.close()
|
socket.close()
|
||||||
return err("Error writing requested data")
|
return err("Error writing requested data")
|
||||||
|
|
||||||
|
trace "Offered content item send", dataWritten = dataWritten
|
||||||
await socket.closeWait()
|
await socket.closeWait()
|
||||||
debug "Content successfully offered"
|
debug "Content successfully offered"
|
||||||
|
|
||||||
|
@ -1231,8 +1236,6 @@ proc traceContentLookup*(p: PortalProtocol, target: ByteList, targetId: UInt256)
|
||||||
|
|
||||||
let distance = p.distance(content.src.id, targetId)
|
let distance = p.distance(content.src.id, targetId)
|
||||||
|
|
||||||
let address = content.src.address.get()
|
|
||||||
|
|
||||||
responses["0x" & $content.src.id] = TraceResponse(
|
responses["0x" & $content.src.id] = TraceResponse(
|
||||||
durationMs: duration,
|
durationMs: duration,
|
||||||
respondedWith: respondedWith,
|
respondedWith: respondedWith,
|
||||||
|
|
|
@ -16,6 +16,5 @@
|
||||||
|
|
||||||
--styleCheck:usages
|
--styleCheck:usages
|
||||||
--styleCheck:hint
|
--styleCheck:hint
|
||||||
--hint[XDeclaredButNotUsed]:off
|
|
||||||
--hint[ConvFromXtoItselfNotNeeded]:off
|
--hint[ConvFromXtoItselfNotNeeded]:off
|
||||||
--hint[Processing]:off
|
--hint[Processing]:off
|
||||||
|
|
|
@ -116,8 +116,7 @@ proc installEthApiHandlers*(
|
||||||
# Currently only HistoryNetwork needed, later we might want a master object
|
# Currently only HistoryNetwork needed, later we might want a master object
|
||||||
# holding all the networks.
|
# holding all the networks.
|
||||||
rpcServerWithProxy: var RpcProxy, historyNetwork: HistoryNetwork,
|
rpcServerWithProxy: var RpcProxy, historyNetwork: HistoryNetwork,
|
||||||
beaconLightClient: Opt[LightClient])
|
beaconLightClient: Opt[LightClient]) =
|
||||||
{.raises: [CatchableError].} =
|
|
||||||
|
|
||||||
# Supported API
|
# Supported API
|
||||||
rpcServerWithProxy.registerProxyMethod("eth_blockNumber")
|
rpcServerWithProxy.registerProxyMethod("eth_blockNumber")
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# Nimbus
|
# fluffy
|
||||||
# Copyright (c) 2021-2024 Status Research & Development GmbH
|
# Copyright (c) 2021-2024 Status Research & Development GmbH
|
||||||
# Licensed and distributed under either of
|
# Licensed and distributed under either of
|
||||||
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
||||||
|
@ -40,8 +40,7 @@ TraceResponse.useDefaultSerializationIn JrpcConv
|
||||||
# as the proc becomes generic, where the rpc macro from router.nim can no longer
|
# as the proc becomes generic, where the rpc macro from router.nim can no longer
|
||||||
# be found, which is why we export rpcserver which should export router.
|
# be found, which is why we export rpcserver which should export router.
|
||||||
proc installPortalApiHandlers*(
|
proc installPortalApiHandlers*(
|
||||||
rpcServer: RpcServer|RpcProxy, p: PortalProtocol, network: static string)
|
rpcServer: RpcServer|RpcProxy, p: PortalProtocol, network: static string) =
|
||||||
{.raises: [CatchableError].} =
|
|
||||||
|
|
||||||
rpcServer.rpc("portal_" & network & "NodeInfo") do() -> NodeInfo:
|
rpcServer.rpc("portal_" & network & "NodeInfo") do() -> NodeInfo:
|
||||||
return p.routingTable.getNodeInfo()
|
return p.routingTable.getNodeInfo()
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# Fluffy
|
# Fluffy
|
||||||
# Copyright (c) 2022-2023 Status Research & Development GmbH
|
# Copyright (c) 2022-2024 Status Research & Development GmbH
|
||||||
# Licensed and distributed under either of
|
# Licensed and distributed under either of
|
||||||
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
||||||
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
||||||
|
@ -18,8 +18,7 @@ export rpcserver
|
||||||
|
|
||||||
# Non-spec-RPCs that are (currently) useful for testing & debugging
|
# Non-spec-RPCs that are (currently) useful for testing & debugging
|
||||||
proc installPortalDebugApiHandlers*(
|
proc installPortalDebugApiHandlers*(
|
||||||
rpcServer: RpcServer|RpcProxy, p: PortalProtocol, network: static string)
|
rpcServer: RpcServer|RpcProxy, p: PortalProtocol, network: static string) =
|
||||||
{.raises: [CatchableError].} =
|
|
||||||
|
|
||||||
rpcServer.rpc("portal_" & network & "_storeContent") do(
|
rpcServer.rpc("portal_" & network & "_storeContent") do(
|
||||||
dataFile: string) -> bool:
|
dataFile: string) -> bool:
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# Nimbus fluffy
|
# fluffy
|
||||||
# Copyright (c) 2023 Status Research & Development GmbH
|
# Copyright (c) 2023-2024 Status Research & Development GmbH
|
||||||
# Licensed and distributed under either of
|
# Licensed and distributed under either of
|
||||||
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
||||||
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
||||||
|
@ -13,8 +13,7 @@ import
|
||||||
|
|
||||||
export rpcserver
|
export rpcserver
|
||||||
|
|
||||||
proc installWeb3ApiHandlers*(rpcServer: RpcServer|RpcProxy)
|
proc installWeb3ApiHandlers*(rpcServer: RpcServer|RpcProxy) =
|
||||||
{.raises: [CatchableError].} =
|
|
||||||
|
|
||||||
rpcServer.rpc("web3_clientVersion") do() -> string:
|
rpcServer.rpc("web3_clientVersion") do() -> string:
|
||||||
return clientVersion
|
return clientVersion
|
||||||
|
|
|
@ -106,23 +106,6 @@ template asEthHash(hash: web3types.BlockHash): Hash256 =
|
||||||
template unsafeQuantityToInt64(q: Quantity): int64 =
|
template unsafeQuantityToInt64(q: Quantity): int64 =
|
||||||
int64 q
|
int64 q
|
||||||
|
|
||||||
# TODO: Cannot use the `hexToInt` from rpc_utils as it importing that causes a
|
|
||||||
# strange "Exception can raise an unlisted exception: Exception` compile error.
|
|
||||||
func hexToInt(
|
|
||||||
s: string, T: typedesc[SomeInteger]): T {.raises: [ValueError].} =
|
|
||||||
var i = 0
|
|
||||||
if s[i] == '0' and (s[i+1] in {'x', 'X'}):
|
|
||||||
inc(i, 2)
|
|
||||||
if s.len - i > sizeof(T) * 2:
|
|
||||||
raise newException(ValueError, "Input hex too big for destination int")
|
|
||||||
|
|
||||||
var res: T = 0
|
|
||||||
while i < s.len:
|
|
||||||
res = res shl 4 or readHexChar(s[i]).T
|
|
||||||
inc(i)
|
|
||||||
|
|
||||||
res
|
|
||||||
|
|
||||||
func asTxType(quantity: Option[Quantity]): Result[TxType, string] =
|
func asTxType(quantity: Option[Quantity]): Result[TxType, string] =
|
||||||
let value = quantity.get(0.Quantity).uint8
|
let value = quantity.get(0.Quantity).uint8
|
||||||
var txType: TxType
|
var txType: TxType
|
||||||
|
@ -553,7 +536,6 @@ proc run(config: BeaconBridgeConf) {.raises: [CatchableError].} =
|
||||||
let
|
let
|
||||||
root = hash_tree_root(forkyObject.header)
|
root = hash_tree_root(forkyObject.header)
|
||||||
contentKey = encode(bootstrapContentKey(root))
|
contentKey = encode(bootstrapContentKey(root))
|
||||||
contentId = beacon_content.toContentId(contentKey)
|
|
||||||
forkDigest = forkDigestAtEpoch(
|
forkDigest = forkDigestAtEpoch(
|
||||||
forkDigests[], epoch(forkyObject.header.beacon.slot), cfg)
|
forkDigests[], epoch(forkyObject.header.beacon.slot), cfg)
|
||||||
content = encodeBootstrapForked(
|
content = encodeBootstrapForked(
|
||||||
|
@ -586,7 +568,6 @@ proc run(config: BeaconBridgeConf) {.raises: [CatchableError].} =
|
||||||
let
|
let
|
||||||
period = forkyObject.attested_header.beacon.slot.sync_committee_period
|
period = forkyObject.attested_header.beacon.slot.sync_committee_period
|
||||||
contentKey = encode(updateContentKey(period.uint64, uint64(1)))
|
contentKey = encode(updateContentKey(period.uint64, uint64(1)))
|
||||||
contentId = beacon_content.toContentId(contentKey)
|
|
||||||
forkDigest = forkDigestAtEpoch(
|
forkDigest = forkDigestAtEpoch(
|
||||||
forkDigests[], epoch(forkyObject.attested_header.beacon.slot), cfg)
|
forkDigests[], epoch(forkyObject.attested_header.beacon.slot), cfg)
|
||||||
content = encodeLightClientUpdatesForked(
|
content = encodeLightClientUpdatesForked(
|
||||||
|
@ -621,7 +602,6 @@ proc run(config: BeaconBridgeConf) {.raises: [CatchableError].} =
|
||||||
let
|
let
|
||||||
slot = forkyObject.signature_slot
|
slot = forkyObject.signature_slot
|
||||||
contentKey = encode(optimisticUpdateContentKey(slot.uint64))
|
contentKey = encode(optimisticUpdateContentKey(slot.uint64))
|
||||||
contentId = beacon_content.toContentId(contentKey)
|
|
||||||
forkDigest = forkDigestAtEpoch(
|
forkDigest = forkDigestAtEpoch(
|
||||||
forkDigests[], epoch(forkyObject.attested_header.beacon.slot), cfg)
|
forkDigests[], epoch(forkyObject.attested_header.beacon.slot), cfg)
|
||||||
content = encodeOptimisticUpdateForked(
|
content = encodeOptimisticUpdateForked(
|
||||||
|
@ -655,7 +635,6 @@ proc run(config: BeaconBridgeConf) {.raises: [CatchableError].} =
|
||||||
let
|
let
|
||||||
finalizedSlot = forkyObject.finalized_header.beacon.slot
|
finalizedSlot = forkyObject.finalized_header.beacon.slot
|
||||||
contentKey = encode(finalityUpdateContentKey(finalizedSlot.uint64))
|
contentKey = encode(finalityUpdateContentKey(finalizedSlot.uint64))
|
||||||
contentId = beacon_content.toContentId(contentKey)
|
|
||||||
forkDigest = forkDigestAtEpoch(
|
forkDigest = forkDigestAtEpoch(
|
||||||
forkDigests[], epoch(forkyObject.attested_header.beacon.slot), cfg)
|
forkDigests[], epoch(forkyObject.attested_header.beacon.slot), cfg)
|
||||||
content = encodeFinalityUpdateForked(
|
content = encodeFinalityUpdateForked(
|
||||||
|
|
|
@ -23,7 +23,7 @@ const
|
||||||
restRequestsTimeout = 30.seconds
|
restRequestsTimeout = 30.seconds
|
||||||
|
|
||||||
proc getBeaconData*(): (
|
proc getBeaconData*(): (
|
||||||
RuntimeConfig, ref ForkDigests, BeaconClock) {.raises: [IOError].} =
|
RuntimeConfig, ref ForkDigests, BeaconClock) =
|
||||||
let
|
let
|
||||||
metadata = getMetadataForNetwork("mainnet")
|
metadata = getMetadataForNetwork("mainnet")
|
||||||
genesisState =
|
genesisState =
|
||||||
|
@ -32,7 +32,7 @@ proc getBeaconData*(): (
|
||||||
newClone(readSszForkedHashedBeaconState(
|
newClone(readSszForkedHashedBeaconState(
|
||||||
metadata.cfg,
|
metadata.cfg,
|
||||||
genesisData.toOpenArray(genesisData.low, genesisData.high)))
|
genesisData.toOpenArray(genesisData.low, genesisData.high)))
|
||||||
except CatchableError as err:
|
except SerializationError as err:
|
||||||
raiseAssert "Invalid baked-in state: " & err.msg
|
raiseAssert "Invalid baked-in state: " & err.msg
|
||||||
genesis_validators_root =
|
genesis_validators_root =
|
||||||
getStateField(genesisState[], genesis_validators_root)
|
getStateField(genesisState[], genesis_validators_root)
|
||||||
|
@ -60,14 +60,12 @@ proc exportLCBootstrapUpdate*(
|
||||||
fatal "Error occured while closing file", error = e.msg
|
fatal "Error occured while closing file", error = e.msg
|
||||||
quit 1
|
quit 1
|
||||||
|
|
||||||
var
|
let
|
||||||
client = RestClientRef.new(restUrl).valueOr:
|
client = RestClientRef.new(restUrl).valueOr:
|
||||||
error "Cannot connect to server", error = error
|
error "Cannot connect to server", error = error
|
||||||
quit 1
|
quit 1
|
||||||
|
|
||||||
var contentTable: JsonPortalContentTable
|
let update =
|
||||||
|
|
||||||
var update =
|
|
||||||
try:
|
try:
|
||||||
notice "Downloading LC bootstrap"
|
notice "Downloading LC bootstrap"
|
||||||
awaitWithTimeout(
|
awaitWithTimeout(
|
||||||
|
@ -118,14 +116,12 @@ proc exportLCUpdates*(
|
||||||
fatal "Error occured while closing file", error = e.msg
|
fatal "Error occured while closing file", error = e.msg
|
||||||
quit 1
|
quit 1
|
||||||
|
|
||||||
var
|
let
|
||||||
client = RestClientRef.new(restUrl).valueOr:
|
client = RestClientRef.new(restUrl).valueOr:
|
||||||
error "Cannot connect to server", error = error
|
error "Cannot connect to server", error = error
|
||||||
quit 1
|
quit 1
|
||||||
|
|
||||||
var contentTable: JsonPortalContentTable
|
let updates =
|
||||||
|
|
||||||
var updates =
|
|
||||||
try:
|
try:
|
||||||
notice "Downloading LC updates"
|
notice "Downloading LC updates"
|
||||||
awaitWithTimeout(
|
awaitWithTimeout(
|
||||||
|
@ -181,14 +177,12 @@ proc exportLCFinalityUpdate*(
|
||||||
fatal "Error occured while closing file", error = e.msg
|
fatal "Error occured while closing file", error = e.msg
|
||||||
quit 1
|
quit 1
|
||||||
|
|
||||||
var
|
let
|
||||||
client = RestClientRef.new(restUrl).valueOr:
|
client = RestClientRef.new(restUrl).valueOr:
|
||||||
error "Cannot connect to server", error = error
|
error "Cannot connect to server", error = error
|
||||||
quit 1
|
quit 1
|
||||||
|
|
||||||
var contentTable: JsonPortalContentTable
|
let update =
|
||||||
|
|
||||||
var update =
|
|
||||||
try:
|
try:
|
||||||
notice "Downloading LC finality update"
|
notice "Downloading LC finality update"
|
||||||
awaitWithTimeout(
|
awaitWithTimeout(
|
||||||
|
@ -207,7 +201,6 @@ proc exportLCFinalityUpdate*(
|
||||||
let
|
let
|
||||||
finalizedSlot = forkyObject.finalized_header.beacon.slot
|
finalizedSlot = forkyObject.finalized_header.beacon.slot
|
||||||
contentKey = encode(finalityUpdateContentKey(finalizedSlot.uint64))
|
contentKey = encode(finalityUpdateContentKey(finalizedSlot.uint64))
|
||||||
contentId = beacon_content.toContentId(contentKey)
|
|
||||||
forkDigest = forkDigestAtEpoch(
|
forkDigest = forkDigestAtEpoch(
|
||||||
forkDigests[], epoch(forkyObject.attested_header.beacon.slot), cfg)
|
forkDigests[], epoch(forkyObject.attested_header.beacon.slot), cfg)
|
||||||
content = encodeFinalityUpdateForked(
|
content = encodeFinalityUpdateForked(
|
||||||
|
@ -238,14 +231,12 @@ proc exportLCOptimisticUpdate*(
|
||||||
fatal "Error occured while closing file", error = e.msg
|
fatal "Error occured while closing file", error = e.msg
|
||||||
quit 1
|
quit 1
|
||||||
|
|
||||||
var
|
let
|
||||||
client = RestClientRef.new(restUrl).valueOr:
|
client = RestClientRef.new(restUrl).valueOr:
|
||||||
error "Cannot connect to server", error = error
|
error "Cannot connect to server", error = error
|
||||||
quit 1
|
quit 1
|
||||||
|
|
||||||
var contentTable: JsonPortalContentTable
|
let update =
|
||||||
|
|
||||||
var update =
|
|
||||||
try:
|
try:
|
||||||
notice "Downloading LC optimistic update"
|
notice "Downloading LC optimistic update"
|
||||||
awaitWithTimeout(
|
awaitWithTimeout(
|
||||||
|
@ -264,7 +255,6 @@ proc exportLCOptimisticUpdate*(
|
||||||
let
|
let
|
||||||
slot = forkyObject.signature_slot
|
slot = forkyObject.signature_slot
|
||||||
contentKey = encode(optimisticUpdateContentKey(slot.uint64))
|
contentKey = encode(optimisticUpdateContentKey(slot.uint64))
|
||||||
contentId = beacon_content.toContentId(contentKey)
|
|
||||||
forkDigest = forkDigestAtEpoch(
|
forkDigest = forkDigestAtEpoch(
|
||||||
forkDigests[], epoch(forkyObject.attested_header.beacon.slot), cfg)
|
forkDigests[], epoch(forkyObject.attested_header.beacon.slot), cfg)
|
||||||
content = encodeOptimisticUpdateForked(
|
content = encodeOptimisticUpdateForked(
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# Fluffy
|
# Fluffy
|
||||||
# Copyright (c) 2023 Status Research & Development GmbH
|
# Copyright (c) 2023-2024 Status Research & Development GmbH
|
||||||
# Licensed and distributed under either of
|
# Licensed and distributed under either of
|
||||||
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
||||||
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
||||||
|
@ -108,7 +108,7 @@ proc cmdBench(conf: DbConf) =
|
||||||
|
|
||||||
for key in keys:
|
for key in keys:
|
||||||
withTimer(timers[tDbGet]):
|
withTimer(timers[tDbGet]):
|
||||||
let val = db.get(key)
|
let _ = db.get(key)
|
||||||
|
|
||||||
for key in keys:
|
for key in keys:
|
||||||
withTimer(timers[tDbContains]):
|
withTimer(timers[tDbContains]):
|
||||||
|
@ -120,17 +120,17 @@ proc cmdBench(conf: DbConf) =
|
||||||
|
|
||||||
for i in 0..<conf.samples:
|
for i in 0..<conf.samples:
|
||||||
withTimer(timers[tDbSize]):
|
withTimer(timers[tDbSize]):
|
||||||
let size = db.size()
|
let _ = db.size()
|
||||||
withTimer(timers[tDbUsedSize]):
|
withTimer(timers[tDbUsedSize]):
|
||||||
let size = db.usedSize()
|
let _ = db.usedSize()
|
||||||
withTimer(timers[tDbContentSize]):
|
withTimer(timers[tDbContentSize]):
|
||||||
let size = db.contentSize()
|
let _ = db.contentSize()
|
||||||
withTimer(timers[tDbContentCount]):
|
withTimer(timers[tDbContentCount]):
|
||||||
let count = db.contentCount()
|
let _ = db.contentCount()
|
||||||
withTimer(timers[tDbLargestDistance]):
|
withTimer(timers[tDbLargestDistance]):
|
||||||
# The selected local ID doesn't matter here as it currently needs to
|
# The selected local ID doesn't matter here as it currently needs to
|
||||||
# iterate over all content for this call.
|
# iterate over all content for this call.
|
||||||
let distance = db.getLargestDistance(u256(0))
|
let _ = db.getLargestDistance(u256(0))
|
||||||
|
|
||||||
printTimers(timers)
|
printTimers(timers)
|
||||||
|
|
||||||
|
|
|
@ -95,7 +95,7 @@ proc runBeacon(config: PortalBridgeConf) {.raises: [CatchableError].} =
|
||||||
currentPeriod =
|
currentPeriod =
|
||||||
wallSlot div (SLOTS_PER_EPOCH * EPOCHS_PER_SYNC_COMMITTEE_PERIOD)
|
wallSlot div (SLOTS_PER_EPOCH * EPOCHS_PER_SYNC_COMMITTEE_PERIOD)
|
||||||
requestAmount = backfillAmount div updatesPerRequest
|
requestAmount = backfillAmount div updatesPerRequest
|
||||||
leftOver = backFillAmount mod updatesPerRequest
|
leftOver = backfillAmount mod updatesPerRequest
|
||||||
|
|
||||||
for i in 0..<requestAmount:
|
for i in 0..<requestAmount:
|
||||||
await portalRpcClient.connect(rpcAddress, rpcPort, false)
|
await portalRpcClient.connect(rpcAddress, rpcPort, false)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# Fluffy
|
# Fluffy
|
||||||
# Copyright (c) 2023 Status Research & Development GmbH
|
# Copyright (c) 2023-2024 Status Research & Development GmbH
|
||||||
# Licensed and distributed under either of
|
# Licensed and distributed under either of
|
||||||
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
||||||
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
||||||
|
@ -100,10 +100,9 @@ proc gossipLCUpdates*(
|
||||||
when lcDataFork > LightClientDataFork.None:
|
when lcDataFork > LightClientDataFork.None:
|
||||||
let
|
let
|
||||||
slot = forkyObject.attested_header.beacon.slot
|
slot = forkyObject.attested_header.beacon.slot
|
||||||
period = forkyObject.attested_header.beacon.slot.sync_committee_period
|
period = slot.sync_committee_period
|
||||||
contentKey = encode(updateContentKey(period.uint64, count))
|
contentKey = encode(updateContentKey(period.uint64, count))
|
||||||
forkDigest = forkDigestAtEpoch(
|
forkDigest = forkDigestAtEpoch(forkDigests[], epoch(slot), cfg)
|
||||||
forkDigests[], epoch(forkyObject.attested_header.beacon.slot), cfg)
|
|
||||||
|
|
||||||
content = encodeLightClientUpdatesForked(
|
content = encodeLightClientUpdatesForked(
|
||||||
forkDigest,
|
forkDigest,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# Fluffy
|
# Fluffy
|
||||||
# Copyright (c) 2023 Status Research & Development GmbH
|
# Copyright (c) 2023-2024 Status Research & Development GmbH
|
||||||
# Licensed and distributed under either of
|
# Licensed and distributed under either of
|
||||||
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
||||||
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
||||||
|
@ -60,7 +60,7 @@ type
|
||||||
name: "rest-url" .}: string
|
name: "rest-url" .}: string
|
||||||
|
|
||||||
# Backfill options
|
# Backfill options
|
||||||
backFillAmount* {.
|
backfillAmount* {.
|
||||||
desc: "Amount of beacon LC updates to backfill gossip into the network"
|
desc: "Amount of beacon LC updates to backfill gossip into the network"
|
||||||
defaultValue: 64
|
defaultValue: 64
|
||||||
name: "backfill-amount" .}: uint64
|
name: "backfill-amount" .}: uint64
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# Fluffy
|
# Fluffy
|
||||||
# Copyright (c) 2021-2023 Status Research & Development GmbH
|
# Copyright (c) 2021-2024 Status Research & Development GmbH
|
||||||
# Licensed and distributed under either of
|
# Licensed and distributed under either of
|
||||||
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
||||||
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
||||||
|
@ -261,10 +261,7 @@ proc run(config: PortalCliConf) =
|
||||||
else:
|
else:
|
||||||
echo nodes.error
|
echo nodes.error
|
||||||
of findContent:
|
of findContent:
|
||||||
proc random(T: type UInt256, rng: var HmacDrbgContext): T =
|
# For now just some bogus bytes
|
||||||
rng.generate(T)
|
|
||||||
|
|
||||||
# For now just some random bytes
|
|
||||||
let contentKey = ByteList.init(@[1'u8])
|
let contentKey = ByteList.init(@[1'u8])
|
||||||
|
|
||||||
let foundContent = waitFor portal.findContent(config.findContentTarget,
|
let foundContent = waitFor portal.findContent(config.findContentTarget,
|
||||||
|
|
|
@ -19,6 +19,5 @@
|
||||||
|
|
||||||
--styleCheck:usages
|
--styleCheck:usages
|
||||||
--styleCheck:hint
|
--styleCheck:hint
|
||||||
--hint[XDeclaredButNotUsed]:off
|
|
||||||
--hint[ConvFromXtoItselfNotNeeded]:off
|
--hint[ConvFromXtoItselfNotNeeded]:off
|
||||||
--hint[Processing]:off
|
--hint[Processing]:off
|
||||||
|
|
|
@ -66,7 +66,7 @@ proc run(config: VerifiedProxyConf) {.raises: [CatchableError].} =
|
||||||
except CatchableError as err:
|
except CatchableError as err:
|
||||||
raiseAssert "Invalid baked-in state: " & err.msg
|
raiseAssert "Invalid baked-in state: " & err.msg
|
||||||
|
|
||||||
genesistime = getStateField(genesisState[], genesis_time)
|
genesisTime = getStateField(genesisState[], genesis_time)
|
||||||
beaconClock = BeaconClock.init(genesisTime).valueOr:
|
beaconClock = BeaconClock.init(genesisTime).valueOr:
|
||||||
error "Invalid genesis time in state", genesisTime
|
error "Invalid genesis time in state", genesisTime
|
||||||
quit QuitFailure
|
quit QuitFailure
|
||||||
|
|
Loading…
Reference in New Issue