-
Notifications
You must be signed in to change notification settings - Fork 383
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[chain] Gas Estimations #1826
Comments
Note that at the time of writing, The reason I'm writing here, though, is relating to the latest work undertaken in #1702, which improves the UX for simulating transactions on it seems to me that the approach you quoted @zivkovicmilos with (I think we can still reasonably provide something like For what concerns test4; after #1702 is merged, I propose setting up a "gas estimation system" which would work as follows:
|
@thehowl We need to have an estimation endpoint on the node and not (just) on the indexer because we actually want to "simulate" transactions which are unsigned, and have no specified gas values yet. Gas price delegation to the indexer makes sense, since this value is actually historical, while the estimation depends on the VM |
To be clear, the output of this effort is an endpoint that the user can call? |
Relevant PR |
<!-- please provide a detailed description of the changes made in this pull request. --> ## Descriptions To simulate transactions, utilize the `.app/simulate` method for ABCI Query. ### Changes 1. change the path of ABCI Query's `.app` to the result data storage location. - You can receive the query result data as `RequestQuery.ResponseData.Data` instead of `RequestQuery.Value`. - Provide it in a common form with other ABCI Queries. 2. remove the gas-consume logic of mocking signature data that is executed when simulating transactions ([/tm2/pkg/sdk/auth/ante.go#L231-L237](https://github.com/gnolang/gno/blob/master/tm2/pkg/sdk/auth/ante.go#L231-L237)) - We will get the correct value when simulating a real transaction. - We want transactions to run without signatures, but we already have checks in place to see if a signature exists. ([tm2/pkg/sdk/auth/ante.go#L104-L106](https://github.com/gnolang/gno/blob/master/tm2/pkg/sdk/auth/ante.go#L104-L106)) ### Example #### [Request Simulate] ```curl curl --location 'http://localhost:26657' \ --header 'Content-Type: application/json' \ --data '{ "id": 1, "jsonrpc": "2.0", "method": "abci_query", "params": [ ".app/simulate", "CnMKDS9iYW5rLk1zZ1NlbmQSYgooZzFqZzhtdHV0dTlraGhmd2M0bnhtdWhjcGZ0ZjBwYWpkaGZ2c3FmNRIoZzFmZnp4aGE1N2RoMHFndjltYTV2MzkzdXIwemV4ZnZwNmxzanBhZRoMNTAwMDAwMHVnbm90Eg4IgIl6EggzMDB1Z25vdBp+CjoKEy90bS5QdWJLZXlTZWNwMjU2azESIwohA+FhNtsXHjLfSJk1lB8FbiL4mGPjc50Kt81J7EKDnJ2yEkCrIOTBt7YcDGcQ6Ohfv1r3nftAPaTATAtPfYD5zLQf7WDf1KPvWARe//CANtLLtIzcPVl7P/HnHxmfCYEwfGogIgUxMjMxMw==", "0", false ] }' ``` #### [Response] ```curl { "jsonrpc": "2.0", "id": 1, "result": { "response": { "ResponseBase": { "Error": null, "Data": "eyJFcnJvciI6bnVsbCwiRGF0YSI6IiIsIkV2ZW50cyI6W10sIkxvZyI6Im1zZzowLHN1Y2Nlc3M6dHJ1ZSxsb2c6LGV2ZW50czpbXSIsIkluZm8iOiIiLCJHYXNXYW50ZWQiOjEwMDAwMDAsIkdhc1VzZWQiOjQ0NjI5fQ==", "Events": null, "Log": "", "Info": "" }, "Key": null, "Value": null, "Proof": null, "Height": "0" } } } ``` ### Related Issue - #1826 <details><summary>Contributors' checklist...</summary> - [x] Added new tests, or not needed, or not feasible - [ ] Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory - [ ] Updated the official documentation or not needed - [ ] No breaking changes were made, or a `BREAKING CHANGE: xxx` message was included in the description - [x] Added references to related issues and PRs - [x] Provided any useful hints for running manual tests </details> --------- Co-authored-by: n3wbie <[email protected]> Co-authored-by: Miloš Živković <[email protected]>
<!-- please provide a detailed description of the changes made in this pull request. --> ## Descriptions To simulate transactions, utilize the `.app/simulate` method for ABCI Query. ### Changes 1. change the path of ABCI Query's `.app` to the result data storage location. - You can receive the query result data as `RequestQuery.ResponseData.Data` instead of `RequestQuery.Value`. - Provide it in a common form with other ABCI Queries. 2. remove the gas-consume logic of mocking signature data that is executed when simulating transactions ([/tm2/pkg/sdk/auth/ante.go#L231-L237](https://github.com/gnolang/gno/blob/master/tm2/pkg/sdk/auth/ante.go#L231-L237)) - We will get the correct value when simulating a real transaction. - We want transactions to run without signatures, but we already have checks in place to see if a signature exists. ([tm2/pkg/sdk/auth/ante.go#L104-L106](https://github.com/gnolang/gno/blob/master/tm2/pkg/sdk/auth/ante.go#L104-L106)) ### Example #### [Request Simulate] ```curl curl --location 'http://localhost:26657' \ --header 'Content-Type: application/json' \ --data '{ "id": 1, "jsonrpc": "2.0", "method": "abci_query", "params": [ ".app/simulate", "CnMKDS9iYW5rLk1zZ1NlbmQSYgooZzFqZzhtdHV0dTlraGhmd2M0bnhtdWhjcGZ0ZjBwYWpkaGZ2c3FmNRIoZzFmZnp4aGE1N2RoMHFndjltYTV2MzkzdXIwemV4ZnZwNmxzanBhZRoMNTAwMDAwMHVnbm90Eg4IgIl6EggzMDB1Z25vdBp+CjoKEy90bS5QdWJLZXlTZWNwMjU2azESIwohA+FhNtsXHjLfSJk1lB8FbiL4mGPjc50Kt81J7EKDnJ2yEkCrIOTBt7YcDGcQ6Ohfv1r3nftAPaTATAtPfYD5zLQf7WDf1KPvWARe//CANtLLtIzcPVl7P/HnHxmfCYEwfGogIgUxMjMxMw==", "0", false ] }' ``` #### [Response] ```curl { "jsonrpc": "2.0", "id": 1, "result": { "response": { "ResponseBase": { "Error": null, "Data": "eyJFcnJvciI6bnVsbCwiRGF0YSI6IiIsIkV2ZW50cyI6W10sIkxvZyI6Im1zZzowLHN1Y2Nlc3M6dHJ1ZSxsb2c6LGV2ZW50czpbXSIsIkluZm8iOiIiLCJHYXNXYW50ZWQiOjEwMDAwMDAsIkdhc1VzZWQiOjQ0NjI5fQ==", "Events": null, "Log": "", "Info": "" }, "Key": null, "Value": null, "Proof": null, "Height": "0" } } } ``` ### Related Issue - gnolang#1826 <details><summary>Contributors' checklist...</summary> - [x] Added new tests, or not needed, or not feasible - [ ] Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory - [ ] Updated the official documentation or not needed - [ ] No breaking changes were made, or a `BREAKING CHANGE: xxx` message was included in the description - [x] Added references to related issues and PRs - [x] Provided any useful hints for running manual tests </details> --------- Co-authored-by: n3wbie <[email protected]> Co-authored-by: Miloš Živković <[email protected]>
<!-- please provide a detailed description of the changes made in this pull request. --> ## Descriptions To simulate transactions, utilize the `.app/simulate` method for ABCI Query. ### Changes 1. change the path of ABCI Query's `.app` to the result data storage location. - You can receive the query result data as `RequestQuery.ResponseData.Data` instead of `RequestQuery.Value`. - Provide it in a common form with other ABCI Queries. 2. remove the gas-consume logic of mocking signature data that is executed when simulating transactions ([/tm2/pkg/sdk/auth/ante.go#L231-L237](https://github.com/gnolang/gno/blob/master/tm2/pkg/sdk/auth/ante.go#L231-L237)) - We will get the correct value when simulating a real transaction. - We want transactions to run without signatures, but we already have checks in place to see if a signature exists. ([tm2/pkg/sdk/auth/ante.go#L104-L106](https://github.com/gnolang/gno/blob/master/tm2/pkg/sdk/auth/ante.go#L104-L106)) ### Example #### [Request Simulate] ```curl curl --location 'http://localhost:26657' \ --header 'Content-Type: application/json' \ --data '{ "id": 1, "jsonrpc": "2.0", "method": "abci_query", "params": [ ".app/simulate", "CnMKDS9iYW5rLk1zZ1NlbmQSYgooZzFqZzhtdHV0dTlraGhmd2M0bnhtdWhjcGZ0ZjBwYWpkaGZ2c3FmNRIoZzFmZnp4aGE1N2RoMHFndjltYTV2MzkzdXIwemV4ZnZwNmxzanBhZRoMNTAwMDAwMHVnbm90Eg4IgIl6EggzMDB1Z25vdBp+CjoKEy90bS5QdWJLZXlTZWNwMjU2azESIwohA+FhNtsXHjLfSJk1lB8FbiL4mGPjc50Kt81J7EKDnJ2yEkCrIOTBt7YcDGcQ6Ohfv1r3nftAPaTATAtPfYD5zLQf7WDf1KPvWARe//CANtLLtIzcPVl7P/HnHxmfCYEwfGogIgUxMjMxMw==", "0", false ] }' ``` #### [Response] ```curl { "jsonrpc": "2.0", "id": 1, "result": { "response": { "ResponseBase": { "Error": null, "Data": "eyJFcnJvciI6bnVsbCwiRGF0YSI6IiIsIkV2ZW50cyI6W10sIkxvZyI6Im1zZzowLHN1Y2Nlc3M6dHJ1ZSxsb2c6LGV2ZW50czpbXSIsIkluZm8iOiIiLCJHYXNXYW50ZWQiOjEwMDAwMDAsIkdhc1VzZWQiOjQ0NjI5fQ==", "Events": null, "Log": "", "Info": "" }, "Key": null, "Value": null, "Proof": null, "Height": "0" } } } ``` ### Related Issue - gnolang#1826 <details><summary>Contributors' checklist...</summary> - [x] Added new tests, or not needed, or not feasible - [ ] Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory - [ ] Updated the official documentation or not needed - [ ] No breaking changes were made, or a `BREAKING CHANGE: xxx` message was included in the description - [x] Added references to related issues and PRs - [x] Provided any useful hints for running manual tests </details> --------- Co-authored-by: n3wbie <[email protected]> Co-authored-by: Miloš Živković <[email protected]>
Description
This effort covers the introduction of gas estimation functionality for transactions.
Copied from an issue on the Gno repo:
For users to send transactions that will eventually be committed to the Gno chain, they essentially need to provided 2 pieces of information gas-wise:
Currently, gas estimation is not possible for a client application interacting with gno, and therefore applications and users need to guess the gas limit. If they guess incorrectly (too low), their transaction is rejected as being underpriced.
Additionally, there is the problem of gas fees being fixed to 1GNOT (
1000000ugnot
), as outlined in issue #649.Ethereum has support for gas estimations with the following RPC endpoints:
eth_estimateGas
- returns the lowest gas limit at which the transaction is successful. It finds the lowest value by doing a binary search over the gas range, and executing the transaction for each (middle) value in that rangeeth_gasPrice
- returns the current average gas price for a (any) transaction, in wei. Usually, this average is implemented as a rolling average value, and is tied temporally to the node serving the call (the average is reset when the node is restarted)Successful outcome of this effort:
The text was updated successfully, but these errors were encountered: