forked from gnolang/gno
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Modify
app
path method to simulate for ABCI query (gnolang#3207)
<!-- 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]>
- Loading branch information
1 parent
9156613
commit 936ade0
Showing
5 changed files
with
75 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# load the package | ||
loadpkg gno.land/r/simulate $WORK/simulate | ||
|
||
# start a new node | ||
gnoland start | ||
|
||
# simulate only | ||
gnokey maketx call -pkgpath gno.land/r/simulate -func Hello -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test -simulate only test1 | ||
stdout 'GAS USED: 50299' | ||
|
||
# simulate skip | ||
gnokey maketx call -pkgpath gno.land/r/simulate -func Hello -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test -simulate skip test1 | ||
stdout 'GAS USED: 50299' # same as simulate only | ||
|
||
|
||
-- package/package.gno -- | ||
package call_package | ||
|
||
func Render() string { | ||
return "notok" | ||
} | ||
|
||
-- simulate/simulate.gno -- | ||
package simulate | ||
|
||
func Hello() string { | ||
return "Hello" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters