bolt icon indicating copy to clipboard operation
bolt copied to clipboard

🔐 New address

Open notdanilo opened this issue 1 month ago • 1 comments

Status Type ⚠️ Core Change Issue
Ready Refactor Yes None

Problem

New version of Bolt introduces a breaking change, we want to keep a program that is retro-compatible while introducing a new one with the breaking changes.

Solution

New program with the new features

Summary by CodeRabbit

  • New Features

    • Added bundle support combining components and systems into unified programs.
    • Added CLI command to create new bundles.
    • Introduced new Component and System classes in TypeScript and C# clients.
    • Updated instruction APIs with new discriminator-based methods and improved type handling.
  • Chores

    • Updated world program identifier.
    • Reorganized workspace members and dependencies.

notdanilo avatar Nov 04 '25 20:11 notdanilo

Walkthrough

This pull request refactors the Bolt framework's architecture by consolidating attribute macros into a unified bolt-attribute crate, removing standalone bolt-component and bolt-system programs, and introducing a new bundle concept for combining components and systems. It adds ECS support classes (Component, System, Identifier) to TypeScript and C# clients, updates the World program with discriminator-based CPI calls, and extends CLI tooling and test infrastructure for bundle support. World program ID has been updated across configurations.

Changes

Cohort / File(s) Summary
CI/CD Workflows
.github/workflows/publish-bolt-crates.yml, publish-bolt-sdk.yml, run-tests.yml
Added deployment keypair provisioning for example_bundle; restructured crate publish list (removed bolt-component, bolt-system, bolt-delegate, bolt-program; added bolt-attribute-bolt-bundle)
Configuration & Manifests
Anchor.toml, Cargo.toml, crates/bolt-lang/Cargo.toml, crates/programs/world/Cargo.toml
Updated workspace members and dependencies; reorganized localnet programs; changed devnet world ID; replaced bolt-component/bolt-system with bundle-related entries; added const-crypto and sha2 dependencies
Attribute Macro Consolidation
crates/bolt-lang/attribute/Cargo.toml, crates/bolt-lang/attribute/bolt-program/src/lib.rs (deleted), crates/bolt-lang/attribute/component/src/lib.rs, crates/bolt-lang/attribute/delegate/src/lib.rs (deleted), crates/bolt-lang/attribute/bundle/Cargo.toml
Consolidated attribute macro logic into unified bolt-attribute crate; renamed bolt-attribute-bolt-delegate to bolt-attribute-bolt-bundle; removed standalone bolt-program and delegate macros; delegated component processing to central processor
Attribute Macro Implementations
crates/bolt-lang/attribute/src/lib.rs, crates/bolt-lang/attribute/src/component/mod.rs, crates/bolt-lang/attribute/src/system/mod.rs, crates/bolt-lang/attribute/src/bundle/mod.rs, crates/bolt-lang/attribute/src/delegate/mod.rs
Added modular attribute processing for component, system, bundle, and delegate with code generation helpers and module transformation logic
Component Deserialization & System Input
crates/bolt-lang/attribute/component-deserialize/src/lib.rs, crates/bolt-lang/attribute/system-input/src/lib.rs
Introduced SHA-256 based discriminator generation for components; updated system input to use Signer<'info> and relocated NumberOfComponents trait to bolt-lang
Utility Attributes
crates/bolt-lang/attribute/extra-accounts/src/lib.rs
Dynamically generated trait names and struct generation; added heck dependency for case conversion
Bundle CLI & Templates
crates/bolt-cli/src/bundle.rs, crates/bolt-cli/src/lib.rs, crates/bolt-cli/src/rust_template.rs, crates/bolt-cli/src/templates/bundle/lib.rs.template, crates/bolt-cli/src/templates/bundle/mod.rs, crates/bolt-cli/src/templates/mod.rs, crates/bolt-cli/src/templates/workspace/workspace.toml.template
Added Bundle command and bundle creation templates; registered new bundle workflow in CLI dispatcher
Core Bolt Lang
crates/bolt-lang/src/lib.rs, crates/bolt-lang/src/cpi/mod.rs, crates/bolt-lang/src/errors.rs, crates/bolt-lang/src/instructions/mod.rs, crates/bolt-lang/src/instructions/initialize.rs, crates/bolt-lang/src/instructions/destroy.rs, crates/bolt-lang/src/instructions/update.rs
Added new CPI validation, instruction lifecycle functions (initialize, destroy, update), NumberOfComponents trait, and BoltMetadata helpers; added AccountMismatch and ComponentNotDelegateable error variants
Removed Programs
crates/programs/bolt-component/*, crates/programs/bolt-system/*
Deleted standalone component and system program implementations; moved functionality into bundle and core instruction modules
World Program Refactoring
crates/programs/world/src/lib.rs, crates/programs/world/src/utils.rs, crates/programs/world/Cargo.toml
Refactored CPI invocations from CpiContext-based to explicit Solana SDK calls; introduced discriminator-based routing; added utils module with discriminator_for function; updated program ID
TypeScript Client - ECS Classes
clients/typescript/src/ecs/identifier.ts, clients/typescript/src/ecs/component.ts, clients/typescript/src/ecs/system.ts, clients/typescript/src/ecs/index.ts
Added Identifier, Component, and System classes with method discriminator, PDA, and conversion support
TypeScript Client - Core
clients/typescript/src/index.ts, clients/typescript/.solitarc.js, clients/typescript/idl/world.json
Exported Component and System; added GetDiscriminator utility; updated world program ID
TypeScript Client - Transactions
clients/typescript/src/delegation/delegate.ts, clients/typescript/src/world/transactions.ts
Updated signatures to accept Component/System objects; refactored initialization, destruction, and apply flows to use discriminators; added component/system resolution via factory methods
TypeScript Client - Tests & Framework
clients/typescript/test/framework.ts, clients/typescript/test/intermediate-level/acceleration.ts, clients/typescript/test/intermediate-level/ecs.ts
Added ExampleBundle program support; added bundle-related PDA fields; extended test coverage for bundled components and systems
C# Client - ECS Classes
clients/csharp/Solana.Unity.Bolt/ECS/Identifier.cs, clients/csharp/Solana.Unity.Bolt/ECS/Component.cs, clients/csharp/Solana.Unity.Bolt/ECS/System.cs
Introduced Identifier, Component, and System classes with method discriminator and conversion support
C# Client - World Program
clients/csharp/Solana.Unity.Bolt/WorldProgram/Bolt.cs, clients/csharp/Solana.Unity.Bolt/WorldProgram/Generated.cs, clients/csharp/Solana.Unity.Bolt/WorldProgram/World.cs
Added GetDiscriminator utility; introduced ApplyWithDiscriminator and ApplyWithSessionAndDiscriminator methods; added CpiAuthAddress field; updated world program ID
C# Client - Component Operations
clients/csharp/Solana.Unity.Bolt/WorldProgram/Bolt/ApplySystem.cs, clients/csharp/Solana.Unity.Bolt/WorldProgram/Bolt/InitializeComponent.cs, clients/csharp/Solana.Unity.Bolt/WorldProgram/Bolt/DestroyComponent.cs, clients/csharp/Solana.Unity.Bolt/WorldProgram/Bolt/DelegateComponent.cs
Added Component-aware overloads for initialize, destroy, delegate, and apply operations with discriminator-based routing
C# Client - Tests & Framework
clients/csharp/Solana.Unity.Bolt.Test/Framework.cs, clients/csharp/Solana.Unity.Bolt.Test/AccelerationTest.cs, clients/csharp/Solana.Unity.Bolt.Test/ECSTest.cs
Added ExampleBundle program support; extended test methods for bundled component initialization and bundled system application
Example Bundle
examples/bundle/Cargo.toml, examples/bundle/src/lib.rs
Added new example bundle module with Position and Velocity components and movement/stop systems
Test & Build Scripts
scripts/test-publish.sh, tests/test-validator.sh, docs/REPORT.md, crates/bolt-lang/utils/src/lib.rs
Updated publish script to reflect new crate structure; updated validator test with new world program ID; updated performance report data; minor utility change for bolt_metadata field ordering

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant BundleProgram as Bundle Program<br/>(example_bundle)
    participant WorldProgram as World Program
    participant Sysvar as Instruction Sysvar

    rect rgb(200, 220, 255)
    Note over Client,WorldProgram: Old Flow: CpiContext-based
    Client->>WorldProgram: InitializeComponent<br/>(via CpiContext)
    WorldProgram->>BundleProgram: CPI (auto-generated context)
    end

    rect rgb(220, 240, 220)
    Note over Client,WorldProgram: New Flow: Discriminator-based
    Client->>WorldProgram: InitializeComponent<br/>(with discriminator)
    WorldProgram->>Sysvar: Verify caller via<br/>instruction sysvar
    Sysvar-->>WorldProgram: Instruction validated
    WorldProgram->>BundleProgram: CPI (explicit instruction<br/>+ accounts + discriminator)
    BundleProgram-->>WorldProgram: Component initialized
    end

    rect rgb(240, 240, 220)
    Note over Client,WorldProgram: Bundle Apply Flow
    Client->>WorldProgram: ApplySystem<br/>(system_id, entities, args)
    WorldProgram->>BundleProgram: Execute system<br/>(bolt_execute)
    BundleProgram-->>WorldProgram: Execution result
    WorldProgram->>BundleProgram: Update component<br/>(update with discriminator)
    BundleProgram-->>WorldProgram: Component updated
    end

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~75 minutes

Areas requiring extra attention:

  • Attribute macro refactoring (crates/bolt-lang/attribute/src/*): Complex procedural macro logic with interconnected code generation for components, systems, bundles, and delegates. Requires understanding of token stream processing and trait implementations.
  • World program CPI changes (crates/programs/world/src/lib.rs): Significant architectural shift from auto-generated CpiContext patterns to explicit Solana SDK invocations with discriminator routing. High logic density requiring careful verification of account ordering and discriminator computation.
  • Component/System/Identifier classes (across TypeScript and C# clients): Parallel implementations in multiple languages with new factory methods and PDA derivation logic; ensure consistency across bindings.
  • Removed programs (crates/programs/bolt-component/ and crates/programs/bolt-system/): Verify that all functionality previously in these programs is correctly migrated to the new instruction module and bundle system.
  • Discriminator computation (SHA-256 based): Verify discriminator generation is consistent across Rust, TypeScript, and C# implementations, especially in const/compile-time evaluations.

Possibly related PRs

  • bolt#213: Changes CPI authentication by replacing cpi_auth/World PDA usage with instruction sysvar validation (InstructionSysvarAccount) and adjusts generated account field handling—directly related to the instruction sysvar check pattern introduced here.

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title '🔐 New address' is vague and does not clearly convey the main purpose of this substantial refactoring PR. Use a more descriptive title that captures the primary change, such as 'Refactor: Update World program ID and introduce bundle architecture' or 'Add new World program with bundle support and deprecate legacy components'.
✅ Passed checks (1 passed)
Check name Status Explanation
Description check ✅ Passed The PR description follows the template structure with Status, Type, Core Change fields filled in and includes Problem/Solution sections explaining the refactoring rationale.
✨ Finishing touches
  • [ ] 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • [ ] Create PR with unit tests
  • [ ] Post copyable unit tests in a comment
  • [ ] Commit unit tests in branch feature/new-address

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar Nov 04 '25 20:11 coderabbitai[bot]