Skip to content

Commit 5d9d547

Browse files
Merge pull request #246 from rainlanguage/2026-06-20-versioned-deploy-constants
Pin versioned deploy constants per soldeer tag (dex pattern)
2 parents dabe1cd + 60e042c commit 5d9d547

3 files changed

Lines changed: 117 additions & 0 deletions

File tree

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/usr/bin/env bash
2+
# SPDX-License-Identifier: LicenseRef-DCL-1.0
3+
# SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd
4+
#
5+
# Prints "OK" iff every version published to the soldeer registry for
6+
# `rain-math-float` has a full suite of pinned deploy constants in
7+
# LibDecimalFloatDeploy.sol: a log-tables address + codehash and a DecimalFloat
8+
# address + codehash, each suffixed with the version.
9+
#
10+
# Consumed by LibDecimalFloatDeployTaggedConstants.t.sol via FFI. Output is one
11+
# of:
12+
# OK - every published version has its full constant suite
13+
# MISSING: <names...> - one or more expected constants are absent
14+
# SKIP: <reason> - the registry could not be reached (nothing verified)
15+
#
16+
# Always exits 0 so the test sees the message rather than an ffi failure.
17+
18+
lib="src/lib/deploy/LibDecimalFloatDeploy.sol"
19+
20+
versions=$(
21+
curl -fsS --connect-timeout 5 --max-time 20 --retry 2 --retry-delay 1 \
22+
"https://api.soldeer.xyz/api/v1/revision?project_name=rain-math-float" 2>/dev/null \
23+
| grep -oE '"version":"[0-9][0-9.]*"' | cut -d'"' -f4 | sort -u
24+
)
25+
26+
if [ -z "$versions" ]; then
27+
printf 'SKIP: could not fetch published soldeer versions'
28+
exit 0
29+
fi
30+
31+
# The deploy constants that must be pinned for every published version, suffixed
32+
# with the version (dots replaced by underscores).
33+
bases="ZOLTU_DEPLOYED_LOG_TABLES_ADDRESS \
34+
LOG_TABLES_DATA_CONTRACT_HASH \
35+
ZOLTU_DEPLOYED_DECIMAL_FLOAT_ADDRESS \
36+
DECIMAL_FLOAT_CONTRACT_HASH"
37+
38+
missing=""
39+
for v in $versions; do
40+
suffix=$(printf '%s' "$v" | tr . _)
41+
for b in $bases; do
42+
name="${b}_${suffix}"
43+
grep -qE "constant ${name} =" "$lib" || missing="${missing} ${name}"
44+
done
45+
done
46+
47+
if [ -n "$missing" ]; then
48+
printf 'MISSING:%s' "$missing"
49+
else
50+
printf 'OK'
51+
fi

src/lib/deploy/LibDecimalFloatDeploy.sol

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,29 @@ library LibDecimalFloatDeploy {
3131
/// Zoltu's deterministic deployment proxy.
3232
bytes32 constant DECIMAL_FLOAT_CONTRACT_HASH = 0xdc468883c345d41c0abd98ef2fd933c370bd1682522d37e6f6b729793301f55e;
3333

34+
/// @dev Deploy constants pinned to each version published to the soldeer
35+
/// registry. These are frozen literals — not aliases of the "current"
36+
/// constants above — so each keeps referencing its own release's deployment
37+
/// after the current constants advance to a newer version.
38+
/// `script/check-published-deploy-constants.sh` (run by
39+
/// `LibDecimalFloatDeployTaggedConstantsTest`) queries the registry and
40+
/// fails if any published version is missing its suite, so publishing a new
41+
/// tag forces pinning that tag's deploy constants here.
42+
43+
/// @dev Log tables address at the published `0.1.1` soldeer tag.
44+
address constant ZOLTU_DEPLOYED_LOG_TABLES_ADDRESS_0_1_1 = address(0xc51a14251b0dcF0ae24A96b7153991378938f5F5);
45+
46+
/// @dev Log tables codehash at the published `0.1.1` soldeer tag.
47+
bytes32 constant LOG_TABLES_DATA_CONTRACT_HASH_0_1_1 =
48+
0x2573004ac3a9ee7fc8d73654d76386f1b6b99e34cdf86a689c4691e47143420f;
49+
50+
/// @dev DecimalFloat address at the published `0.1.1` soldeer tag.
51+
address constant ZOLTU_DEPLOYED_DECIMAL_FLOAT_ADDRESS_0_1_1 = address(0xBee0eEFaffD046c9602109eB30A858Be301CC926);
52+
53+
/// @dev DecimalFloat codehash at the published `0.1.1` soldeer tag.
54+
bytes32 constant DECIMAL_FLOAT_CONTRACT_HASH_0_1_1 =
55+
0x7a93d0311f7782b44157ba40e94ec936085ebe001c7893bdd74911c8351d3def;
56+
3457
/// Combines all log and anti-log tables into a single bytes array for
3558
/// deployment. These are using packed encoding to minimize size and remove
3659
/// the complexity of full ABI encoding.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// SPDX-License-Identifier: LicenseRef-DCL-1.0
2+
// SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd
3+
pragma solidity =0.8.25;
4+
5+
import {Test} from "forge-std-1.16.1/src/Test.sol";
6+
7+
/// @title LibDecimalFloatDeployTaggedConstantsTest
8+
/// @notice Every version published to the soldeer registry for `rain-math-float`
9+
/// must have a full suite of pinned deploy constants in `LibDecimalFloatDeploy`:
10+
/// a log-tables address + codehash and a DecimalFloat address + codehash for
11+
/// each published version. `script/check-published-deploy-constants.sh` queries
12+
/// the live registry (via FFI) and lists any missing constants, so publishing a
13+
/// new tag without pinning its constants fails this test. Skips if the registry
14+
/// is unreachable rather than failing on network flakiness.
15+
contract LibDecimalFloatDeployTaggedConstantsTest is Test {
16+
function testAllPublishedSoldeerTagsHaveAFullConstantSuite() external {
17+
string[] memory cmd = new string[](2);
18+
cmd[0] = "bash";
19+
cmd[1] = "script/check-published-deploy-constants.sh";
20+
bytes memory out = vm.ffi(cmd);
21+
22+
// The registry could not be reached; there is nothing to verify.
23+
if (_startsWith(out, bytes("SKIP"))) {
24+
vm.skip(true);
25+
return;
26+
}
27+
28+
// On failure the actual value lists the missing `*_<version>` constants.
29+
assertEq(string(out), "OK", "a published soldeer tag is missing pinned deploy constants");
30+
}
31+
32+
function _startsWith(bytes memory s, bytes memory prefix) private pure returns (bool) {
33+
if (s.length < prefix.length) {
34+
return false;
35+
}
36+
for (uint256 i = 0; i < prefix.length; i++) {
37+
if (s[i] != prefix[i]) {
38+
return false;
39+
}
40+
}
41+
return true;
42+
}
43+
}

0 commit comments

Comments
 (0)