Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
chliddle committed Dec 10, 2024
2 parents d53d368 + b763c29 commit 37a7a1d
Show file tree
Hide file tree
Showing 91 changed files with 1,651 additions and 390 deletions.
60 changes: 43 additions & 17 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,43 @@ on:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
- "v[0-9]+.[0-9]+.[0-9]+-[a-z]+"
branches:
- "v?[0-9]+.[0-9]+.[0-9]+-rc"
- "v?[0-9]+.[0-9]+.[0-9]+-[a-z]+-rc"

permissions:
packages: write
pages: write
id-token: write
contents: read

jobs:
swagger-ui:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Generate Swagger UI
uses: Legion2/swagger-ui-action@v1
with:
output: swagger-ui
spec-file: swagger.yml
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
- name: Setup Pages
if: startsWith(github.ref, 'refs/tags/v')
uses: actions/configure-pages@v5
- name: Upload artifact
if: startsWith(github.ref, 'refs/tags/v')
uses: actions/upload-pages-artifact@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: swagger-ui
path: 'swagger-ui'
- name: Deploy to GitHub Pages
if: startsWith(github.ref, 'refs/tags/v')
id: deployment
uses: actions/deploy-pages@v4

docker:
name: Docker
Expand All @@ -34,14 +55,14 @@ jobs:
matrix:
docker:
[
{ image: namada-indexer-chain, context: chain },
{ image: namada-indexer-governance, context: governance },
{ image: namada-indexer-pos, context: pos },
{ image: namada-indexer-rewards, context: rewards },
{ image: namada-indexer-seeder, context: seeder },
{ image: namada-indexer-webserver, context: webserver },
{ image: namada-indexer-parameters, context: parameters },
{ image: namada-indexer-transactions, context: transactions },
{ image: chain, package: chain },
{ image: governance, package: governance },
{ image: pos, package: pos },
{ image: rewards, package: rewards },
{ image: seeder, package: seeder },
{ image: webserver, package: webserver },
{ image: parameters, package: parameters },
{ image: transactions, package: transactions },
]

