Skip to content

flamenco, vm: update cpi account borrowing checks#8754

Merged
topointon-jump merged 1 commit intomainfrom
firedancer-cpi-bug
Mar 6, 2026
Merged

flamenco, vm: update cpi account borrowing checks#8754
topointon-jump merged 1 commit intomainfrom
firedancer-cpi-bug

Conversation

@topointon-jump
Copy link
Copy Markdown
Contributor

@topointon-jump topointon-jump commented Mar 5, 2026

Align CPI error checks to better reflect Agave's structure, after feedback from auditors.

  • Accounts are borrowed outside UPDATE_CALLEE_ACC and UPDATE_CALLER_ACC to align better with Agave. This aligns more closely to the Agave structure.
  • Errors in the borrowing are propagated. Note that this borrow should never fail unless there is a bug somewhere else in the runtime.
  • Remove special-case handling of FD_ACC_MGR_ERR_UNKNOWN_ACCOUNT, as there is no reason not to error out in this case. This is a non-functional change as FD_ACC_MGR_ERR_UNKNOWN_ACCOUNT would never be thrown (all call sites return FD_EXECUTOR_INSTR_ERR_MISSING_ACC which is a different error code) but is less confusing.

Copilot AI review requested due to automatic review settings March 5, 2026 22:59
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Refactors CPI account update helpers to borrow CPI accounts at the call sites (closer to Agave’s structure) and simplifies callee/caller update code by removing in-function account lookups.

Changes:

  • Changed CPI update helper signatures to accept already-borrowed accounts rather than instruction account indices/keys.
  • Moved try_borrow_instr_account* calls to the call sites in CPI translation/entrypoint paths.
  • Removed dead/confusing borrowing paths and key-based lookup logic.

Comment thread src/flamenco/vm/syscall/fd_vm_syscall_cpi_common.c
Comment thread src/flamenco/vm/syscall/fd_vm_syscall_cpi_common.c
Comment thread src/flamenco/vm/syscall/fd_vm_syscall_cpi_common.c
Comment thread src/flamenco/vm/syscall/fd_vm_syscall_cpi_common.c
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 5, 2026

Performance Measurements ⏳

Suite Baseline New Change
backtest mainnet-368528500-perf per slot 0.061455 s 0.061009 s -0.726%
backtest mainnet-368528500-perf snapshot load 3.148 s 2.386 s -24.206%
backtest mainnet-368528500-perf total elapsed 61.454603 s 61.008825 s -0.725%
firedancer mem usage with mainnet.toml 963.38 GiB 963.38 GiB 0.000%

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 6, 2026

Performance Measurements ⏳

Suite Baseline New Change
backtest mainnet-368528500-perf per slot 0.090969 s 0.089043 s -2.117%
backtest mainnet-368528500-perf snapshot load 5.716 s 4.43 s -22.498%
backtest mainnet-368528500-perf total elapsed 90.968918 s 89.043335 s -2.117%
firedancer mem usage with mainnet.toml 963.38 GiB 963.38 GiB 0.000%

@topointon-jump topointon-jump changed the title flamenco, vm: fix cpi account borrowing checks flamenco, vm: update cpi account borrowing checks Mar 6, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.

Comment thread src/flamenco/vm/syscall/fd_vm_syscall_cpi_common.c
Comment thread src/flamenco/vm/syscall/fd_vm_syscall_cpi_common.c Outdated
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 6, 2026

Performance Measurements ⏳

Suite Baseline New Change
backtest mainnet-368528500-perf per slot 0.061442 s 0.060965 s -0.776%
backtest mainnet-368528500-perf snapshot load 3.224 s 2.48 s -23.077%
backtest mainnet-368528500-perf total elapsed 61.441589 s 60.964833 s -0.776%
firedancer mem usage with mainnet.toml 963.38 GiB 963.38 GiB 0.000%

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 6, 2026

Performance Measurements ⏳

Suite Baseline New Change
backtest mainnet-368528500-perf per slot 0.061122 s 0.061069 s -0.087%
backtest mainnet-368528500-perf snapshot load 3.253 s 2.487 s -23.547%
backtest mainnet-368528500-perf total elapsed 61.12229 s 61.069424 s -0.086%
firedancer mem usage with mainnet.toml 963.38 GiB 963.38 GiB 0.000%

@topointon-jump topointon-jump merged commit 05ed084 into main Mar 6, 2026
17 checks passed
@topointon-jump topointon-jump deleted the firedancer-cpi-bug branch March 6, 2026 20:20
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.

3 participants