Skip to content

Refactor hardcoded program ID away from the interface - #202

Open
fedgiac wants to merge 2 commits into
mainfrom
federico/sc-560-stagingprod-program-separation
Open

fedgiac wants to merge 2 commits into
mainfrom
federico/sc-560-stagingprod-program-separation

Conversation

@fedgiac

@fedgiac fedgiac commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

Before this PR, the interface inconsistently assumes either that the program address is exactly the one specified in the solana_pubkey::declare_id! or that the program address is the one passed to the relevant function.
This inconsistency was caused by a series of refactors with the purpose of better CU efficiency in the programs.

This PR split these concerns: all these tricks are only needed in the program, so everything that requires the hardcoded program is moved out of the interface crate and into the settlement program crate. The rest of the interface then becomes generic, and the interface/client crates can be used with any program.
This is particularly relevant in a future follow-up: implement a nicer way to deploy both prod and barn (staging) programs with the same code by just switching a build-time flag.

No changes to the program logic are intended. Interesting, we get some minor CU savings. (I tried to remove some inline(always) via AI but it didn't work still, unfortunately.)

How to review

Most of the code is the same, just moved.

This can be easily seen with git diff --color-moved. The actual changes to review are much less than the line diff count would lead to believe, namely two new tests and some glue.

Another thing to check is: does the interface still use the hardcoded program address anywhere?
To verify this isn't the case, comment out the PROD_ID constant and compile only the client (and through it the interface) and see that build passes:

cargo check -p cow-settlement-client --all-targets

Tests

The tests are mostly the same, so check that tests weren't dropped and the split doesn't require additional coverage.

@fedgiac
fedgiac requested a review from a team as a code owner October 12, 2026 17:43
@linear-code

linear-code Bot commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

SC-560

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