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
Env::from_snapshot
no longer creates an Env
consistent with Env::default
#1101
Labels
bug
Something isn't working
Comments
leighmcculloch
changed the title
Env::from_snapshot no longer restores state
Oct 3, 2023
Env::from_snapshot
no longer creates an Env
consistent with Env::default
ElliotFriend
added a commit
to ElliotFriend/rs-soroban-sdk
that referenced
this issue
Oct 9, 2023
I've noticed some inconsistencies with snapshot creation and use where the various `*_entry_expiration` values are not set properly when create an `Env` from a snapshot that did have those values set. This could possibly be related to stellar#1101, but I'm not sure, since Leigh seemed more focused on prng. Refs: stellar#1101
github-merge-queue bot
pushed a commit
that referenced
this issue
Oct 9, 2023
I've noticed some inconsistencies with snapshot creation and use where the various `*_entry_expiration` values are not set properly when create an `Env` from a snapshot that did have those values set. This could possibly be related to #1101, but I'm not sure, since Leigh seemed more focused on prng. Refs: #1101 ### What This commit updates the ledger-snapshot crate to also set the various ledger entry expiration values, if they are set on the snapshot being set in the environment. ### Why When trying to load a ledger snapshot that I've created from an `Env` with valid entry expiration values, the new Env uses the defaults (which turn out to be `0`) for those expiration values. I noticed trouble trying to run `env.register_contract()` or `env.register_stellar_asset_contract()` in a test file after loading a previously valid snapshot, and receive the error: `trying to bump past max expiration ledger`. (That expiration ledger, being `0` ledgers from now.) ### Known limitations It's possible this is deliberate, and I'm misunderstanding how to use snapshots. If that's the case, we should probably bolster documentation around ledger snapshots to communicate that.
@brson You're welcome to take this, especially if it's blocking your work. |
Yep. I will try to fix it. |
brson
added a commit
to brson/rs-soroban-sdk
that referenced
this issue
Nov 6, 2023
github-merge-queue bot
pushed a commit
that referenced
this issue
Nov 7, 2023
…e same (#1133) ### What Make Env::default (when cfg testutils) and Env::from_snapshot configure the environment with a source account, a prng seed, and the debug diagnostics level. Do not turn on recording auth. Fixes #1101 ### Why Users writing tests will expect a test environment to be configured similarly regardless of how it was constructed. At present these two constructors create differently-configured environments. ### Known limitations na --------- Co-authored-by: Leigh McCulloch <351529+leighmcculloch@users.noreply.github.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What version are you using?
v20.0.0-rc2
What did you do?
Serialized an
Env
to aLedgerSnapshot
, then reloaded it into anEnv
.What did you expect to see?
The
Env
loaded with the same state as ifEnv::default()
had been called and the ledger state loaded, meaning auth recording is off, and a default base prng seed is set.What did you see instead?
An
Env
loaded with auth recording on and no default base prng seed.Discussion
It looks like when we added new behavior, and removed auth recording, in
Env::default
:rs-soroban-sdk/soroban-sdk/src/env.rs
Lines 524 to 532 in 0992413
We forgot to make the same changes in
Env::from_snapshot
:rs-soroban-sdk/soroban-sdk/src/env.rs
Lines 1216 to 1231 in 0992413
We should probably have
Env::from_snapshot
andEnv::default
share the same setup logic and the same storage type, where default is just an emptyLedgerSnapshot
.The text was updated successfully, but these errors were encountered: