Merge branch 'distro' into protocol

# Conflicts:
#	version.go
This commit is contained in:
David Vennik
2023-01-17 11:13:59 +00:00
9 changed files with 1971 additions and 52 deletions

View File

@@ -36,30 +36,47 @@ var (
func strPtr(str string) *string { return &str }
var buildConfigurations = []docker.BuildConfiguration{
//docker.BuildConfiguration{
// Name: defaultRepositoryName + "/" + "btcd-base",
// ContextFilePath: "/tmp/btcd-base.tar",
// BuildOpts: types.ImageBuildOptions{
// Dockerfile: "docker/btcd/base.Dockerfile",
// Tags: []string{
// "v0.23.3",
// "latest",
// },
// BuildArgs: map[string]*string{
// "builder_image": strPtr(defaultBuildContainer),
// "source_release_url_prefix": strPtr("https://github.com/btcsuite/btcd"),
// "target_os": strPtr("linux"),
// "target_platform": strPtr("amd64"),
// "target_version": strPtr("v0.23.3"),
// },
// SuppressOutput: false,
// Remove: false,
// ForceRemove: false,
// PullParent: false,
// },
//},
docker.BuildConfiguration{
Name: defaultRepositoryName + "/" + "btcd",
ContextFilePath: "/tmp/btcd.tar",
BuildOpts: types.ImageBuildOptions{
Dockerfile: "docker/btcd/btcd.Dockerfile",
Tags: []string{
"v0.23.4",
"v0.23.3",
"latest",
},
BuildArgs: map[string]*string{
"base_image": strPtr(defaultBuildContainer),
"target_image": strPtr("indralabs/scratch:latest"),
// This argument is the tag fetched by git
// It MUST be updated alongside the tag above
"git_repository": strPtr("github.com/btcsuite/btcd"),
"git_tag": strPtr("v0.23.4"),
"btcd_version": strPtr("v0.23.3"),
"scratch_version": strPtr("latest"),
},
SuppressOutput: false,
Remove: true,
ForceRemove: true,
PullParent: true,
Remove: false,
ForceRemove: false,
PullParent: false,
},
},
docker.BuildConfiguration{
Name: defaultRepositoryName + "/" + "btcctl",
ContextFilePath: "/tmp/btcctl.tar",
@@ -70,11 +87,12 @@ var buildConfigurations = []docker.BuildConfiguration{
"latest",
},
BuildArgs: map[string]*string{
"semver": strPtr("v0.23.4"),
"btcd_version": strPtr("v0.23.3"),
"scratch_version": strPtr("latest"),
},
SuppressOutput: false,
Remove: true,
ForceRemove: true,
Remove: false,
ForceRemove: false,
PullParent: false,
},
},

View File

@@ -0,0 +1,59 @@
# ---
# Build Process
# ---
ARG builder_image="golang"
FROM indralabs/scratch:latest as config
FROM ${builder_image} AS builder
ARG source_release_url_prefix="https://github.com/btcsuite/btcd"
ARG target_os="linux"
ARG target_platform="amd64"
ARG target_version="v0.23.3"
WORKDIR /tmp
RUN set -ex echo "downloading source and binaries with manifest and signature." \
&& wget ${source_release_url_prefix}/releases/download/${target_version}/manifest-${target_version}.txt \
&& wget ${source_release_url_prefix}/releases/download/${target_version}/manifest-guggero-${target_version}.sig \
&& wget ${source_release_url_prefix}/releases/download/${target_version}/btcd-${target_os}-${target_platform}-${target_version}.tar.gz \
&& wget ${source_release_url_prefix}/releases/download/${target_version}/btcd-source-${target_version}.tar.gz
# Importing keys from scratch
COPY --from=config /etc/btcd/keys/guggero.asc /tmp/guggero.asc
RUN set -ex echo "importing keys" \
&& cat guggero.asc | gpg --import
RUN set -ex echo "running signature verification on manifest" \
&& gpg --verify manifest-guggero-${target_version}.sig manifest-${target_version}.txt
RUN set -ex echo "verifying checksum on btcd-${target_os}-${target_platform}-${target_version}.tar.gz" \
&& cat manifest-${target_version}.txt | grep btcd-${target_os}-${target_platform}-${target_version}.tar.gz | shasum -a 256 -c
#RUN set -ex echo "DEBUG: verifying a checksum failure stops the build" \
# && mv btcd-${target_os}-${target_platform}-${target_version}.tar.gz btcd-source-${target_version}.tar.gz
RUN set -ex echo "verifying checksum on btcd-source-${target_version}.tar.gz" \
&& cat manifest-${target_version}.txt | grep btcd-source-${target_version}.tar.gz | shasum -a 256 -c
RUN set -ex echo "untarring binaries and source code" \
&& mkdir -pv /tmp/btcd-${target_os}-${target_platform}-${target_version} \
&& tar -xzvf btcd-${target_os}-${target_platform}-${target_version}.tar.gz --directory /tmp/btcd-${target_os}-${target_platform}-${target_version} \
&& mkdir -pv /tmp/btcd-source-${target_version} \
&& tar -xzvf btcd-source-${target_version}.tar.gz --directory /tmp/btcd-source-${target_version}
WORKDIR /tmp/btcd-source-${target_version}
RUN set -ex echo "building binaries for ${GOOS}/${GOARCH}" \
&& mkdir -pv /tmp/bin \
&& GO111MODULE=on GOOS=${target_os} CGO_ENABLED=0 go build --ldflags '-w -s' -o /tmp/bin/btcd . \
&& GO111MODULE=on GOOS=${target_os} CGO_ENABLED=0 go build --ldflags '-w -s' -o /tmp/bin/ ./cmd/...
#RUN set -ex echo "moving btcd binary to /tmp/bin" \
# && mkdir -pv /tmp/bin \
# && cp /tmp/btcd-${target_os}-${target_platform}-${target_version}/btcd /tmp/bin

View File

@@ -1,6 +1,26 @@
ARG semver=master
# ---
# Build Process
# ---
FROM indralabs/btcd:${semver}
ARG btcd_version="latest"
ARG scratch_version="latest"
ENTRYPOINT ["/bin/btcctl", "--configfile=/etc/btcd/btcd.conf", "--rpccert=/etc/btcd/keys/rpc.cert"]
FROM indralabs/btcd-base:${btcd_version} as base
# ---
# Target Configuration
# ---
FROM indralabs/scratch:${scratch_version}
## Migrate the binaries and storage folder
COPY --from=base /tmp/bin/btcctl /bin
# Enable the btcd user
USER btcd:btcd
# Set the data volumes. Should be read-only.
#VOLUME ["/etc/btcd"]
ENTRYPOINT ["/bin/btcctl", "--configfile=/etc/btcd/btcd.conf"]

View File

@@ -1,47 +1,22 @@
ARG base_image="golang"
ARG target_image="indralabs/scratch"
# ---
# Build Process
# ---
FROM ${base_image} AS builder
ARG btcd_version="latest"
ARG scratch_version="latest"
# Get the repo and build
ARG git_repository="github.com/indra-labs/btcd"
ARG git_tag="master"
# Install dependencies and build the binaries.
RUN git clone "https://"${git_repository} /go/src/${git_repository}
WORKDIR $GOPATH/src/${git_repository}
RUN git checkout ${git_tag}
# Source/Target release defaults
ARG ARCH=amd64
ARG GOARCH=amd64
ENV GO111MODULE=on GOOS=linux
WORKDIR $GOPATH/src/${git_repository}
RUN cp sample-btcd.conf /tmp/btcd.conf
RUN set -ex \
&& CGO_ENABLED=0 go build --ldflags '-w -s' -o /tmp/bin/btcd . \
&& CGO_ENABLED=0 go build --ldflags '-w -s' -o /tmp/bin/ ./cmd/...
FROM indralabs/btcd-base:${btcd_version} as base
# ---
# Target Configuration
# ---
FROM indralabs/scratch:latest
FROM indralabs/scratch:${scratch_version}
## Migrate the binaries and storage folder
COPY --from=builder /tmp/btcd.conf /etc/btcd/btcd.conf
COPY --from=builder /tmp/bin /bin
COPY --from=base /tmp/bin/btcd /bin
COPY --from=base /tmp/bin/gencerts /bin
# Enable the btcd user
USER btcd:btcd
@@ -54,4 +29,4 @@ USER btcd:btcd
# :8334 btcd RPC port
EXPOSE 8333 8334
ENTRYPOINT ["/bin/btcd", "--configfile=/etc/btcd/btcd.conf", "--datadir=/var/btcd", "--logdir=/var/btcd", "--rpckey=/etc/btcd/keys/rpc.key", "--rpccert=/etc/btcd/keys/rpc.cert", "--listen=0.0.0.0:8333", "--rpclisten=0.0.0.0:8334"]
ENTRYPOINT ["/bin/btcd", "--configfile=/etc/btcd/btcd.conf"]

View File

@@ -0,0 +1,41 @@
version: '3'
services:
btcd:
image: indralabs/btcd
volumes:
- config:/etc/btcd
- data:/var/btcd
networks:
indranet:
ipv4_address: 172.16.42.2
command:
- "--rpcuser=simnet"
- "--rpcpass=simnet"
- "--simnet"
btcctl:
image: indralabs/btcctl
volumes:
- config:/etc/btcd:ro
networks:
indranet:
depends_on:
- btcd
command:
- "--rpcserver=172.16.42.2:8333"
- "--rpcuser=simnet"
- "--rpcpass=simnet"
- "--simnet"
- "getinfo"
volumes:
config:
data:
networks:
indranet:
driver: bridge
ipam:
driver: default
config:
- subnet: 172.16.42.0/24
gateway: 172.16.42.1
# docker-compose -f docker/btcd/docker-compose.yml up

View File

@@ -58,6 +58,21 @@ RUN set -ex && echo "adding and permissioning /etc directories" \
&& mkdir -pv /etc/lnd/keys && chmod 750 /etc/lnd/keys && chown lnd:lnd /etc/lnd/keys \
&& mkdir -pv /etc/indra && chmod 755 /etc/indra
RUN set -ex && echo "adding keys to verify btcd/lnd releases" \
&& wget https://raw.githubusercontent.com/lightningnetwork/lnd/master/scripts/keys/guggero.asc \
&& chmod 555 guggero.asc \
&& mv guggero.asc /etc/btcd/keys/ \
&& wget https://raw.githubusercontent.com/lightningnetwork/lnd/master/scripts/keys/roasbeef.asc \
&& chmod 555 roasbeef.asc \
&& mv roasbeef.asc /etc/lnd/keys/
ADD ./defaults/btcd.conf .
ADD ./defaults/lnd.conf .
RUN set -ex & echo "adding default .conf files" \
&& chmod 755 btcd.conf && mv btcd.conf /etc/btcd/ \
&& chmod 755 lnd.conf && mv lnd.conf /etc/lnd
RUN set -ex && echo "copying /etc directories to root filesystem" \
&& cp -rp /etc/btcd /tmp/root-fs/etc/btcd \
&& cp -rp /etc/lnd /tmp/root-fs/etc/lnd \

View File

@@ -1,9 +1,9 @@
#!/bin/bash
docker build -t indralabs/scratch-builder .
docker build -t indralabs/scratch-builder ./docker/scratch/.
docker run --rm -it --volume=${PWD}/tmp:/output indralabs/scratch-builder cp /tmp/root-fs.tgz /output
docker run --rm -it --volume=${PWD}/docker/scratch/tmp:/output indralabs/scratch-builder cp /tmp/root-fs.tgz /output
docker image import tmp/root-fs.tgz indralabs/scratch
docker image import ${PWD}/docker/scratch/tmp/root-fs.tgz indralabs/scratch
docker push indralabs/scratch:latest

View File

@@ -0,0 +1,354 @@
[Application Options]
; ------------------------------------------------------------------------------
; Data settings
; ------------------------------------------------------------------------------
; The directory to store data such as the block chain and peer addresses. The
; block chain takes several GB, so this location must have a lot of free space.
; The default is ~/.btcd/data on POSIX OSes, $LOCALAPPDATA/Btcd/data on Windows,
; ~/Library/Application Support/Btcd/data on Mac OS, and $home/btcd/data on
; Plan9. Environment variables are expanded so they may be used. NOTE: Windows
; environment variables are typically %VARIABLE%, but they must be accessed with
; $VARIABLE here. Also, ~ is expanded to $LOCALAPPDATA on Windows.
datadir=/var/btcd
logdir=/var/btcd
; ------------------------------------------------------------------------------
; Network settings
; ------------------------------------------------------------------------------
; Use testnet.
; testnet=1
; Connect via a SOCKS5 proxy. NOTE: Specifying a proxy will disable listening
; for incoming connections unless listen addresses are provided via the 'listen'
; option.
; proxy=127.0.0.1:9050
; proxyuser=
; proxypass=
; The SOCKS5 proxy above is assumed to be Tor (https://www.torproject.org).
; If the proxy is not tor the following may be used to prevent using tor
; specific SOCKS queries to lookup addresses (this increases anonymity when tor
; is used by preventing your IP being leaked via DNS).
; noonion=1
; Use an alternative proxy to connect to .onion addresses. The proxy is assumed
; to be a Tor node. Non .onion addresses will be contacted with the main proxy
; or without a proxy if none is set.
; onion=127.0.0.1:9051
; onionuser=
; onionpass=
; Enable Tor stream isolation by randomizing proxy user credentials resulting in
; Tor creating a new circuit for each connection. This makes it more difficult
; to correlate connections.
; torisolation=1
; Use Universal Plug and Play (UPnP) to automatically open the listen port
; and obtain the external IP address from supported devices. NOTE: This option
; will have no effect if exernal IP addresses are specified.
; upnp=1
; Specify the external IP addresses your node is listening on. One address per
; line. btcd will not contact 3rd-party sites to obtain external ip addresses.
; This means if you are behind NAT, your node will not be able to advertise a
; reachable address unless you specify it here or enable the 'upnp' option (and
; have a supported device).
; externalip=1.2.3.4
; externalip=2002::1234
; ******************************************************************************
; Summary of 'addpeer' versus 'connect'.
;
; Only one of the following two options, 'addpeer' and 'connect', may be
; specified. Both allow you to specify peers that you want to stay connected
; with, but the behavior is slightly different. By default, btcd will query DNS
; to find peers to connect to, so unless you have a specific reason such as
; those described below, you probably won't need to modify anything here.
;
; 'addpeer' does not prevent connections to other peers discovered from
; the peers you are connected to and also lets the remote peers know you are
; available so they can notify other peers they can to connect to you. This
; option might be useful if you are having problems finding a node for some
; reason (perhaps due to a firewall).
;
; 'connect', on the other hand, will ONLY connect to the specified peers and
; no others. It also disables listening (unless you explicitly set listen
; addresses via the 'listen' option) and DNS seeding, so you will not be
; advertised as an available peer to the peers you connect to and won't accept
; connections from any other peers. So, the 'connect' option effectively allows
; you to only connect to "trusted" peers.
; ******************************************************************************
; Add persistent peers to connect to as desired. One peer per line.
; You may specify each IP address with or without a port. The default port will
; be added automatically if one is not specified here.
; addpeer=192.168.1.1
; addpeer=10.0.0.2:8333
; addpeer=fe80::1
; addpeer=[fe80::2]:8333
; Add persistent peers that you ONLY want to connect to as desired. One peer
; per line. You may specify each IP address with or without a port. The
; default port will be added automatically if one is not specified here.
; NOTE: Specifying this option has other side effects as described above in
; the 'addpeer' versus 'connect' summary section.
; connect=192.168.1.1
; connect=10.0.0.2:8333
; connect=fe80::1
; connect=[fe80::2]:8333
; Maximum number of inbound and outbound peers.
; maxpeers=125
; Disable banning of misbehaving peers.
; nobanning=1
; Maximum allowed ban score before disconnecting and banning misbehaving peers.
; banthreshold=100
; How long to ban misbehaving peers. Valid time units are {s, m, h}.
; Minimum 1s.
; banduration=24h
; banduration=11h30m15s
; Add whitelisted IP networks and IPs. Connected peers whose IP matches a
; whitelist will not have their ban score increased.
; whitelist=127.0.0.1
; whitelist=::1
; whitelist=192.168.0.0/24
; whitelist=fd00::/16
; Disable DNS seeding for peers. By default, when btcd starts, it will use
; DNS to query for available peers to connect with.
; nodnsseed=1
; Specify the interfaces to listen on. One listen address per line.
; NOTE: The default port is modified by some options such as 'testnet', so it is
; recommended to not specify a port and allow a proper default to be chosen
; unless you have a specific reason to do otherwise.
; All interfaces on default port (this is the default):
; listen=
; All ipv4 interfaces on default port:
listen=0.0.0.0:8333
; All ipv6 interfaces on default port:
; listen=::
; All interfaces on port 8333:
; listen=:8333
; All ipv4 interfaces on port 8333:
; listen=0.0.0.0:8333
; All ipv6 interfaces on port 8333:
; listen=[::]:8333
; Only ipv4 localhost on port 8333:
; listen=127.0.0.1:8333
; Only ipv6 localhost on port 8333:
; listen=[::1]:8333
; Only ipv4 localhost on non-standard port 8336:
; listen=127.0.0.1:8336
; All interfaces on non-standard port 8336:
; listen=:8336
; All ipv4 interfaces on non-standard port 8336:
; listen=0.0.0.0:8336
; All ipv6 interfaces on non-standard port 8336:
; listen=[::]:8336
; Disable listening for incoming connections. This will override all listeners.
; nolisten=1
; Disable peer bloom filtering. See BIP0111.
; nopeerbloomfilters=1
; Add additional checkpoints. Format: '<height>:<hash>'
; addcheckpoint=<height>:<hash>
; Add comments to the user agent that is advertised to peers.
; Must not include characters '/', ':', '(' and ')'.
; uacomment=
; Disable committed peer filtering (CF).
; nocfilters=1
; ------------------------------------------------------------------------------
; RPC server options - The following options control the built-in RPC server
; which is used to control and query information from a running btcd process.
;
; NOTE: The RPC server is disabled by default if rpcuser AND rpcpass, or
; rpclimituser AND rpclimitpass, are not specified.
; ------------------------------------------------------------------------------
rpckey=/etc/btcd/keys/rpc.key
rpccert=/etc/btcd/keys/rpc.cert
; Secure the RPC API by specifying the username and password. You can also
; specify a limited username and password. You must specify at least one
; full set of credentials - limited or admin - or the RPC server will
; be disabled.
; rpcuser=whatever_admin_username_you_want
; rpcpass=
; rpclimituser=whatever_limited_username_you_want
; rpclimitpass=
; Specify the interfaces for the RPC server listen on. One listen address per
; line. NOTE: The default port is modified by some options such as 'testnet',
; so it is recommended to not specify a port and allow a proper default to be
; chosen unless you have a specific reason to do otherwise. By default, the
; RPC server will only listen on localhost for IPv4 and IPv6.
; All interfaces on default port:
; rpclisten=
; All ipv4 interfaces on default port:
rpclisten=0.0.0.0:8334
; All ipv6 interfaces on default port:
; rpclisten=::
; All interfaces on port 8334:
; rpclisten=:8334
; All ipv4 interfaces on port 8334:
; rpclisten=0.0.0.0:8334
; All ipv6 interfaces on port 8334:
; rpclisten=[::]:8334
; Only ipv4 localhost on port 8334:
; rpclisten=127.0.0.1:8334
; Only ipv6 localhost on port 8334:
; rpclisten=[::1]:8334
; Only ipv4 localhost on non-standard port 8337:
; rpclisten=127.0.0.1:8337
; All interfaces on non-standard port 8337:
; rpclisten=:8337
; All ipv4 interfaces on non-standard port 8337:
; rpclisten=0.0.0.0:8337
; All ipv6 interfaces on non-standard port 8337:
; rpclisten=[::]:8337
; Specify the maximum number of concurrent RPC clients for standard connections.
; rpcmaxclients=10
; Specify the maximum number of concurrent RPC websocket clients.
; rpcmaxwebsockets=25
; Mirror some JSON-RPC quirks of Bitcoin Core -- NOTE: Discouraged unless
; interoperability issues need to be worked around
; rpcquirks=1
; Use the following setting to disable the RPC server even if the rpcuser and
; rpcpass are specified above. This allows one to quickly disable the RPC
; server without having to remove credentials from the config file.
; norpc=1
; Use the following setting to disable TLS for the RPC server. NOTE: This
; option only works if the RPC server is bound to localhost interfaces (which is
; the default).
; notls=1
; ------------------------------------------------------------------------------
; Mempool Settings - The following options
; ------------------------------------------------------------------------------
; Set the minimum transaction fee to be considered a non-zero fee,
; minrelaytxfee=0.00001
; Rate-limit free transactions to the value 15 * 1000 bytes per
; minute.
; limitfreerelay=15
; Require high priority for relaying free or low-fee transactions.
; norelaypriority=0
; Limit orphan transaction pool to 100 transactions.
; maxorphantx=100
; Do not accept transactions from remote peers.
; blocksonly=1
; Relay non-standard transactions regardless of default network settings.
; relaynonstd=1
; Reject non-standard transactions regardless of default network settings.
; rejectnonstd=1
; ------------------------------------------------------------------------------
; Optional Indexes
; ------------------------------------------------------------------------------
; Build and maintain a full hash-based transaction index which makes all
; transactions available via the getrawtransaction RPC.
; txindex=1
; Build and maintain a full address-based transaction index which makes the
; searchrawtransactions RPC available.
; addrindex=1
; Delete the entire address index on start up, then exit.
; dropaddrindex=0
; ------------------------------------------------------------------------------
; Signature Verification Cache
; ------------------------------------------------------------------------------
; Limit the signature cache to a max of 50000 entries.
; sigcachemaxsize=50000
; ------------------------------------------------------------------------------
; Coin Generation (Mining) Settings - The following options control the
; generation of block templates used by external mining applications through RPC
; calls as well as the built-in CPU miner (if enabled).
; ------------------------------------------------------------------------------
; Enable built-in CPU mining.
;
; NOTE: This is typically only useful for testing purposes such as testnet or
; simnet since the difficulty on mainnet is far too high for CPU mining to be
; worth your while.
; generate=false
; Add addresses to pay mined blocks to for CPU mining and potentially in the
; block templates generated for the getblocktemplate RPC. One address per line.
; miningaddr=1yourbitcoinaddress
; miningaddr=1yourbitcoinaddress2
; miningaddr=1yourbitcoinaddress3
; Specify the minimum block size in bytes to create. By default, only
; transactions which have enough fees or a high enough priority will be included
; in generated block templates. Specifying a minimum block size will instead
; attempt to fill generated block templates up with transactions until it is at
; least the specified number of bytes.
; blockminsize=0
; Specify the maximum block size in bytes to create. This value will be limited
; to the consensus limit if it is larger than that value.
; blockmaxsize=750000
; Specify the size in bytes of the high-priority/low-fee area when creating a
; block. Transactions which consist of large amounts, old inputs, and small
; sizes have the highest priority. One consequence of this is that as low-fee
; or free transactions age, they raise in priority thereby making them more
; likely to be included in this section of a new block. This value is limited
; by the blockmaxsize option and will be limited as needed.
; blockprioritysize=50000
; ------------------------------------------------------------------------------
; Debug
; ------------------------------------------------------------------------------
; Debug logging level.
; Valid levels are {trace, debug, info, warn, error, critical}
; You may also specify <subsystem>=<level>,<subsystem2>=<level>,... to set
; log level for individual subsystems. Use btcd --debuglevel=show to list
; available subsystems.
; debuglevel=info
; The port used to listen for HTTP profile requests. The profile server will
; be disabled if this option is not specified. The profile information can be
; accessed at http://localhost:<profileport>/debug/pprof once running.
; profile=6061

File diff suppressed because it is too large Load Diff