From d4f398e0f23699c41e5380f538cc4dbe697e8913 Mon Sep 17 00:00:00 2001 From: Laurens Verspeek Date: Wed, 29 Nov 2023 12:12:46 +0100 Subject: [PATCH 1/5] print job addr + check if job failed --- src/nosana_node/join_test_grid.clj | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/nosana_node/join_test_grid.clj b/src/nosana_node/join_test_grid.clj index fd69583..5c7ac60 100644 --- a/src/nosana_node/join_test_grid.clj +++ b/src/nosana_node/join_test_grid.clj @@ -42,7 +42,11 @@ (println "Benchmark finished.") (println "Receipt" sig "\n") (println "---\n") - (println "Test Grid Registration code: " run-addr)) + + (if (= (:status flow) :failed) + (println (str "Job failed: https://explorer.nosana.io/jobs/"(.toString run-addr)"?network=devnet")) + (println "Test Grid Registration code: " (.toString run-addr))) + ) (defn join-test-grid "Handle the `join-test-grid` command." @@ -78,11 +82,11 @@ {:sig ( run second :job) (:flow result)) + (System/exit 0))))))))) From da38c3125699ff219a6bfd0689f49711dedd167b Mon Sep 17 00:00:00 2001 From: Jair Zijp Date: Wed, 29 Nov 2023 11:15:03 +0000 Subject: [PATCH 2/5] Create wallet for node --- src/nosana_node/cli.clj | 12 +++++++++--- src/nosana_node/main.clj | 5 +++-- src/nosana_node/nosana.clj | 4 ++++ src/nosana_node/solana.clj | 18 ++++++++++++++++-- 4 files changed, 32 insertions(+), 7 deletions(-) diff --git a/src/nosana_node/cli.clj b/src/nosana_node/cli.clj index b4abe70..6148309 100644 --- a/src/nosana_node/cli.clj +++ b/src/nosana_node/cli.clj @@ -1,5 +1,6 @@ (ns nosana-node.cli (:require [taoensso.timbre :as log] + [nosana-node.solana :as sol] [clojure.string :as string] [clojure.edn :as edn] [clojure.java.io :as io] @@ -36,9 +37,14 @@ :id :solana-network] ["-k" "--keypair PATH" "Path to wallet private key" :default-fn (fn [_] - (or (System/getenv "SOLANA_PRIVATE_KEY") - (slurp (str (System/getenv "HOME") "/nosana_key.json")))) - :default-desc "~/nosana_key.json" + (let [default-key-file-name (str (System/getenv "HOME") "/.nosana/nosana_key.json")] + (or (System/getenv "SOLANA_PRIVATE_KEY") + (do + (when (not (.exists (io/as-file default-key-file-name))) + (let [public-key (sol/create-private-key default-key-file-name)] + (println "Created SOL Keypair at: \u001B[34m" default-key-file-name "\u001B[0m"))) + (slurp default-key-file-name))))) + :default-desc "~/.nosana/nosana_key.json" :parse-fn slurp :id :solana-private-key] ["-v" nil "Use verbose output (-vvvvv very verbose output)" diff --git a/src/nosana_node/main.clj b/src/nosana_node/main.clj index 3b1a141..92d6c8e 100644 --- a/src/nosana_node/main.clj +++ b/src/nosana_node/main.clj @@ -49,8 +49,9 @@ system {:http/handler #'nos-sys/handler :system/components [use-vault - cli/use-cli - store/use-fs-store + cli/use-cli + nosana/use-fund-sol-wallet + store/use-fs-store ;; nrepl is useful for debugging, ;; make config later (use-when (constantly false) diff --git a/src/nosana_node/nosana.clj b/src/nosana_node/nosana.clj index 9b41f89..9b0c2a9 100644 --- a/src/nosana_node/nosana.clj +++ b/src/nosana_node/nosana.clj @@ -792,6 +792,10 @@ nil))) sys) +(defn use-fund-sol-wallet [{:nos/keys [conf] :as sys}] + + sys) + (defn use-nosana "Component that loads the Nosana config." [{:nos/keys [store flow-chan vault] :as system}] diff --git a/src/nosana_node/solana.clj b/src/nosana_node/solana.clj index 20397f7..099212f 100644 --- a/src/nosana_node/solana.clj +++ b/src/nosana_node/solana.clj @@ -5,7 +5,8 @@ [clojure.core.async :as async :refer [!! put! go go-loop >! timeout take! chan]] [cheshire.core :as json] [clj-http.client :as http] - [clojure.java.io :as io]) + [clojure.java.io :as io] + [taoensso.timbre :as log]) (:import [org.p2p.solanaj.utils ByteUtils] [org.p2p.solanaj.rpc RpcClient Cluster] @@ -116,7 +117,20 @@ (recur rst) (->> head (conj rst) (take 32) reverse byte-array public-key)))))) - +(defn create-private-key + "Save new keypair as JSON at `file-name`, returns public key." + [file-name] + (let [keypair (TweetNaclFast$Signature/keyPair) + ;; convert private key to a unsigned int array format + private-key (json/encode (map #(bit-and % 0xff) (.getSecretKey keypair))) + public-key (util/base58 (.getPublicKey keypair))] + (if (.exists (io/as-file file-name)) + (log :error "KeyPair already exists at " file-name) + (do + (io/make-parents file-name) + (spit file-name private-key) + (log :debug "Created Solana Key Pair at " file-name public-key) + public-key)))) (defn create-pub-key-from-seed "Derive a public key from another key, a seed, and a program ID. From ca47a1ccc1e7c3b6b6398e45bd77351b3a9c3ed6 Mon Sep 17 00:00:00 2001 From: Laurens Verspeek Date: Wed, 29 Nov 2023 12:15:54 +0100 Subject: [PATCH 3/5] remove double System/exit --- src/nosana_node/join_test_grid.clj | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/nosana_node/join_test_grid.clj b/src/nosana_node/join_test_grid.clj index 5c7ac60..4285d21 100644 --- a/src/nosana_node/join_test_grid.clj +++ b/src/nosana_node/join_test_grid.clj @@ -88,5 +88,4 @@ (do (println (:error result)) (System/exit 1)) - ((print-results (:sig result) (-> run second :job) (:flow result)) - (System/exit 0))))))))) + (print-results (:sig result) (-> run second :job) (:flow result))))))))) From cf279d407c3c685b6549ed296ff5efd1b1ede693 Mon Sep 17 00:00:00 2001 From: Laurens Verspeek Date: Wed, 29 Nov 2023 12:21:25 +0100 Subject: [PATCH 4/5] also post link to explorer on successful test-grid job --- src/nosana_node/join_test_grid.clj | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/nosana_node/join_test_grid.clj b/src/nosana_node/join_test_grid.clj index 4285d21..1bf13ed 100644 --- a/src/nosana_node/join_test_grid.clj +++ b/src/nosana_node/join_test_grid.clj @@ -44,8 +44,10 @@ (println "---\n") (if (= (:status flow) :failed) - (println (str "Job failed: https://explorer.nosana.io/jobs/"(.toString run-addr)"?network=devnet")) - (println "Test Grid Registration code: " (.toString run-addr))) + (println (str "Job failed: https://explorer.nosana.io/jobs/"(.toString run-addr)"?network=devnet")) + ((println (str "Job Succeeded: https://explorer.nosana.io/jobs/"(.toString run-addr)"?network=devnet")) + (println "Test Grid Registration code: " (.toString run-addr))) + ) ) (defn join-test-grid From 4390a8f0438d05844ae1e300405eae4a76abd87b Mon Sep 17 00:00:00 2001 From: Laurens Verspeek Date: Wed, 29 Nov 2023 12:34:01 +0100 Subject: [PATCH 5/5] show video card not detected when job fails --- src/nosana_node/join_test_grid.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nosana_node/join_test_grid.clj b/src/nosana_node/join_test_grid.clj index 1bf13ed..b9e82ee 100644 --- a/src/nosana_node/join_test_grid.clj +++ b/src/nosana_node/join_test_grid.clj @@ -44,7 +44,7 @@ (println "---\n") (if (= (:status flow) :failed) - (println (str "Job failed: https://explorer.nosana.io/jobs/"(.toString run-addr)"?network=devnet")) + (println (str "Could not detect NVIDIA Video Card: https://explorer.nosana.io/jobs/"(.toString run-addr)"?network=devnet")) ((println (str "Job Succeeded: https://explorer.nosana.io/jobs/"(.toString run-addr)"?network=devnet")) (println "Test Grid Registration code: " (.toString run-addr))) )