Skip to content

Commit

Permalink
Bump 0.15.0-rc1 (#798)
Browse files Browse the repository at this point in the history
* Bump 0.15.0-rc1

Signed-off-by: lukelee-sl <[email protected]>

* 651 add eth methods validations (#663)

* Sort errors alphabetically

Signed-off-by: Maksim Dimitrov <[email protected]>

* Add required params validations

Signed-off-by: Maksim Dimitrov <[email protected]>

* Add required params tests

Signed-off-by: Maksim Dimitrov <[email protected]>

* Remove unsused package

Signed-off-by: Maksim Dimitrov <[email protected]>

* Fix condition

Signed-off-by: Maksim Dimitrov <[email protected]>

* Validate param types

Signed-off-by: Maksim Dimitrov <[email protected]>

* Move validation logic to separate class

Signed-off-by: Maksim Dimitrov <[email protected]>

* Add more validation logic

Signed-off-by: Maksim Dimitrov <[email protected]>

* Update validations and add server tests

Signed-off-by: Maksim Dimitrov <[email protected]>

* Fix codesmell

Signed-off-by: Maksim Dimitrov <[email protected]>

* Rename folder

Signed-off-by: Maksim Dimitrov <[email protected]>

* Fix array type validation and postman tests

Signed-off-by: Maksim Dimitrov <[email protected]>

* Some fixes and add tests

Signed-off-by: Maksim Dimitrov <[email protected]>

* Update test command

Signed-off-by: Maksim Dimitrov <[email protected]>

* Limit block number regex

Signed-off-by: Maksim Dimitrov <[email protected]>

* Update gitignore

Signed-off-by: Maksim Dimitrov <[email protected]>

* Test if coverage will trigger

Signed-off-by: Maksim Dimitrov <[email protected]>

* Add more tests

Signed-off-by: Maksim Dimitrov <[email protected]>

* Add tests and fixes

Signed-off-by: Maksim Dimitrov <[email protected]>

* Try to fix code smells

Signed-off-by: Maksim Dimitrov <[email protected]>

* Fix code smell

Signed-off-by: Maksim Dimitrov <[email protected]>

* Try fix complexity

Signed-off-by: Maksim Dimitrov <[email protected]>

* Add all remaining tests

Signed-off-by: Maksim Dimitrov <[email protected]>

* Remove obsolete logic. Update tests

Signed-off-by: Maksim Dimitrov <[email protected]>

* Refactor. Update tests

Signed-off-by: Maksim Dimitrov <[email protected]>

* Fix getLogs order to asc. Fix tests. Fix acceptance api tests

Signed-off-by: Maksim Dimitrov <[email protected]>

* Remove merge connflict marker

Signed-off-by: Maksim Dimitrov <[email protected]>

* Use evm address instead of contract id in getStorageAt test. Skip test until mirror node PR is merged and released

Signed-off-by: Maksim Dimitrov <[email protected]>

* Make the to param not required

Signed-off-by: Maksim Dimitrov <[email protected]>

* Return error for unexpected named parameters

Signed-off-by: Maksim Dimitrov <[email protected]>

* Remove imorts added by the IDE

Signed-off-by: Maksim Dimitrov <[email protected]>

* Add missing params

Signed-off-by: Maksim Dimitrov <[email protected]>

* Allow topic to be null

Signed-off-by: Maksim Dimitrov <[email protected]>

* Add more tests and remove throwing an error

Signed-off-by: Maksim Dimitrov <[email protected]>

* Fix conflicts, missing validations, tests

Signed-off-by: Maksim Dimitrov <[email protected]>

* Use single quote

Signed-off-by: Maksim Dimitrov <[email protected]>

* Remove import added by the IDE

Signed-off-by: Maksim Dimitrov <[email protected]>

* Rollback getStorageAt changes

Signed-off-by: Maksim Dimitrov <[email protected]>

* Remove getStorageAt test

Signed-off-by: Maksim Dimitrov <[email protected]>

* Make block param optional for eth_getStorageAt

Signed-off-by: Maksim Dimitrov <[email protected]>

* Refactor. Move validation in logAndHandleResponse

Signed-off-by: Maksim Dimitrov <[email protected]>

* Try to reduce complexity

Signed-off-by: Maksim Dimitrov <[email protected]>

* Refactor

Signed-off-by: Maksim Dimitrov <[email protected]>

* Fix slot param in test

Signed-off-by: Maksim Dimitrov <[email protected]>

* Fix slot param in another test

Signed-off-by: Maksim Dimitrov <[email protected]>

* Update tests

Signed-off-by: Maksim Dimitrov <[email protected]>

* Remove only() from test

Signed-off-by: Maksim Dimitrov <[email protected]>

Signed-off-by: Maksim Dimitrov <[email protected]>

Signed-off-by: lukelee-sl <[email protected]>
Signed-off-by: Maksim Dimitrov <[email protected]>
Co-authored-by: Maksim Dimitrov <[email protected]>
  • Loading branch information
lukelee-sl and dimitrovmaksim authored Jan 5, 2023
1 parent ca850cd commit d10b0b2
Show file tree
Hide file tree
Showing 29 changed files with 2,623 additions and 332 deletions.
6 changes: 2 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,5 @@ tsconfig.tsbuildinfo
.idea
.vscode/
.devcontainer/
packages/relay/coverage/**
packages/server/coverage/**
packages/relay/.nyc_output/**
packages/server/.nyc_output/**
**/**/coverage/
**/**/.nyc_output/
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@

Implementation of an Ethereum JSON RPC APIs for Hedera Hashgraph. Utilises both Hedera Consensus Nodes and Mirror nodes
to support RPC queries as defined in
the [JSON RPC Specification](https://playground.open-rpc.org/?schemaUrl=https://raw.githubusercontent.com/hashgraph/hedera-json-rpc-relay/main/docs/openrpc.json&uiSchema%5BappBar%5D%5Bui:splitView%5D=false&uiSchema%5BappBar%5D%5Bui:input%5D=false&uiSchema%5BappBar%5D%5Bui:examplesDropdown%5D=false)

the [JSON RPC Specification](https://playground.open-rpc.org/?schemaUrl=https://raw.githubusercontent.com/hashgraph/hedera-json-rpc-relay/release/0.15/docs/openrpc.json&uiSchema%5BappBar%5D%5Bui:splitView%5D=false&uiSchema%5BappBar%5D%5Bui:input%5D=false&uiSchema%5BappBar%5D%5Bui:examplesDropdown%5D=false)
## Building

### Pre-requirements
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: "3.7"
services:
relay:
container_name: hedera-jspn-rpc-relay
image: "ghcr.io/hashgraph/hedera-json-rpc-relay:main"
image: "ghcr.io/hashgraph/hedera-json-rpc-relay:0.15.0-rc1"
restart: "unless-stopped"
ports:
- 7546:7546
Expand Down
2 changes: 1 addition & 1 deletion docs/openrpc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"info": {
"title": "Hedera JSON-RPC Specification",
"description": "A specification of the implemented Ethereum JSON RPC APIs interface for Hedera clients and adheres to the Ethereum execution APIs schema.",
"version": "0.15.0-SNAPSHOT"
"version": "0.15.0-rc1"
},
"methods": [
{
Expand Down
4 changes: 2 additions & 2 deletions helm-chart/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ apiVersion: v2
name: hedera-json-rpc-relay
description: Helm chart deployment of the hashgraph/hedera-json-rpc-relay
type: application
version: 0.15.0-SNAPSHOT
appVersion: "0.15.0-SNAPSHOT"
version: 0.15.0-rc1
appVersion: "0.15.0-rc1"
home: https://github.com/hashgraph/hedera-json-rpc-relay
48 changes: 16 additions & 32 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/relay/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hashgraph/json-rpc-relay",
"version": "0.15.0-SNAPSHOT",
"version": "0.15.0-rc1",
"description": "Hedera Hashgraph implementation of Ethereum JSON RPC APIs. Utilises both the Hedera Consensus Nodes and the Mirror Nodes for transaction management and information retrieval",
"types": "dist/index.d.ts",
"main": "dist/index.js",
Expand Down
163 changes: 89 additions & 74 deletions packages/relay/src/lib/errors/JsonRpcError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,115 +35,130 @@ export class JsonRpcError {
}

export const predefined = {
'NO_MINING_WORK': new JsonRpcError({
name: 'No mining work',
'CONTRACT_REVERT': (errorMessage?: string) => new JsonRpcError({
name: 'Contract revert executed',
code: -32008,
message: `execution reverted: ${decodeErrorMessage(errorMessage)}`,
data: errorMessage
}),
'GAS_LIMIT_TOO_HIGH': new JsonRpcError({
name: 'gasLimit too high',
code: -32005,
message: 'Transaction gas limit exceeds block gas limit'
}),
'GAS_LIMIT_TOO_LOW': new JsonRpcError({
name: 'gasLimit too low',
code: -32003,
message: 'Intrinsic gas exceeds gas limit'
}),
'GAS_PRICE_TOO_LOW': new JsonRpcError({
name: 'Gas price too low',
code: -32009,
message: 'Gas price below configured minimum gas price'
}),
'HBAR_RATE_LIMIT_EXCEEDED': new JsonRpcError({
name: 'HBAR Rate limit exceeded',
code: -32606,
message: 'HBAR Rate limit exceeded'
}),
'INCORRECT_NONCE': new JsonRpcError({
name: 'Incorrect nonce',
code: -32006,
message: 'Incorrect nonce'
}),
'INSUFFICIENT_ACCOUNT_BALANCE': new JsonRpcError({
name: 'Insufficient account balance',
code: -32000,
message: 'No mining work available yet'
message: 'Insufficient funds for transfer'
}),
'INVALID_REQUEST': new JsonRpcError({
name: 'Invalid request',
code: -32600,
message: 'Invalid request'
'INTERNAL_ERROR': (message = '') => new JsonRpcError({
name: 'Internal error',
code: -32603,
message: message === '' ? 'Unknown error invoking RPC' : `Error invoking RPC: ${message}`
}),
'UNSUPPORTED_METHOD': new JsonRpcError({
name: 'Method not found',
code: -32601,
message: 'Unsupported JSON-RPC method'
'INVALID_PARAMETER': (index: number | string, message: string) => new JsonRpcError({
name: 'Invalid parameter',
code: -32602,
message: `Invalid parameter ${index}: ${message}`
}),
'INVALID_PARAMETERS': new JsonRpcError({
name: 'Invalid parameters',
code: -32602,
message: 'Invalid params'
}),
'INTERNAL_ERROR': (message: string = '') => new JsonRpcError({
name: 'Internal error',
code: -32603,
message: message === '' ? `Error invoking RPC: ${message}` : 'Unknown error invoking RPC'
'INVALID_REQUEST': new JsonRpcError({
name: 'Invalid request',
code: -32600,
message: 'Invalid request'
}),
'PARSE_ERROR': new JsonRpcError({
name: 'Parse error',
code: -32700,
message: 'Unable to parse JSON'
'IP_RATE_LIMIT_EXCEEDED': (methodName: string) => new JsonRpcError({
name: 'IP Rate limit exceeded',
code: -32605,
message: `IP Rate limit exceeded on ${methodName}`
}),
'MISSING_FROM_BLOCK_PARAM': new JsonRpcError({
name: 'Missing fromBlock parameter',
code: -32011,
message: 'Provided toBlock parameter without specifying fromBlock'
}),
'MISSING_REQUIRED_PARAMETER': (index: number | string) => new JsonRpcError({
name: 'Missing required parameters',
code: -32602,
message: `Missing value for required parameter ${index}`
}),
'NONCE_TOO_LOW': new JsonRpcError({
name: 'Nonce too low',
code: 32001,
message: 'Nonce too low'
}),
'INCORRECT_NONCE': new JsonRpcError({
name: 'Incorrect nonce',
code: -32006,
message: 'Incorrect nonce'
'NO_MINING_WORK': new JsonRpcError({
name: 'No mining work',
code: -32000,
message: 'No mining work available yet'
}),
'GAS_LIMIT_TOO_HIGH': new JsonRpcError({
name: 'gasLimit too high',
code: -32005,
message: 'Transaction gas limit exceeds block gas limit'
'PARSE_ERROR': new JsonRpcError({
name: 'Parse error',
code: -32700,
message: 'Unable to parse JSON'
}),
'GAS_LIMIT_TOO_LOW': new JsonRpcError({
name: 'gasLimit too low',
code: -32003,
message: 'Intrinsic gas exceeds gas limit'
'RANGE_TOO_LARGE': (blockRange: number) => new JsonRpcError({
name: 'Block range too large',
code: -32000,
message: `Exceeded maximum block range: ${blockRange}`
}),
'REQUEST_BEYOND_HEAD_BLOCK': (requested: number, latest: number) => new JsonRpcError({
name: 'Incorrect block',
code: -32000,
message: `Request beyond head block: requested ${requested}, head ${latest}`
}),
'UNSUPPORTED_CHAIN_ID': (requested: string | number, current: string | number) => new JsonRpcError({
name: 'ChainId not supported',
code: -32000,
message: `ChainId (${requested}) not supported. The correct chainId is ${current}`
}),
'GAS_PRICE_TOO_LOW': new JsonRpcError({
name: 'Gas price too low',
code: -32009,
message: 'Gas price below configured minimum gas price'
}),
'INSUFFICIENT_ACCOUNT_BALANCE': new JsonRpcError({
name: 'Insufficient account balance',
code: -32000,
message: 'Insufficient funds for transfer'
}),
'VALUE_TOO_LOW': new JsonRpcError({
name: 'Value too low',
code: -32602,
message: 'Value below 10_000_000_000 wei which is 1 tinybar'
}),
'REQUEST_TIMEOUT': new JsonRpcError({
name: 'Request timeout',
code: -32010,
message: 'Request timeout. Please try again.'
}),
'RESOURCE_NOT_FOUND': (message: string = '') => new JsonRpcError({
'RESOURCE_NOT_FOUND': (message = '') => new JsonRpcError({
name: 'Resource not found',
code: -32001,
message: `Requested resource not found. ${message}`
}),
'RANGE_TOO_LARGE': (blockRange: number) => new JsonRpcError({
name: 'Block range too large',
code: -32000,
message: `Exceeded maximum block range: ${blockRange}`
}),
'IP_RATE_LIMIT_EXCEEDED': (methodName: string) => new JsonRpcError({
name: 'IP Rate limit exceeded',
code: -32605,
message: `IP Rate limit exceeded on ${methodName}`
'UNKNOWN_HISTORICAL_BALANCE': new JsonRpcError({
name: 'Unavailable balance',
code: -32007,
message: 'Historical balance data is available only after 15 minutes.'
}),
'HBAR_RATE_LIMIT_EXCEEDED': new JsonRpcError({
name: 'HBAR Rate limit exceeded',
code: -32606,
message: 'HBAR Rate limit exceeded'
'UNSUPPORTED_CHAIN_ID': (requested: string | number, current: string | number) => new JsonRpcError({
name: 'ChainId not supported',
code: -32000,
message: `ChainId (${requested}) not supported. The correct chainId is ${current}`
}),
'CONTRACT_REVERT': (errorMessage?: string) => new JsonRpcError({
name: 'Contract revert executed',
code: -32008,
message: `execution reverted: ${decodeErrorMessage(errorMessage)}`,
data: errorMessage
'UNSUPPORTED_METHOD': new JsonRpcError({
name: 'Method not found',
code: -32601,
message: 'Unsupported JSON-RPC method'
}),
'MISSING_FROM_BLOCK_PARAM': new JsonRpcError({
name: 'Missing fromBlock parameter',
code: -32011,
message: 'Provided toBlock parameter without specifying fromBlock'
'VALUE_TOO_LOW': new JsonRpcError({
name: 'Value too low',
code: -32602,
message: 'Value below 10_000_000_000 wei which is 1 tinybar'
})
};
2 changes: 1 addition & 1 deletion packages/relay/tests/lib/eth.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2632,7 +2632,7 @@ describe('Eth', async function () {
it('should execute "eth_chainId"', async function () {
const chainId = await Relay.eth().chainId();

expect(chainId).to.be.equal(`0x${process.env.CHAIN_ID}`);
expect(chainId).to.be.equal('0x' + Number(process.env.CHAIN_ID).toString(16));
});

it('should execute "eth_accounts"', async function () {
Expand Down
2 changes: 1 addition & 1 deletion packages/relay/tests/lib/openrpc.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ describe("Open RPC Specification", function () {
mock.onGet(`contracts/${log.address}`).reply(200, defaultContract);
}
sdkClientStub.getAccountBalanceInWeiBar.returns(1000);
sdkClientStub.getAccountBalanceInTinyBar.returns(100000000000)
sdkClientStub.getAccountBalanceInTinyBar.returns(100000000000);
sdkClientStub.getContractByteCode.returns(Buffer.from(bytecode.replace('0x', ''), 'hex'));
sdkClientStub.getAccountInfo.returns({ ethereumNonce: '0x1' });
sdkClientStub.submitEthereumTransaction.returns({});
Expand Down
Loading

0 comments on commit d10b0b2

Please sign in to comment.