Skip to content

Bound the compute unit limit of Solana sponsored creations - #5277

Open
tilacog wants to merge 4 commits into
mainfrom
tiago/be-526-bound-the-compute-unit-limit-of-sponsored
Open

tilacog wants to merge 4 commits into
mainfrom
tiago/be-526-bound-the-compute-unit-limit-of-sponsored

Conversation

@tilacog

@tilacog tilacog commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Description

Until now, validate used the compute unit limit of a sponsored creation only inside the priority fee product. A creation that declared SetComputeUnitLimit(1) passed placement, failed on chain, and the funder paid the base fee for no order.

With this PR, the orderbook now bounds a declared limit with two configuration values.

A creation that declares no limit passes, just as before, since it will end up using the Solana runtime defaults, which are acceptable.

Changes

  • infra/config.rs: sponsoring.min-compute-unit-limit (default 0) and sponsoring.max-compute-unit-limit (default 1,400,000, the most a transaction can consume). The defaults accept every creation that passes today with a limit of at most 1,400,000.
  • create_order/mod.rs: validate returns InvalidTransaction when a declared limit is below the minimum or above the maximum.
  • infra/api/mod.rs, run.rs: the runtime Sponsoring carries the two bounds.
  • example.toml: documents both keys.

How to test

cargo nextest run -p solana-orderbook

  • create_order_bounds_the_declared_compute_unit_limit: with a minimum of 10,000 it refuses 9,999 and accepts 10,000 and an undeclared limit. With the defaults it accepts 1,400,000 and refuses 1,400,001.

Related Issues

BE-526

The orderbook read the compute unit limit of a creation only to price its
priority fee. A creation that declares too few units fails on chain, and
the funder pays the base fee for no order.

The `[sponsoring]` section gets two keys. A creation that declares a limit
outside them is rejected with `InvalidTransaction`. A creation that
declares no limit is not bounded.

- `min-compute-unit-limit`, default 0
- `max-compute-unit-limit`, default 1400000
…ames

The two runtime `Sponsoring` fields and the test server helper carry their meaning in their names. The configuration doc comments keep the reason for each bound.
@linear-code

linear-code Bot commented Nov 13, 2026

Copy link
Copy Markdown

BE-526

@tilacog
tilacog marked this pull request as ready for review November 13, 2026 13:44
@tilacog
tilacog requested a review from a team as a code owner November 13, 2026 13:44
@claude

claude Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @tilacog's task in 31s —— View job


Review

The change looks correct. The bounds apply only to a declared limit, they're checked after the priority fee ceiling and before the bundle is parsed, and the defaults keep today's behaviour up to 1,400,000. The new test covers both edges and the undeclared case.

I left one inline comment: the config doesn't check that min-compute-unit-limit <= max-compute-unit-limit, so a swapped pair would silently refuse every creation that declares a limit.

I didn't run the tests in this job.

@github-actions

Copy link
Copy Markdown

🤖 Claude reviewed this PR. Any issues are posted as inline comments on the relevant lines.

  • Runs automatically when a PR is opened or marked ready for review.
  • Re-run it: comment @claude on this PR (requires write access; bots and drafts are skipped).
  • Skip it: add the skip-claude-review label.

Won't run when: the PR is a draft, the author is a bot or lacks write access, or the skip-claude-review label is set.

…are inverted

With the minimum above the maximum, validate refuses every sponsored
creation that declares a limit.

@jmg-duarte jmg-duarte left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM but I think the error message should be rethought

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The error implies that the transaction should not be sponsored but still go through

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