Skip to content

Commit a020d03

Browse files
committed
Add deployment optimizations
1 parent eb8cfcf commit a020d03

1 file changed

Lines changed: 188 additions & 0 deletions

File tree

DEPLOYMENT_OPTIMIZATION.md

Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
# PixeLAW App Deployment Optimization Recommendations
2+
3+
Based on analysis of the current PixeLAW deployment flow, this document outlines key optimizations to enable more permissionless app deployment to the PixeLAW world.
4+
5+
## Current Deployment Bottlenecks
6+
7+
### 1. Manual Configuration Dependencies
8+
- Apps must manually configure `world_address` in `dojo_sepolia.toml`
9+
- Requires knowing specific core deployment addresses
10+
- Manual keystore management and account setup
11+
12+
### 2. Permission Management Complexity
13+
- Apps need explicit write permissions in core's `dojo_sepolia.toml`
14+
- Core contracts control which apps can write to which models
15+
- Requires coordination with core maintainers for permission updates
16+
17+
### 3. Initialization Dependencies
18+
- Apps must call `core_actions.new_app()` during `dojo_init()`
19+
- Registration happens post-deployment, creating deployment-registration gap
20+
- Manual namespace registration required
21+
22+
## Optimization Recommendations
23+
24+
### 1. Auto-Discovery Deployment
25+
```bash
26+
# Create a registry-aware deployment script
27+
./scripts/deploy_to_world.sh --world-address <auto-detect> --app-key <unique-key>
28+
```
29+
**Benefits:**
30+
- Auto-detect existing world address from chain
31+
- Eliminate manual `dojo_sepolia.toml` world_address configuration
32+
- Use chain queries to discover core contract addresses
33+
34+
### 2. Permissionless Permission System
35+
```cairo
36+
// In core actions - implement permission-by-registration
37+
fn register_app_with_permissions(app_key: felt252, required_models: Array<felt252>) {
38+
// Automatically grant write permissions for registered apps
39+
// to standard models (Pixel, QueueItem, etc.)
40+
}
41+
```
42+
**Benefits:**
43+
- Apps self-declare required model permissions during registration
44+
- Core automatically grants standard permissions (Pixel updates, Queue operations)
45+
- Remove need for core maintainers to manually update writer permissions
46+
47+
### 3. Deployment-Time Registration
48+
```bash
49+
# Enhanced deployment script
50+
sozo migrate --profile sepolia --post-deploy-hook register_app
51+
```
52+
**Benefits:**
53+
- Combine deployment and registration into single atomic operation
54+
- Auto-call `new_app()` immediately after contract deployment
55+
- Reduce deployment-to-registration gap
56+
57+
### 4. App Registry Smart Contract
58+
```cairo
59+
#[starknet::contract]
60+
mod AppRegistry {
61+
// Permissionless app registration
62+
fn register_app(app_key: felt252, contract_address: ContractAddress) {
63+
// Validate app_key uniqueness
64+
// Auto-grant standard permissions
65+
// Emit registration event
66+
}
67+
}
68+
```
69+
**Benefits:**
70+
- Centralized app discovery mechanism
71+
- Apps register themselves without core team intervention
72+
- Event-driven frontend updates for new apps
73+
74+
### 5. Template Standardization
75+
```bash
76+
# One-command deployment
77+
pixelaw create-app --name myapp --deploy-to sepolia
78+
```
79+
**Benefits:**
80+
- Standardized CLI tool for app creation and deployment
81+
- Pre-configured templates with optimal settings
82+
- Automated APP_KEY uniqueness checking
83+
84+
### 6. Gas-Optimized Deployment
85+
**Optimizations:**
86+
- Batch app registration with initial pixel operations
87+
- Use CREATE2-style deterministic addresses for apps
88+
- Implement app proxy pattern for upgradeable deployments
89+
90+
### 7. Developer Experience Improvements
91+
```json
92+
// pixelaw.config.json
93+
{
94+
"app_key": "maze",
95+
"target_world": "sepolia-main",
96+
"auto_permissions": ["Pixel", "QueueItem"],
97+
"init_pixels": [{"x": 0, "y": 0, "color": "blue"}]
98+
}
99+
```
100+
**Benefits:**
101+
- Configuration-driven deployment
102+
- Auto-populate deployment parameters
103+
- Built-in testing against live worlds
104+
105+
## Implementation Priority
106+
107+
### Phase 1 (High Impact, Low Effort)
108+
- **Auto-discovery deployment scripts**
109+
- Create enhanced deployment scripts that auto-detect world addresses
110+
- Update template with configuration-free deployment options
111+
- **Standardized deployment templates**
112+
- Improve existing scripts with better error handling and automation
113+
- Add validation for APP_KEY uniqueness
114+
- **Documentation improvements**
115+
- Create step-by-step deployment guides
116+
- Add troubleshooting sections for common deployment issues
117+
118+
### Phase 2 (Medium Effort)
119+
- **Permissionless permission system in core**
120+
- Modify core contracts to support self-service permission granting
121+
- Implement standard permission sets for common app patterns
122+
- **App registry smart contract**
123+
- Deploy centralized registry for app discovery
124+
- Add event emission for frontend integration
125+
- **CLI tooling improvements**
126+
- Create `pixelaw` CLI tool for streamlined app development
127+
- Add commands for deployment, testing, and management
128+
129+
### Phase 3 (High Effort)
130+
- **Gas optimization patterns**
131+
- Research and implement gas-efficient deployment strategies
132+
- Add batching capabilities for multiple operations
133+
- **Proxy-based upgradeable apps**
134+
- Design upgradeable app architecture
135+
- Implement migration patterns for app updates
136+
- **Advanced developer tooling**
137+
- Build IDE extensions and development environments
138+
- Create testing frameworks specific to PixeLAW apps
139+
140+
## Expected Impact
141+
142+
These optimizations would transform the PixeLAW app deployment process from:
143+
144+
**Current State:**
145+
1. Manual world address configuration
146+
2. Coordinate with core team for permissions
147+
3. Deploy contracts separately
148+
4. Manually register app post-deployment
149+
5. Hope everything works together
150+
151+
**Optimized State:**
152+
1. Run single deployment command
153+
2. Automatic world discovery and registration
154+
3. Self-service permission granting
155+
4. Atomic deployment and registration
156+
5. Built-in validation and error handling
157+
158+
This would significantly reduce friction for developers wanting to deploy new apps to the PixeLAW world, moving from a manually-coordinated process to a truly permissionless system where apps can self-register and deploy with minimal configuration.
159+
160+
## Next Steps
161+
162+
1. **Immediate (Week 1-2):**
163+
- Enhance existing deployment scripts with auto-discovery
164+
- Add better error handling and validation
165+
- Create deployment troubleshooting guide
166+
167+
2. **Short-term (Month 1):**
168+
- Design permissionless permission system
169+
- Prototype app registry contract
170+
- Begin CLI tool development
171+
172+
3. **Medium-term (Quarter 1):**
173+
- Implement and test new permission system
174+
- Deploy app registry to testnet
175+
- Release initial CLI tooling
176+
177+
4. **Long-term (Quarter 2+):**
178+
- Implement gas optimizations
179+
- Design upgradeable app patterns
180+
- Build advanced developer tooling
181+
182+
This roadmap provides a clear path toward making PixeLAW app deployment truly permissionless while maintaining security and reliability.
183+
184+
185+
justfile that installs all the boilerplate configs from a seperate repo.
186+
base repo - includes all configs / boilerplaye (This should probably be in the devcontaienr)
187+
app template - inlcudes all app/game specific code + justfile + dev specific (i.e. private keys)
188+
ideally this works for any machine (i.e. using devcointainer/docker)

0 commit comments

Comments
 (0)