2020-10-27 09:00:57 +00:00
|
|
|
import
|
2020-11-19 17:19:03 +00:00
|
|
|
std/[sequtils, deques],
|
2020-10-27 09:00:57 +00:00
|
|
|
json_rpc/[rpcserver, jsonmarshal],
|
|
|
|
chronicles,
|
2020-11-19 17:19:03 +00:00
|
|
|
../version, ../beacon_node_common, ../eth2_json_rpc_serialization,
|
|
|
|
../eth1_monitor, ../validator_duties, ../eth2_network, ../peer_pool,
|
2020-10-27 09:00:57 +00:00
|
|
|
../spec/[datatypes, digest, presets],
|
|
|
|
./rpc_utils
|
|
|
|
|
|
|
|
logScope: topics = "debugapi"
|
|
|
|
|
|
|
|
type
|
|
|
|
RpcServer = RpcHttpServer
|
2020-11-19 17:19:03 +00:00
|
|
|
Eth1Block = eth1_monitor.Eth1Block
|
2020-10-27 09:00:57 +00:00
|
|
|
|
|
|
|
proc installDebugApiHandlers*(rpcServer: RpcServer, node: BeaconNode) =
|
|
|
|
rpcServer.rpc("get_v1_debug_beacon_states_stateId") do (
|
|
|
|
stateId: string) -> BeaconState:
|
|
|
|
withStateForStateId(stateId):
|
|
|
|
return state
|
|
|
|
|
|
|
|
rpcServer.rpc("get_v1_debug_beacon_heads") do (
|
|
|
|
stateId: string) -> seq[tuple[root: Eth2Digest, slot: Slot]]:
|
|
|
|
return node.chainDag.heads.mapIt((it.root, it.slot))
|
2020-11-19 17:19:03 +00:00
|
|
|
|
|
|
|
rpcServer.rpc("get_v1_debug_eth1_chain") do () -> seq[Eth1Block]:
|
|
|
|
return mapIt(node.eth1Monitor.blocks, it)
|
|
|
|
|
|
|
|
rpcServer.rpc("get_v1_debug_eth1_proposal_data") do () -> BlockProposalEth1Data:
|
|
|
|
let
|
|
|
|
wallSlot = node.beaconClock.now.slotOrZero
|
|
|
|
head = node.doChecksAndGetCurrentHead(wallSlot)
|
|
|
|
|
|
|
|
node.chainDag.withState(node.chainDag.tmpState, head.atSlot(wallSlot)):
|
|
|
|
return node.getBlockProposalEth1Data(state)
|
|
|
|
|