Skip to content

simulateTransaction: re-enable emitting restore preambles after protocol 23 #464

@2opremio

Description

@2opremio

Protocol 23 introduced autorestore, which, for most cases, makes explicit restore operations (and the restore preamble returned by simulateTransaction) redundant.

#463 enabled autorestore for simulateTransaction for protocol > 22 but disabled restore preambles.

However, there are corner cases (when network limits are surpassed) for which autorestore isn't enough. In those cases we need to split restoring into autorestore+restore preamble.

To implement this we should include this changes in the libpreflight Rust library:

  1. run simulation using regular (non-auto-restore) snapshot source. the result will contain auto-restored entries (if any) in SorobanTransactionData . The result will also have proper fees and limits for autorestoration.
  2. verify the output SorobanTransactionData against the network limits.
    a. if it is below limits, return the result from step 1
    b. if it is above limits, re-run simulation using AutoRestoringSnapshotSource and populate the restore preamble. now you'll have an invoke transaction without any auto-restored entries, and a restore transaction.

note, that step 2b doesn't guarantee that the original transaction without autorestore, or the restore transaction don't exceed the network limits. which is why I suggest to postpone that until after we have a more coherent design for handling the network limits in simulation. thus the algorithm can be shortcut to just step 1.

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions