Skip to content
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

Add federated block-signing server implementation #4

Open
wants to merge 28 commits into
base: dvep
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
c4d3a12
[BlockSigner] Add block signer thread initialization code.
maaku Jul 13, 2021
cdae6ed
[BlockSigner] Add utility function for fetching wallet to use for blo…
maaku Aug 10, 2021
a93c459
[BlockSigner] Parse federation and block signer configuration options.
maaku Aug 9, 2021
daf40f3
[BlockSigner] Use the wallet to generate blocks at fixed intervals.
maaku Aug 3, 2021
bf079d1
[BlockSigner] Add 'blocksign' p2p message, and handshake protocol.
maaku Aug 10, 2021
0107ee1
[BlockSigner] Add peer-to-peer protocol for sharing block proposals, …
maaku Aug 10, 2021
826ca7f
[BlockSigner] Add script demonstrating how to use the federated block…
maaku Aug 11, 2021
79a9dcd
f '[BlockSigner] Parse federation and block signer configuration opti…
maaku Aug 21, 2021
b3a0ab9
f '[BlockSigner] Parse federation and block signer configuration opti…
maaku Aug 21, 2021
1da1bbb
f '[BlockSigner] Parse federation and block signer configuration opti…
maaku Aug 21, 2021
bf28ee6
f '[BlockSigner] Add script demonstrating how to use the federated bl…
maaku Aug 21, 2021
2817b6a
f '[BlockSigner] Parse federation and block signer configuration opti…
maaku Aug 21, 2021
fef2e4e
f '[BlockSigner] Parse federation and block signer configuration opti…
maaku Aug 21, 2021
2722026
f '[BlockSigner] Use the wallet to generate blocks at fixed intervals.'
maaku Aug 21, 2021
c4500a8
f '[BlockSigner] Use the wallet to generate blocks at fixed intervals.'
maaku Aug 21, 2021
910b875
f '[BlockSigner] Use the wallet to generate blocks at fixed intervals.'
maaku Aug 21, 2021
0c5d845
f '[BlockSigner] Add 'blocksign' p2p message, and handshake protocol.'
maaku Aug 21, 2021
6bb86db
f '[BlockSigner] Add 'blocksign' p2p message, and handshake protocol.'
maaku Aug 21, 2021
cb96642
f '[BlockSigner] Add peer-to-peer protocol for sharing block proposal…
maaku Aug 21, 2021
45a9dbd
f '[BlockSigner] Add 'blocksign' p2p message, and handshake protocol.'
maaku Aug 21, 2021
8efa38a
f '[BlockSigner] Add peer-to-peer protocol for sharing block proposal…
maaku Aug 21, 2021
8862190
f '[BlockSigner] Parse federation and block signer configuration opti…
maaku Aug 21, 2021
3c70538
[Mining] Explicitly record block height as part of CBlockTemplate str…
maaku Nov 16, 2021
cbae6d7
f '[BlockSigner] Use the wallet to generate blocks at fixed intervals.'
maaku Nov 16, 2021
9c375ba
[BlockSigner] Verify and store ACK signature from block proposal.
maaku Dec 6, 2021
ba4cc36
[ElementsRegtest] Add public parameters for block-signer elementsregt…
maaku Dec 6, 2021
8cc00bc
f '[ElementsRegtest] Add public parameters for block-signer elementsr…
maaku Dec 7, 2021
8a98f08
[BlockSigner] Ignore empty block proposals, exept every 15 minutes.
maaku Dec 7, 2021
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
96 changes: 96 additions & 0 deletions contrib/federation/blocksign.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#!/bin/bash

BIN=$(dirname $0)/../../src/elements

ADDR0=2dg8TR1BtYs1BJPLdjSpWnhDgadEDXxKRM7
PK0=02febf482b566f37b7b8a624e3bcb708ff745daa37389bcc381ea207efaa84d85c
SK0=cPpQ1dgHCiaPKmpCeuRBECfwaa5cJCj39n6j8vLmZ8ZgLJ6NQ4ce

ADDR1=2dmHcVLR9xCbCnkVGAAaJyps5Ak7hPkNEWu
PK1=039a70503f82b475f0388a0a187b4bef35f54d4e63e6ea235790f03ac070750b93
SK1=cStpof1xJ6yvGhxMmxKrJPfV8D8V8VGgftJPffyZk8eaJmFWZMFR

ADDR2=2dZwNCpB4xHqhexTavHdFXHjRRCLALpkYmm
PK2=022ceed2aa5b56abf6765135daf8970bd0be44e890d0b493eb6efb824be6c29197
SK2=cVNMk5uTaAFVRKQvEwSxd6hnuQdDoXJ5qpGsvVchmESuy6s9MPcd

# 2-of-3 multisig
SCRIPT=5221${PK0}21${PK1}21${PK2}53ae

TMP=/tmp/blocksign.$$
PORT0=38401
PORT1=38402
PORT2=38403
RPCPORT0=38501
RPCPORT1=38502
RPCPORT2=38503

