Skip to content

cuprated: CupratedRpcHandler, enable certain endpoints#450

Merged
Boog900 merged 57 commits intoCuprate:mainfrom
hinto-janai:rpc-1
Jun 4, 2025
Merged

cuprated: CupratedRpcHandler, enable certain endpoints#450
Boog900 merged 57 commits intoCuprate:mainfrom
hinto-janai:rpc-1

Conversation

@hinto-janai
Copy link
Member

@hinto-janai hinto-janai commented May 1, 2025

What

  • Makes necessary changes to CupratedRpcHandler and replaces the dummy handler with it
  • Adds an RPC section in the user book
  • Enables the following methods/endpoints: get_block, get_block_count, get_last_block_header, get_block_header_by_hash, get_block_header_by_height, get_block_headers_range, on_get_block_hash, /get_height
  • Implements internal code called by the methods/endpoints above

JSON formatting

Currently it is compact. This can be changed in a different PR.

JSON output examples

These are real responses from cuprated (piped to jq).

They seem to be identical in type/value compared to monerod's output, although there are a few unintended(?) differences e.g. block_headers appearing in get_block_header_by_hash. I will set all methods/endpoints to 🟠 in the user book until they are more thoroughly tested with #422.

The coloring below seems off although all output is guaranteed to be valid JSON since we use serde_json to serialize things + it is piped through jq which rejects invalid JSON.

get_block

