Skip to content

Handle event ring-buffer resizing safely in set_max_events #28

Closed

Description

@priscaenoch

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

  • explorer/src/lib.rs

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.

Activity

  1. Ayinkx01 commented on Aug 18, 2026

    @Ayinkx01

    Hi i would like to work on this issue please assign to me
    I can do it perfectly

  2. Ayinkx01 commented on Aug 18, 2026

    @Ayinkx01

    Hi i would like to work on this issue please assign to me
    I can do it perfectly

  3. Ayinkx01 commented on Aug 18, 2026

    @Ayinkx01

    Hi i would like to work on this issue please assign to me
    I can do it perfectly

  4. rudeus112266 commented on Aug 25, 2026

    @rudeus112266
    Contributor

    I would love to have a go at resolving this issue. kindly assign

  5. grantfox-oss commented on Aug 25, 2026

    @grantfox-oss

    🦊 GrantFox — @rudeus112266 has been assigned to this issue as part of the Third Campaign campaign!

    Next steps:

    1. Open a Pull Request referencing this issue (e.g., Closes #28)
    2. Your PR will be reviewed by the octraban maintainers

    Good luck! Track your progress on GrantFox.

  6. added a commit that references this issue on Oct 9, 2026
    5887472
  7. grantfox-oss commented on Oct 9, 2026

    @grantfox-oss

    🎉 This issue has been marked as completed on GrantFox!

    @rudeus112266's PR #34 was approved and merged by @priscaenoch.

    🏆 @rudeus112266: You earned 35 FoxPoints for this contribution! Your current tier: Explorer (433 total points). Track your full progress on GrantFox.

    👏 Great work, @rudeus112266! Keep contributing to octraban.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardThird CampaignCampaign: Third CampaignbugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions