-
Notifications
You must be signed in to change notification settings - Fork 3
Add interface crate #47
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me overall, just a few little things
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! But do get approval from @buffalojoec as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just did some work on removing the Config builtin from Agave before you opened this, so there are a few updates we can make here.
For starters, the builtin crates are all non-semver, and we're also just outright dropping them, so no need to preserve any backwards compatibility in this new interface crate.
create_config_account
serialized_size
- Anything else that seems silly to include in the interface API
I also outfitted the Rust client in this repository to support the remaining builtin API we needed in Agave, so that should already have all of the methods we need in the validator.
That being said, I'm sure the Rust client in here is bringing a lot of dependencies we don't need. Can we just refactor the client, or is the interface crate absolutely necessary?
interface/src/instruction.rs
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's either refactor the existing client or strip this new crate down to bare bones, as per my initial comment.
I removed I don't know how to remove solana-program from the existing client since it's autogenerated |
Welp, evicting I'm not convinced jamming an interface crate into this repository, which contains the same API as the client, just with better dependency management, is the right way to go. If it was, we might as well just stop using the Codama clients altogether. The long-tail, right thing to do is probably to see my PR into Codama all the way through and get those clients refactored properly, so they aren't introducing kitchen sink SDKs into dependent libraries, including those in Agave. If that's not something you can wait for, and you need crates in Agave un-bloated sooner, we can continue discussion about some kind of shorter-term workaround (like this PR). Which crate(s) are you primarily seeking to slim down? |
The only auto-generated part of solana_config_program_client that gets used in Agave is the program ID - the rest is hand-written Rust. So yes that would be a good idea here at least.
The main one is solana-account-decoder. yellowstone-grpc depends on this via solana-transaction-status (and it is using types that are not present in solana-transaction-status-client-types). |
Typically we've been using the interface crates to define whatever's necessary to create the IDL, from which we can auto-generate clients, ie https://github.com/solana-program/system/tree/main/interface We need to have the base types somewhere from which the IDL is generated, otherwise we have a circular relationship. Meaning, if the IDL is generated from the Rust client, and then Rust client is generated from the IDL, we're going to run into weird situations. Why not put those base things in here? |
@joncinque Is that a suggestion to change something in this PR? |
Yes, that's only because I was too lazy to refactor all of the hand-written stuff in Agave to use the generated stuff. 😅 Maybe that's a good thing for what this PR aims to do though. I was going to write up a few suggestions, but I should have probably done some of this when I first added the hooked types to the client, instead of just dumping them all in the dependency-bloated Codama client. So instead I just added a commit to deprecate the My next commit would be to squash the reimplementations of Lmk what you think of my commit, otherwise g2g for me @kevinheavey |
fn max_space() -> u64; | ||
} | ||
|
||
// TODO move ConfigState into `solana_program` to implement trait locally |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ehh, we should probably just get rid of the trait. It's pretty silly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm definitely down to remove it, but where should we move it to in the meantime? It's still used a bit in agave
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably just somewhere in Agave. I'll take a look and circle back here!
#[serde(with = "short_vec")] | ||
pub keys: Vec<(Pubkey, bool)>, | ||
} | ||
pub use solana_config_interface::state::ConfigKeys; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The program crate has not been published for 3.0.0, so we can actually drop this altogether!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, that means the program won't actually depend on the interface at all, right? Man, the config program is weird
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, mainly just the question about the plan for the trait if you want to remove it
#[serde(with = "short_vec")] | ||
pub keys: Vec<(Pubkey, bool)>, | ||
} | ||
pub use solana_config_interface::state::ConfigKeys; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, that means the program won't actually depend on the interface at all, right? Man, the config program is weird
fn max_space() -> u64; | ||
} | ||
|
||
// TODO move ConfigState into `solana_program` to implement trait locally |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm definitely down to remove it, but where should we move it to in the meantime? It's still used a bit in agave
@@ -29,14 +21,14 @@ pub fn create_account<T: ConfigState>( | |||
lamports: u64, | |||
keys: Vec<(Pubkey, bool)>, | |||
) -> Vec<Instruction> { | |||
let space = T::max_space().saturating_add(serialized_size(&ConfigKeys { keys }).unwrap()); | |||
let space = T::max_space() + bincode::serialized_size(&ConfigKeys { keys }).unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this change intended?
Moving from anza-xyz/solana-sdk#123