curl http://127.0.0.1:28081/json_rpc -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":"0","method":"get_block","params":{"height":0,"hash":"fd4638f60cada2adfd53aa119a1479ea6e48301f2f3f422bdc3abd71c117f927","fill_pow_hash":false}}' | jq
{
  "jsonrpc": "2.0",
  "id": "0",
  "result": {
    "status": "OK",
    "untrusted": false,
    "credits": 0,
    "top_hash": "",
    "blob": "1010c5c4e8c1065c133b6727015a133575330f60452e583f50c19fe72f61401554b4df2e16dc7d3e951d1802d4f8d00101ff98f8d0012ed29afafd04038a3837e0b12b6b5a0cab63b89cc0d3887b179e9ef1bf82d30c69ac6dd3cc859c1afea5dbbb3f033ab445e5c71f0c7d92e21dca97bc80238f1d001804098e591aa4a8bcf18ca1cf08f4c5b6fb030308b42a997d78a91c1769dc2dec27c42db16f82e537611c0e25453b7c32eb2d10a2b0ba8ef80403112187410eb1c9ac8795b3a7b8573295d58d89ea42fd7c87bd35804cd777fc7833fdd9af82050351ff5ea5269abccb66526764079af02a8e1fa56f48c8b76fc13f11c9dbf131ebf590b0cff9e5060369eecc28c127071d2d015e407933837ec7ef37a65e257b7d0072a80edb681ad3a6e2f6ecf309033f2b20336373624bd2f5972bba03859e5e37fd6b19d6919e3a0ca77f13a1626f2aa090bffd04033feae6534ff62b6b53a00e28731799728f0461f3b207d1e426a0e2dab3e8056170c5ecf9c8830203bc1c741724bfd39da714229d76486e60b406bbe02c939aaff4be4f5939211110ebf091cbe917030c0e73acc3e10de3e7bba51fb35d3ab43315fb341d51f3fcb85dbb65d9caf7111dc9ddc9bf3b03afaac7a27145279a3f5d719f00bcb60e10d72c389099fc6c7e42db1471483568afc8aaa4f40403a0383528c75d1a48022fdbbeea25c5034538a283fcf9b8f46d277ee85e89cf9e04ff83d7e31e0353201a17498449aad7ed17c5c040c2746291fa8681f42ef582750e4ec316a07c20bab9ccfb0403fc57096aa49bda14d3d35021b050b8c98443d2fd2c16d80516f62811902ec5519c86e08aec0c033f82c562e95f9b397ced26c7c07abaf8e8f0071de378448c5ff3677dbf8c460852eeddcdfb0403ef5fb712f92bcf6eda7c59295aeb2a5a14d4eefc4c10386f79f9f208b7b8b229dffadecbf609036cc9425ea9009c7909014c399d0841868ecc194956f92fff35a77cb4c0c11203f8c9dda7ef09035e7981483e84dddad849539f1f1195b9d1d9a06ab7361453d1af190f0119b0f5e5bcb5e1fb0403ed96b36a9405d360938972ecbabeeee3fa5ac6f9f4b9d4707c65245862a64a77d8cdbae1fb0403d3b35dc8ecc9054e1bf75b197b518e0a6cd7a09bcbadf100caf2d040887aa42bbce98febf4090313b14493284a76a7bb2b1de95dbfbbb641b5ccde44606ca93e2d5c678c11f2ec1eb2bca9f904039199e24b119d326230832080149c2a4af72567be9d7c741d4ae1488649c987d180ded5e1e30e03f9c1ab4dc7909bf20fe325e133441d6cb7b76e88205ba8572f6f0276e2201ee568c4d5e1f60903bdb449822de9a15add0437583c673551c25a75ce630a626af52140fdcb69d727b9ff93bfe61703963eabaf85647ef9124b5376a13db6b2db3087cbd92eed8eb5fe129912c19b6669aa9fcffd04038008571ca1594da968983020f89d1115f7a1b15d38690adf06368b9ed101b9f000d5de83da1d035abf77d761dab95fc6116e9fc42c79027657d0ddf3992621b99f5a8df42ff52ef09baeabf209034a42a7d187599f89ee868f35b84f5c6db4fa394164a4486e893152c86f9c296583b9f4fffa0403ed49ed0235e362a1bdd49a6302382e5f91d515b0d7c439504aa8a75ae22f5752678ae593f57b036bf845702e23d351f75c30f8288c234cd655035b045f688831c7642ca26d2634838b9fe9f504031919a5fd2087f25c802842807d6a429e5b89d395cb14afeb58587e2b720ac01615c9b7b1f60403b086eee2536cc838ec9ac4e868c2b4ec5c5b0feb56233fb1d5cc38f4f1876669d0d3ba94cff5010339a846cc97d717c106c7f2083b6bab0b024b0d21f02b4b5542d30d1e4b3f95548989c0c2fb040351fa1b23c587d587b07d5bfce7c726ef85b15dc0beeeaa9dc5917c07193e9b1a42e58cd3fc09032d95ff536ef2c9771e97ee6a501ea227bf8e3e6b97104e34ac56435f1f2aefb9d5b79bf8f00903194ef633897f0b4cab8a2a9d4e13731736a1e2d4a86bc049bca4baa947a02b60f386bdfefb0403c90f51e9e5a46d47c67e741f8fa30df1bcc4c6b50532dfc693050fd6920d7cba878b9db4f60403227b56d5b83dc27a21fb8998eec69484563e16abdfe87d18bc9fa97e754d58f3a6a1bee6f7040331a2c45b9d439e3092f9044a71c2c5ff1cbec98c8cc89905629e909018458074b4b3c8e9acdc0103dee98a546ff9343af6a6d4fcdf5849b4f30d9605da6367cddcb51ecdda65d14565b5acaef604034abb5b8a31fe91defe168ca4e44604c60a16010a3a1ec6bbf3183b9cc1d1d952cdbbb9c3810503a17eec52d94a5f38f87d2ce55b66cf1708e14efae8a8486f32a17e0d75efa4936ca5adf1ed09033874ec1ae8b0e22f928a8dc65ed6f1efe34c03c62379566cc323be5456cacb72ed93c8baf704036a998678b0fd069a14237ae771347b5719b2686abca601e35f68fc5b017af80ea49cff91ae4e03e8cd326d41cb91780f681340290e4b0f1bafce6f1bf5ce2add92862b68b33e1077f0f6daf50e03629524884c776f43fb821c897dd0f424750ef3efa4b4facff319ec8ad76a657e524a01e0bc9814175d5a7f8eaba650da2bb27440ab9a6d382999eb807205f577a98cc10204e81893f703210854096256d23debb370e720efb7ba2b035298f17b3abaa81f9994f0ffbe4adeb40003391cf0dabe33bcf054487eb36095efcd021f2edf1321cfc3750bc6c2c7110ae825e76fd95c0995d9bbd7b215a34fab0848830d92d71f556df47a03953eeda3f73bf0153b7b9955d714beb562ed141479e45cecaf96585b0cc6c5fd6ed67058f4",
    "block_header": {
      "block_size": 7183,
      "block_weight": 7183,
      "cumulative_difficulty_top64": 463404268542897540,
      "cumulative_difficulty": 0,
      "depth": 17,
      "difficulty_top64": 597518381009,
      "difficulty": 0,
      "hash": "fd4638f60cada2adfd53aa119a1479ea6e48301f2f3f422bdc3abd71c117f927",
      "height": 3423256,
      "long_term_weight": 176470,
      "major_version": 16,
      "miner_tx_hash": "34805ad36817c822d25e9ce5a3d943557fda17d870132090770c215c6869ecc7",
      "minor_version": 16,
      "nonce": 404591934,
      "num_txes": 3,
      "orphan_status": false,
      "pow_hash": "",
      "prev_hash": "5c133b6727015a133575330f60452e583f50c19fe72f61401554b4df2e16dc7d",
      "reward": 608969400000,
      "timestamp": 1748640325,
      "wide_cumulative_difficulty": "0x66e57ba1de62d720000000000000000",
      "wide_difficulty": "0x8b1edeefd10000000000000000"
    },
    "json": "{\n  \"major_version\": 16,\n  \"minor_version\": 16,\n  \"timestamp\": 1748640325,\n  \"prev_id\": \"5c133b6727015a133575330f60452e583f50c19fe72f61401554b4df2e16dc7d\",\n  \"nonce\": 404591934,\n  \"miner_tx\": {\n    \"version\": 2,\n    \"unlock_time\": 3423316,\n    \"vin\": [\n      {\n        \"gen\": {\n          \"height\": 3423256\n        }\n      }\n    ],\n    \"vout\": [\n      {\n        \"amount\": 1337888082,\n        \"target\": {\n          \"tagged_key\": {\n            \"key\": \"8a3837e0b12b6b5a0cab63b89cc0d3887b179e9ef1bf82d30c69ac6dd3cc859c\",\n            \"view_tag\": \"1a\"\n          }\n        }\n      },\n      {\n        \"amount\": 17036661502,\n        \"target\": {\n          \"tagged_key\": {\n            \"key\": \"3ab445e5c71f0c7d92e21dca97bc80238f1d001804098e591aa4a8bcf18ca1cf\",\n            \"view_tag\": \"08\"\n          }\n        }\n      },\n      {\n        \"amount\": 1064149748,\n        \"target\": {\n          \"tagged_key\": {\n            \"key\": \"08b42a997d78a91c1769dc2dec27c42db16f82e537611c0e25453b7c32eb2d10\",\n            \"view_tag\": \"a2\"\n          }\n        }\n      },\n      {\n        \"amount\": 1325636912,\n        \"target\": {\n          \"tagged_key\": {\n            \"key\": \"112187410eb1c9ac8795b3a7b8573295d58d89ea42fd7c87bd35804cd777fc78\",\n            \"view_tag\": \"33\"\n          }\n        }\n      },\n      {\n        \"amount\": 1347153149,\n        \"target\": {\n          \"tagged_key\": {\n            \"key\": \"51ff5ea5269abccb66526764079af02a8e1fa56f48c8b76fc13f11c9dbf131eb\",\n            \"view_tag\": \"f5\"\n          }\n        }\n      },\n      {\n        \"amount\": 233525467152,\n        \"target\": {\n          \"tagged_key\": {\n            \"key\": \"69eecc28c127071d2d015e407933837ec7ef37a65e257b7d0072a80edb681ad3\",\n            \"view_tag\": \"a6\"\n          }\n        }\n      },\n      {\n        \"amount\": 2658876258,\n        \"target\": {\n          \"tagged_key\": {\n            \"key\": \"3f2b20336373624bd2f5972bba03859e5e37fd6b19d6919e3a0ca77f13a1626f\",\n            \"view_tag\": \"2a\"\n          }\n        }\n      },\n      {\n        \"amount\": 1336920096,\n        \"target\": {\n          \"tagged_key\": {\n            \"key\": \"3feae6534ff62b6b53a00e28731799728f0461f3b207d1e426a0e2dab3e80561\",\n            \"view_tag\": \"70\"\n          }\n        }\n      },\n      {\n        \"amount\": 69677774405,\n        \"target\": {\n          \"tagged_key\": {\n            \"key\": \"bc1c741724bfd39da714229d76486e60b406bbe02c939aaff4be4f5939211110\",\n            \"view_tag\": \"eb\"\n          }\n        }\n      },\n      {\n        \"amount\": 6395447536,\n        \"target\": {\n          \"tagged_key\": {\n            \"key\": \"0c0e73acc3e10de3e7bba51fb35d3ab43315fb341d51f3fcb85dbb65d9caf711\",\n            \"view_tag\": \"1d\"\n          }\n        }\n      },\n      {\n        \"amount\": 15971020489,\n        \"target\": {\n          \"tagged_key\": {\n            \"key\": \"afaac7a27145279a3f5d719f00bcb60e10d72c389099fc6c7e42db1471483568\",\n            \"view_tag\": \"af\"\n          }\n        }\n      },\n      {\n        \"amount\": 1317606728,\n        \"target\": {\n          \"tagged_key\": {\n            \"key\": \"a0383528c75d1a48022fdbbeea25c5034538a283fcf9b8f46d277ee85e89cf9e\",\n            \"view_tag\": \"04\"\n          }\n        }\n      },\n      {\n        \"amount\": 8262107647,\n        \"target\": {\n          \"tagged_key\": {\n            \"key\": \"53201a17498449aad7ed17c5c040c2746291fa8681f42ef582750e4ec316a07c\",\n            \"view_tag\": \"20\"\n          }\n        }\n      },\n      {\n        \"amount\": 1332944058,\n        \"target\": {\n          \"tagged_key\": {\n            \"key\": \"fc57096aa49bda14d3d35021b050b8c98443d2fd2c16d80516f62811902ec551\",\n            \"view_tag\": \"9c\"\n          }\n        }\n      },\n      {\n        \"amount\": 3447894022,\n        \"target\": {\n          \"tagged_key\": {\n            \"key\": \"3f82c562e95f9b397ced26c7c07abaf8e8f0071de378448c5ff3677dbf8c4608\",\n            \"view_tag\": \"52\"\n          }\n        }\n      },\n      {\n        \"amount\": 1332965102,\n        \"target\": {\n          \"tagged_key\": {\n            \"key\": \"ef5fb712f92bcf6eda7c59295aeb2a5a14d4eefc4c10386f79f9f208b7b8b229\",\n            \"view_tag\": \"df\"\n          }\n        }\n      },\n      {\n        \"amount\": 2664623994,\n        \"target\": {\n          \"tagged_key\": {\n            \"key\": \"6cc9425ea9009c7909014c399d0841868ecc194956f92fff35a77cb4c0c11203\",\n            \"view_tag\": \"f8\"\n          }\n        }\n      },\n      {\n        \"amount\": 2649353929,\n        \"target\": {\n          \"tagged_key\": {\n            \"key\": \"5e7981483e84dddad849539f1f1195b9d1d9a06ab7361453d1af190f0119b0f5\",\n            \"view_tag\": \"e5\"\n          }\n        }\n      },\n      {\n        \"amount\": 1333287612,\n        \"target\": {\n          \"tagged_key\": {\n            \"key\": \"ed96b36a9405d360938972ecbabeeee3fa5ac6f9f4b9d4707c65245862a64a77\",\n            \"view_tag\": \"d8\"\n          }\n        }\n      },\n      {\n        \"amount\": 1333288269,\n        \"target\": {\n          \"tagged_key\": {\n            \"key\": \"d3b35dc8ecc9054e1bf75b197b518e0a6cd7a09bcbadf100caf2d040887aa42b\",\n            \"view_tag\": \"bc\"\n          }\n        }\n      },\n      {\n        \"amount\": 2660943849,\n        \"target\": {\n          \"tagged_key\": {\n            \"key\": \"13b14493284a76a7bb2b1de95dbfbbb641b5ccde44606ca93e2d5c678c11f2ec\",\n            \"view_tag\": \"1e\"\n          }\n        }\n      },\n      {\n        \"amount\": 1328176690,\n        \"target\": {\n          \"tagged_key\": {\n            \"key\": \"9199e24b119d326230832080149c2a4af72567be9d7c741d4ae1488649c987d1\",\n            \"view_tag\": \"80\"\n          }\n        }\n      },\n      {\n        \"amount\": 3967314654,\n        \"target\": {\n          \"tagged_key\": {\n            \"key\": \"f9c1ab4dc7909bf20fe325e133441d6cb7b76e88205ba8572f6f0276e2201ee5\",\n            \"view_tag\": \"68\"\n          }\n        }\n      },\n      {\n        \"amount\": 2664983236,\n        \"target\": {\n          \"tagged_key\": {\n            \"key\": \"bdb449822de9a15add0437583c673551c25a75ce630a626af52140fdcb69d727\",\n            \"view_tag\": \"b9\"\n          }\n        }\n      },\n      {\n        \"amount\": 6388959743,\n        \"target\": {\n          \"tagged_key\": {\n            \"key\": \"963eabaf85647ef9124b5376a13db6b2db3087cbd92eed8eb5fe129912c19b66\",\n            \"view_tag\": \"69\"\n          }\n        }\n      },\n      {\n        \"amount\": 1337184170,\n        \"target\": {\n          \"tagged_key\": {\n            \"key\": \"8008571ca1594da968983020f89d1115f7a1b15d38690adf06368b9ed101b9f0\",\n            \"view_tag\": \"00\"\n          }\n        }\n      },\n      {\n        \"amount\": 7973433173,\n        \"target\": {\n          \"tagged_key\": {\n            \"key\": \"5abf77d761dab95fc6116e9fc42c79027657d0ddf3992621b99f5a8df42ff52e\",\n            \"view_tag\": \"f0\"\n          }\n        }\n      },\n      {\n        \"amount\": 2655704859,\n        \"target\": {\n          \"tagged_key\": {\n            \"key\": \"4a42a7d187599f89ee868f35b84f5c6db4fa394164a4486e893152c86f9c2965\",\n            \"view_tag\": \"83\"\n          }\n        }\n      },\n      {\n        \"amount\": 1331690041,\n        \"target\": {\n          \"tagged_key\": {\n            \"key\": \"ed49ed0235e362a1bdd49a6302382e5f91d515b0d7c439504aa8a75ae22f5752\",\n            \"view_tag\": \"67\"\n          }\n        }\n      },\n      {\n        \"amount\": 33263252106,\n        \"target\": {\n          \"tagged_key\": {\n            \"key\": \"6bf845702e23d351f75c30f8288c234cd655035b045f688831c7642ca26d2634\",\n            \"view_tag\": \"83\"\n          }\n        }\n      },\n      {\n        \"amount\": 1320832907,\n        \"target\": {\n          \"tagged_key\": {\n            \"key\": \"1919a5fd2087f25c802842807d6a429e5b89d395cb14afeb58587e2b720ac016\",\n            \"view_tag\": \"15\"\n          }\n        }\n      },\n      {\n        \"amount\": 1322015689,\n        \"target\": {\n          \"tagged_key\": {\n            \"key\": \"b086eee2536cc838ec9ac4e868c2b4ec5c5b0feb56233fb1d5cc38f4f1876669\",\n            \"view_tag\": \"d0\"\n          }\n        }\n      },\n      {\n        \"amount\": 65932696915,\n        \"target\": {\n          \"tagged_key\": {\n            \"key\": \"39a846cc97d717c106c7f2083b6bab0b024b0d21f02b4b5542d30d1e4b3f9554\",\n            \"view_tag\": \"89\"\n          }\n        }\n      },\n      {\n        \"amount\": 1332781065,\n        \"target\": {\n          \"tagged_key\": {\n            \"key\": \"51fa1b23c587d587b07d5bfce7c726ef85b15dc0beeeaa9dc5917c07193e9b1a\",\n            \"view_tag\": \"42\"\n          }\n        }\n      },\n      {\n        \"amount\": 2677327461,\n        \"target\": {\n          \"tagged_key\": {\n            \"key\": \"2d95ff536ef2c9771e97ee6a501ea227bf8e3e6b97104e34ac56435f1f2aefb9\",\n            \"view_tag\": \"d5\"\n          }\n        }\n      },\n      {\n        \"amount\": 2652769719,\n        \"target\": {\n          \"tagged_key\": {\n            \"key\": \"194ef633897f0b4cab8a2a9d4e13731736a1e2d4a86bc049bca4baa947a02b60\",\n            \"view_tag\": \"f3\"\n          }\n        }\n      },\n      {\n        \"amount\": 1333763718,\n        \"target\": {\n          \"tagged_key\": {\n            \"key\": \"c90f51e9e5a46d47c67e741f8fa30df1bcc4c6b50532dfc693050fd6920d7cba\",\n            \"view_tag\": \"87\"\n          }\n        }\n      },\n      {\n        \"amount\": 1322061451,\n        \"target\": {\n          \"tagged_key\": {\n            \"key\": \"227b56d5b83dc27a21fb8998eec69484563e16abdfe87d18bc9fa97e754d58f3\",\n            \"view_tag\": \"a6\"\n          }\n        }\n      },\n      {\n        \"amount\": 1324982049,\n        \"target\": {\n          \"tagged_key\": {\n            \"key\": \"31a2c45b9d439e3092f9044a71c2c5ff1cbec98c8cc89905629e909018458074\",\n            \"view_tag\": \"b4\"\n          }\n        }\n      },\n      {\n        \"amount\": 59149804595,\n        \"target\": {\n          \"tagged_key\": {\n            \"key\": \"dee98a546ff9343af6a6d4fcdf5849b4f30d9605da6367cddcb51ecdda65d145\",\n            \"view_tag\": \"65\"\n          }\n        }\n      },\n      {\n        \"amount\": 1321965109,\n        \"target\": {\n          \"tagged_key\": {\n            \"key\": \"4abb5b8a31fe91defe168ca4e44604c60a16010a3a1ec6bbf3183b9cc1d1d952\",\n            \"view_tag\": \"cd\"\n          }\n        }\n      },\n      {\n        \"amount\": 1345379515,\n        \"target\": {\n          \"tagged_key\": {\n            \"key\": \"a17eec52d94a5f38f87d2ce55b66cf1708e14efae8a8486f32a17e0d75efa493\",\n            \"view_tag\": \"6c\"\n          }\n        }\n      },\n      {\n        \"amount\": 2646365861,\n        \"target\": {\n          \"tagged_key\": {\n            \"key\": \"3874ec1ae8b0e22f928a8dc65ed6f1efe34c03c62379566cc323be5456cacb72\",\n            \"view_tag\": \"ed\"\n          }\n        }\n      },\n      {\n        \"amount\": 1324262419,\n        \"target\": {\n          \"tagged_key\": {\n            \"key\": \"6a998678b0fd069a14237ae771347b5719b2686abca601e35f68fc5b017af80e\",\n            \"view_tag\": \"a4\"\n          }\n        }\n      },\n      {\n        \"amount\": 21034729372,\n        \"target\": {\n          \"tagged_key\": {\n            \"key\": \"e8cd326d41cb91780f681340290e4b0f1bafce6f1bf5ce2add92862b68b33e10\",\n            \"view_tag\": \"77\"\n          }\n        }\n      },\n      {\n        \"amount\": 4004952944,\n        \"target\": {\n          \"tagged_key\": {\n            \"key\": \"629524884c776f43fb821c897dd0f424750ef3efa4b4facff319ec8ad76a657e\",\n            \"view_tag\": \"52\"\n          }\n        }\n      }\n    ],\n    \"extra\": [\n      1,\n      224,\n      188,\n      152,\n      20,\n      23,\n      93,\n      90,\n      127,\n      142,\n      171,\n      166,\n      80,\n      218,\n      43,\n      178,\n      116,\n      64,\n      171,\n      154,\n      109,\n      56,\n      41,\n      153,\n      235,\n      128,\n      114,\n      5,\n      245,\n      119,\n      169,\n      140,\n      193,\n      2,\n      4,\n      232,\n      24,\n      147,\n      247,\n      3,\n      33,\n      8,\n      84,\n      9,\n      98,\n      86,\n      210,\n      61,\n      235,\n      179,\n      112,\n      231,\n      32,\n      239,\n      183,\n      186,\n      43,\n      3,\n      82,\n      152,\n      241,\n      123,\n      58,\n      186,\n      168,\n      31,\n      153,\n      148,\n      240,\n      255,\n      190,\n      74,\n      222,\n      180\n    ],\n    \"rct_signatures\": {\n      \"type\": 0\n    }\n  },\n  \"tx_hashes\": [\n    \"391cf0dabe33bcf054487eb36095efcd021f2edf1321cfc3750bc6c2c7110ae8\",\n    \"25e76fd95c0995d9bbd7b215a34fab0848830d92d71f556df47a03953eeda3f7\",\n    \"3bf0153b7b9955d714beb562ed141479e45cecaf96585b0cc6c5fd6ed67058f4\"\n  ]\n}",
    "miner_tx_hash": "34805ad36817c822d25e9ce5a3d943557fda17d870132090770c215c6869ecc7",
    "tx_hashes": [
      "391cf0dabe33bcf054487eb36095efcd021f2edf1321cfc3750bc6c2c7110ae8",
      "25e76fd95c0995d9bbd7b215a34fab0848830d92d71f556df47a03953eeda3f7",
      "3bf0153b7b9955d714beb562ed141479e45cecaf96585b0cc6c5fd6ed67058f4"
    ]
  }
}

