Skip to content

Fix delegated roll result synchronization - #120

Merged
GabrielePicco merged 1 commit into
mainfrom
fix/delegated-roll-result-sync
Jul 17, 2026
Merged

Fix delegated roll result synchronization#120
GabrielePicco merged 1 commit into
mainfrom
fix/delegated-roll-result-sync

Conversation

@GabrielePicco

@GabrielePicco GabrielePicco commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Summary

  • reconcile delegated roll results through the processed player-account subscription
  • keep hidden warm-up callbacks separate from visible roll history
  • add guarded account-read fallback polling and isolate latency counter rendering
  • correlate callbacks with the submitted request slot after the u8 roll counter reaches 255

Summary by CodeRabbit

  • Improvements
    • Improved delegated dice-roll reliability and result synchronization.
    • Added clearer roll timing information, including elapsed time and timed-out states.
    • Enhanced handling of background preparation to make delegated rolls start more smoothly.
    • Updated loading and result states to provide more consistent feedback while awaiting outcomes.
    • Improved polling behavior so results are checked efficiently without exceeding the roll timeout.

@vercel

vercel Bot commented Jul 17, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
counter-session-keys Ready Ready Preview, Comment Jul 17, 2026 9:27am
er-rolldice Ready Ready Preview, Comment Jul 17, 2026 9:27am
magicblock-counter-example Ready Ready Preview, Comment Jul 17, 2026 9:27am
magicblock-engine-examples Ready Ready Preview, Comment Jul 17, 2026 9:27am
magicblock-rewards-dashboard Ready Ready Preview, Comment Jul 17, 2026 9:27am
spl-tokens Ready Ready Preview, Comment Jul 17, 2026 9:27am

Request Review

@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 062c16d5-c855-4bdc-bd28-86e61bdb52a3

📥 Commits

Reviewing files that changed from the base of the PR and between 04e4ba7 and 97fd2ec.

📒 Files selected for processing (2)
  • roll-dice/anchor/app/app/delegated/page.tsx
  • roll-dice/anchor/app/lib/types.ts

Walkthrough

Changes

Delegated Roll Flow

Layer / File(s) Summary
Roll state and tracking contracts
roll-dice/anchor/app/app/delegated/page.tsx, roll-dice/anchor/app/lib/types.ts
Adds shared roll-tracking types and refs, awaiting-result state, timeout support, and the optional RollEntry.timedOut field.
Account-change reconciliation
roll-dice/anchor/app/app/delegated/page.tsx
Centralizes account decoding, ordering guards, request-slot reconciliation, roll completion detection, initialization, and subscription updates.
Background roll transaction flow
roll-dice/anchor/app/app/delegated/page.tsx
Reworks background rolls around cached blockhashes, raw submission, status polling, expiration handling, and guarded delegation warmups.
User roll polling and presentation
roll-dice/anchor/app/app/delegated/page.tsx
Updates user-roll transaction handling, adaptive polling, timeout recording, button states, cached blockhash warming, and latency rendering.

Estimated code review effort: 4 (Complex) | ~60 minutes

Suggested reviewers: dhruvja

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/delegated-roll-result-sync

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@GabrielePicco
GabrielePicco marked this pull request as ready for review July 17, 2026 09:27
@GabrielePicco
GabrielePicco merged commit 77e6e1a into main Jul 17, 2026
12 of 32 checks passed
@GabrielePicco
GabrielePicco deleted the fix/delegated-roll-result-sync branch July 17, 2026 09:28

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 97fd2ec07d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

}
return
}
if (slot <= requestSlot) return

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Accept the request transaction's account update

When rollnum has saturated at 255, the account write produced by this roll is in the same Solana slot as the tracked signature, so its account-change callback has slot === requestSlot. This <= check discards that actual result; the deferred path also only replays a notification whose slot is greater. Consequently every roll after the counter reaches 255 remains pending indefinitely (until an unrelated later account write), despite the transaction succeeding.

Useful? React with 👍 / 👎.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant