Code Monkey home page Code Monkey logo

Comments (2)

keroro520 avatar keroro520 commented on September 7, 2024

The reproducing smart contract:

function add(uint256 b2, uint256 cc1, uint256 cc2) public view returns (bytes memory a, bytes memory b){
    assembly {
        a := mload(0x40)
        b := add(a, b2)
        codecopy(a, cc1, cc2)
    }
}

The error code we receive from Godwoken and Godwoken-Web3 is GW_FATAL_BUFFER_OVERFLOW 50

This error is throw by sys_set_program_return_data, indicates 25KB upper limit for return data:

/* set call return data */
int sys_set_program_return_data(gw_context_t *ctx, uint8_t *data,
                                uint64_t len) {
  if (ctx == NULL) {
    return GW_FATAL_INVALID_CONTEXT;
  }
  if (len > GW_MAX_DATA_SIZE) {
    printf("Exceeded max return data size");
    return GW_FATAL_BUFFER_OVERFLOW;
  }
  return syscall(GW_SYS_SET_RETURN_DATA, data, len, 0, 0, 0, 0);
}

After discussing with @jjyr , I think the limit is reasonable. On the other hand, I think we should document these resource limits on the documentation for compatibility, e.g. return data, contract code, and contract storage.


I try to implement a contract to locate the upper limit for return data on Hardhat localnet. My experiment's conclusion is 1785056.

contract TestLimitForReturnData {
    function works_well() public view returns (bytes memory value) {
        value = new bytes(1785056);
        return value;
    }

    function works_bad() public view returns (bytes memory value) {
        value = new bytes(1785057);
        return value;
    }
}

from godwoken-web3.

keroro520 avatar keroro520 commented on September 7, 2024

The size limit for contract storage is 25KB too:

/* Store data by data hash */
int sys_store_data(gw_context_t *ctx, uint64_t data_len, uint8_t *data) {
  if (ctx == NULL) {
    return GW_FATAL_INVALID_CONTEXT;
  }

  if (0 == data_len) {
    return 0;
  }
  if (data_len > GW_MAX_DATA_SIZE) {
    printf("Exceeded max store data size");
    return GW_FATAL_INVALID_DATA;
  }

..

from godwoken-web3.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.