Skip to content

Commit 7c1fcd1

Browse files
committed
Merge remote-tracking branch 'origin/master' into HEAD
2 parents 60fba75 + dee90f2 commit 7c1fcd1

14 files changed

Lines changed: 328 additions & 180 deletions

contrib/merge-prs.sh

Lines changed: 143 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,58 @@
33
export LC_ALL=C
44
set -eo pipefail
55

6+
# Setup base branch and Bitcoin/Elements remote names.
67
BASE_ORIG=merged-master
78
BASE="${BASE_ORIG}"
89
BITCOIN_UPSTREAM_REMOTE=bitcoin
9-
BITCOIN_UPSTREAM="${BITCOIN_UPSTREAM_REMOTE}/master"
10-
# ELEMENTS_UPSTREAM_REMOTE=upstream
11-
# ELEMENTS_UPSTREAM="${ELEMENTS_UPSTREAM_REMOTE}/master"
10+
export BITCOIN_UPSTREAM="${BITCOIN_UPSTREAM_REMOTE}/master"
11+
ELEMENTS_UPSTREAM_REMOTE=upstream
12+
export ELEMENTS_UPSTREAM="${ELEMENTS_UPSTREAM_REMOTE}/master"
1213

14+
# START USER CONFIG:
15+
# Set your target upstream here
16+
TARGET_UPSTREAM=$BITCOIN_UPSTREAM
17+
TARGET_NAME="Bitcoin"
18+
PR_PREFIX="bitcoin/bitcoin"
19+
# TARGET_UPSTREAM=$ELEMENTS_UPSTREAM
20+
# TARGET_NAME="Elements"
21+
# PR_PREFIX="ElementsProject/elements"
22+
23+
# Set your git worktree location here. This is where the merges will be done, and where you should checkout the merged-master branch.
24+
WORKTREE="/home/byron/code/elements-worktree"
25+
26+
# Set your parallellism during build/test. You probably want as many cores as possible.
27+
# Parallel functional tests can somewhat exceed your core count, depends on the build machine CPU/RAM.
28+
PARALLEL_BUILD=23 # passed to make -j
29+
PARALLEL_TEST=46 # passed to test_runner.py --jobs
30+
PARALLEL_FUZZ=12 # passed to test_runner.py -j when fuzzing
31+
32+
# Setup a ccache dir if necessary.
33+
#export CCACHE_DIR="/tmp/ccache"
34+
#export CCACHE_MAXSIZE="20G"
35+
36+
# Set and export a WEBHOOK environment variable to a Discord webhook URL outside of this script to get notifications of progress and failures.
37+
38+
# We don't currently fuzz during merging. Check fuzzing and CI after a merge run.
1339
# Replace this with the location where we should put the fuzz test corpus
14-
BITCOIN_QA_ASSETS="${HOME}/.tmp/bitcoin/qa-assets"
15-
FUZZ_CORPUS="${BITCOIN_QA_ASSETS}/fuzz_seed_corpus/"
16-
mkdir -p "$(dirname "${BITCOIN_QA_ASSETS}")"
17-
18-
# BEWARE: On some systems /tmp/ gets periodically cleaned, which may cause
19-
# random files from this directory to disappear based on timestamp, and
20-
# make git very confused
21-
WORKTREE="${HOME}/.tmp/elements-merge-worktree"
22-
mkdir -p "${HOME}/.tmp"
23-
24-
# These should be tuned to your machine; below values are for an 8-core
25-
# 16-thread macbook pro
26-
PARALLEL_BUILD=4 # passed to make -j
27-
PARALLEL_TEST=12 # passed to test_runner.py --jobs
28-
PARALLEL_FUZZ=8 # passed to test_runner.py -j when fuzzing
40+
# BITCOIN_QA_ASSETS="${HOME}/code/bitcoin/qa-assets"
41+
# FUZZ_CORPUS="${BITCOIN_QA_ASSETS}/fuzz_seed_corpus/"
2942

