简体   繁体   English

RSK 网络上智能合约的最大大小是多少?

[英]What is the max size of a smart contract on the RSK network?

Does RSK have a maximum size of a compiled smart contract? RSK 是否有已编译智能合约的最大大小? If so, what is the max size of the byte code that can be deployed?如果是这样,可以部署的字节码的最大大小是多少?

Yes there is, the maximum size is 24567 , which is ~24KB.是的,最大大小为24567 ,即 ~24KB。

This is defined in Constants#getMaxContractSize()这在Constants#getMaxContractSize()定义

    public static int getMaxContractSize() {
        return 0x6000;
    }

The specific logic during a contract deployment uses this value within TransactionExecutor#createContract()合约部署期间的特定逻辑在TransactionExecutor#createContract()使用此值

    private void createContract() {
        int createdContractSize = getLength(program.getResult().getHReturn());
        long returnDataGasValue = GasCost.multiply(GasCost.CREATE_DATA, createdContractSize);
        if (mEndGas < returnDataGasValue) {
            program.setRuntimeFailure(
                    Program.ExceptionHelper.notEnoughSpendingGas(
                            program,
                            "No gas to return just created contract",
                            returnDataGasValue));
            result = program.getResult();
            result.setHReturn(EMPTY_BYTE_ARRAY);
        } else if (createdContractSize > Constants.getMaxContractSize()) {
            program.setRuntimeFailure(
                    Program.ExceptionHelper.tooLargeContractSize(
                            program,
                            Constants.getMaxContractSize(),
                            createdContractSize));
            result = program.getResult();
            result.setHReturn(EMPTY_BYTE_ARRAY);
        } else {
            mEndGas = GasCost.subtract(mEndGas,  returnDataGasValue);
            program.spendGas(returnDataGasValue, "CONTRACT DATA COST");
            cacheTrack.saveCode(tx.getContractAddress(), result.getHReturn());
        }
    }

The part of the above function relevant to your question, is that the condition (createdContractSize > Constants.getMaxContractSize()) needs to be satisfied, otherwise an exception is thrown.与您的问题相关的上述函数的部分是需要满足条件(createdContractSize > Constants.getMaxContractSize()) ,否则会引发异常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM