Commit 0c32ac8
authored
Fix
### What
Guard `stellar contract restore` against the same "index out of bounds"
panic that #2657 fixed in `extend`: the no-op path unconditionally
indexed `entry.entries[0]`, which panics if the post-transaction fetch
returns no entries. It now errors with "Ledger entry not found" instead.
### Why
`restore` carried the identical unguarded indexing as `extend` (see
#2599), so this applies the same
`.first().ok_or(Error::LedgerEntryNotFound)?` fix. Unlike extend,
restoring a non-existent entry fails cleanly at simulation ("Missing
entry to restore") before reaching the no-op path, so this guard is
defensive hardening for the narrower case where the fetch after a no-op
comes back empty (e.g. the entry was evicted in the meantime). The
regression test asserts the non-existent-entry case fails cleanly at
simulation without panicking.
### Known limitations
The empty-fetch-after-no-op case itself isn't covered by an integration
test since simulation catches the straightforward missing-entry scenario
first.contract restore panic when restoring a missing entry (#2660)1 parent 380f7c1 commit 0c32ac8
2 files changed
Lines changed: 30 additions & 1 deletion
File tree
- cmd
- crates/soroban-test/tests/it/integration
- soroban-cli/src/commands/contract
Lines changed: 21 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
365 | 365 | | |
366 | 366 | | |
367 | 367 | | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
368 | 389 | | |
369 | 390 | | |
370 | 391 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
262 | 262 | | |
263 | 263 | | |
264 | 264 | | |
265 | | - | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
266 | 274 | | |
267 | 275 | | |
268 | 276 | | |
| |||
0 commit comments