Skip to content

Commit 7420f68

Browse files
committed
Bitcoin 31.0
Due to laanwj's general delay in posting signatures these days, and in the spirit of the signatures being posted with users allowed to choose who to trust and to what thresholds, Serai now relies on a 2-of-3 scheme where: - If the signatures are present, they must be valid - At least two out of three acknowledged signers must be present - The acknowledged signers are laanwj, fanquake, and achow101 For the new fingerprints, I derived them myself from the keys present in the repository. I did find reference to fanquake's fingerprint in the example text for verifying a download of Bitcoin, so that should be correct. For achow101, I was able to find a Keybase proof stating the same fingerprint, and accordingly should also be correct. Also updated is the Foundry CI action and MacPorts (trivial).
1 parent 2d76726 commit 7420f68

4 files changed

Lines changed: 114 additions & 39 deletions

File tree

.github/actions/bitcoin/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ inputs:
55
version:
66
description: "Version to download and run"
77
required: false
8-
default: "30.2"
8+
default: "31.0"
99

1010
runs:
1111
using: "composite"

.github/actions/test-dependencies/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ inputs:
1010
bitcoin-version:
1111
description: "Bitcoin version to download and run as a regtest node"
1212
required: false
13-
default: "30.2"
13+
default: "31.0"
1414

1515
runs:
1616
using: "composite"
@@ -19,7 +19,7 @@ runs:
1919
uses: ./.github/actions/build-dependencies
2020

2121
- name: Install Foundry
22-
uses: foundry-rs/foundry-toolchain@8789b3e21e6c11b2697f5eb56eddae542f746c10 # 1.7.0
22+
uses: foundry-rs/foundry-toolchain@c7450ba673e133f5ee30098b3b54f444d3a2ca2d # 1.8.0
2323
with:
2424
version: v1.5.1
2525
cache: false

.github/workflows/stack-size.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ jobs:
7474
# macOS also has the benefit of packaging (via MacPorts) `mrsh`,
7575
# which explicitly attempts to be be exactly POSIX, without any extensions.
7676
# We first have to install MacPorts, the easiest method being from source.
77-
curl -O https://distfiles.macports.org/MacPorts/MacPorts-2.12.4.tar.bz2
78-
tar xf MacPorts-2.12.4.tar.bz2
79-
cd MacPorts-2.12.4
77+
curl -O https://distfiles.macports.org/MacPorts/MacPorts-2.12.5.tar.bz2
78+
tar xf MacPorts-2.12.5.tar.bz2
79+
cd MacPorts-2.12.5
8080
./configure
8181
make
8282
sudo make install

orchestration/src/networks/bitcoin.rs

Lines changed: 108 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
1+
use core::fmt::Write as _;
12
use std::path::Path;
23

34
use crate::{Network, Os, mimalloc, os, write_dockerfile};
45

56
pub fn bitcoin(orchestration_path: &Path, network: Network) {
6-
const VERSION: &str = "30.2";
7+
const VERSION: &str = "31.0";
78
let file = format!("bitcoin-{VERSION}-$(uname -m)-linux-gnu.tar.gz");
89
let url = format!("https://bitcoincore.org/bin/bitcoin-core-{VERSION}");
910

10-
// laanwj
11-
const FINGERPRINT: &str = "71A3B16735405025D447E8F274810B012346C9A6";
12-
1311
#[rustfmt::skip]
14-
let download_bitcoin = format!(r#"
12+
let mut download_bitcoin = format!(r#"
1513
FROM alpine:latest AS download
1614
1715
RUN apk --no-cache add git
@@ -23,49 +21,126 @@ RUN wget {url}/{file}
2321
RUN tar -xf "{file}"
2422
RUN mv $(find . -name bitcoind) .
2523
26-
# Download the hashes, signature from laanwj
24+
# Download the hashes, signatures
2725
RUN git clone --depth 1 https://github.com/bitcoin-core/guix.sigs
28-
RUN cp guix.sigs/{VERSION}/laanwj/all.SHA256SUMS SHA256SUMS
29-
RUN cp guix.sigs/{VERSION}/laanwj/all.SHA256SUMS.asc SHA256SUMS.asc
26+
"#);
3027

28+
let mut run_bitcoin_first = String::new();
29+
let mut run_bitcoin_second = r#"
30+
RUN <<'EOF'
31+
set -eux
32+
COUNT=0
33+
"#
34+
.to_owned();
35+
36+
let signers = [
37+
("laanwj", "71A3B16735405025D447E8F274810B012346C9A6"),
38+
("fanquake", "E777299FC265DD04793070EB944D35F9AC3DB76A"),
39+
("achow101", "152812300785C96444D3334D17565732E08E5E41"),
40+
];
41+
for (username, fingerprint) in signers {
42+
write!(
43+
&mut download_bitcoin,
44+
r#"
3145
# Verify `SHA256SUMS` with GnuPG
32-
FROM alpine:latest AS gnupg
46+
FROM alpine:latest AS gnupg-{username}
3347
RUN apk --no-cache add gnupg
3448
RUN mkdir ~/.gnupg # Prevent the default config of `use-keyboxd`
35-
COPY --from=download SHA256SUMS SHA256SUMS.asc /
36-
RUN gpg --keyserver hkps://keyserver.ubuntu.com --keyserver-options no-self-sigs-only --receive-keys {FINGERPRINT}
37-
RUN gpg --verify SHA256SUMS.asc SHA256SUMS
38-
RUN touch /tmp/done
49+
COPY --from=download guix.sigs /guix.sigs
50+
RUN <<'EOF'
51+
set -eux
52+
mkdir -p /tmp
53+
if [ ! -d "/guix.sigs/{VERSION}/{username}" ]; then exit 0; fi
54+
55+
cp guix.sigs/{VERSION}/{username}/all.SHA256SUMS SHA256SUMS
56+
cp guix.sigs/{VERSION}/{username}/all.SHA256SUMS.asc SHA256SUMS.asc
57+
gpg --keyserver hkps://keyserver.ubuntu.com --keyserver-options no-self-sigs-only \
58+
--receive-keys {fingerprint}
59+
gpg --verify SHA256SUMS.asc SHA256SUMS
60+
touch /tmp/gnupg-{username}
61+
EOF
3962
4063
# Verify `SHA256SUMS` with Sequoia PGP
41-
FROM alpine:latest AS sequoia
64+
FROM alpine:latest AS sequoia-{username}
4265
RUN apk --no-cache add sequoia-sq
43-
COPY --from=download SHA256SUMS SHA256SUMS.asc /
44-
RUN sq network keyserver search --server hkps://keyserver.ubuntu.com {FINGERPRINT}
45-
RUN sq pki link add --cert {FINGERPRINT} --all
46-
RUN sq verify --signature-file SHA256SUMS.asc SHA256SUMS
47-
RUN touch /tmp/done
66+
COPY --from=download guix.sigs /guix.sigs
67+
RUN <<'EOF'
68+
set -eux
69+
mkdir -p /tmp
70+
if [ ! -d "/guix.sigs/{VERSION}/{username}" ]; then exit 0; fi
71+
72+
cp guix.sigs/{VERSION}/{username}/all.SHA256SUMS SHA256SUMS
73+
cp guix.sigs/{VERSION}/{username}/all.SHA256SUMS.asc SHA256SUMS.asc
74+
sq network keyserver search --server hkps://keyserver.ubuntu.com {fingerprint}
75+
sq pki link add --cert {fingerprint} --all
76+
sq verify --signature-file SHA256SUMS.asc SHA256SUMS
77+
touch /tmp/sequoia-{username}
78+
EOF
4879
4980
# Verify the integrity of `bitcoin-*.tar.gz` with regards to the `SHA256SUMS` file
50-
FROM alpine:latest AS sha256sum
51-
COPY --from=download *.tar.gz SHA256SUMS /
52-
# Parse to just the hash for the one file we downloaded
53-
RUN echo $(grep "{file}" SHA256SUMS) > SHA256SUMS
54-
# Ensure we successfully grabbed the line in question
55-
RUN if [ $(wc -l SHA256SUMS) -ne 1 ]; then exit 1; fi
56-
RUN cat SHA256SUMS | sha256sum -c
57-
RUN touch /tmp/done
58-
"#);
81+
FROM alpine:latest AS sha256sum-{username}
82+
COPY --from=download *.tar.gz /
83+
COPY --from=download guix.sigs /guix.sigs
84+
RUN <<'EOF'
85+
set -eux
86+
mkdir -p /tmp
87+
if [ ! -d "/guix.sigs/{VERSION}/{username}" ]; then exit 0; fi
88+
89+
cp guix.sigs/{VERSION}/{username}/all.SHA256SUMS SHA256SUMS
90+
# Parse to just the hash for the one file we downloaded
91+
echo $(grep "{file}" SHA256SUMS) > SHA256SUMS
92+
# Ensure we successfully grabbed the line in question
93+
if [ $(wc -l SHA256SUMS) -ne 1 ]; then exit 1; fi
94+
cat SHA256SUMS | sha256sum -c
95+
touch /tmp/sha256sum-{username}
96+
EOF
97+
"#
98+
)
99+
.unwrap();
100+
101+
write!(
102+
&mut run_bitcoin_first,
103+
r#"
104+
# Require successful executions of the verification steps
105+
RUN mkdir -p /tmp
106+
# Use a wildcard to allow for if the file doesn't exist
107+
COPY --chown=bitcoin --from=gnupg-{username} /tmp/*gnupg-{username} /tmp/
108+
COPY --chown=bitcoin --from=sequoia-{username} /tmp/*sequoia-{username} /tmp/
109+
COPY --chown=bitcoin --from=sha256sum-{username} /tmp/*sha256sum-{username} /tmp/
110+
"#
111+
)
112+
.unwrap();
113+
114+
write!(
115+
&mut run_bitcoin_second,
116+
r#"
117+
if [ -f /tmp/gnupg-{username} ]; then
118+
if [ ! -f /tmp/sequoia-{username} ]; then exit 1; fi
119+
if [ ! -f /tmp/sha256sum-{username} ]; then exit 1; fi
120+
COUNT=$(( $COUNT + 1 ))
121+
fi
122+
"#
123+
)
124+
.unwrap();
125+
}
126+
127+
write!(
128+
&mut run_bitcoin_second,
129+
r#"
130+
if [ $COUNT -lt {} ]; then exit 1; fi
131+
rm -rf /tmp/*
132+
EOF
133+
"#,
134+
signers.len() - 1
135+
)
136+
.unwrap();
59137

60138
let setup = mimalloc(Os::Alpine, true) + &download_bitcoin;
61139

62140
let run_bitcoin = format!(
63141
r#"
64-
# Require successful executions of the verification steps
65-
COPY --from=sha256sum /tmp/done /tmp/done
66-
COPY --from=gnupg /tmp/done /tmp/done
67-
COPY --from=sequoia --chown=bitcoin /tmp/done /tmp/done
68-
RUN rm /tmp/done
142+
{run_bitcoin_first}
143+
{run_bitcoin_second}
69144
70145
COPY --from=download --chown=bitcoin bitcoind /usr/bin
71146

0 commit comments

Comments
 (0)