Skip to content

feat: add BisonFi override templates - #8

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

feat: add BisonFi override templates#8
bakasura980 wants to merge 39 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 BisonFi scenario templates backed by guarded raw byte-layout writes.

  • Adds price, depth, spread, and freshness templates for BisonFi v3 pool accounts.
  • Extends scenario contracts with optional IDLs, raw account guards, and integer/strided/slot encodings.
  • Routes raw templates through account materialization while preserving the existing IDL-based path.
  • Adds BisonFi integration coverage and supporting scenario documentation.

Confidence Score: 5/5

The PR appears safe to merge because no blocking failure eligible for this follow-up review remains.

No blocking failure remains.

Important Files Changed

Filename Overview
crates/types/src/scenarios.rs Adds optional template IDLs and guarded raw-layout encodings while retaining the existing scenario wire model.
crates/core/src/surfnet/svm.rs Adds raw-template materialization before the IDL path and skips IDL registration for templates that do not carry one.
crates/core/src/scenarios/registry.rs Registers four BisonFi templates through a new IDL-free collection-loading path.
crates/core/src/scenarios/protocols/bisonfi/overrides.yaml Defines guarded byte offsets and encodings for BisonFi price, depth, spread, and freshness overrides.
crates/core/src/tests/bisonfi/mod.rs Adds raw encoding, guard, scenario materialization, and mainnet-backed BisonFi coverage.
.github/workflows/openai-review.yml Adds an automated pull-request review workflow that runs Codex and posts its final feedback.

Flowchart

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

Reviews (11): Last reviewed commit: "fix(types): prevent slot encoding trunca..." | 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.

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