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 end point with more fine grained tx status #9542

Closed
telezhnaya opened this issue Sep 20, 2023 · 3 comments
Closed

RPC end point with more fine grained tx status #9542

telezhnaya opened this issue Sep 20, 2023 · 3 comments
Assignees

Comments

@telezhnaya
Copy link
Contributor

I want to rework tx and EXPERIMENTAL_tx_status methods:

  1. I want to add include_receipts flag to tx method (default false, it saves backward compatibility). true will return the result from EXPERIMENTAL_tx_status
  2. The new flag will allow us to deprecate EXPERIMENTAL_tx_status and hopefully we may drop it in one day. It's not experimental from it's very first day
  3. (most important for me) I want to redesign the way how and when we return the response. Right now, we are uncertain which receipts are finalised, which are not, and we ask the users to re-check this. The doc is full of ambiguity. Change tx status method doc docs#1499
    I suggest to add to response the new enum value, as Illia suggested in RPC end point to configure broadcast transaction await #6837, it will answer what is the status of the execution.
@jakmeier
Copy link
Contributor

Great idea to clean this up!

Disclaimer, my knowledge here is not perfect on how these endpoints work. But I'll try to explain how I think it works today.

I believe both endpoints look up recursively all execution statuses of the receipts DAG, then they aggregate the status of all receipts into a single FinalExecutionStatus. Aggregation is a bit weird, in each step it only looks at the first (or last?) outgoing receipt and takes the result of that IIRC. This means if two receipts spawn and the first returns SuccessValue then it doesn't matter if the second receipt has failed, succeeded, or hasn't even started execution yet.

The FinalExecutionStatus we return, I think , has zero finality guarantees (as in blockchain finality). In my understanding, it corresponds to BroadcastWait::Executed.

However, putting finality aside, for some reason I used to think EXPERIMENTAL_tx_status waits for all execution outcomes (BroadcastWait::Executed) but tx doesn't (BroadcastWait::Inclusion). But I am no longer sure. The code looks to me like both endpoints behave the same, except the experimental call also includes receipts. And I think actually both wait for all outcomes to be known, at least that's how I understand the description in #6834.


So much about what the status quo is. I think the ideal API would be exactly as you describe in points 1,2,3. But for the aggregated status, I would probably keep it as is but at least make it much clearer in the documentation what it means.

@wacban
Copy link
Contributor

wacban commented Sep 20, 2023

I like the idea of reusing the same wait enum for both broadcast and status endpoints. I have no clue how do clients actually use the endpoint so it's hard to say for me what is the best design. Logically speaking there are three separate functionalities that we're considering: broadcast, status and wait. Today 'wait' seems to be integrated into the other two in one way or another. Depending on the client usage it may make sense to add the WaitCondition as either an argument, return value or both for both endpoints. I think what you're suggesting is one viable option.

At the end of the day what matters is that the API is usable and well documented so any improvement is welcome.

github-merge-queue bot pushed a commit that referenced this issue Oct 4, 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.
nikurt pushed a commit that referenced this issue 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.
@telezhnaya
Copy link
Contributor Author

Done 😎

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

No branches or pull requests

3 participants