V4VApp update plus how to: MongodDB Replica Set on a local machine & Github Actions PyTest

Support Proposal 342 on PeakD
Vote for Brianoflondon's Witness KeyChain or HiveSigner

This is a value for value post: see the explanation in the footer.

docker container frustration in the forest from grok.jpg


Working on @v4vapp and @vsc.network

I'm still here! I'm still working! I've not been posting much but I should. So here's a post and a very quick update.

I'm working on rebuilding the entire back end of @v4vapp both to be public source and (one day) runnable by others. And I'm working toward the direction of using @vsc.network as the BTC/Hive/HBD exchange as and when those features become available. This is a pretty huge change for me.

That's also why I'm deeply involved with @vaultec and his crew to make sure we keep heading in the same direction.

Minor changes to @v4vapp

I didn't really mention it but the front end got a few tweaks like zoom controls on the camera for scanning QR Codes. Also the system now copes properly with internal transfers (even if these are via Lightning). It's crazy how Lightning does this internally, but I'm coping with it now. It just means that if you try using v4v.app to send Lightning to another Hive user's Lightning address (mine is brianoflondon@sats.v4v.app it works.

I'm working most of the time on by v4vapp-backend-v2 which is a public Github repo. It's not really decipherable right now, but a lot of work is going into it.

Nectar replacing Beem

There is a whole push for new dev tools with @blocktrades team having come up with some great new code but it's not finished and really ready. In the mean time the old Python library called Beem remained my main working system but it has problems.

In steps @thecrazygm and starts converting it into something called Nectar pip install hive-nectar. This is great and I've put in a couple of pull requests already and have more I'll be sending in.

Async streaming of blocks

Chief amongst this will be an async block stream which I'm using in my code and is starting to be really really reliable. It's public already but burried in my code, I'll work with @thecrazygm to put this direct into the Nectar code.

Code lesson for today: MongodDB Replica Set locally and on Github Actions

Do let me know in the comments if any of this is helpful to you!

This took me far longer than you'd think to get work. With a million prompts to Co-Pilot and Grok you'd be surprised at just how bad these two things were at really understanding the underlying complexity of this.

MongoDB Replica Sets

MongoDB is easy peasy to set up for a single instance running in a docker container. But in production and for certain of the more advanced features of this database like "change streams" you need something called a replica set. This is designed to run on multiple computers simultaneously and copies all its data around the whole "cluster" automatically.

But when you're writing software you really need a local copy of this running on your machine and you probably don't want three of these. Docker containers are perfect for this and it should be easy, right?

The big gotcha

The big gotcha that took me hours to really get to grips with is that the usually distinct internal network name and port inside the Docker container, and the external name by which you address the replica set cluster (even though it's only one machine). MUST BE THE SAME!

So if you're connecting on localhost:37017 outside the container, you must ensure that localhost37017 is the same name used when setting up the replica set in the container.

Trust me on this (past those two paragraphs into Grok and ask it why I'm right).

So here's the answer: localhost and Github Actions

The Connection string

If you use the two config files below, the connection string for connecting to your MongoDB on both Github actions and your local machine will be:

mongodb://127.0.0.1:37017/?replicaSet=rsPytest

docker_compose.yaml

services:
  mongo-pytest-local:
    image: mongo:8.0
    command: >
      bash -c "
        mongod --replSet rsPytest --bind_ip_all --port 37017 &
        sleep 10 &&
        mongosh --port 37017 --eval 'rs.initiate({
          _id: \"rsPytest\",
          members: [{ _id: 0, host: \"127.0.0.1:37017\" }]
        })' &&
        wait
      "
    ports:
      - "127.0.0.1:37017:37017"
      - "${LOCAL_TAILSCALE_IP}:37017:37017"
    healthcheck:
      test: ["CMD", "mongosh", "--eval", "db.runCommand({ ping: 1 })"]
      interval: 10s
      timeout: 5s
      retries: 5
    restart: unless-stopped
    networks:
      - v4vapp-backend
    volumes:
      - mongo_data:/data/db
      - mongo_config:/data/configdb

volumes:
  mongo_data:
  mongo_config:

networks:
  v4vapp-backend:
    driver: bridge

.github/workflows/pytest.yaml

This includes the code for running my code using uv but I'm giving the whole file for completeness, you can see the docker setup for MongoDB (and Redis too).

name: Pytest

on:
  push:
    branches:
      - main
      - develop
    tags:
      - "v*"
  pull_request:
    branches:
      - main
      - develop
    paths-ignore:
      - "**.md"
      - ".gitignore"
      - "LICENSE"
      - ".env*"

jobs:
  test:
    runs-on: ubuntu-latest
    services:
      redis:
        image: redis:latest
        ports:
          - "6379:6379"

    steps:
      - uses: actions/checkout@v4

      - uses: actions/setup-python@v5
        with:
          python-version: "3.12"

      # Install UV
      - name: Install UV
        run: |
          curl -LsSf https://astral.sh/uv/install.sh | sh
          echo "$HOME/.cargo/bin" >> $GITHUB_PATH

      # Cache virtual environment
      - name: Cache UV virtual environment
        id: cache-venv
        uses: actions/cache@v4
        with:
          path: .venv
          key: uv-venv-${{ runner.os }}-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('uv.lock') }}

      # Set up virtual environment and sync dependencies
      - name: Set up UV environment and install dependencies
        if: steps.cache-venv.outputs.cache-hit != 'true'
        run: |
          uv venv --python 3.12
          uv sync --group dev

      # Ensure UV is available and sync if cache is hit
      - name: Sync UV dependencies (post-cache)
        run: |
          uv sync --group dev

      # Check UV version
      - name: Check UV version
        run: uv --version

      # List installed packages
      - name: List installed packages
        run: uv pip list

      # Start MongoDB with replica set
      - name: Start MongoDB
        uses: supercharge/mongodb-github-action@1.12.0
        with:
          mongodb-version: '8.0'
          mongodb-replica-set: rsPytest
          mongodb-port: 37017

      # Set PYTHONPATH
      - name: Set PYTHONPATH
        run: echo "PYTHONPATH=$PWD/src" >> $GITHUB_ENV

      # Run tests
      - name: Test with pytest
        env:
          HIVE_ACC_TEST: ${{ secrets.HIVE_ACC_TEST }}
          HIVE_MEMO_TEST_KEY: ${{ secrets.HIVE_MEMO_TEST_KEY }}
        run: |
          uv run pytest

      # Print service container logs only if tests fail
      - name: Print service container logs
        if: failure()
        run: |
          echo "MongoDB logs:"
          docker logs $(docker ps -q --filter "ancestor=mongo:8.0")
          echo "Redis logs:"
          docker logs $(docker ps -q --filter "ancestor=redis:latest")

Value for Value

For the last few months while building @v4vapp I was generously supported by the DHF. Going forward I have a much more modest support which covers direct server costs and a little of my time.

If you appreciate the work I do on and around Hive, you can express this directly: upvoting posts on Hive is great. Also consider a direct donation (there's a Tip button on Hive or a Lightning Address) on all my posts.

hivebuzz-orca-120.png

Support Proposal 342 on PeakD
Support Proposal 342 with Hivesigner
Support Proposal 303 on Ecency
Vote for Brianoflondon's Witness KeyChain or HiveSigner


Send Lightning to Me!

Sort:  

Hey Brian,
good to hear from you again. Those things you are working on sound very promising though I don’t get too much of the coding deep dive. But I understood its still the plan to decentralize v4vapp, which I think is very valuable. 💪🏻

What I wanted to try is sending literally Sats to another Hive Account. How does that work? Is the LN adress always username@sats.v4vapp?

Have a great sunday and talk soon
Thomas

The internal transfers are useful for programmatic stuff which @sstarker others are doing for on boarding btc communities.

Ah, so nothing for regular use and „normal Hivers“?

I have a question. If I swap my BNB on BSC to BTC, can I then transfer it to Hive via V4V?
I am having trouble transferring BNB to HE xD

My system is only good for sats in the form of Lightning. If you can send as lightning to @v4vapp you can get Hive or HBD.

Dude, I don't fking know these things haha :D
I am so bad at crypto in generel its a laugh. I am only on Hive xD

Very impressive, although I only understood about half of it! :-)

You've been quiet lately, so I figured you must be busy both in the real world and on the back end of things. It was good to get an update on what's been going on. Cheers!

Building!

I voted for proposals. I hope it gets the votes it deserves.

VSC will greatly facilitate the hive ecosystem.

This is a very big news
Keep up doing the great work and I am really super proud
You are a big inspiration

Keep up the good work 💪 sir and a big thank you on engaging in our post by upvoting.

This project will surely be of benefit to everyone... welldone 👏