Skip to content

Commit a42f741

Browse files
authored
chore: cherry pick PR#2566 (#2573)
fix: fixed condition to employ HFS in submitEthereumTransaction() (#2566) Signed-off-by: Logan Nguyen <[email protected]>
1 parent 5ba6f21 commit a42f741

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

packages/relay/src/lib/clients/sdkClient.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,8 @@ export class SDKClient {
250250
const interactingEntity = ethereumTransactionData.toJSON()['to'].toString();
251251
let fileId: FileId | null = null;
252252

253-
if (ethereumTransactionData.toBytes().length <= 5120) {
253+
// if callData's size is greater than `fileAppendChunkSize` => employ HFS to create new file to carry the rest of the contents of callData
254+
if (ethereumTransactionData.callData.length <= this.fileAppendChunkSize) {
254255
ethereumTransaction.setEthereumData(ethereumTransactionData.toBytes());
255256
} else {
256257
fileId = await this.createFile(

packages/server/tests/acceptance/rpc_batch1.spec.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,6 +1110,35 @@ describe('@api-batch-1 RPC Server Acceptance Tests', function () {
11101110
expect(info.created_contract_ids.length).to.be.equal(1);
11111111
});
11121112

1113+
// note: according to this ticket https://github.com/hashgraph/hedera-json-rpc-relay/issues/2563,
1114+
// if calldata's size fails into the range of [2568 bytes, 5217 bytes], the request fails and throw
1115+
// `Null Entity ID` error. This unit test makes sure that with the new fix, requests should work with all case scenarios.
1116+
it('should execute "eth_sendRawTransaction" and deploy a contract with any arbitrary calldata size', async () => {
1117+
const gasPrice = await relay.gasPrice(requestId);
1118+
1119+
const randomBytes = [2566, 2568, 3600, 5217, 7200];
1120+
1121+
for (const bytes of randomBytes) {
1122+
const transaction = {
1123+
type: 2,
1124+
chainId: Number(CHAIN_ID),
1125+
nonce: await relay.getAccountNonce(accounts[0].address, requestId),
1126+
maxPriorityFeePerGas: gasPrice,
1127+
maxFeePerGas: gasPrice,
1128+
gasLimit: defaultGasLimit,
1129+
data: '0x' + '00'.repeat(bytes),
1130+
};
1131+
const signedTx = await accounts[0].wallet.signTransaction(transaction);
1132+
const transactionHash = await relay.sendRawTransaction(signedTx, requestId);
1133+
const info = await mirrorNode.get(`/contracts/results/${transactionHash}`, requestId);
1134+
expect(info).to.have.property('contract_id');
1135+
expect(info.contract_id).to.not.be.null;
1136+
expect(info).to.have.property('created_contract_ids');
1137+
expect(info.created_contract_ids.length).to.be.equal(1);
1138+
await new Promise((r) => setTimeout(r, 3000));
1139+
}
1140+
});
1141+
11131142
it('should delete the file created while execute "eth_sendRawTransaction" to deploy a large contract', async function () {
11141143
const gasPrice = await relay.gasPrice(requestId);
11151144
const transaction = {

0 commit comments

Comments
 (0)