Skip to content
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

fix: Modify app path method to simulate for ABCI query #3207

Conversation

jinoosss
Copy link
Member

@jinoosss jinoosss commented Nov 26, 2024

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.
  1. remove the gas-consume logic of mocking signature data that is executed when simulating transactions (/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)

Example

[Request Simulate]

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]

{
  "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

Contributors' checklist...
  • 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
  • Added references to related issues and PRs
  • Provided any useful hints for running manual tests

@github-actions github-actions bot added the 📦 🌐 tendermint v2 Issues or PRs tm2 related label Nov 26, 2024
Copy link

codecov bot commented Nov 26, 2024

Codecov Report

Attention: Patch coverage is 57.14286% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
tm2/pkg/sdk/baseapp.go 57.14% 1 Missing and 2 partials ⚠️

📢 Thoughts on this report? Let us know!

@jinoosss jinoosss force-pushed the fix/modify-app-path-method-to-utilize-simulator-for-abci-queries branch from dd4ec33 to 1ad2433 Compare November 27, 2024 02:53
@jinoosss jinoosss marked this pull request as ready for review November 27, 2024 07:08
@zivkovicmilos zivkovicmilos self-requested a review November 27, 2024 08:17
@github-actions github-actions bot added the 📦 ⛰️ gno.land Issues or PRs gno.land package related label Nov 27, 2024
@zivkovicmilos
Copy link
Member

zivkovicmilos commented Nov 27, 2024

@jinoosss

I'm not sure if this part is needed anymore in ProcessPubKey:

	if simulate {
		// In simulate mode the transaction comes with no signatures, thus if the
		// account's pubkey is nil, both signature verification and gasKVStore.Set()
		// shall consume the largest amount, i.e. it takes more gas to verify
		// secp256k1 keys than ed25519 ones.
		if pubKey == nil {
			return simSecp256k1Pubkey, sdk.Result{}
		}

		return pubKey, sdk.Result{}
	}

Can you please check? 🙏

tm2/pkg/sdk/baseapp_test.go Outdated Show resolved Hide resolved
tm2/pkg/sdk/baseapp.go Outdated Show resolved Hide resolved
tm2/pkg/sdk/baseapp.go Outdated Show resolved Hide resolved
@zivkovicmilos zivkovicmilos requested a review from piux2 November 27, 2024 08:27
@jinoosss jinoosss force-pushed the fix/modify-app-path-method-to-utilize-simulator-for-abci-queries branch from e98b1f8 to 4cf5e1c Compare November 27, 2024 08:32
@jinoosss jinoosss force-pushed the fix/modify-app-path-method-to-utilize-simulator-for-abci-queries branch from ad14e18 to 692f2bb Compare November 27, 2024 09:58
@Kouteki Kouteki added this to the 🚀 Mainnet launch milestone Nov 27, 2024
@Kouteki Kouteki added the in focus Core team is prioritizing this work label Nov 27, 2024
@zivkovicmilos
Copy link
Member

@jinoosss

I've dug into this a bit, and I believe we should stick to using ResponseQuery.Value to transfer the response of the query.

It's seems to be a standard practice in Cosmos, that query results are stored within the response query Value. (It's the value part of the key query)

ResponseBase.Data is typically used for additional metadata or any auxiliary information that may accompany the primary response (in ResponseQuery.Value).

I'm sorry for the change-up, we should switch to using ResponseQuery.Value as it was 🙏

@zivkovicmilos
Copy link
Member

@jinoosss
Did you get a chance to check this? 👀
#3207 (comment)

@jinoosss
Copy link
Member Author

@zivkovicmilos ,
Thank you for checking it out.

Let's check the following
#3207 (comment)

@jinoosss
Copy link
Member Author

@jinoosss

I'm not sure if this part is needed anymore in ProcessPubKey:

	if simulate {
		// In simulate mode the transaction comes with no signatures, thus if the
		// account's pubkey is nil, both signature verification and gasKVStore.Set()
		// shall consume the largest amount, i.e. it takes more gas to verify
		// secp256k1 keys than ed25519 ones.
		if pubKey == nil {
			return simSecp256k1Pubkey, sdk.Result{}
		}

		return pubKey, sdk.Result{}
	}

Can you please check? 🙏

I think it's fine to remove it.

The account coming in as an argument is generated from the transaction's signature.

The contents of the pubKey == nil condition is not executed because this logic is checked against the transaction before it is executed.

@Gno2D2
Copy link
Collaborator

Gno2D2 commented Dec 4, 2024

I'm a bot that assists the Gno Core team in maintaining this repository. My role is to ensure that contributors understand and follow our guidelines, helping to streamline the development process.

The following requirements must be fulfilled before a pull request can be merged.
Some requirement checks are automated and can be verified by the CI, while others need manual verification by a staff member.

These requirements are defined in this configuration file.

Automated Checks

🟢 Maintainers must be able to edit this pull request
🟢 The pull request head branch must be up-to-date with its base

Manual Checks

  • The pull request description provides enough details (checked by @zivkovicmilos)
Debug
Automated Checks
Maintainers must be able to edit this pull request

If

🟢 Condition met
└── 🟢 On every pull request

Then

🟢 Requirement satisfied
└── 🟢 Maintainer can modify this pull request

The pull request head branch must be up-to-date with its base

If

🟢 Condition met
└── 🟢 On every pull request

Then

🟢 Requirement satisfied
└── 🟢 Head branch (jinoosss:fix/modify-app-path-method-to-utilize-simulator-for-abci-queries) is up to date with base (master): behind by 0 / ahead by 15

Manual Checks
The pull request description provides enough details

If

🟢 Condition met
└── 🟢 Not (🔴 Pull request author is a member of the team: core-contributors)

Can be checked by

  • team core-contributors

@zivkovicmilos zivkovicmilos merged commit 2496db7 into gnolang:master Dec 4, 2024
102 of 103 checks passed
omarsy pushed a commit to TERITORI/gno that referenced this pull request Dec 7, 2024
<!-- 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]>
r3v4s added a commit to gnoswap-labs/gno that referenced this pull request Dec 10, 2024
<!-- 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in focus Core team is prioritizing this work 📦 🌐 tendermint v2 Issues or PRs tm2 related 📦 ⛰️ gno.land Issues or PRs gno.land package related
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

5 participants