eos icon indicating copy to clipboard operation
eos copied to clipboard

Error 3070003: Serialization Error Processing WASM, Error Details: Too many function defs

Open keisuke-kanao opened this issue 7 years ago • 5 comments

I wrote a contract and compiled it successfully using eosio-cpp version 1.6.2. Then, when I tried to deploy it, I got the below error: Error 3070003: Serialization Error Processing WASM Error Details: Too many function defs

This message is from https://github.com/EOSIO/eos/blob/master/libraries/wasm-jit/Source/WASM/WASMSerialization.cpp#L683 which means that the number of function definitions are more than 1024. https://github.com/EOSIO/eos/blob/master/libraries/chain/include/eosio/chain/wasm_eosio_constraints.hpp#L14 Actually, my code has about a dozen of functions (class methods).

If I remove some of part of a function from the contract code, deployment succeeds. Also, if I divide the contract code into three parts, deployment of each contract succeeds. original contract .wasm: 254.0 KiB three-divided contract .wasms : 132.8 KiB, 171.2 KiB, 159.9 KiB I have to modify each divided contract code accordingly, though. Incidentally, eosio.token.wasm (from eosio.contracts v1.7.0): 103.8 KiB

My question is: Are there any other ways to cope with this issue?

keisuke-kanao avatar Sep 29 '19 08:09 keisuke-kanao

Sorry, this was by my mistake.

keisuke-kanao avatar Sep 30 '19 11:09 keisuke-kanao

@keisuke-kanao I have the same issue now. Can you explain what the mistake was?

PhillipHamnett avatar Sep 10 '20 12:09 PhillipHamnett

Phillip Hamnett - Chintai, [10.09.20 09:01] [In reply to Phillip Hamnett - Chintai] @tbfleming @heifner this seems to be an issue with contracts being too large, but surely that would be very limiting when dealing with very complex applications like what Chintai is dealing with

Kevin Heifner, [10.09.20 09:10] [In reply to Phillip Hamnett - Chintai] Do you have more than 1024 functions?

Phillip Hamnett - Chintai, [10.09.20 09:11] [In reply to Kevin Heifner] Do you mean functions, or actions? I have about 80 actions, counting the functions now

Kevin Heifner, [10.09.20 09:11] It is total functions, including actions and all functions

Phillip Hamnett - Chintai, [10.09.20 09:15] [In reply to Kevin Heifner] If it turns out I have reached the limit of the number of functions, what would you recommend as the best course of action?

Kevin Heifner, [10.09.20 09:16] Inline some of them :(

Kevin Heifner, [10.09.20 09:17] If this is a private net you could increase the limit. If public, you would need a consensus change.

Phillip Hamnett - Chintai, [10.09.20 09:19] [In reply to Kevin Heifner] Is there any obvious downside to increasing the limit?

Kevin Heifner, [10.09.20 09:19] On a private chain, no.

Phillip Hamnett - Chintai, [10.09.20 09:20] [In reply to Kevin Heifner] And on a public chain? If I have to go to the BPs to ask them to do this, what potential downsides are there?

Kevin Heifner, [10.09.20 09:21] It is not currently configurable without modifying the code. I doubt BPs would be willing.

Phillip Hamnett - Chintai, [10.09.20 09:25] [In reply to Kevin Heifner] Me too. But it seems that eventually any piece of code might go over 1024 functions. I guess I'm asking why the limit was put into the code in the first place

Matt Witherspoon, [10.09.20 09:30] EOSIO 1.0 had a number of WASM protections in place to protect from abuse (such as a WASM declaring it had 1000000 functions that would cause a huge slow malloc blocking the main thread). All these protections are part of consensus. Unfortunately some of the limits were probably too strict, such as this one.

matthewdarwin avatar Sep 10 '20 13:09 matthewdarwin

https://github.com/EOSIO/eos/pull/8360

heifner avatar Sep 10 '20 13:09 heifner

Any additional updates on this? I'm getting this error when running unit tests for my contract. My contract is pretty large and complex. Plus I have some additional test actions that I need for unit testing. Does eosio-cpp remove unused code blocks and functions by default?

vernonjohnson avatar Sep 19 '20 18:09 vernonjohnson