raiden-contracts icon indicating copy to clipboard operation
raiden-contracts copied to clipboard

Create script to save transaction gas cost estimations to doc

Open loredanacirstea opened this issue 6 years ago • 8 comments

tl;dr Gas cost estimations are calculated in test_print_gas.py. This should not be ran as a test, but should be a script that generates a file with the information, which should be added in the docs.

Problem Definition

There is no way for (advanced developer) users to easily see a rundown of how much it would cost at any verion of raiden to perform common channel operations.

Solution

Add a table, probably in spec.rst with gas costs of all raiden common channel operations which should be updated every time we change the logic of the contracts or if there is any considerable contract revamp.

This way we will be able to efficiently have a versioned tracking of gas costs optimizations and also a way to identify bottlenecks that require optimization.

loredanacirstea avatar Mar 21 '18 13:03 loredanacirstea

Update: the values should not be in the docs, but as package deliverables. We can make this script run at deployment time for the testnet and save the addresses & gas estimation values together, in a json file. Also, we need to make sure we have the worst case scenarios in mind for the gas costs (e.g. calling closeChannel with a balance proof will cost more than without).

Related: https://github.com/raiden-network/raiden-contracts/issues/306

loredanacirstea avatar Oct 08 '18 08:10 loredanacirstea

This should have not been closed, sorry. https://github.com/raiden-network/raiden-contracts/pull/335 only adds the gas limits to the constants.py file. We should still have this calculations done automatically, maybe after we compile the contracts.json file, but I am moving the issue to anther milestone.

loredanacirstea avatar Oct 16 '18 10:10 loredanacirstea

An idea mentioned by @hackaugusto here is to not auto-generate a constants.py but instead a .json file so that it can be processed by non-python consumers.

LefterisJP avatar Feb 05 '19 08:02 LefterisJP

  • [x] is there a standard format for storing gas-cost estimations? (Maybe solc output)?

pirapira avatar Feb 11 '19 16:02 pirapira

solc does not like --combined-json abi,bin,bin-runtime,gas,metadata,ast.

pirapira avatar Feb 11 '19 16:02 pirapira

Here is one option:

  • If we switch to standard-input, we can get gas estimates. https://solidity.readthedocs.io/en/v0.5.3/using-the-compiler.html#compiler-input-and-output-json-description
    • but, this will not cover some special needs like "how much gas does it take to unlock() six hashlocks?"

pirapira avatar Feb 11 '19 16:02 pirapira

But, the first task is probably https://github.com/raiden-network/raiden-contracts/issues/547 .

After that the test can be turned into a script.

pirapira avatar Feb 11 '19 16:02 pirapira

This issue is about adding the gas information in the document. I don't know if that's so urgent.

pirapira avatar Feb 28 '19 11:02 pirapira