Skip to content

Commit

Permalink
Add custom json-rpc method to initialize the trusted block root (#2805)
Browse files Browse the repository at this point in the history
  • Loading branch information
kdeme authored Oct 30, 2024
1 parent 8d8f62b commit bef4c05
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
3 changes: 2 additions & 1 deletion fluffy/fluffy.nim
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import
./rpc/[
rpc_eth_api, rpc_debug_api, rpc_discovery_api, rpc_portal_common_api,
rpc_portal_history_api, rpc_portal_beacon_api, rpc_portal_state_api,
rpc_portal_debug_history_api,
rpc_portal_nimbus_beacon_api, rpc_portal_debug_history_api,
],
./database/content_db,
./portal_node,
Expand Down Expand Up @@ -273,6 +273,7 @@ proc run(
rpcServer.installPortalBeaconApiHandlers(
node.beaconNetwork.value.portalProtocol
)
rpcServer.installPortalNimbusBeaconApiHandlers(node.beaconNetwork.value)
if node.stateNetwork.isSome():
rpcServer.installPortalCommonApiHandlers(
node.stateNetwork.value.portalProtocol, PortalSubnetwork.state
Expand Down
2 changes: 1 addition & 1 deletion fluffy/network/beacon/beacon_network.nim
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ proc validateContent(

debug "Received offered content validated successfully", contentKey
else:
error "Received offered content failed validation",
debug "Received offered content failed validation",
contentKey, error = validation.error
return false

Expand Down
19 changes: 19 additions & 0 deletions fluffy/rpc/rpc_portal_nimbus_beacon_api.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# nimbus
# Copyright (c) 2024 Status Research & Development GmbH
# Licensed and distributed under either of
# * 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).
# at your option. This file may not be copied, modified, or distributed except according to those terms.

{.push raises: [].}

import json_rpc/rpcserver, ../network/beacon/beacon_network

export rpcserver

# Nimbus/fluffy specific RPC methods for the Portal beacon network.
proc installPortalNimbusBeaconApiHandlers*(rpcServer: RpcServer, n: BeaconNetwork) =
rpcServer.rpc("portal_nimbus_beaconSetTrustedBlockRoot") do(blockRoot: string) -> bool:
let root = Digest.fromHex(blockRoot)
n.trustedBlockRoot = Opt.some(root)
true

0 comments on commit bef4c05

Please sign in to comment.