-
Notifications
You must be signed in to change notification settings - Fork 131
interface: Split out instructions, state, errors from program #616
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
Conversation
#### Problem The token-2022 program has some heavy dependencies that most users of the crate don't care about. This causes dependency issues and long compilation times. Also, the program uses Agave dependencies, which creates circular dependencies and makes it impossible to upgrade to SDK v3 without some complicated gymnastics. #### Summary of changes Similar to the ATA's interface crate, split out everything need by Agave into a separate crate, which can also be used by on-chain programs as an rlib, and thus allow for LTO in program builds.
|
Sorry for the size of this! The general pattern for the changes goes: interface crate has:
for each extension:
The program has all of the above modules, but they just re-export everything from the interface. On top of that it has:
And for each extension, on top of re-exporting the structs and instructions, it includes:
lib.rs is a bit special, so some functions are split between the program and the interface as makes sense. I also removed a dependency on spl-token for my future sanity. This might be a bit of a monster to review, but the changes should be straightforward. |
Got it, starting to comb through it. |
rustopian
left a comment
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. Large mechanical code relocation. Notable changes along the way:
serde_traits->serde- removal of
PodTokenInstructionpassages in tests - import and import path updates
- visibility + doc comment tweaks
- removed
test_decimals()innative_mint.rs
A few nits, but most are minor errors in the doc comments which were already present.
| std::convert::TryInto, | ||
| }; | ||
|
|
||
| /// Interesting-bearing mint extension instructions |
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.
| /// Interesting-bearing mint extension instructions | |
| /// Interest-bearing mint extension instructions |
| /// 0. `[writable]` The mint to initialize. | ||
| /// | ||
| /// Data expected by this instruction: | ||
| /// `crate::extension::interest_bearing::instruction::InitializeInstructionData` |
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.
| /// `crate::extension::interest_bearing::instruction::InitializeInstructionData` | |
| /// `crate::extension::interest_bearing_mint::instruction::InitializeInstructionData` |
| pub decryptable_supply: PodAeCiphertext, | ||
| } | ||
|
|
||
| /// Data expected by `ConfidentialMintBurnInstruction::RotateSupplyElGamal` |
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.
| /// Data expected by `ConfidentialMintBurnInstruction::RotateSupplyElGamal` | |
| /// Data expected by `ConfidentialMintBurnInstruction::RotateSupplyElGamalPubkey` |
| pub new_supply_elgamal_pubkey: PodElGamalPubkey, | ||
| /// The location of the | ||
| /// `ProofInstruction::VerifyCiphertextCiphertextEquality` instruction | ||
| /// relative to the `RotateSupplyElGamal` instruction in the transaction |
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.
| /// relative to the `RotateSupplyElGamal` instruction in the transaction | |
| /// relative to the `RotateSupplyElGamalPubkey` instruction in the | |
| /// transaction |
| )) | ||
| } | ||
|
|
||
| /// Create a `RotateSupplyElGamal` instruction |
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.
| /// Create a `RotateSupplyElGamal` instruction | |
| /// Create a `RotateSupplyElGamalPubkey` instruction |
| Ok(instructions) | ||
| } | ||
|
|
||
| /// Create a `UpdateMint` instruction |
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.
| /// Create a `UpdateMint` instruction | |
| /// Create an `UpdateDecryptableSupply` instruction |
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.
comment nits
|
Ok everything should be addressed, thanks again for the review! |
Problem
The token-2022 program has some heavy dependencies that most users of the crate don't care about. This causes dependency issues and long compilation times.
Also, the program uses Agave dependencies, which creates circular dependencies and makes it impossible to upgrade to SDK v3 without some complicated gymnastics.
Summary of changes
Similar to the ATA's interface crate, split out everything need by Agave into a separate crate, which can also be used by on-chain programs as an rlib, and thus allow for LTO in program builds.