get_block_count

curl http://127.0.0.1:28081/json_rpc -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":"0","method":"get_block_count","params":{}}' | jq
{
  "jsonrpc": "2.0",
  "id": "0",
  "result": {
    "status": "OK",
    "untrusted": false,
    "count": 3423276
  }
}

get_last_block_header

curl -v http://127.0.0.1:28081/json_rpc -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":"0","method":"get_last_block_header","params":{"fill_pow_hash":false}}' | jq
{
  "jsonrpc": "2.0",
  "id": "0",
  "result": {
    "status": "OK",
    "untrusted": false,
    "credits": 0,
    "top_hash": "",
    "block_header": {
      "block_size": 12776,
      "block_weight": 12776,
      "cumulative_difficulty_top64": 463419299369392060,
      "cumulative_difficulty": 0,
      "depth": 0,
      "difficulty_top64": 604984468787,
      "difficulty": 0,
      "hash": "2b86c2b53145c9dba07c1c230042e069ab5cf0d253f30577f5794c217c62e740",
      "height": 3423281,
      "long_term_weight": 176470,
      "major_version": 16,
      "miner_tx_hash": "b4ee7986b8b6487d701846cec27a2d0b293e41a559db009be6e65642041ceb9f",
      "minor_version": 16,
      "nonce": 1882052206,
      "num_txes": 6,
      "orphan_status": false,
      "pow_hash": "",
      "prev_hash": "398b75de44707ec29a45651f8dde1794857bf6a1865ade7146cbf8e0779d4e7d",
      "reward": 600252480000,
      "timestamp": 1748644630,
      "wide_cumulative_difficulty": "0x66e6565c0f917c30000000000000000",
      "wide_difficulty": "0x8cdbe265330000000000000000"
    }
  }
}

get_block_header_by_hash

curl http://127.0.0.1:28081/json_rpc -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":"0","method":"get_block_header_by_hash","params":{"hash":"6f71b284a23d03ddcdf5cc325706ebd7637d3436d7ed7f1fdc47587d25cd18e0","fill_pow_hash":false}}' | jq
{
  "jsonrpc": "2.0",
  "id": "0",
  "result": {
    "status": "OK",
    "untrusted": false,
    "credits": 0,
    "top_hash": "",
    "block_header": {
      "block_size": 166755,
      "block_weight": 166755,
      "cumulative_difficulty_top64": 463415095874726700,
      "cumulative_difficulty": 0,
      "depth": 1,
      "difficulty_top64": 599749930910,
      "difficulty": 0,
      "hash": "6f71b284a23d03ddcdf5cc325706ebd7637d3436d7ed7f1fdc47587d25cd18e0",
      "height": 3423274,
      "long_term_weight": 176470,
      "major_version": 16,
      "miner_tx_hash": "e5cbc534909dbe95ac374ccac4d3c4d117232977553dabac8be86c5797357220",
      "minor_version": 16,
      "nonce": 3478556,
      "num_txes": 64,
      "orphan_status": false,
      "pow_hash": "",
      "prev_hash": "52b794ebbca023574b3d1ea2981d39cafcfb3b2e960ea9d1c35c1a40619c44cc",
      "reward": 613506920000,
      "timestamp": 1748643548,
      "wide_cumulative_difficulty": "0x66e61930d2aab270000000000000000",
      "wide_difficulty": "0x8ba3e1af9e0000000000000000"
    },
    "block_headers": []
  }
}

