Skip to content

Commit 375a581

Browse files
committed
Merge branch 'bitcoin' into auxpow
2 parents 1b61f03 + 8bb77f3 commit 375a581

174 files changed

Lines changed: 2394 additions & 1879 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/ci-lint-exec.py

Lines changed: 0 additions & 55 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ jobs:
168168
run: |
169169
# A workaround for "The `brew link` step did not complete successfully" error.
170170
brew install --quiet python@3 || brew link --overwrite python@3
171-
brew install --quiet coreutils ninja pkgconf gnu-getopt ccache boost libevent zeromq qt@6 qrencode capnp
171+
brew install --quiet coreutils ninja pkgconf ccache boost libevent zeromq qt@6 qrencode capnp
172172
173173
- name: Set Ccache directory
174174
run: echo "CCACHE_DIR=${RUNNER_TEMP}/ccache_dir" >> "$GITHUB_ENV"
@@ -681,4 +681,6 @@ jobs:
681681
cache-provider: ${{ needs.runners.outputs.provider }}
682682

683683
- name: CI script
684-
run: python .github/ci-lint-exec.py
684+
run: |
685+
git worktree add ../lint-worktree HEAD
686+
../lint-worktree/ci/lint.py

CMakeLists.txt

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -483,14 +483,8 @@ configure_file(contrib/filter-lcov.py filter-lcov.py USE_SOURCE_PERMISSIONS COPY
483483
# Don't allow extended (non-ASCII) symbols in identifiers. This is easier for code review.
484484
try_append_cxx_flags("-fno-extended-identifiers" TARGET core_interface SKIP_LINK)
485485

486-
# Avoiding the `-ffile-prefix-map` compiler option because it implies
487-
# `-fcoverage-prefix-map` on Clang or `-fprofile-prefix-map` on GCC,
488-
# which can cause issues with coverage builds, particularly when using
489-
# Clang in the OSS-Fuzz environment due to its use of other options
490-
# and a third party script, or with GCC.
491-
try_append_cxx_flags("-fdebug-prefix-map=A=B" TARGET core_interface SKIP_LINK
492-
IF_CHECK_PASSED "-fdebug-prefix-map=${PROJECT_SOURCE_DIR}/src=."
493-
)
486+
# Set `-fmacro-prefix-map`, so that source file names are expanded without the
487+
# src prefix.
494488
try_append_cxx_flags("-fmacro-prefix-map=A=B" TARGET core_interface SKIP_LINK
495489
IF_CHECK_PASSED "-fmacro-prefix-map=${PROJECT_SOURCE_DIR}/src=."
496490
)

CONTRIBUTING.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ The codebase is maintained using the "contributor workflow" where everyone
7878
without exception contributes patch proposals using "pull requests" (PRs). This
7979
facilitates social contribution, easy testing and peer review.
8080

81+
Pull request authors must fully and confidently understand their own changes
82+
and must have tested them. Contributors should mention which tests cover their
83+
changes, or include the manual steps they used to confirm the change.
84+
Contributors are expected to be prepared to clearly motivate and explain their
85+
changes. If there is doubt, the pull request may be closed.
86+
Please refer to the [peer review](#peer-review) section below for more details.
87+
8188
To contribute a patch, the workflow is as follows:
8289

8390
1. Fork repository ([only for the first time](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo))
@@ -338,6 +345,11 @@ reviewers that the changes warrant the review effort, and if reviewers are
338345
"Concept NACK'ing" the PR, the author may need to present arguments and/or do
339346
research backing their suggested changes.
340347

348+
Moreover, if there is reasonable doubt that the pull request author does not
349+
fully understand the changes they are submitting themselves, or if it becomes
350+
clear that they have not tested the changes on a basic level themselves, the
351+
pull request may be closed immediately.
352+
341353
#### Conceptual Review
342354

343355
A review can be a conceptual review, where the reviewer leaves a comment

ci/lint.py

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#!/usr/bin/env python3
2+
# Copyright (c) The Bitcoin Core developers
3+
# Distributed under the MIT software license, see the accompanying
4+
# file COPYING or https://opensource.org/license/mit/.
5+
6+
import os
7+
import shlex
8+
import subprocess
9+
import sys
10+
import time
11+
from pathlib import Path
12+
13+
14+
def run(cmd, **kwargs):
15+
print("+ " + shlex.join(cmd), flush=True)
16+
kwargs.setdefault("check", True)
17+
try:
18+
return subprocess.run(cmd, **kwargs)
19+
except Exception as e:
20+
sys.exit(str(e))
21+
22+
23+
def get_worktree_mounts(repo_root):
24+
git_path = repo_root / ".git"
25+
if not git_path.is_file():
26+
return []
27+
content = git_path.read_text().strip()
28+
if not content.startswith("gitdir: "):
29+
return []
30+
gitdir = (repo_root / content.removeprefix("gitdir: ")).resolve()
31+
main_gitdir = gitdir.parent.parent
32+
return [
33+
f"--volume={gitdir}:{gitdir}",
34+
f"--volume={main_gitdir}:{main_gitdir}",
35+
]
36+
37+
38+
def main():
39+
repo_root = Path(__file__).resolve().parent.parent
40+
is_ci = os.environ.get("GITHUB_ACTIONS") == "true"
41+
container = "bitcoin-linter"
42+
43+
build_cmd = [
44+
"docker",
45+
"buildx",
46+
"build",
47+
f"--tag={container}",
48+
*shlex.split(os.environ.get("DOCKER_BUILD_CACHE_ARG", "")),
49+
f"--file={repo_root}/ci/lint_imagefile",
50+
str(repo_root),
51+
]
52+
if run(build_cmd, check=False).returncode != 0:
53+
if is_ci:
54+
print("Retry building image after failure")
55+
time.sleep(3)
56+
run(build_cmd)
57+
58+
extra_env = []
59+
if is_ci:
60+
if os.environ.get("GITHUB_EVENT_NAME") == "pull_request":
61+
extra_env = ["--env", "LINT_CI_IS_PR=1"]
62+
elif os.environ.get("GITHUB_REPOSITORY") == "bitcoin/bitcoin":
63+
extra_env = ["--env", "LINT_CI_SANITY_CHECK_COMMIT_SIG=1"]
64+
65+
run(
66+
[
67+
"docker",
68+
"run",
69+
"--rm",
70+
*extra_env,
71+
f"--volume={repo_root}:/bitcoin",
72+
*get_worktree_mounts(repo_root),
73+
*([] if is_ci else ["-it"]),
74+
container,
75+
*sys.argv[1:],
76+
]
77+
)
78+
79+
80+
if __name__ == "__main__":
81+
main()

ci/lint/01_install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export LC_ALL=C
88

99
set -o errexit -o pipefail -o xtrace
1010

11-
export CI_RETRY_EXE="/ci_retry --"
11+
export CI_RETRY_EXE="/ci_retry"
1212

1313
pushd "/"
1414

ci/lint/06_script.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ if [ -n "${LINT_CI_IS_PR}" ]; then
1616
fi
1717
fi
1818

19-
RUST_BACKTRACE=1 cargo run --manifest-path "./test/lint/test_runner/Cargo.toml"
19+
RUST_BACKTRACE=1 cargo run --manifest-path "./test/lint/test_runner/Cargo.toml" -- "$@"
2020

2121
if [ "${LINT_CI_SANITY_CHECK_COMMIT_SIG}" = "1" ] ; then
2222
# Sanity check only the last few commits to get notified of missing sigs,

ci/lint/container-entrypoint.sh

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,4 @@ git config --global --add safe.directory /bitcoin
1212

1313
export PATH="/python_build/bin:${PATH}"
1414

15-
if [ -z "$1" ]; then
16-
bash -ic "./ci/lint/06_script.sh"
17-
else
18-
exec "$@"
19-
fi
15+
./ci/lint/06_script.sh "$@"

ci/retry/retry

Lines changed: 0 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
#!/usr/bin/env bash
22

3-
GETOPT_BIN=$IN_GETOPT_BIN
4-
GETOPT_BIN=${GETOPT_BIN:-getopt}
5-
63
__sleep_amount() {
74
if [ -n "$constant_sleep" ]; then
85
sleep_time=$constant_sleep
@@ -71,93 +68,10 @@ retry()
7168
exit $return_code
7269
}
7370

74-
# If we're being sourced, don't worry about such things
75-
if [ "$BASH_SOURCE" == "$0" ]; then
76-
# Prints the help text
77-
help()
78-
{
79-
local retry=$(basename $0)
80-
cat <<EOF
81-
Usage: $retry [options] -- execute command
82-
-h, -?, --help
83-
-v, --verbose Verbose output
84-
-t, --tries=# Set max retries: Default 10
85-
-s, --sleep=secs Constant sleep amount (seconds)
86-
-m, --min=secs Exponential Backoff: minimum sleep amount (seconds): Default 0.3
87-
-x, --max=secs Exponential Backoff: maximum sleep amount (seconds): Default 60
88-
-f, --fail="script +cmds" Fail Script: run in case of final failure
89-
EOF
90-
}
91-
92-
# show help for no arguments if stdin is a terminal
93-
if { [ -z "$1" ] && [ -t 0 ] ; } || [ "$1" == '-h' ] || [ "$1" == '-?' ] || [ "$1" == '--help' ]
94-
then
95-
help
96-
exit 0
97-
fi
98-
99-
$GETOPT_BIN --test > /dev/null
100-
if [[ $? -ne 4 ]]; then
101-
echo "I’m sorry, 'getopt --test' failed in this environment. Please load GNU getopt."
102-
exit 1
103-
fi
104-
105-
OPTIONS=vt:s:m:x:f:
106-
LONGOPTIONS=verbose,tries:,sleep:,min:,max:,fail:
107-
108-
PARSED=$($GETOPT_BIN --options="$OPTIONS" --longoptions="$LONGOPTIONS" --name "$0" -- "$@")
109-
if [[ $? -ne 0 ]]; then
110-
# e.g. $? == 1
111-
# then getopt has complained about wrong arguments to stdout
112-
exit 2
113-
fi
114-
# read getopt’s output this way to handle the quoting right:
115-
eval set -- "$PARSED"
116-
11771
max_tries=10
11872
min_sleep=0.3
11973
max_sleep=60.0
12074
constant_sleep=
12175
fail_script=
12276

123-
# now enjoy the options in order and nicely split until we see --
124-
while true; do
125-
case "$1" in
126-
-v|--verbose)
127-
VERBOSE=true
128-
shift
129-
;;
130-
-t|--tries)
131-
max_tries="$2"
132-
shift 2
133-
;;
134-
-s|--sleep)
135-
constant_sleep="$2"
136-
shift 2
137-
;;
138-
-m|--min)
139-
min_sleep="$2"
140-
shift 2
141-
;;
142-
-x|--max)
143-
max_sleep="$2"
144-
shift 2
145-
;;
146-
-f|--fail)
147-
fail_script="$2"
148-
shift 2
149-
;;
150-
--)
151-
shift
152-
break
153-
;;
154-
*)
155-
echo "Programming error"
156-
exit 3
157-
;;
158-
esac
159-
done
160-
16177
retry "$max_tries" "$min_sleep" "$max_sleep" "$constant_sleep" "$fail_script" "$@"
162-
163-
fi

ci/test/00_setup_env.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export PREVIOUS_RELEASES_DIR=${PREVIOUS_RELEASES_DIR:-$BASE_ROOT_DIR/prev_releas
6262
export CI_BASE_PACKAGES=${CI_BASE_PACKAGES:-build-essential pkgconf curl ca-certificates ccache python3-dev rsync git procps bison e2fsprogs cmake ninja-build}
6363
export GOAL=${GOAL:-install}
6464
export DIR_QA_ASSETS=${DIR_QA_ASSETS:-${BASE_SCRATCH_DIR}/qa-assets}
65-
export CI_RETRY_EXE=${CI_RETRY_EXE:-"retry --"}
65+
export CI_RETRY_EXE=${CI_RETRY_EXE:-"retry"}
6666

6767
# The --platform argument used with `docker build` and `docker run`.
6868
export CI_IMAGE_PLATFORM=${CI_IMAGE_PLATFORM:-"linux"} # Force linux, but use native arch by default

0 commit comments

Comments
 (0)