Skip to content
Open
16 changes: 14 additions & 2 deletions .github/scripts/install-bitcoind.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/sh
# If an argument is specified, that dir is checked before downloading,
# and updated after successful install.

set -e

Expand All @@ -18,13 +20,23 @@ cd /tmp/
# testing against `bitcoind` but still believe that we ran against
# `elementsd`.
if [ "$TEST_NETWORK" = "liquid-regtest" ]; then
wget "https://github.com/ElementsProject/elements/releases/download/elements-${ELEMENTS_VERSION}/${EFILENAME}"
if [ -f "$1/${EFILENAME}" ]; then
cp "$1/${EFILENAME}" .
else
wget "https://github.com/ElementsProject/elements/releases/download/elements-${ELEMENTS_VERSION}/${EFILENAME}"
fi
tar -xf "${EFILENAME}"
[ "$1" = "" ] || cp "${EFILENAME}" "$1"/
sudo mv "${EDIRNAME}"/bin/* "/usr/local/bin"
rm -rf "${EFILENAME}" "${EDIRNAME}"
else
wget "https://bitcoincore.org/bin/bitcoin-core-${BITCOIN_VERSION}/${FILENAME}"
if [ -f "$1/${FILENAME}" ]; then
cp "$1/${FILENAME}" .
else
wget "https://bitcoincore.org/bin/bitcoin-core-${BITCOIN_VERSION}/${FILENAME}"
fi
tar -xf "${FILENAME}"
[ "$1" = "" ] || cp "${FILENAME}" "$1"/
sudo mv "${DIRNAME}"/bin/* "/usr/local/bin"
rm -rf "${FILENAME}" "${DIRNAME}"
fi
Expand Down
30 changes: 23 additions & 7 deletions .github/scripts/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,26 @@ set -e
export DEBIAN_FRONTEND=noninteractive
export RUST_VERSION=stable

sudo useradd -ms /bin/bash tester
sudo apt-get update -qq
sudo mkdir -p /var/cache/apt/archives
mkdir -p ~/ci-cache/apt/
sudo cp -a ~/ci-cache/apt/. /var/cache/apt/archives/ 2>/dev/null || true

sudo apt-get -qq install --no-install-recommends --allow-unauthenticated -yy \
sudo apt-get update

# Install eatmydata, then use it for the rest.
sudo apt-get install --no-install-recommends --allow-unauthenticated -yy \
-o APT::Keep-Downloaded-Packages=true \
eatmydata

sudo eatmydata apt-get install --no-install-recommends --allow-unauthenticated -yy \
-o APT::Keep-Downloaded-Packages=true \
autoconf \
automake \
binfmt-support \
build-essential \
clang \
cppcheck \
docbook-xml \
eatmydata \
gcc-aarch64-linux-gnu \
gcc-arm-linux-gnueabihf \
gcc-arm-none-eabi \
Expand Down Expand Up @@ -64,7 +72,7 @@ sudo apt-get -qq install --no-install-recommends --allow-unauthenticated -yy \
echo "tester ALL=(root) NOPASSWD:ALL" | sudo tee /etc/sudoers.d/tester
sudo chmod 0440 /etc/sudoers.d/tester

"$(dirname "$0")"/install-bitcoind.sh
"$(dirname "$0")"/install-bitcoind.sh ~/ci-cache/

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- \
-y --default-toolchain ${RUST_VERSION}
Expand Down Expand Up @@ -92,8 +100,14 @@ uv tool install poetry

PROTOC_VERSION=29.4
PB_REL="https://github.com/protocolbuffers/protobuf/releases"
curl -LO $PB_REL/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-x86_64.zip
sudo unzip protoc-${PROTOC_VERSION}-linux-x86_64.zip -d /usr/local/
PROTOC_ZIP=protoc-${PROTOC_VERSION}-linux-x86_64.zip
if [ ! -f ~/ci-cache/$PROTOC_ZIP ]; then
curl -LO $PB_REL/download/v${PROTOC_VERSION}/$PROTOC_ZIP
# Check it before we commit it to the cache!
unzip -t $PROTOC_ZIP
cp $PROTOC_ZIP ~/ci-cache/
fi
sudo unzip ~/ci-cache/$PROTOC_ZIP -d /usr/local/
sudo chmod a+x /usr/local/bin/protoc
export PROTOC=/usr/local/bin/protoc
export PATH=$PATH:/usr/local/bin
Expand All @@ -110,3 +124,5 @@ sudo setcap cap_net_raw,cap_net_admin=eip /usr/bin/dumpcap
# Add ourselves to the wireshark group (still need "sg wireshark..." for it to take effect)
sudo usermod -aG wireshark "$(id -nu)"

# Copy archives back for caching
cp /var/cache/apt/archives/*.deb ~/ci-cache/apt/ || true
69 changes: 62 additions & 7 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ jobs:
- name: Install uv
uses: astral-sh/setup-uv@v5

- uses: actions/cache@v4
with:
path: ~/ci-cache
key: apt-${{ runner.os }}

- name: Install dependencies
env:
TEST_NETWORK: ${{ matrix.TEST_NETWORK }}
Expand Down Expand Up @@ -132,6 +137,7 @@ jobs:
- CFG: compile-clang
VALGRIND: 1
COMPILER: clang
COPTFLAGS_VAR: COPTFLAGS="-O3"
DEBUG_BUILD: --enable-debugbuild
- CFG: compile-clang-sanitizers
COMPILER: clang
Expand All @@ -152,6 +158,11 @@ jobs:
- name: Install uv
uses: astral-sh/setup-uv@v5

- uses: actions/cache@v4
with:
path: ~/ci-cache
key: apt-${{ runner.os }}

- name: Install dependencies
env:
TEST_NETWORK: ${{ matrix.TEST_NETWORK }}
Expand Down Expand Up @@ -202,6 +213,11 @@ jobs:
- name: Install uv
uses: astral-sh/setup-uv@v5

- uses: actions/cache@v4
with:
path: ~/ci-cache
key: apt-${{ runner.os }}

- name: Install dependencies
env:
TEST_NETWORK: ${{ matrix.TEST_NETWORK }}
Expand Down Expand Up @@ -262,6 +278,11 @@ jobs:
- name: Install uv
uses: astral-sh/setup-uv@v5

- uses: actions/cache@v4
with:
path: ~/ci-cache
key: apt-${{ runner.os }}

- name: Install dependencies
env:
TEST_NETWORK: ${{ matrix.TEST_NETWORK }}
Expand Down Expand Up @@ -307,6 +328,11 @@ jobs:
- name: Install uv
uses: astral-sh/setup-uv@v5

- uses: actions/cache@v4
with:
path: ~/ci-cache
key: apt-${{ runner.os }}

- name: Install dependencies
env:
TEST_NETWORK: ${{ matrix.TEST_NETWORK }}
Expand Down Expand Up @@ -355,6 +381,11 @@ jobs:
- name: Install uv
uses: astral-sh/setup-uv@v5

- uses: actions/cache@v4
with:
path: ~/ci-cache
key: apt-${{ runner.os }}

- name: Install dependencies
env:
TEST_NETWORK: ${{ matrix.TEST_NETWORK }}
Expand Down Expand Up @@ -441,6 +472,11 @@ jobs:
- name: Install uv
uses: astral-sh/setup-uv@v5

- uses: actions/cache@v4
with:
path: ~/ci-cache
key: apt-${{ runner.os }}

- name: Install dependencies
env:
TEST_NETWORK: ${{ matrix.TEST_NETWORK }}
Expand Down Expand Up @@ -535,6 +571,11 @@ jobs:
- name: Install uv
uses: astral-sh/setup-uv@v5

- uses: actions/cache@v4
with:
path: ~/ci-cache
key: apt-${{ runner.os }}

- name: Install dependencies
env:
TEST_NETWORK: ${{ matrix.TEST_NETWORK }}
Expand Down Expand Up @@ -610,13 +651,15 @@ jobs:
- name: Install uv
uses: astral-sh/setup-uv@v5

- uses: actions/cache@v4
with:
path: ~/ci-cache
key: apt-${{ runner.os }}

- name: Install dependencies
run: |
bash -x .github/scripts/setup.sh

- name: Install bitcoind
run: .github/scripts/install-bitcoind.sh

- name: Download build
uses: actions/download-artifact@v4
with:
Expand Down Expand Up @@ -672,6 +715,11 @@ jobs:
- name: Install uv
uses: astral-sh/setup-uv@v5

- uses: actions/cache@v4
with:
path: ~/ci-cache
key: apt-${{ runner.os }}

- name: Install dependencies
env:
TEST_NETWORK: ${{ matrix.TEST_NETWORK }}
Expand Down Expand Up @@ -729,13 +777,15 @@ jobs:
- name: Install uv
uses: astral-sh/setup-uv@v5

- uses: actions/cache@v4
with:
path: ~/ci-cache
key: apt-${{ runner.os }}

- name: Install dependencies
run: |
bash -x .github/scripts/setup.sh
- name: Install bitcoind
env:
TEST_NETWORK: regtest
run: .github/scripts/install-bitcoind.sh

- name: Download build
uses: actions/download-artifact@v4
with:
Expand Down Expand Up @@ -790,6 +840,11 @@ jobs:
- name: Install uv
uses: astral-sh/setup-uv@v5

- uses: actions/cache@v4
with:
path: ~/ci-cache
key: apt-${{ runner.os }}

- name: Install dependencies
env:
TEST_NETWORK: ${{ matrix.TEST_NETWORK }}
Expand Down
34 changes: 25 additions & 9 deletions channeld/channeld.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,18 @@ const u8 *hsm_req(const tal_t *ctx, const u8 *req TAKES)
return msg;
}

/* We're in STFU mode now: must not send messages. */
static bool is_stfu_active(const struct peer *peer)
{
return peer->stfu_sent[LOCAL] && peer->stfu_sent[REMOTE];
}

/* We're trying to enter STFU mode now: don't start *new* conversations */
static bool is_entering_stfu(const struct peer *peer)
{
return peer->want_stfu || peer->stfu_sent[LOCAL] || peer->stfu_sent[REMOTE];
}

static void end_stfu_mode(struct peer *peer)
{
peer->want_stfu = false;
Expand All @@ -231,10 +238,20 @@ static void end_stfu_mode(struct peer *peer)

static bool maybe_send_stfu(struct peer *peer)
{
struct htlc_map_iter it;
const struct htlc *htlc;

if (!peer->want_stfu)
return false;

if (pending_updates(peer->channel, LOCAL, false)) {
for (htlc = htlc_map_first(peer->channel->htlcs, &it);
htlc;
htlc = htlc_map_next(peer->channel->htlcs, &it)) {
status_info("maybe_send_stfu: htlc %"PRIu64" state %s",
htlc->id, htlc_state_name(htlc->state));
}

if (pending_updates(peer->channel, LOCAL)) {
status_info("Pending updates prevent us from STFU mode at this"
" time.");
return false;
Expand Down Expand Up @@ -297,7 +314,7 @@ static void handle_stfu(struct peer *peer, const u8 *stfu)
}

/* Sanity check */
if (pending_updates(peer->channel, REMOTE, false))
if (pending_updates(peer->channel, REMOTE))
peer_failed_warn(peer->pps, &peer->channel_id,
"STFU but you still have updates pending?");

Expand Down Expand Up @@ -343,7 +360,7 @@ static void handle_stfu(struct peer *peer, const u8 *stfu)
/* Returns true if we queued this for later handling (steals if true) */
static bool handle_master_request_later(struct peer *peer, const u8 *msg)
{
if (is_stfu_active(peer)) {
if (is_entering_stfu(peer)) {
msg_enqueue(peer->update_queue, take(msg));
return true;
}
Expand Down Expand Up @@ -1077,7 +1094,7 @@ static bool want_fee_update(const struct peer *peer, u32 *target)
return false;

/* No fee update while quiescing! */
if (peer->want_stfu || is_stfu_active(peer))
if (is_entering_stfu(peer))
return false;

current = channel_feerate(peer->channel, REMOTE);
Expand Down Expand Up @@ -1115,8 +1132,8 @@ static bool want_blockheight_update(const struct peer *peer, u32 *height)
if (peer->channel->lease_expiry == 0)
return false;

/* No fee update while quiescing! */
if (peer->want_stfu || is_stfu_active(peer))
/* No block update while quiescing! */
if (is_entering_stfu(peer))
return false;

/* What's the current blockheight */
Expand Down Expand Up @@ -1499,10 +1516,9 @@ static void send_commit(struct peer *peer)

static void send_commit_if_not_stfu(struct peer *peer)
{
if (!is_stfu_active(peer) && !peer->want_stfu) {
if (!peer->stfu_sent[LOCAL]) {
send_commit(peer);
}
else {
} else {
/* Timer now considered expired, you can add a new one. */
peer->commit_timer = NULL;
start_commit_timer(peer);
Expand Down
Loading
Loading