get_block_header_by_height

curl http://127.0.0.1:18081/json_rpc -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":"0","method":"get_block_header_by_height","params":{"height":3423276,"fill_pow_hash":false}}' | jq
{
  "id": "0",
  "jsonrpc": "2.0",
  "result": {
    "block_header": {
      "block_size": 164266,
      "block_weight": 164266,
      "cumulative_difficulty": 463416295168802500,
      "cumulative_difficulty_top64": 0,
      "depth": 1,
      "difficulty": 599749930910,
      "difficulty_top64": 0,
      "hash": "5334581a1a1162858c4931788928e12c322649a554dce8633f17c596e67e29bd",
      "height": 3423276,
      "long_term_weight": 176470,
      "major_version": 16,
      "miner_tx_hash": "2327f007b6a421dc9f879a9fd775dbfb400c6e1d1f5c52e208b9f109c4179320",
      "minor_version": 16,
      "nonce": 1090754916,
      "num_txes": 86,
      "orphan_status": false,
      "pow_hash": "",
      "prev_hash": "b5e1e2bedd45d3095d80bcc10a464ccd9eba96a06c387292060e848fd4492d1a",
      "reward": 625516140000,
      "timestamp": 1748643990,
      "wide_cumulative_difficulty": "0x66e62aa48a9feae",
      "wide_difficulty": "0x8ba3e1af9e"
    },
    "credits": 0,
    "status": "OK",
    "top_hash": "",
    "untrusted": false
  }
}

