Skip to content
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

Implement actual AVS functionality #30

Merged
merged 52 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
a7eed42
start fixing ava-sdk-js test
v9n Nov 14, 2024
31fb659
add create wallet test
v9n Nov 14, 2024
b178ec5
run test with local docker
v9n Nov 14, 2024
5ceffca
SDK is 100% working
v9n Nov 19, 2024
361e2b2
add 2 ore attestion
v9n Nov 19, 2024
c2d3530
remvoe magic const
v9n Nov 19, 2024
24c2028
more fixed test
v9n Nov 20, 2024
8424188
add ulid
v9n Nov 20, 2024
52c6226
fix get addresses test
v9n Nov 20, 2024
463c28a
fix get Task
v9n Nov 20, 2024
5a0929e
fix list task
v9n Nov 20, 2024
4e01b01
wait for aggregator
v9n Nov 20, 2024
5ce463e
wait server ready
v9n Nov 20, 2024
d9bcb71
run compose up early
v9n Nov 20, 2024
415b364
run compose up very early
v9n Nov 20, 2024
179a8f7
no head
v9n Nov 20, 2024
d5300aa
update test
v9n Nov 20, 2024
0d59d3a
update github action
v9n Nov 20, 2024
52ccbe1
use 2 different provider for unittest
v9n Nov 20, 2024
8e4ad91
add information about apikey
v9n Nov 20, 2024
fefd122
improve test reliabilioty
v9n Nov 20, 2024
33a330d
remove unused secret
v9n Nov 20, 2024
deb660c
fix workflow file
v9n Nov 20, 2024
a75597d
use pre-define dummy private key for deterministic test
v9n Nov 20, 2024
504d97a
implement trigger
v9n Nov 20, 2024
262bd7c
update node return type
v9n Nov 20, 2024
eebb69e
use vinh's rpc to run test
v9n Nov 20, 2024
98aca01
update type
v9n Nov 20, 2024
7db6649
add compiled file
v9n Nov 20, 2024
906793f
fix all test
v9n Nov 20, 2024
200ef71
completed all node type
v9n Nov 20, 2024
77d66ce
update type
v9n Nov 20, 2024
b6355ca
pr feedback
v9n Nov 20, 2024
bb887d8
switch to dist
v9n Nov 20, 2024
7f5a762
test
v9n Nov 20, 2024
8111a80
update fixture name
v9n Nov 20, 2024
ce82fc0
update readme
v9n Nov 20, 2024
0fbb45b
update
v9n Nov 20, 2024
fee4ca0
add backend endpoint
v9n Nov 20, 2024
5efd01d
run test agains local and staging
v9n Nov 20, 2024
b5be367
add sleep to wait
v9n Nov 20, 2024
1dbc3de
export right env
v9n Nov 20, 2024
f672150
wait
v9n Nov 20, 2024
457aeed
debug
v9n Nov 20, 2024
173a81b
separea local and staging test
v9n Nov 20, 2024
7666f88
Added auto-replace command of TEST_API_KEY to gen-apikey
chrisli30 Nov 21, 2024
82848b1
Removed dist folder since we can auto-generate it now
chrisli30 Nov 21, 2024
ebbc05a
Added grpc-tools to package.json dependency
chrisli30 Nov 21, 2024
05aa834
Remove the ./dist folder
chrisli30 Nov 21, 2024
924a64c
Cleaned up README to remove old instructions
chrisli30 Nov 21, 2024
a8200fc
Merge pull request #31 from AvaProtocol/chris-cleanup_readme
v9n Nov 21, 2024
23000c4
split workflow
v9n Nov 21, 2024
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
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"
v9n marked this conversation as resolved.
Show resolved Hide resolved
eth_ws_url: wss://sepolia.gateway.tenderly.co
bundler_url: https://bundler-sepolia.avaprotocol.org
factory_address: 0x29adA1b5217242DEaBB142BC3b1bCfFdd56008e7
Expand Down
Loading