Skip to content

Commit

Permalink
Merge pull request #28 from bacalhau-project/dev-holly
Browse files Browse the repository at this point in the history
document cowsay on-chain; update HH .env with NETWORK=
  • Loading branch information
hollygrimm authored Nov 3, 2023
2 parents de302b2 + cadeb90 commit 17fb8e0
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 3 deletions.
12 changes: 12 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
36 changes: 34 additions & 2 deletions TESTNETDEPLOY.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<INFURA_KEY>` with the Infura key from above:
```
Expand Down Expand Up @@ -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"
```
```

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
4 changes: 3 additions & 1 deletion hardhat/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {},
Expand Down
6 changes: 6 additions & 0 deletions hardhat/scripts/run-cowsay-onchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)}`)
Expand Down
22 changes: 22 additions & 0 deletions stack
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,10 @@ function balances() {
hardhat-script scripts/balances.ts
}

function run-cowsay-onchain() {
hardhat-script scripts/run-cowsay-onchain.ts
}

############################################################################
############################################################################
# services
Expand All @@ -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 <model> PROMPT=\"<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)
Expand Down

0 comments on commit 17fb8e0

Please sign in to comment.