Skip to content

Commit 8dfdcde

Browse files
committed
chore: remove contract size precheck
Signed-off-by: nikolay <[email protected]>
1 parent edd6c18 commit 8dfdcde

File tree

8 files changed

+1
-204
lines changed

8 files changed

+1
-204
lines changed

docs/configuration.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ Unless you need to set a non-default value, it is recommended to only populate o
3434
| `CLIENT_TRANSPORT_SECURITY` | "false" | Flag to enable or disable TLS for both networks. |
3535
| `CONSENSUS_MAX_EXECUTION_TIME` | "15000" | Maximum time in ms the SDK will wait when submitting a transaction/query before throwing a TIMEOUT error. |
3636
| `CONTRACT_CALL_GAS_LIMIT` | "50_000_000" | Maximum gas limit applied to eth_call endpoint networks, the Relay will accept up to 50M but keep it capped at 15M for the actual call. |
37-
| `CONTRACT_CODE_SIZE_LIMIT` | 24576 | Maximum contract code size in bytes (24KB by default) allowed for contract deployment transactions. This limit is enforced during transaction validation to prevent excessive gas consumption from oversized contracts. |
3837
| `CONTRACT_QUERY_TIMEOUT_RETRIES` | "3" | Maximum retries for failed contract call query with timeout exceeded error |
3938
| `DEBUG_API_ENABLED` | "false" | Enables all debug related methods: `debug_traceTransaction` |
4039
| `DEFAULT_RATE_LIMIT` | "200" | default fallback rate limit, if no other is configured. |

packages/config-service/src/services/globalConfig.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,6 @@ const _CONFIG = {
148148
required: false,
149149
defaultValue: 50_000_000,
150150
},
151-
CONTRACT_CODE_SIZE_LIMIT: {
152-
envName: 'CONTRACT_CODE_SIZE_LIMIT',
153-
type: 'number',
154-
required: false,
155-
defaultValue: 24576, // 24KB
156-
},
157151
CONTRACT_QUERY_TIMEOUT_RETRIES: {
158152
envName: 'CONTRACT_QUERY_TIMEOUT_RETRIES',
159153
type: 'number',

packages/relay/src/lib/constants.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,6 @@ export default {
237237

238238
MAX_TRANSACTION_FEE_THRESHOLD: ConfigService.get('MAX_TRANSACTION_FEE_THRESHOLD'),
239239
SEND_RAW_TRANSACTION_SIZE_LIMIT: ConfigService.get('SEND_RAW_TRANSACTION_SIZE_LIMIT'),
240-
CONTRACT_CODE_SIZE_LIMIT: ConfigService.get('CONTRACT_CODE_SIZE_LIMIT'),
241240
CALL_DATA_SIZE_LIMIT: ConfigService.get('CALL_DATA_SIZE_LIMIT'),
242241

243242
INVALID_EVM_INSTRUCTION: '0xfe',

packages/relay/src/lib/errors/JsonRpcError.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -289,11 +289,6 @@ export const predefined = {
289289
code: -32201,
290290
message: `Oversized data: call data size ${actualSize}, call data size limit ${expectedSize}`,
291291
}),
292-
CONTRACT_CODE_SIZE_LIMIT_EXCEEDED: (actualSize: number, expectedSize: number) =>
293-
new JsonRpcError({
294-
code: -32201,
295-
message: `Oversized data: contract code size ${actualSize}, contract code size limit ${expectedSize}`,
296-
}),
297292
BATCH_REQUESTS_DISABLED: new JsonRpcError({
298293
code: -32202,
299294
message: 'Batch requests are disabled',

packages/relay/src/lib/precheck.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ export class Precheck {
6363
networkGasPriceInWeiBars: number,
6464
requestDetails: RequestDetails,
6565
): Promise<void> {
66-
this.contractCodeSize(parsedTx);
6766
this.callDataSize(parsedTx);
6867
this.transactionSize(parsedTx);
6968
this.transactionType(parsedTx, requestDetails);
@@ -383,21 +382,4 @@ export class Precheck {
383382
}
384383
}
385384
}
386-
387-
/**
388-
* Validates that the contract code size is within the allowed limit.
389-
* This check is only performed for contract creation transactions (where tx.to is null).
390-
* This limits contract code size to prevent excessive gas consumption.
391-
*
392-
* @param {Transaction} tx - The transaction to validate.
393-
* @throws {JsonRpcError} If the contract code size exceeds the configured limit.
394-
*/
395-
contractCodeSize(tx: Transaction): void {
396-
if (!tx.to) {
397-
const contractCodeSize = tx.data.replace('0x', '').length / 2;
398-
if (contractCodeSize > constants.CONTRACT_CODE_SIZE_LIMIT) {
399-
throw predefined.CONTRACT_CODE_SIZE_LIMIT_EXCEEDED(contractCodeSize, constants.CONTRACT_CODE_SIZE_LIMIT);
400-
}
401-
}
402-
}
403385
}

packages/relay/tests/lib/precheck.spec.ts

Lines changed: 0 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -769,90 +769,6 @@ describe('Precheck', async function () {
769769
});
770770
});
771771

