Skip to content

Commit 94d4386

Browse files
authored
Merge pull request #18000 from MinaProtocol/dkijania/ci_for_archive_hardfork_toolbox
ci for archive hardfork toolbox app
2 parents e8e5f9e + bfb1ed0 commit 94d4386

File tree

5 files changed

+185
-0
lines changed

5 files changed

+185
-0
lines changed
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
let S = ../../Lib/SelectFiles.dhall
2+
3+
let Pipeline = ../../Pipeline/Dsl.dhall
4+
5+
let PipelineTag = ../../Pipeline/Tag.dhall
6+
7+
let JobSpec = ../../Pipeline/JobSpec.dhall
8+
9+
let Artifacts = ../../Constants/Artifacts.dhall
10+
11+
let Dockers = ../../Constants/DockerVersions.dhall
12+
13+
let BuildFlags = ../../Constants/BuildFlags.dhall
14+
15+
let Command = ../../Command/Base.dhall
16+
17+
let Size = ../../Command/Size.dhall
18+
19+
let RunWithPostgres = ../../Command/RunWithPostgres.dhall
20+
21+
let dependsOn =
22+
Dockers.dependsOn
23+
Dockers.DepsSpec::{
24+
, buildFlags = BuildFlags.Type.Instrumented
25+
, artifact = Artifacts.Type.FunctionalTestSuite
26+
}
27+
28+
let key = "archive-hardfork-toolbox-test"
29+
30+
in Pipeline.build
31+
Pipeline.Config::{
32+
, spec = JobSpec::{
33+
, dirtyWhen =
34+
[ S.strictlyStart (S.contains "src/app/archive_hardfork_toolbox")
35+
, S.exactly
36+
"buildkite/src/Jobs/Test/ArchiveHardforkToolboxTest"
37+
"dhall"
38+
, S.exactly
39+
"scripts/tests/archive-hardfork-toolbox/hf_archive"
40+
"tar.gz"
41+
, S.exactly "scripts/tests/archive-hardfork-toolbox/runner" "sh"
42+
]
43+
, path = "Test"
44+
, name = "ArchiveHardforkToolboxTest"
45+
, tags =
46+
[ PipelineTag.Type.Long
47+
, PipelineTag.Type.Test
48+
, PipelineTag.Type.Stable
49+
]
50+
}
51+
, steps =
52+
[ Command.build
53+
Command.Config::{
54+
, commands =
55+
[ RunWithPostgres.runInDockerWithPostgresConn
56+
([] : List Text)
57+
( RunWithPostgres.ScriptOrArchive.Archive
58+
{ Script = "post_upgrade_archive.sql"
59+
, Archive =
60+
"scripts/tests/archive-hardfork-toolbox/post_upgrade_archive.tar.gz"
61+
}
62+
)
63+
( Artifacts.fullDockerTag
64+
Artifacts.Tag::{
65+
, artifact = Artifacts.Type.FunctionalTestSuite
66+
, buildFlags = BuildFlags.Type.Instrumented
67+
}
68+
)
69+
( "scripts/tests/archive-hardfork-toolbox/runner.sh --mode pre-fork"
70+
++ " && scripts/tests/archive-hardfork-toolbox/runner.sh --mode upgrade"
71+
++ " && buildkite/scripts/upload-partial-coverage-data.sh ${key} "
72+
)
73+
, RunWithPostgres.runInDockerWithPostgresConn
74+
([] : List Text)
75+
( RunWithPostgres.ScriptOrArchive.Archive
76+
{ Script = "hf_archive.sql"
77+
, Archive =
78+
"scripts/tests/archive-hardfork-toolbox/hf_archive.tar.gz"
79+
}
80+
)
81+
( Artifacts.fullDockerTag
82+
Artifacts.Tag::{
83+
, artifact = Artifacts.Type.FunctionalTestSuite
84+
, buildFlags = BuildFlags.Type.Instrumented
85+
}
86+
)
87+
"scripts/tests/archive-hardfork-toolbox/runner.sh --mode post-fork && buildkite/scripts/upload-partial-coverage-data.sh ${key} "
88+
]
89+
, label = "Archive: Hardfork Toolbox Test"
90+
, key = key
91+
, target = Size.Large
92+
, depends_on = dependsOn
93+
}
94+
]
95+
}

