Problem
The explorer contract stores decoded events in a ring buffer indexed by seq % max (see the slot computation in get_events/submit_event). set_max_events (explorer/src/lib.rs) validates only that the new value is at least MIN_MAX_EVENTS, then overwrites DataKey::MaxEvents. It does not remap existing entries. After a resize, seq % new_max points at different physical slots than the data was written to, so get_event/get_events return wrong, misordered, or missing events for everything already stored. This silently corrupts the readable history.
What needs to be done
- Define and implement safe resize semantics. Options, to be chosen and documented:
- Rebuild/migrate the buffer contents into the new layout during
set_max_events.
- Or reset/clear the buffer on resize with an explicit event and documented consequence.
- Or forbid resizing while the buffer is non-empty and require an explicit clear first.
- Ensure
get_event/get_events remain correct across a resize.
- Extend the instance TTL on the write and emit an event describing the resize.
Files
Acceptance deliverables
- Reads return correct, correctly ordered events before and after a resize (per the chosen, documented semantics).
- The resize behavior is documented in the README.
- All CI checks pass; the change cannot be merged until CI is green.
Tests to pass
- Test: write events, call
set_max_events, then read back and assert the documented behavior (no silent corruption).
- Test:
get_events ordering is correct after a resize.
Problem
The explorer contract stores decoded events in a ring buffer indexed by
seq % max(see the slot computation inget_events/submit_event).set_max_events(explorer/src/lib.rs) validates only that the new value is at leastMIN_MAX_EVENTS, then overwritesDataKey::MaxEvents. It does not remap existing entries. After a resize,seq % new_maxpoints at different physical slots than the data was written to, soget_event/get_eventsreturn wrong, misordered, or missing events for everything already stored. This silently corrupts the readable history.What needs to be done
set_max_events.get_event/get_eventsremain correct across a resize.Files
explorer/src/lib.rsAcceptance deliverables
Tests to pass
set_max_events, then read back and assert the documented behavior (no silent corruption).get_eventsordering is correct after a resize.