Skip to content

refactor: latest wavs 0.4.0-alpha.2 #119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 37 commits into from
Apr 18, 2025
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
a0bc63e
`local`
Reecepbcups Apr 8, 2025
9fcc0f3
wavs-wasi-utils, use middleware interface for Submit
Reecepbcups Apr 8, 2025
467ce0d
almost working
Reecepbcups Apr 8, 2025
c6d5a19
re-org
Reecepbcups Apr 8, 2025
92b5094
use upstream npm instead of local
Reecepbcups Apr 8, 2025
0ec0bbd
fix: go bindings https://github.com/Lay3rLabs/wavs-wasi/pull/15
Reecepbcups Apr 8, 2025
abf60d1
fix: js component wasm-exec
Reecepbcups Apr 8, 2025
4ddfe6d
touchups
Reecepbcups Apr 8, 2025
e242b21
`0.4.0-alpha.2`
Reecepbcups Apr 9, 2025
f603309
closer!! actually deployed the service
Reecepbcups Apr 10, 2025
252b8b5
WORKING WOOOO
Reecepbcups Apr 10, 2025
223512a
wavs:latest: new commands off of c10f680b41b
Reecepbcups Apr 11, 2025
d90e219
all components work in the live env
Reecepbcups Apr 11, 2025
096e25f
use latest with docker tagged
Reecepbcups Apr 11, 2025
0c38ad1
remove aggregator endpoints
Reecepbcups Apr 11, 2025
3b7e027
optional: use aggregator in build_service.sh
Reecepbcups Apr 11, 2025
0af0a7c
chore(deps): docci v0.7 (#123)
Reecepbcups Apr 12, 2025
a58b4e2
docci: main readme only (no docs/tutorial atm)
Reecepbcups Apr 12, 2025
1a91dc3
unofficial `ghcr.io/lay3rlabs/wavs-middleware:0.0.1`
Reecepbcups Apr 12, 2025
9f43f5d
test: README's updated to work for all languages
Reecepbcups Apr 12, 2025
e179373
wavs-middleware:local
Reecepbcups Apr 12, 2025
b3470c2
mv wavs-middleware:local -> reecepbcups/wavs-middleware:0.0.1
Reecepbcups Apr 14, 2025
1e80170
`start-all.sh` refactor, working local docci for all languages
Reecepbcups Apr 14, 2025
1ae8e90
more delay (go)
Reecepbcups Apr 14, 2025
97dac86
fix: wavs-cli hardcode
Reecepbcups Apr 14, 2025
7c36c36
slow down deploying contracts
Reecepbcups Apr 14, 2025
d04a64c
raw curl upload component (temp)
Reecepbcups Apr 14, 2025
fbbf00d
fix: ci format
Reecepbcups Apr 14, 2025
b4e3a44
longer docci delay
Reecepbcups Apr 14, 2025
562b2c0
fix: use wget
Reecepbcups Apr 14, 2025
bdcc460
nits
Reecepbcups Apr 14, 2025
f397551
cleanup
Reecepbcups Apr 14, 2025
5d012c4
macos support
Reecepbcups Apr 14, 2025
0f7e009
fix: sed_opt
Reecepbcups Apr 15, 2025
c3640e9
sed space or not depending on OS
Reecepbcups Apr 15, 2025
3db54aa
remove via_ir in foundry.toml
Reecepbcups Apr 15, 2025
8ee37bc
fix: add more delay
Reecepbcups Apr 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,21 +1,41 @@
# == project ==
# If you have custom env vars in your project, you can set them here
# You also must update the `host_envs` field in `SERVICE_CONFIG` in `Makefile`
# You also must update the `host_envs` field in `SERVICE_CONFIG` in `Makefile`
WAVS_ENV_YOURKEYHERE="00000000000000000000000000000000"

# WAVS
WAVS_DATA=~/wavs/data
WAVS_LOG_LEVEL="info"
WAVS_SUBMISSION_MNEMONIC="test test test test test test test test test test test junk"
WAVS_AGGREGATOR_MNEMONIC="test test test test test test test test test test test junk"
WAVS_COSMOS_SUBMISSION_MNEMONIC="cosmos mnemonic here"

# CLI
WAVS_CLI_DATA=~/wavs/cli
WAVS_CLI_COSMOS_MNEMONIC="cosmos mnemonic here"
WAVS_CLI_ETH_MNEMONIC="test test test test test test test test test test test junk"
WAVS_CLI_LOG_LEVEL="info, wavs_cli=debug"
WAVS_CLI_LOG_LEVEL="info, wavs_cli=info"

# FUNDED_KEY=0x10df54bba92e291d74bc0b453d8173641f7df5b2db419d0276865079902636b6

# Aggregator
WAVS_AGGREGATOR_DATA=~/wavs/aggregator
WAVS_AGGREGATOR_MNEMONIC="test test test test test test test test test test test junk"
WAVS_AGGREGATOR_MNEMONIC="test test test test test test test test test test test junk"

# TODO: Replace with your RPC URL
RPC_URL=https://holesky.drpc.org



# FIXME: place your project's metadata URI here
METADATA_URI=https://wavs.xyz/metadata.json

# what should I put here??
QUICK_MODE=ON
NUM_OPERATORS=3 # Number of operators to set up when QUICK_MODE is OFF
DEPLOY_ENV=LOCAL
FUNDED_KEY=
CHAIN_ID=17000
ETHERSCAN_API_KEY=foobar
LOCAL_ETHEREUM_RPC_URL=http://localhost:8545
LST_CONTRACT_ADDRESS=0x3F1c547b21f65e10480dE3ad8E19fAAC46C95034
LST_STRATEGY_ADDRESS=0x7D704507b76571a51d9caE8AdDAbBFd0ba0e63d3
24 changes: 0 additions & 24 deletions .github/single-wavs-image-verifier.bash
Original file line number Diff line number Diff line change
Expand Up @@ -51,29 +51,5 @@ main() {
fi
}

test_data() {
# Example test data
TEST_DATA="
Running container ghcr.io/lay3rlabs/wavs:latest-beta
Pulling ghcr.io/lay3rlabs/wavs:latest
Found ghcr.io/lay3rlabs/wavs:0.1.0
Invalid: docker.io/other/image:1.0
Using ghcr.io/lay3rlabs/wavs:sha-abc123
ghcr.io/lay3rlabs/wavs:rc.1.0.0
Pulling ghcr.io/lay3rlabs/wavs:latest
Found ghcr.io/lay3rlabs/wavs:0.1.0
Invalid: docker.io/other/image:1.0
Using ghcr.io/lay3rlabs/wavs:sha-abc123
ghcr.io/lay3rlabs/wavs:rc.1.0.0
ghcr.io/lay3rlabs/wavs:latest-beta
ghcr.io/lay3rlabs/wavs:1.0.0-alpha
"

# Find all matches_set with line numbers (-n) and print the pattern at the top
echo "Pattern being used: $GREP_PATTERN"
echo -e "\nmatches_set found:"
echo "$TEST_DATA" | grep -P -o "$GREP_PATTERN"
}

# test_data
main
13 changes: 5 additions & 8 deletions .github/workflows/docs-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,20 +91,17 @@ jobs:

- name: Install docci readme runner
run: |
RELEASE=https://github.com/Reecepbcups/docci/releases/download/v0.6.0/docci
RELEASE=https://github.com/Reecepbcups/docci/releases/download/v0.7.1/docci
sudo wget --quiet -O /usr/local/bin/docci ${RELEASE}
sudo chmod a+rx /usr/local/bin/docci


# installs wasm-tools as well, required for rust & ts
- name: Run docci (go)
run: |
docci components/golang-eth-price-oracle/config.json
run: docci components/golang-eth-price-oracle/config.json

- name: Run docci (rust)
run: |
docci components/eth-price-oracle/config.json
run: docci components/eth-price-oracle/config.json

- name: Run docci (typescript)
run: |
docci components/js-eth-price-oracle/config.json
# - name: Run docci (typescript)
# run: docci components/js-eth-price-oracle/config.json
Comment on lines +106 to +107
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: re-add

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ cache/
broadcast/
compiled/*.wasm
.docker/*.json
.docker/*.log
.env
node_modules/
lcov.info
internal/
wavs:worker*.wit
wavs:worker*.wasm
.nodes
6 changes: 3 additions & 3 deletions Cargo-component.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ version = 1
name = "wavs:worker"

[[package.version]]
requirement = "^0.4.0-alpha.1"
version = "0.4.0-alpha.1"
digest = "sha256:7fe7d9e60fa1fa215b8e70b24ed77f9bd62c1d98c09060036d8b7e7b804e0dac"
requirement = "^0.4.0-alpha.2"
version = "0.4.0-alpha.2"
digest = "sha256:6b8578c639c35ca2fd53c2cb7c357e29e62a605ebe4b3180bd5ad00f069d3624"
9 changes: 4 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ wit-bindgen-rt = {version = "0.39.0", features = ["bitflags"]}
wit-bindgen = "0.39.0"
wstd = "0.5.1"
wasi = "0.14.1"
wavs-wasi-chain = "0.3.0"
wavs-wasi-utils = { git = "https://github.com/Lay3rLabs/wavs-wasi" }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: use crates.io v0.4.0 when it comes out for alpha.2 +


# Other
serde = { version = "1.0.217", features = ["derive"] }
Expand Down
20 changes: 13 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ SERVICE_CONFIG_FILE?=.docker/service.json
CARGO=cargo
# the directory to build, or "" for all
WASI_BUILD_DIR ?= ""
DOCKER_IMAGE?=ghcr.io/lay3rlabs/wavs:0.4.0-alpha1-amd64
DOCKER_IMAGE?=ghcr.io/lay3rlabs/wavs:reece_priv_key_signing_apr_10
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TOOD: alpha.3 +

WAVS_CMD ?= $(SUDO) docker run --rm --network host $$(test -f .env && echo "--env-file ./.env") -v $$(pwd):/data ${DOCKER_IMAGE} wavs-cli
ANVIL_PRIVATE_KEY?=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
RPC_URL?=http://localhost:8545
Expand Down Expand Up @@ -83,30 +83,36 @@ start-all: clean-docker setup-env

## get-service-handler: getting the service handler address from the script deploy
get-service-handler-from-deploy:
@jq -r '.service_handler' "./.docker/script_deploy.json"
@jq -r '.deployedTo' "./.docker/submit.json"

get-eigen-service-manager-from-deploy:
@jq -r '.eigen_service_managers.local | .[-1]' .docker/deployments.json

## get-trigger: getting the trigger address from the script deploy
get-trigger-from-deploy:
@jq -r '.trigger' "./.docker/script_deploy.json"
@jq -r '.deployedTo' "./.docker/trigger.json"

## wavs-cli: running wavs-cli in docker
wavs-cli:
@$(WAVS_CMD) $(filter-out $@,$(MAKECMDGOALS))

## upload-component: uploading the WAVS component | COMPONENT_FILENAME
upload-component:
@curl --silent -X POST http://127.0.0.1:8000/upload --data-binary @./compiled/$(COMPONENT_FILENAME) -H "Content-Type: application/wasm" | jq -r .digest
# TODO: move to $(WAVS_CMD) upload-component ./compiled/${COMPONENT_FILENAME}
@wget --post-file=./compiled/${COMPONENT_FILENAME} --header="Content-Type: application/wasm" -O - http://127.0.0.1:8000/upload | jq -r .digest
Comment on lines +85 to +86
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine for now, but upload-component (or using a proper registry with the new workflows coming in -alpha.3 are ideal)


## deploy-service: deploying the WAVS component service json | SERVICE_CONFIG_FILE
deploy-service:
@$(WAVS_CMD) deploy-service-raw --log-level=info --data /data/.docker --home /data --service `jq -c . < $(SERVICE_CONFIG_FILE)`
@$(WAVS_CMD) deploy-service-raw --service `jq . -cr ${SERVICE_CONFIG_FILE}` --log-level=info --data /data/.docker --home /data

## show-result: showing the result | SERVICE_TRIGGER_ADDR, SERVICE_SUBMISSION_ADDR, RPC_URL
## get-trigger: get the trigger id | SERVICE_TRIGGER_ADDR, RPC_URL
get-trigger:
@forge script ./script/ShowResult.s.sol ${SERVICE_TRIGGER_ADDR} --sig 'trigger(string)' --rpc-url $(RPC_URL) --broadcast -v 4

TRIGGER_ID?=1
## show-result: showing the result | SERVICE_SUBMISSION_ADDR, TRIGGER_ID, RPC_URL
show-result:
@forge script ./script/ShowResult.s.sol ${SERVICE_TRIGGER_ADDR} ${SERVICE_SUBMISSION_ADDR} --sig 'run(string,string)' --rpc-url $(RPC_URL) --broadcast -v 4
@forge script ./script/ShowResult.s.sol ${SERVICE_SUBMISSION_ADDR} ${TRIGGER_ID} --sig 'data(string,uint64)' --rpc-url $(RPC_URL) --broadcast -v 4

_build_forge:
@forge build
Expand Down
43 changes: 27 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,17 +173,25 @@ Result (utf8):

Start an ethereum node (anvil), the WAVS service, and deploy [eigenlayer](https://www.eigenlayer.xyz/) contracts to the local network.

```bash docci-background docci-delay-after=5
# copy over the .env file if you need to override the defaults
# the default component does not require any env variables
#
# cp .env.example .env

```bash docci-background docci-delay-after=15
# Start the backend
#
# This must remain running in your terminal. Use another terminal to run other commands.
# You can stop the services with `ctrl+c`. Some MacOS terminals require pressing it twice.
make start-all
# make start-all
cp .env.example .env

sh ./script/start_all.sh
```

Wait for full local deployment, then grab values

```bash docci-delay-after=2
while [ ! -f .docker/start.log ]; do echo "waiting for start.log" && sleep 1; done

export SERVICE_MANAGER_ADDRESS=$(jq -r .addresses.WavsServiceManager .nodes/avs_deploy.json)
export PRIVATE_KEY=$(cat .nodes/deployer)
export MY_ADDR=$(cast wallet address --private-key $PRIVATE_KEY)
```

### Deploy Service Contracts
Expand All @@ -196,20 +204,20 @@ make start-all
`SERVICE_MANAGER_ADDR` is the address of the Eigenlayer service manager contract. It was deployed in the previous step. Then you deploy the trigger and submission contracts which depends on the service manager. The service manager will verify that a submission is valid (from an authorized operator) before saving it to the blockchain. The trigger contract is any arbitrary contract that emits some event that WAVS will watch for. Yes, this can be on another chain (e.g. an L2) and then the submission contract on the L1 *(Ethereum for now because that is where Eigenlayer is deployed)*.

```bash
export SERVICE_MANAGER_ADDR=`make get-eigen-service-manager-from-deploy`
forge script ./script/Deploy.s.sol ${SERVICE_MANAGER_ADDR} --sig 'run(string)' --rpc-url http://localhost:8545 --broadcast
```
forge create SimpleSubmit --json --broadcast -r http://127.0.0.1:8545 --private-key "${PRIVATE_KEY}" --constructor-args "${SERVICE_MANAGER_ADDRESS}" > .docker/submit.json
export SERVICE_SUBMISSION_ADDR=`jq -r .deployedTo .docker/submit.json`

> [!TIP]
> You can see the deployed trigger address with `make get-trigger-from-deploy`
forge create SimpleTrigger --json --broadcast -r http://127.0.0.1:8545 --private-key "${PRIVATE_KEY}" > .docker/trigger.json
export SERVICE_TRIGGER_ADDR=`jq -r .deployedTo .docker/trigger.json`
```

## Deploy Service

Deploy the compiled component with the contract information from the previous steps. Review the [makefile](./Makefile) for more details and configuration options.`TRIGGER_EVENT` is the event that the trigger contract emits and WAVS watches for. By altering `SERVICE_TRIGGER_ADDR` you can watch events for contracts others have deployed.

```bash docci-delay-per-cmd=1
```bash docci-delay-per-cmd=2
# Build your service JSON with optional overrides in the script
COMPONENT_FILENAME=eth_price_oracle.wasm sh ./script/build_service.sh
COMPONENT_FILENAME=eth_price_oracle.wasm AGGREGATOR_URL=http://127.0.0.1:8001 sh ./script/build_service.sh

# Deploy the service JSON to WAVS so it now watches and submits
# the results based on the service json configuration.
Expand All @@ -234,7 +242,10 @@ forge script ./script/Trigger.s.sol ${SERVICE_TRIGGER_ADDR} ${COIN_MARKET_CAP_ID

Query the latest submission contract id from the previous request made.

```bash docci-delay-per-cmd=2 docci-output-contains="1"
make get-trigger
```

```bash docci-delay-per-cmd=2 docci-output-contains="BTC"
# Get the latest TriggerId and show the result via `script/ShowResult.s.sol`
make show-result
TRIGGER_ID=1 make show-result
```
4 changes: 0 additions & 4 deletions cli.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,18 @@ gas_denom = "untrn"
chain_id = "31337"
ws_endpoint = "ws://localhost:8545"
http_endpoint = "http://localhost:8545"
aggregator_endpoint = "http://localhost:8001"

[chains.eth.local2]
chain_id = "31338"
ws_endpoint = "ws://localhost:8645"
http_endpoint = "http://localhost:8645"
aggregator_endpoint = "http://localhost:8001"

[chains.eth.sepolia]
chain_id = "11155111"
ws_endpoint = "wss://ethereum-sepolia-rpc.publicnode.com"
http_endpoint = "https://ethereum-sepolia-rpc.publicnode.com"
aggregator_endpoint = "http://localhost:8001"

[chains.eth.holesky]
chain_id = "17000"
ws_endpoint = "wss://ethereum-holesky-rpc.publicnode.com"
http_endpoint = "https://ethereum-holesky-rpc.publicnode.com"
aggregator_endpoint = "http://localhost:8001"
4 changes: 2 additions & 2 deletions components/eth-price-oracle/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ repository.workspace = true

[dependencies]
wit-bindgen-rt = {workspace = true}
wavs-wasi-chain = { workspace = true }
wavs-wasi-utils = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
alloy-sol-macro = { workspace = true }
Expand All @@ -28,4 +28,4 @@ lto = true

[package.metadata.component]
package = "component:eth-price-oracle"
target = "wavs:worker/[email protected].1"
target = "wavs:worker/[email protected].2"
6 changes: 2 additions & 4 deletions components/eth-price-oracle/config.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
{
"__tool": "github.com/reecepbcups/docci",
"paths": [
"README.md",
"docs/tutorial"
"README.md"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: docs/ update and re-add tutorial back

],
"env_vars": {},
"pre_cmds": [],
"log_level": "ERROR",
"cleanup_cmds": [
"killall anvil || true",
"docker compose rm --stop --force --volumes || true",
"docker rm -f wavs wavs-aggregator wavs-deploy-service-manager wavs-deploy-eigenlayer || true"
"docker compose rm --stop --force --volumes || true"
]
}
Loading
Loading