changes/18000.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Introduce app for dealing with hardfork archive related operations like validating hard fork block etc.
597 KB
Binary file not shown.
Binary file not shown.
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#!/usr/bin/env bash
2+
3+
set -euox pipefail
4+
5+
# This script runs the archive hardfork toolbox tests.
6+
# It assumes that the archive hardfork toolbox has already been built.
7+
# It requires the archive database URI to be provided via --postgres-uri argument.
8+
9+
# Parse command line arguments
10+
POSTGRES_URI="${PG_CONN:-}"
11+
TOOLBOX_PATH="mina-archive-hardfork-toolbox"
12+
AVAILABLE_MODES=("pre-fork" "post-fork" "upgrade")
13+
MODE=""
14+
15+
while [[ $# -gt 0 ]]; do
16+
case $1 in
17+
--postgres-uri)
18+
POSTGRES_URI="$2"
19+
shift 2
20+
;;
21+
--toolbox-path)
22+
TOOLBOX_PATH="$2"
23+
shift 2
24+
;;
25+
--mode)
26+
MODE="$2"
27+
if [[ ! " ${AVAILABLE_MODES[*]} " =~ ${MODE} ]]; then
28+
echo "Invalid mode: $MODE"
29+
echo "Available modes are: ${AVAILABLE_MODES[*]}"
30+
exit 1
31+
fi
32+
shift 2
33+
;;
34+
*)
35+
echo "Unknown option: $1"
36+
echo "Usage: $0 --postgres-uri <database_uri> [--toolbox-path <path_to_binary>]"
37+
exit 1
38+
;;
39+
esac
40+
done
41+
42+
# Validate required arguments
43+
if [[ -z "$POSTGRES_URI" ]]; then
44+
echo "Error: --postgres-uri argument is required"
45+
echo "Usage: $0 --postgres-uri <database_uri> [--toolbox-path <path_to_binary>]"
46+
exit 1
47+
fi
48+
49+
echo "Using archive database URI: $POSTGRES_URI"
50+
echo "Using toolbox binary: $TOOLBOX_PATH"
51+
52+
# Run the archive hardfork toolbox tests
53+
echo "Running archive hardfork toolbox tests..."
54+
55+
# Define test parameters
56+
# Those values are hardcoded for the purpose of testing the toolbox.
57+
# They correspond sql scripts scripts/tests/archive-hardfork-toolbox/*.sql
58+
# Reason for using two databases is to simulate pre-fork and post-fork states independently.
59+
# This is required as for example pre-fork db cannot include transactions after stop slot.
60+
# Such check will fail if we try to run it on a single db including both pre and post fork data.
61+
62+
# Pre-fork test parameters
63+
64+
FORK_CANDIDATE_HEIGHT=297884
65+
FORK_CANDIDATE_GENESIS_SLOT=448610
66+
FORK_CANDIDATE_STATE_HASH="3NKJ8d6ncwhLGv3B28xCuTQfXxa3MyEShSWasVFYjtnm8sFZrhF6"
67+
LATEST_STATE_HASH="3NKX1QQ5bSjPwE5HLxLZ6dj2Abe9uk4tqWsjGisxittxLEd8rrLK"
68+
69+
# Post-fork test parameters
70+
# these values correspond to the fork defined in scripts/tests/archive-hardfork-toolbox/hf_archive.tar.gz
71+
# that data can be different from the pre-fork test data. They are independent tests.
72+
FORK_SLOT=1067
73+
FORK_STATE_HASH="3NK38gNjWR6sE2MTKV8AqogjY6WaboPjSDq3zfpfVtiUgLMze1Wm"
74+
75+
if [[ "$MODE" == "pre-fork" ]]; then
76+
"$TOOLBOX_PATH" fork-candidate is-in-best-chain --postgres-uri "$POSTGRES_URI" --fork-state-hash "$FORK_CANDIDATE_STATE_HASH" --fork-height "$FORK_CANDIDATE_HEIGHT" --fork-slot "$FORK_CANDIDATE_GENESIS_SLOT"
77+
78+
"$TOOLBOX_PATH" fork-candidate confirmations --postgres-uri "$POSTGRES_URI" --latest-state-hash "$LATEST_STATE_HASH" --fork-slot "$FORK_CANDIDATE_GENESIS_SLOT" --required-confirmations 1
79+
80+
"$TOOLBOX_PATH" fork-candidate no-commands-after --postgres-uri "$POSTGRES_URI" --fork-state-hash "$FORK_CANDIDATE_STATE_HASH" --fork-slot "$FORK_CANDIDATE_GENESIS_SLOT"
81+
fi
82+
83+
if [[ "$MODE" == "upgrade" ]]; then
84+
"$TOOLBOX_PATH" verify-upgrade --postgres-uri "$POSTGRES_URI" --version 4.0.0
85+
fi
86+
87+
if [[ "$MODE" == "post-fork" ]]; then
88+
"$TOOLBOX_PATH" validate-fork --postgres-uri "$POSTGRES_URI" --fork-slot "$FORK_SLOT" --fork-state-hash "$FORK_STATE_HASH"
89+
fi

0 commit comments

Comments
 (0)