Skip to content
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

Docker Compose setup of non-sBTC Components #141

Merged
merged 39 commits into from
May 24, 2024
Merged

Docker Compose setup of non-sBTC Components #141

merged 39 commits into from
May 24, 2024

Conversation

SundarGowtham
Copy link
Collaborator

@SundarGowtham SundarGowtham commented May 9, 2024

This PR includes the Docker Compose Setup of:

  • Docker Builds of Non-sBTC components:
    • Bitcoin Regtest Node
    • Bitcoin Miner
    • Stacks Node
    • Nakamoto Signer
    • Electrs
    • Stacks API
    • Stacks Explorer
    • Mempool Frontend
    • Mempool Backend
    • MariaDB
    • Postgres
  • docker-compose.yml file
  • helper .sh files:
    • build.sh for docker builds
    • up.sh for docker spin up
    • down.sh for docker spin down
  • devnet-liveness.sh file for testing
  • devenv/local/docker-compose/README.md for setup

This PR does NOT include:

  • Any Kubernetes setup for local testing
  • Any Cloud related Kubernetes setup

To setup and test, follow the instructions in ./devenv/local/docker-compose/README.md

@SundarGowtham SundarGowtham added the test environment The testing envionment used to develop the sBTC-v1 features. label May 9, 2024
@SundarGowtham SundarGowtham self-assigned this May 9, 2024
@AshtonStephens
Copy link
Collaborator

What should we look for / be able to do with this PR? Can you provide some tests or some commands that we can use to verify that this is doing or able to handle some expected behavior?

@hstove
Copy link
Contributor

hstove commented May 13, 2024

I mentioned this in the other PR, but two things that would be helpful with this PR are:

  1. Rebase your commits on top of the main branch - you can do this with git rebase origin/main, and then git push origin testnet -f

  2. Instead of using all-caps with [N]- folders, just do things like devenv/local/docker-compose, devenv/local/custom-k8s, etc

SundarGowtham and others added 24 commits May 14, 2024 02:50
- Refactored the Dockerfile of the stacks node to just run the entrypoint.sh
- Bitcoin Miner correctly mines blocks
@SundarGowtham SundarGowtham changed the title Docker Compose setup of non-sBTC Components Docker Compose setup of non-sBTC Components-DRAFT May 14, 2024
- Added INSTRUCTIONS.md to devenv/local/docker-compose
- Added stacks-old container
- Added tests/ folder with runs automated devnet tests
@SundarGowtham
Copy link
Collaborator Author

@AshtonStephens

  1. I've used the old Stacks version (2.4.0.0.0) in this Docker Compose build temporarily
  2. I've written INSTRUCTIONS.md in ./devenv/local/docker-compose/ on how to replicate and test
  3. To run some automated tests, you can run sh devenv/local/docker-compose/tests/devnet-liveness.sh (also mentioned in INSTRUCTIONS.md)

Some problems:

  1. [CRITICAL] Even after changing the Stacks container to a pre-Nakamoto version, the Stacks Node still autogenerates a miner address instead of using the private key hard-coded in devenv/local/docker-compose/stacks-old/docker/Config.toml. The Bitcoin Node and Miner works perfectly fine

  2. [DEBUG] Mempool Backend complains that it is not able to connect to the Electrum Backend; so for right now I've set MEMPOOL_BACKEND: "none" instead of MEMPOOL_BACKEND: "electrum" in the docker compose. This is not a critical problem but it would be ideal to get it working

Remaining Notes:

  1. Every other component works just fine. The only quip is that the Nakamoto Signer won't exactly be able to connect to our v24.0.0.0 Stacks Node since it is pre-Nakamoto. However, if you uncomment the stacks section of the Docker Compose, change the depends-on, and change STACKS_CORE_RPC_HOST env var for stacks-api, then the Signer also connects to the Stacks Node correctly

@SundarGowtham
Copy link
Collaborator Author

The Stacks Node successfully finds the UTXOs now. The whole Testnet should work except for 2 caveats.

[1] The Stacks Explorer devnet shows up as offline in Stacks Explorer.
[2] The mempool backend refuses to connect with electrs (or that electrs drops all inbound connections. So I configured mempool backend to not use electrs for now)

