raiden-contracts
raiden-contracts copied to clipboard
Create script to save transaction gas cost estimations to doc
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.
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
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.
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.
- [x] is there a standard format for storing gas-cost estimations? (Maybe
solc
output)?
solc
does not like --combined-json abi,bin,bin-runtime,gas,metadata,ast
.
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?"
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.
This issue is about adding the gas information in the document. I don't know if that's so urgent.