Skip to content

The contractCodeSize function uses the size of the transaction's call data as the size of the contract. #3883

@Neurone

Description

@Neurone

Description

The contractCodeSize function uses the size of the transaction's call data as the size of the contract.

I don't think it's possible to calculate the final contract size based on the transaction details alone without executing the EVM code, so I suggest skipping this pre-check entirely.

contractCodeSize(tx: Transaction): void {
if (!tx.to) {
const contractCodeSize = tx.data.replace('0x', '').length / 2;
if (contractCodeSize > constants.CONTRACT_CODE_SIZE_LIMIT) {
throw predefined.CONTRACT_CODE_SIZE_LIMIT_EXCEEDED(contractCodeSize, constants.CONTRACT_CODE_SIZE_LIMIT);
}
}
}

callDataSize(tx: Transaction): void {
const totalCallDataSizeInBytes = tx.data.replace('0x', '').length / 2;
const callDataSizeLimit = constants.CALL_DATA_SIZE_LIMIT;
if (totalCallDataSizeInBytes > callDataSizeLimit) {
throw predefined.CALL_DATA_SIZE_LIMIT_EXCEEDED(totalCallDataSizeInBytes, callDataSizeLimit);
}
}

Steps to reproduce

  1. Deploy a contract smaller than 24 KB but using a call data bigger than 24 KB
  2. See an error similar to this {"error":{"code":-32201,"message":"[Request ID: 19e1ce52-ff63-4cbd-894e-b9d941e23c9a] Oversized data: contract code size 30412, contract code size limit 24576"},"jsonrpc":"2.0","id":86}

Additional context

No response

Hedera network

No response

Version

v0.69.2

Operating system

None

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions