0KnowledgeNetwork / opt

mixnet server plugins, client apps, and other components
GNU Affero General Public License v3.0
2 stars 1 forks source link

Automate github CI docker mixnet testing #9

Closed david415 closed 2 months ago

david415 commented 4 months ago

The Katzenpost monorepo https://github.com/katzenpost/katzenpost/ does it's github CI with this config: https://github.com/katzenpost/katzenpost/blob/main/.github/workflows/go.yml

We want some of the same functionality:

  1. runs a mixnet using docker compose
  2. tests client and server components using docker mixnet

The goal of this ticket is to make Github CI work for us with this git repo. We do not want to test all of katzenpost like in the above workflows/go.yml file. For now the goal is simply to configure our github CI to run a dockerized katzenpost mixnet... and run a simple ping test against the mixnet. In the katzenpost CI we are running a simple ping test like this:

https://github.com/katzenpost/katzenpost/blob/main/.github/workflows/go.yml#L81

In particular we wish to do:

  1. test walletshield against the docker mixnet https://github.com/0KnowledgeNetwork/opt/tree/main/apps/walletshield
  2. test our http_proxy server plugin with the docker mixnet https://github.com/0KnowledgeNetwork/opt/tree/main/server_plugins/cbor_plugins/http_proxy/cmd/http_proxy

It's easy to run genconfig:

mkdir -p voting_mixnet
cd ../genconfig && go build && cd ../docker \
    && ../genconfig/genconfig -wirekem xwing -a 127.0.0.1 -nv 3 -n 3 -p 2 \
    -sr 0 -mu 0.005 -muMax 1000 -lP 0.001 -lPMax 1000 -lL 0.0005 \
    -lLMax 1000 -lD 0.0005 -lDMax 3000 -lM 0.0005 -lMMax 100 \
    -S .alpine -v -o ./voting_mixnet -b /voting_mixnet -P 30000 \
    -nike "x25519" -kem "" -d katzenpost-alpine_go_mod \
    -UserForwardPayloadLength 2000 -log_level DEBUG

If you look at voting_mix/docker-compose.yml you'll see entries like this:

  mix1:
    restart: "no"
    image: katzenpost-alpine_go_mod
    volumes:
      - ./:/voting_mixnet
    command: /voting_mixnet/server.alpine -f /voting_mixnet/mix1/katzenpost.toml
    network_mode: host
    depends_on:
      - auth1
      - auth2
      - auth3

which means there needs to be a docker image called katzenpost-alpine_go_mod.

The recipe to generating that docker image is in our docker makefile, here:

https://github.com/katzenpost/katzenpost/blob/main/docker/Makefile

However the docker makefile also runs the katzenpost mix server makefile:

https://github.com/katzenpost/katzenpost/blob/main/server/Makefile

As you can see, those testnet-build and testnet-build are specific to docker and assist in creating the desired docker image. Our particular use case for the katzenpost mixnet does not require any of the server plugins except our own http_proxy. That means we do not want to execute some of the lines within the server makefile such as:

    cd ../memspool/server/cmd/memspool ; go build -trimpath -ldflags ${ldflags}
    cd ../reunion/servers/reunion_katzenpost_server ; go build -trimpath -ldflags ${ldflags}
    cd ../panda/server/cmd/panda_server ; go build -trimpath -ldflags ${ldflags}
    cd ../server_plugins/cbor_plugins/echo-go ; go build -trimpath -o echo_server -ldflags ${ldflags}

    mv /go/katzenpost/memspool/server/cmd/memspool/memspool /$(net_name)/memspool.$(distro)
    mv /go/katzenpost/reunion/servers/reunion_katzenpost_server/reunion_katzenpost_server /$(net_name)/reunion_katzenpost_server.$(distro)
    mv /go/katzenpost/panda/server/cmd/panda_server/panda_server /$(net_name)/panda_server.$(distro)
    mv /go/katzenpost/server_plugins/cbor_plugins/echo-go/echo_server /$(net_name)/echo_server.$(distro)

Instead we must build our http_proxy plugin and move it into the docker volume during image creation.

Build our http_proxy plugin here: https://github.com/0KnowledgeNetwork/opt/tree/main/server_plugins/cbor_plugins/http_proxy/cmd/http_proxy

Deploy http_proxy with it's config, here: https://github.com/0KnowledgeNetwork/opt/blob/main/server_plugins/cbor_plugins/http_proxy/http_proxy_config.toml

And note that the katzenpost provider toml config has to have a section to enable the http_proxy server plugin:

  [[Provider.CBORPluginKaetzchen]]
    Capability = "http_proxy"
    Endpoint = "http_proxy"
    Command = "/opt/katzenpost/http_proxy"
    MaxConcurrency = 1
    Disable = false
    [Provider.CBORPluginKaetzchen.Config]
      config = "/opt/katzenpost/http_proxy_config.toml"
      log_dir = "/voting_mixnet/provider1"

Note that this repo has a modified fork of genconfig which does enable the above http_proxy config:

https://github.com/0KnowledgeNetwork/opt/blob/main/genconfig/main.go#L202

But it also writes the http_proxy_config.toml... and we probably want to instead copy that from elsewhere.

amitbasuri commented 4 months ago

@david415 The goal here is to integrate the build steps directly into the Docker build process, rather than building the server components and plugins outside of Docker and then copying the binaries into the Docker image. Right?

david415 commented 4 months ago

@david415 The goal here is to integrate the build steps directly into the Docker build process, rather than building the server components and plugins outside of Docker and then copying the binaries into the Docker image. Right?

@amitbasuri The goal is to configure our github CI (in this opt repo) to run a docker mixnet such that the Provider nodes are running our "http_proxy server plugin" --> https://github.com/0KnowledgeNetwork/opt/tree/main/server_plugins/cbor_plugins/http_proxy/cmd/http_proxy

Currently the only way to run a docker mixnet is with the docker/Makefile inside the katzenpost monorepo ( this repo https://github.com/katzenpost/katzenpost/ ). Here we need some kind of alternative way to run the docker mixnet... because the katzenpost docker makefile doesn't let us start the mixnet with our own http proxy plugin... unless we fork katzenpost. we are trying to avoid forking katzenpost.