Skip to content

Commit

Permalink
Merge branch 'main' of gitlab.com:nosana-ci/apps/platform/nosana-node…
Browse files Browse the repository at this point in the history
… into mainn
  • Loading branch information
jeisses committed Nov 29, 2023
2 parents 0a23a0c + 4390a8f commit be5bf3f
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 11 deletions.
12 changes: 9 additions & 3 deletions src/nosana_node/cli.clj
Original file line number Diff line number Diff line change
@@ -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]
Expand Down Expand Up @@ -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)"
Expand Down
13 changes: 9 additions & 4 deletions src/nosana_node/join_test_grid.clj
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,13 @@
(println "Benchmark finished.")
(println "Receipt" sig "\n")
(println "---\n")
(println "Test Grid Registration code: " run-addr))

(if (= (:status flow) :failed)
(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)))
)
)

(defn join-test-grid
"Handle the `join-test-grid` command."
Expand Down Expand Up @@ -78,11 +84,10 @@
{:sig (<! (nos/finish-flow-2 flow conf))
:flow flow})

;; TODO: does this timeout make sense?
(timeout 5000)
(timeout 300000)
{:error "Error: timed out while waiting for benchmark results."})]
(if (:error result)
(do
(println (:error result))
(System/exit 1))
(print-results (:sig result) (first run) (:flow result)))))))))
(print-results (:sig result) (-> run second :job) (:flow result)))))))))
5 changes: 3 additions & 2 deletions src/nosana_node/main.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
18 changes: 16 additions & 2 deletions src/nosana_node/solana.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit be5bf3f

Please sign in to comment.