✨ Components & Systems Bundle#207
Open
notdanilo wants to merge 42 commits into
Open
Conversation
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.
Problem
Deployment cost of projects with several components and systems programs might get too high. We want to allow developers to bundle systems and components in a single program to reduce deployment costs.
Solution
Introduce the
#[bundle]to allow to ship several#[component]s and#[system]s in a single program.To implement this, we need to add discriminators for components and systems in the program.
The biggest API change is in the delegation instruction, because now we need to send the seeds as a parameter.
Greptile Overview
Updated On: 2025-10-06 07:08:22 UTC
Summary
This PR introduces a major architectural feature called "bundling" that allows developers to combine multiple `#[component]`s and `#[system]`s into a single Solana program, addressing the high deployment costs of approximately 1.7 SOL per component/system. The solution adds a new `#[bundle]` procedural macro that generates unified programs with discriminator-based routing to distinguish between different components and systems within the same program.The implementation involves significant changes across the entire codebase:
Core Architecture Changes:
bolt-componentandbolt-systemprograms, replacing them with bundle functionalitybolt-attributecrate to enable code reuse between standalone and bundled deploymentsBundle Implementation:
#[bundle]macro processes modules containing mixed component structs and system modulesClient Integration:
ComponentandSystemclasses provide abstractions for working with both standalone and bundled entitiesGetDiscriminatorfunctions implement Anchor's standard SHA-256-based discriminator generationDevelopment Workflow:
bolt bundle <name>creates bundle templates inprograms-ecs/bundles/The bundling feature maintains backward compatibility with existing standalone components and systems while providing a cost-effective deployment option for projects with multiple ECS entities. The architecture enables the same component and system logic to work in both contexts through shared instruction modules and unified API interfaces.
Sequence Diagram
sequenceDiagram participant User participant BoltCLI participant BundleTemplate participant BundleAttribute participant ComponentGen participant SystemGen participant AnchorProgram User->>BoltCLI: "bolt bundle example-bundle" BoltCLI->>BundleTemplate: "create_bundle_template()" BundleTemplate->>BundleTemplate: "generate bundle lib.rs with #[bundle]" BundleTemplate-->>BoltCLI: "bundle files created" User->>AnchorProgram: "anchor build" AnchorProgram->>BundleAttribute: "process(#[bundle] mod)" BundleAttribute->>BundleAttribute: "parse bundle module content" loop "for each item in bundle" alt "item is #[component] struct" BundleAttribute->>ComponentGen: "generate_implementation()" ComponentGen->>ComponentGen: "generate initialize/update/destroy functions" ComponentGen->>ComponentGen: "add component name as PDA seed suffix" ComponentGen-->>BundleAttribute: "component instructions generated" else "item is #[system] mod" BundleAttribute->>SystemGen: "transform_module_for_bundle()" SystemGen->>SystemGen: "rename Components to {name}Components" SystemGen->>SystemGen: "generate {name}_bolt_execute wrapper" SystemGen-->>BundleAttribute: "system instructions generated" end end BundleAttribute->>BundleAttribute: "wrap everything in #[program] module" BundleAttribute-->>AnchorProgram: "unified program module" User->>User: "deploy bundle as single program" Note over User,AnchorProgram: Bundle allows multiple components/systems<br/>in one program to reduce deployment costsSummary by CodeRabbit
New Features
Improvements