Skip to content

Commit d912133

Browse files
[USER_OPS_INDEXER] EIP4337 user operations indexer & API server (blockscout#692)
* feat: initial demo * fix: initial review fixes * fix: filter parser * chore: refactor page token parsing * feat: remaining endpoints * chore: refactor * chore: more improvements * fix: sql error * feat: simplify migration * chore: best practices refactor * feat: simple retries * chore: rename to logic * chore: ci * feat: simple repo tests * chore: lint * fix: ci db service * feat: remaining repo tests * feat: tx handler basic test * feat: optional realtime indexer * fix: gas limit bug * fix: bytes json display * feat: custom migration table * fix: tests * feat: page size cfg * chore: adjust fields naming * chore: minor changes * chore: common db settings * chore: update env config * chore: update cfg * chore: fmt * chore: nit * feat: handle_tx db test * chore: sort imports * feat: status & fee in user ops list
1 parent 4cf2a60 commit d912133

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+12905
-0
lines changed
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
on:
2+
push:
3+
branches:
4+
- 'main'
5+
tags:
6+
- 'user-ops-indexer/v*'
7+
pull_request:
8+
paths:
9+
- user-ops-indexer/**
10+
- .github/workflows/user-ops-indexer.yml
11+
- .github/actions/deps/**
12+
13+
14+
name: Test, lint and docker (user-ops-indexer)
15+
16+
env:
17+
REGISTRY: ghcr.io
18+
IMAGE_NAME: blockscout/user-ops-indexer
19+
20+
defaults:
21+
run:
22+
working-directory: user-ops-indexer
23+
24+
jobs:
25+
test:
26+
name: Unit, doc and integration tests
27+
runs-on: ubuntu-latest
28+
services:
29+
postgres:
30+
image: postgres
31+
env:
32+
POSTGRES_PASSWORD: admin
33+
POSTGRES_USER: postgres
34+
options: >-
35+
--health-cmd pg_isready
36+
--health-interval 10s
37+
--health-timeout 5s
38+
--health-retries 5
39+
ports:
40+
- 5432:5432
41+
steps:
42+
- name: Checkout sources
43+
uses: actions/checkout@v2
44+
45+
- name: Install deps
46+
uses: ./.github/actions/deps
47+
48+
- name: Install toolchain
49+
uses: actions-rs/toolchain@v1
50+
with:
51+
toolchain: stable
52+
profile: minimal
53+
override: true
54+
55+
- name: Rust cache
56+
uses: Swatinem/rust-cache@v2
57+
with:
58+
cache-on-failure: true
59+
workspaces: user-ops-indexer -> target
60+
61+
- name: Unit tests
62+
run: RUST_BACKTRACE=1 RUST_LOG=info cargo test --locked --workspace --all-features --lib --bins -- --nocapture
63+
if: success() || failure()
64+
env:
65+
DATABASE_URL: postgres://postgres:admin@localhost:5432/
66+
67+
- name: Doc tests
68+
run: RUST_BACKTRACE=1 RUST_LOG=info cargo test --locked --workspace --all-features --doc -- --skip proto
69+
if: success() || failure()
70+
71+
# TODO: Uncomment when integration test added
72+
# - name: Integration tests
73+
# run: RUST_BACKTRACE=1 RUST_LOG=info cargo test --locked --workspace --test '*' -- --nocapture
74+
# if: success() || failure()
75+
76+
lint:
77+
name: Linting
78+
runs-on: ubuntu-latest
79+
steps:
80+
- name: Checkout sources
81+
uses: actions/checkout@v2
82+
83+
- name: Install deps
84+
uses: ./.github/actions/deps
85+
86+
- name: Install toolchain
87+
uses: actions-rs/toolchain@v1
88+
with:
89+
toolchain: stable
90+
profile: minimal
91+
components: rustfmt, clippy
92+
override: true
93+
94+
- uses: Swatinem/rust-cache@v2
95+
with:
96+
cache-on-failure: true
97+
workspaces: user-ops-indexer -> target
98+
99+
- name: cargo fmt
100+
run: cargo fmt --all -- --check --config imports_granularity=Crate
101+
102+
- name: cargo clippy
103+
run: cargo clippy --all --all-targets --all-features -- -D warnings
104+
105+
push:
106+
name: Docker build and docker push
107+
needs:
108+
- test
109+
- lint
110+
if: |
111+
always() &&
112+
(needs.test.result == 'success' || needs.test.result == 'cancelled') &&
113+
(needs.lint.result == 'success' || needs.lint.result == 'cancelled')
114+
timeout-minutes: 30
115+
runs-on: ubuntu-latest
116+
steps:
117+
- name: Checkout repository
118+
uses: actions/checkout@v2
119+
120+
- uses: actions-ecosystem/action-regex-match@v2
121+
id: regex
122+
with:
123+
text: ${{ github.ref }}
124+
regex: '^(refs\/tags\/user-ops-indexer\/(v\d+\.\d+\.\d+))|(refs\/heads\/(main))$'
125+
126+
- name: Extract tag name
127+
id: tags_extractor
128+
run: |
129+
t=${{ steps.regex.outputs.group2 }}
130+
m=${{ steps.regex.outputs.group4 }}
131+
(if ! [[ "$t" == "" ]]; then echo tags=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:$t, ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest; elif ! [[ "$m" == "" ]]; then echo tags=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:$m; else echo tags=; fi) >> $GITHUB_OUTPUT
132+
133+
- name: Login to GitHub Container Registry
134+
uses: docker/login-action@v1
135+
with:
136+
registry: ${{ env.REGISTRY }}
137+
username: ${{ github.actor }}
138+
password: ${{ secrets.GITHUB_TOKEN }}
139+
140+
- name: Extract metadata for Docker
141+
id: meta
142+
uses: docker/metadata-action@v3
143+
with:
144+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
145+
146+
- name: Set up Docker Buildx
147+
uses: docker/setup-buildx-action@v1
148+
- name: Build and push
149+
uses: docker/build-push-action@v2
150+
with:
151+
context: "user-ops-indexer"
152+
file: "user-ops-indexer/Dockerfile"
153+
push: ${{ steps.tags_extractor.outputs.tags != '' }}
154+
tags: ${{ steps.tags_extractor.outputs.tags }}
155+
labels: ${{ steps.meta.outputs.labels }}
156+
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:build-cache
157+
cache-to: ${{ github.ref == 'refs/heads/main' && format('type=registry,ref={0}/{1}:build-cache,mode=max', env.REGISTRY, env.IMAGE_NAME) || '' }}

user-ops-indexer/.dockerignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
target
2+
Dockerfile
3+
README.md
4+
tests
5+
config.toml

0 commit comments

Comments
 (0)