-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
lang: Remove #[state]
#456
Comments
One reason we might want to keep state structs around is for program composition #454. One way to implement composition would be via traits similar to how |
I don't have a strong technical reason why it shouldn't be removed, but as someone very new to the scene, state was the only thing that made sense to me at the beginning. Although later I realized its limitation, and need to create other PDA accounts, having a central state that keeps tracks of the source of truth always feel nice: (I hope I am doing this right though)
|
I am in the "should be removed" camp as I find it antonymic to how Solana works. For context, I got in this discussion because I was looking at how to access the state account "outside" the state |
How does one define a interface implementation without |
The current |
We should consider removing state. The same functionality can be created by initializing PDAs with fixed seeds in the accounts context. E.g.,
#[account(init, seeds = [b"state".as_ref(), &[bump]])]
Currently, the only benefit of state is that it makes the programming model easier to reason about when coming from Solidity. However, it seems to fight against solana's parallel first programming model, adds more syntax to learn, maintain, audit, and document, and is ultimately less convenient to use because the state struct can't be easily accessed via the
#[derive(Accounts)]
macro and so constraint validation has to be brought up into the instruction handler, which is less idiomatic.I'm in favor of removing the syntax and am curious if others agree.
The text was updated successfully, but these errors were encountered: