feat(solana): add solana-ibc-sdk, decouple relayer and solana-ibc-types and remove duplicated types#957
Open
mariuszzak wants to merge 32 commits intomainfrom
Open
feat(solana): add solana-ibc-sdk, decouple relayer and solana-ibc-types and remove duplicated types#957mariuszzak wants to merge 32 commits intomainfrom
mariuszzak wants to merge 32 commits intomainfrom
Conversation
…r from solana-ibc-types Introduce solana-ibc-sdk, a new crate that auto-generates Rust types, instruction builders, PDA helpers and event structs from Anchor IDL files via a build.rs codegen step (solana-ibc-sdk-codegen). Extract borsh_header and ics27 modules from solana-ibc-types into standalone crates (solana-ibc-borsh-header, solana-ibc-gmp-types) so they can be consumed independently. Migrate the relayer and operator to depend on solana-ibc-sdk and the new leaf crates instead of solana-ibc-types, which is now scoped to shared types between on-chain Solana programs only.
- Classify IDL instruction args into three patterns: no args, single defined type and flat/mixed args - Generate BorshSerialize/BorshDeserialize args structs for flat-arg instructions and typed build_instruction signatures per pattern - Thread NameMap and has_accounts/has_types flags through codegen to resolve IDL types and emit correct super imports - Replace manual byte construction and try_to_vec calls in relayer consumers with typed args structs
- Codegen produces `{Ix}Builder` with chained `.accounts()`, `.args()`, `.remaining_accounts()`, `.build()`
- `{Ix}` becomes a unit struct (namespace for constants and PDA helpers)
- Removed `new()`, `to_account_metas()` and `build_instruction()` from generated code
- Updated all 13 relayer call sites to the builder API
- Replace hardcoded keyword list with syn::parse_str::<Ident>() - Automatically stays current with Rust's keyword grammar
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #957 +/- ##
=======================================
Coverage 99.91% 99.91%
=======================================
Files 27 27
Lines 1123 1123
=======================================
Hits 1122 1122
Misses 1 1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
- Resolve cross-program and dot-path PDAs in codegen - Emit standalone PDA helper methods for Provided accounts - Replace hardcoded PDA seeds in relayer ift.rs with generated helpers - Add tests for cross-program PDA resolution and provided account helpers
- Add pda module with helpers for accounts Anchor omits from the IDL - ics07_tendermint: header_chunk_pda, sig_verify_pda - ics26_router: payload_chunk_pda, proof_chunk_pda - ibc_app: app_state_pda for dynamic IBC app programs - Replace all hardcoded find_program_address in relayer with SDK helpers
- Remove derive_header_chunk, payload_chunk_pda and proof_chunk_pda wrappers - Call solana_ibc_sdk::pda helpers directly at each call site
- Use module aliases (att/tm) for readability in derive_light_client_pdas - Add const to UcAndMembershipOutput::new to fix clippy warning
Sync generated SDK code with the pause/unpause feature merged from main: add `paused` field to `RouterState`, `Pause`/`Unpause` instruction builders and event types.
…ed paths The import already used `solana_ibc_gmp_types` but the call sites still referenced the old `solana_ibc_types` module.
The FinalizeTransferAccounts struct no longer has an ift_bridge field; app_state, app_mint_state and mint_authority are auto-derived by the SDK builder. Also includes regenerated Go anchor bindings.
Co-authored-by: srdtrk <59252793+srdtrk@users.noreply.github.com>
Co-authored-by: srdtrk <59252793+srdtrk@users.noreply.github.com>
- Resolve merge conflict in ics26_router events.rs - Rename ClientSequenceWithArgSeedPDA to CseqWithArgSeedPDA in e2e tests
- Regenerate PDA helpers with renamed cseq seed - Add authority and program_data to initialize instructions - Update timeout_timestamp from i64 to u64 - Add encoding field to SendCallMsg - Remove stale ProgramExtendedEvent
Drop old ClientSequenceWithArgSeedPDA functions from main since they were renamed to CseqWithArgSeedPDA on this branch.
Remove program_data and authority from initialize instructions and drop encoding field from SendCallMsg.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Introduce
solana-ibc-sdk— an auto-generated off-chain SDK that produces typed instruction builders, PDAderivation helpers, account structs and event types from Anchor IDL files for all six Solana programs
(ics26-router, ics07-tendermint, attestation, ift, ics27-gmp, access-manager)
Extract
solana-ibc-borsh-headerandsolana-ibc-gmp-typesinto standalone crates (previously modules insidesolana-ibc-types)Decouple the relayer and operator from
solana-ibc-types: they now depend onsolana-ibc-sdkand the newleaf crates instead.
solana-ibc-typesis now only shared between on-chain Solana programs.Remove hand-maintained type duplicates, serialization compatibility tests and the
light-clientfeature fromsolana-ibc-types(moved tosolana-ibc-borsh-header)Add a dependency graph to the Solana README
Dependency graph
graph LR subgraph shared["Solana Packages"] types["solana-ibc-types"] sdk["solana-ibc-sdk"] constants["solana-ibc-constants"] proto["solana-ibc-proto"] borsh["solana-ibc-borsh-header"] ics25["ics25-handler"] gmp_types["solana-ibc-gmp-types"] macros["solana-ibc-macros"] end subgraph programs["Solana Programs"] am["access-manager"] ics07["ics07-tendermint"] ics26["ics26-router"] ics27["ics27-gmp"] ift["ift"] att["attestation"] end idls["IDL files<br/><i>target/idl/*.json</i>"] subgraph relayer["Relayer"] c2s["cosmos-to-solana"] end subgraph tm["Tendermint Light Client"] tm_update["update-client"] tm_membership["membership"] tm_misbehaviour["misbehaviour"] end types --> constants types --> proto types --> macros types --> gmp_types gmp_types --> proto am --> types ics07 --> am ics07 --> types ics07 --> ics25 ics07 --> borsh ics07 --> constants ics07 --> tm_update ics07 --> tm_membership ics07 --> tm_misbehaviour ics26 --> am ics26 --> types ics26 --> ics25 ics26 --> constants ics27 --> ics26 ics27 --> am ics27 --> types ics27 --> proto ics27 --> macros ift --> ics26 ift --> ics27 ift --> types ift --> gmp_types att --> am att --> types att --> ics25 am -.- idls ics07 -.- idls ics26 -.- idls ics27 -.- idls ift -.- idls att -.- idls idls -.-|build.rs codegen| sdk c2s --> sdk c2s --> constants c2s --> proto c2s --> borsh c2s --> gmp_types style shared fill:#e0e7ff,stroke:#4f46e5,color:#1e1b4b style programs fill:#d1fae5,stroke:#059669,color:#064e3b style relayer fill:#ffedd5,stroke:#ea580c,color:#7c2d12 style tm fill:#fce7f3,stroke:#db2777,color:#831843 style idls fill:#fef9c3,stroke:#ca8a04,color:#713f12 classDef sharedNode fill:#c7d2fe,stroke:#4f46e5,color:#1e1b4b classDef programNode fill:#a7f3d0,stroke:#059669,color:#064e3b classDef relayerNode fill:#fed7aa,stroke:#ea580c,color:#7c2d12 classDef tmNode fill:#fbcfe8,stroke:#db2777,color:#831843 classDef idlNode fill:#fef08a,stroke:#ca8a04,color:#713f12 class types,sdk,constants,proto,borsh,ics25,gmp_types,macros sharedNode class am,ics07,ics26,ics27,ift,att programNode class c2s,s2c relayerNode class tm_update,tm_membership,tm_misbehaviour tmNode class idls idlNode linkStyle 0,1,2,3,4 stroke:#4f46e5 linkStyle 5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29 stroke:#059669 linkStyle 30,31,32,33,34,35,36 stroke:#ca8a04,stroke-dasharray:5 5 linkStyle 37,38,39,40,41 stroke:#ea580cBefore we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.
godoccomments.Files changedin the GitHub PR explorer.SonarCloud Reportin the comment section below once CI passes.