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

feat: add tool to query aggregates pending deal #99

Merged
merged 1 commit into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- uses: actions/setup-node@v3
with:
registry-url: 'https://registry.npmjs.org'
node-version: 18
node-version: 20
cache: 'npm'
- run: npm install @web3-storage/pieces
- name: Run job
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- uses: actions/setup-node@v3
with:
registry-url: 'https://registry.npmjs.org'
node-version: 18
node-version: 20
cache: 'npm'
- run: npm install @web3-storage/pieces
- name: Run job
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/get-aggregate-deals.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- uses: actions/setup-node@v3
with:
registry-url: 'https://registry.npmjs.org'
node-version: 18
node-version: 20
cache: 'npm'
- run: npm ci
- name: Run job
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/get-aggregates-pending-deals.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Get Aggregates pending deals

on:
workflow_dispatch:

jobs:
getAggregatesOffered:
name: Get Aggregates pending deals
runs-on: ubuntu-latest
strategy:
matrix:
env: ['staging', 'production']
timeout-minutes: 20
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
registry-url: 'https://registry.npmjs.org'
node-version: 20
cache: 'npm'
- run: npm ci
- name: Run job
run: npm run get-aggregates-pending-deals -w packages/tools
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- uses: actions/setup-node@v3
with:
registry-url: 'https://registry.npmjs.org'
node-version: 18
node-version: 20
cache: 'npm'
- run: npm ci
- run: npm run lint
Expand Down
46 changes: 46 additions & 0 deletions packages/tools/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# w3filecoin Tools

> A set of tools to facilitate diagnosing and debugging incidents.

## Getting Started

Run in the main folder of this repo `npm install` to guarantee all the dependencies needed are properly installed.

To be able to run these tools, an AWS account with the AWS CLI MUST be configured locally and have access to the resources of w3filecoin.

## Tools

### Get aggregate deals

Get all known deals for a given aggregate.

```sh
$ npm run get-aggregate-deals bafkz...
> @w3filecoin/[email protected] get-aggregate-deals
> node get-aggregate-deals.js bafkz...

known information for aggregate bafkz...:
{
deals: {
'123': { provider: '111' },
'124': { provider: '222' }
}
}
```

### Get aggregates pending deals

```sh
$ npm run get-aggregates-pending-deals

> @w3filecoin/[email protected] get-aggregates-pending-deals
> node get-aggregates-pending-deals.js

Offered aggregates page size: 4

Aggregate offer list:
bafkzcibcaapg... at 2024-05-28T06:52:25.779Z
bafkzcibcaapn... at 2024-05-28T07:12:45.567Z
bafkzcibcaapb... at 2024-05-28T07:48:21.420Z
bafkzcibcaapi... at 2024-05-28T08:23:59.203Z
```
23 changes: 23 additions & 0 deletions packages/tools/get-aggregates-pending-deals.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { createClient as createAggregateStoreClient } from '@w3filecoin/core/src/store/dealer-aggregate-store.js'

const AWS_REGION = 'us-west-2'

const aggregateStore = createAggregateStoreClient({
region: AWS_REGION
}, {
tableName: 'prod-w3filecoin-dealer-aggregate-store'
})

// Get offered aggregates pending approval/rejection
const offeredAggregates = await aggregateStore.query({
status: 'offered',
})
if (offeredAggregates.error) {
throw offeredAggregates.error
}

console.log('Offered aggregates page size:', offeredAggregates.ok.length, '\n')
console.log('Aggregate offer list:')
for (const aggregate of offeredAggregates.ok) {
console.log(`${aggregate.aggregate.link()} at ${aggregate.insertedAt}`)
}
3 changes: 2 additions & 1 deletion packages/tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"version": "0.0.0",
"type": "module",
"scripts": {
"get-aggregate-deals": "node get-aggregate-deals.js"
"get-aggregate-deals": "node get-aggregate-deals.js",
"get-aggregates-pending-deals": "node get-aggregates-pending-deals.js"
},
"dependencies": {},
"devDependencies": {
Expand Down
Loading