Skip to content

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
mariuszzak/generate-rust-types-from-idl
Open

feat(solana): add solana-ibc-sdk, decouple relayer and solana-ibc-types and remove duplicated types#957
mariuszzak wants to merge 32 commits intomainfrom
mariuszzak/generate-rust-types-from-idl

Conversation

@mariuszzak
Copy link
Collaborator

Description

  • Introduce solana-ibc-sdk — an auto-generated off-chain SDK that produces typed instruction builders, PDA
    derivation 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-header and solana-ibc-gmp-types into standalone crates (previously modules inside
    solana-ibc-types)

  • Decouple the relayer and operator from solana-ibc-types: they now depend on solana-ibc-sdk and the new
    leaf crates instead. solana-ibc-types is now only shared between on-chain Solana programs.

  • Remove hand-maintained type duplicates, serialization compatibility tests and the light-client feature from
    solana-ibc-types (moved to solana-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:#ea580c
    
    Loading

Before 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.

  • Linked to GitHub issue with discussion and accepted design, OR link to spec that describes this work.
  • Wrote unit and integration tests.
  • Added relevant natspec and godoc comments.
  • Provide a conventional commit message to follow the repository standards.
  • Re-reviewed Files changed in the GitHub PR explorer.
  • Review SonarCloud Report in the comment section below once CI passes.

…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
@mariuszzak mariuszzak self-assigned this Feb 26, 2026
@codecov
Copy link

codecov bot commented Feb 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.91%. Comparing base (14730c5) to head (4af9170).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mariuszzak mariuszzak changed the title feat(solana): add solana-ibc-sdk with IDL codegen and remove types duplication feat(solana): add solana-ibc-sdk, decouple relayer with solana-ibc-types and remove duplicated types Feb 26, 2026
@mariuszzak mariuszzak changed the title feat(solana): add solana-ibc-sdk, decouple relayer with solana-ibc-types and remove duplicated types feat(solana): add solana-ibc-sdk, decouple relayer and solana-ibc-types and remove duplicated types Feb 26, 2026
- 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.
@mariuszzak mariuszzak marked this pull request as ready for review March 6, 2026 12:56
@mariuszzak mariuszzak requested a review from srdtrk as a code owner March 6, 2026 12:56
vaporif and others added 8 commits March 19, 2026 23:18
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants