-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: snapshot tests during CI (#137)
* feat: make snapshot tests capable of running in parallel. This is the default behaviour when running 'cargo test', and it's been slightly annoying to have to run them one by one every time. Now, they happily all run at once by sharing and reusing connections to the on-disk snapshots. Signed-off-by: KtorZ <[email protected]> * feat: introduce a basic Makefile Signed-off-by: jeluard <[email protected]> * feat: make sure snapshot tests are executed during CI Signed-off-by: jeluard <[email protected]> * feat: use local cardano-node in CI snapshot tests. Signed-off-by: KtorZ <[email protected]> * chore: use actions/cache@v4, same as network sync workflow. Signed-off-by: KtorZ <[email protected]> * fix: make sure the cache path also match for re-use between workflows. Signed-off-by: KtorZ <[email protected]> * fix: fix cache-hit strategy for cardano-node-db. Interstingly enough, a 'cache-hit' value of 'false' does not indicate a miss. It indicates a hit on a restore key (and not a _direct_ hit). A miss is denoted by an empty string. :| Signed-off-by: KtorZ <[email protected]> * chore: use same host for Haskell cardano node container. Signed-off-by: KtorZ <[email protected]> * chore: build Amaru in a separate step Signed-off-by: KtorZ <[email protected]> * fix: add missing topology config file to Haskell's node configuration. Signed-off-by: KtorZ <[email protected]> * fix: wrong PID access Signed-off-by: jeluard <[email protected]> * fix: fix amaru e2e watch script Signed-off-by: KtorZ <[email protected]> * chore: update epoch used as stop gap Signed-off-by: jeluard <[email protected]> * test Signed-off-by: jeluard <[email protected]> * tmp: comment out build part to allow build to finish and cash to be pushed. Signed-off-by: KtorZ <[email protected]> * chore: only restore cardano-db cache, to save time and avoid weird cache conflict Signed-off-by: KtorZ <[email protected]> * tmp Signed-off-by: KtorZ <[email protected]> * fix: fix ledger db snapshots paths + add version key. Signed-off-by: KtorZ <[email protected]> * remove intermediate log lines. Signed-off-by: KtorZ <[email protected]> * send INT signal, not TERM, to ensure a clean stop. Signed-off-by: KtorZ <[email protected]> * . Signed-off-by: KtorZ <[email protected]> * fix: end sync right after snapshot exit. Signed-off-by: KtorZ <[email protected]> * split ledge cache restore/save Signed-off-by: KtorZ <[email protected]> * prune node db. Signed-off-by: KtorZ <[email protected]> --------- Signed-off-by: KtorZ <[email protected]> Signed-off-by: jeluard <[email protected]> Co-authored-by: KtorZ <[email protected]>
- Loading branch information
Showing
5 changed files
with
247 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,22 +24,25 @@ jobs: | |
|
||
- uses: actions/checkout@v4 | ||
|
||
- id: date-time | ||
shell: bash | ||
run: | | ||
echo "timestamp=$(/bin/date -u '+%Y%m%d-%H%M%S')" >> $GITHUB_OUTPUT | ||
- id: cache | ||
uses: actions/cache@v4 | ||
with: | ||
path: ${{ runner.temp }}/db-${{ matrix.network }} | ||
key: cardano-node-ogmios-${{ matrix.network }}-${{ steps.date-time.outputs.timestamp }} | ||
key: cardano-node-ogmios-${{ matrix.network }} | ||
restore-keys: | | ||
cardano-node-ogmios-${{ matrix.network }}- | ||
cardano-node-ogmios-${{ matrix.network }} | ||
- uses: CardanoSolutions/[email protected] | ||
with: | ||
db-dir: ${{ runner.temp }}/db-${{ matrix.network }} | ||
network: ${{ matrix.network }} | ||
version: ${{ matrix.ogmios_version }}_${{ matrix.cardano_node_version }} | ||
synchronization-level: ${{ inputs.synchronization-level || 1 }} | ||
|
||
# Remove old immutable chunks from the database, we don't need them and they make cache & on-disk system larger. | ||
- name: prune node db | ||
shell: bash | ||
working-directory: ${{ runner.temp }}/db-${{ matrix.network }} | ||
run: | | ||
touch clean | ||
rm immutable/00*.chunk immutable/01*.chunk immutable/02*.chunk immutable/030*.chunk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
NETWORK ?= preprod | ||
HASKELL_NODE_CONFIG_DIR ?= cardano-node-config | ||
HASKELL_NODE_CONFIG_SOURCE := https://book.world.dev.cardano.org/environments | ||
|
||
.PHONY: help bootstrap run import-snapshots import-headers import-nonces download-haskell-config | ||
all: help | ||
|
||
help: | ||
@echo "Build and publish playground components" | ||
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n \033[36m\033[0m\n"} /^[0-9a-zA-Z_-]+:.*?##/ { printf " \033[36m%-25s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) | ||
|
||
snapshots: ## Download snapshots | ||
mkdir -p $@ | ||
curl -s -o - "https://raw.githubusercontent.com/pragma-org/amaru/refs/heads/main/data/snapshots.json" \ | ||
| jq -r '.[] | "\(.point) \(.url)"' \ | ||
| while read p u; do \ | ||
echo "Fetching $$p.cbor"; \ | ||
curl --progress-bar -o - $$u | gunzip > $@/$$p.cbor; \ | ||
done | ||
|
||
download-haskell-config: ## Download Cardano Haskell configuration for ${NETWORK} | ||
mkdir -p $(HASKELL_NODE_CONFIG_DIR) | ||
curl -O --output-dir $(HASKELL_NODE_CONFIG_DIR) $(HASKELL_NODE_CONFIG_SOURCE)/$(NETWORK)/config.json | ||
curl -O --output-dir $(HASKELL_NODE_CONFIG_DIR) $(HASKELL_NODE_CONFIG_SOURCE)/$(NETWORK)/topology.json | ||
curl -O --output-dir $(HASKELL_NODE_CONFIG_DIR) $(HASKELL_NODE_CONFIG_SOURCE)/$(NETWORK)/byron-genesis.json | ||
curl -O --output-dir $(HASKELL_NODE_CONFIG_DIR) $(HASKELL_NODE_CONFIG_SOURCE)/$(NETWORK)/shelley-genesis.json | ||
curl -O --output-dir $(HASKELL_NODE_CONFIG_DIR) $(HASKELL_NODE_CONFIG_SOURCE)/$(NETWORK)/alonzo-genesis.json | ||
curl -O --output-dir $(HASKELL_NODE_CONFIG_DIR) $(HASKELL_NODE_CONFIG_SOURCE)/$(NETWORK)/conway-genesis.json | ||
|
||
import-snapshots: snapshots ## Import snapshots | ||
cargo run --release -- import-ledger-state \ | ||
--snapshot $^/69206375.6f99b5f3deaeae8dc43fce3db2f3cd36ad8ed174ca3400b5b1bed76fdf248912.cbor \ | ||
--snapshot $^/69638382.5da6ba37a4a07df015c4ea92c880e3600d7f098b97e73816f8df04bbb5fad3b7.cbor \ | ||
--snapshot $^/70070379.d6fe6439aed8bddc10eec22c1575bf0648e4a76125387d9e985e9a3f8342870d.cbor | ||
|
||
import-headers: enforce-peer-address ## Import headers from ${AMARU_PEER_ADDRESS} | ||
cargo run --release -- import-headers \ | ||
--peer-address ${AMARU_PEER_ADDRESS} \ | ||
--starting-point 69638365.4ec0f5a78431fdcc594eab7db91aff7dfd91c13cc93e9fbfe70cd15a86fadfb2 \ | ||
--count 2 | ||
cargo run --release -- import-headers \ | ||
--peer-address ${AMARU_PEER_ADDRESS} \ | ||
--starting-point 70070331.076218aa483344e34620d3277542ecc9e7b382ae2407a60e177bc3700548364c \ | ||
--count 2 | ||
|
||
import-nonces: ## Import nonces | ||
cargo run --release -- import-nonces \ | ||
--at 70070379.d6fe6439aed8bddc10eec22c1575bf0648e4a76125387d9e985e9a3f8342870d \ | ||
--active a7c4477e9fcfd519bf7dcba0d4ffe35a399125534bc8c60fa89ff6b50a060a7a \ | ||
--candidate 74fe03b10c4f52dd41105a16b5f6a11015ec890a001a5253db78a779fe43f6b6 \ | ||
--evolving 24bb737ee28652cd99ca41f1f7be568353b4103d769c6e1ddb531fc874dd6718 \ | ||
--tail 5da6ba37a4a07df015c4ea92c880e3600d7f098b97e73816f8df04bbb5fad3b7 | ||
|
||
bootstrap: import-headers import-nonces import-snapshots ## Bootstrap the node | ||
|
||
enforce-peer-address: | ||
@if [ -z ${AMARU_PEER_ADDRESS} ]; then \ | ||
echo "Error: AMARU_PEER_ADDRESS environment variable is not set."; \ | ||
exit 1; \ | ||
fi | ||
|
||
run: enforce-peer-address ## Run the node | ||
AMARU_TRACE="amaru=debug" cargo run --release -- --with-json-traces daemon --peer-address=${AMARU_PEER_ADDRESS} ${AMARU_RUN_EXTRA} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters