-
Notifications
You must be signed in to change notification settings - Fork 118
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
RFC: Transaction Flow (parity of behavior between localBlockchain and Testnet) #824
Comments
Thanks for the proposal @rpanic! I like it a lot:
I have a few comments: Errors The change from Therefore, I propose to add an alternative method which retains the old behavior (of throwing an error), and implement this method on both
Minor comment: Let's rename It's unclear to me how One question/thought: There may be a difference in what errors the Mina node returns from GraphQL (subset of errors that can occur in the transaction logic, but some additional checks done before entering the transaction pool) vs what the local blockchain returns from
Yes, we can implement |
Thanks for your comments! I like the idea of adding a method that would throw if errors occurred. I would go with
Renaming makes a lot of sense!
I think that ideally we can also make both implementations consistent, but that kind of comes in tandem with the simulation argument above. It makes no sense to check for things that we don't keep track of in the localblockchain. I think even if there is some discrepancy of errors returned on |
@Trivo25 could you take a look at this too please? Important enough to have a couple reviewers. After your conference. |
No further comments to add. I think it would be great to get the tx e2e flow for both the LocalBlockchain and the live Network up to sync. Ideally, without simulating blocks on the JS side (imo). |
Prioritised. First step is to make choices as peresented by this RFC, copy it over to the RFC repo, and present it to architects and community. The work will follow from there. |
This comment is a continuation of what was proposed earlier in this issue. I will attempt to make a finalization on all the choices for the work that is to follow. Proposed changesIn an effort to consolidate the API between the local blockchain and remote blockchain APIs, I propose we make the following changes: Add
|
Very nice @MartinMinkov, I'm excited for this to land! I only have a comment on clarifying the behaviour of // does not throw
Transaction.send(): Promise<PendingTransaction>;
// throws if and only if `.send()` would have an `.errors` property; otherwise same behaviour
Transaction.sendOrThrow(): Promise<PendingTransaction>;
// does not throw
PendingTransaction.wait(): Promise<IncludedTransaction>;
// throws if and only if `.wait()` would have an `.errors` property; otherwise same behaviour
PendingTransaction.waitOrThrow(): Promise<IncludedTransaction>; comment on the name In Ocaml there is a very consistent convention of having |
Thanks @MartinMinkov. Looks great! Would it be possible to extend the testing plan a bit? You already do this for the section on parity between |
Sounds good! I added a |
Motivation & Current State
The sending of Transactions and subsequent status retrieval is inconsistent between local and remote implementations and additionally re-uses the TransactionId and re-uses properties for different functionality.
As an example, in remote networks,
TransactionId.isSuccess
is used for both the indication that the sending of the transaction has succeeded and does not work correctly after calling.wait()
. See #819In comparison, LocalBlockchain throws at
.send()
if the transaction cannot be applied to the ledger, and does not implement .wait().Altough the interface for these implementation is the same, the behaviour is completely different and leads to worse developer experience and extra effort to check for those things in scripts.
Proposed changes
I propose an extension to the current API which aligns both implementations and seperates concerns into different classes.
Where TransactionId uniformly implements properties as:
isSuccess
: The Transaction is well-formed and passes initial checks by the node (I think the mina node primarily checks some nonce preconditions and the fee payer)errors
: Error[] that occurredhash()
: Returns the hash of the txidwait()
: Waits for the tx to be mined (details below)The first implementation spec only needs an default mina node
isIncluded
: The tx got included in a block (is only false if errors occurred)errors
: Error[] that occurredThe second possibility would extend the above and involve the new archive-node api:
getInfo() : Promise<IncludedTransactionInfo>
: Retrieves information about the mined transaction from an archive node.IncludedTransactionInfo would include inclusion-time errors, block info. This method would throw if no archive node url has been specified for remote networks.
This should be an extra method in order to allow operation without an archive-node api, as is the current interface for remote networks.
Reliably usage would depend on Archive-Node-API#69 being implemented.
Things I am not sure about
hash() is currently taken from the graphql response. I don't know why but it seems that this should be possible to do in snarkyjs
The text was updated successfully, but these errors were encountered: