Arachnid / solidity-stringutils

Basic string utilities for Solidity
Apache License 2.0
1.12k stars 369 forks source link

Tx silently fails if payload is too large but shows up as succesful #16

Open kaustavha opened 6 years ago

kaustavha commented 6 years ago

Hi there,

I'm attempting to jam a ton of text into a smart contract on the rinkeby network. (~12kb). The contract in essence takes text supplied and concats it to its internal data variable. When I try to shove the whole 12kb payload in a single TX it fails silently while showing a succesfully mined TX. But if I break it up into smaller TXs it works till 4605 bytes at least. I chunked the whole text blob into 3. Attempting to send the TX with the s3 sized payload fails silently, but shows up in metamask as succesful. The other two work fine.

s3.length
4794
s2.length
3031
s1.length
4605

Here is the contract code:

import "github.com/Arachnid/solidity-stringutils/strings.sol";

contract PermanentDataStore {
    using strings for *;
    string public data;
    function PermanentDataStore(string _data) public {
        concat(data, _data);
    }

    function get() constant returns (string) {
        return data;
    }

    function add(string _data) public {
        concat(data, _data);
    }

    function clear() public {
        data = "";
    }

    function concat(string s1, string s2) {
        data = s1.toSlice().concat(s2.toSlice());
    }
}

I'm wondering what the limit is and if it is documented anywhere? Also would it be possible to alert when it fails?

Expected behaviour would be either an alert that there was an issue, or a block that prevents initiating a tx with a payload too large.

Browser is chrome 59. OS is macOS 10.12.

Steps to reproduce:

Same issue: https://github.com/MetaMask/metamask-extension/issues/1809