Skip to content

feat: add BisonFi override templates - #8

Open
bakasura980 wants to merge 40 commits into
feat/scenarios/protocols/kaminofrom
feat/bisonfi-support
Open

feat: add BisonFi override templates#8
bakasura980 wants to merge 40 commits into
feat/scenarios/protocols/kaminofrom
feat/bisonfi-support

Conversation

@bakasura980

@bakasura980 bakasura980 commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

BisonFi publishes no IDL and is not an Anchor program, so this adds a raw byte-layout write path guarded by account size and magic, plus four templates on it: price, depth, spread and freshness.

Also introduces optional IDLs on templates, so a program without one no longer needs a reconstructed IDL in the repo.

Greptile Summary

The PR adds IDL-free raw-layout scenario support and four BisonFi override templates.

  • Adds guarded byte-level encodings for price, depth, spread, and freshness overrides.
  • Makes template IDLs optional and routes raw templates through a dedicated SVM materialization path.
  • Adds BisonFi integration coverage, protocol guidance, and an automated review workflow.

Confidence Score: 5/5

The pull request appears safe to merge because no blocking failure remains within the eligible follow-up review scope.

No blocking failure remains.

Important Files Changed

Filename Overview
crates/types/src/scenarios.rs Adds optional template IDLs and guarded raw-layout definitions, encodings, and materialization support.
crates/core/src/surfnet/svm.rs Routes raw-layout templates through byte-level account materialization before the existing token and IDL paths.
crates/core/src/scenarios/registry.rs Registers the four BisonFi templates without requiring an IDL.
crates/core/src/scenarios/protocols/bisonfi/overrides.yaml Defines the BisonFi v3 account guard and price, depth, spread, and freshness byte offsets.
crates/core/src/tests/bisonfi/mod.rs Adds extensive mainnet-backed integration coverage for BisonFi layouts and scenario behavior.
.github/workflows/openai-review.yml Adds a pull-request workflow that runs Codex and posts its feedback.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
    A[Scenario override] --> B[Resolve target account]
    B --> C{Template has raw layout?}
    C -->|Yes| D[Validate account size and magic]
    D --> E[Encode values at byte offsets]
    E --> F[Write modified local account]
    C -->|No| G[Resolve registered IDL]
    G --> H[Decode and update fields]
    H --> F
Loading

Reviews (12): Last reviewed commit: "Merge with kamino" | Re-trigger Greptile

Context used:

…y slot

Addresses two review comments.

A persisted override was re-queued with fetch_before_use intact, so every
following slot pulled the whole account from mainnet again: one RPC per slot
per override, and any field the override does not write was reset to mainnet's
value, discarding what local transactions had written to it.

fetch_before_use is now cleared on the re-queue, but only after the write
succeeds, so a failed apply still retries next slot with the fetch. The
re-queue replaces a copy of itself already queued for that slot instead of
bailing out, which keeps one entry per id.

persist also gains the ts-bindings attribute its sibling fetch_before_use
already had, and the regenerated OverrideInstance.ts exposes it - the field
was previously absent from the TS SDK entirely.
@bakasura980 bakasura980 changed the title ⏺ feat: add BisonFi override templates feat: add BisonFi override templates Aug 20, 2026
…y slot

Addresses two review comments.

A persisted override was re-queued with fetch_before_use intact, so every
following slot pulled the whole account from mainnet again: one RPC per slot
per override, and any field the override does not write was reset to mainnet's
value, discarding what local transactions had written to it.

fetch_before_use is now cleared on the re-queue, but only after the write
succeeds, so a failed apply still retries next slot with the fetch. The
re-queue replaces a copy of itself already queued for that slot instead of
bailing out, which keeps one entry per id.

persist also gains the ts-bindings attribute its sibling fetch_before_use
already had, and the regenerated OverrideInstance.ts exposes it - the field
was previously absent from the TS SDK entirely.
@bakasura980
bakasura980 force-pushed the feat/kamino-protocol-support branch from 686cf07 to f71abb8 Compare August 24, 2026 12:20
Comment thread crates/core/src/scenarios/protocols/bisonfi/overrides.yaml Outdated
…y slot

Addresses two review comments.

A persisted override was re-queued with fetch_before_use intact, so every
following slot pulled the whole account from mainnet again: one RPC per slot
per override, and any field the override does not write was reset to mainnet's
value, discarding what local transactions had written to it.

fetch_before_use is now cleared on the re-queue, but only after the write
succeeds, so a failed apply still retries next slot with the fetch. The
re-queue replaces a copy of itself already queued for that slot instead of
bailing out, which keeps one entry per id.

persist also gains the ts-bindings attribute its sibling fetch_before_use
already had, and the regenerated OverrideInstance.ts exposes it - the field
was previously absent from the TS SDK entirely.
@bakasura980
bakasura980 force-pushed the feat/kamino-protocol-support branch from c40c4ea to 794b8e8 Compare August 25, 2026 11:23
@bakasura980
bakasura980 changed the base branch from feat/kamino-protocol-support to feat/scenarios/protocols/kamino August 26, 2026 09:45
@bakasura980
bakasura980 changed the base branch from feat/scenarios/protocols/kamino to feat/kamino-protocol-support August 26, 2026 09:45
@github-actions

Copy link
Copy Markdown
  • svm.rs:3015: Raw-layout overrides validate size/magic but not account ownership. A caller can target any matching 2,048-byte account, unlike the IDL path which selects by owner program. Include BisonFi’s program ID in RawLayout and reject accounts owned by another program before writing.

@bakasura980
bakasura980 changed the base branch from feat/kamino-protocol-support to feat/scenarios/protocols/kamino August 26, 2026 09:52
The Kamino PR was squash-merged into the base as 272e238, which has no
ancestry link to the feat/kamino-protocol-support history already in this
branch - so every merge re-derived the same six conflicts from two
unrelated lineages. 272e238's tree is byte-identical to the kamino tip
merged in d243443, so this records the parent and leaves the tree alone.
@github-actions

Copy link
Copy Markdown
  • .github/workflows/openai-review.yml:2: Using pull_request means OPENAI_API_KEY is unavailable for PRs from forks, so the Codex step will fail for external contributors. Add a fork-aware condition or document/use a secure alternative trigger.

Tests couldn’t run because Rustup attempted to write outside the permitted workspace. No other actionable issues found.

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
  • P1 – Raw writes do not verify account ownership (svm.rs): An override can supply any account address; the raw path validates only size and magic. A matching account owned by another program could be corrupted. Include the expected owner/program ID in RawLayout and validate account.owner() before writing.

  • P2 – Slot encoding truncates large u64 slots (scenarios.rs): Casting target_slot to i64 turns values above i64::MAX negative, causing them to encode as zero. Use checked u64 addition/subtraction based on the lead’s sign.

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
  • svm.rs:3047: Raw-layout overrides validate only size/magic, not account ownership. Because callers may replace the template’s address, any 2048-byte account beginning with the same header can be modified—even if it is not owned by BisonFi. Add the expected program owner to the raw-layout guard and verify account.owner() before writing.

@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
  • [P2] svm.rs:3082: Raw writes validate only size and magic, not account owner. Because callers can override the target address, any 2048-byte account with matching header could be modified. Add the expected BisonFi program ID to RawLayout and verify account.owner() before writing.

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.

2 participants