43+
# END USER CONFIG
44+
45+
# Script
3046
SKIP_MERGE=0
3147
DO_BUILD=1
3248
KEEP_GOING=1
49+
DO_TEST=1
50+
DO_FUZZ=0
51+
NUM=15
52+
COUNT=0
3353

3454
if [[ "$1" == "setup" ]]; then
3555
echo "Setting up..."
3656
echo
37-
git config remote.upstream.url >/dev/null || remote add upstream "https://github.com/ElementsProject/elements.git"
57+
git config remote.upstream.url >/dev/null || git remote add upstream "https://github.com/ElementsProject/elements.git"
3858
git config remote.bitcoin.url >/dev/null || git remote add bitcoin "https://github.com/bitcoin/bitcoin.git"
3959
if git worktree list --porcelain | grep --silent prunable; then
4060
echo "You have stale git worktrees, please either fix them or run 'git worktree prune'."
@@ -45,14 +65,7 @@ if [[ "$1" == "setup" ]]; then
4565
echo "Fetching all remotes..."
4666
echo
4767
git fetch --all
48-
echo
49-
#echo "Cloning fuzz test corpus..."
50-
#echo
51-
#if [[ ! -d "${BITCOIN_QA_ASSETS}" ]]; then
52-
# cd "$(dirname ${BITCOIN_QA_ASSETS})" && git clone https://github.com/bitcoin-core/qa-assets.git
53-
#fi
54-
#echo
55-
echo "Done! Remember to also check out merged-master, and push it back up when finished."
68+
echo "Done! Remember to also checkout merged-master at ${WORKTREE}"
5669
exit 0
5770
elif [[ "$1" == "continue" ]]; then
5871
SKIP_MERGE=1
@@ -62,17 +75,35 @@ elif [[ "$1" == "list-only" ]]; then
6275
DO_BUILD=0
6376
elif [[ "$1" == "step" ]]; then
6477
KEEP_GOING=0
78+
elif [[ "$1" == "merge-only" ]]; then
79+
SKIP_MERGE=0
80+
KEEP_GOING=0
81+
DO_BUILD=0
82+
DO_TEST=0
6583
elif [[ "$1" == "step-continue" ]]; then
6684
SKIP_MERGE=1
6785
KEEP_GOING=0
86+
elif [[ "$1" == "step-test" ]]; then
87+
SKIP_MERGE=1
88+
KEEP_GOING=0
89+
DO_BUILD=0
90+
elif [[ "$1" == "step-fuzz" ]]; then
91+
SKIP_MERGE=1
92+
KEEP_GOING=0
93+
DO_BUILD=0
94+
DO_TEST=0
95+
elif [[ "$1" == "analyze" ]]; then
96+
DO_BUILD=0
97+
DO_TEST=0
6898
else
69-
echo "Usage: $0 <setup|list-only|go|continue|step|step-continue>"
99+
echo "Usage: $0 <setup|list-only|go|continue|step|step-continue|analyze>"
70100
echo " setup will configure your repository for the first run of this script"
71101
echo " list-only will simply list all the PRs yet to be done"
72102
echo " go will try to merge every PR, building/testing each"
73103
echo " continue assumes the first git-merge has already happened, and starts with building"
74104
echo " step will try to merge/build/test a single PR"
75105
echo " step-continue assumes the first git-merge has already happened, and will try to build/test a single PR"
106+
echo " analyze will analyze the next $NUM PRs and count conflicts NB: DO NOT CTRL+C THIS PROCESS"
76107
echo
77108
echo "Prior to use, please create a git worktree for the elements repo at:"
78109
echo " $WORKTREE"
@@ -101,54 +132,95 @@ if [[ "$SKIP_MERGE" == "1" ]]; then
101132
fi
102133

103134
## Get full list of merges
104-
# for elements
105-
# COMMITS=$(git -C "$WORKTREE" log "$ELEMENTS_UPSTREAM" --not $BASE --merges --first-parent --pretty='format:%ct %cI %h Elements %s')
106-
# for bitcoin
107-
COMMITS=$(git -C "$WORKTREE" log "$BITCOIN_UPSTREAM" --not $BASE --merges --first-parent --pretty='format:%ct %cI %h Bitcoin %s')
135+
COMMITS=$(git -C "$WORKTREE" log "$TARGET_UPSTREAM" --not $BASE --merges --first-parent --pretty="format:%ct %cI %h $TARGET_NAME %s")
108136

109-
cd "$WORKTREE"
137+
cd "$WORKTREE" || exit 1
110138

111139
VERBOSE=1
112140

141+
echo start > merge.log
142+
113143
quietly () {
114144
if [[ "$VERBOSE" == "1" ]]; then
115-
"$@"
145+
date | tee --append merge.log
146+
time "$@" 2>&1 | tee --append merge.log
116147
else
117148
chronic "$@"
118149
fi
119150
}
120151

152+
notify () {
153+
local MESSAGE="$1"
154+
local JSON="{\"content\": \"$MESSAGE\"}"
155+
if [ -n "$WEBHOOK" ]; then
156+
curl -d "$JSON" -H "Content-Type: application/json" "$WEBHOOK"
157+
else
158+
echo "$MESSAGE"
159+
fi
160+
if [[ "$2" == "1" ]]; then
161+
exit 1
162+
fi
163+
}
164+
121165
## Sort by unix timestamp and iterate over them
122-
#echo "$ELT_COMMITS" "$BTC_COMMITS" | sort -n -k1 | while read line
123166
echo "$COMMITS" | tac | while read -r line
124167
do
125-
echo
126-
echo "=-=-=-=-=-=-=-=-=-=-="
127-
echo
128-
129-
echo -e "$line"
130168
## Extract data and output what we're doing
131-
DATE=$(echo "$line" | cut -d ' ' -f 2)
132169
HASH=$(echo "$line" | cut -d ' ' -f 3)
133170
CHAIN=$(echo "$line" | cut -d ' ' -f 4)
134-
PR_ID=$(echo "$line" | cut -d ' ' -f 6 | tr -d :)
135-
PR_ID_ALT=$(echo "$line" | cut -d ' ' -f 8 | tr -d :)
171+
PR_ID=$(echo "$line" | grep -o -P "#\d+")
136172

137-
if [[ "$PR_ID" == "pull" ]]; then
138-
PR_ID="${PR_ID_ALT}"
139-
fi
140-
echo -e "$CHAIN PR \e[37m$PR_ID \e[33m$HASH\e[0m on \e[32m$DATE\e[0m "
173+
GIT_HEAD=$(git rev-parse HEAD)
141174

142175
## Do it
143176
if [[ "$1" == "list-only" ]]; then
177+
echo -e "$line"
144178
continue
145179
fi
180+
if [[ "$1" == "analyze" ]]; then
181+
COUNT=$((COUNT + 1))
182+
# todo: count conflicts in critical files
183+
# CRITICAL_FILES=("src/wallet/spend.h", "src/wallet/spend.cpp")
184+
MERGE_FILE="/tmp/$HASH.merge"
185+
DIFF_FILE="/tmp/$HASH.diff"
186+
git -C "$WORKTREE" merge "$HASH" --no-ff -m "Merge $HASH into merged_master ($CHAIN PR $PR_PREFIX$PR_ID)" > "$MERGE_FILE" || true
187+
git -C "$WORKTREE" diff > "$DIFF_FILE"
188+
git -C "$WORKTREE" reset --hard "$GIT_HEAD" > /dev/null
189+
# FILES=$(grep "CONFLICT" "$MERGE_FILE")
190+
NUM_FILES=$(grep -c "CONFLICT" "$MERGE_FILE")
191+
NUM_CONFLICTS=$(grep -c "<<<<<<<" "$DIFF_FILE")
192+
echo "$COUNT. Merge up to $PR_ID ($HASH) has $NUM_CONFLICTS conflicts in $NUM_FILES files."
193+
if [[ "$COUNT" == "$NUM" ]]; then
194+
exit 0
195+
else
196+
continue
197+
fi
198+
fi
199+
notify "starting merge of $PR_ID"
200+
201+
# check for stoppers and halt if found
202+
# a stopper is normally the PR after the version has been changed
203+
# ie. the branch point we want to stop at for this version
204+
STOPPERS=(
205+
"#30716" # bitcoin v28
206+
"#32041" # bitcoin v29
207+
)
208+
for STOPPER in "${STOPPERS[@]}"
209+
do
210+
if [[ "$PR_ID" == *"$STOPPER"* ]]; then
211+
echo "Found $STOPPER in $PR_ID! Exiting."
212+
notify "hit stopper, exiting"
213+
exit 1
214+
else
215+
echo "Didn't find $STOPPER in $PR_ID. Continuing."
216+
fi
217+
done
146218

147219
if [[ "$SKIP_MERGE" == "1" ]]; then
148220
echo -e "Continuing build of \e[37m$PR_ID\e[0m at $(date)"
149221
else
150222
echo -e "Start merge/build of \e[37m$PR_ID\e[0m at $(date)"
151-
git -C "$WORKTREE" merge "$HASH" --no-ff -m "Merge $HASH into merged_master ($CHAIN PR $PR_ID)"
223+
git -C "$WORKTREE" merge "$HASH" --no-ff -m "Merge $HASH into merged_master ($CHAIN PR $PR_PREFIX$PR_ID)" || notify "fail merge" 1
152224
fi
153225

154226
# FIXME: ELEMENTS, move make building process into CMake one?
@@ -164,35 +236,43 @@ do
164236
# The following is an expansion of `make check` that skips the libsecp
165237
# tests and also the benchmarks (though it does build them!)
166238
echo "Building"
167-
quietly make -j"$PARALLEL_BUILD" -k
168-
# quietly make -j1 check
169-
echo "Linting"
170-
quietly ./ci/lint/06_script.sh
239+
quietly make -j"$PARALLEL_BUILD" -k || notify "fail build" 1
240+
# todo: fix linting step
241+
# echo "Linting"
242+
# quietly ./ci/lint/06_script.sh || notify "fail lint"
243+
fi
244+
245+
if [[ "$DO_TEST" == "1" ]]; then
171246
echo "Testing"
172-
quietly ./src/qt/test/test_elements-qt
173-
quietly ./src/test/test_bitcoin
174-
quietly ./src/bench/bench_bitcoin
175-
quietly ./test/util/bitcoin-util-test.py
176-
quietly ./test/util/rpcauth-test.py
177-
quietly make -C src/univalue/ check
247+
quietly ./src/qt/test/test_elements-qt || notify "fail test qt" 1
248+
quietly ./src/test/test_bitcoin || notify "fail test bitcoin" 1
249+
quietly ./src/bench/bench_bitcoin || notify "fail test bench" 1
250+
quietly ./test/util/test_runner.py || notify "fail test util" 1
251+
quietly ./test/util/rpcauth-test.py || notify "fail test rpc" 1
178252
echo "Functional testing"
179-
quietly ./test/functional/test_runner.py --jobs="$PARALLEL_TEST"
253+
quietly ./test/functional/test_runner.py --jobs="$PARALLEL_TEST" || notify "fail test runner" 1
254+
fi
255+
256+
if [[ "$DO_FUZZ" == "1" ]]; then
180257
echo "Cleaning for fuzz"
181258
quietly make distclean || true
182259
quietly git -C "$WORKTREE" clean -xf
183260
echo "Building for fuzz"
184261
quietly ./autogen.sh
185262
# TODO turn on `,integer` after this rebase
186-
quietly ./configure --with-incompatible-bdb --enable-fuzz --with-sanitizers=address,fuzzer,undefined CC=clang CXX=clang++
263+
quietly ./configure --enable-fuzz --with-sanitizers=address,fuzzer,undefined CC="ccache clang" CXX="ccache clang++"
187264
quietly make -j"$PARALLEL_BUILD" -k
188265
echo "Fuzzing"
189-
quietly ./test/fuzz/test_runner.py -j"$PARALLEL_FUZZ" "${FUZZ_CORPUS}"
266+
quietly ./test/fuzz/test_runner.py -j"$PARALLEL_FUZZ" "${FUZZ_CORPUS}" || notify "fail fuzz" 1
190267
fi
191268

