Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rust workspace changes (formerly anchor-0.30 but reverted) #174

Merged
merged 36 commits into from
Aug 15, 2024

Conversation

wjthieme
Copy link
Member

@wjthieme wjthieme commented Aug 6, 2024

No description provided.

@wjthieme wjthieme self-assigned this Aug 6, 2024
@wjthieme wjthieme marked this pull request as ready for review August 7, 2024 18:30
Base automatically changed from wjthieme/nx-monorepo to main August 8, 2024 13:17
# Conflicts:
#	.github/actions/anchor/action.yml
#	.github/workflows/publish.yml
#	Anchor.toml
#	README.md
#	legacy-sdk/scripts/tsconfig.json
#	legacy-sdk/whirlpool/package.json
#	package.json
#	yarn.lock
@wjthieme
Copy link
Member Author

wjthieme commented Aug 8, 2024

Sidenote: don't think this would have to be deployed immediately since the program instructions themselves don't change. This is only needed for:

  • Kinobi rust only works with solana-program 1.18 so this makes sure the program and the sdk use the same version
  • Kinobi requires idls that contain address key which anchor only added in version 0.30 (technically we can do a workaround but we need to upgrade anchor at some point anyway).

Copy link
Collaborator

@yugure-orca yugure-orca left a comment

Choose a reason for hiding this comment

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

Almost LGTM.

One point is rent: Sysvar<'info, Rent> part.
I think it is nice to keep it unchanged for the following reasons.

  • That the name of the account is rent.
  • That we want to avoid the fact that an arbitrary address is passed (safer & indexer friendly)
  • The transaction size of the instruction receiving "rent" is not a major problem, imo
  • That the v2 instruction can solve the open_position problem (v2 for open_position is coming)
  • ALT can be used.

WDYT ?

Anchor.toml Outdated
# So we need to use test.genesis config.
# [[test.validator.clone]]
# address = "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"

Copy link
Collaborator

Choose a reason for hiding this comment

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

hmm, how about using [[test.validator.clone]] again and moreve external_program/mpl_token_metadata.20240214.so, or keep this comment to explain why we stopped to use [[test.validator.clone]]

Metaplex has had breaking changes in the past, so it is somewhat safer to use the latest binaries.
They have removed the old instructions, that Whirlpool depended on, to introduce fees.

Anchor 0.30.1 fixed this issue: coral-xyz/anchor#3010

@@ -16,7 +16,7 @@ In your package, run:
```
yarn add "@orca-so/whirlpools-sdk"
yarn add "@orca-so/common-sdk"
yarn add "@coral-xyz/anchor@0.29.0"
yarn add "@coral-xyz/anchor@0.30.0"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we use 0.30.0 ? (not 0.30.1 ?) on client-side.

README.md Outdated
- Anchor 0.29.0
- Solana 1.17.22
- Anchor v0.30
- Solana v1.18
Copy link
Collaborator

Choose a reason for hiding this comment

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

How about v0.30.1 and v1.18.21. (as officially tested version)

Comment on lines 19 to 32
spl-token = { version = "=4.0.3", features = ["no-entrypoint"] }
spl-transfer-hook-interface = { version = "=0.6.5" }
solana-program = { version = "=1.18.21" }
thiserror = { version = "=1.0.63" }
uint = { version = "=0.9.5", default-features = false }
arrayref = { version = "=0.3.8" }
borsh09 = { package = "borsh", version = "=0.9.3" }
solana-security-txt = { version = "=1.1.1" }
bytemuck = { version = "=1.16.3", features = ["derive", "min_const_generics"] }

[dev-dependencies]
proptest = "1.0"
serde = "1.0.117"
serde_json = "1.0.59"
proptest = "=1.5.0"
serde = "=1.0.205"
serde_json = "=1.0.122"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need to =x.x.x other than anchor library ?
There was a concern that even fixed versions of Solana would suffer from type mismatches, as different versions of the library would be treated as different libraries.

Copy link
Member Author

Choose a reason for hiding this comment

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

This was done because in #172 I added more rust packages in the workspace. These might have different versions of the same libraries. I need to pin them here to the exact versions otherwise it might take a version that is not compatible (but would still satisfy the version constraint here.

The dev dependencies don't matter that much but I figured might as well pin them too. IMO the more of the 'core' dependencies we can pin the less chance there is that in the future it takes a different version which breaks things. Dependabot should ping us when new versions become available which IMO is more transparent than cargo doing those things under the hood.

Copy link
Collaborator

Choose a reason for hiding this comment

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

hmm, I think the Rust SDK gets requests from developers who want to use with Anchor 0.29, Solana 1.17 or something more up-to-date.
That's what the crate for CPI was. Once anchor released v0.30.0, some devs started asking to update whirlpools crate.
In light of such requests, I think the contract and SDK versions should be intentionally separated.
I think the workspace that ties those two together can be problematic, what do you think?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep agree. If you look at #172 you can see the versions for the rust sdk are more permissive. This is only to prevent any local version mismatches. Any downstream consumer would be able to specify versions they would like to use as long as it complies with the constraints in the rust-sdk cargo file. At least that is how I intended it to be

pub rent: Sysvar<'info, Rent>,
/// CHECK: checked via account constraints
#[account(address = sysvar::rent::ID)]
pub rent: UncheckedAccount<'info>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

hmm, could we keep Sysvar<'info, Rent> ?

To avoid being given arbitrary addresses.
Not as massively executed as "swap" instruction and does not affect transaction size.
As far as open_position is concerned, it should be excluded from open_position_v2. As you know, I think open_position_v2 is clearly preferred because of its advantages (no non-refundable rent overhead).

Copy link
Member Author

Choose a reason for hiding this comment

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

The problem is stack space and not transaction size. See my comment below

@wjthieme
Copy link
Member Author

One point is rent: Sysvar<'info, Rent> part.
I think it is nice to keep it unchanged for the following reasons.

This change was required because it ran out of stack space in the open_position, open_position_with_metadata, open_position_bundle, open_position_bundle_with_metadata, initialize_pool and initialize_pool_v2 instructions. ALTs wouldn't help reduce the stack space in this case.

@wjthieme wjthieme changed the title Update anchor to 0.30 and solana-program to 1.18 Rust workspace changes (formerly anchor-0.30 but reverted) Aug 15, 2024
Copy link
Collaborator

@yugure-orca yugure-orca left a comment

Choose a reason for hiding this comment

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

LGTM🚀

@wjthieme wjthieme merged commit 331814d into main Aug 15, 2024
4 checks passed
@wjthieme wjthieme deleted the wjthieme/anchor-0.30.1 branch August 15, 2024 15:00
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