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

add status field to response in RPC methods tx, EXPERIMENTAL_tx_status, broadcast_tx_commit, broadcast_tx_async #9556

Merged
merged 1 commit into from
Oct 4, 2023

Conversation

telezhnaya
Copy link
Contributor

@telezhnaya telezhnaya commented Sep 21, 2023

This PR is a part of RPC tx methods redesign https://docs.google.com/document/d/1jGuXzBlMAGQENsUpy5x5Xd7huCLOd8k6tyMOEE41Rro/edit?usp=sharing
Addressing point 3 in #9542 and start working on #6837

Changes:

  • New field status appeared in the response of RPC methods tx, EXPERIMENTAL_tx_status, broadcast_tx_commit, broadcast_tx_async
  • Added some comments with the explanations

In #6837, Illia suggested to have the structure

enum BroadcastWait {
 /// Returns right away.
 None,
 /// Waits only for inclusion into the block.
 Inclusion,
 /// Waits until block with inclusion is finalized.
 InclusionFinal,
 /// Waits until all non-refund receipts are executed.
 Executed,
 /// Waits until all non-refund receipts are executed and the last of the blocks is final.
 ExecutedFinal,
 /// Waits until everything has executed and is final.
 Final,
 }

I've renamed it to TxExecutionStatus and simplified it a little by dropping all refund options:

  1. We may add them later without breaking backwards compatibility
  2. To support them, we need to have the access to receipt (it's the method get_tx_execution_status). We have there only execution_outcome by default. We created special logic to be able not to retrieve the receipts (it's the only difference between tx and EXPERIMENTAL_tx_status). I have a feeling (please correct me here if I'm wrong) that retrieving corresponding receipt may slow down the execution that we tried to optimise.
    BTW, maybe the data from execution_outcome is enough (we have there gas_burnt and tokens_burnt). @jakmeier suggested the condition outcome.tokens_burnt == 0 && outcome.status == Success. Unfortunately, we need to work with any status. But maybe the first part (outcome.tokens_burnt == 0) is enough to say that it could be only refund receipt. I need more input here.

@telezhnaya telezhnaya requested review from wacban and jakmeier and removed request for wacban and jakmeier September 21, 2023 15:59
@telezhnaya telezhnaya force-pushed the tx_status branch 2 times, most recently from 38de644 to 4dca195 Compare September 22, 2023 16:06
@telezhnaya
Copy link
Contributor Author

@wacban @jakmeier adding you back :)
I can't mark this PR as "ready for the review", it's still too raw.
Though I need your attention here. Could you please have a look at the general approach? Any of your input will be appreciated.

In the meantime, I'll think about tests. For now, I just roughly fixed the existing ones

@telezhnaya telezhnaya marked this pull request as ready for review September 27, 2023 09:40
@telezhnaya telezhnaya requested a review from a team as a code owner September 27, 2023 09:40
@telezhnaya telezhnaya requested a review from nikurt September 27, 2023 09:40
@telezhnaya telezhnaya changed the title add status field to response in RPC methods tx, EXPERIMENTAL_tx_status, broadcast_tx_commit add status field to response in RPC methods tx, EXPERIMENTAL_tx_status, broadcast_tx_commit, broadcast_tx_async Sep 28, 2023
Eq,
PartialEq,
)]
pub enum TxExecutionStatus {
Copy link
Contributor

@nikurt nikurt Oct 2, 2023

Choose a reason for hiding this comment

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

Thinking about the corner cases from a point of view of a user:

  • Submit a transaction
  • Transaction gets included in a block in a fork
  • See that the transaction is included in a block
  • Wait for 10s
  • See that the transaction is included in a block
  • Wait for 10s
  • .. repeat forever

Should we help the user in this case?
IIUC, this infinite loop is not possible with the execution of receipts, because the outgoing receipts of the parent block must be included in the child block.
Inclusion of transactions is different, because it is not mandatory.

A counter-argument would be that a transaction may never be included in any block by chunk producers, and we can't possibly verify this condition.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After we merge this, I'll start working on adding the same struct to the request to all the methods touched in this PR. It should solve this issue at least partially.

Thank you for the review!
I've addressed all the other comments and added the notes to CHANGELOG.md, please have a look again

@telezhnaya telezhnaya force-pushed the tx_status branch 2 times, most recently from 8243ac6 to ddb1e43 Compare October 3, 2023 19:38
Copy link
Contributor

@nikurt nikurt left a comment

Choose a reason for hiding this comment

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

👍 👍 👍

@telezhnaya telezhnaya force-pushed the tx_status branch 2 times, most recently from 3b7d40b to cb1cc58 Compare October 4, 2023 12:00
@telezhnaya telezhnaya enabled auto-merge October 4, 2023 12:03
add `final_execution_status` field to response in RPC methods:
- tx
- EXPERIMENTAL_tx_status
- broadcast_tx_commit
- broadcast_tx_async
@telezhnaya telezhnaya added this pull request to the merge queue Oct 4, 2023
Merged via the queue into near:master with commit 9c8d0bb Oct 4, 2023
@telezhnaya telezhnaya deleted the tx_status branch October 4, 2023 13:03
nikurt pushed a commit that referenced this pull request Oct 11, 2023
…atus`, `broadcast_tx_commit`, `broadcast_tx_async` (#9556)

This PR is a part of RPC tx methods redesign
https://docs.google.com/document/d/1jGuXzBlMAGQENsUpy5x5Xd7huCLOd8k6tyMOEE41Rro/edit?usp=sharing
Addressing point 3 in #9542 and
start working on #6837

Changes:
- New field `status` appeared in the response of RPC methods `tx`,
`EXPERIMENTAL_tx_status`, `broadcast_tx_commit`, `broadcast_tx_async`
- Added some comments with the explanations

In #6837, Illia suggested to have
the structure
```rust
enum BroadcastWait {
 /// Returns right away.
 None,
 /// Waits only for inclusion into the block.
 Inclusion,
 /// Waits until block with inclusion is finalized.
 InclusionFinal,
 /// Waits until all non-refund receipts are executed.
 Executed,
 /// Waits until all non-refund receipts are executed and the last of the blocks is final.
 ExecutedFinal,
 /// Waits until everything has executed and is final.
 Final,
 }
```

I've renamed it to `TxExecutionStatus` and simplified it a little by
dropping all refund options:
1. We may add them later without breaking backwards compatibility
2. To support them, we need to have the access to `receipt` (it's the
method `get_tx_execution_status`). We have there only
`execution_outcome` by default. We created special logic to be able not
to retrieve the receipts (it's the only difference between `tx` and
`EXPERIMENTAL_tx_status`). I have a feeling (please correct me here if
I'm wrong) that retrieving corresponding receipt may slow down the
execution that we tried to optimise.
BTW, maybe the data from `execution_outcome` is enough (we have there
`gas_burnt` and `tokens_burnt`). @jakmeier suggested the condition
`outcome.tokens_burnt == 0 && outcome.status == Success`. Unfortunately,
we need to work with any status. But maybe the first part
(`outcome.tokens_burnt == 0`) is enough to say that it could be only
refund receipt. I need more input here.
github-merge-queue bot pushed a commit that referenced this pull request Oct 24, 2023
…, add method `broadcast_tx` (#9644)

Fixes #6837

I'll need to update the [docs](/~https://github.com/near/docs) and
[jsonrpc_client](/~https://github.com/near/near-jsonrpc-client-rs) (and
maybe something else, I haven't already checked)

Important updates:
1. We have a new concept for all tx-related methods - `finality`.
`finality` in the response is merged to master 2 weeks ago:
#9556. `finality` field in the
request means "I want at least this level of confidence". So, the
stricter the level, the longer the user needs to wait.
2. I decided to use `Final` as a default `finality` value because it
gives the strongest guarantee and does not change backward compatibility
for any of the methods (though, the waiting time may be increased
sometimes to achieve the strictest level of confidence).
3. Methods `tx`, `EXPERIMENTAL_tx_status` have `finality` as an
additional optional field.
4. A new method appeared - `broadcast_tx`. It allows to send the tx, it
also have the optional field `finality`.
6. `broadcast_tx_async` is equal to `broadcast_tx` with hardcoded
`finality None`, I'll mark it as deprecated in the doc
7. `broadcast_tx_commit` is equal to `broadcast_tx` with hardcoded
`finality Final`, I'll mark it as deprecated in the doc.
nikurt pushed a commit that referenced this pull request Nov 2, 2023
…, add method `broadcast_tx` (#9644)

Fixes #6837

I'll need to update the [docs](/~https://github.com/near/docs) and
[jsonrpc_client](/~https://github.com/near/near-jsonrpc-client-rs) (and
maybe something else, I haven't already checked)

Important updates:
1. We have a new concept for all tx-related methods - `finality`.
`finality` in the response is merged to master 2 weeks ago:
#9556. `finality` field in the
request means "I want at least this level of confidence". So, the
stricter the level, the longer the user needs to wait.
2. I decided to use `Final` as a default `finality` value because it
gives the strongest guarantee and does not change backward compatibility
for any of the methods (though, the waiting time may be increased
sometimes to achieve the strictest level of confidence).
3. Methods `tx`, `EXPERIMENTAL_tx_status` have `finality` as an
additional optional field.
4. A new method appeared - `broadcast_tx`. It allows to send the tx, it
also have the optional field `finality`.
6. `broadcast_tx_async` is equal to `broadcast_tx` with hardcoded
`finality None`, I'll mark it as deprecated in the doc
7. `broadcast_tx_commit` is equal to `broadcast_tx` with hardcoded
`finality Final`, I'll mark it as deprecated in the doc.
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.

3 participants