From 7b413691ab662e9904c40c04069dd85094cbcd93 Mon Sep 17 00:00:00 2001 From: Simeon Nakov Date: Wed, 16 Apr 2025 15:57:30 +0300 Subject: [PATCH 1/2] feat: change eth_maxPriorityFeePerGas to return UNSUPPORTED_METHOD Signed-off-by: Simeon Nakov --- docs/openrpc.json | 10 ++-------- docs/rpc-api.md | 2 +- packages/relay/src/index.ts | 2 +- packages/relay/src/lib/eth.ts | 4 ++-- .../relay/tests/lib/eth/eth_common.spec.ts | 5 ++++- packages/relay/tests/lib/openrpc.spec.ts | 6 ++++++ .../data/conformity-tests-batch-5.json | 5 +++-- .../tests/acceptance/rpc_batch2.spec.ts | 9 ++++----- .../server/tests/integration/server.spec.ts | 19 +++++++++++-------- 9 files changed, 34 insertions(+), 28 deletions(-) diff --git a/docs/openrpc.json b/docs/openrpc.json index 08ab915d04..3c5872a43c 100644 --- a/docs/openrpc.json +++ b/docs/openrpc.json @@ -653,17 +653,11 @@ }, { "name": "eth_maxPriorityFeePerGas", - "summary": "Returns a fee per gas that is an estimate of how much you can pay as a priority fee, or 'tip', to get a transaction included in the current block.", + "summary": "Always returns UNSUPPORTED_METHOD error. Hedera doesn't have a concept of tipping nodes to promote any behavior", "description": "![](https://raw.githubusercontent.com/hiero-ledger/hiero-json-rpc-relay/main/docs/images/http_label.png) ![](https://raw.githubusercontent.com/hiero-ledger/hiero-json-rpc-relay/main/docs/images/ws_label.png)", "params": [], "result": { - "name": "eth_maxPriorityFeePerGas result", - "schema": { - "description": "Always returns '0x0'. Hedera doesn't have a concept of tipping nodes to promote any behavior", - "title": "hex encoded unsigned integer", - "type": "string", - "pattern": "0x0" - } + "$ref": "#/components/schemas/unsupportedError" } }, { diff --git a/docs/rpc-api.md b/docs/rpc-api.md index e982daf3e4..596b4df73c 100644 --- a/docs/rpc-api.md +++ b/docs/rpc-api.md @@ -90,7 +90,7 @@ Below is a table of provided methods. | [eth_getUncleCountByBlockNumber](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getunclecountbyblocknumber) | `0x0` | N/A | | [eth_getWork](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getwork) | `-32601` (Method not found) | N/A | | [eth_hashrate](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_hashrate) | `0x0` | N/A | -| [eth_maxPriorityFeePerGas](https://docs.alchemy.com/reference/eth-maxpriorityfeepergas) | `0x0` | N/A | +| [eth_maxPriorityFeePerGas](https://docs.alchemy.com/reference/eth-maxpriorityfeepergas) | `-32601` (Method not found) | N/A | | [eth_mining](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_mining) | `false` | N/A | | [eth_newBlockFilter](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_newblockfilter) | N/A | N/A | | [eth_newFilter](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_newfilter) | N/A | N/A | diff --git a/packages/relay/src/index.ts b/packages/relay/src/index.ts index 575b89deca..16bb04022f 100644 --- a/packages/relay/src/index.ts +++ b/packages/relay/src/index.ts @@ -119,7 +119,7 @@ export interface Eth { hashrate(requestDetails: RequestDetails): Promise; - maxPriorityFeePerGas(requestDetails: RequestDetails): Promise; + maxPriorityFeePerGas(requestDetails: RequestDetails): JsonRpcError; mining(requestDetails: RequestDetails): Promise; diff --git a/packages/relay/src/lib/eth.ts b/packages/relay/src/lib/eth.ts index 8e7297f22f..2563478ed0 100644 --- a/packages/relay/src/lib/eth.ts +++ b/packages/relay/src/lib/eth.ts @@ -3240,11 +3240,11 @@ export class EthImpl implements Eth { */ @rpcMethod @rpcParamLayoutConfig(RPC_LAYOUT.REQUEST_DETAILS_ONLY) - async maxPriorityFeePerGas(requestDetails: RequestDetails): Promise { + maxPriorityFeePerGas(requestDetails: RequestDetails): JsonRpcError { if (this.logger.isLevelEnabled('trace')) { this.logger.trace(`${requestDetails.formattedRequestId} maxPriorityFeePerGas()`); } - return EthImpl.zeroHex; + return predefined.UNSUPPORTED_METHOD; } static isArrayNonEmpty(input: any): boolean { diff --git a/packages/relay/tests/lib/eth/eth_common.spec.ts b/packages/relay/tests/lib/eth/eth_common.spec.ts index 60338fee4c..7c59f8bda1 100644 --- a/packages/relay/tests/lib/eth/eth_common.spec.ts +++ b/packages/relay/tests/lib/eth/eth_common.spec.ts @@ -84,7 +84,10 @@ describe('@ethCommon', async function () { it('should execute "eth_maxPriorityFeePerGas"', async function () { const result = await relay.eth().maxPriorityFeePerGas(requestDetails); - expect(result).to.eq('0x0'); + expect(result).to.have.property('code'); + expect(result.code).to.be.equal(-32601); + expect(result).to.have.property('message'); + expect(result.message).to.be.equal('Unsupported JSON-RPC method'); }); }); }); diff --git a/packages/relay/tests/lib/openrpc.spec.ts b/packages/relay/tests/lib/openrpc.spec.ts index 027c6492c9..c3328293a6 100644 --- a/packages/relay/tests/lib/openrpc.spec.ts +++ b/packages/relay/tests/lib/openrpc.spec.ts @@ -494,6 +494,12 @@ describe('Open RPC Specification', function () { validateResponseSchema(methodsResponseSchema.eth_hashrate, response); }); + it('should execute "eth_maxPriorityFeePerGas"', function () { + const response = ethImpl.maxPriorityFeePerGas(requestDetails); + + validateResponseSchema(methodsResponseSchema.eth_maxPriorityFeePerGas, response); + }); + it('should execute "eth_mining"', async function () { const response = await ethImpl.mining(requestDetails); diff --git a/packages/server/tests/acceptance/data/conformity-tests-batch-5.json b/packages/server/tests/acceptance/data/conformity-tests-batch-5.json index 758f3c1bbb..4ebf657f60 100644 --- a/packages/server/tests/acceptance/data/conformity-tests-batch-5.json +++ b/packages/server/tests/acceptance/data/conformity-tests-batch-5.json @@ -28,8 +28,9 @@ "response": "{\"result\":\"0x0\",\"jsonrpc\":\"2.0\",\"id\":\"test_id\"}" }, "eth_maxPriorityFeePerGas": { - "request": "{\"id\":\"test_id\",\"jsonrpc\":\"2.0\",\"method\":\"eth_maxPriorityFeePerGas\"}", - "response": "{\"result\":\"0x0\",\"jsonrpc\":\"2.0\",\"id\":\"test_id\"}" + "status": 400, + "request": "{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"eth_maxPriorityFeePerGas\"}", + "response": "{\"jsonrpc\":\"2.0\",\"id\":1,\"error\":{\"code\":-32601}}" }, "eth_mining": { "request": "{\"id\":\"test_id\",\"jsonrpc\":\"2.0\",\"method\":\"eth_mining\",\"params\":[]}", diff --git a/packages/server/tests/acceptance/rpc_batch2.spec.ts b/packages/server/tests/acceptance/rpc_batch2.spec.ts index 65220a6d87..73b1be1f28 100644 --- a/packages/server/tests/acceptance/rpc_batch2.spec.ts +++ b/packages/server/tests/acceptance/rpc_batch2.spec.ts @@ -683,11 +683,6 @@ describe('@api-batch-2 RPC Server Acceptance Tests', function () { const res = await relay.call(RelayCalls.ETH_ENDPOINTS.ETH_SYNCING, [], requestId); expect(res).to.be.equal(false); }); - - it('should execute "eth_maxPriorityFeePerGas"', async function () { - const res = await relay.call(RelayCalls.ETH_ENDPOINTS.ETH_MAX_PRIORITY_FEE_PER_GAS, [], requestId); - expect(res).to.be.equal('0x0'); - }); }); describe('@release Unsupported RPC Endpoints', () => { @@ -724,6 +719,10 @@ describe('@api-batch-2 RPC Server Acceptance Tests', function () { await relay.callUnsupported(method, [], requestId); } }); + + it('should not support "eth_maxPriorityFeePerGas"', async function () { + await relay.callUnsupported(RelayCalls.ETH_ENDPOINTS.ETH_MAX_PRIORITY_FEE_PER_GAS, [], requestId); + }); }); describe('eth_getCode', () => { diff --git a/packages/server/tests/integration/server.spec.ts b/packages/server/tests/integration/server.spec.ts index e0d6bd3a50..ad1829f1c2 100644 --- a/packages/server/tests/integration/server.spec.ts +++ b/packages/server/tests/integration/server.spec.ts @@ -475,15 +475,18 @@ describe('RPC Server', function () { }); it('should execute "eth_maxPriorityFeePerGas"', async function () { - const res = await testClient.post('/', { - id: '2', - jsonrpc: '2.0', - method: RelayCalls.ETH_ENDPOINTS.ETH_MAX_PRIORITY_FEE_PER_GAS, - params: [null], - }); + try { + await testClient.post('/', { + id: '2', + jsonrpc: '2.0', + method: RelayCalls.ETH_ENDPOINTS.ETH_MAX_PRIORITY_FEE_PER_GAS, + params: [null], + }); - BaseTest.defaultResponseChecks(res); - expect(res.data.result).to.be.equal('0x0'); + Assertions.expectedError(); + } catch (error: any) { + BaseTest.unsupportedJsonRpcMethodChecks(error.response); + } }); // Test all engine methods From 38c3bfc224f304d5aef0c1bbaad64fd50a3123ca Mon Sep 17 00:00:00 2001 From: Simeon Nakov Date: Thu, 17 Apr 2025 15:59:46 +0300 Subject: [PATCH 2/2] added public keyword to method Signed-off-by: Simeon Nakov --- packages/relay/src/lib/eth.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/relay/src/lib/eth.ts b/packages/relay/src/lib/eth.ts index 2563478ed0..dd9b4f6974 100644 --- a/packages/relay/src/lib/eth.ts +++ b/packages/relay/src/lib/eth.ts @@ -3240,7 +3240,7 @@ export class EthImpl implements Eth { */ @rpcMethod @rpcParamLayoutConfig(RPC_LAYOUT.REQUEST_DETAILS_ONLY) - maxPriorityFeePerGas(requestDetails: RequestDetails): JsonRpcError { + public maxPriorityFeePerGas(requestDetails: RequestDetails): JsonRpcError { if (this.logger.isLevelEnabled('trace')) { this.logger.trace(`${requestDetails.formattedRequestId} maxPriorityFeePerGas()`); }