-
Notifications
You must be signed in to change notification settings - Fork 43
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
Refactor soroban-simulation to use the e2e_invoke #1354
Conversation
- Simplify `SnapshotSource` interface - Expose some useful functions as public and decoupled from `Host` - Expose most of the test utils for e2e testing
…re modular/reusable. - Use e2e_invoke for invoking host functions in recording mode - Separate network config and adjustment config into separate structs for easier testing/caching etc. - Clean up the storage logic to clearly distinguish between snapshots with and without archive access - Added some documentation for public functions/structs - Added some basic test coverage. I didn't try to verify the math for every number, but I did sanity-check them. The host function simulation accuracy is mostly covered on `e2e_invoke` side.
@dmkozh Nice! I see that the public API has changed. Did you take into consideration the impact at https://github.com/stellar/soroban-rpc/blob/main/cmd/soroban-rpc/lib/preflight/src/lib.rs and whether it satisfies all the current functionality? |
@dmkozh I would like to make sure that all integration tests of soroban-rpc pass after these changes. Could you take a stab at adapting the rpc code? |
Another option is to do this in a two-step process, keeping an externally-compatible layer at first. |
Of course, these changes are meant to be functionally no-op (besides the additional capabilities, like ledger diffs we've discussed before - but there is no need to use them immediately). I'll definitely help with the migration, but this PR has to be finalized first. |
This feature has to be used for changes that are considered 'breaking' from the semver standpoint, but those that we still want to integrate to RPC/SDK/Core.
… into sim_refactor
… into sim_refactor
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.
A couple asks are inline. At minimum can we fix the docs issue before this is released?
# These changes may be used by the 'Soroban-owned' crates, such as | ||
# stellar-core, soroban-simulation, and soroban-sdk. | ||
# When bumping the major version of soroban-env-host all the code guarded | ||
# by this feature should be enabled unconditionally. |
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.
It feels odd to say this functionality can only be used by certain crates. Realistically anyone can use this functionality. What we should communicate about is who can safely use this functionality without big surprises or breaking builds.
# These changes may be used by the 'Soroban-owned' crates, such as | |
# stellar-core, soroban-simulation, and soroban-sdk. | |
# When bumping the major version of soroban-env-host all the code guarded | |
# by this feature should be enabled unconditionally. | |
# These changes should only be used by importers who depend on | |
# an exact patch version of the crates in this repo, because breaking | |
# changes may be introduced into any version in any code gated by | |
# this feature. When bumping the major version of any crates in this | |
# repo all the code guarded by this feature should be enabled | |
# unconditionally. |
#[cfg(any(test, feature = "unstable-next-api"))] | ||
pub contract_events_and_return_value_size: u32, |
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.
This field will show up in the docs on docs.rs without any disclaimer it is only available with a certain feature. We have a couple options:
-
Mark any unstable-next-api using the doc attribute so that docs.rs knows that it is only available with certain features and will display so.
This is what we do for testutils in the sdk. It requires more work. It's good for things we want people to use.
See this example for how to do it:
https://github.com/stellar/rs-soroban-sdk/blob/9d802fc8ab82ff571e71b85c790b397b680a00bf/soroban-sdk/src/testutils.rs#L2 -
Tell docs.rs not to enable the
unstable-next-api
feature at all when building docs so that none of these features show up in the docs at all.This is the simpler approach. It's a single line in a toml file. We need to change:
rs-soroban-env/soroban-env-host/Cargo.toml
Lines 122 to 123 in 0ceb08b
[package.metadata.docs.rs] all-features = true
My gut feel is we should do (2), because we don't see a ton of value in people using this features asap.
#[cfg(any(test, feature = "unstable-next-api"))] | ||
let entry_with_live_until = init_storage_snapshot.get(key)?; | ||
#[cfg(not(any(test, feature = "unstable-next-api")))] | ||
let entry_with_live_until = if init_storage_snapshot.has(key)? { |
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.
The fact that test
is included in here as an any condition suggests that the non-unstable code is not tested. How can we still test it?
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.
I don't think there is anything to test in this particular case. SnapshotSource
is not really covered directly. The new field is covered in the tests as well and I don't see much value in covering not returning this field.
### What This is a small followup/cleanup after #1354. Updated comments and exclude some features from the generated docs. ### Why Cleanup ### Known limitations N/A --------- Co-authored-by: Leigh McCulloch <351529+leighmcculloch@users.noreply.github.com>
What
Refactor soroban-simulation to use the e2e_invoke and also to be more modular/reusable.
e2e_invoke
side.Why
Improving simulation quality, as well as maintainability.
Known limitations
N/A