From 1d74978d845cbebe5aaca8539b3e93f6a4714ca8 Mon Sep 17 00:00:00 2001 From: clayton neal Date: Tue, 11 Feb 2025 13:21:48 +0000 Subject: [PATCH 01/10] chore: blk-01 --- packages/core/src/vcdm/Revision.ts | 85 ++++++++++--------- .../core/tests/vcdm/Revision.unit.test.ts | 5 +- .../src/provider/utils/const/blocks/blocks.ts | 82 +++++++++--------- .../src/provider/utils/rpc-mapper/index.ts | 1 - .../rpc-mapper/methods/eth_call/eth_call.ts | 7 +- .../eth_estimateGas/eth_estimateGas.ts | 13 ++- .../methods/eth_getBalance/eth_getBalance.ts | 9 +- .../eth_getBlockByHash/eth_getBlockByHash.ts | 24 +++++- .../eth_getBlockByNumber.ts | 13 ++- .../methods/eth_getCode/eth_getCode.ts | 9 +- .../eth_getStorageAt/eth_getStorageAt.ts | 9 +- .../provider/utils/rpc-mapper/rpc-mapper.ts | 5 +- .../src/provider/utils/rpc-mapper/types.d.ts | 19 ----- .../eth_call/eth_call.mock.solo.test.ts | 34 +++++++- packages/rpc-proxy/README.md | 16 ++++ .../tests/e2e_rpc_proxy.solo.test.ts | 4 +- 16 files changed, 194 insertions(+), 141 deletions(-) delete mode 100644 packages/network/src/provider/utils/rpc-mapper/types.d.ts diff --git a/packages/core/src/vcdm/Revision.ts b/packages/core/src/vcdm/Revision.ts index 1ff005da6..92f83903a 100644 --- a/packages/core/src/vcdm/Revision.ts +++ b/packages/core/src/vcdm/Revision.ts @@ -1,46 +1,44 @@ import { InvalidDataType } from '@vechain/sdk-errors'; import { Hex } from './Hex'; -import { HexUInt } from './HexUInt'; import { Txt } from './Txt'; /** - * Represents a revision for a Thor transaction or block. - * - * @remarks The string representation of the revision is always expressed as a number in base 10. + * Represents a revision for a Thor transaction or block + * Revision strings can be one of the following: + * - "best": indicating the best revision + * - "finalized": indicating a finalized revision + * - "next": indicating the next revision + * - "justified": indicating the justified revision + * - A hex string prefixed with "0x" indicating a specific block id + * - A positive number indicating a specific block number * * @extends Txt */ class Revision extends Txt { /** * Regular expression pattern for revision strings. - * Revision strings can be one of the following: - * - "best": indicating the best revision - * - "finalized": indicating a finalized revision - * - A positive numeric string indicating a specific revision * * @type {RegExp} */ - private static readonly REGEX_DECIMAL_REVISION = /^(best|finalized|\d+)$/; + private static readonly VALID_REVISION_REGEX = + /^(best|finalized|next|justified|0x[a-fA-F0-9]+|\d+)$/; /** - * Determines if the given value is valid. - * This is true if the given value is - * - "best" string or {@link Txt}: indicating the best revision; - * - "finalized" string or {@link Txt}: indicating a finalized revision; - * - a positive number; - * - a positive numeric decimal or `0x` prefixed hexadecimal string indicating a specific revision, - * - * @param {bigint | number | string | Hex | Txt} value - The value to be validated. + * Determines if the given value is a valid revision. + * @param {bigint| number | string | Hex} value - The value to be validated. * @returns {boolean} - Returns `true` if the value is valid, `false` otherwise. */ - public static isValid(value: number | string): boolean { + public static isValid(value: bigint | number | string | Hex): boolean { if (typeof value === 'number') { return Number.isInteger(value) && value >= 0; } - return ( - HexUInt.isValid0x(value) || - Revision.REGEX_DECIMAL_REVISION.test(value) - ); + if (typeof value === 'bigint') { + return value >= BigInt(0); + } + if (value instanceof Hex) { + return Revision.isValid(value.bi); + } + return Revision.VALID_REVISION_REGEX.test(value); } /** @@ -59,24 +57,25 @@ class Revision extends Txt { */ public static of(value: bigint | number | string | Uint8Array | Hex): Txt { try { - let txt: string; - if (value instanceof Hex) { - txt = value.bi.toString(); - } else if ( - typeof value === 'bigint' || - typeof value === 'number' || - typeof value === 'string' - ) { - txt = `${value}`; - } else { - txt = Txt.of(value).toString(); + // handle Uint8Array which is needed to extend Txt.of + if (ArrayBuffer.isView(value)) { + const txtValue = Txt.of(value).toString(); + if (Revision.isValid(txtValue)) { + return new Revision(txtValue); + } else { + throw new InvalidDataType('Revision.of', 'not a revision', { + value: `${value}` + }); + } } - if (Revision.isValid(txt)) { - return new Revision(txt); + // handle other types + if (Revision.isValid(value)) { + return new Revision(`${value}`); + } else { + throw new InvalidDataType('Revision.of', 'not a revision', { + value: `${value}` + }); } - throw new InvalidDataType('Revision.of', 'not a revision', { - value: `${value}` - }); } catch (e) { throw new InvalidDataType('Revision.of', 'not a revision', { value: `${value}`, @@ -94,6 +93,16 @@ class Revision extends Txt { * Return the `finalized` revision instance. */ public static readonly FINALIZED: Revision = Revision.of('finalized'); + + /** + * Return the `next` revision instance. + */ + public static readonly NEXT: Revision = Revision.of('next'); + + /** + * Return the `justified` revision instance. + */ + public static readonly JUSTIFIED: Revision = Revision.of('justified'); } export { Revision }; diff --git a/packages/core/tests/vcdm/Revision.unit.test.ts b/packages/core/tests/vcdm/Revision.unit.test.ts index 6fcc610dc..d97f5bfe0 100644 --- a/packages/core/tests/vcdm/Revision.unit.test.ts +++ b/packages/core/tests/vcdm/Revision.unit.test.ts @@ -31,7 +31,7 @@ describe('Revision class tests', () => { expect(Revision.isValid('123.57')).toBeFalsy(); }); - test('Return false for not numeric nor `best` nor `finalized` value', () => { + test('Return false for not numeric not a block tag', () => { expect(Revision.isValid('ABadBabe')).toBeFalsy(); }); @@ -54,6 +54,9 @@ describe('Revision class tests', () => { test('Return true for `finalized` value', () => { expect(Revision.isValid('finalized')).toBeTruthy(); }); + test('Return true for `next` value', () => { + expect(Revision.isValid('next')).toBeTruthy(); + }); }); }); diff --git a/packages/network/src/provider/utils/const/blocks/blocks.ts b/packages/network/src/provider/utils/const/blocks/blocks.ts index 465a05bcc..03aa55b92 100644 --- a/packages/network/src/provider/utils/const/blocks/blocks.ts +++ b/packages/network/src/provider/utils/const/blocks/blocks.ts @@ -1,46 +1,52 @@ -import { Hex } from '@vechain/sdk-core'; -import { type BlockQuantityInputRPC } from '../../rpc-mapper/types'; +import { HexUInt, Revision } from '@vechain/sdk-core'; + +type DefaultBlock = + | `0x${string}` + | 'latest' + | 'earliest' + | 'pending' + | 'safe' + | 'finalized'; +const defaultBlockTags: DefaultBlock[] = [ + 'latest', + 'earliest', + 'pending', + 'safe', + 'finalized' +]; /** - * Get the correct block number for the given block number. - * - * @param block - The block tag to get. - * 'latest' or 'earliest' or 'pending' or 'safe' or 'finalized' - * or an object: { blockNumber: number } or { blockHash: string } + * Maps the Ethereum "default block" type to VeChainThor Revision type. + * Ethereum "default block" can be: + * - 'latest' or 'earliest' or 'pending' or 'safe' or 'finalized' + * - a hexadecimal block number + * VeChainThor revision type can be: + * - 'best', 'next', 'justified', 'finalized' + * - a hexadecimal block Id + * - a integer block number * - * @note - * * Currently VeChainThor supports 'earliest', 'latest' and 'finalized' as block tags. - * So 'pending' and 'safe' are converted to 'best' which is the alias for 'latest' and 'finalized' in VeChainThor. + * @param defaultBlock - The Ethereum default block type to convert + * @returns The VeChainThor revision type */ -const getCorrectBlockNumberRPCToVeChain = ( - block: BlockQuantityInputRPC -): string => { - // Tag block number - if (typeof block === 'string') { - // Latest, Finalized, Safe blocks - if ( - block === 'latest' || - block === 'finalized' || - block === 'safe' || - block === 'pending' - ) - // 'best' is the alias for 'latest', 'finalized' and 'safe' in VeChainThor - return 'best'; - - // Earliest block - if (block === 'earliest') return Hex.of(0).toString(); - - // Hex number of block - return block; +const DefaultBlockToRevision = (defaultBlock: DefaultBlock): Revision => { + // if valid hex then return integer block number + if (HexUInt.isValid(defaultBlock)) { + return Revision.of(HexUInt.of(defaultBlock).n.toString()); } - - // Object with block number - if (block.blockNumber !== undefined) { - return Hex.of(block.blockNumber).toString(); + // check if default block is a valid block tag + if (!defaultBlockTags.includes(defaultBlock)) { + throw new Error(`Invalid block tag: ${defaultBlock}`); + } + // map block tag to VeChainThor revision + if (defaultBlock === 'earliest') { + return Revision.of(HexUInt.of(0)); + } else if (defaultBlock === 'safe') { + return Revision.of('justified'); + } else if (defaultBlock === 'finalized') { + return Revision.of('finalized'); + } else { + return Revision.of('best'); } - - // Object with block hash - Default case - return block.blockHash; }; -export { getCorrectBlockNumberRPCToVeChain }; +export { type DefaultBlock, DefaultBlockToRevision }; diff --git a/packages/network/src/provider/utils/rpc-mapper/index.ts b/packages/network/src/provider/utils/rpc-mapper/index.ts index 6a3dce332..91e25752f 100644 --- a/packages/network/src/provider/utils/rpc-mapper/index.ts +++ b/packages/network/src/provider/utils/rpc-mapper/index.ts @@ -1,3 +1,2 @@ export * from './methods'; export * from './rpc-mapper'; -export type * from './types.d'; diff --git a/packages/network/src/provider/utils/rpc-mapper/methods/eth_call/eth_call.ts b/packages/network/src/provider/utils/rpc-mapper/methods/eth_call/eth_call.ts index f7e6cbf80..038004691 100644 --- a/packages/network/src/provider/utils/rpc-mapper/methods/eth_call/eth_call.ts +++ b/packages/network/src/provider/utils/rpc-mapper/methods/eth_call/eth_call.ts @@ -3,9 +3,8 @@ import { JSONRPCInvalidParams, stringifyData } from '@vechain/sdk-errors'; -import { getCorrectBlockNumberRPCToVeChain } from '../../../const'; +import { type DefaultBlock, DefaultBlockToRevision } from '../../../const'; import { type TransactionObjectInput } from './types'; -import { type BlockQuantityInputRPC } from '../../types'; import { type SimulateTransactionClause, type SimulateTransactionOptions, @@ -41,7 +40,7 @@ const ethCall = async ( try { const [inputOptions, block] = params as [ TransactionObjectInput, - BlockQuantityInputRPC + DefaultBlock ]; // Simulate transaction @@ -54,7 +53,7 @@ const ethCall = async ( } satisfies SimulateTransactionClause ], { - revision: getCorrectBlockNumberRPCToVeChain(block), + revision: DefaultBlockToRevision(block).toString(), gas: inputOptions.gas !== undefined ? parseInt(inputOptions.gas, 16) diff --git a/packages/network/src/provider/utils/rpc-mapper/methods/eth_estimateGas/eth_estimateGas.ts b/packages/network/src/provider/utils/rpc-mapper/methods/eth_estimateGas/eth_estimateGas.ts index 9fd101caf..bbc2102c1 100644 --- a/packages/network/src/provider/utils/rpc-mapper/methods/eth_estimateGas/eth_estimateGas.ts +++ b/packages/network/src/provider/utils/rpc-mapper/methods/eth_estimateGas/eth_estimateGas.ts @@ -8,8 +8,7 @@ import { type SimulateTransactionClause, type ThorClient } from '../../../../../thor-client'; -import { getCorrectBlockNumberRPCToVeChain } from '../../../const'; -import { type BlockQuantityInputRPC } from '../../types'; +import { type DefaultBlock, DefaultBlockToRevision } from '../../../const'; import { RPC_DOCUMENTATION_URL } from '../../../../../utils'; /** @@ -42,10 +41,11 @@ const ethEstimateGas = async ( // NOTE: The standard requires block parameter. // Here it is ignored and can be added in the future compatibility reasons. // (INPUT CHECK TAKE CARE OF THIS) - const [inputOptions, revision] = params as [ + const [inputOptions, defaultBlock] = params as [ TransactionObjectInput, - BlockQuantityInputRPC? + DefaultBlock ]; + const revision = DefaultBlockToRevision(defaultBlock); const estimatedGas = await thorClient.gas.estimateGas( [ @@ -57,10 +57,7 @@ const ethEstimateGas = async ( ], inputOptions.from, { - revision: - revision !== undefined - ? getCorrectBlockNumberRPCToVeChain(revision) - : undefined + revision: revision.toString() } ); diff --git a/packages/network/src/provider/utils/rpc-mapper/methods/eth_getBalance/eth_getBalance.ts b/packages/network/src/provider/utils/rpc-mapper/methods/eth_getBalance/eth_getBalance.ts index b8a0b5684..5cfda79bb 100644 --- a/packages/network/src/provider/utils/rpc-mapper/methods/eth_getBalance/eth_getBalance.ts +++ b/packages/network/src/provider/utils/rpc-mapper/methods/eth_getBalance/eth_getBalance.ts @@ -4,10 +4,9 @@ import { JSONRPCInvalidParams, stringifyData } from '@vechain/sdk-errors'; -import type { BlockQuantityInputRPC } from '../../types'; -import { getCorrectBlockNumberRPCToVeChain } from '../../../const'; +import { type DefaultBlock, DefaultBlockToRevision } from '../../../const'; import { RPC_DOCUMENTATION_URL } from '../../../../../utils'; -import { Address, Revision } from '@vechain/sdk-core'; +import { Address } from '@vechain/sdk-core'; /** * RPC Method eth_getBalance implementation @@ -40,13 +39,13 @@ const ethGetBalance = async ( ); try { - const [address, block] = params as [string, BlockQuantityInputRPC]; + const [address, block] = params as [string, DefaultBlock]; // Get the account details const accountDetails = await thorClient.accounts.getAccount( Address.of(address), { - revision: Revision.of(getCorrectBlockNumberRPCToVeChain(block)) + revision: DefaultBlockToRevision(block) } ); diff --git a/packages/network/src/provider/utils/rpc-mapper/methods/eth_getBlockByHash/eth_getBlockByHash.ts b/packages/network/src/provider/utils/rpc-mapper/methods/eth_getBlockByHash/eth_getBlockByHash.ts index 972aed4b1..19d786d98 100644 --- a/packages/network/src/provider/utils/rpc-mapper/methods/eth_getBlockByHash/eth_getBlockByHash.ts +++ b/packages/network/src/provider/utils/rpc-mapper/methods/eth_getBlockByHash/eth_getBlockByHash.ts @@ -1,13 +1,14 @@ import { ThorId } from '@vechain/sdk-core'; import { RPC_DOCUMENTATION_URL } from '../../../../../utils'; -import { ethGetBlockByNumber } from '../eth_getBlockByNumber'; import { JSONRPCInternalError, JSONRPCInvalidParams, stringifyData } from '@vechain/sdk-errors'; -import { type BlocksRPC } from '../../../formatter'; +import { blocksFormatter, type BlocksRPC } from '../../../formatter'; import { type ThorClient } from '../../../../../thor-client'; +import { type DefaultBlock, DefaultBlockToRevision } from '../../../const'; +import { ethChainId } from '../eth_chainId'; /** * RPC Method eth_getBlockByHash implementation @@ -19,6 +20,7 @@ import { type ThorClient } from '../../../../../thor-client'; * * params[0]: The block hash of block to get. * * params[1]: The transaction hydrated detail flag. If true, the block will contain the transaction details, otherwise it will only contain the transaction hashes. * @returns the block at the given block hash formatted to the RPC standard or null if the block does not exist. + * @note Ethereum block hash is passed to Thor as the block id. * @throws {JSONRPCInvalidParams, JSONRPCInternalError} */ const ethGetBlockByHash = async ( @@ -39,8 +41,22 @@ const ethGetBlockByHash = async ( ); try { - // Return the block by number (in this case, the block hash is the block number) - return await ethGetBlockByNumber(thorClient, params); + const [blockHash, isTxDetail] = params as [string, boolean]; + + let chainId: string = '0x0'; + + // If the transaction detail flag is set, we need to get the chain id + if (isTxDetail) { + chainId = await ethChainId(thorClient); + } + + const block = isTxDetail + ? await thorClient.blocks.getBlockExpanded(blockHash) + : await thorClient.blocks.getBlockCompressed(blockHash); + + return block !== null + ? blocksFormatter.formatToRPCStandard(block, chainId) + : null; } catch (e) { throw new JSONRPCInternalError( 'eth_getBlockByHash()', diff --git a/packages/network/src/provider/utils/rpc-mapper/methods/eth_getBlockByNumber/eth_getBlockByNumber.ts b/packages/network/src/provider/utils/rpc-mapper/methods/eth_getBlockByNumber/eth_getBlockByNumber.ts index 01c03b9a2..04c831cc1 100644 --- a/packages/network/src/provider/utils/rpc-mapper/methods/eth_getBlockByNumber/eth_getBlockByNumber.ts +++ b/packages/network/src/provider/utils/rpc-mapper/methods/eth_getBlockByNumber/eth_getBlockByNumber.ts @@ -5,7 +5,7 @@ import { } from '@vechain/sdk-errors'; import { type ThorClient } from '../../../../../thor-client'; import { RPC_DOCUMENTATION_URL } from '../../../../../utils'; -import { getCorrectBlockNumberRPCToVeChain } from '../../../const'; +import { type DefaultBlock, DefaultBlockToRevision } from '../../../const'; import { blocksFormatter, type BlocksRPC } from '../../../formatter'; import { ethChainId } from '../eth_chainId'; @@ -42,7 +42,8 @@ const ethGetBlockByNumber = async ( ); try { - const [blockNumber, isTxDetail] = params as [string, boolean]; + const [blockNumber, isTxDetail] = params as [DefaultBlock, boolean]; + const revision = DefaultBlockToRevision(blockNumber); let chainId: string = '0x0'; @@ -52,12 +53,8 @@ const ethGetBlockByNumber = async ( } const block = isTxDetail - ? await thorClient.blocks.getBlockExpanded( - getCorrectBlockNumberRPCToVeChain(blockNumber) - ) - : await thorClient.blocks.getBlockCompressed( - getCorrectBlockNumberRPCToVeChain(blockNumber) - ); + ? await thorClient.blocks.getBlockExpanded(revision.toString()) + : await thorClient.blocks.getBlockCompressed(revision.toString()); return block !== null ? blocksFormatter.formatToRPCStandard(block, chainId) diff --git a/packages/network/src/provider/utils/rpc-mapper/methods/eth_getCode/eth_getCode.ts b/packages/network/src/provider/utils/rpc-mapper/methods/eth_getCode/eth_getCode.ts index d1a55c0e7..d0d227bd2 100644 --- a/packages/network/src/provider/utils/rpc-mapper/methods/eth_getCode/eth_getCode.ts +++ b/packages/network/src/provider/utils/rpc-mapper/methods/eth_getCode/eth_getCode.ts @@ -4,10 +4,9 @@ import { JSONRPCInvalidParams, stringifyData } from '@vechain/sdk-errors'; -import type { BlockQuantityInputRPC } from '../../types'; -import { getCorrectBlockNumberRPCToVeChain } from '../../../const'; +import { type DefaultBlock, DefaultBlockToRevision } from '../../../const'; import { RPC_DOCUMENTATION_URL } from '../../../../../utils'; -import { Address, Revision } from '@vechain/sdk-core'; +import { Address } from '@vechain/sdk-core'; /** * RPC Method eth_getCode implementation @@ -40,13 +39,13 @@ const ethGetCode = async ( ); try { - const [address, block] = params as [string, BlockQuantityInputRPC]; + const [address, block] = params as [string, DefaultBlock]; // Get the account bytecode const bytecode = await thorClient.accounts.getBytecode( Address.of(address), { - revision: Revision.of(getCorrectBlockNumberRPCToVeChain(block)) + revision: DefaultBlockToRevision(block) } ); return bytecode.toString(); diff --git a/packages/network/src/provider/utils/rpc-mapper/methods/eth_getStorageAt/eth_getStorageAt.ts b/packages/network/src/provider/utils/rpc-mapper/methods/eth_getStorageAt/eth_getStorageAt.ts index 3ace9e08d..c515ea9b4 100644 --- a/packages/network/src/provider/utils/rpc-mapper/methods/eth_getStorageAt/eth_getStorageAt.ts +++ b/packages/network/src/provider/utils/rpc-mapper/methods/eth_getStorageAt/eth_getStorageAt.ts @@ -1,12 +1,11 @@ -import { Address, Revision, ThorId } from '@vechain/sdk-core'; +import { Address, ThorId } from '@vechain/sdk-core'; import { RPC_DOCUMENTATION_URL } from '../../../../../utils'; -import { getCorrectBlockNumberRPCToVeChain } from '../../../const'; +import { type DefaultBlock, DefaultBlockToRevision } from '../../../const'; import { JSONRPCInternalError, JSONRPCInvalidParams, stringifyData } from '@vechain/sdk-errors'; -import type { BlockQuantityInputRPC } from '../../types'; import { type ThorClient } from '../../../../../thor-client'; /** @@ -45,7 +44,7 @@ const ethGetStorageAt = async ( const [address, storagePosition, block] = params as [ string, string, - BlockQuantityInputRPC + DefaultBlock ]; // Get the account details @@ -53,7 +52,7 @@ const ethGetStorageAt = async ( Address.of(address), ThorId.of(storagePosition), { - revision: Revision.of(getCorrectBlockNumberRPCToVeChain(block)) + revision: DefaultBlockToRevision(block) } ); return storage.toString(); diff --git a/packages/network/src/provider/utils/rpc-mapper/rpc-mapper.ts b/packages/network/src/provider/utils/rpc-mapper/rpc-mapper.ts index 209c0e3b2..c991b9263 100644 --- a/packages/network/src/provider/utils/rpc-mapper/rpc-mapper.ts +++ b/packages/network/src/provider/utils/rpc-mapper/rpc-mapper.ts @@ -93,7 +93,10 @@ import { web3ClientVersion, web3Sha3 } from './methods'; -import { type MethodHandlerType } from './types'; + +type MethodHandlerType = ( + params: TParams[] +) => Promise; /** * Map of RPC methods to their implementations with the SDK. diff --git a/packages/network/src/provider/utils/rpc-mapper/types.d.ts b/packages/network/src/provider/utils/rpc-mapper/types.d.ts deleted file mode 100644 index aa31e1586..000000000 --- a/packages/network/src/provider/utils/rpc-mapper/types.d.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Type for the method handler. - * It is basically a function that takes an array of parameters and returns a promise. - */ -type MethodHandlerType = ( - params: TParams[] -) => Promise; - -/** - * Block type for RPC methods. - * - * It can be a block hash or a block number or a string ('0x...', 'latest', 'earliest', 'pending'). - */ -type BlockQuantityInputRPC = - | string - | { blockHash: string; blockNumber: never } - | { blockHash: never; blockNumber: number }; - -export { type MethodHandlerType, type BlockQuantityInputRPC }; diff --git a/packages/network/tests/provider/rpc-mapper/methods/eth_call/eth_call.mock.solo.test.ts b/packages/network/tests/provider/rpc-mapper/methods/eth_call/eth_call.mock.solo.test.ts index 359c6024a..ef60c104c 100644 --- a/packages/network/tests/provider/rpc-mapper/methods/eth_call/eth_call.mock.solo.test.ts +++ b/packages/network/tests/provider/rpc-mapper/methods/eth_call/eth_call.mock.solo.test.ts @@ -10,7 +10,7 @@ import { /** * RPC Mapper integration tests for 'eth_call' method with Solo Network and mocked functionality * - * @group integration/rpc-mapper/methods/eth_call + * @group unit/rpc-mapper/methods/eth_call */ describe('RPC Mapper - eth_call method tests', () => { /** @@ -52,5 +52,37 @@ describe('RPC Mapper - eth_call method tests', () => { ]) ).rejects.toThrowError(JSONRPCInternalError); }); + /** + * Test an invalid default block tag name + */ + test('Should throw `JSONRPCInvalidParams` if the default block parameter is invalid block tag', async () => { + await expect( + RPCMethodsMap(thorClient)[RPC_METHODS.eth_call]([ + { + from: '0x7487d912d03ab9de786278f679592b3730bdd540', + to: '0x3db469a79593dcc67f07DE1869d6682fC1eaf535', + value: '1000000000000000000', + data: '0x' + }, + 'invalid' + ]) + ).rejects.toThrowError(JSONRPCInternalError); + }); + /** + * Test an invalid hexadecimal block number + */ + test('Should throw `JSONRPCInvalidParams` if the default block parameter is invalid block tag', async () => { + await expect( + RPCMethodsMap(thorClient)[RPC_METHODS.eth_call]([ + { + from: '0x7487d912d03ab9de786278f679592b3730bdd540', + to: '0x3db469a79593dcc67f07DE1869d6682fC1eaf535', + value: '1000000000000000000', + data: '0x' + }, + '0xinvalid' + ]) + ).rejects.toThrowError(JSONRPCInternalError); + }); }); }); diff --git a/packages/rpc-proxy/README.md b/packages/rpc-proxy/README.md index f85785ef5..49f020220 100644 --- a/packages/rpc-proxy/README.md +++ b/packages/rpc-proxy/README.md @@ -260,3 +260,19 @@ Below is the support status for JSON RPC methods in VeChain via `sdk-rpc-proxy`. - **Fully Supported**: The method is implemented and works as expected. - **Partially Supported**: The method is implemented but may have limitations or deviations from the Ethereum standard. - **Not Supported**: The method is not implemented or cannot be supported due to protocol constraints. + +## RPC to VeChain Mappings + +The following mappings are performed by the RPC proxy + +| RPC Parameter | VeChain Parameter | +|----------------------------------------|-----------------------| +| block hash | block id | +| latest block | best block | +| safe block | best block | +| finalized block | finalized block | +| pending block | best block | +| earliest block | block number 0 | + + + diff --git a/packages/rpc-proxy/tests/e2e_rpc_proxy.solo.test.ts b/packages/rpc-proxy/tests/e2e_rpc_proxy.solo.test.ts index 4ec540ee4..92999a797 100644 --- a/packages/rpc-proxy/tests/e2e_rpc_proxy.solo.test.ts +++ b/packages/rpc-proxy/tests/e2e_rpc_proxy.solo.test.ts @@ -292,9 +292,7 @@ describe('RPC Proxy endpoints', () => { const response = await axios.post(RPC_PROXY_URL, { jsonrpc: '2.0', method: 'eth_getBlockReceipts', - params: [ - '0x0000000008602e7a995c747a3215b426c0c65709480b9e9ac57ad37c3f7d73de' - ], + params: ['0x0'], id: 1 }); From 0cd03a568e28e72a0208d3451e72c636162668a1 Mon Sep 17 00:00:00 2001 From: clayton neal Date: Tue, 11 Feb 2025 14:24:40 +0000 Subject: [PATCH 02/10] chore: fix --- .../rpc-mapper/methods/eth_getBlockByHash/eth_getBlockByHash.ts | 1 - packages/rpc-proxy/README.md | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/network/src/provider/utils/rpc-mapper/methods/eth_getBlockByHash/eth_getBlockByHash.ts b/packages/network/src/provider/utils/rpc-mapper/methods/eth_getBlockByHash/eth_getBlockByHash.ts index 19d786d98..97eadb1af 100644 --- a/packages/network/src/provider/utils/rpc-mapper/methods/eth_getBlockByHash/eth_getBlockByHash.ts +++ b/packages/network/src/provider/utils/rpc-mapper/methods/eth_getBlockByHash/eth_getBlockByHash.ts @@ -7,7 +7,6 @@ import { } from '@vechain/sdk-errors'; import { blocksFormatter, type BlocksRPC } from '../../../formatter'; import { type ThorClient } from '../../../../../thor-client'; -import { type DefaultBlock, DefaultBlockToRevision } from '../../../const'; import { ethChainId } from '../eth_chainId'; /** diff --git a/packages/rpc-proxy/README.md b/packages/rpc-proxy/README.md index 49f020220..9bacdcd7a 100644 --- a/packages/rpc-proxy/README.md +++ b/packages/rpc-proxy/README.md @@ -269,7 +269,7 @@ The following mappings are performed by the RPC proxy |----------------------------------------|-----------------------| | block hash | block id | | latest block | best block | -| safe block | best block | +| safe block | justified block | | finalized block | finalized block | | pending block | best block | | earliest block | block number 0 | From 83297869c4f23f05dfbb13762538c4e7e811fa3e Mon Sep 17 00:00:00 2001 From: clayton neal Date: Tue, 11 Feb 2025 17:25:15 +0000 Subject: [PATCH 03/10] chore: code-review --- .../rpc-mapper/methods/eth_call/eth_call.mock.solo.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/network/tests/provider/rpc-mapper/methods/eth_call/eth_call.mock.solo.test.ts b/packages/network/tests/provider/rpc-mapper/methods/eth_call/eth_call.mock.solo.test.ts index ef60c104c..5d1c1ccda 100644 --- a/packages/network/tests/provider/rpc-mapper/methods/eth_call/eth_call.mock.solo.test.ts +++ b/packages/network/tests/provider/rpc-mapper/methods/eth_call/eth_call.mock.solo.test.ts @@ -71,7 +71,7 @@ describe('RPC Mapper - eth_call method tests', () => { /** * Test an invalid hexadecimal block number */ - test('Should throw `JSONRPCInvalidParams` if the default block parameter is invalid block tag', async () => { + test('Should throw `JSONRPCInvalidParams` if the default block parameter is invalid block number hex', async () => { await expect( RPCMethodsMap(thorClient)[RPC_METHODS.eth_call]([ { From eee93361ba07a744392ca3d0174975361b543151 Mon Sep 17 00:00:00 2001 From: clayton neal Date: Tue, 11 Feb 2025 17:58:37 +0000 Subject: [PATCH 04/10] chore: fix tests --- .../eth_getTransactionByHash/eth_getTransactionByHash.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/network/src/provider/utils/rpc-mapper/methods/eth_getTransactionByHash/eth_getTransactionByHash.ts b/packages/network/src/provider/utils/rpc-mapper/methods/eth_getTransactionByHash/eth_getTransactionByHash.ts index 0ba29ec4a..c5e700ff9 100644 --- a/packages/network/src/provider/utils/rpc-mapper/methods/eth_getTransactionByHash/eth_getTransactionByHash.ts +++ b/packages/network/src/provider/utils/rpc-mapper/methods/eth_getTransactionByHash/eth_getTransactionByHash.ts @@ -8,7 +8,7 @@ import { RPC_DOCUMENTATION_URL } from '../../../../../utils'; import { type TransactionRPC, transactionsFormatter } from '../../../formatter'; import { getTransactionIndexIntoBlock } from '../../../helpers'; import { ethChainId } from '../eth_chainId'; -import { ethGetBlockByNumber } from '../eth_getBlockByNumber'; +import { ethGetBlockByHash } from '../eth_getBlockByHash'; /** * RPC Method eth_getTransactionByHash implementation @@ -42,7 +42,7 @@ const ethGetTransactionByHash = async ( if (tx === null) return null; // Get the block containing the transaction - const block = await ethGetBlockByNumber(thorClient, [ + const block = await ethGetBlockByHash(thorClient, [ tx.meta.blockID, false ]); From 8af62fd17c7d3fd3f30009f8ddf98643398f49b4 Mon Sep 17 00:00:00 2001 From: clayton neal Date: Wed, 12 Feb 2025 13:47:36 +0000 Subject: [PATCH 05/10] chore: fix tests --- .../src/available-errors/provider/provider.ts | 11 +++++- .../src/provider/utils/const/blocks/blocks.ts | 9 ++++- .../eth_estimateGas/eth_estimateGas.ts | 2 +- .../eth_getBlockTransactionCountByNumber.ts | 2 +- .../rpc-mapper/methods/eth_call/fixture.ts | 22 ++---------- .../methods/eth_estimateGas/fixture.ts | 20 +++++------ .../methods/eth_getBalance/fixture.ts | 5 --- .../methods/eth_getBlockByHash/fixture.ts | 2 +- ...ckTransactionCountByNumber.testnet.test.ts | 35 +++++++++---------- .../fixture.ts | 15 ++++++-- packages/rpc-proxy/README.md | 9 +++++ 11 files changed, 71 insertions(+), 61 deletions(-) diff --git a/packages/errors/src/available-errors/provider/provider.ts b/packages/errors/src/available-errors/provider/provider.ts index dc96e2364..1606f4111 100644 --- a/packages/errors/src/available-errors/provider/provider.ts +++ b/packages/errors/src/available-errors/provider/provider.ts @@ -118,6 +118,14 @@ class JSONRPCInternalError extends JSONRPCProviderError { } } +/** + * Invalid default block. + * + * WHEN TO USE: + * * When converting default block to vechain revision + */ +class JSONRPCInvalidDefaultBlock extends VechainSDKError {} + /** * Server error. * @@ -143,5 +151,6 @@ export { JSONRPCParseError, JSONRPCProviderError, JSONRPCServerError, - ProviderMethodError + ProviderMethodError, + JSONRPCInvalidDefaultBlock }; diff --git a/packages/network/src/provider/utils/const/blocks/blocks.ts b/packages/network/src/provider/utils/const/blocks/blocks.ts index 03aa55b92..644131438 100644 --- a/packages/network/src/provider/utils/const/blocks/blocks.ts +++ b/packages/network/src/provider/utils/const/blocks/blocks.ts @@ -1,4 +1,5 @@ import { HexUInt, Revision } from '@vechain/sdk-core'; +import { JSONRPCInvalidDefaultBlock } from '@vechain/sdk-errors'; type DefaultBlock = | `0x${string}` @@ -35,7 +36,13 @@ const DefaultBlockToRevision = (defaultBlock: DefaultBlock): Revision => { } // check if default block is a valid block tag if (!defaultBlockTags.includes(defaultBlock)) { - throw new Error(`Invalid block tag: ${defaultBlock}`); + const defaultBlockValue = defaultBlock.toString(); + throw new JSONRPCInvalidDefaultBlock( + 'DefaultBlockToRevision', + `Invalid default block: ${defaultBlockValue}`, + defaultBlockValue, + null + ); } // map block tag to VeChainThor revision if (defaultBlock === 'earliest') { diff --git a/packages/network/src/provider/utils/rpc-mapper/methods/eth_estimateGas/eth_estimateGas.ts b/packages/network/src/provider/utils/rpc-mapper/methods/eth_estimateGas/eth_estimateGas.ts index bbc2102c1..b8133e80a 100644 --- a/packages/network/src/provider/utils/rpc-mapper/methods/eth_estimateGas/eth_estimateGas.ts +++ b/packages/network/src/provider/utils/rpc-mapper/methods/eth_estimateGas/eth_estimateGas.ts @@ -30,7 +30,7 @@ const ethEstimateGas = async ( params: unknown[] ): Promise => { // Input validation - if (![1, 2].includes(params.length) || typeof params[0] !== 'object') + if (params.length !== 2 || typeof params[0] !== 'object') throw new JSONRPCInvalidParams( 'eth_estimateGas', `Invalid input params for "eth_estimateGas" method. See ${RPC_DOCUMENTATION_URL} for details.`, diff --git a/packages/network/src/provider/utils/rpc-mapper/methods/eth_getBlockTransactionCountByNumber/eth_getBlockTransactionCountByNumber.ts b/packages/network/src/provider/utils/rpc-mapper/methods/eth_getBlockTransactionCountByNumber/eth_getBlockTransactionCountByNumber.ts index 50749f28b..3440365a5 100644 --- a/packages/network/src/provider/utils/rpc-mapper/methods/eth_getBlockTransactionCountByNumber/eth_getBlockTransactionCountByNumber.ts +++ b/packages/network/src/provider/utils/rpc-mapper/methods/eth_getBlockTransactionCountByNumber/eth_getBlockTransactionCountByNumber.ts @@ -26,7 +26,7 @@ const ethGetBlockTransactionCountByNumber = async ( { params } ); - const block = await ethGetBlockByNumber(thorClient, [params[0], false]); + const block = await ethGetBlockByNumber(thorClient, [params[0], true]); if (block !== null) return block.transactions.length; return 0; }; diff --git a/packages/network/tests/provider/rpc-mapper/methods/eth_call/fixture.ts b/packages/network/tests/provider/rpc-mapper/methods/eth_call/fixture.ts index f7432ab4d..102b15189 100644 --- a/packages/network/tests/provider/rpc-mapper/methods/eth_call/fixture.ts +++ b/packages/network/tests/provider/rpc-mapper/methods/eth_call/fixture.ts @@ -61,22 +61,8 @@ const positiveCasesFixtures = [ expected: '0x' }, { - description: 'Sends 1 VET to the receiver. (using { blockNumber: 0 } )', - input: [ - { - from: '0x7487d912d03ab9de786278f679592b3730bdd540', - to: '0x3db469a79593dcc67f07DE1869d6682fC1eaf535', - value: '1000000000000000000', - data: '0x' - }, - { - blockNumber: 0 - } - ], - expected: '0x' - }, - { - description: 'Sends 1 VET to the receiver. (using { blockHash: 0x } )', + description: + 'Sends 1 VET to the receiver. (using { blockNumber: 0x0 } )', input: [ { from: '0x7487d912d03ab9de786278f679592b3730bdd540', @@ -84,9 +70,7 @@ const positiveCasesFixtures = [ value: '1000000000000000000', data: '0x' }, - { - blockHash: Hex.of(0).toString() - } + '0x0' ], expected: '0x' }, diff --git a/packages/network/tests/provider/rpc-mapper/methods/eth_estimateGas/fixture.ts b/packages/network/tests/provider/rpc-mapper/methods/eth_estimateGas/fixture.ts index e7ca9182d..6d5bb8af9 100644 --- a/packages/network/tests/provider/rpc-mapper/methods/eth_estimateGas/fixture.ts +++ b/packages/network/tests/provider/rpc-mapper/methods/eth_estimateGas/fixture.ts @@ -30,16 +30,6 @@ const positiveCasesFixtures = [ 'latest' ], expected: '0x45015' - }, - { - description: 'Missing block reference', - input: [ - { - from: '0x37cce5c8bd6141cbe8172b277faa65af5cc83c6a', - data: '0x' - } - ], - expected: '0xcf08' } ]; @@ -61,6 +51,16 @@ const negativeCasesFixtures = [ 'latest' ], expected: JSONRPCInternalError + }, + { + description: 'Missing block reference', + input: [ + { + from: '0x37cce5c8bd6141cbe8172b277faa65af5cc83c6a', + data: '0x' + } + ], + expected: JSONRPCInvalidParams } ]; diff --git a/packages/network/tests/provider/rpc-mapper/methods/eth_getBalance/fixture.ts b/packages/network/tests/provider/rpc-mapper/methods/eth_getBalance/fixture.ts index 024322dab..5508092da 100644 --- a/packages/network/tests/provider/rpc-mapper/methods/eth_getBalance/fixture.ts +++ b/packages/network/tests/provider/rpc-mapper/methods/eth_getBalance/fixture.ts @@ -14,11 +14,6 @@ const ethGetBalanceTestCases = [ params: [THOR_SOLO_ACCOUNTS[0].address, 'latest'], expected: Quantity.of(Units.parseEther('500000000').bi).toString() }, - { - description: 'Should return correct balance of the test account', - params: [THOR_SOLO_ACCOUNTS[0].address, 'best'], - expected: Quantity.of(Units.parseEther('500000000').bi).toString() - }, { description: 'Should return correct balance of the test account before seeding', diff --git a/packages/network/tests/provider/rpc-mapper/methods/eth_getBlockByHash/fixture.ts b/packages/network/tests/provider/rpc-mapper/methods/eth_getBlockByHash/fixture.ts index f7beaf305..71c19d60d 100644 --- a/packages/network/tests/provider/rpc-mapper/methods/eth_getBlockByHash/fixture.ts +++ b/packages/network/tests/provider/rpc-mapper/methods/eth_getBlockByHash/fixture.ts @@ -37,7 +37,7 @@ const ethGetBlockByHashTestCases = [ { description: 'Should get null if block does not exist', params: [ - '0x00000000000000000000000000083d49db800000000000000000000000000000', + '0x00000000851caf3cfdb6e899cf5958bfb1ac3413d346d43539627e6be7ec1b4a', // Invalid block hash for testnet true ], expected: null, diff --git a/packages/network/tests/provider/rpc-mapper/methods/eth_getBlockTransactionCountByNumber/eth_getBlockTransactionCountByNumber.testnet.test.ts b/packages/network/tests/provider/rpc-mapper/methods/eth_getBlockTransactionCountByNumber/eth_getBlockTransactionCountByNumber.testnet.test.ts index 2bf899aed..bb17edb28 100644 --- a/packages/network/tests/provider/rpc-mapper/methods/eth_getBlockTransactionCountByNumber/eth_getBlockTransactionCountByNumber.testnet.test.ts +++ b/packages/network/tests/provider/rpc-mapper/methods/eth_getBlockTransactionCountByNumber/eth_getBlockTransactionCountByNumber.testnet.test.ts @@ -5,8 +5,7 @@ import { TESTNET_URL, ThorClient } from '../../../../../src'; -import { ethGetBlockByHashTestCases } from '../eth_getBlockByHash/fixture'; -import { invalideEthGetBlockTransactionCountByHashTestCases } from './fixture'; +import { validTestCases, invalidTestCases } from './fixture'; /** * RPC Mapper integration tests for 'eth_getBlockTransactionCountByNumber' method @@ -34,16 +33,16 @@ describe('RPC Mapper - eth_getBlockTransactionCountByNumber method tests', () => /** * eth_getBlockTransactionCountByNumber RPC method positive test cases */ - ethGetBlockByHashTestCases.forEach( - ({ description, params, expectedTransactionsLength }) => { + validTestCases.forEach( + ({ description, blockNumberHex, expectedTxCount }) => { test(description, async () => { // Call RPC function const rpcCall = await RPCMethodsMap(thorClient)[ RPC_METHODS.eth_getBlockTransactionCountByNumber - ]([params[0]]); + ]([blockNumberHex]); // Compare the result with the expected value - expect(rpcCall).toStrictEqual(expectedTransactionsLength); + expect(rpcCall).toStrictEqual(expectedTxCount); }); } ); @@ -56,18 +55,16 @@ describe('RPC Mapper - eth_getBlockTransactionCountByNumber method tests', () => /** * Invalid eth_getBlockTransactionCountByNumber RPC method test cases */ - invalideEthGetBlockTransactionCountByHashTestCases.forEach( - ({ description, params, expectedError }) => { - test(description, async () => { - // Call RPC function - await expect( - async () => - await RPCMethodsMap(thorClient)[ - RPC_METHODS.eth_getBlockTransactionCountByNumber - ](params) - ).rejects.toThrowError(expectedError); - }); - } - ); + invalidTestCases.forEach(({ description, params, expectedError }) => { + test(description, async () => { + // Call RPC function + await expect( + async () => + await RPCMethodsMap(thorClient)[ + RPC_METHODS.eth_getBlockTransactionCountByNumber + ](params) + ).rejects.toThrowError(expectedError); + }); + }); }); }); diff --git a/packages/network/tests/provider/rpc-mapper/methods/eth_getBlockTransactionCountByNumber/fixture.ts b/packages/network/tests/provider/rpc-mapper/methods/eth_getBlockTransactionCountByNumber/fixture.ts index 94958aece..f175f6b01 100644 --- a/packages/network/tests/provider/rpc-mapper/methods/eth_getBlockTransactionCountByNumber/fixture.ts +++ b/packages/network/tests/provider/rpc-mapper/methods/eth_getBlockTransactionCountByNumber/fixture.ts @@ -1,9 +1,18 @@ import { JSONRPCInvalidParams } from '@vechain/sdk-errors'; +const validTestCases = [ + { + description: + 'Should return correct transaction count for specific block number', + blockNumberHex: '0x13F6730', + expectedTxCount: 1 + } +]; + /** - * Invalid eth_getBlockByHash RPC method test cases + * Invalid eth_getBlockTransactionCountByNumber RPC method test cases */ -const invalideEthGetBlockTransactionCountByHashTestCases = [ +const invalidTestCases = [ { description: 'Should throw error when invalid params are provided', params: [], @@ -21,4 +30,4 @@ const invalideEthGetBlockTransactionCountByHashTestCases = [ } ]; -export { invalideEthGetBlockTransactionCountByHashTestCases }; +export { invalidTestCases, validTestCases }; diff --git a/packages/rpc-proxy/README.md b/packages/rpc-proxy/README.md index 96e6eff3c..f8dd628d2 100644 --- a/packages/rpc-proxy/README.md +++ b/packages/rpc-proxy/README.md @@ -276,4 +276,13 @@ The following mappings are performed by the RPC proxy | earliest block | block number 0 | +## Transaction Coversions + +The method `eth_sendTransaction` requires the input to be a VeChain transaction object, not a Ethereum transaction object +This method signs the transaction using the configured PK, before passing it on to VeChain Thor + +For method `eth_sendRawTransaction` the signed encoded raw transaction parameter must be a vechain transaction object +This method cannot convert a signed Ethereum transaction to a signed VeChain transaction + + From 6f132a694120d04d2613a4ca37c80f89f6c29f7b Mon Sep 17 00:00:00 2001 From: clayton neal Date: Wed, 12 Feb 2025 14:01:08 +0000 Subject: [PATCH 06/10] chore: update openssl --- docker/rpc-proxy/Dockerfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docker/rpc-proxy/Dockerfile b/docker/rpc-proxy/Dockerfile index ee39c43a8..3b1099e24 100644 --- a/docker/rpc-proxy/Dockerfile +++ b/docker/rpc-proxy/Dockerfile @@ -19,6 +19,9 @@ COPY ./docker/rpc-proxy/adjust-packages.sh ./adjust-packages.sh # Install all the dependencies and build the app RUN yarn install && yarn build +# Upgrade openssl +RUN apk update && apk upgrade openssl + # Clean the package.json files ready for production RUN apk add --no-cache jq RUN chmod +x ./adjust-packages.sh From a4695481a1b2cf2dbc7bee814ae3d0d7da168302 Mon Sep 17 00:00:00 2001 From: clayton neal Date: Wed, 12 Feb 2025 15:03:43 +0000 Subject: [PATCH 07/10] chore: dockerfile --- docker/rpc-proxy/Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docker/rpc-proxy/Dockerfile b/docker/rpc-proxy/Dockerfile index 3b1099e24..4dd63a2d7 100644 --- a/docker/rpc-proxy/Dockerfile +++ b/docker/rpc-proxy/Dockerfile @@ -19,9 +19,6 @@ COPY ./docker/rpc-proxy/adjust-packages.sh ./adjust-packages.sh # Install all the dependencies and build the app RUN yarn install && yarn build -# Upgrade openssl -RUN apk update && apk upgrade openssl - # Clean the package.json files ready for production RUN apk add --no-cache jq RUN chmod +x ./adjust-packages.sh @@ -30,6 +27,9 @@ RUN /bin/sh ./adjust-packages.sh ./ # Stage 2: Serve the app using node FROM node:20.17.0-alpine3.20 AS runner +# Upgrade openssl +RUN apk update && apk upgrade openssl + # Copy only the built files and essential runtime files from the builder stage ## rpc-proxy COPY --from=builder /app/packages/rpc-proxy/dist /app/packages/rpc-proxy/dist From 993bc10046a911a19e5b6d9905985ffc69bac10a Mon Sep 17 00:00:00 2001 From: clayton neal Date: Wed, 12 Feb 2025 15:13:22 +0000 Subject: [PATCH 08/10] chore: fix openssl --- docker/rpc-proxy/Dockerfile | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/docker/rpc-proxy/Dockerfile b/docker/rpc-proxy/Dockerfile index 4dd63a2d7..c0d77b728 100644 --- a/docker/rpc-proxy/Dockerfile +++ b/docker/rpc-proxy/Dockerfile @@ -1,6 +1,14 @@ # Stage 1: Build the app FROM node:20.17-alpine3.20 AS builder +# Update package list and upgrade OpenSSL +RUN apk update && \ + apk upgrade --no-cache openssl && \ + # Verify the OpenSSL version + openssl version && \ + # Clean up + rm -rf /var/cache/apk/* + # Set the working directory in the builder stage WORKDIR /app @@ -27,9 +35,6 @@ RUN /bin/sh ./adjust-packages.sh ./ # Stage 2: Serve the app using node FROM node:20.17.0-alpine3.20 AS runner -# Upgrade openssl -RUN apk update && apk upgrade openssl - # Copy only the built files and essential runtime files from the builder stage ## rpc-proxy COPY --from=builder /app/packages/rpc-proxy/dist /app/packages/rpc-proxy/dist From 442bc49346c15df5877f5d815d80bd4b34065933 Mon Sep 17 00:00:00 2001 From: clayton neal Date: Wed, 12 Feb 2025 15:22:56 +0000 Subject: [PATCH 09/10] chore: fix openssl --- docker/rpc-proxy/Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docker/rpc-proxy/Dockerfile b/docker/rpc-proxy/Dockerfile index c0d77b728..19eb15ee4 100644 --- a/docker/rpc-proxy/Dockerfile +++ b/docker/rpc-proxy/Dockerfile @@ -3,8 +3,9 @@ FROM node:20.17-alpine3.20 AS builder # Update package list and upgrade OpenSSL RUN apk update && \ + apk add --no-cache openssl && \ apk upgrade --no-cache openssl && \ - # Verify the OpenSSL version + # Verify OpenSSL installation openssl version && \ # Clean up rm -rf /var/cache/apk/* From fbf6ba8071c11d2260bbab77cb5545f723c52968 Mon Sep 17 00:00:00 2001 From: clayton neal Date: Wed, 12 Feb 2025 15:27:24 +0000 Subject: [PATCH 10/10] chore: fix openssl --- docker/rpc-proxy/Dockerfile | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/docker/rpc-proxy/Dockerfile b/docker/rpc-proxy/Dockerfile index 19eb15ee4..739e6db71 100644 --- a/docker/rpc-proxy/Dockerfile +++ b/docker/rpc-proxy/Dockerfile @@ -1,15 +1,6 @@ # Stage 1: Build the app FROM node:20.17-alpine3.20 AS builder -# Update package list and upgrade OpenSSL -RUN apk update && \ - apk add --no-cache openssl && \ - apk upgrade --no-cache openssl && \ - # Verify OpenSSL installation - openssl version && \ - # Clean up - rm -rf /var/cache/apk/* - # Set the working directory in the builder stage WORKDIR /app @@ -36,6 +27,15 @@ RUN /bin/sh ./adjust-packages.sh ./ # Stage 2: Serve the app using node FROM node:20.17.0-alpine3.20 AS runner +# Update package list and upgrade OpenSSL +RUN apk update && \ + apk add --no-cache openssl && \ + apk upgrade --no-cache openssl && \ + # Verify OpenSSL installation + openssl version && \ + # Clean up + rm -rf /var/cache/apk/* + # Copy only the built files and essential runtime files from the builder stage ## rpc-proxy COPY --from=builder /app/packages/rpc-proxy/dist /app/packages/rpc-proxy/dist