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

Prod Release #196

Merged
merged 31 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
c64e862
DPLT-1076 create node worker to process real time streams (#159)
morgsmccauley Aug 4, 2023
ca7aefd
DPLT-1084 Add support for Runner infrastructure (#166)
morgsmccauley Aug 7, 2023
6a113ed
DPLT-999 feat: fetch activeTab from localstorage to persist-tabs (#162)
roshaans Aug 7, 2023
93f892a
DEC-1373 flag button on posts/comments (#164)
roshaans Aug 7, 2023
759670e
DPLT-1083 Add Docker Compose file (#168)
morgsmccauley Aug 7, 2023
6218297
DPLT-1084 Add Hasura CLI config (#167)
morgsmccauley Aug 7, 2023
54ee547
DPLT-1129 Publish unprocessed stream messages count to Grafana (#169)
morgsmccauley Aug 8, 2023
98bc8bb
Revert "DPLT-1129 Publish unprocessed stream messages count to Grafan…
morgsmccauley Aug 8, 2023
1ec9d5e
DPLT-1129 Publish Runner metrics to Grafana (#170)
morgsmccauley Aug 8, 2023
8189a09
fix: Use correct PG env vars when adding hasura datasource (#172)
morgsmccauley Aug 9, 2023
dc69002
fix: Local development & add steps in `README.md` (#173)
morgsmccauley Aug 9, 2023
4172d9a
fix: Fetch cargo packages from registry in Docker build (#174)
morgsmccauley Aug 9, 2023
444fba3
ci: Add GitHub Action for Runner CI (#175)
morgsmccauley Aug 9, 2023
73f8786
feat: add replacement map feature (#176)
roshaans Aug 16, 2023
cfb7f46
chore: Remove unused transaction cache (#182)
morgsmccauley Aug 17, 2023
639064d
DPLT-1077 Process historical messages via Redis Streams (#181)
morgsmccauley Aug 17, 2023
10aae59
feat: Generate insert and select methods for context object under db …
darunrs Aug 22, 2023
077dccf
feat: add temp mint (#183)
morgsmccauley Aug 24, 2023
67164c4
mint nft url (#184)
morgsmccauley Aug 24, 2023
2e64d52
fix: Avoid writing misleading failed/skipped duration metrics (#187)
morgsmccauley Aug 29, 2023
e1d55a2
chore: Revert hackathon minting code (#186)
morgsmccauley Aug 29, 2023
6a26a8d
DPLT-1022 feat: store code in local storage (#180)
roshaans Aug 30, 2023
a138bfa
Add darunrs.near to whitelist (#185)
darunrs Aug 31, 2023
b58a0fc
fix: Improve Scope of Table Name Regex to Resolve Errors
darunrs Sep 6, 2023
f0c3a53
DPLT-1136: Implement update, upsert, and delete on context.db (#189)
darunrs Sep 7, 2023
4dbf605
DPLT-1118 Parallelize stream processing with worker threads (#191)
morgsmccauley Sep 19, 2023
0c92fe2
fix: Skip missing blocks in manual filtering (#195)
gabehamilton Sep 21, 2023
4682e05
DPLT-1121: Generate and Support Strongly Typed Objects for DB Methods…
darunrs Sep 27, 2023
b80842f
feat: Add `indexer_log_entries` indexes to `hasura` migrations (#238)
morgsmccauley Sep 27, 2023
bf0cbf5
Update issue templates
Ishatt Sep 28, 2023
7f6d3b6
Update issue templates
Ishatt Sep 28, 2023
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
38 changes: 38 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

**Additional context**
Add any other context about the problem here.
30 changes: 30 additions & 0 deletions .github/ISSUE_TEMPLATE/epic-template-.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
name: 'Epic Template '
about: 'Epics are milestones or groups of alike issues '
title: "\U0001F537 [Epic] New Epic "
labels: ''
assignees: ''

---

### Description
(Overview of milestone or function governed by this epic)
### Success Criteria
(Evaluate how this epic could be considered as complete and success)
### Resources
(Relevant documentation, Figma links, and other reference material)
Item 1
Item 2
Item 3
```[tasklist]
### Child Issues
[ ] https://github.com/near/github-project-test/issues/1
[ ] https://github.com/near/github-project-test/issues/2
[ ] https://github.com/near/github-project-test/issues/3
```
```[tasklist]
### dependencies/blocked
[ ] https://github.com/near/github-project-test/issues/1
[ ] https://github.com/near/github-project-test/issues/2
[ ] https://github.com/near/github-project-test/issues/3
```
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature-request-.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: 'Feature Request '
about: Suggest an idea for this project. If this doesn't look right
title: ''
labels: ''
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
23 changes: 23 additions & 0 deletions .github/ISSUE_TEMPLATE/secondary-focus-area-.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
name: 'Secondary Focus Area '
about: This issue serves to help us propose and organize support for impactful work,
as a secondary priority to epics & planned roadmap items. If this doesn't look right
title: "\U0001F525 [Secondary Focus Area] <Add a brief Title>"
labels: ''
assignees: ''

---

**Motivation**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.

**Open questions**
1 change: 1 addition & 0 deletions .github/workflows/deploy-dev-widgets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ jobs:
directory-paths: ${{vars.WIDGETS_DIRECTORY_PATHS}}
deploy-account-address: ${{ vars.DEV_SIGNER_ACCOUNT_ID }}
signer-public-key: ${{ vars.DEV_SIGNER_PUBLIC_KEY }}
environment: dev
secrets:
SIGNER_PRIVATE_KEY: ${{ secrets.DEV_SIGNER_PRIVATE_KEY }}
1 change: 1 addition & 0 deletions .github/workflows/deploy-prod-widgets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ jobs:
directory-paths: ${{vars.WIDGETS_DIRECTORY_PATHS}}
deploy-account-address: ${{ vars.PROD_SIGNER_ACCOUNT_ID }}
signer-public-key: ${{ vars.PROD_SIGNER_PUBLIC_KEY }}
environment: mainnet
secrets:
SIGNER_PRIVATE_KEY: ${{ secrets.PROD_SIGNER_PRIVATE_KEY }}
25 changes: 22 additions & 3 deletions .github/workflows/deploy-widgets.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Deploy Components to Mainnet
name: Deploy Components
on:
workflow_call:
inputs:
Expand All @@ -19,24 +19,43 @@ on:
required: true
description: "Comma-separated paths to the directories that contain the code to be deployed"
type: string
environment:
required: true
description: "mainnet or dev"
type: string
secrets:
SIGNER_PRIVATE_KEY:
description: "Private key in `ed25519:<private_key>` format for signing transaction"
required: true
jobs:
deploy-widgets:
runs-on: ubuntu-latest
name: Deploy widgets to social.near (mainnet)
name: Deploy widgets to social.near
env:
BOS_DEPLOY_ACCOUNT_ID: ${{ inputs.deploy-account-address }}
BOS_SIGNER_PUBLIC_KEY: ${{ inputs.signer-public-key }}
BOS_SIGNER_PRIVATE_KEY: ${{ secrets.SIGNER_PRIVATE_KEY }}
DIRECTORY_PATHS: ${{ inputs.directory-paths }}
ENVIRONMENT: ${{inputs.environment}}
BOS_SIGNER_PRIVATE_KEY: ${{ secrets.SIGNER_PRIVATE_KEY }}

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

- name: Set replacements
id: set_replacements
run: |
cd "frontend/widgets/"
echo "replacements=$(jq -r '[to_entries[] | .["find"] = "${" + .key + "}" | .["replace"] = .value | del(.key, .value)]' ../replacement.${ENVIRONMENT}.json | tr -d "\n\r")" >> $GITHUB_OUTPUT

- name: Replace placeholders
uses: flcdrg/replace-multiple-action@v1
with:
files: '**/*.jsx'
find: '${{ steps.set_replacements.outputs.replacements }}'
prefix: '(^|.*)'
suffix: '($|.*)'

- name: Install near-social CLI
run: |
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/FroVolod/bos-cli-rs/releases/download/v${{ inputs.cli-version }}/bos-cli-v${{ inputs.cli-version }}-installer.sh | sh
Expand Down
63 changes: 63 additions & 0 deletions .github/workflows/runner-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Runner CI

on:
pull_request:
paths:
- "runner/**"

jobs:
test:
runs-on: ubuntu-latest

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

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: '18.x'

- name: Install Node Dependencies
run: npm install
working-directory: ./runner

- name: Test
run: npm test
working-directory: ./runner
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: '18.x'

- name: Install Node Dependencies
run: npm install
working-directory: ./runner

- name: Lint
run: npm run lint
working-directory: ./runner
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: '18.x'

- name: Install Node Dependencies
run: npm install
working-directory: ./runner

- name: Build
run: npm run build
working-directory: ./runner
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
redis/
*.log
/indexer/blocks/
node_modules/
56 changes: 55 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ With QueryApi you can
* Specify the schema for your own custom hosted database and write to it with your indexer function;
* Retrieve that data through a GraphQL API.

# Table of Contents / Applications
## 🧩 Components
1. [QueryApi Coordinator](./indexer)
An Indexer that tracks changes to the QueryApi registry contract. It triggers the execution of those IndexerFunctions
when they match new blocks by placing messages on an SQS queue. Spawns historical processing threads when needed.
1.a. Subfolders provide crates for the different components of the Indexer: indexer_rule_type (shared with registry contract),
indexer_rules_engine, storage.
2. [Indexer Runner](.indexer-js-queue-handler)
Retrieves messages from the SQS queue, fetches the matching block and executes the IndexerFunction.
3. [Runner](.runner)
Retrieves messages from Redis Stream, fetching matching block and executes the IndexerFunction.
3. [IndexerFunction Editor UI](./frontend)
Serves the editor UI within the dashboard widget and mediates some communication with the GraphQL DB and block server.
4. [Hasura Authentication Service](./hasura-authentication-service)
Expand All @@ -21,3 +23,55 @@ indexer_rules_engine, storage.
Stores IndexerFunctions, their schemas and execution parameters like start block height.
6. [Lake Block server](./block-server)
Serves blocks from the S3 lake for in browser testing of IndexerFunctions.

## 🚀 Getting Started

The majority of the QueryApi components can be set up locally using Docker. For this purpose, a [Docker Compose file](./docker-compose.yml) has been provided. However, the local system still relies on the NEAR Mainnet, rather than running on a localnet.

### Requirements
- [Docker](https://docs.docker.com/engine/install/)
- [Docker Compose](https://docs.docker.com/compose/install/)
- [Hasura CLI](https://hasura.io/docs/latest/hasura-cli/install-hasura-cli/)
- AWS Access Keys

### AWS Credentials Setup
QueryApi requires AWS credentials to stream blocks from [NEAR Lake](https://github.com/near/near-lake-indexer). Credentials are exposed via the following environment variables, which can be found in the Docker Compose file:

Runner:
- `AWS_ACCESS_KEY_ID`
- `AWS_SECRET_ACCESS_KEY`

Coordinator:
- `LAKE_AWS_ACCESS_KEY`
- `LAKE_AWS_SECRET_ACCESS_KEY`
- `QUEUE_AWS_ACCESS_KEY`
- `QUEUE_AWS_SECRET_ACCESS_KEY`

These should be populated with your credentials. In most cases, the same key pair can be used for all 3 sets of credentials. Just ensure the keys have permissions to access S3 for handling [Requestor Pays](https://docs.aws.amazon.com/AmazonS3/latest/userguide/RequesterPaysBuckets.html) in Near Lake.

### Hasura Configuration
Hasura contains shared tables for e.g. logging and setting arbitrary state. These tables must be configured prior to running the entire QueryApi application. Configuration is stored in the `hasura/` directory and deployed through the Hasura CLI.

To configure Hasura, first start it with:
```sh
docker compose up hasura-graphql --detach
```

And apply the configuration with:
```sh
cd ./hasura && hasura deploy
```

### Running QueryApi
With everything configured correctly, we can now start all components of QueryApi with:
```sh
docker compose up
```

### Local Configuration
- Coordinator watches the dev registry contract by default (`dev-queryapi.dataplatform.near`). To use a different contract, you can update the `REGISTRY_CONTRACT_ID` environment variable.
- Coodinator will log SQS messages rather than sending them. To use an actual Queue, you can update the `QUEUE_URL` and `START_FROM_BLOCK_QUEUE_URL` environment variables.

### Known Issues

It is expected to see some provisioning errors from `Runner` when starting QueryAPI for the first time. These occur when multiple indexers under the same account attempt to provision the same shared infrastructure. These should self resolve after a few seconds.
Loading
Loading