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

Commit

Permalink
Rename and Cleanup (#7)
Browse files Browse the repository at this point in the history
Renames everything Allora, and cleans up errors.

---------

Signed-off-by: Derek Anderson <[email protected]>
  • Loading branch information
dmikey authored Feb 8, 2024
1 parent 66f98dd commit 5c3fecc
Show file tree
Hide file tree
Showing 13 changed files with 70 additions and 52 deletions.
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
GOCMD=go
GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
BINARY_NAME=upshot-blockless-extension
BINARY_NAME=allora-offchain-extension
SOURCE_FILE=main.go

# Detect the operating system and architecture
Expand Down Expand Up @@ -48,7 +48,7 @@ clean:
rm -rf $(BINARY_NAME)

example:
cd upshot-function-example && npm run build:release
cd allora-inference-function && npm run build:release

setup:
@echo "\n📥 Downloading and extracting runtime...\n"
Expand All @@ -58,6 +58,7 @@ setup:
@echo "\n✅ Done.\n"

test: example build
/tmp/runtime/bls-runtime upshot-function-example/build/release.wasm - --drivers-root-path=$(PWD)
export ALLORA_ARG_PARAMS=yuga BLS_LIST_VARS=ALLORA_ARG_PARAMS; \
/tmp/runtime/bls-runtime allora-inference-function/build/release.wasm - --drivers-root-path=$(PWD)

.PHONY: all build clean example setup test
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
README for Upshot Blockless Extension
README for Allora Inference Extension
=====================================

This document provides instructions on how to use the Makefile for building the Upshot Blockless Extension.
This document provides instructions on how to use the Makefile for building the extension.

Prerequisites
-------------
Expand All @@ -16,7 +16,7 @@ Makefile Targets

* `build`: Compiles the Go source file into a binary.
* `clean`: Removes the compiled binary and other generated files.
* `example`: Runs a Node.js build script in the `upshot-function-example` directory.
* `example`: Runs a Node.js build script in the `allora-function-example` directory.
* `setup`: Downloads and extracts the appropriate blockless runtime for the current OS and architecture.
* `test`: Runs a test using the blockless runtime and the built wasm file.

Expand Down
File renamed without changes.
3 changes: 3 additions & 0 deletions allora-inference-function/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Allora Network Offchain CGI Extensions Function Example

This function interacts with the Upshot CGI Extension.
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
name = "upshot-function-example"
name = "allora-inference-function"
version = "1.0.0"

[deployment]
nodes = 1

[build]
dir = "build"
entry = "upshot-function-example_debug.wasm"
entry = "allora-inference-function_debug.wasm"
command = "npm run build:debug"

[build_release]
dir = "build"
entry = "upshot-function-example.wasm"
entry = "allora-inference-function.wasm"
command = "npm run build:release"
8 changes: 8 additions & 0 deletions allora-inference-function/footest.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[2024-01-12T04:42:36Z ERROR bls_runtime] panicked at 'called `Result::unwrap()` on an `Err` value: failed to read input file

Caused by:
No such file or directory (os error 2)', /Users/runner/work/bls-runtime/bls-runtime/blockless/src/lib.rs:167:68
[2024-01-12T04:43:09Z ERROR bls_runtime] panicked at 'called `Result::unwrap()` on an `Err` value: failed to read input file

Caused by:
No such file or directory (os error 2)', /Users/runner/work/bls-runtime/bls-runtime/blockless/src/lib.rs:167:68
46 changes: 46 additions & 0 deletions allora-inference-function/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { Console } from "as-wasi/assembly";
import { CgiCommand, cgiExtendsList } from "@blockless/sdk/assembly/cgi";
import { memory } from "@blockless/sdk/assembly";
import { buffer2string } from "@blockless/sdk/assembly/strings";
// env UPSHOT_ARG_PARAMS=FOO BLS_LIST_VARS=UPSHOT_ARG_PARAMS
let envVars = new memory.EnvVars().read().toJSON();
if (envVars) {
let environmentValue = envVars.get("ALLORA_ARG_PARAMS");
if (environmentValue) {
// get as list of the extensions available
let l = cgiExtendsList();

if (l != null) {
let command = new CgiCommand("cgi-allora-infer", null, null);
let rs = command.exec();
if (rs == true) {
const SEP = "\r\n";
let buf = new Array<u8>(1024);
let req = `{"arguments":["${environmentValue.toString()}"]}`;
let req_len = req.length;
let head = `${req_len}${SEP}`;
command.stdinWriteString(head);
command.stdinWriteString(`${req}${SEP}`);
buf = new Array<u8>(65535);
let all_buff: u8[] = new Array(0);
let l = command.stdoutRead(buf);
all_buff = all_buff.concat(buf.slice(0, l));
let read_string = buffer2string(all_buff, all_buff.length);
Console.log(read_string);
} else {
Console.log(
"error: no response from the inference extension, source: cgi-allora-infer",
);
}
command.close();
} else {
Console.log(
"error: inference extension not available, source: cgi-allora-infer",
);
}
} else {
Console.log(
"error: inference param not available: ALLORA_ARG_PARAMS, source: cgi-allora-infer",
);
}
}
6 changes: 3 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ func main() {

// Create the Verify struct
verify := Verify{
Alias: "cgi-upshot",
Description: "upshot cgi extension for blockless runtime",
Alias: "cgi-allora-infer",
Description: "allora cgi extension for blockless runtime",
IsCGI: true,
}

Expand Down Expand Up @@ -77,7 +77,7 @@ func main() {
fmt.Println("No valid input provided, continuing with the main loop.")
}

scriptPath := "./main.py"
scriptPath := "/tmp/runtime/extensions/main.py"
if _, err := os.Stat(scriptPath); os.IsNotExist(err) {
scriptPath = "/app/main.py"
if _, err := os.Stat(scriptPath); os.IsNotExist(err) {
Expand Down
3 changes: 0 additions & 3 deletions upshot-function-example/README.md

This file was deleted.

37 changes: 0 additions & 37 deletions upshot-function-example/index.ts

This file was deleted.

0 comments on commit 5c3fecc

Please sign in to comment.