During the BSV DevCon, which took place during the London Blockchain Conference run-up, Ty Everett (Founder of Project Babbage) presented the ‘Bitcoin CPU’. The CPU represents a breakthrough in blockchain technology, enabling general-purpose computation on a blockchain for the first time.
During his presentation, Everett outlined the challenges that arose during the development of the CPU, how he solved them, how the CPU is structured and functions and which use cases the CPU enables.
Groundwork for the Bitcoin CPU
Everett started by explaining the groundwork of the Bitcoin CPU, which consists of the transaction structure of BSV. Each transaction has inputs and outputs, where outputs act as predicates or locks to ensure only authorised parties can access the coins. These outputs can be constrained to enforce specific rules, like defining what subsequent transactions can be, leading to stateful UTXOs or stateful smart contracts.
However, creating contracts with an undefined number of future transactions is challenging. For example, if Alice sets up a smart contract and Bob tries to solve it across multiple transactions, there’s a risk. Bob could broadcast a malicious partial solution, corrupting Alice’s original output. This corruption prevents achieving the correct solution if missteps occur in the process. The ‘Bitcoin CPU’ found a solution for this in the solver’s bond.
The solver’s bond
In the example that Everett used, Alice proposes a contract on BSV, and Bob posts a bond to start solving it. A timer begins, giving Bob a limited period to satisfy all the multi-stage constraints across several transactions. If Bob’s solution is valid, the UTXO is unlocked, and everything proceeds smoothly. If Bob’s solution is invalid, the UTXO becomes locked.
Once the timer expires, the state of the UTXO resets to its original condition before Bob’s attempt, causing Bob to lose his bond. Carol, or another participant, can then attempt the solution with a higher bounty. This process continues until the UTXO is successfully unlocked or fully consumed. This mechanism ensures multi-stage computation on the BSV blockchain (BSV) without causing network disruption, allowing more complex transactions and smart contracts.
Instruction set architecture of the Bitcoin CPU
The described CPU has four registers, a stack, and a heap. It includes various opcodes, a base pointer, an execution pointer, and a stack pointer, similar to standard CPUs. Implemented in sCrypt, it supports instructions like JSR and RSR for recursive subroutine calls.
Everett explained that each transaction functions as a clock pulse, allowing one opcode execution per transaction, with potential future support for multiple opcodes per transaction. These are the fundamental aspects of the architecture.
Everett used an illustration in the presentation to highlight the Instruction Set Architecture (ISA). Throughout his presentation, he referred to it to showcase its functionality, for example for the different opcodes the CPU operates with.
Opcodes of the CPU
Everett discussed various opcodes for executing programs within transactions. Key opcodes include:
- op_win: Terminates the program, releasing the UTXO when the solution is reached.
- op_lose: Halts the CPU, leading to a timer expiry, state reset, and restart by another participant.
- op_bill: Adds additional money to the contract as defined in a register, allowing for financial inputs during execution.
- op_pay: Pays out money from the system, using large numbers in scripts to facilitate this, continuing execution afterwards.
- Checkpoint: Allows state resets to a specific point, not just the initial state, enabling updates and partial progress saving.
These opcodes support complex computations and financial transactions within the framework of the BSV blockchain. In his presentation, Everett explained the different opcodes in more detail and also highlighted that he is particularly excited about the capabilities of op_pay and op_bill.
Innovations by the Bitcoin CPU
In many aspects, the Bitcoin CPU is unique, as it offers several groundbreaking features and implications, Everett particularly emphasised the following:
- Off-chain Memory Storage: The heap and stack are stored off-chain, while their Merkle roots are stored on-chain. This allows for virtually unlimited memory capacity, as memory can be dynamically allocated off-chain and selectively disclosed to solvers as needed.
- Dynamic Memory Sizing: Memory elements can dynamically adjust in size, accommodating large data structures such as strings or factorial computations (like 52 factorial), enhancing computational capabilities significantly.
- Memory-Mapped I/O: Users can configure custom memory-mapped I/O, enabling diverse interactions with external devices or applications. This flexibility supports versatile applications, including potentially running complex tasks like gaming.
- New Assembly Language and ISA: A new assembly language and instruction set architecture (ISA) incorporate unique opcodes like op_bill and op_pay, facilitating financial transactions and enhancing computational flexibility on BSV.
- Future Development: The architecture supports compiling various programs to it, expanding its utility beyond initial implementations and paving the way for diverse applications in distributed computing environments.
Breakthrough in the Bitcoin CPU
Towards the end of his presentation, Everett highlighted how the Bitcoin CPU is a breakthrough in technological terms.
- State Reset: The innovation of state reset opens up new possibilities beyond traditional CPU functionalities, potentially impacting distributed computing significantly.
- Beyond CPU: Recognising the architecture’s potential, it’s seen as more than just a CPU, differing from ASICs in terms of script size efficiency.
- Future Directions: Plans include developing compilers for other languages to run on this architecture, and fostering diverse applications and innovations.
Everett also highlighted that the current goal is to optimise the script further, exploring techniques such as hashed chains for improved efficiency. Initially, sCrypt’s ECDSA (elliptic curve digital signature algorithm) was implemented, but it led to an increased data volume of 8MB per transaction, while the current implementation involves 2MB per transaction.
Use cases and implications
Everett also briefly discussed exemplary use cases such as adaptive routing in logistics, which can be enhanced by creating a simulated world using a high-level language that compiles down to simulate various networks and solve problems using real-time data.
Beyond logistics, this technology can be applied in the financial industry for dynamic portfolio rebalancing and managing digital assets. It supports complex constraints for tokenised CBDCs and integrates identity solutions for enhanced security and compliance. Everett suggested that a hackathon would be suited to explore further use cases of the Bitcoin CPU.
The Bitcoin CPU is a further demonstration of the Turing completeness of the BSV blockchain, which is the only blockchain capable of operating a CPU as outlined on the scale. Everett also pointed to Teranode and acknowledged one million transactions per second as a significant milestone for blockchain technology. However, he also mentioned that a much higher scale is necessary, to operate something like the Bitcoin CPU in meaningful terms.