8000 CI fix by Sjors · Pull Request #35 · Sjors/bitcoin · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

CI fix #35

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
ae582af
Add sv2 log category for Stratum v2
Sjors Nov 30, 2023
af8e738
Add sv2 noise protocol
Sjors Feb 2, 2024
1ede30c
move-only: introduce common/transport.h
Sjors Jan 8, 2024
008177b
move-only: v1 and v2 transport to their own file
Sjors Dec 29, 2023
d540438
Add sv2 messages
Sjors Dec 1, 2023
bd0c9ab
Introduce Sv2Transport
Sjors Jan 8, 2024
cdcd590
CKey: add Serialize and Unserialize
Sjors Feb 1, 2024
3babb16
Chainparams: add default sv2 port
Sjors Nov 29, 2023
37a00a1
Stratum v2 template provider scaffold
Sjors Jan 8, 2024
d9bbc9d
Template provider sv2 connection support
Sjors Feb 9, 2024
ebaa452
Persist static key for Template Provider
Sjors Jan 11, 2024
3b217e3
Sv2: construct and submit block templates
Sjors Dec 28, 2023
a2038d1
Incrementally update sv2 block template
Sjors Nov 30, 2023
b2a4924
Reject RequestTransactionData for stale templates
Sjors Feb 12, 2024
99fbdff
test: Sv2TemplateProvider tests
Sjors Feb 7, 2024
8142ba6
signet: miner skips PSBT step for OP_TRUE
Sjors Dec 8, 2023
4c5d254
doc: explain Stratum v2 design, testing and usage
Sjors Dec 28, 2023
760a133
ci: vary /tmp/env
Sjors Jan 16, 2024
835acbf
ci: refer to origin/master in linter script
Sjors Jan 16, 2024
8de4256
ci: forks can opt-out of CI branch push
Sjors Jan 18, 2024
7216b4a
ci: avoid sudo requirement for self-hosted cirrus
Sjors Jan 18, 2024
d5480e6
ci: skip arm and noble if no worker is configured
Sjors Jan 18, 2024
b72b47c
ci: skip Github CI on branch pushes for forks
Sjors Jan 18, 2024
8337650
ci: skip 'test each commit' task for forks
Sjors Jan 18, 2024
476a248
ci: clarify Cirrus self-hosted workers setup
Sjors Jan 25, 2024
1e06c04
Temporarily break certificate generation and validation
Sjors Feb 5, 2024
56db604
ci: bump macOS to 14
Sjors Feb 15, 2024
c8d10af
Try to fix sv2_template_provider_tests.cpp failure
Sjors Feb 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 34 additions & 15 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,38 @@ env: # Global defaults
CCACHE_DIR: "/tmp/ccache_dir"
CCACHE_NOHASHDIR: "1" # Debug info might contain a stale path if the build dir changes, but this is fine

# A self-hosted machine(s) can be used via Cirrus CI. It can be configured with a
# single user with sudo access, or multiple users without by setting USER_MODE=true
#
# https://cirrus-ci.org/guide/persistent-workers/
#
# It is possible to select a specific persistent worker by label. Refer to the
# Generally, a persistent worker must run Ubuntu 23.04+ or Debian 12+.
#
# The following specific types should exist, with the following requirements:
# - small: For an x86_64 machine, recommended to have 2 CPUs and 8 GB of memory.
# - medium: For an x86_64 machine, recommended to have 4 CPUs and 16 GB of memory.
# - noble: For a machine running the Linux kernel shipped with exaclty Ubuntu Noble 24.04. The machine is recommended to have 4 CPUs and 16 GB of memory.
# - arm64: For an aarch64 machine, recommended to have 2 CPUs and 8 GB of memory.
#
# CI jobs for the latter two configurations can be skipped by setting NO_ARM=1 or
# NO_NOBLE=1 as a custom env variable in Cirrus.
#
# The above machine types are matched to each job by their label. Refer to the
# Cirrus CI docs for more details.
#
# Generally, a persistent worker must run Ubuntu 23.04+ or Debian 12+.
# Specifically,
# On machines that are persisted between CI jobs, RESTART_CI_DOCKER_BEFORE_RUN=1
# ensures that previous containers and artifacts are cleared before each run.
# This requires installing Podman instead of Docker.
#
# Futhermore:
# - apt-get is required due to PACKAGE_MANAGER_INSTALL
# - podman-docker-4.1+ is required due to the use of `podman` when
# RESTART_CI_DOCKER_BEFORE_RUN is set and 4.1+ due to the bugfix in 4.1
# - podman-docker-4.1+ is required due to the bugfix in 4.1
# (https://github.com/bitcoin/bitcoin/pull/21652#issuecomment-1657098200)
# - The ./ci/ depedencies (with cirrus-cli) should be installed:
# - The ./ci/ depedencies (with cirrus-cli) should be installed. One-liner example
# for a single user setup with sudo permission:
#
# ```
# apt update && apt install screen python3 bash podman-docker curl -y && curl -L -o cirrus "https://github.com/cirruslabs/cirrus-cli/releases/latest/download/cirrus-linux-$(dpkg --print-architecture)" && mv cirrus /usr/local/bin/cirrus && chmod +x /usr/local/bin/cirrus
# apt update && apt install git screen python3 bash podman-docker curl -y && curl -L -o cirrus "https://github.com/cirruslabs/cirrus-cli/releases/latest/download/cirrus-linux-$(dpkg --print-architecture)" && mv cirrus /usr/local/bin/cirrus && chmod +x /usr/local/bin/cirrus
# ```
#
# - There are no strict requirements on the hardware, because having less CPUs
Expand All @@ -40,22 +57,20 @@ env: 6DB6 # Global defaults
# RESTART_CI_DOCKER_BEFORE_RUN=1 screen cirrus worker run --labels type=todo_fill_in_type --token todo_fill_in_token
# ```
#
# The following specific types should exist, with the following requirements:
# - small: For an x86_64 machine, recommended to have 2 CPUs and 8 GB of memory.
# - medium: For an x86_64 machine, recommended to have 4 CPUs and 16 GB of memory.
# - noble: For a machine running the Linux kernel shipped with exaclty Ubuntu Noble 24.04. The machine is recommended to have 4 CPUs and 16 GB of memory.
# - arm64: For an aarch64 machine, recommended to have 2 CPUs and 8 GB of memory.

# https://cirrus-ci.org/guide/tips-and-tricks/#sharing-configuration-between-tasks
filter_template: &FILTER_TEMPLATE
skip: $CIRRUS_REPO_FULL_NAME == "bitcoin-core/gui" && $CIRRUS_PR == "" # No need to run on the read-only mirror, unless it is a PR. https://cirrus-ci.org/guide/writing-tasks/#conditional-task-execution
# No need to run on the read-only mirror, unless it is a PR.
# https://cirrus-ci.org/guide/writing-tasks/#conditional-task-execution
skip: $CIRRUS_REPO_FULL_NAME == "bitcoin-core/gui" && $CIRRUS_PR == ""
# Allow forks to skip CI runs when a branch is pushed.
skip: $NO_BRANCH == "true" && $CIRRUS_PR == ""
stateful: false # https://cirrus-ci.org/guide/writing-tasks/#stateful-tasks

base_template: &BASE_TEMPLATE
<< : *FILTER_TEMPLATE
merge_base_script:
# Unconditionally install git (used in fingerprint_script).
- bash -c "$PACKAGE_MANAGER_INSTALL git"
- git --version || bash -c "$PACKAGE_MANAGER_INSTALL git"
- if [ "$CIRRUS_PR" = "" ]; then exit 0; fi
- git fetch --depth=1 $CIRRUS_REPO_CLONE_URL "pull/${CIRRUS_PR}/merge"
- git checkout FETCH_HEAD # Use merged changes to detect silent merge conflicts
Expand Down Expand Up @@ -106,7 +121,9 @@ task:

task:
name: 'ARM, unit tests, no functional tests'
# Skip if no ARM worker exists (for a fork)
<< : *GLOBAL_TASK_TEMPLATE
only_if: $NO_ARM != "true"
persistent_worker:
labels:
type: arm64 # Use arm64 worker to sidestep qemu and avoid a slow CI: https://github.com/bitcoin/bitcoin/pull/28087#issuecomment-1649399453
Expand Down Expand Up @@ -161,11 +178,13 @@ task:

task:
name: 'ASan + LSan + UBSan + integer, no depends, USDT'
# Skip if no Noble worker exists (for a fork)
enable_bpfcc_script:
# In the image build step, no external environment variables are available,
# so any settings will need to be written to the settings env file:
- sed -i "s|\${CIRRUS_CI}|true|g" ./ci/test/00_setup_env_native_asan.sh
<< : *GLOBAL_TASK_TEMPLATE
only_if: $NO_NOBLE != "true"
persistent_worker:
labels:
type: noble # Must use this specific worker (needed for USDT functional tests)
Expand Down
14 changes: 10 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ on:
# See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#push.
push:
branches:
- '**'
# Do not run branch pushes on forks, because they are typically redundant with
# pull requests to the main repo.
- 'bitcoin/**'
- 'bitcoin-core/**'
tags-ignore:
- '**'

