# Host a bidder A bidder provides its host's VMs on the market: QEMU on x86_64 (guests get `/dev/kvm` when nested virtualization is on), Firecracker on arm64; `--compute-kinds vm,deno` adds Deno sandboxes. ## Host Linux with `/dev/kvm` and `/dev/net/tun`, systemd 253 or newer, cgroup v2. Debian or Ubuntu: ```sh sudo apt-get update sudo apt-get install -y uidmap openssh-client curl tzdata jq ``` Where AppArmor restricts unprivileged user namespaces (Ubuntu 24.04), `install bidder` writes an AppArmor profile for its pasta (`check-host` line `apparmor-pasta-profile`); do not turn the restriction off. No inbound TCP: ssh to a guest goes over iroh (outbound) or webrtc, which leases one UDP port per VM from 31000-31999 on the host's private addresses (allow that range from your LAN). `scripts/host-nested-kvm.sh` (from a clone) reports nested virtualization, `--apply` turns it on. ## Binary The current release of a channel, from a clone ([README](../README.md#install)), checked against the CID its release record names: ```sh scripts/install.sh stable ``` ```sh scripts/install.sh rc ``` One commit of main (`main/latest/` is the newest; no release record names it, so it is checked against the `SHA256SUMS` beside it): ```sh C=db33c9ffd53cd4a9c38a5db4372a1b0d711e0ac0 A=linux-$(uname -m | sed 's/x86_64/amd64/; s/aarch64/arm64/') B=https://socialweb-computer-kcp.sfo3.digitaloceanspaces.com/main/$C/binaries mkdir -p ~/.cache/swc/$C && cd ~/.cache/swc/$C curl -fsSL -O $B/socialweb-computer-$A -O $B/SHA256SUMS sha256sum -c --ignore-missing SHA256SUMS ``` A dev build from a clone (`git go jq zstd tar flock curl`; the first build on a host stages every pinned asset, minutes; `install` and `upgrade` take it only with `--allow-dev-binary`): ```sh git clone https://knotless.dev/socialweb.computer/socialweb-computer-kcp cd socialweb-computer-kcp scripts/build-socialweb-computer.sh --dev --publish ~/swc ~/swc/bin/socialweb-computer version | grep 'dev build' ``` ## Installed `install bidder` (as root) creates the account `swc-bidder`, its subordinate ids and the state dir `/var/lib/socialweb-computer/swc-bidder`, fetches the guest image and starts the systemd user unit `socialweb-computer-bidder@`. `--dry-run` prints every step and writes nothing; a second run changes nothing. ```sh sudo "$(command -v socialweb-computer)" install bidder --handle --bidder-operator-signin --dry-run sudo "$(command -v socialweb-computer)" install bidder --handle --bidder-operator-signin ``` The bidder gets a DID of its own, an agent of your account once you sign in at the URL of its MarketIdentity `operator`. A slow link: `--network-timeout 20m` for the guest image. Its health, as the account, and the sign-in URL (with `kubectl`): ```sh ACCT=swc-bidder ST=/var/lib/socialweb-computer/swc-bidder asb() { sudo runuser -u $ACCT -- env XDG_RUNTIME_DIR=/run/user/$(id -u $ACCT) CONFIG_PATH_SOCIALWEB_COMPUTER=$ST/config.json "$@"; } asb $ST/bin/current/socialweb-computer check-host -role bidder -state-dir $ST asb systemctl --user status 'socialweb-computer-bidder@*' --no-pager sudo journalctl _SYSTEMD_USER_UNIT=socialweb-computer-bidder@.service --since -10min K=$(sudo sh -c "ls $ST/handles/*/kcp/admin.kubeconfig" | head -1) sudo kubectl --kubeconfig "$K" get marketidentities -o jsonpath='{range .items[*]}{.metadata.name} {.spec.mode} {.status.phase}{"\n"}{end}' sudo kubectl --kubeconfig "$K" get marketidentity operator -o jsonpath='{.status.pendingAction.url}{"\n"}' sudo kubectl --kubeconfig "$K" get marketbidder app -o jsonpath='{.status.phase} {.status.did}{"\n"}' ``` `check-host` prints only `OK` (and `INFO`) lines; `marketbidder app` stays `Provisioning` until you sign in. ## Who you run as | mode | the bidder is | use it when | | --- | --- | --- | | associated (`--bidder-operator-signin `) | a DID of its own, on a PDS it runs, an agent of your account | one account runs several bidders | | your account (`identity: {mode: oauthQr}`) | your account itself: offering, bids and receipts in your repo | one bidder, no DID of its own | ### Associated The install above. Open the URL of `marketidentity operator` (a QR session transfer on qr.fedfork.com) and sign in as ``: the bidder writes the grant and the endorsement into your repo and `agent-of` your DID into its own DID document. Check it (`K` above): ```sh D=$(sudo kubectl --kubeconfig "$K" get marketidentity bidder -o jsonpath='{.status.did}') sudo kubectl --kubeconfig "$K" get marketidentity bidder -o jsonpath='{range .status.conditions[*]}{.type}={.status}{"\n"}{end}' | grep Associated socialweb-computer internal association "$D" | jq -c '{roots, errors}' ``` You see `Associated=True` and `{"roots":[""],"errors":null}`; `marketbidder app` turns `Ready `. ### Your account ```sh sudo install -D -m 0644 /dev/stdin /etc/socialweb-computer/bidder.yaml <<'YAML' identity: mode: oauthQr YAML sudo "$(command -v socialweb-computer)" install bidder --handle --bidder-spec-file /etc/socialweb-computer/bidder.yaml sudo kubectl --kubeconfig "$K" get marketidentity bidder -o jsonpath='{.status.pendingAction.url}{"\n"}' ``` Open that URL and sign in as ``: `marketidentity bidder` turns `oauthQr Ready ` and `marketbidder app` `Ready `, with no PDS of its own. ## Who it serves The default policy `bidder-tangled-vouch`: the bidder bids only for requesters its operator (your account) vouches for ([quickstart-prod.md](quickstart-prod.md#vouches)). Never set `--bidder-policy open`. A bidder can also vouch named DIDs itself, from its spec file: ```yaml options: - {name: vouch, value: } ``` ## Upgrade, rollback, self-update An installed release bidder follows a release channel and upgrades itself; its journal names the channel (`releasefollow_on ... "channel":"rc"`). With no option it follows `rc` when its version contains `-rc`, which every build's version does today, v0.0.0 included; pin one in the spec file: ```yaml options: - {name: release-channel, value: stable} ``` By hand, as the account (`ST`, `asb` above), to the main commit downloaded under [Binary](#binary) (`C`, `A`): ```sh NEW=~/.cache/swc/$C/socialweb-computer-$A sudo install -m 0755 "$NEW" /var/tmp/socialweb-computer-next asb $ST/bin/current/socialweb-computer upgrade --binary /var/tmp/socialweb-computer-next --sha256 "$(sha256sum "$NEW" | cut -d' ' -f1)" ``` It prints `upgrade: bin/current -> (previous )` and restarts the bidder; the state, DID and VMs stay. Back to `bin/previous`: ```sh asb $ST/bin/current/socialweb-computer rollback ``` ## Uninstall ```sh sudo $ST/bin/current/socialweb-computer uninstall bidder --purge ``` `--purge` also removes the state (DID, repo, OpenBao, VMs) and the account; without it they stay. ## End a VM Delete its `ComputeVM`; the bidder writes `vm.terminated` and the contract is released. Every VM also ends by itself 24 h after its accept (or at the RFP's `expiresAt`) plus 10 min. ```sh K=$(sudo sh -c "ls $ST/handles/*/kcp/admin.kubeconfig" | head -1) sudo kubectl --kubeconfig "$K" get computevms.socialweb.computer sudo kubectl --kubeconfig "$K" delete computevms.socialweb.computer --wait=false ``` ## Foreground For a look, as a normal account (not root) in the `kvm` group, with linger: ```sh sudo usermod -aG kvm $USER sudo loginctl enable-linger $USER ``` Log in again. `check-host` names what else is missing; the account needs exactly one subordinate id range in `/etc/subuid` and `/etc/subgid` (65536 ids per VM; `useradd` on Ubuntu already made one, do not add a second): ```sh socialweb-computer check-host -role bidder -state-dir ~/.local/state/socialweb-computer ``` ```sh socialweb-computer run bidder --handle --host-backend proc --fg --atproto-oauth-qr ``` It prints a QR code and its URL; sign in as `` and it bids as your account. Ctrl-C stops it and keeps its state; the same command resumes it. ## More Comms modes, association by hand, the VMM choice: [CONTRIBUTING.md](../CONTRIBUTING.md#install-a-release-bidder) and `socialweb-computer run bidder -h`.