Skip to content

Commit

Permalink
Implement actual AVS functionality (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
v9n authored Nov 21, 2024
1 parent 7877b3c commit 38b6d89
Show file tree
Hide file tree
Showing 31 changed files with 15,530 additions and 21,007 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/dev-test-on-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Run tests againts dev version on PR

on:
pull_request:
branches: [ main ]

jobs:
local-test:
runs-on: ubuntu-latest
environment: test # The below environment variables are only available in the test environment

env:
TEST_PRIVATE_KEY: ${{ secrets.TEST_PRIVATE_KEY }}
TOKEN_CONTRACT: ${{ vars.TOKEN_CONTRACT }}
ORACLE_CONTRACT: ${{ vars.ORACLE_CONTRACT }}
ENDPOINT: "localhost:2206"

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Bring up docker compose
run: |
docker compose up -d
- name: Debug environment variables
run: |
echo "TOKEN_CONTRACT: $TOKEN_CONTRACT"
echo "ORACLE_CONTRACT: $ORACLE_CONTRACT"
echo "ENDPOINT: $ENDPOINT"
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '18.x'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: ensure the aggregator and env is ready
run: |
until curl --output /dev/null --silent --fail http://localhost:1323/up; do
printf '.'
sleep 5
done
- name: Run tests againts local AVS
run: |
export TEST_API_KEY="$(docker compose exec aggregator /ava create-api-key --role=admin --subject=apikey)"
export ENDPOINT="localhost:2206"
npm test
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: Run tests on PR
name: Run tests against staging on PR

on:
pull_request:
branches: [ main ]

jobs:
test:
staging-test:
runs-on: ubuntu-latest
environment: test # The below environment variables are only available in the test environment

Expand All @@ -15,26 +15,26 @@ jobs:
TOKEN_CONTRACT: ${{ vars.TOKEN_CONTRACT }}
ORACLE_CONTRACT: ${{ vars.ORACLE_CONTRACT }}
ENDPOINT: ${{ vars.ENDPOINT }}

steps:
- name: Checkout repository
uses: actions/checkout@v4


- name: Debug environment variables
run: |
echo "TOKEN_CONTRACT: $TOKEN_CONTRACT"
echo "ORACLE_CONTRACT: $ORACLE_CONTRACT"
echo "ENDPOINT: $ENDPOINT"
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '18.x'
cache: 'npm'

- name: Install dependencies
run: npm ci
- name: Debug environment variables

- name: Run tests againts staging AVS
run: |
echo "TOKEN_CONTRACT: $TOKEN_CONTRACT"
echo "ORACLE_CONTRACT: $ORACLE_CONTRACT"
echo "ENDPOINT: $ENDPOINT"
echo "TEST_PRIVATE_KEY is set: ${{ env.TEST_PRIVATE_KEY != '' }}"
- name: Run tests
run: npm test
npm test
42 changes: 23 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ import { AvaSDK } from "ava-sdk-js";

## Development

### Regenerating gRPC Types

In the case of `.proto` files at https://github.com/AvaProtocol/EigenLayer-AVS/blob/main/protobuf/avs.proto changes, the gRPC types needs to be regenerated.Before regenerating the types from the protocol buffers, ensure that `grpc_tools_node_protoc` is installed globally on your system. You can install it using npm:
### Install Dependencies and Download Proto Files

```bash
npm install # install grpc-tools, etc. as dev dependencies
Expand All @@ -49,9 +47,10 @@ npm run proto-download

# Generate the TypeScript types and gRPC code based on the downloaded .proto file
npm run gen-protoc
```

> Important: the last line of the `grpc_codegen/avs_pb.js` needs to be manually added after the `gen-protoc` command. These type definitions must be exported; otherwise they will be undefined in the SDK. For example: `export const { Task, CreateTaskReq, CreateTaskResp, GetKeyReq, KeyResp, UpdateChecksReq, UpdateChecksResp, AddressResp, AddressRequest } = proto.aggregator;`
# Build the source files in to ./dist folder
npm run build
```

### Running Tests

Expand All @@ -67,19 +66,23 @@ To ensure the SDK is functioning correctly, we have a comprehensive test suite.
3. Bring up a locally environment for aggregator

```bash
docker compose up -d
docker compose up -d --pull always
```

When running test, you will want to test against different aggregator. You can do so by finding the hash of the branch/commit of EigenLayer-AVS code and run it like this
> By default the above command will pull the docker image of the latest commit on the `main` branch of https://github.com/AvaProtocol/EigenLayer-AVS. Alternatively, we could also run tests against a specific commit with the below command.
>
> ```
> export AVS_BUILD_VERSION=git-commit-hash-123
> docker compose up -d --pull always
> ```
```
export AVS_BUILD_VERSION=git-commit-hash-123
docker compose down
docker compose pull
docker compose up -d
```
4. Generate a test API key for the local tests with the following command. It will automatically save the output to the `TEST_API_KEY` variable in `.env.test`.
3. Run the test command. This will test the SDK against test server, configured in `.env.test`.
```bash
npm run gen-apikey
```
5. Run the test command with env variables set in `.env.test`.

```bash
# Run all tests
Expand All @@ -89,12 +92,13 @@ To ensure the SDK is functioning correctly, we have a comprehensive test suite.
npm run test:select -- <authWithSignature>
```

4. In order to individually test `cancelTask` or `deleteTask`, `createTask` test needs to run first.
```bash
npm run test:select -- "createTask|cancelTask"
```
> Note: In order to individually test `cancelTask` or `deleteTask`, `createTask` test needs to run first.
> ```bash
> npm run test:select -- "createTask|cancelTask"
> ```
This will execute all unit and integration tests. Make sure all tests pass before submitting a pull request or deploying changes.
This will execute all unit and integration tests. Make sure all tests pass in local dev environment before submitting a pull request or deploying changes.
## Release Process
Expand Down
3 changes: 2 additions & 1 deletion config/aggregator.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Dummy unsecure test key. do not deposit real fund to here
# Wallet: 0x578B110b0a7c06e66b7B1a33C39635304aaF733c
ecdsa_private_key: e0502ddd5a0d05ec7b5c22614a01c8ce783810edaa98e44cc82f5fa5a819aaa9

eth_rpc_url: https://holesky.gateway.tenderly.co/6PJfDJkrMGBl3f4MuyU5M
Expand All @@ -23,7 +24,7 @@ jwt_secret: "1b7db1c64236d92de3b3ed32e5d6bf56"
# account abstraction config
# Sepolia
smart_wallet:
eth_rpc_url: https://sepolia.gateway.tenderly.co
eth_rpc_url: "https://sepolia-rpc.asa.town/?apikey=gvbYpyPMZtS8c3ye801OHMmSJy8WndPcg3AWaFYcs3nSkgI4"
eth_ws_url: wss://sepolia.gateway.tenderly.co
bundler_url: https://bundler-sepolia.avaprotocol.org
factory_address: 0x29adA1b5217242DEaBB142BC3b1bCfFdd56008e7
Expand Down
Loading

0 comments on commit 38b6d89

Please sign in to comment.