Expand All @@ -26,7 +29,10 @@ jobs:
test-each-commit:
name: 'test each commit'
runs-on: ubuntu-22.04
if: github.event_name == 'pull_request' && github.event.pull_request.commits != 1
# Only run on pull requests, skip if there's only commit.
# Do not run on forks.
if: github.event_name == 'pull_request' && github.event.pull_request.commits != 1 &&
(github.repository == 'bitcoin-core/gui' || github.repository == 'bitcoin/bitcoin')
timeout-minutes: 360 # Use maximum time, see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idtimeout-minutes. Assuming a worst case time of 1 hour per commit, this leads to a --max-count=6 below.
env:
MAX_COUNT: 6
Expand Down Expand Up @@ -70,10 +76,10 @@ jobs:
git rebase --exec "echo Running test-one-commit on \$( git log -1 ) && ./autogen.sh && CC=clang-15 CXX=clang++-15 ./configure && make clean && make -j $(nproc) check && ./test/functional/test_runner.py -j $(( $(nproc) * 2 ))" ${{ env.TEST_BASE }}

macos-native-x86_64:
name: 'macOS 13 native, x86_64, no depends, sqlite only, gui'
name: 'macOS 14 native, x86_64, no depends, sqlite only, gui'
# Use latest image, but hardcode version to avoid silent upgrades (and breaks).
# See: https://github.com/actions/runner-images#available-images.
runs-on: macos-13
runs-on: macos-14

# No need to run on the read-only mirror, unless it is a PR.
if: github.repository != 'bitcoin-core/gui' || github.event_name == 'pull_request'
Expand Down
2 changes: 1 addition & 1 deletion ci/lint/06_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ set -ex
if [ -n "$LOCAL_BRANCH" ]; then
# To faithfully recreate CI linting locally, specify all commits on the current
# branch.
COMMIT_RANGE="$(git merge-base HEAD master)..HEAD"
COMMIT_RANGE="$(git merge-base HEAD origin/master)..HEAD"
elif [ -n "$CIRRUS_PR" ]; then
COMMIT_RANGE="HEAD~..HEAD"
echo
Expand Down
8 changes: 5 additions & 3 deletions ci/test/02_run_container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ set -ex
if [ -z "$DANGER_RUN_CI_ON_HOST" ]; then
# Export all env vars to avoid missing some.
# Though, exclude those with newlines to avoid parsing problems.
python3 -c 'import os; [print(f"{key}={value}") for key, value in os.environ.items() if "\n" not in value and "HOME" != key and "PATH" != key and "USER" != key]' | tee /tmp/env
python3 -c 'import os; [print(f"{key}={value}") for key, value in os.environ.items() if "\n" not in value and "HOME" != key and "PATH" != key and "USER" != key]' | tee "/tmp/env-$USER-$CONTAINER_NAME"
# System-dependent env vars must be kept as is. So read them from the container.
docker run --rm "${CI_IMAGE_NAME_TAG}" bash -c "env | grep --extended-regexp '^(HOME|PATH|USER)='" | tee --append /tmp/env
docker run --rm "${CI_IMAGE_NAME_TAG}" bash -c "env | grep --extended-regexp '^(HOME|PATH|USER)='" | tee --append "/tmp/env-$USER-$CONTAINER_NAME"
echo "Creating $CI_IMAGE_NAME_TAG container to run in"
DOCKER_BUILDKIT=1 10000 docker build \
--file "${BASE_READ_ONLY_DIR}/ci/test_imagefile" \
Expand Down Expand Up @@ -44,6 +44,8 @@ if [ -z "$DANGER_RUN_CI_ON_HOST" ]; then
# When detecting podman-docker, `--external` should be added.
docker image prune --force --filter "label=$CI_IMAGE_LABEL"

# Append $USER to /tmp/env to support multi-user systems and $CONTAINER_NAME
# to allow support starting multiple runs simultaneously by the same user.
# shellcheck disable=SC2086
CI_CONTAINER_ID=$(docker run --cap-add LINUX_IMMUTABLE $CI_CONTAINER_CAP --rm --interactive --detach --tty \
--mount "type=bind,src=$BASE_READ_ONLY_DIR,dst=$BASE_READ_ONLY_DIR,readonly" \
Expand All @@ -52,7 +54,7 @@ if [ -z "$DANGER_RUN_CI_ON_HOST" ]; then
--mount "type=volume,src=${CONTAINER_NAME}_depends_sources,dst=$DEPENDS_DIR/sources" \
--mount "type=volume,src=${CONTAINER_NAME}_depends_SDKs_android,dst=$DEPENDS_DIR/SDKs/android" \
--mount "type=volume,src=${CONTAINER_NAME}_previous_releases,dst=$PREVIOUS_RELEASES_DIR" \
--env-file /tmp/env \
--env-file /tmp/env-$USER-$CONTAINER_NAME \
--name "$CONTAINER_NAME" \
"$CONTAINER_NAME")
export CI_CONTAINER_ID
Expand Down
3 changes: 2 additions & 1 deletion contrib/signet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ Adding the --ongoing parameter will then cause the signet miner to create blocks

