From 4e73d10f8685192eaea2148224a41cc9ee06e3c0 Mon Sep 17 00:00:00 2001 From: Viktor Kirilov Date: Thu, 15 Oct 2020 15:26:59 +0300 Subject: [PATCH] removed 2 buggy RPC API endpoints - there are 2 well functioning ones in validator_api.nim anyway (#1867) --- beacon_chain/beacon_node.nim | 38 ------------------- .../spec/eth2_apis/beacon_callsigs.nim | 5 --- docs/the_nimbus_book/src/api.md | 4 -- 3 files changed, 47 deletions(-) diff --git a/beacon_chain/beacon_node.nim b/beacon_chain/beacon_node.nim index 69107cc6a..bf3059cb8 100644 --- a/beacon_chain/beacon_node.nim +++ b/beacon_chain/beacon_node.nim @@ -719,44 +719,6 @@ proc installBeaconApiHandlers(rpcServer: RpcServer, node: BeaconNode) = raise newException(CatchableError, "Please specify one of " & astToStr(x) & " or " & astToStr(y)) - template jsonResult(x: auto): auto = - StringOfJson(Json.encode(x)) - - rpcServer.rpc("getBeaconBlock") do (slot: Option[Slot], - root: Option[Eth2Digest]) -> StringOfJson: - requireOneOf(slot, root) - var blockHash: Eth2Digest - if root.isSome: - blockHash = root.get - else: - let foundRef = node.chainDag.getBlockByPreciseSlot(slot.get) - if foundRef != nil: - blockHash = foundRef.root - else: - return StringOfJson("null") - - let dbBlock = node.db.getBlock(blockHash) - if dbBlock.isSome: - return jsonResult(dbBlock.get) - else: - return StringOfJson("null") - - rpcServer.rpc("getBeaconState") do (slot: Option[Slot], - root: Option[Eth2Digest]) -> StringOfJson: - requireOneOf(slot, root) - if slot.isSome: - # TODO sanity check slot so that it doesn't cause excessive rewinding - let blk = node.chainDag.head.atSlot(slot.get) - node.chainDag.withState(node.chainDag.tmpState, blk): - return jsonResult(state) - else: - let tmp = BeaconStateRef() # TODO use tmpState - but load the entire StateData! - let state = node.db.getState(root.get, tmp[], noRollback) - if state: - return jsonResult(tmp[]) - else: - return StringOfJson("null") - rpcServer.rpc("getNetworkPeerId") do () -> string: return $publicKey(node.network) diff --git a/beacon_chain/spec/eth2_apis/beacon_callsigs.nim b/beacon_chain/spec/eth2_apis/beacon_callsigs.nim index 45aa86cfb..6d4957e7c 100644 --- a/beacon_chain/spec/eth2_apis/beacon_callsigs.nim +++ b/beacon_chain/spec/eth2_apis/beacon_callsigs.nim @@ -63,13 +63,8 @@ proc get_v1_config_fork_schedule(): seq[tuple[epoch: uint64, version: Version]] proc get_v1_debug_beacon_states_stateId(stateId: string): BeaconState -# TODO: delete old stuff -# https://github.com/ethereum/eth2.0-APIs/blob/master/apis/beacon/basic.md -# proc getBeaconHead(): Slot -proc getBeaconBlock(slot = none(Slot), root = none(Eth2Digest)): BeaconBlock -proc getBeaconState(slot = none(Slot), root = none(Eth2Digest)): BeaconState proc getNetworkPeerId() proc getNetworkPeers() proc getNetworkEnr() diff --git a/docs/the_nimbus_book/src/api.md b/docs/the_nimbus_book/src/api.md index 483148ad5..7684a7374 100644 --- a/docs/the_nimbus_book/src/api.md +++ b/docs/the_nimbus_book/src/api.md @@ -42,10 +42,6 @@ curl -d '{"jsonrpc":"2.0","id":"id","method":"getChainHead","params":[] }' -H 'C ### getSyncing -### getBeaconBlock - -### getBeaconState - ### getNetworkPeerId ### getNetworkPeers