mirror of
https://github.com/bitcoin/bips.git
synced 2026-03-09 15:53:54 +00:00
BIP360: Pay to Merkle Root (P2MR) (#1670)
Review comments and assistance by: Armin Sabouri <armins88@gmail.com> D++ <82842780+dplusplus1024@users.noreply.github.com> Jameson Lopp <jameson.lopp@gmail.com> jbride <jbride2001@yahoo.com> Joey Yandle <xoloki@gmail.com> Jon Atack <jon@atack.com> Jonas Nick <jonasd.nick@gmail.com> Kyle Crews <kylecrews@Kyles-Mac-Studio.local> Mark "Murch" Erhardt <murch@murch.one> notmike-5 <notmike-5@users.noreply.github.com> Vojtěch Strnad <43024885+vostrnad@users.noreply.github.com> Co-authored-by: Ethan Heilman <ethan.r.heilman@gmail.com> Co-authored-by: Isabel Foxen Duke <110147802+Isabelfoxenduke@users.noreply.github.com>
This commit is contained in:
40
bip-0360/ref-impl/common/utils/signet_miner_loop.sh
Executable file
40
bip-0360/ref-impl/common/utils/signet_miner_loop.sh
Executable file
@@ -0,0 +1,40 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Invokes mining simulator a configurable number of times
|
||||
|
||||
if [ -z "${P2MR_ADDR}" ]; then
|
||||
echo "Error: Environment variable P2MR_ADDR needs to be set"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
BITCOIN_SOURCE_DIR=${BITCOIN_SOURCE_DIR:-$HOME/bitcoin}
|
||||
|
||||
# path to bitcoin.conf for signet
|
||||
BITCOIN_CONF_FILE_PATH=${BITCOIN_CONF_FILE_PATH:-$HOME/anduro-360/configs/bitcoin.conf.signet}
|
||||
|
||||
# Set default LOOP_COUNT to 110 if not set
|
||||
LOOP_COUNT=${LOOP_COUNT:-110}
|
||||
|
||||
# Validate LOOP_COUNT is a positive integer
|
||||
if ! [[ "$LOOP_COUNT" =~ ^[0-9]+$ ]] || [ "$LOOP_COUNT" -le 0 ]; then
|
||||
echo "Error: LOOP_COUNT must be a positive integer"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Determine name of pool by querying mempool.space backend
|
||||
# curl -X GET "http://localhost:8999/api/v1/mining/pool/marapool" | jq -r .pool.regexes
|
||||
export POOL_ID=${POOL_ID:-"MARA Pool"}
|
||||
|
||||
echo -en "\nLoop_COUNT = $LOOP_COUNT\nBITCOIN_CONF_FILE_PATH=$BITCOIN_CONF_FILE_PATH\nBITCOIN_SOURCE_DIR=$BITCOIN_SOURCE_DIR\nPOOL_ID=$POOL_ID\n\n";
|
||||
|
||||
|
||||
for ((i=1; i<=LOOP_COUNT; i++))
|
||||
do
|
||||
echo "Iteration $i of $LOOP_COUNT"
|
||||
$BITCOIN_SOURCE_DIR/contrib/signet/miner --cli "bitcoin-cli -conf=$BITCOIN_CONF_FILE_PATH" generate \
|
||||
--address $P2MR_ADDR \
|
||||
--grind-cmd "$BITCOIN_SOURCE_DIR/build/bin/bitcoin-util grind" \
|
||||
--poolid "$POOL_ID" \
|
||||
--min-nbits --set-block-time $(date +%s)
|
||||
done
|
||||
88
bip-0360/ref-impl/common/utils/workshop/Dockerfile.bcli
Normal file
88
bip-0360/ref-impl/common/utils/workshop/Dockerfile.bcli
Normal file
@@ -0,0 +1,88 @@
|
||||
# podman build -f Dockerfile.bcli -t quay.io/jbride2000/p2mr_bcli:0.1 .
|
||||
# podman run -it --entrypoint /bin/bash quay.io/jbride200/p2mr_bcli:0.1
|
||||
|
||||
FROM rust:1-slim-bookworm AS builder
|
||||
|
||||
# Install build dependencies
|
||||
RUN apt-get update && apt-get install -y \
|
||||
build-essential \
|
||||
cmake \
|
||||
git \
|
||||
autoconf \
|
||||
automake \
|
||||
libtool \
|
||||
pkg-config \
|
||||
zlib1g-dev \
|
||||
libevent-dev \
|
||||
libboost-dev \
|
||||
libzmq3-dev \
|
||||
bash \
|
||||
python3 \
|
||||
python3-pip \
|
||||
libclang-dev \
|
||||
clang \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /bitcoin
|
||||
|
||||
# Copy Bitcoin Core source (or clone)
|
||||
# COPY . /bitcoin
|
||||
RUN git clone --branch p2mr-pqc --single-branch https://github.com/jbride/bitcoin.git
|
||||
|
||||
# Environment variables for musl
|
||||
ENV CC=gcc
|
||||
ENV CXX=g++
|
||||
|
||||
# Build Bitcoin Core
|
||||
WORKDIR bitcoin
|
||||
|
||||
RUN apt-get update && apt-get install -y libsqlite3-dev && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
RUN mkdir build && cd build && \
|
||||
cmake .. \
|
||||
-DWITH_ZMQ=ON \
|
||||
-DBUILD_BENCH=ON \
|
||||
-DBUILD_DAEMON=ON && \
|
||||
make -j$(nproc) bitcoin-cli
|
||||
|
||||
# Runtime stage with Debian Slim
|
||||
FROM debian:bookworm-slim
|
||||
|
||||
# Install minimal runtime dependencies
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
bash \
|
||||
ca-certificates \
|
||||
libevent-core-2.1-7 \
|
||||
libevent-pthreads-2.1-7 \
|
||||
libevent-extra-2.1-7 \
|
||||
libboost-filesystem1.74.0 \
|
||||
libboost-thread1.74.0 \
|
||||
libzmq5 \
|
||||
libsqlite3-0 \
|
||||
telnet \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Copy bitcoin-cli from builder
|
||||
COPY --from=builder /bitcoin/bitcoin/build/bin/bitcoin-cli /usr/local/bin/bitcoin-cli
|
||||
|
||||
# Create non-root user and set permissions
|
||||
RUN groupadd --system bip360 && \
|
||||
useradd --system --gid bip360 --shell /bin/bash --create-home bip360 && \
|
||||
chmod +x /usr/local/bin/bitcoin-cli && \
|
||||
ln -s /usr/local/bin/bitcoin-cli /usr/local/bin/b-cli && \
|
||||
echo 'b-cli() { /usr/local/bin/bitcoin-cli -rpcconnect=${RPC_CONNECT:-192.168.122.1} -rpcport=${RPC_PORT:-18443} -rpcuser=${RPC_USER:-signet} -rpcpassword=${RPC_PASSWORD:-signet} "$@"; }' >> /home/bip360/.bashrc
|
||||
|
||||
# Set default environment variables (can be overridden at runtime)
|
||||
ENV RPC_CONNECT=192.168.122.1 \
|
||||
RPC_PORT=38332 \
|
||||
RPC_USER=signet \
|
||||
RPC_PASSWORD=signet
|
||||
|
||||
# Switch to non-root user
|
||||
USER bip360
|
||||
|
||||
WORKDIR /home/bip360
|
||||
|
||||
ENTRYPOINT ["/usr/local/bin/bitcoin-cli"]
|
||||
|
||||
115
bip-0360/ref-impl/common/utils/workshop/Dockerfile.full
Normal file
115
bip-0360/ref-impl/common/utils/workshop/Dockerfile.full
Normal file
@@ -0,0 +1,115 @@
|
||||
# podman build -f Dockerfile.full -t quay.io/jbride2000/p2mr_demo:0.1 .
|
||||
# podman run -it --entrypoint /bin/bash quay.io/jbride2000/p2mr_demo:0.1
|
||||
|
||||
FROM rust:1-slim-bookworm AS builder
|
||||
|
||||
# Install build dependencies
|
||||
RUN apt-get update && apt-get install -y \
|
||||
build-essential \
|
||||
cmake \
|
||||
git \
|
||||
autoconf \
|
||||
automake \
|
||||
libtool \
|
||||
pkg-config \
|
||||
zlib1g-dev \
|
||||
libevent-dev \
|
||||
libboost-dev \
|
||||
libzmq3-dev \
|
||||
bash \
|
||||
python3 \
|
||||
python3-pip \
|
||||
libclang-dev \
|
||||
clang \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /bitcoin
|
||||
|
||||
# Copy Bitcoin Core source (or clone)
|
||||
# COPY . /bitcoin
|
||||
RUN git clone --branch p2mr-pqc --single-branch https://github.com/jbride/bitcoin.git
|
||||
|
||||
# Environment variables for musl
|
||||
ENV CC=gcc
|
||||
ENV CXX=g++
|
||||
|
||||
# Build Bitcoin Core
|
||||
WORKDIR bitcoin
|
||||
|
||||
RUN apt-get update && apt-get install -y libsqlite3-dev && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
RUN mkdir build && cd build && \
|
||||
cmake .. \
|
||||
-DWITH_ZMQ=ON \
|
||||
-DBUILD_BENCH=ON \
|
||||
-DBUILD_DAEMON=ON && \
|
||||
make -j$(nproc) bitcoin-cli
|
||||
|
||||
# Runtime stage with Debian Slim
|
||||
FROM rust:1-slim-bookworm
|
||||
|
||||
# Install minimal runtime dependencies
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
bash \
|
||||
ca-certificates \
|
||||
libevent-core-2.1-7 \
|
||||
libevent-pthreads-2.1-7 \
|
||||
libevent-extra-2.1-7 \
|
||||
libboost-filesystem1.74.0 \
|
||||
libboost-thread1.74.0 \
|
||||
libzmq5 \
|
||||
libsqlite3-0 \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Copy bitcoin-cli from builder
|
||||
COPY --from=builder /bitcoin/bitcoin/build/bin/bitcoin-cli /usr/local/bin/bitcoin-cli
|
||||
|
||||
# Create non-root user and set permissions
|
||||
RUN groupadd --system bip360 && \
|
||||
useradd --system --gid bip360 --shell /bin/bash --create-home bip360 && \
|
||||
chmod +x /usr/local/bin/bitcoin-cli && \
|
||||
ln -s /usr/local/bin/bitcoin-cli /usr/local/bin/b-cli && \
|
||||
echo 'b-cli() { /usr/local/bin/bitcoin-cli -rpcconnect=${RPC_CONNECT:-192.168.122.1} -rpcport=${RPC_PORT:-18443} -rpcuser=${RPC_USER:-signet} -rpcpassword=${RPC_PASSWORD:-signet} "$@"; }' >> /home/bip360/.bashrc
|
||||
|
||||
# Install additional tools needed for building Rust code (before switching to non-root user)
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
libclang-dev \
|
||||
clang \
|
||||
git \
|
||||
curl \
|
||||
cmake \
|
||||
build-essential \
|
||||
jq \
|
||||
gawk \
|
||||
telnet \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Set default environment variables (can be overridden at runtime)
|
||||
ENV RPC_CONNECT=192.168.122.1 \
|
||||
RPC_PORT=38332 \
|
||||
RPC_USER=signet \
|
||||
RPC_PASSWORD=signet
|
||||
|
||||
# Switch to non-root user
|
||||
USER bip360
|
||||
|
||||
WORKDIR /home/bip360
|
||||
|
||||
RUN git clone --no-checkout --depth 1 --branch p2mr-pqc \
|
||||
--single-branch https://github.com/jbride/bips.git bips && \
|
||||
cd bips && \
|
||||
git sparse-checkout init --cone && \
|
||||
git sparse-checkout set bip-0360 && \
|
||||
git checkout && \
|
||||
cd bip-0360/ref-impl/rust && \
|
||||
cargo build && \
|
||||
rm -rf target
|
||||
|
||||
WORKDIR /home/bip360/bips/bip-0360/ref-impl/rust
|
||||
|
||||
ENV BITCOIN_NETWORK=signet \
|
||||
USE_PQC=true
|
||||
|
||||
ENTRYPOINT ["/usr/local/bin/bitcoin-cli"]
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
<mxfile host="Electron" agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/26.1.1 Chrome/132.0.6834.210 Electron/34.3.3 Safari/537.36" version="26.1.1">
|
||||
<diagram name="Page-1" id="OP7udTXFU-9K02oCjO5S">
|
||||
<mxGraphModel dx="1098" dy="914" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
|
||||
<root>
|
||||
<mxCell id="0" />
|
||||
<mxCell id="1" parent="0" />
|
||||
</root>
|
||||
</mxGraphModel>
|
||||
</diagram>
|
||||
</mxfile>
|
||||
BIN
bip-0360/ref-impl/common/utils/workshop/signet_360.drawio.png
Normal file
BIN
bip-0360/ref-impl/common/utils/workshop/signet_360.drawio.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 80 KiB |
Reference in New Issue
Block a user