Commit ac4ea91
authored
Fix testutils incompatibility with soroban-ledger-snapshot (#1476)
### What
Add a `testutils` feature to `soroban-ledger-snapshot`, and use it to
gate the functionality in ledger snapshots that uses the
`soroban-env-host`'s `testutils` features.
### Why
In #1467 the
`soroban-ledger-snapshot` crate dependency on `soroban-env-host` was
changed to include an always-enabled dependency on the `testutils`
feature. This appears to have been done because the function
`get_stored_entries` of the `Host` was changed from being always
available, to only available in `testutils` mode. The
`soroban-ledger-snapshot` crate uses the `get_stored_entries` function.
A side-effect of of always pulling in the `soroban-env-host` is that the
`soroban-ledger-snapshot` crate became incompatible with any project
that also depends on the `soroban-sdk` without its `testutil` feature
enabled. This is because the `soroban_env_host::EnvBase` trait type,
which is implemented by the `soroban-sdk` crate, has functions that are
required when the `testutil` feature is enabled.
To resolve the above challenges with only changes to this repository the
most straight-forward thing to do is to move the functionality in
`soroban-ledger-snapshot` that now needs `testutils` in
`soroban-env-host` behind a `testutils` feature as well, which
`soroban-sdk` enables when it uses `soroban-ledger-snapshot`.
### Known Limitations
Features on traits, like `EnvBase`, inherently create situations where
dependencies can get stuck in situations where they are incompatible
because another dep might be dependent on the trait in the opposite
state. We should probably revisit `EnvBase`'s liberal use of features,
breaking it up into separate traits. Rust features should always be,
where possible, additively compatible. I've opened the following issue
for us to explore that sometime:
- stellar/rs-soroban-env#1570
We may also want to revisit whether some simple getters like
`get_stored_entries` truly need to be gated behind a testutils flag.
Features in general come at a cost in maintenance and rigidity.
Typically features in Rust projects are used to reduce dependencies, but
in `soroban-env-host` we are using it to limit features in different use
cases.
After #1467 and the change
in this PR, some of the functionality in `soroban-ledger-snapshot` crate
is unusable with the `Host`, unless the `Host` is being used in
`testutils` mode. Today the only uses of the library that use that
functionality is when the `soroban-sdk` is also being used with
`testutils` enabled, but it is feasible that we may want to use the
functionality in situations where it doesn't make sense to run the
`Host` in `testutils` mode. This would probably mean changing the
function in `soroban-env-host` that became testutils only, to be
available without `testutils` again. We don't need it today, so I'm not
proposing it today.
cc @stellar/devx @stellar/contract-committers @fnando1 parent 9653830 commit ac4ea91
File tree
3 files changed
+10
-6
lines changed- soroban-ledger-snapshot
- src
- soroban-sdk
3 files changed
+10
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
| 53 | + | |
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | | - | |
| 59 | + | |
| 60 | + | |
60 | 61 | | |
61 | 62 | | |
62 | 63 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
45 | 46 | | |
46 | 47 | | |
47 | | - | |
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | | - | |
| 61 | + | |
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| |||
0 commit comments