Skip to content
This repository has been archived by the owner on Sep 4, 2024. It is now read-only.

Commit

Permalink
Rename upshot to allora, use new Allora inference function (#52)
Browse files Browse the repository at this point in the history
* Rename remaining occurrences of upshot to allora. 
* Use new allora inference function, downloading the new release
* Added README information about Run, Build and cleaned it up.
  • Loading branch information
xmariachi authored Feb 13, 2024
1 parent 23a09d0 commit dc1d367
Show file tree
Hide file tree
Showing 10 changed files with 110 additions and 39 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ workspace
runtime.tar.gz
cmd/node/node
cmd/keys/keys
data
keys
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ all: clean build-node build-keys
.PHONY: build-node
build-node:
@echo "\n🛠 Building node...\n"
cd cmd/node && go build -o ../../dist/upshot-node
cd cmd/node && go build -o ../../dist/allora-node
@echo "\n✅ Done.\n"

.PHONY: build-keys
build-keys:
@echo "\n🛠 Building node keys...\n"
cd cmd/keys && go build -o ../../dist/upshot-keys
cd cmd/keys && go build -o ../../dist/allora-keys
@echo "\n✅ Done.\n"

.PHONY: clean
Expand Down
92 changes: 81 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
# Upshot Compute Node
# Allora Inference Base

This node allows model providers to participate providing inferences to the Upshot Network.
This node allows model providers to participate in the Allora network.
This repo is the base for worker nodes (for providing inferences) and head nodes (which coordinates requests and aggregates results).

# Build locally

First you need to set the env vars to connect with the Upshot Appchain
In order to build locally:

```
export NODE_ADDRESS="http://localhost:26657"
export ALLORA_ACCOUNT_MNEMONIC="palm key track hammer early love act cat area betray ..."
export ALLORA_ACCOUNT_NAME="alice"
export ALLORA_ACCOUNT_PASSPHRASE="1234567890"
GOOS=linux GOARCH=amd64 make
```

***WARNING***
Expand All @@ -20,14 +19,85 @@ This repo is currently relying on a private module, current development requires
export GOPRIVATE=github.com/allora-network/allora-appchain
```

Then to build
# Run locally

## Head

```
GOOS=linux GOARCH=amd64 make
docker build -f docker/Dockerfile -t upshot:dev --build-arg "GH_TOKEN=${YOUR_GH_TOKEN}" --build-arg "BLS_EXTENSION_VER=${BLS_UPSHOT_EXTENSION_VERSION}" .
./allora-node \
--role=head \
--peer-db=/data/peerdb \
--function-db=/data/function-db \
--runtime-path=/app/runtime \
--runtime-cli=bls-runtime \
--workspace=/data/workspace \
--private-key=/var/keys/priv.bin \
--port=9010 \
--rest-api=:6000 \
--allora-chain-key-name=local-head \
--allora-chain-restore-mnemonic='your mnemonic words...' --allora-node-rpc-address=https://some-allora-rpc-address/ \
```
## Worker

```
./allora-node \
--role=worker \
--peer-db=/data/peerdb \
--function-db=/data/function-db \
--runtime-path=/app/runtime \
--runtime-cli=bls-runtime \
--workspace=/data/workspace \
--private-key=/var/keys/priv.bin \
--port=9010 \
--rest-api=:6000 \
--topic=1 \
--allora-chain-key-name=local-worker \
--allora-chain-restore-mnemonic='your mnemonic words...' --allora-node-rpc-address=https://some-allora-rpc-address/ \
--allora-chain-topic-id=1
```

where `YOUR_GH_TOKEN` is you Github token, and optionally `BLS_EXTENSION_VER` is the release version of the [Upshot blockless extension](https://github.com/upshot-tech/upshot-blockless-extension) to use (will use latest if not set).
## Notes

If you plan to deploy without wanting to connect to the Allora blockchain, just by testing your setup and your inferences, do not set any `--allora` flag.

### Topic registration

`--topic` defines the topic internally as a Blockless channel, so the heads are able to identify which workers can respond to requests on that topic.

`--allora-chain-topic-id` is the topic in which your worker registers on the appchain. This will be used for evaluating performance and allocating rewards.

### Keys
The `--private-key` sets the Blockless peer key for your particular node. Obviously, please use different keys for different nodes.
The `--allora-chain-key-name` and `--allora-chain-restore-mnemonic` are used to set the local Allora client keyring that your node will use when communicating with the Allora chain.

### Blockless directories

Blockless nodes need to define a number of directories:
`--peer-db`: database for peers in the network.
`--function-db`: database for WASM functions to be executed in the workers.
`--runtime-path`: runtime path to execute the functions
`--runtime-cli`: runtime command to run functions
`--workspace`: work directory where temporary files are stored.


# Docker images

To build the image for the head:

```
docker build -f docker/Dockerfile_head -t allora-inference-base:dev-head --build-arg "GH_TOKEN=${YOUR_GH_TOKEN}" --build-arg "BLS_EXTENSION_VER=${BLS_EXTENSION_VERSION}" .
```

Then to build the image for the head:

```
docker build -f docker/Dockerfile_worker -t allora-inference-base:dev-worker --build-arg "GH_TOKEN=${YOUR_GH_TOKEN}" --build-arg "BLS_EXTENSION_VER=${BLS_EXTENSION_VERSION}" .
```

where `YOUR_GH_TOKEN` is your Github token, and optionally `BLS_EXTENSION_VER` is the release version of the [Allora inference extension](https://github.com/allora-network/allora-inference-extension) to use (it will use latest if none is set).

You can use the worker image as a base for building your own worker.


# Debugging Locally Using VSCode.

Expand Down
12 changes: 6 additions & 6 deletions cmd/node/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,17 +217,17 @@ func run() int {

log.Info().
Str("role", role.String()).
Msg("Upshot Node starting")
Msg("Allora Node starting")

err := node.Run(ctx)
if err != nil {
log.Error().Err(err).Msg("Upshot Node failed")
log.Error().Err(err).Msg("Allora Node failed")
close(failed)
} else {
close(done)
}

log.Info().Msg("Upshot Node stopped")
log.Info().Msg("Allora Node stopped")
}()

// If we're a head node - start the REST API.
Expand Down Expand Up @@ -274,11 +274,11 @@ func run() int {

select {
case <-sig:
log.Info().Msg("Upshot Node stopping")
log.Info().Msg("Allora Node stopping")
case <-done:
log.Info().Msg("Upshot Node done")
log.Info().Msg("Allora Node done")
case <-failed:
log.Info().Msg("Upshot Node aborted")
log.Info().Msg("Allora Node aborted")
return failure
}

Expand Down
1 change: 0 additions & 1 deletion cmd/node/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/ignite/cli/v28/ignite/pkg/cosmosaccount"
"github.com/ignite/cli/v28/ignite/pkg/cosmosclient"
"github.com/rs/zerolog"
// types "github.com/upshot-tech/protocol-state-machine-module"
)

type alloraCfg struct {
Expand Down
6 changes: 3 additions & 3 deletions docker/Dockerfile_head
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ RUN apt update && \
perl-base && \
rm -rf /var/cache/apt/*

COPY --from=builder /src/dist/upshot-node /usr/local/bin/upshot-node
COPY --from=builder /src/dist/upshot-keys /usr/local/bin/upshot-keys
COPY --from=builder /src/dist/allora-node /usr/local/bin/allora-node
COPY --from=builder /src/dist/allora-keys /usr/local/bin/allora-keys

RUN groupadd -g 1001 ${USERNAME} \
&& useradd -m -d ${APP_PATH} -u 1001 -g 1001 ${USERNAME}
Expand All @@ -42,4 +42,4 @@ USER ${USERNAME}
VOLUME ${APP_PATH}
EXPOSE 8080 9527

ENTRYPOINT ["upshot-node"]
ENTRYPOINT ["allora-node"]
22 changes: 11 additions & 11 deletions docker/Dockerfile_worker
Original file line number Diff line number Diff line change
Expand Up @@ -56,25 +56,25 @@ ARG BLS_EXTENSION_VER
# If BLS_EXTENSION_VER install the version else install latest
RUN if [ -n $BLS_EXTENSION_VER]; then \
gh release download $BLS_EXTENSION_VER \
--repo "upshot-tech/upshot-blockless-extension" \
--repo "allora-network/allora-inference-extension" \
--pattern '*linux-amd64.tar.gz' \
--output upshot-extension.tar.gz; \
--output allora-extension.tar.gz; \
else \
gh release download $(gh release list --repo "upshot-tech/upshot-blockless-extension" | grep Latest | awk '{print($1)}') \
--repo "upshot-tech/upshot-blockless-extension" \
gh release download $(gh release list --repo "allora-network/allora-inference-extension" | grep Latest | awk '{print($1)}') \
--repo "allora-network/allora-inference-extension" \
--pattern '*linux-amd64.tar.gz' \
--output upshot-extension.tar.gz; \
--output allora-extension.tar.gz; \
fi && \
mkdir -p /app/runtime/extensions && \
tar -xvkf ./upshot-extension.tar.gz -C /app/runtime/extensions && \
rm ./upshot-extension.tar.gz
tar -xvkf ./allora-extension.tar.gz -C /app/runtime/extensions && \
rm ./allora-extension.tar.gz

COPY --from=builder /src/dist/upshot-node /usr/local/bin/upshot-node
COPY --from=builder /src/dist/upshot-keys /usr/local/bin/upshot-keys
COPY --from=builder /src/dist/allora-node /usr/local/bin/allora-node
COPY --from=builder /src/dist/allora-keys /usr/local/bin/allora-keys

# Smoke test
RUN /app/runtime/bls-runtime --help && \
/app/runtime/extensions/upshot-blockless-extension --help
/app/runtime/extensions/allora-inference-extension --help

RUN groupadd -g 1001 ${USERNAME} \
&& useradd -m -d ${APP_PATH} -u 1001 -g 1001 ${USERNAME} \
Expand All @@ -84,4 +84,4 @@ USER ${USERNAME}

EXPOSE 8080 9527

ENTRYPOINT ["upshot-node"]
ENTRYPOINT ["allora-node"]
6 changes: 3 additions & 3 deletions docker/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ if [ -f "$CONFIG_PATH/identity" ]; then
else
echo "Generating New Node Identity"
cd /app/keys
../upshot-keys
../allora-keys
# Backup keys
if [ -n "$KEY_PATH" ]; then
# backup the on chain node identity
Expand Down Expand Up @@ -86,7 +86,7 @@ if [ -n "$TOPICS" ]; then
fi

if [ "$NODE_ROLE" = "head" ]; then
./upshot-node --peer-db /var/tmp/upshot/peerdb --function-db /var/tmp/upshot/function-db --log-level debug --port $P2P_PORT --role head --workspace $WORKSPACE_ROOT --private-key $NODE_KEY_PATH --rest-api :$REST_API $dialback_args $bootnode_args
./allora-node --peer-db /var/tmp/allora/peerdb --function-db /var/tmp/allora/function-db --log-level debug --port $P2P_PORT --role head --workspace $WORKSPACE_ROOT --private-key $NODE_KEY_PATH --rest-api :$REST_API $dialback_args $bootnode_args
else
./upshot-node --peer-db ./peer-database --function-db ./function-database --log-level debug --port $P2P_PORT --role worker --runtime-path /app/runtime --runtime-cli bls-runtime --workspace $WORKSPACE_ROOT --private-key $NODE_KEY_PATH $dialback_args $bootnode_args $topic_args
./allora-node --peer-db ./peer-database --function-db ./function-database --log-level debug --port $P2P_PORT --role worker --runtime-path /app/runtime --runtime-cli bls-runtime --workspace $WORKSPACE_ROOT --private-key $NODE_KEY_PATH $dialback_args $bootnode_args $topic_args
fi
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/upshot-tech/upshot-compute-node
module github.com/allora-network/allora-inference-base

go 1.21.1

Expand Down
2 changes: 1 addition & 1 deletion launch-node.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
upshot-node \
allora-node \
--peer-db /tmp/avs/head-peer-db \
--function-db /tmp/avs/head-fdb \
--log-level debug \
Expand Down

0 comments on commit dc1d367

Please sign in to comment.