Skip to content

Commit 234425b

Browse files
authored
Merge pull request #1252 from o1-labs/dw/scripts-to-update-ocaml-node
Scripts to update OCaml node
2 parents 62238de + 5d13598 commit 234425b

File tree

4 files changed

+121
-40
lines changed

4 files changed

+121
-40
lines changed

.github/workflows/test-docs-scripts.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,3 +172,41 @@ jobs:
172172
# Docker Desktop needs to be started manually on macOS
173173
# We'll just check if it was installed via Homebrew
174174
docker --version || echo "Docker installed but not running (expected on macOS CI)"
175+
176+
test-update-ocaml-node-script:
177+
name: Test Update OCaml Node Script
178+
runs-on: [macos-latest, ubuntu-latest]
179+
180+
- name: Test update-ocaml-node script reproducibility
181+
run: |
182+
# Save the current script to use with the old commit state
183+
cp ./website/docs/developers/scripts/update-ocaml-node.sh /tmp/update-ocaml-node.sh
184+
chmod +x /tmp/update-ocaml-node.sh
185+
186+
# Check out the parent commit of the example update (cf67d94c)
187+
git checkout cf67d94c
188+
189+
# Run the script from current branch with the same parameters as the example
190+
/tmp/update-ocaml-node.sh 7f94ae0b 978866cd "3.2.0-alpha1" "3.2.0-beta1"
191+
192+
# Check if the changes match the expected diff from commit 31caeee6
193+
git diff --name-only | sort > actual_files.txt
194+
echo ".github/workflows/ci.yaml" > expected_files.txt
195+
echo "docker-compose.archive.devnet.compare.yml" >> expected_files.txt
196+
echo "node/testing/src/node/ocaml/config.rs" >> expected_files.txt
197+
echo "node/testing/src/node/ocaml/mod.rs" >> expected_files.txt
198+
echo "node/testing/src/scenarios/multi_node/basic_connectivity_peer_discovery.rs" >> expected_files.txt
199+
echo "node/testing/src/scenarios/solo_node/basic_connectivity_accept_incoming.rs" >> expected_files.txt
200+
sort expected_files.txt > expected_files_sorted.txt
201+
202+
# Verify the same files were modified
203+
if ! diff -q actual_files.txt expected_files_sorted.txt; then
204+
echo "ERROR: Script modified different files than expected"
205+
echo "Expected files:"
206+
cat expected_files_sorted.txt
207+
echo "Actual files:"
208+
cat actual_files.txt
209+
exit 1
210+
fi
211+
212+
echo "SUCCESS: Script produced the expected file changes"

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2020

2121
- **Documentation**: Add instructions to update the OCaml node dependencies.
2222
([#1237](https://github.com/o1-labs/openmina/pull/1237))
23+
- **Development Tools**: Automation script for updating OCaml node references
24+
with comprehensive documentation and CI testing to ensure reproducibility
25+
([#1252](https://github.com/o1-labs/openmina/pull/1252))
2326
- **Documentation**: Complete Docusaurus-based documentation website with
2427
comprehensive guides for node runners, developers, and researchers
2528
([#1234](https://github.com/o1-labs/openmina/pull/1234)). It migrates all the
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/bash
2+
3+
set -eou pipefail
4+
5+
# Checkout to the root directory of the project
6+
# We suppose this script is run from a copy of the git repository.
7+
base_dir="$(git rev-parse --show-toplevel)"
8+
9+
if [ "$#" -ne 4 ]; then
10+
echo "Error: Missing arguments."
11+
echo "Usage: $0 <old_hash> <new_hash> <old_version> <new_version>"
12+
exit 1
13+
fi
14+
15+
old_hash=$1
16+
new_hash=$2
17+
old_version=$3
18+
new_version=$4
19+
20+
length_old_hash=${#old_hash}
21+
length_new_hash=${#new_hash}
22+
23+
if [ "$length_old_hash" -ne 8 ] || [ "$length_new_hash" -ne 8 ]; then
24+
echo "Error: Hashes must be exactly 8 characters long."
25+
echo "Old hash: $old_hash, New hash: $new_hash"
26+
echo "The correct hashes can be found on the GitHub release page of MinaProtocol/Mina."
27+
exit 1
28+
fi
29+
30+
# The docker images are named with only 7 characters of the hash.
31+
shorter_old_hash=${old_hash:0:7}
32+
shorter_new_hash=${new_hash:0:7}
33+
34+
echo "Updating config_${old_hash} to config_${new_hash}"
35+
sed -i'' -e "s/config_${old_hash}/config_${new_hash}/g" \
36+
"${base_dir}"/node/testing/src/node/ocaml/config.rs \
37+
"${base_dir}"/node/testing/src/node/ocaml/mod.rs \
38+
"${base_dir}"/node/testing/src/scenarios/multi_node/basic_connectivity_peer_discovery.rs \
39+
"${base_dir}"/node/testing/src/scenarios/solo_node/basic_connectivity_accept_incoming.rs
40+
sed -i'' -e "s/${old_version}-${shorter_old_hash}/${new_version}-${shorter_new_hash}/g" \
41+
"${base_dir}"/.github/workflows/ci.yaml \
42+
"${base_dir}"/docker-compose.archive.devnet.compare.yml \
43+
"${base_dir}"/node/testing/src/node/ocaml/config.rs

website/docs/developers/updating-ocaml-node.md

Lines changed: 37 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -18,58 +18,53 @@ Visit the
1818
find the latest release version and associated container image tags.
1919

2020
For example, release `3.2.0-alpha1` provides updated container images and
21-
configuration files.
21+
configuration files. You'll need:
2222

23-
## 2. Update GCR Links in Code
23+
- The new version number (e.g., `3.2.0-alpha1`)
24+
- The 8-character configuration hash from the release page
2425

25-
Use `git grep` to find all Google Container Registry (GCR) references that need
26-
updating:
26+
## 2. Automated Update with Script
2727

28-
```bash
29-
# Search for GCR image references
30-
git grep "gcr.io/o1labs-192920/mina-daemon"
28+
OpenMina provides an automation script to handle the bulk of the update process:
3129

32-
# Search for any mina-daemon references
33-
git grep "mina-daemon"
30+
```bash
31+
./website/docs/developers/scripts/update-ocaml-node.sh <old_hash> <new_hash> <old_version> <new_version>
3432
```
3533

36-
Update the image tags in the found files to match the new release version.
37-
Typically this involves changing version strings in Docker Compose files,
38-
testing configurations, and CI workflows.
34+
**Example usage:**
3935

40-
## 3. Update Configuration Files
36+
For example, to update from `3.2.0-alpha1` to `3.2.0-beta1` (as done in commit
37+
[31caeee6](https://github.com/o1-labs/openmina/commit/31caeee6af7bf20b8578a23bf69718dbe68fe5cc)):
4138

42-
Update the configuration file hash to match the new release. The config files
43-
with the pattern `config_[8-character-hash]` come from the OCaml node release
44-
and need to be referenced in the OpenMina codebase.
45-
46-
The configuration hash corresponds to the genesis state and network parameters
47-
for the specific release. You may need to:
39+
```bash
40+
./website/docs/developers/scripts/update-ocaml-node.sh 7f94ae0b 978866cd "3.2.0-alpha1" "3.2.0-beta1"
41+
```
4842

49-
- Update references to the config filename in code to match the new hash
50-
- Download or reference the new config files from the OCaml node release
51-
- Verify the new configuration is compatible with OpenMina
43+
**Parameters:**
5244

53-
## 4. Example Workflow
45+
- `old_hash`: Current 8-character config hash
46+
- `new_hash`: New 8-character config hash from the release
47+
- `old_version`: Current version (e.g., `3.1.0`)
48+
- `new_version`: New version (e.g., `3.2.0-alpha1`)
5449

55-
Based on PR #1236, a typical update involves:
50+
The script automatically updates:
5651

57-
```bash
58-
# 1. Find current references
59-
git grep "gcr.io/o1labs-192920/mina-daemon"
60-
git grep "3\.1\.0" # Search for old version numbers
52+
- Configuration file references in testing code
53+
- Docker image tags in CI workflows and compose files
54+
- Version strings throughout the codebase
6155

62-
# 2. Update image tags throughout the codebase
63-
# Replace old tags with new release version
56+
## 3. Manual Verification
6457

65-
# 3. Search for config file references in code
66-
git grep "config_"
58+
After running the script, verify all references were updated correctly:
6759

68-
# 4. Update any hardcoded version references
69-
git grep -i "mina.*3\.1\.0" # Example for version 3.1.0
60+
```bash
61+
# Search for any remaining old references
62+
git grep "gcr.io/o1labs-192920/mina-daemon"
63+
git grep "config_<old_hash>"
64+
git grep "<old_version>"
7065
```
7166

72-
## 5. Verification Steps
67+
## 4. Verification Steps
7368

7469
After making updates:
7570

@@ -80,13 +75,15 @@ After making updates:
8075
with the updated OCaml node
8176
5. **CI Pipeline**: Verify that automated testing passes with new versions
8277

83-
## 6. Commit Structure
78+
## 5. Commit Structure
8479

85-
Following the pattern from PR #1236:
80+
Following the pattern from commit
81+
[31caeee6](https://github.com/o1-labs/openmina/commit/31caeee6af7bf20b8578a23bf69718dbe68fe5cc):
8682

87-
1. **Main Update Commit**: "Update OCaml node dependencies to [version]"
88-
2. **Changelog**: Add entry documenting the version bump
89-
3. **Config Updates**: Separate commit for configuration file changes if needed
83+
1. **Main Update Commit**: "OCaml nodes: bump up to release [version]"
84+
- Updates 6 files: CI workflows, Docker compose, and testing configurations
85+
- Atomic change affecting all OCaml node references
86+
2. **Changelog**: Add entry documenting the version bump if needed
9087

9188
## Related Resources
9289

0 commit comments

Comments
 (0)