Inspiration
I am rebuilding the bitcoin mining pool stack from the ground up because it's broke af and if we don't fix it the FPPS mining cartels are going to fuck up bitcoin for all of us. I need non-custodial coinbase payouts to make this dream a reality. CTV lets me accomplish this.
What it does
Builds and deploys a custom bitcoind fork with CTV and CSFS activated. I didn't build this part but I did nixify it by forking the repo and adding a nix flake. Spins up a regtest devenv environment with an elctrs + esplora blockchain explorer stack. Custom rust scripts to interact with the blockchain. Specifically to mine blocks with CTV coinbase transactions.
How we built it
I vibed my heart out over the course of a week and stood this thing up from sheer force of will. I kinda suck at nix, but I suck a lot less now! =D
Challenges we ran into
The hardest part was standing up the blockchain explorer. Electrs is really not well supported. First I tried mempool, but their stack is built on docker which makes me want to puke. I gave up on integrating docker with nix and switched to a pure nix build using electrs. This seemed like a good path until I realized how poorly supported this tech stack is. I finally pushed through to victory by forcing a recompile of the blockstream electrs repo with the esplora binary target. I also had to stand up a proxy to scrape the /api URL path and redirect some ports to stitch it all together. The fun part is that the frontend and backend are both part of the same repo! wtf! ¯_(ツ)_/¯
The CTV coinbase scripts were also very challenging to write. I have never really hacked directly on bitcoin before, so this is my first experience building custom transactions. It was really fun though. Once I had the environment set up I had a very quick feedback loop so I could really crank out some code.
Accomplishments that we're proud of
This is a really useful stack to experiment with. I will definitely be playing in the coinbase playground more. I've got a lot of ideas to explore.
What we learned
So much... Here's a few nuggets: Don't try to pass stuff from the flake to devenv. Just fork the repo, flake it, and import to devenv.nix using builtIns. tx relay policy is really complicated when it comes to anchor outputs. I am starting to believe we should delete the mempool. Mempool policy rules are complexity demon incarnate. Just is awesome! Leverage it! I used just to write a recipe to build the entire frontend and commit the whole thing. It's stupid but it works. So it's not stupid.
What's next for CTV + CSFS Coinbase Playground
Check the readme. I got lots more ideas to explore.
Built With
- bitcoind
- devenv
- electrs
- esplora
- nix
- rust
Log in or sign up for Devpost to join the conversation.