What do you want to see in Anchor V2? #3742
Replies: 30 comments 61 replies
-
I would love a unification of tools with Anchor, i.e. just use Kit/Codama etc. from a UI perspective |
Beta Was this translation helpful? Give feedback.
-
I hate the testing framework built into Anchor. Would love to have you plug in your testing framework of choice (such as LiteSVM) |
Beta Was this translation helpful? Give feedback.
-
I want Anchor V2 to be near as performant as "solana native" programs. |
Beta Was this translation helpful? Give feedback.
-
On perf optimization, the default serialization should probably behave more like zero-copy but with better UX (IE not having to try to have perfect byte alignment, etc). Not sure if that's possible. But borsh is kind of terrible |
Beta Was this translation helpful? Give feedback.
-
Remove anchor-js (there doesn't seem to be much point now we have Codama, and it gives Acheron one less thing to maintain). |
Beta Was this translation helpful? Give feedback.
-
Default to not requiring flaky/unnecessary third party test runners like ts-mocha or ts-jest (node has a test runner and it works fine). |
Beta Was this translation helpful? Give feedback.
-
Get rid of remaining accounts. Support variable length arrays of the same type of account or some arbitrary constraint |
Beta Was this translation helpful? Give feedback.
-
Would be interesting to drop the 8byte discriminators in favor of 1-byte as a default. Either some analysis to lift some checks or allow me to override some of the account checks (e.g. can make a lot of assumptions when calling other programs like token/token22) |
Beta Was this translation helpful? Give feedback.
-
Remove boilerplate byte conversion for seeds - if someone wants to specify bytes, they can, otherwise Anchor should just do the conversion for us in the most popular way. This won't break anything because people that specify bytes can still specify bytes. Good frontend tools (like Kite 😁) already do this. |
Beta Was this translation helpful? Give feedback.
-
The interface should be as declarative as possible. Would be awesome if, like active record in ruby, I could just pull accounts off of an existing account. More concretely, currently we do: #[derive(Accounts)]
pub struct Thing<'info> {
pub mint: Account<'info, Mint>
#[account(has_one = mint)]
pub stake_account: Account<'info, StakeAccount>,
}
fn handler(ctx: Context<Thing>) -> Result<()> {
do_something(ctx.accounts.mint)
do_something(ctx.accounts.stake_account)
} This has the potential footgun of forgetting to add that has_one. What if instead I was able to write code like: #[derive(Accounts)]
pub struct CloseEntityClaimCronV0<'info> {
pub stake_account: Account<'info, StakeAccount>
}
fn handler(ctx: Context<Thing>) -> Result<()> {
do_something(ctx.accounts.stake_account.mint)
do_something(ctx.accounts.stake_account)
} Likewise, any client should be able to infer these types of relationships when forming instructions. When I want to execute a contract endpoint, typically I only care about a single account. Then lots of other things get pulled in around the side that I (the programmer that didn't write the contract) don't care about. I want to be able to do |
Beta Was this translation helpful? Give feedback.
-
Pinocchio-like CPI api! This felt like such a breath of fresh air when I tried pinocchio! |
Beta Was this translation helpful? Give feedback.
-
Needs a well thought solution to multiple versions of account or different possible account structs being loaded based on a version number |
Beta Was this translation helpful? Give feedback.
-
This is a big one, but: I'd move the seeds for each struct as a macro for the struct. PDAs are a key/value store. The struct is the value, the seeds are the key. Put them in the same place. |
Beta Was this translation helpful? Give feedback.
-
Please God version IDLs. A breaking change to IDL formats that breaks clients should be uploaded to a different place so that old clients can peacefully coexist with new ones. The Anchor 29 to Anchor 30 upgrade gave me my first gray hairs. |
Beta Was this translation helpful? Give feedback.
-
Try to optimise the structure of the new anchor for use with AI. Make sure that the best AI can intuitively figure out the structure and reconsider redesigning any obvious sticking points where it makes repeated mistakes |
Beta Was this translation helpful? Give feedback.
-
Oh another one: Codama (and probably anchor-js but I can't remember) doesn't have any tsdoc for the functions it exports. Whatever generates the TS for frontend should show up nicely in editors (this means tsdoc, whether we like it or not). Possible add a macro in Rust to add comments into the IDL? |
Beta Was this translation helpful? Give feedback.
-
Read layer integration. We're defining all these well-structured accounts that are easy to parse. Why am I not able to query the RPC with GraphQL? Solana is basically a database. I should be able to define my models (accounts) and how they relate. Those relations should be used when I'm coding my contract endpoints to prevent footguns. The RPC should also be aware of those relations and give me a nice structured way to query, join, and aggregate data. This would be a massive UX unlock over getMultipleAccounts, getProgramAccounts, etc. |
Beta Was this translation helpful? Give feedback.
-
Less macros!!! Debugging errors in macro is a pain, macros are not flexible at all and AI-based editors also struggle to provide accurate hints. New developers often don't understand what's happening behind the scenes. I would love some kind of rework on the serialization and deserialization. Copying accounts makes anchor stack hungry. This will be an issue with the upcoming increase in transaction size, as developers will be able to include more accounts. |
Beta Was this translation helpful? Give feedback.
-
CPI utility function that auto-reloads accounts that need to be
|
Beta Was this translation helpful? Give feedback.
-
Helper to expose the current instruction’s index in the transaction i.e
|
Beta Was this translation helpful? Give feedback.
-
LiteSVM for testing and also using surfpool as the native local validator |
Beta Was this translation helpful? Give feedback.
-
Allow for <8byte account/instruction discriminators? |
Beta Was this translation helpful? Give feedback.
-
Less boilerplate let transfer_accounts = TransferChecked {
from: from.to_account_info(),
mint: mint.to_account_info(),
to: to.to_account_info(),
authority: authority.to_account_info(),
}; Allow devs to just: let transfer_accounts = TransferChecked { from, mint, to, authority }; |
Beta Was this translation helpful? Give feedback.
-
Hi everyone, I would like to suggest adding an anchor audit parameter that scans vulnerabilities in a project and suggests fixes. The Solana ecosystem is already very large, but there’s still a lack of native tools focused on automated security analysis. I believe this is something the ecosystem truly needs. Developers should be able to catch common security issues early, without leaving their existing workflow. I’ve been working on a tool called Solsec: https://github.com/hasip-timurtas/solsec Solsec is designed to be lightweight and developer-friendly. I believe it would be a great fit for powering an anchor audit command inside the Anchor CLI. I’d be happy to work on a PR to explore and implement this integration. Let me know what you think or if there are any specific requirements you’d like to see. Thanks, |
Beta Was this translation helpful? Give feedback.
-
I wonder will this allow us to be able to compile Anchor code as executable binary if we want to, so we can use for debugging in LLDB. Because currently i don't have much choice on compiling it compiles to SBF Bytecode that is not usable for debugging. |
Beta Was this translation helpful? Give feedback.
-
Hey everyone Thanks, |
Beta Was this translation helpful? Give feedback.
-
I just wish I can code from arm device plz 🙏😭 |
Beta Was this translation helpful? Give feedback.
-
Interface for fetching sliced accounts |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
Remove |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Anchor V1 was built during a different time of Solana and contains a number of choices that are very difficult to change without making a very breaking change to Anchor.
With Anchor V2, we want to design the framework from the ground up with all the learnings we've had maintaining and building Anchor. What works, what doesn't, what we wish we had, and more.
For this discussion we want to pose the following question:
If we were to rebuild Anchor from the ground up in V2, what should we change?
Things already under consideration:
Beta Was this translation helpful? Give feedback.
All reactions