echo Setting up nodes...
mkdir -p ${TMP}/node0
echo "validatepegin=0" > ${TMP}/node0/elements.conf
echo "con_signed_blocks=1" >> ${TMP}/node0/elements.conf
echo "signblockscript=${SCRIPT}" >> ${TMP}/node0/elements.conf
echo "con_max_block_sig_size=150" >> ${TMP}/node0/elements.conf
echo "con_dyna_deploy_start=9999999999" >> ${TMP}/node0/elements.conf
echo "blocksigner=1" >> ${TMP}/node0/elements.conf
echo "debug=federation" >> ${TMP}/node0/elements.conf
echo "debug=net" >> ${TMP}/node0/elements.conf
mkdir -p ${TMP}/node1
cp ${TMP}/node0/elements.conf \
${TMP}/node1/elements.conf
mkdir -p ${TMP}/node2
cp ${TMP}/node0/elements.conf \
${TMP}/node2/elements.conf
echo "elementsregtest.port=${PORT0}" >> ${TMP}/node0/elements.conf
echo "elementsregtest.port=${PORT1}" >> ${TMP}/node1/elements.conf
echo "elementsregtest.port=${PORT2}" >> ${TMP}/node2/elements.conf
echo "elementsregtest.rpcport=${RPCPORT0}" >> ${TMP}/node0/elements.conf
echo "elementsregtest.rpcport=${RPCPORT1}" >> ${TMP}/node1/elements.conf
echo "elementsregtest.rpcport=${RPCPORT2}" >> ${TMP}/node2/elements.conf

${BIN}d -datadir=${TMP}/node0 -chain=elementsregtest -daemon
${BIN}d -datadir=${TMP}/node1 -chain=elementsregtest -daemon
${BIN}d -datadir=${TMP}/node2 -chain=elementsregtest -daemon
sleep 1

echo Importing block-signing keys...
${BIN}-cli -datadir=${TMP}/node0 -chain=elementsregtest createwallet "" >/dev/null
${BIN}-cli -datadir=${TMP}/node0 -chain=elementsregtest importprivkey ${SK0}
${BIN}-cli -datadir=${TMP}/node0 -chain=elementsregtest stop

${BIN}-cli -datadir=${TMP}/node1 -chain=elementsregtest createwallet "" >/dev/null
${BIN}-cli -datadir=${TMP}/node1 -chain=elementsregtest importprivkey ${SK1}
${BIN}-cli -datadir=${TMP}/node1 -chain=elementsregtest stop

${BIN}-cli -datadir=${TMP}/node2 -chain=elementsregtest createwallet "" >/dev/null
${BIN}-cli -datadir=${TMP}/node2 -chain=elementsregtest importprivkey ${SK2}
${BIN}-cli -datadir=${TMP}/node2 -chain=elementsregtest stop
sleep 1

echo Connecting nodes...
echo "elementsregtest.blocksignnode=${PK1}:localhost:${PORT1}" >> ${TMP}/node0/elements.conf
echo "elementsregtest.blocksignnode=${PK2}:localhost:${PORT2}" >> ${TMP}/node0/elements.conf
echo "elementsregtest.blocksignnode=${PK0}:localhost:${PORT0}" >> ${TMP}/node1/elements.conf
echo "elementsregtest.blocksignnode=${PK2}:localhost:${PORT2}" >> ${TMP}/node1/elements.conf
echo "elementsregtest.blocksignnode=${PK0}:localhost:${PORT0}" >> ${TMP}/node2/elements.conf
echo "elementsregtest.blocksignnode=${PK1}:localhost:${PORT1}" >> ${TMP}/node2/elements.conf

echo "Watching logs..."
${BIN}d -datadir=${TMP}/node0 -chain=elementsregtest -daemon
${BIN}d -datadir=${TMP}/node1 -chain=elementsregtest -daemon
${BIN}d -datadir=${TMP}/node2 -chain=elementsregtest -daemon

xtail ${TMP}/node{0,1,2}/elementsregtest/debug.log

echo ""
echo "Cleaning up..."

${BIN}-cli -datadir=${TMP}/node0 -chain=elementsregtest stop
${BIN}-cli -datadir=${TMP}/node1 -chain=elementsregtest stop
${BIN}-cli -datadir=${TMP}/node2 -chain=elementsregtest stop
sleep 1
rm -rf ${TMP}

echo "Done!"

# End of File
2 changes: 2 additions & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ BITCOIN_CORE_H = \
cuckoocache.h \
dbwrapper.h \
dynafed.h \
federation.h \
flatfile.h \
fs.h \
httprpc.h \
Expand Down Expand Up @@ -310,6 +311,7 @@ libbitcoin_server_a_SOURCES = \
consensus/tx_verify.cpp \
dynafed.cpp \
dbwrapper.cpp \
federation.cpp \
flatfile.cpp \
httprpc.cpp \
httpserver.cpp \
Expand Down
Loading