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

rpc: ignore refunds in RPC tx methods #10948

Merged
merged 1 commit into from
Apr 5, 2024
Merged

Conversation

telezhnaya
Copy link
Contributor

@telezhnaya telezhnaya commented Apr 4, 2024

(drums)
Resolves #6834

This PR changes the default behaviour of broadcast_tx_commit, send_tx, tx, EXPERIMENTAL_tx_status RPC methods. We no longer wait for refund receipts by default.
If you do need to wait for refund receipts, you need ask about it explicitly by using TxExecutionStatus::Final option ("wait_until": "FINAL" in the json request).

[We had a discussion with @bowenwang1996 about the case described below, tldr: he thinks it's unreachable. I haven't reproduced it, but I still think it may be an issue. I'm investigating, leave it here for now]

Ugly side-effect:
Sometimes, the response for any of mentioned methods may look like

{
  "jsonrpc": "2.0",
  "result": {
    "final_execution_status": "EXECUTED_OPTIMISTIC",
    "status": "Started",
  ...
}

The full response format may be found here

status field corresponds to FinalExecutionStatus structure:

pub enum FinalExecutionStatus {
    /// The execution has not yet started.
    #[default]
    NotStarted,
    /// The execution has started and still going.
    Started,
    /// The execution has failed with the given error.
    Failure(TxExecutionError),
    /// The execution has succeeded and returned some value or an empty vec encoded in base64.
    SuccessValue(#[serde_as(as = "Base64")] Vec<u8>),
}

In status, we store the result of all the execution process, which, strictly saying, is not finalised without refund receipts.
So, in the example above, final_execution_status conflicts with status. We say "it's executed, but not really", which may be confusing for the users.
Replacing status with some other value would be even a bigger problem. Current situation is a weird truth. Replaced value would be a lie, which is much worse.
Ideally, I'd prefer to drop status field from the response, but it's impossible because of compatibility reasons.

Copy link
Member

@Longarithm Longarithm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

chain/client/src/view_client.rs Show resolved Hide resolved
@telezhnaya telezhnaya added this pull request to the merge queue Apr 5, 2024
Merged via the queue into near:master with commit e96db70 Apr 5, 2024
22 of 24 checks passed
@telezhnaya telezhnaya deleted the refunds branch April 5, 2024 22:12
github-merge-queue bot pushed a commit that referenced this pull request Apr 5, 2024
This PR is based on #10948 because
it touches the same places
It's better to look at the separate commits

So first commit can be reviewed separately in
#10948

Second commit is a partial revert of
#10792
I just returned this piece back, no changes is made

https://github.com/near/nearcore/pull/10792/files#diff-ef9c6aaa80a330e446c5365f42be9bff37ba4f898cf519dadd7e17545783c77cL3099-L3126

Third commit is the meaningful part. We need to adjust the logic with
the old implementation.
1. We now treat incomplete list of the receipts as a valid state. It
means no `expect` usage, handle empty list of outcomes
2. We no longer can use `status` field for `finalExecutionStatus`
github-merge-queue bot pushed a commit that referenced this pull request Apr 6, 2024
With the changes made in #10948, we may no longer see refund receipts in
the result.
VanBarbascu pushed a commit that referenced this pull request Apr 8, 2024
(drums)
Resolves #6834 

This PR changes the default behaviour of `broadcast_tx_commit`,
`send_tx`, `tx`, `EXPERIMENTAL_tx_status` RPC methods. We no longer wait
for refund receipts by default.
If you do need to wait for refund receipts, you need ask about it
explicitly by using `TxExecutionStatus::Final` option (`"wait_until":
"FINAL"` in the json request).

[We had a discussion with @bowenwang1996 about the case described below,
tldr: he thinks it's unreachable. I haven't reproduced it, but I still
think it may be an issue. I'm investigating, leave it here for now]

Ugly side-effect:
Sometimes, the response for any of mentioned methods may look like
```json

{
  "jsonrpc": "2.0",
  "result": {
    "final_execution_status": "EXECUTED_OPTIMISTIC",
    "status": "Started",
  ...
}
```
The full response format may be found
[here](https://docs.near.org/api/rpc/transactions)

`status` field corresponds to [`FinalExecutionStatus`
structure](https://github.com/near/nearcore/blob/master/core/primitives/src/views.rs#L1354-L1364):
```rust
pub enum FinalExecutionStatus {
    /// The execution has not yet started.
    #[default]
    NotStarted,
    /// The execution has started and still going.
    Started,
    /// The execution has failed with the given error.
    Failure(TxExecutionError),
    /// The execution has succeeded and returned some value or an empty vec encoded in base64.
    SuccessValue(#[serde_as(as = "Base64")] Vec<u8>),
}
```


In `status`, we store the result of all the execution process, which,
strictly saying, is not finalised without refund receipts.
So, in the example above, `final_execution_status` conflicts with
`status`. We say "it's executed, but not really", which may be confusing
for the users.
Replacing `status` with some other value would be even a bigger problem.
Current situation is a weird truth. Replaced value would be a lie, which
is much worse.
Ideally, I'd prefer to drop `status` field from the response, but it's
impossible because of compatibility reasons.
VanBarbascu pushed a commit that referenced this pull request Apr 8, 2024
This PR is based on #10948 because
it touches the same places
It's better to look at the separate commits

So first commit can be reviewed separately in
#10948

Second commit is a partial revert of
#10792
I just returned this piece back, no changes is made

https://github.com/near/nearcore/pull/10792/files#diff-ef9c6aaa80a330e446c5365f42be9bff37ba4f898cf519dadd7e17545783c77cL3099-L3126

Third commit is the meaningful part. We need to adjust the logic with
the old implementation.
1. We now treat incomplete list of the receipts as a valid state. It
means no `expect` usage, handle empty list of outcomes
2. We no longer can use `status` field for `finalExecutionStatus`
VanBarbascu pushed a commit that referenced this pull request Apr 8, 2024
(drums)
Resolves #6834 

This PR changes the default behaviour of `broadcast_tx_commit`,
`send_tx`, `tx`, `EXPERIMENTAL_tx_status` RPC methods. We no longer wait
for refund receipts by default.
If you do need to wait for refund receipts, you need ask about it
explicitly by using `TxExecutionStatus::Final` option (`"wait_until":
"FINAL"` in the json request).

[We had a discussion with @bowenwang1996 about the case described below,
tldr: he thinks it's unreachable. I haven't reproduced it, but I still
think it may be an issue. I'm investigating, leave it here for now]

Ugly side-effect:
Sometimes, the response for any of mentioned methods may look like
```json

{
  "jsonrpc": "2.0",
  "result": {
    "final_execution_status": "EXECUTED_OPTIMISTIC",
    "status": "Started",
  ...
}
```
The full response format may be found
[here](https://docs.near.org/api/rpc/transactions)

`status` field corresponds to [`FinalExecutionStatus`
structure](https://github.com/near/nearcore/blob/master/core/primitives/src/views.rs#L1354-L1364):
```rust
pub enum FinalExecutionStatus {
    /// The execution has not yet started.
    #[default]
    NotStarted,
    /// The execution has started and still going.
    Started,
    /// The execution has failed with the given error.
    Failure(TxExecutionError),
    /// The execution has succeeded and returned some value or an empty vec encoded in base64.
    SuccessValue(#[serde_as(as = "Base64")] Vec<u8>),
}
```


In `status`, we store the result of all the execution process, which,
strictly saying, is not finalised without refund receipts.
So, in the example above, `final_execution_status` conflicts with
`status`. We say "it's executed, but not really", which may be confusing
for the users.
Replacing `status` with some other value would be even a bigger problem.
Current situation is a weird truth. Replaced value would be a lie, which
is much worse.
Ideally, I'd prefer to drop `status` field from the response, but it's
impossible because of compatibility reasons.
VanBarbascu pushed a commit that referenced this pull request Apr 8, 2024
This PR is based on #10948 because
it touches the same places
It's better to look at the separate commits

So first commit can be reviewed separately in
#10948

Second commit is a partial revert of
#10792
I just returned this piece back, no changes is made

https://github.com/near/nearcore/pull/10792/files#diff-ef9c6aaa80a330e446c5365f42be9bff37ba4f898cf519dadd7e17545783c77cL3099-L3126

Third commit is the meaningful part. We need to adjust the logic with
the old implementation.
1. We now treat incomplete list of the receipts as a valid state. It
means no `expect` usage, handle empty list of outcomes
2. We no longer can use `status` field for `finalExecutionStatus`
bowenwang1996 added a commit that referenced this pull request Apr 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Transaction status query should not wait for refunds to finish
2 participants