Skip to content

Commit d88322e

Browse files
authored
Merge pull request #18027 from MinaProtocol/dkijania/fix_fork_pipeline
[HF] allow to build on more distros than focal. Allow to override precomp blocks bucket
2 parents ec7fb77 + 6ae70c2 commit d88322e

File tree

4 files changed

+110
-24
lines changed

4 files changed

+110
-24
lines changed

buildkite/scripts/entrypoints/run-hardfork-package-gen.sh

Lines changed: 63 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/bash
22

3+
set -euox pipefail
4+
35
# Generate Hardfork Package Build Script
46
#
57
# This script generates Dhall configuration for creating hardfork packages in the Mina protocol
@@ -10,11 +12,12 @@
1012
# ./run-hardfork-package-gen.sh
1113
#
1214
# REQUIRED ENVIRONMENT VARIABLES:
13-
# CODENAMES - Comma-separated list of Debian codenames (e.g., "Bullseye,Focal")
14-
# NETWORK - Target network name (e.g., "Devnet", "Mainnet")
15-
# GENESIS_TIMESTAMP - Genesis timestamp in ISO format (e.g., "2024-04-07T11:45:00Z")
16-
# CONFIG_JSON_GZ_URL - URL to the gzipped genesis config JSON file
17-
# VERSION - Version string for the hardfork package
15+
# CODENAMES - Comma-separated list of Debian codenames (e.g., "Bullseye,Focal")
16+
# NETWORK - Target network name (e.g., "Devnet", "Mainnet")
17+
# GENESIS_TIMESTAMP - Genesis timestamp in ISO format (e.g., "2024-04-07T11:45:00Z")
18+
# CONFIG_JSON_GZ_URL - URL to the gzipped genesis config JSON file
19+
# VERSION - Version string for the hardfork package (optional, if not set, defaults to calculated from git)
20+
# PRECOMPUTED_FORK_BLOCK_PREFIX - (Optional) Prefix for precomputed fork block URLs (e.g., "gs://mina_network_block_data/mainnet")
1821
#
1922
# EXAMPLE:
2023
# export CODENAMES="Bullseye,Focal"
@@ -42,20 +45,21 @@ function usage() {
4245
echo -e "${RED}$1${CLEAR}\n";
4346
fi
4447
cat << EOF
45-
CODENAMES The Debian codenames (Bullseye, Focal etc.)
46-
NETWORK The Docker and Debian network (Devnet, Mainnet)
47-
GENESIS_TIMESTAMP The Genesis timestamp in ISO format (e.g. 2024-04-07T11:45:00Z)
48-
CONFIG_JSON_GZ_URL The URL to the gzipped genesis config JSON file
49-
VERSION The version of the hardfork package to generate (e.g. 3.0.0devnet-tooling-dkijania-hardfork-package-gen-in-nightly-b37f50e)
50-
48+
CODENAMES The Debian codenames (Bullseye, Focal etc.)
49+
NETWORK The Docker and Debian network (Devnet, Mainnet)
50+
GENESIS_TIMESTAMP The Genesis timestamp in ISO format (e.g. 2024-04-07T11:45:00Z)
51+
CONFIG_JSON_GZ_URL The URL to the gzipped genesis config JSON file
52+
VERSION (Optional) The version of the hardfork package to generate (e.g. 3.0.0devnet-tooling-dkijania-hardfork-package-gen-in-nightly-b37f50e)
53+
PRECOMPUTED_FORK_BLOCK_PREFIX (Optional) The prefix for precomputed fork block URLs (e.g. gs://mina_network_block_data/mainnet)
5154
EOF
5255
exit 1
5356
}
5457

5558
function to_dhall_list() {
5659
local input_str="$1"
5760
local dhall_type="$2"
58-
local arr=("${input_str//,/ }")
61+
local arr
62+
IFS=',' read -ra arr <<< "$input_str"
5963
local dhall_list=""
6064

6165
if [[ ${#arr[@]} -eq 0 || -z "${arr[0]}" ]]; then
@@ -72,6 +76,52 @@ function to_dhall_list() {
7276
echo "$dhall_list"
7377
}
7478

79+
if [[ -z "$CODENAMES" ]]; then
80+
usage "CODENAMES environment variable is required"
81+
fi
82+
83+
if [[ -z "$NETWORK" ]]; then
84+
usage "NETWORK environment variable is required"
85+
fi
86+
87+
if [[ -z "$CONFIG_JSON_GZ_URL" ]]; then
88+
usage "CONFIG_JSON_GZ_URL environment variable is required"
89+
fi
90+
91+
# Format GENESIS_TIMESTAMP as Optional Text for Dhall
92+
if [[ -z "$GENESIS_TIMESTAMP" ]]; then
93+
GENESIS_TIMESTAMP="None Text"
94+
else
95+
# shellcheck disable=SC2089
96+
GENESIS_TIMESTAMP="(Some \"${GENESIS_TIMESTAMP}\")"
97+
fi
98+
99+
# Format VERSION as Optional Text for Dhall
100+
if [[ -z "$VERSION" ]]; then
101+
VERSION="(None Text)"
102+
else
103+
# shellcheck disable=SC2089
104+
VERSION="(Some \"${VERSION}\")"
105+
fi
106+
107+
# Format PRECOMPUTED_FORK_BLOCK_PREFIX as Optional Text for Dhall
108+
if [[ -z "$PRECOMPUTED_FORK_BLOCK_PREFIX" ]]; then
109+
PRECOMPUTED_FORK_BLOCK_PREFIX="(None Text)"
110+
else
111+
# shellcheck disable=SC2089
112+
PRECOMPUTED_FORK_BLOCK_PREFIX="(Some \"${PRECOMPUTED_FORK_BLOCK_PREFIX}\")"
113+
fi
114+
75115
DHALL_CODENAMES=$(to_dhall_list "$CODENAMES" "$DEBIAN_VERSION_DHALL_DEF.DebVersion")
76116

77-
echo $GENERATE_HARDFORK_PACKAGE_DHALL_DEF'.generate_hardfork_package '"$DHALL_CODENAMES"' '$NETWORK_DHALL_DEF'.Type.'"${NETWORK}"' (None Text) "'"${CONFIG_JSON_GZ_URL}"'" "'""'" ' | dhall-to-yaml --quoted
117+
# shellcheck disable=SC2089
118+
printf '%s.generate_hardfork_package %s %s.Type.%s %s "%s" "%s" %s %s\n' \
119+
"$GENERATE_HARDFORK_PACKAGE_DHALL_DEF" \
120+
"$DHALL_CODENAMES" \
121+
"$NETWORK_DHALL_DEF" \
122+
"$NETWORK" \
123+
"$GENESIS_TIMESTAMP" \
124+
"$CONFIG_JSON_GZ_URL" \
125+
"" \
126+
"$VERSION" \
127+
"$PRECOMPUTED_FORK_BLOCK_PREFIX" | dhall-to-yaml --quoted

buildkite/src/Constants/Network.dhall

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ let List/any = Prelude.List.any
44

55
let Network
66
: Type
7-
= < Devnet | Mainnet | Berkeley | DevnetLegacy | MainnetLegacy >
7+
= < Devnet | Mainnet | Berkeley | DevnetLegacy | MainnetLegacy | PreMesa1 >
88

99
let capitalName =
1010
\(network : Network)
@@ -14,6 +14,7 @@ let capitalName =
1414
, Berkeley = "Berkeley"
1515
, DevnetLegacy = "DevnetLegacy"
1616
, MainnetLegacy = "MainnetLegacy"
17+
, PreMesa1 = "PreMesa1"
1718
}
1819
network
1920

@@ -25,6 +26,7 @@ let lowerName =
2526
, Berkeley = "berkeley"
2627
, DevnetLegacy = "devnet_legacy"
2728
, MainnetLegacy = "mainnet_legacy"
29+
, PreMesa1 = "hetzner-pre-mesa-1"
2830
}
2931
network
3032

@@ -36,6 +38,7 @@ let requiresMainnetBuild =
3638
, Berkeley = False
3739
, DevnetLegacy = True
3840
, MainnetLegacy = True
41+
, PreMesa1 = False
3942
}
4043
network
4144

buildkite/src/Constants/Profiles.dhall

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ let fromNetwork =
4242
, Berkeley = Profile.Devnet
4343
, DevnetLegacy = Profile.Devnet
4444
, MainnetLegacy = Profile.Mainnet
45+
, PreMesa1 = Profile.Devnet
4546
}
4647
network
4748

buildkite/src/Entrypoints/GenerateHardforkPackage.dhall

Lines changed: 42 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
-- Autogenerates any pre-reqs for monorepo triage execution
22
-- Keep these rules lean! They have to run unconditionally.
33

4+
5+
let Prelude = ../External/Prelude.dhall
6+
7+
let List/concatMap = Prelude.List.concatMap
8+
49
let SelectFiles = ../Lib/SelectFiles.dhall
510

611
let Cmd = ../Lib/Cmds.dhall
@@ -37,6 +42,7 @@ let Spec =
3742
, config_json_gz_url : Text
3843
, version : Text
3944
, suffix : Text
45+
, precomputed_block_prefix : Optional Text
4046
}
4147
, default =
4248
{ codenames = [ DebianVersions.DebVersion.Bullseye ]
@@ -45,6 +51,8 @@ let Spec =
4551
, config_json_gz_url =
4652
"https://storage.googleapis.com/o1labs-gitops-infrastructure/devnet/devnet-state-dump-3NK4eDgbkCjKj9fFUXVkrJXsfpfXzJySoAvrFJVCropPW7LLF14F-676026c4d4d2c18a76b357d6422a06f932c3ef4667a8fd88717f68b53fd6b2d7.json.gz"
4753
, suffix = ""
54+
, version = "\\\$MINA_DEB_VERSION"
55+
, precomputed_block_prefix = None Text
4856
}
4957
}
5058

@@ -55,8 +63,6 @@ let generateDockerForCodename =
5563
-> let image =
5664
Artifacts.fullDockerTag
5765
Artifacts.Tag::{
58-
, version =
59-
"${spec.version}-${DebianVersions.lowerName codename}"
6066
, remove_profile_from_name = True
6167
, network = spec.network
6268
}
@@ -76,13 +82,24 @@ let generateDockerForCodename =
7682
, deb_profile = profile
7783
, deb_repo = DebianRepo.Type.Local
7884
, deb_suffix = Some "hardfork"
85+
, step_key_suffix =
86+
"-${DebianVersions.lowerName codename}-docker-image"
7987
}
8088

8189
let dockerDaemonStep = DockerImage.stepKey dockerDaemonSpec
8290

8391
let dependsOnTest =
8492
[ { name = pipelineName, key = dockerDaemonStep } ]
8593

94+
let precomputed_block_prefix_arg =
95+
merge
96+
{ Some =
97+
\(prefix : Text)
98+
-> "--precomputed-block-prefix " ++ prefix
99+
, None = ""
100+
}
101+
spec.precomputed_block_prefix
102+
86103
in [ MinaArtifact.buildArtifacts
87104
MinaArtifact.MinaBuildSpec::{
88105
, artifacts =
@@ -118,6 +135,8 @@ let generateDockerForCodename =
118135
, deb_codename = codename
119136
, deb_profile = profile
120137
, deb_repo = DebianRepo.Type.Local
138+
, step_key_suffix =
139+
"-${DebianVersions.lowerName codename}-docker-image"
121140
}
122141
, DockerImage.generateStep
123142
DockerImage.ReleaseSpec::{
@@ -133,6 +152,8 @@ let generateDockerForCodename =
133152
, deb_repo = DebianRepo.Type.Local
134153
, deb_codename = codename
135154
, deb_suffix = Some "hardfork"
155+
, step_key_suffix =
156+
"-${DebianVersions.lowerName codename}-docker-image"
136157
}
137158
, Command.build
138159
Command.Config::{
@@ -161,11 +182,13 @@ let generateDockerForCodename =
161182
codename} && source ./buildkite/scripts/export-git-env-vars.sh"
162183
, Cmd.runInDocker
163184
Cmd.Docker::{ image = image }
164-
"curl ${spec.config_json_gz_url} > config.json.gz && gunzip config.json.gz && FORKING_FROM_CONFIG_JSON=config.json mina-verify-packaged-fork-config ${Network.lowerName
165-
spec.network} config.json /workdir/verification"
185+
"curl ${spec.config_json_gz_url} > config.json.gz && gunzip config.json.gz && FORKING_FROM_CONFIG_JSON=config.json mina-verify-packaged-fork-config --network ${Network.lowerName
186+
spec.network} --fork-config config.json --working-dir /workdir/verification ${precomputed_block_prefix_arg}"
166187
]
167188
, label = "Verify packaged artifacts"
168-
, key = "verify-packaged-artifacts"
189+
, key =
190+
"verify-packaged-artifacts-${DebianVersions.lowerName
191+
codename}"
169192
, target = Size.XLarge
170193
, depends_on = dependsOnTest
171194
}
@@ -188,10 +211,13 @@ let pipeline =
188211
]
189212
}
190213
, steps =
191-
generateDockerForCodename
192-
spec
193-
DebianVersions.DebVersion.Focal
194-
pipelineName
214+
List/concatMap
215+
DebianVersions.DebVersion
216+
Command.Type
217+
( \(codename : DebianVersions.DebVersion)
218+
-> generateDockerForCodename spec codename pipelineName
219+
)
220+
spec.codenames
195221
}
196222

197223
let generate_hardfork_package =
@@ -200,14 +226,20 @@ let generate_hardfork_package =
200226
-> \(genesis_timestamp : Optional Text)
201227
-> \(config_json_gz_url : Text)
202228
-> \(suffix : Text)
229+
-> \(version : Optional Text)
230+
-> \(precomputed_block_prefix : Optional Text)
203231
-> ( pipeline
204232
Spec::{
205233
, codenames = codenames
206234
, network = network
207-
, version = "\\\$MINA_DEB_VERSION"
235+
, version =
236+
merge
237+
{ Some = \(v : Text) -> v, None = "\\\$MINA_DEB_VERSION" }
238+
version
208239
, genesis_timestamp = genesis_timestamp
209240
, config_json_gz_url = config_json_gz_url
210241
, suffix = suffix
242+
, precomputed_block_prefix = precomputed_block_prefix
211243
}
212244
).pipeline
213245

0 commit comments

Comments
 (0)