772-
describe('contractCodeSize', function () {
773-
const defaultTx = {
774-
value: ONE_TINYBAR_IN_WEI_HEX,
775-
gasPrice: defaultGasPrice,
776-
gasLimit: defaultGasLimit,
777-
chainId: defaultChainId,
778-
nonce: 5,
779-
};
780-
781-
// Helper function to create a transaction with specified data and to address
782-
const createTransaction = async (data: string, to?: string) => {
783-
const wallet = ethers.Wallet.createRandom();
784-
const txParams = {
785-
...defaultTx,
786-
from: wallet.address,
787-
data: data,
788-
};
789-
790-
if (to) {
791-
txParams['to'] = to;
792-
}
793-
794-
const signed = await wallet.signTransaction(txParams);
795-
return ethers.Transaction.from(signed);
796-
};
797-
798-
it('should accept contract creation with code size within limit', async () => {
799-
// Create data that is within the limit
800-
const dataSize = constants.CONTRACT_CODE_SIZE_LIMIT - 1;
801-
const data = '0x' + '00'.repeat(dataSize);
802-
803-
const tx = await createTransaction(data);
804-
805-
expect(() => precheck.contractCodeSize(tx)).not.to.throw();
806-
});
807-
808-
it('should accept contract creation with code size at the limit', async () => {
809-
// Create data that is exactly at the limit
810-
const dataSize = constants.CONTRACT_CODE_SIZE_LIMIT;
811-
const data = '0x' + '00'.repeat(dataSize);
812-
813-
const tx = await createTransaction(data);
814-
815-
expect(() => precheck.contractCodeSize(tx)).not.to.throw();
816-
});
817-
818-
it('should reject contract creation with code size exceeding limit', async () => {
819-
// Create data that exceeds the limit
820-
const dataSize = constants.CONTRACT_CODE_SIZE_LIMIT + 1;
821-
const data = '0x' + '00'.repeat(dataSize);
822-
823-
const tx = await createTransaction(data);
824-
825-
try {
826-
precheck.contractCodeSize(tx);
827-
expect('Transaction should have been rejected');
828-
} catch (error) {
829-
expect(error).to.be.an.instanceOf(JsonRpcError);
830-
const expectedError = predefined.CONTRACT_CODE_SIZE_LIMIT_EXCEEDED(
831-
dataSize,
832-
constants.CONTRACT_CODE_SIZE_LIMIT,
833-
);
834-
expect(error).to.deep.equal(expectedError);
835-
}
836-
});
837-
838-
it('should not check code size for regular transactions (with to address)', async () => {
839-
// Create data that exceeds the limit but has a to address
840-
const dataSize = constants.CONTRACT_CODE_SIZE_LIMIT + 1;
841-
const data = '0x' + '00'.repeat(dataSize);
842-
843-
const tx = await createTransaction(data, contractAddress1);
844-
845-
// Should not throw even though data size exceeds limit
846-
expect(() => precheck.contractCodeSize(tx)).not.to.throw();
847-
});
848-
849-
it('should handle empty data for contract creation', async () => {
850-
const tx = await createTransaction('0x');
851-
852-
expect(() => precheck.contractCodeSize(tx)).not.to.throw();
853-
});
854-
});
855-
856772
describe('transactionType', async function () {
857773
const defaultTx = {
858774
value: ONE_TINYBAR_IN_WEI_HEX,

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

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1419,24 +1419,6 @@ describe('@api-batch-1 RPC Server Acceptance Tests', function () {
14191419
expect(fileInfo.size.toNumber()).to.eq(0);
14201420
});
14211421

1422-
it('should execute "eth_sendRawTransaction" and fail when deploying too large contract', async function () {
1423-
const gasPrice = await relay.gasPrice(requestId);
1424-
const transaction = {
1425-
type: 2,
1426-
chainId: Number(CHAIN_ID),
1427-
nonce: await relay.getAccountNonce(accounts[1].address, requestId),
1428-
maxPriorityFeePerGas: gasPrice,
1429-
maxFeePerGas: gasPrice,
1430-
gasLimit: defaultGasLimit,
1431-
data: '0x' + '00'.repeat(132221),
1432-
};
1433-
1434-
const signedTx = await accounts[1].wallet.signTransaction(transaction);
1435-
const error = predefined.CONTRACT_CODE_SIZE_LIMIT_EXCEEDED(132221, Constants.CONTRACT_CODE_SIZE_LIMIT);
1436-
1437-
await Assertions.assertPredefinedRpcError(error, sendRawTransaction, true, relay, [signedTx, requestDetails]);
1438-
});
1439-
14401422
it('should execute "eth_sendRawTransaction" of type 1 and deploy a real contract', async function () {
14411423
//omitting the "to" and "nonce" fields when creating a new contract
14421424
const transaction = {
@@ -1492,7 +1474,7 @@ describe('@api-batch-1 RPC Server Acceptance Tests', function () {
14921474
maxPriorityFeePerGas: gasPrice,
14931475
maxFeePerGas: gasPrice,
14941476
gasLimit: Constants.MAX_TRANSACTION_FEE_THRESHOLD,
1495-
data: '0x' + '00'.repeat(Constants.CONTRACT_CODE_SIZE_LIMIT),
1477+
data: '0x' + '00'.repeat(100),
14961478
};
14971479

14981480
const signedTx = await accounts[2].wallet.signTransaction(transaction);

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

Lines changed: 0 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -150,76 +150,6 @@ describe('@sendRawTransactionExtension Acceptance Tests', function () {
150150
await Assertions.assertPredefinedRpcError(error, sendRawTransaction, false, relay, [signedTx, requestDetails]);
151151
});
152152
});
153-
154-
describe('contractCodeSize', function () {
155-
it('@release should execute "eth_sendRawTransaction" and deploy a contract with code size within the CONTRACT_CODE_SIZE_LIMIT - 24kb limit', async function () {
156-
const gasPrice = await relay.gasPrice(requestId);
157-
158-
// create a regular deployment transaction with contract code size within the CONTRACT_CODE_SIZE_LIMIT - 24kb limit
159-
const transaction = {
160-
type: 2,
161-
chainId: Number(CHAIN_ID),
162-
nonce: await relay.getAccountNonce(accounts[1].address, requestId),
163-
maxPriorityFeePerGas: gasPrice,
164-
maxFeePerGas: gasPrice,
165-
gasLimit: defaultGasLimit,
166-
data: '0x' + '00'.repeat(5120),
167-
};
168-
169-
const signedTx = await accounts[1].wallet.signTransaction(transaction);
170-
const transactionHash = await relay.sendRawTransaction(signedTx, requestId);
171-
await relay.pollForValidTransactionReceipt(transactionHash);
172-
173-
const info = await mirrorNode.get(`/contracts/results/${transactionHash}`, requestId);
174-
expect(info).to.have.property('contract_id');
175-
expect(info.contract_id).to.not.be.null;
176-
expect(info).to.have.property('created_contract_ids');
177-
expect(info.created_contract_ids.length).to.be.equal(1);
178-
});
179-
180-
it('@release should fail "eth_sendRawTransaction" for contract with code size exceeding the CONTRACT_CODE_SIZE_LIMIT - 24kb limit', async function () {
181-
const gasPrice = await relay.gasPrice(requestId);
182-
// Create a deployment transaction with contract code size exceeding CONTRACT_CODE_SIZE_LIMIT
183-
const transaction = {
184-
type: 2,
185-
chainId: Number(CHAIN_ID),
186-
nonce: await relay.getAccountNonce(accounts[1].address, requestId),
187-
maxPriorityFeePerGas: gasPrice,
188-
maxFeePerGas: gasPrice,
189-
gasLimit: defaultGasLimit,
190-
data: '0x' + '00'.repeat(Constants.CONTRACT_CODE_SIZE_LIMIT + 1024), // exceeds the limit by 1KB
191-
};
192-
193-
const signedTx = await accounts[1].wallet.signTransaction(transaction);
194-
const contractCodeSize = (transaction.data.length - 2) / 2;
195-
const error = predefined.CONTRACT_CODE_SIZE_LIMIT_EXCEEDED(
196-
contractCodeSize,
197-
Constants.CONTRACT_CODE_SIZE_LIMIT,
198-
);
199-
200-
await Assertions.assertPredefinedRpcError(error, sendRawTransaction, false, relay, [signedTx, requestDetails]);
201-
});
202-
203-
it('@release should pass precheck and execute "eth_sendRawTransaction" for a regular transaction i.e. non contract deployment transaction with data exceeding the CONTRACT_CODE_SIZE_LIMIT - 24kb limit', async function () {
204-
const gasPrice = await relay.gasPrice(requestId);
205-
// Create a transaction with large data but sent to an existing address (not contract creation)
206-
const transaction = {
207-
type: 2,
208-
chainId: Number(CHAIN_ID),
209-
nonce: await relay.getAccountNonce(accounts[1].address, requestId),
210-
maxPriorityFeePerGas: gasPrice,
211-
maxFeePerGas: gasPrice,
212-
gasLimit: defaultGasLimit,
213-
to: accounts[0].address, // Sending to existing address, so code size check doesn't apply
214-
data: '0x' + '00'.repeat(Constants.CONTRACT_CODE_SIZE_LIMIT + 1024), // exceeds the limit by 1KB
215-
};
216-
217-
const signedTx = await accounts[1].wallet.signTransaction(transaction);
218-
const transactionHash = await relay.sendRawTransaction(signedTx, requestId);
219-
const info = await mirrorNode.get(`/contracts/results/${transactionHash}`, requestId);
220-
expect(info).to.exist;
221-
});
222-
});
223153
});
224154

225155
describe('Jumbo Transaction', function () {

0 commit comments

Comments
 (0)