diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml new file mode 100644 index 00000000..ac98d114 --- /dev/null +++ b/.github/workflows/create-release.yml @@ -0,0 +1,58 @@ +name: Create release +on: + workflow_dispatch: + inputs: + note: + description: 'Note' + required: false + default: '' + +jobs: + build: + strategy: + matrix: + go: [1.16] + os: [linux, darwin, windows] + ar: [amd64, arm64] + exclude: + - go: 1.16 + os: windows + ar: arm64 + runs-on: ubuntu-latest + steps: + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: ${{ matrix.go }} + - name: Checkout source + uses: actions/checkout@v2 + - name: Build executables + env: + GOOS: ${{ matrix.os }} + GOARCH: ${{ matrix.ar }} + CGO_ENABLED: 0 + run: | + go build -trimpath -ldflags="-s -w -buildid=" -v -o artifacts/ . + go build -trimpath -ldflags="-s -w -buildid=" -v -o artifacts/ ./cmd/lbcctl/ + - name: SHA256 sum + run: sha256sum -b artifacts/* > artifacts/lbcd.sha256 + - name: Upload artifacts + uses: actions/upload-artifact@v2 + with: + name: lbcd-${{ matrix.os }}-${{ matrix.ar }} + path: artifacts/* + + +# for releases see https://trstringer.com/github-actions-create-release-upload-artifacts/ + +# AWS S3 support: +# - name: Upload to Amazon S3 +# uses: ItsKarma/aws-cli@v1.70.0 +# with: +# args: s3 sync .release s3://my-bucket-name +# env: +# # Make sure to add the secrets in the repo settings page +# # AWS_REGION is set to us-east-1 by default +# AWS_ACCESS_KEY_ID: $ +# AWS_SECRET_ACCESS_KEY: $ +# AWS_REGION: us-east-1 diff --git a/.github/workflows/full-sync-part-1.yml b/.github/workflows/full-sync-part-1.yml index 27b88567..8a52fa30 100644 --- a/.github/workflows/full-sync-part-1.yml +++ b/.github/workflows/full-sync-part-1.yml @@ -14,7 +14,7 @@ jobs: runs-on: self-hosted strategy: matrix: - go: [1.17.3] + go: [1.16] steps: - run: | echo "Note ${{ github.event.inputs.note }}!" diff --git a/.github/workflows/full-sync-part-2.yml b/.github/workflows/full-sync-part-2.yml index ab0309fb..844bb1f1 100644 --- a/.github/workflows/full-sync-part-2.yml +++ b/.github/workflows/full-sync-part-2.yml @@ -14,11 +14,11 @@ jobs: runs-on: self-hosted strategy: matrix: - go: [1.17.3] + go: [1.16] steps: - run: | echo "Note ${{ github.event.inputs.note }}!" - - name: Setup Go + - name: Set up Go uses: actions/setup-go@v2 with: go-version: ${{ matrix.go }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 92cffcc4..00000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,48 +0,0 @@ -name: goreleaser - -on: - workflow_dispatch: - inputs: - note: - description: 'Note' - required: false - default: '' - pull_request: - push: - tags: - - '*' - -permissions: - contents: write - -jobs: - goreleaser: - runs-on: ubuntu-latest - steps: - - - name: Checkout - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Set up Go - uses: actions/setup-go@v2 - with: - go-version: 1.17.3 - - - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v2 - with: - distribution: goreleaser - version: latest - args: release --rm-dist - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Upload artifacts - uses: actions/upload-artifact@v2 - with: - name: lbcd-${{ github.sha }} - path: | - dist/checksums.txt - dist/*.tar.gz diff --git a/.gitignore b/.gitignore index 11125e86..749bb6b3 100644 --- a/.gitignore +++ b/.gitignore @@ -49,6 +49,3 @@ btcd btcctl lbcd lbcctl - -# CI artifacts -dist diff --git a/.goreleaser.yml b/.goreleaser.yml deleted file mode 100644 index db30c7fe..00000000 --- a/.goreleaser.yml +++ /dev/null @@ -1,57 +0,0 @@ -# This is an example .goreleaser.yml file with some sensible defaults. -# Make sure to check the documentation at https://goreleaser.com -before: - hooks: - # You may remove this if you don't use go modules. - - go mod tidy - # you may remove this if you don't need go generate - - go generate ./... -builds: - - - main: . - id: "lbcd" - binary: "lbcd" - env: - - CGO_ENABLED=0 - flags: - - -trimpath - ldflags: - - -s -w - - -X main.appBuild={{.Commit}} - targets: - - linux_amd64 - - linux_arm64 - - darwin_amd64 - - darwin_arm64 - - windows_amd64 - - - main: ./cmd/lbcctl - id: "lbcctl" - binary: "lbcctl" - flags: - - -trimpath - ldflags: - - -s -w - - -X main.appBuild={{.Commit}} - env: - - CGO_ENABLED=0 - targets: - - linux_amd64 - - linux_arm64 - - darwin_amd64 - - darwin_arm64 - - windows_amd64 -checksum: - name_template: 'checksums.txt' -snapshot: - name_template: "{{ incpatch .Version }}-next" -changelog: - sort: asc - filters: - exclude: - - '^docs:' - - '^test:' - -release: - draft: true - prerelease: auto diff --git a/Dockerfile b/Dockerfile index fa291954..c0697e8e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,12 +14,9 @@ # 9246 Mainnet Bitcoin peer-to-peer port # 9245 Mainet RPC port -ARG ARCH=amd64 +FROM golang AS build-container -FROM golang:1.16-alpine3.14 AS build-container - -ARG ARCH -ENV GO111MODULE=on +# ENV GO111MODULE=on ADD . /app WORKDIR /app @@ -27,14 +24,15 @@ RUN set -ex \ && if [ "${ARCH}" = "amd64" ]; then export GOARCH=amd64; fi \ && if [ "${ARCH}" = "arm64v8" ]; then export GOARCH=arm64; fi \ && echo "Compiling for $GOARCH" \ - && go install -v . ./cmd/... + && CGO_ENABLED=0 go build . -FROM $ARCH/alpine:3.14 +FROM debian:11-slim -COPY --from=build-container /go/bin /bin +COPY --from=build-container /app/lbcd / +COPY --from=build-container /app/run.sh / VOLUME ["/root/.lbcd"] EXPOSE 9245 9246 -ENTRYPOINT ["lbcd"] +ENTRYPOINT ["/run.sh"] diff --git a/blockchain/chain.go b/blockchain/chain.go index 0e48b694..c829b61c 100644 --- a/blockchain/chain.go +++ b/blockchain/chain.go @@ -595,8 +595,7 @@ func (b *BlockChain) connectBlock(node *blockNode, block *btcutil.Block, // Handle LBRY Claim Scripts if b.claimTrie != nil { - shouldFlush := current && b.chainParams.Net != wire.TestNet - if err := b.ParseClaimScripts(block, node, view, shouldFlush); err != nil { + if err := b.ParseClaimScripts(block, node, view, current); err != nil { return ruleError(ErrBadClaimTrie, err.Error()) } } diff --git a/btcec/precompute.go b/btcec/precompute.go index 3d2eedbb..034cd553 100644 --- a/btcec/precompute.go +++ b/btcec/precompute.go @@ -12,7 +12,7 @@ import ( "strings" ) -//go:rm -f gensecp256k1.go; generate go run -tags gensecp256k1 genprecomps.go +//go:generate go run -tags gensecp256k1 genprecomps.go // loadS256BytePoints decompresses and deserializes the pre-computed byte points // used to accelerate scalar base multiplication for the secp256k1 curve. This diff --git a/config.go b/config.go index 4c8ad5f5..b803358c 100644 --- a/config.go +++ b/config.go @@ -108,6 +108,8 @@ type config struct { BlockPrioritySize uint32 `long:"blockprioritysize" description:"Size in bytes for high-priority/low-fee transactions when creating a block"` BlocksOnly bool `long:"blocksonly" description:"Do not accept transactions from remote peers."` ConfigFile string `short:"C" long:"configfile" description:"Path to configuration file"` + ClaimTrieImpl string `long:"clmtimpl" description:"Implementation of ClaimTrie"` + ClaimTrieHeight uint32 `long:"clmtheight" description:"Reset height of ClaimTrie"` ConnectPeers []string `long:"connect" description:"Connect only to the specified peers at startup"` CPUProfile string `long:"cpuprofile" description:"Write CPU profile to the specified file"` DataDir string `short:"b" long:"datadir" description:"Directory to store data"` @@ -954,35 +956,6 @@ func loadConfig() (*config, []string, error) { cfg.RPCListeners = normalizeAddresses(cfg.RPCListeners, activeNetParams.rpcPort) - // Only allow TLS to be disabled if the RPC is bound to localhost - // addresses. - if !cfg.DisableRPC && cfg.DisableTLS { - allowedTLSListeners := map[string]struct{}{ - "localhost": {}, - "127.0.0.1": {}, - "::1": {}, - } - for _, addr := range cfg.RPCListeners { - host, _, err := net.SplitHostPort(addr) - if err != nil { - str := "%s: RPC listen interface '%s' is " + - "invalid: %v" - err := fmt.Errorf(str, funcName, addr, err) - fmt.Fprintln(os.Stderr, err) - fmt.Fprintln(os.Stderr, usageMessage) - return nil, nil, err - } - if _, ok := allowedTLSListeners[host]; !ok { - str := "%s: the --notls option may not be used " + - "when binding RPC to non localhost " + - "addresses: %s" - err := fmt.Errorf(str, funcName, addr) - fmt.Fprintln(os.Stderr, err) - fmt.Fprintln(os.Stderr, usageMessage) - return nil, nil, err - } - } - } // Add default port to all added peer addresses if needed and remove // duplicate addresses. diff --git a/doc.go b/doc.go index ee4a9405..8ec48b5d 100644 --- a/doc.go +++ b/doc.go @@ -45,6 +45,8 @@ Application Options: 50000) --blocksonly Do not accept transactions from remote peers. -C, --configfile= Path to configuration file + --clmtimpl= Implementation of ClaimTrie + --clmtheight= Reset height of ClaimTrie --connect= Connect only to the specified peers at startup --cpuprofile= Write CPU profile to the specified file -b, --datadir= Directory to store data diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..221bb672 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,20 @@ +version: "3" + +volumes: + lbcd: + +services: + lbcd: + image: jeffreypicard/lbcd:deployment + container_name: lbcd + environment: + - LISTEN_ADDR= # Set me + ulimits: + memlock: + soft: -1 + hard: -1 + volumes: + - lbcd:/root/.lbcd + ports: + - "9245:9245" + - "9246:9246" diff --git a/lbcd.go b/lbcd.go index ec6ef086..cee4edb9 100644 --- a/lbcd.go +++ b/lbcd.go @@ -208,6 +208,13 @@ func removeRegressionDB(dbPath string) error { } } + dbPath = filepath.Join(cfg.DataDir, activeNetParams.Name, "claim_dbs") + btcdLog.Infof("Removing regression test claim databases from '%s'", dbPath) + err = os.RemoveAll(dbPath) + if err != nil { + return err + } + return nil } diff --git a/mining/cpuminer/cpuminer.go b/mining/cpuminer/cpuminer.go index 7659d1a2..64cfaf50 100644 --- a/mining/cpuminer/cpuminer.go +++ b/mining/cpuminer/cpuminer.go @@ -638,6 +638,6 @@ func New(cfg *Config) *CPUMiner { numWorkers: defaultNumWorkers, updateNumWorkers: make(chan struct{}), queryHashesPerSec: make(chan float64), - updateHashes: make(chan uint64, 512), + updateHashes: make(chan uint64), } } diff --git a/rpcclient/infrastructure.go b/rpcclient/infrastructure.go index df91b5c2..aedf18b7 100644 --- a/rpcclient/infrastructure.go +++ b/rpcclient/infrastructure.go @@ -1185,7 +1185,7 @@ type ConnConfig struct { // Params is the string representing the network that the server // is running. If there is no parameter set in the config, then // mainnet will be used by default. - Params string + Params chaincfg.Params // DisableTLS specifies whether transport layer security should be // disabled. It is recommended to always use TLS if the RPC server @@ -1435,22 +1435,7 @@ func New(config *ConnConfig, ntfnHandlers *NotificationHandlers) (*Client, error shutdown: make(chan struct{}), } - // Default network is mainnet, no parameters are necessary but if mainnet - // is specified it will be the param - switch config.Params { - case "": - fallthrough - case chaincfg.MainNetParams.Name: - client.chainParams = &chaincfg.MainNetParams - case chaincfg.TestNet3Params.Name: - client.chainParams = &chaincfg.TestNet3Params - case chaincfg.RegressionNetParams.Name: - client.chainParams = &chaincfg.RegressionNetParams - case chaincfg.SimNetParams.Name: - client.chainParams = &chaincfg.SimNetParams - default: - return nil, fmt.Errorf("rpcclient.New: Unknown chain %s", config.Params) - } + client.chainParams = &config.Params if start { log.Infof("Established connection to RPC server %s", diff --git a/run.sh b/run.sh new file mode 100755 index 00000000..2966339c --- /dev/null +++ b/run.sh @@ -0,0 +1,2 @@ +#!/bin/bash +/lbcd --txindex --notls --rpcuser=lbry --rpcpass=lbry --rpclisten= diff --git a/server.go b/server.go index 02ebb98a..ec492431 100644 --- a/server.go +++ b/server.go @@ -2733,9 +2733,35 @@ func newServer(listenAddrs, agentBlacklist, agentWhitelist []string, claimTrieCfg.DataDir = cfg.DataDir claimTrieCfg.Interrupt = interrupt - ct, err := claimtrie.New(claimTrieCfg) - if err != nil { - return nil, err + var ct *claimtrie.ClaimTrie + + switch cfg.ClaimTrieImpl { + case "none": + // Disable ClaimTrie for development purpose. + lbryLog.Infof("ClaimTrie is disabled") + case "persistent": + claimTrieCfg.RamTrie = false + lbryLog.Infof("ClaimTrie uses Persistent implementation") + case "ram", "": + claimTrieCfg.RamTrie = true + lbryLog.Infof("ClaimTrie uses RamTrie implementation") + default: + lbryLog.Errorf("ClaimTrie uses Unknown implementation") + } + + if cfg.ClaimTrieImpl != "none" { + ct, err = claimtrie.New(claimTrieCfg) + if err != nil { + return nil, err + } + if h := cfg.ClaimTrieHeight; h != 0 { + lbryLog.Infof("Reseting claim trie height to %d", h) + err := ct.ResetHeight(int32(h)) + if err != nil { + return nil, err + } + lbryLog.Infof("Claim trie height is reset to %d", h) + } } // Create a new block chain instance with the appropriate configuration.