1111# Usage: check-protocol-overlay-versions.sh <base-rev> [<head-rev>]
1212#
1313# Compares <head-rev> (or the working tree if <head-rev> is omitted) against
14- # <base-rev>. If the ledger protocol version
15- # increased, exits with a non-zero status unless OVERLAY_PROTOCOL_VERSION is
16- # higher than it was when <base-rev>'s ledger protocol version was introduced.
17- # Comparing against that commit rather than <base-rev> means a change doesn't
18- # need to bump the overlay version again if it was already bumped since the
19- # previous protocol bump. It also doesn't depend on release tags, which may not
20- # be public yet when the next protocol bump lands.
21- #
22- # Requires the history of <base-rev> back to its last ledger protocol bump.
14+ # <base-rev>. Exits with a non-zero status if OVERLAY_PROTOCOL_VERSION was
15+ # lowered, or if the ledger protocol version increased without
16+ # OVERLAY_PROTOCOL_VERSION increasing in the same change. An overlay bump that
17+ # landed separately (before or after an earlier protocol bump) doesn't count,
18+ # since it can't be told apart from one that belongs to the previous protocol.
2319
2420set -e
2521
@@ -85,34 +81,9 @@ ledger_at()
8581 fi
8682}
8783
88- # Print the oldest commit in <base-rev>'s history from which
89- # the ledger protocol version has had the value it has at <base-rev>.
90- ledger_bump_commit ()
91- {
92- FOUND=
93- for C in $( git log --format=%H -G " $LEDGER_LOG_REGEX " " $BASE_REV " -- " $CONFIG_CPP " " $PROTOCOL_H " )
94- do
95- LEDGER=$( ledger_at " $C " )
96- if [ " $LEDGER " != " $BASE_LEDGER " ]
97- then
98- break
99- fi
100- FOUND=$C
101- done
102- # A commit with no parent available is a shallow clone boundary, not
103- # necessarily the commit that introduced the protocol version.
104- if [ -z " $FOUND " ] || ! git rev-parse -q --verify " $FOUND ^" > /dev/null
105- then
106- echo " error: could not find the commit that set the ledger protocol version to $BASE_LEDGER in the history of $BASE_REV (shallow clone?)" >&2
107- exit 2
108- fi
109- echo " $FOUND "
110- }
11184
11285LEDGER_EXPR=' s/.*Config::CURRENT_LEDGER_PROTOCOL_VERSION[[:space:]]*=[[:space:]]*\([0-9][0-9]*\).*/\1/p'
11386MAX_SUPPORTED_EXPR=' s/.*MAX_SUPPORTED_PROTOCOL_VERSION[[:space:]]*=[[:space:]]*\([0-9][0-9]*\).*/\1/p'
114- # Matches diffs that change either form of the ledger protocol version.
115- LEDGER_LOG_REGEX=' (CURRENT_LEDGER|MAX_SUPPORTED)_PROTOCOL_VERSION[[:space:]]*=[[:space:]]*[0-9]'
11687OVERLAY_EXPR=' s/^[[:space:]]*OVERLAY_PROTOCOL_VERSION[[:space:]]*=[[:space:]]*\([0-9][0-9]*\).*/\1/p'
11788
11889BASE_LEDGER=$( ledger_at " $BASE_REV " )
@@ -129,20 +100,12 @@ then
129100 exit 1
130101fi
131102
132- if [ " $HEAD_LEDGER " -gt " $BASE_LEDGER " ]
103+ if [ " $HEAD_LEDGER " -gt " $BASE_LEDGER " ] && [ " $HEAD_OVERLAY " -le " $BASE_OVERLAY " ]
133104then
134- BUMP_COMMIT=$( ledger_bump_commit)
135- BUMP_OVERLAY=$( extract " $BUMP_COMMIT " " $CONFIG_CPP " OVERLAY_PROTOCOL_VERSION " $OVERLAY_EXPR " )
136- echo " Protocol $BASE_LEDGER was introduced in $( git log -1 --format=' %h (%s)' " $BUMP_COMMIT " ) "
137- echo " with OVERLAY_PROTOCOL_VERSION $BUMP_OVERLAY "
138- if [ " $HEAD_OVERLAY " -le " $BUMP_OVERLAY " ]
139- then
140- echo " error: the ledger protocol version was bumped from $BASE_LEDGER to $HEAD_LEDGER " >&2
141- echo " but OVERLAY_PROTOCOL_VERSION ($HEAD_OVERLAY ) has not been bumped since protocol" >&2
142- echo " $BASE_LEDGER was introduced. A ledger protocol bump must be accompanied by a" >&2
143- echo " bump of the maximum overlay protocol version in $CONFIG_CPP ." >&2
144- exit 1
145- fi
105+ echo " error: the ledger protocol version was bumped from $BASE_LEDGER to $HEAD_LEDGER " >&2
106+ echo " but OVERLAY_PROTOCOL_VERSION was not bumped. A ledger protocol bump must be" >&2
107+ echo " accompanied by a bump of the maximum overlay protocol version in $CONFIG_CPP ." >&2
108+ exit 1
146109fi
147110
148111echo " OK"
0 commit comments