Bring the Anchor v1 copies in line with v2 where the Anchor version allows - #163
Merged
Merged
Conversation
…helper v2 split check_mint_data into check_rate_authority, which takes the parsed InterestBearingConfig, because v2's exclusive borrows made the old read-the-account helper need unsafe. Only that parsing route is forced by the Anchor version. The v1 copy now has the same helper, name and signature, and its handlers parse the extension with anchor-spl's get_mint_extension_data. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F8Wo5zNLqZ2NQqSjGD7WpK
A scan of every anchor/anchor-v1 pair (function names, error variants, account fields, constants, seeds) and of every v2 program commit since July that left its v1 copy untouched found: - transfer-hook counter and account-data-as-seed: port 14847e8. The hook dropped the incremented count because counter_account was not mut, so it read one after every transfer. Write it back, add CounterOverflow for the checked add, and assert the stored count in the tests. - account fields v2 declares pub are pub in the v1 copies of account-data, checking-accounts, program-derived-addresses, rent, transfer-sol and nft-operations. - order-book: derive Default on OrderTreeRoot like v2, dropping the hand-written impl. The remaining differences are forced by the Anchor version and are listed in the changelog. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F8Wo5zNLqZ2NQqSjGD7WpK
Keeps both 2026-09-23 changelog entries. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F8Wo5zNLqZ2NQqSjGD7WpK
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CONTRIBUTING.md now says the
anchor-v1/copies differ from their v2 counterparts only where the Anchor version forces it (#156). This PR applies that rule to one known case, the interest-bearing helper, and to everything a scan of all v1/v2 pairs turned up.Changes
Interest-bearing (first commit). v2 split
check_mint_dataintocheck_rate_authority, which takes the parsedInterestBearingConfig. v2 needed that because of its exclusive borrows (44f7c35); only the parsing route is forced. The v1 copy now has the same helper, name and signature, and its handlers parse the extension with anchor-spl'sget_mint_extension_data.Drift scan fixes (second commit).
counterandaccount-data-as-seed(a real bug). The v1 copies still had the bug v2 fixed in 14847e8. The hook added one to the stored count, logged it, and dropped it, becausecounter_accountwasn'tmut. The count read one after every transfer. This ports the fix:mutconstraint and the write-backCounterOverflowerror for the checked add, which previously reusedAmountTooBigpubare nowpubin the v1 copies of account-data, checking-accounts, program-derived-addresses, rent, transfer-sol and nft-operations. The other v1 examples already did this.OrderTreeRootderivesDefaultas in v2, replacing a hand-written impl that clippy flagged as derivable.How the scan worked
anchor/+anchor-v1/pair, I compared the sets of function names,#[error_code]variants,pubfields, constants and seed strings in the program source, plus the test names.MAX_ASSETSandApprovedAsset, lending's index names, and nft-minter'supdate_authority_is_signer, plus the handler-adding commits. All of these were already in v1 or expressed through v1's own API.The remaining differences are all forced by the Anchor version; the root changelog lists them:
entrypointfallbacksession-keyscratelast_restart_slotsyscall wrapper (v1 does the same check through the sysvar)rentVerification
mainin each copy. The order book goes from 10 to 9, because the flagged impl is gone.🤖 Generated with Claude Code
https://claude.ai/code/session_01F8Wo5zNLqZ2NQqSjGD7WpK
Generated by Claude Code