-
Notifications
You must be signed in to change notification settings - Fork 24
Feature: Implemented Configuration System With sbpf.toml #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
This is awesome. Let me collate some additional feedback and make sure we have covered everything. It looks very complete though. Great work! |
|
My preliminary thoughts: Overall very good. I have a few critiques:
Let me know what you think :) |
Work 2 weeks on a side geyser client, come back to main project and forget how to build (real) Also interested by Dean suggestion for the tests in any languages/framework |
|
Thanks for the feedback! I think these suggestions make the system much more flexible:
[test]
language = "typescript" # Defaults to "yarn test"
# command = "pnpm test" # Override when needed
[deploy]
default = "devnet" # default environment
localhost = { keypair_dir = "./deploy", url = "http://localhost:8899" }
devnet = { keypair_dir = "./keys/devnet", url = "https://api.devnet.solana.com" }
mainnet = { keypair_dir = "./keys/mainnet", url = "https://api.mainnet-beta.solana.com" }The command custom_rpc_endpoint = { keypair_dir = "./keys/custom_rpc", url = "https://custom-rpc.example.com" } #custom rpc endpointand then deploy using the command: sbpf deploy --env custom_rpc_endpoint |
|
I think the way I'd rather go about it is to do something more like this: [project]
name = "my-solana-program"
version = "0.1.0"
[scripts]
test = "cargo test"
[deploy]
cluster = "http://localhost:8899"
wallet = "~/.config/solana/id.json"That way, the test script is totally customizable and interoperable with any Anchor test script, and we can make it easy for the user to set up multiple other scripts, and for deploy, they can just maintain multiple versions and comment out the ones the don't want to public. The only downside I can see here is that it would be rather easy to accidentally dox your deployment RPC. |
127eaf0 to
8128d19
Compare
|
I'm done working on it @deanmlittle. Check it out. I also made some improvements to the CLI. In details: Environment Variables
Scripts
Security Warnings
CLI Override
Build
Cluster
|
bf08557 to
28d0321
Compare
28d0321 to
1e0be17
Compare
Add Configuration System with sbpf.toml
The Problem I Discovered
While using sbpf, I noticed some patterns that made development slower and more error-prone:
Developers working on Solana programs end up typing the same command-line flags over and over again. For example, someone working on a DeFi protocol might type
sbpf deploy my-program localhostdozens of times per day. When they forget and accidentally deploy the code to mainnet... well, that's a very expensive mistake.I've seen teams where each developer had their own way of building the same project. Dean uses release builds and deploys to devnet, Joe uses debug builds on localhost, Toly has custom linker flags. When Dean tells Joe "just run sbpf build," they get different results because there's no shared understanding of how the project should be built.
Developers working on multiple Solana projects simultaneously have to mentally remember completely different command sequences for each project. Project A needs optimization flags, Project B needs custom linker scripts, Project C deploys to testnet. This is exhausting and mistakes are inevitable.
Why I Almost Didn't Fix It
Honestly, I debated whether this was worth the effort:
sbpf build --optimization releaseyou know exactly what's happeningWhy I Went Ahead Anyway
But then I realized this isn't just about saving keystrokes, it's about developer experience and team collaboration:
Time is money
Most wonderful development tools use configuration files
Configuration prevents the mistakes highlighted above
I believe there are big plans for sbpf so configuration would be necessary for some of these plans to actually be possible
What I added
I added a TOML-based configuration system that transforms sbpf into a project-aware development environment:
New Features Added
1.
sbpf.tomlConfiguration Files2. Configuration Management Commands
sbpf config init- Create configuration filesbpf config show- View current settingssbpf config set key value- Modify settings3. Project Initialization
sbpf initnow automatically createssbpf.tomlfiles4. Configuration-Aware Commands
build,deploy,test) now respect configurationHow to Try It
Create a new project with configuration:
Add configuration to existing project:
Customize or modify your project configuration:
Build with project awareness:
What I Tested
I tested this to ensure I got the exact result I envisioned:
Existing projects without configuration files work exactly as before. No breaking changes.
You can create a project with configuration, commit it to git, and verify that anyone cloning the repo gets identical build behavior without setup.
Tested malformed TOML files, missing configuration, invalid values and they all produce helpful error messages that guide users to solutions.
Verified that command-line arguments still override configuration when specified, maintaining user control.
The Results
The transformation is immediate and noticeable:
Before:
After: