0069 XLS-69d: Simulating Transaction Execution #199
Replies: 7 comments 16 replies
-
It might be better to clearly note that there is no guarantee that the results of |
Beta Was this translation helpful? Give feedback.
-
I am slightly worried about the cost of processing such transactions in validators. We know there are certain transactions which can be expensive to process e.g. in terms of CPU time, and it would be pretty bad if validators started processing these in large numbers, without actual change in the ledger, but with all the associated data processing cost. To address this concern, I would suggest to add an error code |
Beta Was this translation helpful? Give feedback.
-
This functionality seems useful, however, I wanted to clarify the underlying purpose. Do you see this as predictive of the outcome of large or complex transactions (i.e., the volume of currency that is delivered), or is this targeted toward ensuring the transaction is formatted and submitted correctly? Given how dependent transaction outcomes are on the Ledger's state, it seems the former would not be possible, as the state could change substantially in the interval between the simulated and real transactions (even if the real tx hits in the subsequent ledger to the simulation). If the latter, I'm curious how the simulated transaction benefits from being tested on the main network. I admit it is more convenient not to switch networks, but it's realistically not a massive barrier. Perhaps access to more paths and liquidity could give a more accurate simulation? Finally, is there reason to believe a simulated transaction could take more resources than the actual transaction? It seems like the actual would always take more, since the signature needs to be verified, so I'm interested in the line where this would become admin only. |
Beta Was this translation helpful? Give feedback.
-
I love it, it's an excellent feature! Though, I do have one concern. While a malicious node cannot submit these transactions, they can replay them. For instance, imagine someone is testing a valuable DEX trade. A malicious node will gain information that a trader might submit this transaction in the future or verify that executing this trade is profitable. Before the user submits the real transaction, the malicious node might submit the same transaction using their own private account. That is to say; I think it's important to also caveat this API endpoint that it should only be called on trusted nodes or, even better, on one's own node. |
Beta Was this translation helpful? Give feedback.
-
So with this attack, I wouldn't be submitting your transaction, but mine.
It would just do exactly the same thing as yours. The absence of the
signature doesn't help against this
…On Tue, Jun 4, 2024, 17:20 Mayukha Vadari ***@***.***> wrote:
The signature *must not* be included in simulate, for that exact reason.
Great, thanks - I missed this part. I suggest the error in this case
should be the same as if the signature was invalid, i.e. temBAD_SIGNATURE
In that case, the error will be an RPC-level error. I'd prefer if the
transaction processing part of rippled isn't entered *at all* if there is
a signature included in the transaction.
—
Reply to this email directly, view it on GitHub
<#199 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABMDKUYLJ5A2WSDOC3MYAUDZFXSOBAVCNFSM6AAAAABIXCEIZSVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4TMNRXGEYTK>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Per the new XLS Contributing process, it is my opinion that we have reached a "well-refined standard." As such, I propose that we move this discussion to a file (via #207) and work on final changes using additional PRs, for better change-tracking. Please comment here if you would like to object to moving this spec/discussion forward in the process into a DRAFT spec. (Note that per the Contributing guidelines, moving a spec into the DRAFT state does not mean any kind of endorsement, nor does it mean that this specification will become adopted. It is solely meant as a mechanism to enable better change tracking using PRs.) |
Beta Was this translation helpful? Give feedback.
-
Closing this discussion since the spec has been initially merged via #207. For further discussion or changes, please open a PR on XLS-69d. |
Beta Was this translation helpful? Give feedback.
-
An updated version of this spec can be found here: XLS-69d: Simulate.
The earlier version follows:
Simulating Transaction Execution
Abstract
The XRPL protocol supports numerous different transaction types, with more being added over time. Many transactions are complex and can have numerous modes, flags, and parameters. Some combinations of these can lead to unpredictable results, especially since transactions frequently behave differently depending on the current state of the ledger. This is particularly paramount for high-value transactions, as it is crucial to understand the likely outcome of the transaction and ensure that its effects align with expectations.
This proposal puts forth a new API method, tentatively titled
simulate
, which executes a dry run of a transaction submission. Unlike the existingsubmit
function,simulate
never submits the transaction to the network. This allows users to test transactions and preview their results (including metadata) without committing them to the XRP Ledger.The
simulate
API method offers an efficient way to safely experiment with transactions on any ledger, such as the Mainnet ledger. Unlike using test networks, which can require faithfully replicating an entire scenario for experimentation,simulate
allows users to "apply" transactions to a Mainnet (or other) ledger without actually submitting the transaction to be applied permanently. This allows developers and users to test and refine their transactions with confidence before committing them for real.1. Overview
This spec proposes a new RPC method called
simulate
.This method has no effect on consensus or transaction processing. Therefore, this feature will not require an amendment.
2. RPC:
simulate
The
simulate
method applies a transaction (and returns the result and metadata for review), but will never send it to the network to be confirmed or included in future ledgers. It can be thought of as a dry-run of thesubmit
method. This method can be used to preview the potential results and effects (via the metadata) of a potential transaction, without actually sending it to the wider network.2.1. Request Fields
tx_blob
string
tx_json
object
binary
boolean
true
, return transaction data and metadata as binary serialized to hexadecimal strings. Iffalse
, return transaction data and metadata as JSON. The default isfalse
.A valid request must have exactly one of
tx_blob
ortx_json
included. The transaction must be unsigned.If the
Fee
field is omitted (not set) in the transaction, then the server will automatically fill in a value. The calculatedFee
value will be present in the response. The same is true of theSequence
field.2.2. Response Fields
The shape of the return object is very similar to the response of the
tx
method.tx_json
binary
wasfalse
object
binary
wasfalse
.tx_blob
binary
wastrue
string
binary
wastrue
.hash
string
ledger_index
number
meta
object
(JSON) orstring
(binary)3. Security
The transaction will not actually be submitted. Users and tooling will have to be careful to be using the right RPC when they want to submit vs. not submit.
Since the simulated transaction must be unsigned, a malicious rippled node cannot submit a transaction that a user only wanted to simulate, not submit.
However, a malicious rippled node could still lie about what your transaction does, or front-run your transaction.
Performance tests will need to be conducted in order to ensure that a malicious user cannot DoS a rippled node by calling this function too many times, especially when pertaining to a complex transaction that affects many ledger objects. If it is too taxing on a node, it may be implemented as an admin-only method.
4. Example
4.1. Payment
4.1.1. Request
4.1.2. Response
Appendix
Appendix A: FAQ
A.1: Will calling this method incur any fees?
No, because the transaction is not actually submitted to the consensus ledger and isn’t shared (broadcast) with other nodes.
A.2: Is the
simulate
API call guaranteed to be the same as when I actually submit the transaction?No, because the ledger state, which affects how a transaction is processed, may change between the two API calls.
A.3: Can anyone run this function on any
rippled
node?If the node is configured to provide public API access, yes. The load is similar to that of the
submit
method. If performance tests reveal that the function takes too much of a node’s resources even with rate limits, then it may be an admin-only method, which means that you would need administrator access to a node, or need to run your own node, to call this function.A.4: What types of transactions can be simulated?
All transaction types can be simulated.
A.5: Can I use this method for debugging transactions?
Absolutely! The simulate function is a valuable tool for debugging and troubleshooting transactions before they are submitted to the network. You can test different scenarios and identify potential issues before committing the actual transaction.
A.6: Can I use this method to test transactions sent by accounts that I don’t control (such as a customer’s account)?
Yes, since the simulated transaction does not need to be signed.
A.7: Why isn’t this function instead called [insert alternative here]?
Several other names were considered during the ideation process, such as
submit_dry_run
,dry_run
, orpreview
, or even just including adry_run: true
parameter in the submit method. We decided against having the word “submit” anywhere in the name of the method to avoid confusion from people thinking that the method actually submits a transaction, and the name "simulate" has some precedent in being used by other systems and APIs.Appendix B: Example Use Cases
This is not intended to be an exhaustive list.
Payment
,OfferCreate
, ...) can be expected to do.Beta Was this translation helpful? Give feedback.
All reactions