Open liamcurry opened 6 years ago
The 64KB limit serves as a gatekeeper to ensure blockchain is healthy and secure. Changing this limit will result in hardfork or causing more delays on contract loading which introduces blackholes for hackers. Alternatively you can use multi_index table to store const string data, which takes about same amount of memory.
The reason this occurs for rust is because rust’s compiler, be default, wants 1MB of “stack” to work with. You can reduce this, for example, by
rustc +nightly --target wasm32-unknown-unknown -O hello.rs -Clink-args='-z stack-size=8192'
The above example may or may not work I'm not sure how much stack rust needs to float.
Thanks @spoonincode! Reducing the stack size worked. FYI for anyone else tinkering with Rust, I ended up adding this to my .cargo/config
file:
[target.wasm32-unknown-unknown]
rustflags = [
"-C", "link-args=-z stack-size=48000"
]
Hi @taokayan, I build a contract with static
libsecp256k1, with DATA larger than 64KB. Is there a better way to do? Since get data from table is quite slow when DATA is big.
After the update to EOSIO.CDT v1.8.0-RC1 and EOSIO v2.1.0-RC1 I'm getting this error, too, with a pretty large contract. I previously used EOSIO.CDT v.1.7.0 and EOSIO v2.0.7 and have not had any problems. Is there a way solve this? (like setting -stack-size or so?)
After the update to EOSIO.CDT v1.8.0-RC1 and EOSIO v2.1.0-RC1 I'm getting this error, too, with a pretty large contract. I previously used EOSIO.CDT v.1.7.0 and EOSIO v2.0.7 and have not had any problems. Is there a way solve this? (like setting -stack-size or so?)
Tried setting -stack-size to something small and -fno-stack-first, both without success.
While working on Rust bindings I ran into this error: https://github.com/EOSIO/eos/blob/master/libraries/chain/wasm_eosio_validation.cpp#L28
Smart contract data segments must lie in first 64KiB
It seems to be caused by this line in the
.wast
file:(data (i32.const 1048576) "Hello World")
If I change
1048576
to something much smaller like555
then it works as expected.According to @tbfleming on Telegram: