AI prompts
base on The hemi network core daemons. # ⚡️ The Hemi Network
Hemi is an EVM-compatible L2 blockchain that combines the security of Bitcoin with the programmability of Ethereum.
<details>
<summary>Table of Contents</summary>
<!-- TOC -->
* [⚡️ The Hemi Network](#-the-hemi-network)
* [🔧 Services](#-services)
* [🌐 Binaries](#-binaries)
* [⚡️ Getting Started](#-getting-started)
* [📦 Downloading Release Binaries](#-downloading-release-binaries)
* [🏗 Building from Source](#-building-from-source)
* [🏁 Prerequisites](#-prerequisites)
* [Building with Makefile](#building-with-makefile)
* [🛠 Running the Services](#-running-the-services)
* [▶️ Running popmd](#-running-popmd)
* [🏁 Prerequisites](#-prerequisites-1)
* [CLI](#cli)
* [Web](#web)
* [▶️ Running bfgd](#-running-bfgd)
* [🏁 Prerequisites](#-prerequisites-2)
* [▶️ Running bssd](#-running-bssd)
* [🏁 Prerequisites](#-prerequisites-3)
* [▶️ Running a full node](#-running-a-full-node)
* [▶️ Running the localnet network](#-running-the-localnet-network)
* [🏁 Prerequisites](#-prerequisites-4)
* [📚 Tutorial](#-tutorial)
* [📄 License](#-license)
<!-- TOC -->
</details>
---
## 🔧 Services
The Hemi Network consists of three key services, each serving a unique and important function within the network:
| Service | Description |
|-------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------|
| [**PoP Miner (popmd)**](https://github.com/hemilabs/heminetwork/blob/main/service/popm) | **Mines** L2 Keystones into Bitcoin blocks for Proof-of-Proof. |
| [**Bitcoin Finality Governor (bfgd)**](https://github.com/hemilabs/heminetwork/blob/main/service/bfg) | Acts as the gateway to the Bitcoin network. |
| [**Bitcoin Secure Sequencer (bssd)**](https://github.com/hemilabs/heminetwork/blob/main/service/bss) | Acts as a gateway to the Bitcoin Finality Governor (BFG), managing the consensus mechanisms of the Hemi Network. |
## 🌐 Binaries
- [**bfgd (Bitcoin Finality Governor Daemon)**](cmd/bfgd): Manages connections and data transfers between the Hemi
Network and the Bitcoin blockchain, ensuring finality.
- [**bssd (Bitcoin Secure Sequencer Daemon)**](cmd/bssd): Coordinates and sequences blockchain operations, serving as a
bridge to the Bitcoin Finality Governor.
- [**extool**](cmd/extool): A utility tool for extracting and processing data from various file formats, tailored for
blockchain data analysis.
- [**hemictl**](cmd/hemictl): The command-line interface for controlling and managing all Hemi Network services.
- [**keygen**](cmd/keygen): Generates and manages cryptographic keys used within the Hemi network, ensuring secure
operations.
- [**popmd (Proof-of-Proof Miner Daemon)**](cmd/popmd): Embeds L2 Keystones into Bitcoin blocks for proof-of-proof,
integral to the network's security.
- [**tbcd (Tiny Bitcoin Daemon)**](cmd/tbcd): A minimal Bitcoin block downloader and indexer daemon.
---
# ⚡️ Getting Started
## 📦 Downloading Release Binaries
Pre-built binaries are available on the [Releases Page](https://github.com/hemilabs/heminetwork/releases).
## 🏗 Building from Source
### 🏁 Prerequisites
- `git`
- `make`
- [Go v1.23+](https://go.dev/dl/)
### Building with Makefile
1. Clone the `heminetwork` repository:
```shell
git clone https://github.com/hemilabs/heminetwork.git
cd heminetwork
```
2. Setup and build binaries:
```shell
make deps # Download and install dependencies
make install # Build binaries
```
Output binaries will be written to the `bin/` directory.
---
# 🛠 Running the Services
For any service, you can view configuration options by running:
```shell
./bin/popmd --help
./bin/bfgd --help
./bin/bssd --help
```
## ▶️ Running popmd
### 🏁 Prerequisites
- A funded BTC private key. This can be a testnet address if configured for test environments.
- A BFG URL to establish a connection.
Once properly configured and running, `popmd` will start mining L2 Keystones by adding them to Bitcoin blocks that make
it into the chain.
### CLI
Set up and start popmd using:
```shell
./bin/popmd
```
### Web
There is also a web interface that can be used to run a PoP miner.
Build and run the web interface with:
> [!NOTE]
> The web PoP Miner is currently a proof-of-concept.
```shell
cd ./web
make
go run ./integrationtest
```
## ▶️ Running bfgd
### 🏁 Prerequisites
- A **PostgreSQL database**, bfgd expects the sql scripts in `./database/bfgd/scripts/` to be run to set up your schema.
- A **connection to an Electrs node** on the proper Bitcoin network (testnet or mainnet).
### Running your own Bitcoin Finality Governor (bfgd) and PoP mining with it
If you'd like to run your own `bfgd` and don't want to rely on Hemi Labs (or any third party) for _broadcasting transactions_, you may run `bfgd` and connect it to a _trusted_ `bfgd` run by a third party to _receive l2 keystones only_ (l2 keystones represent l2 state and are what are mined in PoP transactions). In this case, the third party `bfgd` will only send you l2 keystones, your `bfgd` can notify your local pop miner and this will broadcast them to your Electrs+bitcoind setup so you don't rely on Hemi Labs--or any third party--which may be congested.
You'll need the following running to do this:
* bitcoind
* electrs
* postgres
* bfgd
_Note: make sure you run all of the *.sql files for bfg in `database/bfgd/postgres/scripts`_
When running BFG, you'll want the following env variables set:
* `BFG_BFG_URL`: the _trusted_ `bfgd`'s websocket url that you will connect to
* `BFG_BTC_PRIVKEY`: your btc private key. note that this can be an unfunded private key and you'll still receive l2 keystones to mine
* `BFG_POSTGRES_URI`: the connection URI for your postgres instance
* `BFG_BTC_START_HEIGHT`: when your db is empty, bfgd will need a starting point to parse btc blocks at, set this to the tip of the bitcoin chain at first deploy
* `BFG_EXBTC_ADDRESS`: your electrs rpc address
You may then connect your local `popmd` to your aforementioned local `bfgd` via the `POPM_BFG_URL` env variable
## ▶️ Running bssd
### 🏁 Prerequisites
- Connect to a live [bfgd](#-running-bfgd) instance.
## ▶️ Running the Hemi stack
To run the full Hemi stack (non-sequencing), please see [NODE_RUNNING](localnode/NODE_RUNNING.md).
## ▶️ Running the localnet network
> [!WARNING]
> This is designed for use in testing and development environments only.
### 🏁 Prerequisites
- `docker`
### 📚 Tutorial
1. **Start the Network:** Launch the entire Hemi network locally using Docker, which will generate L2 Keystones and BTC
Blocks at a **high rate**:
```shell
docker compose -f ./e2e/docker-compose.yml up --build
```
> [!NOTE]
> The `--build` flag is optional and should only be used if you want to rebuild the binaries.
2. **Manage Caching:**
This initial build may take some time, but subsequent builds should benefit from caching.
> [!NOTE]
> During rebuilding, `popmd`, `bssd`, and `bfgd` may force a rebuild due to the `COPY` command, which can break the
> cache. If you need to deliberately break the cache for the op-stack, use the following arguments:
- For op-geth + optimism (op-node):
```shell
docker compose -f ./e2e/docker-compose.yml build --build-arg OP_GETH_CACHE_BREAK="$(date)"
```
- For optimism cache break only:
```shell
docker compose -f ./e2e/docker-compose.yml build --build-arg OPTIMISM_CACHE_BREAK="$(date)"
```
> [!IMPORTANT]
> Make sure you run the cleanup command to remove data and ensure a fresh start.
```shell
docker compose -f ./e2e/docker-compose.yml down -v --remove-orphans
```
**NOTE:** The `--remove-orphans` flag should remove other containers not defined
in the docker compose file. This is mainly here to help ensure you start with a
clean environment. It can be omitted.
---
## 📄 License
This project is licensed under the [MIT License](https://github.com/hemilabs/heminetwork/blob/main/LICENSE).
", Assign "at most 3 tags" to the expected json: {"id":"11823","tags":[]} "only from the tags list I provide: [{"id":77,"name":"3d"},{"id":89,"name":"agent"},{"id":17,"name":"ai"},{"id":54,"name":"algorithm"},{"id":24,"name":"api"},{"id":44,"name":"authentication"},{"id":3,"name":"aws"},{"id":27,"name":"backend"},{"id":60,"name":"benchmark"},{"id":72,"name":"best-practices"},{"id":39,"name":"bitcoin"},{"id":37,"name":"blockchain"},{"id":1,"name":"blog"},{"id":45,"name":"bundler"},{"id":58,"name":"cache"},{"id":21,"name":"chat"},{"id":49,"name":"cicd"},{"id":4,"name":"cli"},{"id":64,"name":"cloud-native"},{"id":48,"name":"cms"},{"id":61,"name":"compiler"},{"id":68,"name":"containerization"},{"id":92,"name":"crm"},{"id":34,"name":"data"},{"id":47,"name":"database"},{"id":8,"name":"declarative-gui "},{"id":9,"name":"deploy-tool"},{"id":53,"name":"desktop-app"},{"id":6,"name":"dev-exp-lib"},{"id":59,"name":"dev-tool"},{"id":13,"name":"ecommerce"},{"id":26,"name":"editor"},{"id":66,"name":"emulator"},{"id":62,"name":"filesystem"},{"id":80,"name":"finance"},{"id":15,"name":"firmware"},{"id":73,"name":"for-fun"},{"id":2,"name":"framework"},{"id":11,"name":"frontend"},{"id":22,"name":"game"},{"id":81,"name":"game-engine "},{"id":23,"name":"graphql"},{"id":84,"name":"gui"},{"id":91,"name":"http"},{"id":5,"name":"http-client"},{"id":51,"name":"iac"},{"id":30,"name":"ide"},{"id":78,"name":"iot"},{"id":40,"name":"json"},{"id":83,"name":"julian"},{"id":38,"name":"k8s"},{"id":31,"name":"language"},{"id":10,"name":"learning-resource"},{"id":33,"name":"lib"},{"id":41,"name":"linter"},{"id":28,"name":"lms"},{"id":16,"name":"logging"},{"id":76,"name":"low-code"},{"id":90,"name":"message-queue"},{"id":42,"name":"mobile-app"},{"id":18,"name":"monitoring"},{"id":36,"name":"networking"},{"id":7,"name":"node-version"},{"id":55,"name":"nosql"},{"id":57,"name":"observability"},{"id":46,"name":"orm"},{"id":52,"name":"os"},{"id":14,"name":"parser"},{"id":74,"name":"react"},{"id":82,"name":"real-time"},{"id":56,"name":"robot"},{"id":65,"name":"runtime"},{"id":32,"name":"sdk"},{"id":71,"name":"search"},{"id":63,"name":"secrets"},{"id":25,"name":"security"},{"id":85,"name":"server"},{"id":86,"name":"serverless"},{"id":70,"name":"storage"},{"id":75,"name":"system-design"},{"id":79,"name":"terminal"},{"id":29,"name":"testing"},{"id":12,"name":"ui"},{"id":50,"name":"ux"},{"id":88,"name":"video"},{"id":20,"name":"web-app"},{"id":35,"name":"web-server"},{"id":43,"name":"webassembly"},{"id":69,"name":"workflow"},{"id":87,"name":"yaml"}]" returns me the "expected json"