-
Notifications
You must be signed in to change notification settings - Fork 3
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
Rename the existing transaction
to transactionWatch
and add a new different transaction
namespace
#77
Conversation
I'm conflicted about whether the JSON-RPC server should perform a transaction validation. Currently, a JSON-RPC client could abuse this function to make a JSON-RPC server broadcast invalid transactions. This will lead to the server losing reputation. It could be a good idea to force the server to validate the transaction against its current best block (intentionally not saying which one) before broadcasting, but in that case the question is what to do if the transaction is invalid. It feels a bit stupid to just do nothing, but on the other hand reporting the problem to the JSON-RPC client leads to more complications. |
I guess the point of this method is just so that if the client is already downloading and checking block bodies anyway, it can avoid calling (In Subxt's case, since it can talk to RPC nodes too, it's probably always preferable to call Forcing validation and avoiding the client needing to do that step (and being able to broadcast invalid transactions etc) makes sense to me. What are the complications of returning an error if it is/becomes invalid? |
That's fine because we were already planing to use
I'm of the opinion that for any library that wants to be light-client first (not light client only, but light-client first cough 🙂), the best approach would be to use the body of the finalized blocks as the only reliable source of information for knowing exactly when a transaction is in a finalized block. On top of that, it would also be possible to use the Also, please, let's keep in mind that we would only be examining the body of the latest blocks while there are transactions "pending", which for most use-cases that's not very often. At the same time, it would make a lot of sense to develop a tiny library for those use-cases where they only need to be sending transactions very often, and they don't really care about when exactly those transactions get finished. In other words: for those use cases where they won't be caring about |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! Thanks @tomaka !
I've opened polkadot-fellows/RFCs#19 for reference |
This is problematic. I understand why you added this, but consider the following scenario: the JSON-RPC client is well informed about the latest I propose that if the server decides to validate and the validation fails, that we use the In case that it wasn't clear enough, this event that I'm suggesting would only emitted if and only if: the server decides to validate the transaction and the transaction turns out to be invalid. Otherwise, no events would be emitted. |
This is completely intended.
How would the client react, then? |
If the server may or may not not report back on the invalid state of a transaction, do we care that an invalid transaction submitted as immortal or with a fairly large mortality may require the client to download a lot of block bodies before eventually deciding to give up searching for the tx or that the mortality has expired? Or is this a case of seeing how it goes and we can add another RPC method to ask whether a transaction is in a block if that is an issue? |
It depends on the client needs, I suppose. In the case of CAPI: we would stop trying to find the transaction in the bodies of the incoming blocks, and we may decide to try the transaction again if we can determine that the validation problem was caused by a "temporary" accident due to the server lagging behind a bit. Basically, if the server is getting in the way and it's not broadcasting the transaction, then we need to know that. Otherwise, we would be under the wrong impression that the transaction is being broadcasted, when it really isn't. So, yep, if the server decides to get in the way, then it needs to let us know that the transaction was not broadcasted. In the end, the answer to this question is: it would react exactly the same as it would react if we were using |
@tomaka does my previous comment make sense to you? 🙏 Also, I apologize for the number of edits 😬. A possible alternative to the conditional |
I guess I still don't don't really see the use cases for this call over
So then, the only use case I could see for this RPC call is as a "fire and forget" type thing. For me, this isn't useful, but perhaps for others it is. Am I missing something (quite probably this is the case right now :D)? |
Let me provide some insight. 1. Significance of Latest Finalized Block: 2. Dependency between Transaction and Chainhead Functions: 3. Argument against Segregation: 4. Use Cases Illustration:
Subxt, for instance, might not fit snugly into these categories, and that's alright. But CAPI aligns with the latter. If this PR doesn't get merged, we'll resort to using Conclusion: |
Close #76
As mentioned in the title, the current
transaction
namespace is nowtransactionWatch
, and a newtransaction
namespace is added, allowing just broadcasting transactions.The new
transaction_unstable_broadcast
function is very dumb: it just broadcasts the transaction.Before calling it, it is important for the JSON-RPC client to validate the transaction (using
chainHead_call
) and check if thepropagate
field returned by the validation istrue
. The JSON-RPC server intentionally does not do either of these things.It is then the responsibility of the JSON-RPC client to download the bodies of blocks and check if the submitted transaction is there.
One drawback is that these new functions might be difficult to implement in Substrate.
cc @josepot @lexnv @jsdw