From 7b1fcf9fa050cdb898322d7142b17d64ccc0f9ba Mon Sep 17 00:00:00 2001 From: Holly Grimm Date: Thu, 2 Nov 2023 15:49:35 -0600 Subject: [PATCH 1/3] add run-cowsay-onchain and runsdxl scripts --- stack | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/stack b/stack index 937b9eb3..71d310df 100755 --- a/stack +++ b/stack @@ -257,6 +257,10 @@ function balances() { hardhat-script scripts/balances.ts } +function run-cowsay-onchain() { + hardhat-script scripts/run-cowsay-onchain.ts +} + ############################################################################ ############################################################################ # services @@ -272,6 +276,24 @@ function run() { go run . run "$@" } +function runsdxl() { + # Check for the number of arguments provided + if [ $# -lt 3 ]; then + echo "Usage: $0 runsdxl PROMPT=\"\"" + exit 1 + fi + + source .env + eval $(./stack print-local-dev-env) + export WEB3_PRIVATE_KEY=$JOB_CREATOR_PRIVATE_KEY + export SERVICE_SOLVER=$SOLVER_ADDRESS + export SERVICE_MEDIATORS=$MEDIATOR_ADDRESS + local model="$1" + shift # Remove the first argument, so "$@" contains only the second one + local prompt="$@" + go run . run $model -i "PromptEnv=$prompt" +} + function solver() { source .env eval $(./stack print-local-dev-env) From 34f8d41f126d44c808e753f1d1af4d0253674bf2 Mon Sep 17 00:00:00 2001 From: Holly Grimm Date: Fri, 3 Nov 2023 09:20:35 -0600 Subject: [PATCH 2/3] document cowsay on-chain; update HH .env with NETWORK= --- CONTRIBUTING.md | 12 ++++++++++++ TESTNETDEPLOY.md | 36 ++++++++++++++++++++++++++++++++++-- hardhat/hardhat.config.ts | 4 +++- 3 files changed, 49 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d78ab9b6..2212d5bb 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -118,6 +118,18 @@ Run SDXL: ./stack runsdxl sdxl:v0.9-lilypad1 PROMPT="beautiful view of iceland with a record player" ``` +### 4 - Run Cowsay On-Chain + +Start the on-chain Job Creator: + +```bash +./stack jobcreator +``` + +```bash +./stack run-cowsay-onchain +``` + ## Stopping the Stack To stop Geth at any time, use the following command: diff --git a/TESTNETDEPLOY.md b/TESTNETDEPLOY.md index cc4e709b..6d21d6f8 100644 --- a/TESTNETDEPLOY.md +++ b/TESTNETDEPLOY.md @@ -63,7 +63,10 @@ export INFURA_KEY= ## Setup Hardhat -set defaultNetwork to `sepolia` in `hardhat.config.js` +Add NETWORK to the `hardhat/.env` file: +``` +NETWORK=sepolia +``` Update the following values in the `.env` file. Replace `` with the Infura key from above: ``` @@ -114,14 +117,43 @@ Run the following commands in separate terminals: ./stack solver ``` +Wait for the solver to start when `🟡 SOL solver registered` is logged, and then run: + ```bash ./stack mediator ``` +If you have a GPU, run the following command in a separate terminal window: + +```bash +./stack resource-provider --offer-gpu 1 +``` + +Otherwise, if you don't have a GPU: + ```bash ./stack resource-provider ``` +Run Cowsay: + ```bash ./stack run cowsay:v0.0.1 -i Message="moo" -``` \ No newline at end of file +``` + +Run SDXL: + +```bash +./stack runsdxl sdxl:v0.9-lilypad1 PROMPT="beautiful view of iceland with a record player" +``` + +### 4 - Run Cowsay On-Chain + +Start the on-chain Job Creator: + +```bash +./stack jobcreator +``` + +```bash +./stack run-cowsay-onchain \ No newline at end of file diff --git a/hardhat/hardhat.config.ts b/hardhat/hardhat.config.ts index 25a59026..005b6617 100644 --- a/hardhat/hardhat.config.ts +++ b/hardhat/hardhat.config.ts @@ -14,11 +14,13 @@ import { const ENV_FILE = process.env.DOTENV_CONFIG_PATH || '../.env' dotenv.config({ path: ENV_FILE }) +const NETWORK = process.env.NETWORK || "geth"; + const INFURA_KEY = process.env.INFURA_KEY || ""; const config: HardhatUserConfig = { solidity: '0.8.21', - defaultNetwork: 'geth', + defaultNetwork: NETWORK, namedAccounts: ACCOUNT_ADDRESSES, networks: { hardhat: {}, From cadeb90abb1a1ba6a0c5137db68e6818c06541a4 Mon Sep 17 00:00:00 2001 From: Holly Grimm Date: Fri, 3 Nov 2023 09:30:40 -0600 Subject: [PATCH 3/3] add setRequiredDeposit to 2 --- hardhat/scripts/run-cowsay-onchain.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hardhat/scripts/run-cowsay-onchain.ts b/hardhat/scripts/run-cowsay-onchain.ts index d6ba46fb..d54e0116 100644 --- a/hardhat/scripts/run-cowsay-onchain.ts +++ b/hardhat/scripts/run-cowsay-onchain.ts @@ -6,6 +6,7 @@ import { getWallet, getAddress, } from '../utils/web3' +import { ethers } from 'hardhat' async function main() { // it's annoying to not be able to use argv but hardhat complains about it @@ -15,6 +16,11 @@ async function main() { const manager = await connectJobManager() const client = await connectExampleClient() + const setRequiredDepositTx = await manager + .connect(getWallet('solver')) + .setRequiredDeposit(ethers.parseEther("2")) + await setRequiredDepositTx.wait() + const requiredDeposit = await manager.getRequiredDeposit() console.log(`requiredDeposit: ${Number(requiredDeposit)}`)