-
Notifications
You must be signed in to change notification settings - Fork 0
Estimate Gas Usage #46
Comments
Context: near/nearcore#1829 (comment) |
Shedding a little light into Ethereum and gas prices, here's how a person can estimate: |
Additional context: The web3js function uses the eth_estimateGas RPC call, which essentially hits a node, executes the transaction, measures the gas used, then returns the result. @willemneal Can add more detail about how https://github.com/nearprotocol/wasm-mock-vm might be able to replace the "node - execute- return result" portion of this. |
This is also relevant: near/nearcore#1937, basically we can also use symbolic execution to exercise all possible paths and get an upper and lower bound on gas usage. @kcole16 As for the wasm-mock-vm, at first I simulated being inside a running contract and being able to call runtime apis. However, now I'm working on being able to invoke a method on a wasm binary, which can then be prepared with nearcore's runner. This includes the instrumenting needed for gas usage. For the most part this will be a pretty easy metric (outside of cross contract calls), for example, a runtime call for base + storage_write_base + storage_write_key_byte * num_key_bytes + storage_write_value_byte * num_value_bytes + get_vec_from_memory_or_register_cost x 2`. However, a `base + storage_read_base + storage_read_key_byte * num_key_bytes + storage_read_value_byte + num_value_bytes Which means that we need to know the size of the value being read. This also applies for an added cost when a Is there a way to read the storage outside of a contract call? The other option is that we could update nearcore so that it can do a trial run that will perform reads only. |
@willemneal do you feel siloed on this effort? I know your wheelhouse is pretty deep in the weeds and it's not easy for other developers to jump in. I am, however, getting the sense that some of these important issues are kind of lobbed in your court and want to check in to see if folks can help. |
@mikedotexe I feel siloed do a little, but that is partly my fault at this point. After the conversion to gitpod, I'm looking to promote the The same goes for Perhaps after the migration we should just have a meeting for those interested and split up tasks. |
Capturing basic notes as I start learning about this.
|
@chadoh add the issues related to V1 of this associated with this epic. |
Timeline: before MainNet.
Requirements:
The text was updated successfully, but these errors were encountered: