Skip to content

Commit 132a08a

Browse files
committed
Merge remote-tracking branch 'origin/main' into rk/effect-logging
Signed-off-by: Roland Kuhn <rk@rkuhn.info>
2 parents 98898a8 + 2e6d5c1 commit 132a08a

183 files changed

Lines changed: 1702 additions & 512 deletions

File tree

Some content is hidden

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

.github/workflows/CI.yml

Lines changed: 42 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@ jobs:
6767
rustup toolchain add nightly-x86_64-unknown-linux-gnu
6868
rustup component add rust-src --toolchain nightly-x86_64-unknown-linux-gnu
6969
70-
- runner: ubuntu-latest
70+
- runner: ubuntu-24.04
7171
target: aarch64-unknown-linux-musl
7272
command: test
73-
setup: rustup target add aarch64-unknown-linux-musl
73+
setup: rustup target add aarch64-unknown-linux-musl && sudo apt-get install -y pkg-config libssl-dev
7474
cross-compile: true
7575

7676
timeout-minutes: 30
@@ -161,8 +161,11 @@ jobs:
161161
AMARU_PEER_ADDRESS: 127.0.0.1:3001
162162
strategy:
163163
matrix:
164-
network: [preprod]
164+
network:
165+
- name: preprod
166+
magic: 1
165167
cardano_node_version: [10.1.4]
168+
continue-on-error: true
166169
steps:
167170
- uses: actions/checkout@v4
168171

@@ -176,11 +179,11 @@ jobs:
176179
uses: actions/cache/restore@v4
177180
with:
178181
# The path should match the one used for the 'Nightly Sync' workflow.
179-
path: ${{ runner.temp }}/db-${{ matrix.network }}
182+
path: ${{ runner.temp }}/db-${{ matrix.network.name }}
180183
# The key should also match
181-
key: cardano-node-ogmios-${{ matrix.network }}
184+
key: cardano-node-ogmios-${{ matrix.network.name }}
182185
restore-keys: |
183-
cardano-node-ogmios-${{ matrix.network }}
186+
cardano-node-ogmios-${{ matrix.network.name }}
184187
185188
- name: Check if cardano-node-db is available
186189
if: steps.cache-cardano-node-db.outputs.cache-hit == ''
@@ -193,9 +196,9 @@ jobs:
193196
shell: bash
194197
run: |
195198
docker pull ghcr.io/intersectmbo/cardano-node:${{ matrix.cardano_node_version }}
196-
make HASKELL_NODE_CONFIG_DIR=cardano-node-config NETWORK=${{ matrix.network }} download-haskell-config
199+
make HASKELL_NODE_CONFIG_DIR=cardano-node-config NETWORK=${{ matrix.network.name }} download-haskell-config
197200
docker run -d --name cardano-node \
198-
-v ${{ runner.temp }}/db-${{ matrix.network }}:/db \
201+
-v ${{ runner.temp }}/db-${{ matrix.network.name }}:/db \
199202
-v ${{ runner.temp }}/ipc:/ipc \
200203
-v ./cardano-node-config:/config \
201204
-v ./cardano-node-config:/genesis \
@@ -217,11 +220,11 @@ jobs:
217220
run: |
218221
cargo test --no-run -p amaru
219222
220-
- name: Cache Amaru's ledger.db
223+
- name: Cache Amaru's ledger.${{ matrix.network.name }}.db
221224
id: cache-ledger-db
222225
uses: actions/cache/restore@v4
223226
with:
224-
path: ./ledger.db
227+
path: ./ledger.${{ matrix.network.name }}.db
225228
# If the ledger store serialisation format changes and become
226229
# incompatible, it is necessary to bump the index below to invalidate
227230
# the cached ledger snapshots, and recompute them from the CBOR ones
@@ -233,29 +236,51 @@ jobs:
233236
- name: Full bootstrap amaru
234237
if: steps.cache-ledger-db.outputs.cache-hit == ''
235238
run: |
236-
make BUILD_PROFILE=test bootstrap
239+
make BUILD_PROFILE=test NETWORK=${{ matrix.network.name }} bootstrap
237240
238241
- name: Light bootstrap amaru
239242
if: steps.cache-ledger-db.outputs.cache-hit != ''
240243
run: |
241-
make BUILD_PROFILE=test import-headers
242-
make BUILD_PROFILE=test import-nonces
244+
make BUILD_PROFILE=test NETWORK=${{ matrix.network.name }} import-headers
245+
make BUILD_PROFILE=test NETWORK=${{ matrix.network.name }} import-nonces
243246
244247
- uses: actions/cache/save@v4
245248
if: github.event_name == 'push' || steps.cache-ledger-db.outputs.cache-hit == ''
246249
with:
247-
path: ./ledger.db
250+
path: ./ledger.${{ matrix.network.name }}.db
248251
key: ${{ runner.OS }}-ledger-cache-v6-${{ steps.timestamp.outputs.value }}
249252

253+
- name: Install Cardano CLI
254+
if: github.event_name != 'pull_request'
255+
run: |
256+
set -eux
257+
258+
VERSION="10.11.0.0"
259+
260+
curl -L -o cardano-cli.tar.gz \
261+
"https://github.com/IntersectMBO/cardano-cli/releases/download/cardano-cli-${VERSION}/cardano-cli-${VERSION}-x86_64-linux.tar.gz"
262+
263+
mkdir -p cardano-cli-bin
264+
tar -xzf cardano-cli.tar.gz -C cardano-cli-bin
265+
mv cardano-cli-bin/cardano-cli* cardano-cli-bin/cardano-cli
266+
ls $PWD/cardano-cli-bin/
267+
chmod +x cardano-cli-bin/cardano-cli
268+
250269
- name: Run node
251270
timeout-minutes: 30
252271
shell: bash
253272
run: |
273+
set -eux
274+
275+
if [[ "${{ github.event_name }}" != "pull_request" ]]; then
276+
# If this is a push event, we want to test all revolut epochs
277+
export DEMO_TARGET_EPOCH=$(sudo $PWD/cardano-cli-bin/cardano-cli query tip --socket-path ${{ runner.temp }}/ipc/node.socket --testnet-magic ${{ matrix.network.magic }} | jq '.epoch - 1')
278+
fi
254279
make BUILD_PROFILE=test demo
255280
256281
- name: Run tests
257282
run: |
258-
make BUILD_PROFILE=test test-e2e
283+
make BUILD_PROFILE=test NETWORK=${{ matrix.network.name }} test-e2e
259284
260285
- name: Teardown haskell node
261286
shell: bash
@@ -266,8 +291,8 @@ jobs:
266291
- uses: actions/cache/save@v4
267292
if: github.event_name == 'push'
268293
with:
269-
path: ${{ runner.temp }}/db-${{ matrix.network }}
270-
key: cardano-node-ogmios-${{ matrix.network }}-${{ steps.timestamp.outputs.value }}
294+
path: ${{ runner.temp }}/db-${{ matrix.network.name }}
295+
key: cardano-node-ogmios-${{ matrix.network.name }}-${{ steps.timestamp.outputs.value }}
271296

272297
examples:
273298
name: Examples

.github/workflows/NightlySynchronization.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
sync_and_cache:
1616
strategy:
1717
matrix:
18-
network: [ preprod ]
18+
network: [ preprod, preview ]
1919
ogmios_version: [ v6.11.2 ]
2020
cardano_node_version: [ 10.1.4 ]
2121

@@ -50,4 +50,12 @@ jobs:
5050
shell: bash
5151
working-directory: ${{ runner.temp }}/db-${{ matrix.network }}
5252
run: |
53-
rm -f immutable/00*.chunk immutable/01*.chunk immutable/02*.chunk immutable/030*.chunk
53+
if [ "$NETWORK" == "preprod" ]; then
54+
rm -f immutable/00*.chunk immutable/01*.chunk immutable/02*.chunk immutable/030*.chunk
55+
fi
56+
57+
if [ "$NETWORK" == "preview" ]; then
58+
rm -f immutable/0*.chunk immutable/10*.chunk immutable/11*.chunk
59+
fi
60+
env:
61+
NETWORK: ${{ matrix.network }}

.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ target/
1414
*.pdb
1515

