Replies: 1 comment 1 reply
-
is the limit really 48kb now? Still issue deploying with above 24kb... |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Abstract
This HIP proposes an increase to the bytecode size limit for smart contracts on Hedera from the current limit of 24,576 bytes (a limit introduced in Spurious Dragon)[1]. This change would allow developers to write more complex and feature-rich contracts that can better leverage the capabilities of the Hedera network. One of the reasons for this increase is that the Hedera Token Service requires additional code to interact with the HTS, Exchange Rate and Prng precompile contracts that smart contracts on Ethereum do not need.
Specification
The proposed change involves doubling the maximum bytecode size limit from 24,576 bytes to 49,152 bytes (48 KB), as this requirement was previously indicated[3] due to some contracts having a size that is >24KB and <=48KB.
Considerations
Gas Costs and Gas Limits
Larger contract deployments will incur a higher gas cost. However, since gas prices on Hedera are quite cheap, this increase in gas costs should be expected for developers wanting to deploy larger contracts.
To calculate the gas cost for deploying a contract, several factors are considered, including the number of zero and non-zero bytes in the bytecode, the transaction data cost, and the deployed bytecode cost. The provided JavaScript functions
getContractDeployGasCost
andgetBytecodeSizeForGasLimit
illustrate these calculations, taking into account the worst and best cases(i.e., all bytes are either non-zero or zero).Hedera currently imposes a gas limit per transaction of 8m. Assuming the bytecode and deployed bytecode sizes are identical(which for most contracts is a reasonable approximation) and given an 8m gasLimit, the contract size in the worst case can be 29,652 bytes, and in the best case can be 38,955 bytes, both of which exceed the 24 KB contract size limit. This proposal requires doubling the current bytecode size from 24 KB to 48 KB, which would require increasing the gas limit per transaction to 13.226m in the worst case (excluding any potential gas incurred in the constructor). Given this, this HIP also proposes an increase to the gas limit per transaction to 14m, which is still less than the current gas throttle of 15 gas/s, which could likely also be increased without adversely affecting the network.
Contract Storage
It is important to consider the impact on contract storage (state) requirements. Currently, Hedera has a contract storage limit of 10 MB per contract. As developers create larger and more complex contracts with the increased bytecode size limit, it is likely that these contracts may require a larger state.
Therefore, it is reasonable to anticipate that the existing 10 MB storage limit per contract may become a constraint in the future, as the demand for more extensive smart contract capabilities grows. To ensure the continued growth and evolution of the Hedera ecosystem, it may be necessary to reevaluate and potentially increase the contract storage limit to accommodate the needs of larger and more complex smart contracts.
Benefits
In addition to allowing for larger and more complex contracts, increasing the bytecode size limit to 48 KB would also provide other benefits such as:
Backwards Compatibility
Increasing the bytecode size limit should not have any significant impact on existing smart contracts, as the change is only applicable to newly deployed contracts. Existing contracts will continue to operate under the current 24 KB limit. However, developers who wish to take advantage of the increased limit in their existing contracts may need to redeploy them with the updated bytecode size.
References
1. DOWNSIZING CONTRACTS TO FIGHT THE CONTRACT SIZE LIMIT
2. Smart contract creation cost
3. Indication of requirement as some contracts have a size that is >24KB and <=48KB
Beta Was this translation helpful? Give feedback.
All reactions