steps:
Expand All @@ -62,8 +83,9 @@ jobs:
uses: docker/build-push-action@v6
with:
context: .
file: ${{ matrix.docker.context }}/Dockerfile
push: ${{ github.ref == 'refs/heads/main' }}
file: Dockerfile
build-args: PACKAGE=${{ matrix.docker.package }}
push: ${{ startsWith(github.ref, 'refs/tags/v') }}
tags: ${{ env.REGISTRY_URL }}/anoma/namada-indexer:${{ matrix.docker.image }}-${{ steps.get_version.outputs.version-without-v }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
Expand All @@ -72,19 +94,23 @@ jobs:
swagger-npm-package:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- id: get_version
uses: battila7/get-version-action@v2
- uses: actions/setup-node@v4
with:
node-version: 20
- name: Authenticate with private NPM package
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
- name: Generate openapi client configuration file
run: python3 .github/workflows/scripts/update-package.py ${{ steps.get_version.outputs.version-without-v }}
- name: Generate Typescript Client
uses: openapi-generators/openapitools-generator-action@v1
with:
generator: typescript-axios
openapi-file: swagger.yml
- name: Update package.json
run: python3 .github/workflows/scripts/update-package.py typescript-axios/package.json ${{ steps.get_version.outputs.version-without-v }}
command-args: -c swagger-codegen.json -o client
- name: Publish package
run: cd typescript-axios && npm publish --access public --verbose
if: startsWith(github.ref, 'refs/tags/v')
run: cd client && npm install && npm run build && npm publish --access public --verbose
17 changes: 7 additions & 10 deletions .github/workflows/scripts/update-package.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import json
import sys

package_json_path = sys.argv[1]
package_version = sys.argv[2]
package_version = sys.argv[1]

package_json = json.load(open(package_json_path))
configuration = {
"npmName": "@namada/indexer-client",
"npmVersion": package_version
}

package_json['name'] = "namada-indexer-client"
package_json['version'] = package_version
package_json['description'] = "Set of API to interact with a namada indexer."
package_json['license'] = "GPL-3.0 license"

with open(package_json_path, 'w', encoding='utf-8') as f:
json.dump(package_json, f, ensure_ascii=False, indent=4)
with open("swagger-codegen.json", 'w+', encoding='utf-8') as f:
json.dump(configuration, f, ensure_ascii=False, indent=4)
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,6 @@ rust-project.json

# End of https://www.toptal.com/developers/gitignore/api/osx,git,macos,rust-analyzer,rust

.vscode
.vscode

swagger-codegen.json
21 changes: 11 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ authors = ["Heliax <[email protected]>"]
edition = "2021"
license = "GPL-3.0"
readme = "README.md"
version = "0.1.0"
version = "1.0.0"

[workspace.dependencies]
clokwerk = "0.4.0"
Expand All @@ -29,7 +29,7 @@ tower-http = { version = "0.5.0", features = [
] }
tower-layer = "0.3.2"
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
tracing-subscriber = { version = "0.3", features = ["env-filter", "json"] }
serde = { version = "1.0.138", features = ["derive"] }
serde_json = "1.0"
clap = { version = "4.4.2", features = ["derive", "env"] }
Expand All @@ -40,14 +40,14 @@ axum-extra = { version = "0.9.3", features = ["query"] }
chrono = { version = "0.4.30", features = ["serde"] }
async-trait = "0.1.73"
anyhow = "1.0.75"
namada_core = { git = "https://github.com/anoma/namada", tag = "v0.46.0" }
namada_sdk = { git = "https://github.com/anoma/namada", tag = "v0.46.0", default-features = false, features = ["std", "async-send", "download-params"] }
namada_tx = { git = "https://github.com/anoma/namada", tag = "v0.46.0" }
namada_governance = { git = "https://github.com/anoma/namada", tag = "v0.46.0" }
namada_ibc = { git = "https://github.com/anoma/namada", tag = "v0.46.0" }
namada_token = { git = "https://github.com/anoma/namada", tag = "v0.46.0" }
namada_parameters = { git = "https://github.com/anoma/namada", tag = "v0.46.0" }
namada_proof_of_stake = { git = "https://github.com/anoma/namada", tag = "v0.46.0" }
namada_core = { git = "https://github.com/anoma/namada", branch = "fraccaman/rpc-pgf-payments" }
namada_sdk = { git = "https://github.com/anoma/namada", branch = "fraccaman/rpc-pgf-payments", default-features = false, features = ["std", "async-send", "download-params"] }
namada_tx = { git = "https://github.com/anoma/namada", branch = "fraccaman/rpc-pgf-payments" }
namada_governance = { git = "https://github.com/anoma/namada", branch = "fraccaman/rpc-pgf-payments" }
namada_ibc = { git = "https://github.com/anoma/namada", branch = "fraccaman/rpc-pgf-payments" }
namada_token = { git = "https://github.com/anoma/namada", branch = "fraccaman/rpc-pgf-payments" }
namada_parameters = { git = "https://github.com/anoma/namada", branch = "fraccaman/rpc-pgf-payments" }
namada_proof_of_stake = { git = "https://github.com/anoma/namada", branch = "fraccaman/rpc-pgf-payments" }
tendermint = "0.38.0"
tendermint-config = "0.38.0"
tendermint-rpc = { version = "0.38.0", features = ["http-client"] }
Expand Down Expand Up @@ -86,3 +86,4 @@ rand = "0.8.5"
bigdecimal = "0.4.5"
strum = "0.26.3"
strum_macros = "0.26.3"
sha256 = "1.5.0"
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ A set of microservices that crawler data from a namada node, store them in a pos

> 🔧 This is currently being worked on. Don't expect things to work! 🔧
# Namadillo integration

When using this project as a backend for [Namadillo](https://github.com/anoma/namada-interface), always checkout the latest tag, as the `main` branch could have an incompatible set of APIs.

## Architecture

The indexer is composed of a set microservices and a webserver, each one of these lives in his own crate. Each microservice is responsible of indexing some data from the chain and store them in the postgres database. Right now, there are 4 microservices:
Expand Down
3 changes: 1 addition & 2 deletions chain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ path = "src/main.rs"
[dependencies]
test_helpers.workspace = true
tokio.workspace = true
tokio-retry.workspace = true
tracing.workspace = true
tracing-subscriber.workspace = true
serde_json.workspace = true
chrono.workspace = true
clap.workspace = true
Expand All @@ -31,7 +31,6 @@ shared.workspace = true
deadpool-diesel.workspace = true
diesel.workspace = true
orm.workspace = true
clap-verbosity-flag.workspace = true
futures.workspace = true

[build-dependencies]
Expand Down
16 changes: 12 additions & 4 deletions chain/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use core::fmt;
use std::fmt::Display;

use clap_verbosity_flag::{InfoLevel, Verbosity};
use shared::log_config::LogConfig;

#[derive(clap::ValueEnum, Clone, Debug, Copy)]
pub enum CargoEnv {
Expand All @@ -23,9 +23,17 @@ pub struct AppConfig {
#[clap(long, env)]
pub database_url: String,

#[clap(long, env)]
#[clap(
long,
env,
default_value = "100",
help = "Time between retry attempts in milliseconds"
)]
pub initial_query_retry_time: u64,

#[command(flatten)]
pub verbosity: Verbosity<InfoLevel>,
#[clap(long, env, default_value = "5")]
pub initial_query_retry_attempts: usize,

#[clap(flatten)]
pub log: LogConfig,
}
Loading

0 comments on commit 37a7a1d

Please sign in to comment.