1616
# Default database location for the ledger
17-
/*ledger.db/
17+
/*ledger.*.db/
1818

1919
# Default database location for the consensus
20-
/*chain.db/
20+
/*chain.*.db/
2121

2222
# Insta not-yet reviewed snapshots
2323
*.snap.new
@@ -40,4 +40,4 @@ coverage/
4040
/cardano-node-config/
4141

4242
# llvm-cov generated file
43-
lcov.info
43+
lcov.info

Makefile

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ HASKELL_NODE_CONFIG_SOURCE := https://book.world.dev.cardano.org/environments
1111
COVERAGE_DIR ?= coverage
1212
COVERAGE_CRATES ?=
1313
LISTEN_ADDRESS ?= 0.0.0.0:0
14-
LEDGER_DIR ?= ./ledger.db
15-
CHAIN_DIR ?= ./chain.db
14+
LEDGER_DIR ?= ./ledger.$(NETWORK).db
15+
CHAIN_DIR ?= ./chain.$(NETWORK).db
1616
BUILD_PROFILE ?= release
1717

1818
.PHONY: help bootstrap run import-snapshots import-headers import-nonces download-haskell-config coverage-html coverage-lconv check-llvm-cov
@@ -25,60 +25,68 @@ help:
2525
@grep -E '^[a-zA-Z0-9_]+ \?= ' Makefile | sort | while read -r l; do printf " \033[36m$$(echo $$l | cut -f 1 -d'=')\033[00m=$$(echo $$l | cut -f 2- -d'=')\n"; done
2626

2727
snapshots/$(NETWORK): ## Download snapshots
28-
@mkdir -p $@
29-
@cat $(SNAPSHOTS_FILE) \
28+
@if [ ! -f "${SNAPSHOTS_FILE}" ]; then echo "SNAPSHOTS_FILE not found: ${SNAPSHOTS_FILE}"; exit 1; fi;
29+
mkdir -p $@
30+
cat $(SNAPSHOTS_FILE) \
3031
| jq -r '.[] | "\(.point) \(.url)"' \
3132
| while read p u; do \
3233
echo "Fetching $$p.cbor"; \
3334
curl --progress-bar -o - $$u | gunzip > $@/$$p.cbor; \
3435
done
3536

36-
download-haskell-config: ## Download Cardano Haskell configuration for $NETWORK
37-
mkdir -p $(HASKELL_NODE_CONFIG_DIR)
38-
curl -O --output-dir $(HASKELL_NODE_CONFIG_DIR) $(HASKELL_NODE_CONFIG_SOURCE)/$(NETWORK)/config.json
39-
curl -O --output-dir $(HASKELL_NODE_CONFIG_DIR) $(HASKELL_NODE_CONFIG_SOURCE)/$(NETWORK)/topology.json
40-
curl -O --output-dir $(HASKELL_NODE_CONFIG_DIR) $(HASKELL_NODE_CONFIG_SOURCE)/$(NETWORK)/byron-genesis.json
41-
curl -O --output-dir $(HASKELL_NODE_CONFIG_DIR) $(HASKELL_NODE_CONFIG_SOURCE)/$(NETWORK)/shelley-genesis.json
42-
curl -O --output-dir $(HASKELL_NODE_CONFIG_DIR) $(HASKELL_NODE_CONFIG_SOURCE)/$(NETWORK)/alonzo-genesis.json
43-
curl -O --output-dir $(HASKELL_NODE_CONFIG_DIR) $(HASKELL_NODE_CONFIG_SOURCE)/$(NETWORK)/conway-genesis.json
44-
4537
import-snapshots: snapshots/$(NETWORK) ## Import snapshots for demo
46-
@test -d $^ || (echo "Error: folder '$^' does not exist!" && exit 1)
47-
SNAPSHOT_ARGS=""; \
38+
@SNAPSHOT_ARGS=""; \
39+
CBOR_FILES=$$(find "$^" -maxdepth 1 -name '*.cbor'); \
40+
if [ -z "$$CBOR_FILES" ]; then echo "No .cbor files found in $^"; exit 1; fi; \
4841
for SNAPSHOT in $(wildcard $^/*.cbor); do \
4942
SNAPSHOT_ARGS="$$SNAPSHOT_ARGS --snapshot $$SNAPSHOT"; \
5043
done; \
5144
cargo run --profile $(BUILD_PROFILE) -- import-ledger-state \
45+
--network $(NETWORK) \
5246
--ledger-dir "$(LEDGER_DIR)" \
5347
$$SNAPSHOT_ARGS
5448

5549
import-headers: ## Import headers from $AMARU_PEER_ADDRESS for demo
56-
@HEADERS=$$(jq -r '.[]' $(HEADERS_FILE)); \
50+
@if [ ! -f "$(HEADERS_FILE)" ]; then echo "HEADERS_FILE not found: $(HEADERS_FILE)"; exit 1; fi; \
51+
HEADERS=$$(jq -r '.[]' $(HEADERS_FILE)); \
5752
for HEADER in $$HEADERS; do \
5853
cargo run --profile $(BUILD_PROFILE) -- import-headers \
54+
--network $(NETWORK) \
5955
--chain-dir $(CHAIN_DIR) \
6056
--peer-address $(AMARU_PEER_ADDRESS) \
6157
--starting-point $$HEADER \
6258
--count 2; \
6359
done
6460

6561
import-nonces: ## Import nonces for demo
62+
@if [ ! -f "$(NONCES_FILE)" ]; then echo "NONCES_FILE not found: $(NONCES_FILE)"; exit 1; fi; \
6663
cargo run --profile $(BUILD_PROFILE) -- import-nonces \
64+
--network $(NETWORK) \
6765
--chain-dir $(CHAIN_DIR) \
6866
--at $$(jq -r .at $(NONCES_FILE)) \
6967
--active $$(jq -r .active $(NONCES_FILE)) \
7068
--candidate $$(jq -r .candidate $(NONCES_FILE)) \
7169
--evolving $$(jq -r .evolving $(NONCES_FILE)) \
7270
--tail $$(jq -r .tail $(NONCES_FILE))
7371

72+
download-haskell-config: ## Download Cardano Haskell configuration for $NETWORK
73+
mkdir -p $(HASKELL_NODE_CONFIG_DIR)
74+
curl -O --output-dir $(HASKELL_NODE_CONFIG_DIR) $(HASKELL_NODE_CONFIG_SOURCE)/$(NETWORK)/config.json
75+
curl -O --output-dir $(HASKELL_NODE_CONFIG_DIR) $(HASKELL_NODE_CONFIG_SOURCE)/$(NETWORK)/topology.json
76+
curl -O --output-dir $(HASKELL_NODE_CONFIG_DIR) $(HASKELL_NODE_CONFIG_SOURCE)/$(NETWORK)/byron-genesis.json
77+
curl -O --output-dir $(HASKELL_NODE_CONFIG_DIR) $(HASKELL_NODE_CONFIG_SOURCE)/$(NETWORK)/shelley-genesis.json
78+
curl -O --output-dir $(HASKELL_NODE_CONFIG_DIR) $(HASKELL_NODE_CONFIG_SOURCE)/$(NETWORK)/alonzo-genesis.json
79+
curl -O --output-dir $(HASKELL_NODE_CONFIG_DIR) $(HASKELL_NODE_CONFIG_SOURCE)/$(NETWORK)/conway-genesis.json
80+
7481
clear-dbs: ## Clear the databases
7582
@rm -rf $(LEDGER_DIR) $(CHAIN_DIR)
7683

7784
bootstrap: clear-dbs ## Bootstrap the node from scratch
7885
cargo run --profile $(BUILD_PROFILE) -- bootstrap \
7986
--peer-address $(AMARU_PEER_ADDRESS) \
8087
--config-dir $(CONFIG_FOLDER) \
81-
--target-dir '.' \
88+
--ledger-dir $(LEDGER_DIR) \
89+
--chain-dir $(CHAIN_DIR) \
8290
--network $(NETWORK)
8391

8492
dev: ## Compile and run for development with default options
@@ -117,7 +125,7 @@ coverage-lconv: ## Run test coverage for CI to upload to Codecov
117125

118126
demo: ## Synchronize Amaru until a target epoch $DEMO_TARGET_EPOCH
119127
LEDGER_DIR=$(LEDGER_DIR) CHAIN_DIR=$(CHAIN_DIR) \
120-
./scripts/demo.sh $(BUILD_PROFILE) $(AMARU_PEER_ADDRESS) $(LISTEN_ADDRESS) $(DEMO_TARGET_EPOCH) $(NETWORK)
128+
./scripts/demo $(BUILD_PROFILE) $(AMARU_PEER_ADDRESS) $(LISTEN_ADDRESS) $(DEMO_TARGET_EPOCH) $(NETWORK)
121129

122130
build-examples: ## Build all examples
123131
@for dir in $(wildcard examples/*/.); do \

conformance-tests/.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
node_modules
22
yarn.lock
33
package-lock.json
4-
snapshots/*
5-
!snapshots/.gitkeep
4+
generated/*

conformance-tests/README.md

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,51 +2,30 @@
22

33
This folder contains scripts used to generate snapshots used for [conformance tests](../crates/amaru/tests/snapshots).
44

5-
## Pre-Requisites
5+
## Getting started
66

7-
### 3rd-party dependencies
8-
9-
- [Ogmios](https://github.com/CardanoSolutions/ogmios) >= `v6.13.0`
10-
- [cardano-node](https://github.com/IntersectMBO/cardano-node) >= `10.1.0`
11-
12-
### Node.js dependencies
13-
14-
Install necessary Node.js dependencies via:
7+
Install the required dependencies by running:
158

169
```console
1710
yarn
1811
```
1912

20-
## Configuration
21-
22-
Data will be fetched for each point listed in [`config.json`](./config.json). Typically, those points needs to be the _last point_ of target epochs. Currently, it contains points for the PreProd network.
23-
24-
## Fetching Data
25-
26-
The Haskell node only has a memory of up to few thousand blocks. So, in order to fetch states corresponding to historical data, fetching must be done while the cardano-node is synchronizing.
27-
28-
For the current configuration, that means removing all immutable chunks after `03149`, starting your node from there will have it synchronize through the required points. As soon as a point gets available, data will be fetched and the script will move on to the next point. Once your Haskell node is syncing and Ogmios up-and-running as well, quick run:
29-
30-
```console
31-
yarn fetch
32-
```
33-
34-
This should terminate once all the points have been processed.
13+
If you haven't done so, you will also need [the necessary `data`](../data). For an epoch `n`, you need data corresponding to `n`, `n+1` and `n+3` in order to generate the test snapshots. So make sure that you have fetched all the necessary informations beforehand.
3514

3615
## Generating snapshots
3716

3817
Once the data is available, it needs some post-processing to create proper JSON snapshots to be used as conformance tests. The post-processing ensures that data is properly formatted in a canonical way, and combine raw data fetched from the node in a more meaningful way.
3918

40-
Simply run:
19+
Simply run (replacing `NETWORK` with the target network):
4120

4221
```console
43-
yarn generate-all
22+
yarn generate-all NETWORK
4423
```
4524

4625
> [!TIP]
4726
>
4827
> You can also generate snapshots for a single epoch:
4928
>
5029
> ```console
51-
> yarn generate 168
30+
> yarn generate NETWORK 168
5231
> ```
Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
11
#!/usr/bin/env bash
22

3+
NETWORK=${1:-}
4+
5+
if [[ -z ${1:-} ]]; then
6+
echo -e "\033[91mMissing argument 'NETWORK'\033[0m" >&2
7+
exit 1
8+
fi
9+
310
scripts=$(dirname -- "${BASH_SOURCE[0]}")
411

5-
for e in $(seq 163 179); do
6-
node $scripts/generate.mjs $e &
12+
lo=$(ls $scripts/../../data/$NETWORK/pools | sort | head -n 1 | sed "s/.json//")
13+
hi=$(ls $scripts/../../data/$NETWORK/pools | sort | tail -n 1 | sed "s/.json//")
14+
hi=$(($hi - 3))
15+
16+
for EPOCH in $(seq $lo $hi); do
17+
node $scripts/generate.mjs $NETWORK $EPOCH &
718
done;
819

920
wait

0 commit comments

Comments
 (0)