get_block_headers_range

curl -v http://127.0.0.1:28081/json_rpc -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":"0","method":"get_block_headers_range","params":{"start_height":3423274,"end_height":3423275,"fill_pow_hash":false}}' | jq
{
  "jsonrpc": "2.0",
  "id": "0",
  "result": {
    "status": "OK",
    "untrusted": false,
    "credits": 0,
    "top_hash": "",
    "headers": [
      {
        "block_size": 166755,
        "block_weight": 166755,
        "cumulative_difficulty_top64": 463415095874726700,
        "cumulative_difficulty": 0,
        "depth": 4,
        "difficulty_top64": 600638377615,
        "difficulty": 0,
        "hash": "6f71b284a23d03ddcdf5cc325706ebd7637d3436d7ed7f1fdc47587d25cd18e0",
        "height": 3423274,
        "long_term_weight": 176470,
        "major_version": 16,
        "miner_tx_hash": "e5cbc534909dbe95ac374ccac4d3c4d117232977553dabac8be86c5797357220",
        "minor_version": 16,
        "nonce": 3478556,
        "num_txes": 64,
        "orphan_status": false,
        "pow_hash": "",
        "prev_hash": "52b794ebbca023574b3d1ea2981d39cafcfb3b2e960ea9d1c35c1a40619c44cc",
        "reward": 613506920000,
        "timestamp": 1748643548,
        "wide_cumulative_difficulty": "0x66e61930d2aab270000000000000000",
        "wide_difficulty": "0x8bd8d64e8f0000000000000000"
      },
      {
        "block_size": 18579,
        "block_weight": 18579,
        "cumulative_difficulty_top64": 463415695418871550,
        "cumulative_difficulty": 0,
        "depth": 3,
        "difficulty_top64": 600638377615,
        "difficulty": 0,
        "hash": "b5e1e2bedd45d3095d80bcc10a464ccd9eba96a06c387292060e848fd4492d1a",
        "height": 3423275,
        "long_term_weight": 176470,
        "major_version": 16,
        "miner_tx_hash": "34c39573554bef6fed762144c98cb7d5543f76bd0627d100c6f017290d342b69",
        "minor_version": 16,
        "nonce": 1301,
        "num_txes": 9,
        "orphan_status": false,
        "pow_hash": "",
        "prev_hash": "6f71b284a23d03ddcdf5cc325706ebd7637d3436d7ed7f1fdc47587d25cd18e0",
        "reward": 601891280000,
        "timestamp": 1748643593,
        "wide_cumulative_difficulty": "0x66e621ea4c84f100000000000000000",
        "wide_difficulty": "0x8bd8d64e8f0000000000000000"
      }
    ]
  }
}