@SundarGowtham SundarGowtham marked this pull request as ready for review May 17, 2024 02:50
@SundarGowtham SundarGowtham changed the title Docker Compose setup of non-sBTC Components-DRAFT Docker Compose setup of non-sBTC Components May 20, 2024
@SundarGowtham SundarGowtham requested a review from hstove May 20, 2024 14:45
Copy link
Contributor

@hstove hstove left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good! Mainly would like to see a few "process" changes:

  • Rename SETUP-README and INSTRUCTION files to just README.
  • Update this PR's description to note exactly what is (and isn't) included

Comment on lines 1 to 2
K8S
CUSTOM-K8S-DOCKER-BUILDS
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move this (and the .gitignore inside docker-compose) into the top-level .gitignore? That way it's much easier to debug where/why folders are ignored

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've removed the extra .gitignore files and changed md file names

Copy link
Contributor

@hstove hstove left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job! Everything is working well. I'd like to see a few small changes, but mainly unrelated to the actual docker compose setup.

Also, nice job on writing a test for this!

Comment on lines 32 to 33
###### Mempool Frontend: `http://localhost:3020`
###### Stacks Explorer: `http://localhost:8083`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These links are backwards

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Comment on lines 15 to 21
#### (i) _Postgres Tools_

```
brew install libpq
echo 'export PATH="/opt/homebrew/opt/libpq/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very specific install instructions for MacOs with zsh, so if it's necessary it's probably better to just link to a "how to install postgres" page.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a section where any OS user can download from the Postgres website. I also added specific instructions for each type of OS


STX_SYNC_WITH_BTC_UTXO_SUCCESS=false
STX_SYNC_WITH_BTC_UTXO_SUCCESS_FRMT=$(echo "\033[1;31m$STX_SYNC_WITH_BTC_UTXO_SUCCESS\033[0m❌")
if [[ $STACKS_DOCKER_LOGS == *"UTXOs found"* ]]; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test doesn't pass for me, even though I can see the "UTXOs found" log

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wrote the RPC approach instead of using Docker logs. The problem with the using the logs from the Stacks node is that not all of the logs are being captured. The RPC approach is more reliable

echo " ---------------------------------------------------------------"


GET_STACKS_API_PING=$(curl -s "http://localhost:3700")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the port for the API's event observer, which is good, but we should also have a liveness check for the "public" API (port 3999)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just added the STACKS_PUBLIC_API_LIVENESS_SUCCESS test. Everything passes now

Comment on lines 249 to 251
echo "----------------------------------------------------------"
echo "| SUMMARY |"
echo "----------------------------------------------------------"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because this is a test file, it should exit with code 1 unless every test passes

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests return a 0 or 1 now

@SundarGowtham SundarGowtham requested a review from hstove May 22, 2024 14:51
Copy link
Contributor

@hstove hstove left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Nice work

Copy link
Contributor

@netrome netrome left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! There's a lot of commented out stuff that I think can be cleaned up, but feel free to do it as a follow-up or keep anything that you still find helpful.

So excited to have this working!

image

@@ -0,0 +1,3 @@
cloud
K8S
local-commands.sh
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this file contain things that would be useful for us? It could be checked in to a scripts folder then.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does but it will be push in the next PR

Comment on lines +4 to +10
## [1] Build all containers:

##### `sh build.sh`

## [2] Spin up all containers:

##### `sh up.sh`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we consider adding top-level make targets for spinning up the local dev env? It would be nice to be able to run make local-dev-env from the project root. It can definitely be done as a follow-up.

Comment on lines 5 to 10
# hostname: bitcoin
# networks:
# devnet:
# # ipv4_address: 172.16.238.200
# aliases:
# - bitcoin
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this is stale config that should be cleaned up.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Along with the other blocks of commented-out-configuration in this file.

devenv/local/docker-compose/stacks/docker/entrypoint.sh Outdated Show resolved Hide resolved
@SundarGowtham SundarGowtham merged commit e9e2dd0 into main May 24, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
test environment The testing envionment used to develop the sBTC-v1 features.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants