openethereum / sol-rs

Solaris - Solidity testing framework in Rust.
GNU General Public License v3.0
54 stars 14 forks source link

add estimate_gas #24

Closed snd closed 6 years ago

snd commented 6 years ago

https://github.com/ethereum/wiki/wiki/JavaScript-API#web3ethestimategas

usage could look like this:

let gasEstimate: U256 = evm
    .with_sender(authority_addresses[0].clone())
    .estimate_gas(contract.functions().deposit().input(user_address, value, transaction_hash))
    .unwrap();

fn estimate_gas(self, bytes: ethabi::Bytes) -> Result<U256, ...> {
   // ...
}
tomusdrw commented 6 years ago

Just out of curiosity, what is the use case for such methods in tests? Or do you think it should be there for the completeness sake?

tomusdrw commented 6 years ago

Just realized it would be cool for solaris to automatically print out gas estimates for all methods as part of fn main() probably.

snd commented 6 years ago

Just out of curiosity, what is the use case for such methods in tests? Or do you think it should be there for the completeness sake?

good question. maybe this should be in another crate

snd commented 6 years ago

we could split sol-rs into a testing part (~ truffle) and a utility part (~ web3 js api)

sol::wei, estimate_gas, etc could be in the utility part

tomusdrw commented 6 years ago

We already have rust-web3 (over RPC) that does that for state read from database and parity-evm for contract execution (you can run a contract and see how much gas it consumed, just a matter of adding binary chop to find the best value), I don't see how this could be useful even in utility crate.

kirushik commented 6 years ago

@snd Are you OK with closing this one? I'm with @tomusdrw — we'd better focus on making the testing side of things usable, reliable and smooth right now.

snd commented 6 years ago

closing this. i agree with @tomusdrw that this doesn't really belong in sol-rs. on top of that there are already several options to estimate gas from within rust