on_get_block_hash

curl -v http://127.0.0.1:28081/json_rpc -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":"0","method":"on_get_block_hash","params":[912345]}' | jq
{
  "jsonrpc": "2.0",
  "id": "0",
  "result": "e22cf75f39ae720e8b71b3d120a5ac03f0db50bba6379e2850975b4859190bc6"
}

/get_height

curl http://127.0.0.1:28081/get_height -H 'Content-Type: application/json' | jq
{
  "status": "OK",
  "untrusted": false,
  "hash": "b5e1e2bedd45d3095d80bcc10a464ccd9eba96a06c387292060e848fd4492d1a",
  "height": 3423275
}

@github-actions github-actions bot added A-dependency Area: Related to dependencies, or changes to a Cargo.{toml,lock} file. A-workspace Area: Changes to a root workspace file or general repo file. A-helper Area: Related to cuprate-helper. A-rpc Area: Related to RPC. A-binaries Area: Related to binaries. labels May 1, 2025
@hinto-janai hinto-janai changed the title cuprated: CupratedRpcHandler + /get_{height,outs} cuprated: CupratedRpcHandler, enable certain endpoints May 30, 2025
@github-actions github-actions bot added A-docs Area: Related to documentation. A-storage Area: Related to storage. A-books Area: Related to Cuprate's books. A-book-user Area: Related to the User book. labels May 30, 2025
@hinto-janai hinto-janai marked this pull request as ready for review May 31, 2025 00:38
Comment on lines -47 to +53
Req::GetBlocks(r) => Resp::GetBlocks(get_blocks(state, r).await?),
Req::GetBlocksByHeight(r) => Resp::GetBlocksByHeight(get_blocks_by_height(state, r).await?),
Req::GetHashes(r) => Resp::GetHashes(get_hashes(state, r).await?),
Req::GetOutputIndexes(r) => Resp::GetOutputIndexes(get_output_indexes(state, r).await?),
Req::GetOuts(r) => Resp::GetOuts(get_outs(state, r).await?),
Req::GetTransactionPoolHashes(r) => {
Resp::GetTransactionPoolHashes(get_transaction_pool_hashes(state, r).await?)
}
Req::GetOutputDistribution(r) => {
Resp::GetOutputDistribution(get_output_distribution(state, r).await?)
}
Req::GetBlocks(r) => Resp::GetBlocks(not_available()?),
Req::GetBlocksByHeight(r) => Resp::GetBlocksByHeight(not_available()?),
Req::GetHashes(r) => Resp::GetHashes(not_available()?),
Req::GetOutputIndexes(r) => Resp::GetOutputIndexes(not_available()?),
Req::GetOuts(r) => Resp::GetOuts(not_available()?),
Req::GetTransactionPoolHashes(r) => Resp::GetTransactionPoolHashes(not_available()?),
Req::GetOutputDistribution(r) => Resp::GetOutputDistribution(not_available()?),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In binaries/cuprated/src/rpc/handlers/{bin,json_rpc,other_json}.rs, the request handler mapping function will route to not_available until manually enabled in future PRs.

The definition is...

Comment on lines +108 to +110
.json_rpc()
.other_get_height()
.fallback()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Enabled endpoints.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaces books/user/src/resources/{ip,port}.md.

@github-actions github-actions bot added the A-consensus Area: Related to consensus. label Jun 3, 2025
hinto-janai and others added 2 commits June 4, 2025 08:35
Co-authored-by: Boog900 <boog900@tutanota.com>
Copy link
Member

@SyntheticBird45 SyntheticBird45 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No feedback. LGTM

@Boog900 Boog900 merged commit 4c2c749 into Cuprate:main Jun 4, 2025
18 checks passed
@hinto-janai hinto-janai deleted the rpc-1 branch June 4, 2025 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-binaries Area: Related to binaries. A-book-user Area: Related to the User book. A-books Area: Related to Cuprate's books. A-consensus Area: Related to consensus. A-docs Area: Related to documentation. A-storage Area: Related to storage.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants