-
Notifications
You must be signed in to change notification settings - Fork 199
feat(scripts): include ribasushi-rpc-checks
#7477
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
base: main
Are you sure you want to change the base?
Changes from all commits
2087ba4
39db12b
170db74
23532b3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| name: rpc-checks | ||
|
|
||
| # docker compose up --build --abort-on-container-exit --exit-code-from rpc-checks | ||
|
|
||
| x-env: &env | ||
| CHAIN: ${CHAIN:-calibnet} | ||
| DAYS_AGO: ${DAYS_AGO:-2} | ||
| EPOCHS: ${EPOCHS:-1000} | ||
|
|
||
| services: | ||
| snapshot: | ||
| image: alpine:3.24 | ||
| environment: *env | ||
| volumes: | ||
| - ./snapshots:/snapshots | ||
| entrypoint: ["/bin/sh", "-euc"] | ||
| command: | ||
| - | | ||
| apk add --no-cache curl jq >/dev/null | ||
|
|
||
| # validates DAYS_AGO and EPOCHS | ||
| case "$$DAYS_AGO" in ''|*[!0-9]*) echo "DAYS_AGO must be a non-negative integer: '$$DAYS_AGO'"; exit 1;; esac | ||
| case "$$EPOCHS" in ''|*[!0-9]*) echo "EPOCHS must be a non-negative integer: '$$EPOCHS'"; exit 1;; esac | ||
| [ "$$EPOCHS" -ge 1 ] || { echo "EPOCHS must be at least 1"; exit 1; } | ||
|
|
||
| day=$$(date -u -d "@$$(( $$(date -u +%s) - DAYS_AGO * 86400 ))" +%F) | ||
| url=$$(curl -sSf --connect-timeout 10 --retry 3 \ | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unless a flag is obvious, e.g., |
||
| "https://forest-archive.chainsafe.dev/list/$$CHAIN/latest-v2?format=json" | | ||
| jq -r --arg d "$$day" '[.items[].url | select(contains("_"+$$d+"_"))] | first') | ||
| [ "$$url" != null ] || { echo "no $$CHAIN snapshot for $$day"; exit 1; } | ||
|
|
||
| file=$$(basename "$$url") | ||
| head=$$(echo "$$file" | sed 's/.*_height_\([0-9]*\)\..*/\1/') | ||
|
EclesioMeloJunior marked this conversation as resolved.
|
||
| case "$$head" in ''|*[!0-9]*) echo "could not parse a height from '$$file'"; exit 1;; esac | ||
| [ "$$EPOCHS" -le "$$head" ] || { echo "EPOCHS ($$EPOCHS) exceeds head ($$head)"; exit 1; } | ||
|
|
||
| # only downloads if the snapshot is not present | ||
| [ -f "/snapshots/$$file" ] || | ||
| curl -sSfL --connect-timeout 10 --retry 3 -o "/snapshots/$$file" "$$url" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| # define env vars used later on the next services | ||
| printf 'SNAPSHOT=%s\nSTART=%s\nEND=%s\nBACKFILL=%s\n' \ | ||
| "$$file" "$$((head - EPOCHS))" "$$((head - 1))" "$$((EPOCHS + 1))" > /snapshots/env | ||
| cat /snapshots/env | ||
|
|
||
| # The RPC port opens only after the backfill finishes, so "healthy" means ready. | ||
| forest: | ||
| image: ghcr.io/chainsafe/forest:latest | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Re-think your options. Hint: https://docs.forest.chainsafe.io/knowledge_base/docker_tips#tags |
||
| depends_on: | ||
| snapshot: | ||
| condition: service_completed_successfully | ||
| environment: *env | ||
| volumes: | ||
| - ./snapshots:/snapshots:ro | ||
| ports: | ||
| - "2345:2345" | ||
| entrypoint: ["/bin/sh", "-euc"] | ||
| command: | ||
| - | | ||
| . /snapshots/env | ||
| exec forest-tool api serve "/snapshots/$$SNAPSHOT" --chain "$$CHAIN" \ | ||
| --port 2345 --height 0 --index-backfill-epochs "$$BACKFILL" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why |
||
| healthcheck: | ||
| test: ["CMD", "forest-cli", "chain", "head"] | ||
| interval: 15s | ||
| timeout: 10s | ||
| retries: 480 | ||
|
Comment on lines
+63
to
+67
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So... potentially 20h for the probe to fail? |
||
|
|
||
| rpc-checks: | ||
| image: ghcr.io/chainsafe/forest-rpc-checks:latest | ||
| depends_on: | ||
| forest: | ||
| condition: service_healthy | ||
| environment: | ||
| FOREST_RPC_URL: forest:2345/rpc/v1 | ||
| volumes: | ||
| - ./snapshots:/snapshots:ro | ||
| entrypoint: ["/bin/sh", "-euc"] | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you just use the image directly? |
||
| command: | ||
| - | | ||
| . /snapshots/env | ||
| exec bundle exec ruby check_rpc.rb "$$START" "$$END" | ||
|
EclesioMeloJunior marked this conversation as resolved.
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pretty complex on its own - best to put it into a dedicated bash script so that shellcheck linter can nicely check it. It's also pretty obscure unreadable bash (not your fault, it's just bash) with regexes, so plenty of comments are needed to assert the logic is sound.