Skip to content

Commit 50fb478

Browse files
authored
fix: align uncle-related RPC endpoints with Ethereum OpenRPC Spec (#4211)
Signed-off-by: Logan Nguyen <[email protected]>
1 parent 96228bc commit 50fb478

File tree

12 files changed

+270
-127
lines changed

12 files changed

+270
-127
lines changed

charts/hedera-json-rpc-relay/postman.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@
448448
"header": [],
449449
"body": {
450450
"mode": "raw",
451-
"raw": "{\n \"id\": \"test_id\",\n \"jsonrpc\": \"2.0\",\n \"method\": \"eth_getUncleByBlockHashAndIndex\",\n \"params\": []\n}",
451+
"raw": "{\n \"id\": \"test_id\",\n \"jsonrpc\": \"2.0\",\n \"method\": \"eth_getUncleByBlockHashAndIndex\",\n \"params\": [\"0xa291866ddf5dfd7ac83d079614ac60ab412df7c55e4d91408b2f365581405ca8\", \"0x0\"]\n}",
452452
"options": {
453453
"raw": {
454454
"language": "json"
@@ -487,7 +487,7 @@
487487
"header": [],
488488
"body": {
489489
"mode": "raw",
490-
"raw": "{\n \"id\": \"test_id\",\n \"jsonrpc\": \"2.0\",\n \"method\": \"eth_getUncleByBlockNumberAndIndex\",\n \"params\": []\n}",
490+
"raw": "{\n \"id\": \"test_id\",\n \"jsonrpc\": \"2.0\",\n \"method\": \"eth_getUncleByBlockNumberAndIndex\",\n \"params\": [\"latest\", \"0x0\"]\n}",
491491
"options": {
492492
"raw": {
493493
"language": "json"
@@ -526,7 +526,7 @@
526526
"header": [],
527527
"body": {
528528
"mode": "raw",
529-
"raw": "{\n \"id\": \"test_id\",\n \"jsonrpc\": \"2.0\",\n \"method\": \"eth_getUncleCountByBlockHash\",\n \"params\": []\n}",
529+
"raw": "{\n \"id\": \"test_id\",\n \"jsonrpc\": \"2.0\",\n \"method\": \"eth_getUncleCountByBlockHash\",\n \"params\": [\"0xa291866ddf5dfd7ac83d079614ac60ab412df7c55e4d91408b2f365581405ca8\"]\n}",
530530
"options": {
531531
"raw": {
532532
"language": "json"
@@ -565,7 +565,7 @@
565565
"header": [],
566566
"body": {
567567
"mode": "raw",
568-
"raw": "{\n \"id\": \"test_id\",\n \"jsonrpc\": \"2.0\",\n \"method\": \"eth_getUncleCountByBlockNumber\",\n \"params\": []\n}",
568+
"raw": "{\n \"id\": \"test_id\",\n \"jsonrpc\": \"2.0\",\n \"method\": \"eth_getUncleCountByBlockNumber\",\n \"params\": [\"latest\"]\n}",
569569
"options": {
570570
"raw": {
571571
"language": "json"

docs/openrpc.json

Lines changed: 98 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -118,17 +118,21 @@
118118
"name": "eth_coinbase",
119119
"summary": "Always returns UNSUPPORTED_METHOD error.",
120120
"params": [],
121-
"errors": [{
121+
"errors": [
122+
{
122123
"$ref": "#/components/errors/unsupportedError"
123-
}]
124+
}
125+
]
124126
},
125127
{
126128
"name": "eth_blobBaseFee",
127129
"summary": "Always returns UNSUPPORTED_METHOD error.",
128130
"params": [],
129-
"errors": [{
131+
"errors": [
132+
{
130133
"$ref": "#/components/errors/unsupportedError"
131-
}]
134+
}
135+
]
132136
},
133137
{
134138
"name": "eth_estimateGas",
@@ -615,7 +619,22 @@
615619
"name": "eth_getUncleByBlockHashAndIndex",
616620
"summary": "Returns information about a uncle of a block by hash and uncle index position.",
617621
"description": "![](https://raw.githubusercontent.com/hiero-ledger/hiero-json-rpc-relay/main/docs/images/http_label.png)",
618-
"params": [],
622+
"params": [
623+
{
624+
"name": "Block hash",
625+
"required": false,
626+
"schema": {
627+
"$ref": "#/components/schemas/hash32"
628+
}
629+
},
630+
{
631+
"name": "Index",
632+
"required": false,
633+
"schema": {
634+
"$ref": "#/components/schemas/uint"
635+
}
636+
}
637+
],
619638
"result": {
620639
"name": "eth_getUncleByBlockHashAndIndex result",
621640
"schema": {
@@ -628,7 +647,22 @@
628647
"name": "eth_getUncleByBlockNumberAndIndex",
629648
"summary": "Returns information about a uncle of a block by number and uncle index position.",
630649
"description": "![](https://raw.githubusercontent.com/hiero-ledger/hiero-json-rpc-relay/main/docs/images/http_label.png)",
631-
"params": [],
650+
"params": [
651+
{
652+
"name": "Block",
653+
"required": false,
654+
"schema": {
655+
"$ref": "#/components/schemas/BlockNumberOrTag"
656+
}
657+
},
658+
{
659+
"name": "Index",
660+
"required": false,
661+
"schema": {
662+
"$ref": "#/components/schemas/uint"
663+
}
664+
}
665+
],
632666
"result": {
633667
"name": "eth_getUncleByBlockNumberAndIndex result",
634668
"schema": {
@@ -641,7 +675,15 @@
641675
"name": "eth_getUncleCountByBlockHash",
642676
"summary": "Returns the number of uncles in a block from a block matching the given block hash.",
643677
"description": "![](https://raw.githubusercontent.com/hiero-ledger/hiero-json-rpc-relay/main/docs/images/http_label.png)",
644-
"params": [],
678+
"params": [
679+
{
680+
"name": "Block hash",
681+
"required": false,
682+
"schema": {
683+
"$ref": "#/components/schemas/hash32"
684+
}
685+
}
686+
],
645687
"result": {
646688
"name": "eth_getUncleCountByBlockHash result",
647689
"schema": {
@@ -656,7 +698,15 @@
656698
"name": "eth_getUncleCountByBlockNumber",
657699
"summary": "Returns the number of transactions in a block matching the given block number.",
658700
"description": "![](https://raw.githubusercontent.com/hiero-ledger/hiero-json-rpc-relay/main/docs/images/http_label.png)",
659-
"params": [],
701+
"params": [
702+
{
703+
"name": "Block",
704+
"required": false,
705+
"schema": {
706+
"$ref": "#/components/schemas/BlockNumberOrTag"
707+
}
708+
}
709+
],
660710
"result": {
661711
"name": "eth_getUncleCountByBlockNumber result",
662712
"schema": {
@@ -671,9 +721,11 @@
671721
"name": "eth_getWork",
672722
"summary": "Always returns UNSUPPORTED_METHOD error.",
673723
"params": [],
674-
"errors": [{
724+
"errors": [
725+
{
675726
"$ref": "#/components/errors/unsupportedError"
676-
}]
727+
}
728+
]
677729
},
678730
{
679731
"name": "eth_hashrate",
@@ -786,9 +838,11 @@
786838
"name": "eth_newPendingTransactionFilter",
787839
"summary": "Always returns UNSUPPORTED_METHOD error.",
788840
"params": [],
789-
"errors": [{
841+
"errors": [
842+
{
790843
"$ref": "#/components/errors/unsupportedError"
791-
}],
844+
}
845+
],
792846
"tags": [
793847
{
794848
"name": "alpha API"
@@ -863,9 +917,11 @@
863917
"name": "eth_protocolVersion",
864918
"summary": "Always returns UNSUPPORTED_METHOD error.",
865919
"params": [],
866-
"errors": [{
920+
"errors": [
921+
{
867922
"$ref": "#/components/errors/unsupportedError"
868-
}]
923+
}
924+
]
869925
},
870926
{
871927
"name": "eth_sendRawTransaction",
@@ -891,33 +947,41 @@
891947
"name": "eth_sendTransaction",
892948
"summary": "Always returns UNSUPPORTED_METHOD error.",
893949
"params": [],
894-
"errors": [{
950+
"errors": [
951+
{
895952
"$ref": "#/components/errors/unsupportedError"
896-
}]
953+
}
954+
]
897955
},
898956
{
899957
"name": "eth_signTransaction",
900958
"summary": "Always returns UNSUPPORTED_METHOD error.",
901959
"params": [],
902-
"errors": [{
960+
"errors": [
961+
{
903962
"$ref": "#/components/errors/unsupportedError"
904-
}]
963+
}
964+
]
905965
},
906966
{
907967
"name": "eth_sign",
908968
"summary": "Always returns UNSUPPORTED_METHOD error.",
909969
"params": [],
910-
"errors": [{
970+
"errors": [
971+
{
911972
"$ref": "#/components/errors/unsupportedError"
912-
}]
973+
}
974+
]
913975
},
914976
{
915977
"name": "eth_submitHashrate",
916978
"summary": "Always returns UNSUPPORTED_METHOD error.",
917979
"params": [],
918-
"errors": [{
980+
"errors": [
981+
{
919982
"$ref": "#/components/errors/unsupportedError"
920-
}]
983+
}
984+
]
921985
},
922986
{
923987
"name": "eth_submitWork",
@@ -977,9 +1041,11 @@
9771041
"name": "net_peerCount",
9781042
"summary": "Always returns UNSUPPORTED_METHOD error.",
9791043
"params": [],
980-
"errors": [{
1044+
"errors": [
1045+
{
9811046
"$ref": "#/components/errors/unsupportedError"
982-
}]
1047+
}
1048+
]
9831049
},
9841050
{
9851051
"name": "web3_clientVersion",
@@ -1253,17 +1319,21 @@
12531319
"name": "eth_getProof",
12541320
"summary": "Always returns UNSUPPORTED_METHOD error.",
12551321
"params": [],
1256-
"errors": [{
1322+
"errors": [
1323+
{
12571324
"$ref": "#/components/errors/unsupportedError"
1258-
}]
1325+
}
1326+
]
12591327
},
12601328
{
12611329
"name": "eth_createAccessList",
12621330
"summary": "Always returns UNSUPPORTED_METHOD error.",
12631331
"params": [],
1264-
"errors": [{
1332+
"errors": [
1333+
{
12651334
"$ref": "#/components/errors/unsupportedError"
1266-
}]
1335+
}
1336+
]
12671337
}
12681338
],
12691339
"components": {

packages/relay/src/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,13 @@ export interface Eth {
113113

114114
getTransactionReceipt(hash: string, requestDetails: RequestDetails): Promise<Receipt | null>;
115115

116-
getUncleByBlockHashAndIndex(requestDetails: RequestDetails): Promise<any>;
116+
getUncleByBlockHashAndIndex(blockHash: string, index: string): null;
117117

118-
getUncleByBlockNumberAndIndex(requestDetails: RequestDetails): Promise<any>;
118+
getUncleByBlockNumberAndIndex(blockNumOrTag: string, index: string): null;
119119

120-
getUncleCountByBlockHash(requestDetails: RequestDetails): Promise<string>;
120+
getUncleCountByBlockHash(blockHash: string): string;
121121

122-
getUncleCountByBlockNumber(requestDetails: RequestDetails): Promise<string>;
122+
getUncleCountByBlockNumber(blockNumOrTag: string): string;
123123

124124
getWork(): JsonRpcError;
125125

packages/relay/src/lib/eth.ts

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -453,13 +453,17 @@ export class EthImpl implements Eth {
453453
* @rpcMethod Exposed as eth_getUncleByBlockHashAndIndex RPC endpoint
454454
* @rpcParamLayoutConfig decorated method parameter layout
455455
*
456-
* @param {RequestDetails} requestDetails - Details about the request for logging and tracking
457-
* @returns {Promise<null>} Always returns null
456+
* @param blockHash - The block hash
457+
* @param index - The uncle index
458+
* @returns Always returns null
458459
*/
459460
@rpcMethod
460-
@rpcParamLayoutConfig(RPC_LAYOUT.REQUEST_DETAILS_ONLY)
461-
async getUncleByBlockHashAndIndex(requestDetails: RequestDetails): Promise<null> {
462-
return this.blockService.getUncleByBlockHashAndIndex(requestDetails);
461+
@rpcParamValidationRules({
462+
0: { type: 'blockHash', required: false },
463+
1: { type: 'hex', required: false },
464+
})
465+
getUncleByBlockHashAndIndex(blockHash: string, index: string): null {
466+
return this.blockService.getUncleByBlockHashAndIndex(blockHash, index);
463467
}
464468

465469
/**
@@ -468,13 +472,17 @@ export class EthImpl implements Eth {
468472
* @rpcMethod Exposed as eth_getUncleByBlockNumberAndIndex RPC endpoint
469473
* @rpcParamLayoutConfig decorated method parameter layout
470474
*
471-
* @param {RequestDetails} requestDetails - Details about the request for logging and tracking
472-
* @returns {Promise<null>} Always returns null
475+
* @param blockNumOrTag - The block number or tag
476+
* @param index - The uncle index
477+
* @returns Always returns null
473478
*/
474479
@rpcMethod
475-
@rpcParamLayoutConfig(RPC_LAYOUT.REQUEST_DETAILS_ONLY)
476-
async getUncleByBlockNumberAndIndex(requestDetails: RequestDetails): Promise<null> {
477-
return this.blockService.getUncleByBlockNumberAndIndex(requestDetails);
480+
@rpcParamValidationRules({
481+
0: { type: 'blockNumber', required: false },
482+
1: { type: 'hex', required: false },
483+
})
484+
getUncleByBlockNumberAndIndex(blockNumOrTag: string, index: string): null {
485+
return this.blockService.getUncleByBlockNumberAndIndex(blockNumOrTag, index);
478486
}
479487

480488
/**
@@ -483,13 +491,15 @@ export class EthImpl implements Eth {
483491
* @rpcMethod Exposed as eth_getUncleCountByBlockHash RPC endpoint
484492
* @rpcParamLayoutConfig decorated method parameter layout
485493
*
486-
* @param {RequestDetails} requestDetails - Details about the request for logging and tracking
487-
* @returns {Promise<string>} Always returns '0x0'
494+
* @param blockHash - The block hash
495+
* @returns Always returns '0x0'
488496
*/
489497
@rpcMethod
490-
@rpcParamLayoutConfig(RPC_LAYOUT.REQUEST_DETAILS_ONLY)
491-
async getUncleCountByBlockHash(requestDetails: RequestDetails): Promise<string> {
492-
return this.blockService.getUncleCountByBlockHash(requestDetails);
498+
@rpcParamValidationRules({
499+
0: { type: 'blockHash', required: false },
500+
})
501+
getUncleCountByBlockHash(blockHash: string): string {
502+
return this.blockService.getUncleCountByBlockHash(blockHash);
493503
}
494504

495505
/**
@@ -498,13 +508,15 @@ export class EthImpl implements Eth {
498508
* @rpcMethod Exposed as eth_getUncleCountByBlockNumber RPC endpoint
499509
* @rpcParamLayoutConfig decorated method parameter layout
500510
*
501-
* @param requestDetails - Details about the request for logging and tracking
511+
* @param blockNumOrTag - The block number or tag
502512
* @returns Always returns '0x0'
503513
*/
504514
@rpcMethod
505-
@rpcParamLayoutConfig(RPC_LAYOUT.REQUEST_DETAILS_ONLY)
506-
async getUncleCountByBlockNumber(requestDetails: RequestDetails): Promise<string> {
507-
return this.blockService.getUncleCountByBlockNumber(requestDetails);
515+
@rpcParamValidationRules({
516+
0: { type: 'blockNumber', required: false },
517+
})
518+
getUncleCountByBlockNumber(blockNumOrTag: string): string {
519+
return this.blockService.getUncleCountByBlockNumber(blockNumOrTag);
508520
}
509521

510522
/**

0 commit comments

Comments
 (0)