ethereum / solidity

Solidity, the Smart Contract Programming Language
https://soliditylang.org
GNU General Public License v3.0
23.28k stars 5.77k forks source link

Compare gas costs for the old ABI encoder and the new ABIEncoderV2 #6038

Closed axic closed 5 years ago

axic commented 5 years ago

Should compare the deploy time and the runtime costs.

Take the following settings:

Perhaps pompare a calldata struct in ABIEncoderV2 with a list of parameters in V1.

Run these on a set of "real-world" contracts, such as:

chriseth commented 5 years ago

Here are some values for the gnosis safe: https://docs.google.com/spreadsheets/d/158o_8LliRmvph_PcejecP6z0HxevjzzvexHrqOXoF5Q/edit#gid=0

chriseth commented 5 years ago

The previous values might be wrong. I have new ones about the zeppelin tests: https://docs.google.com/spreadsheets/d/1rTq8T2pbhHinmE1pLDEzIGzzUPdn4wmAgGv_hgPgEZI/edit?usp=sharing

In the median, V2 needs only 47 gas more, and the median of the relative change is 0.08%. I will try to split into creation costs and execution costs, though the split can only be done based on gas costs.

chriseth commented 5 years ago

Some of the numbers in the zepplin test set seem to not belong together, but I guess the overall value of 47 gas can still be justified.

axic commented 5 years ago

The second link is not shared.

chriseth commented 5 years ago

Updated.

chriseth commented 5 years ago

Gnosis has changed their tests to include the deployment costs: https://travis-ci.org/gnosis/safe-contracts/builds/498614120?utm_source=github_status&utm_medium=notification We should re-run our benchmarks, also including the knowledge about how to set truffle to the correct compiler version.

chriseth commented 5 years ago

Finished second analysis of gnosis-safe (same link). It looks like regular transactions are sometimes cheaper, but most of the time .5% more expensive. Deployments are not cheaper (in the 2-4% range), except for the master contract, which is 5% cheaper. These values can of course all change with the tuning parameter which was set at 200.

axic commented 5 years ago

I think the gnosis-safe is an example where deployment costs are less relevant compared to runtime costs.

That considered I think the 2-4% increase for a safer ABI decoder is worth it. Same goes for the 0.5% runtime increase.