$MINER --cli="$CLI" generate --grind-cmd="$GRIND" --address="$ADDR" --nbits=$NBITS --ongoing

For custom signets with a trivial challenge a PSBT is not necessary. The miner detects this for `OP_TRUE`.

Other options
-------------

Expand Down Expand Up @@ -80,4 +82,3 @@ These steps can instead be done explicitly:
$CLI -signet -stdin submitblock

This is intended to allow you to replace part of the pipeline for further experimentation (eg, to sign the block with a hardware wallet).

47 changes: 31 additions & 16 deletions contrib/signet/miner
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,10 @@ def do_decode_psbt(b64psbt):
return from_binary(CBlock, psbt.g.map[PSBT_SIGNET_BLOCK]), ser_string(scriptSig) + scriptWitness

def finish_block(block, signet_solution, grind_cmd):
block.vtx[0].vout[-1].scriptPubKey += CScriptOp.encode_op_pushdata(SIGNET_HEADER + signet_solution)
block.vtx[0].rehash()
block.hashMerkleRoot = block.calc_merkle_root()
if signet_solution is not None:
block.vtx[0].vout[-1].scriptPubKey += CScriptOp.encode_op_pushdata(SIGNET_HEADER + signet_solution)
block.vtx[0].rehash()
block.hashMerkleRoot = block.calc_merkle_root()
if grind_cmd is None:
block.solve()
else:
Expand All @@ -110,10 +111,12 @@ def finish_block(block, signet_solution, grind_cmd):
block.rehash()
return block

def generate_psbt(tmpl, reward_spk, *, blocktime=None):
signet_spk = tmpl["signet_challenge"]
def generate_psbt(block, signet_spk):
signet_spk_bin = bytes.fromhex(signet_spk)
signme, spendme = signet_txs(block, signet_spk_bin)
return do_createpsbt(block, signme, spendme)

def new_block(tmpl, reward_spk, blocktime=None):
cbtx = create_coinbase(height=tmpl["height"], value=tmpl["coinbasevalue"], spk=reward_spk)
cbtx.vin[0].nSequence = 2**32-2
cbtx.rehash()
Expand All @@ -135,9 +138,10 @@ def generate_psbt(tmpl, reward_spk, *, blocktime=None):
block.vtx[0].wit.vtxinwit = [cbwit]
block.vtx[0].vout.append(CTxOut(0, bytes(get_witness_script(witroot, witnonce))))

signme, spendme = signet_txs(block, signet_spk_bin)
block.vtx[0].rehash()
block.hashMerkleRoot = block.calc_merkle_root()

return do_createpsbt(block, signme, spendme)
return block

def get_reward_address(args, height):
if args.address is not None:
Expand Down Expand Up @@ -177,8 +181,10 @@ def get_reward_addr_spk(args, height):

def do_genpsbt(args):
tmpl = json.load(sys.stdin)
signet_spk = tmpl["signet_challenge"]
_, reward_spk = get_reward_addr_spk(args, tmpl["height"])
psbt = generate_psbt(tmpl, reward_spk)
block = new_block(tmpl, reward_spk)
psbt = generate_psbt(block, signet_spk)
print(psbt)

def do_solvepsbt(args):
Expand Down Expand Up @@ -407,14 +413,23 @@ def do_generate(args):
# mine block
logging.debug("Mining block delta=%s start=%s mine=%s", seconds_to_hms(mine_time-bestheader["time"]), mine_time, is_mine)
mined_blocks += 1
psbt = generate_psbt(tmpl, reward_spk, blocktime=mine_time)
input_stream = os.linesep.join([psbt, "true", "ALL"]).encode('utf8')
psbt_signed = json.loads(args.bcli("-stdin", "walletprocesspsbt", input=input_stream))
if not psbt_signed.get("complete",False):
logging.debug("Generated PSBT: %s" % (psbt,))
sys.stderr.write("PSBT signing failed\n")
return 1
block, signet_solution = do_decode_psbt(psbt_signed["psbt"])
block = new_block(tmpl, reward_spk, blocktime=mine_time)

# BIP325 allows omitting the signet commitment when scriptSig and
# scriptWitness are both empty. This is the case for trivial
# challenges such as OP_TRUE
signet_solution = None
signet_spk = tmpl["signet_challenge"]
if signet_spk != "51":
psbt = generate_psbt(block, signet_spk)
input_stream = os.linesep.join([psbt, "true", "ALL"]).encode('utf8')
psbt_signed = json.loads(args.bcli("-stdin", "walletprocesspsbt", input=input_stream))
if not psbt_signed.get("complete",False):
logging.debug("Generated PSBT: %s" % (psbt,))
sys.stderr.write("PSBT signing failed\n")
return 1
block, signet_solution = do_decode_psbt(psbt_signed["psbt"])

block = finish_block(block, signet_solution, args.grind_cmd)

# submit block
Expand Down
Loading
0