192269
if [[ "$KEEP_GOING" == "0" ]]; then
193-
exit 1
270+
notify "$PR_ID done, exiting"
271+
exit 0
272+
else
273+
echo "$PR_ID done, continuing"
194274
fi
195275

196-
# bummer1.sh
197276
SKIP_MERGE=0
277+
echo "end" >> merge.log
198278
done

doc/github-merge-script.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ github-merge.py <PR_NUMBER>
2424
For example for PR 1518 I see this output:
2525

2626
```
27-
ElementsProject/elements#1518 Avoid Simplicity header dependency propogation into master
28-
* 6c7788adf373cd8f0dc5c4fe2b7674625631721e Avoid Simplicity header dependency propogation (Russell O'Connor) (upstream/simplicity, pull/1518/head)
27+
ElementsProject/elements#1518 Avoid Simplicity header dependency propagation into master
28+
* 6c7788adf373cd8f0dc5c4fe2b7674625631721e Avoid Simplicity header dependency propagation (Russell O'Connor) (upstream/simplicity, pull/1518/head)
2929
3030
Dropping you on a shell so you can try building/testing the merged source.
3131
Run 'git diff HEAD~' to show the changes being merged.
@@ -47,10 +47,10 @@ exit
4747
In our example this results in the following output:
4848

4949
```
50-
[pull/1518/local-merge 5e1a950e52] Merge ElementsProject/elements#1518: Avoid Simplicity header dependency propogation
50+
[pull/1518/local-merge 5e1a950e52] Merge ElementsProject/elements#1518: Avoid Simplicity header dependency propagation
5151
Date: Thu Jan 22 14:49:26 2026 +0200
52-
ElementsProject/elements#1518 Avoid Simplicity header dependency propogation into master
53-
* 6c7788adf373cd8f0dc5c4fe2b7674625631721e Avoid Simplicity header dependency propogation (Russell O'Connor) (upstream/simplicity, pull/1518/head)
52+
ElementsProject/elements#1518 Avoid Simplicity header dependency propagation into master
53+
* 6c7788adf373cd8f0dc5c4fe2b7674625631721e Avoid Simplicity header dependency propagation (Russell O'Connor) (upstream/simplicity, pull/1518/head)
5454
ACKs:
5555
* ACK 6c7788a; built and tested locally (delta1)
5656
* ACK 6c7788adf373cd8f0dc5c4fe2b7674625631721e; successfully ran local tests (apoelstra)

src/init.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1834,6 +1834,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
18341834
index_cache_sizes.filter_index * (1.0 / 1024 / 1024), BlockFilterTypeName(filter_type));
18351835
}
18361836
LogInfo("* Using %.1f MiB for chain state database", kernel_cache_sizes.coins_db * (1.0 / 1024 / 1024));
1837+
LogInfo("ELIP 203 is%s active\n", (chainparams.GetAcceptUnlimitedIssuances())?"":" not");
18371838

18381839
assert(!node.mempool);
18391840
assert(!node.chainman);

src/kernel/chainparams.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1293,6 +1293,7 @@ class CLiquidTestNetParams : public CCustomParams {
12931293
default_signblockscript = "51210217e403ddb181872c32a0cd468c710040b2f53d8cac69f18dad07985ee37e9a7151ae";
12941294
create_discount_ct = false;
12951295
accept_discount_ct = true;
1296+
accept_unlimited_issuances = true;
12961297
UpdateFromArgs(args);
12971298
multi_data_permitted = true;
12981299
SetGenesisBlock();
@@ -1402,7 +1403,7 @@ class CLiquidV1Params : public CChainParams {
14021403

14031404
enforce_pak = true;
14041405

1405-
accept_unlimited_issuances = args.GetBoolArg("-acceptunlimitedissuances", false);
1406+
accept_unlimited_issuances = args.GetBoolArg("-acceptunlimitedissuances", true);
14061407

14071408
multi_data_permitted = true;
14081409
create_discount_ct = args.GetBoolArg("-creatediscountct", false);

0 commit comments

Comments
 (0)