From f92c407370be25eed68eea85307dd0a03807798a Mon Sep 17 00:00:00 2001 From: Thomas Zarebczan Date: Tue, 17 Nov 2020 03:20:36 -0500 Subject: [PATCH] LBRY changes more more --- .circleci/config.yml | 4 +- .dockerignore | 4 +- .gitignore | 4 +- CONTRIBUTING.md | 18 ++-- Dockerfile | 55 +++++++---- Makefile | 20 ++-- README.md | 91 +++++++++++++------ assets/bitcoin.json | 17 ---- ...bitcoin-mainnet.conf => lbry-mainnet.conf} | 14 +-- ...bitcoin-testnet.conf => lbry-testnet.conf} | 14 +-- assets/lbry.json | 17 ++++ bitcoin/client.go | 80 ++++++++-------- bitcoin/client_test.go | 6 +- bitcoin/node.go | 28 +++--- bitcoin/types.go | 38 ++++---- bitcoin/utils.go | 4 +- configuration/configuration.go | 58 ++++++------ configuration/configuration_test.go | 30 +++--- go.mod | 4 +- go.sum | 4 +- indexer/balance_storage_handler.go | 6 +- indexer/balance_storage_helper.go | 8 +- indexer/coin_storage_helper.go | 4 +- indexer/indexer.go | 68 +++++++------- indexer/indexer_test.go | 80 ++++++++-------- install.sh | 10 +- main.go | 32 +++---- mocks/indexer/client.go | 20 ++-- mocks/services/client.go | 2 +- mocks/services/indexer.go | 12 +-- rosetta-cli-conf/mainnet/config.json | 2 +- rosetta-cli-conf/testnet/config.json | 4 +- .../testnet/{bitcoin.ros => lbry.ros} | 14 +-- services/account_service.go | 6 +- services/account_service_test.go | 18 ++-- services/block_service.go | 6 +- services/block_service_test.go | 6 +- services/construction_service.go | 70 +++++++------- services/construction_service_test.go | 56 ++++++------ services/errors.go | 18 ++-- services/mempool_service.go | 8 +- services/mempool_service_test.go | 6 +- services/network_service.go | 14 +-- services/network_service_test.go | 24 ++--- services/router.go | 6 +- services/types.go | 24 ++--- utils/utils.go | 2 +- 47 files changed, 543 insertions(+), 493 deletions(-) delete mode 100644 assets/bitcoin.json rename assets/{bitcoin-mainnet.conf => lbry-mainnet.conf} (53%) rename assets/{bitcoin-testnet.conf => lbry-testnet.conf} (54%) create mode 100644 assets/lbry.json rename rosetta-cli-conf/testnet/{bitcoin.ros => lbry.ros} (96%) diff --git a/.circleci/config.yml b/.circleci/config.yml index c6bbe5c..8c60d43 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -18,7 +18,7 @@ executors: docker: - image: circleci/golang:1.13 user: root # go directory is owned by root - working_directory: /go/src/github.com/coinbase/rosetta-bitcoin + working_directory: /go/src/github.com/lbryio/rosetta-lbry environment: - GO111MODULE: "on" @@ -69,7 +69,7 @@ jobs: name: default steps: - *fast-checkout - - run: make coverage + - run: make coverage salus: machine: true steps: diff --git a/.dockerignore b/.dockerignore index 5ded4fc..6ffbcca 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,3 +1,3 @@ -rosetta-bitcoin -bitcoin-data +rosetta-lbry +lbry-data cli-data diff --git a/.gitignore b/.gitignore index 5ded4fc..6ffbcca 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ -rosetta-bitcoin -bitcoin-data +rosetta-lbry +lbry-data cli-data diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c37c161..b422acc 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -10,11 +10,11 @@ from further participation in this project, or potentially all Coinbase projects ## Bug Reports -* Ensure your issue [has not already been reported][1]. It may already be fixed! -* Include the steps you carried out to produce the problem. -* Include the behavior you observed along with the behavior you expected, and +- Ensure your issue [has not already been reported][1]. It may already be fixed! +- Include the steps you carried out to produce the problem. +- Include the behavior you observed along with the behavior you expected, and why you expected it. -* Include any relevant stack traces or debugging output. +- Include any relevant stack traces or debugging output. ## Feature Requests @@ -27,18 +27,18 @@ The best way to see a feature added, however, is to submit a pull request. ## Pull Requests -* Before creating your pull request, it's usually worth asking if the code +- Before creating your pull request, it's usually worth asking if the code you're planning on writing will actually be considered for merging. You can do this by [opening an issue][1] and asking. It may also help give the maintainers context for when the time comes to review your code. -* Ensure your [commit messages are well-written][2]. This can double as your +- Ensure your [commit messages are well-written][2]. This can double as your pull request message, so it pays to take the time to write a clear message. -* Add tests for your feature. You should be able to look at other tests for +- Add tests for your feature. You should be able to look at other tests for examples. If you're unsure, don't hesitate to [open an issue][1] and ask! -* Submit your pull request! +- Submit your pull request! ## Support Requests @@ -48,6 +48,6 @@ be locked to prevent further discussion. All support requests must be made via [our support team][3]. -[1]: https://github.com/coinbase/rosetta-bitcoin/issues +[1]: https://github.com/lbryio/rosetta-bitcoin/issues [2]: https://chris.beams.io/posts/git-commit/#seven-rules [3]: https://support.coinbase.com/customer/en/portal/articles/2288496-how-can-i-contact-coinbase-support- diff --git a/Dockerfile b/Dockerfile index 7ae05e4..462f226 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,29 +12,46 @@ # See the License for the specific language governing permissions and # limitations under the License. -# Build bitcoind -FROM ubuntu:18.04 as bitcoind-builder +# Build LBRYCrdd +FROM ubuntu:18.04 as lbrycrdd-builder +ENV LANG C.UTF-8 RUN mkdir -p /app \ && chown -R nobody:nogroup /app WORKDIR /app -# Source: https://github.com/bitcoin/bitcoin/blob/master/doc/build-unix.md#ubuntu--debian -RUN apt-get update && apt-get install -y make gcc g++ autoconf autotools-dev bsdmainutils build-essential git libboost-all-dev \ - libcurl4-openssl-dev libdb++-dev libevent-dev libssl-dev libtool pkg-config python python-pip libzmq3-dev wget +# Source: https://github.com/lbryio/lbrycrd/blob/v19_master/packaging/docker-for-gcc/Dockerfile +RUN set -xe; \ + apt-get update; \ + apt-get install --no-install-recommends -y build-essential libtool autotools-dev automake pkg-config git wget apt-utils \ + librsvg2-bin libtiff-tools cmake imagemagick libcap-dev libz-dev libbz2-dev python-setuptools python3-setuptools xz-utils ccache g++-multilib \ + g++-mingw-w64-i686 mingw-w64-i686-dev bsdmainutils curl ca-certificates g++-mingw-w64-x86-64 mingw-w64-x86-64-dev \ + clang-8 lldb-8 lld-8 libc++-8-dev libboost-all-dev libcurl4-openssl-dev libssl-devlibdb++-dev libevent-dev \ + libssl-dev libtool pkg-config python python-pip libzmq3-dev; \ + rm -rf /var/lib/apt/lists/*; -# VERSION: Bitcoin Core 0.20.1 -RUN git clone https://github.com/bitcoin/bitcoin \ - && cd bitcoin \ - && git checkout 7ff64311bee570874c4f0dfa18f518552188df08 +RUN update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang-cpp-8 80; \ + update-alternatives --install /usr/bin/clang clang /usr/bin/clang-8 80; \ + update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++ 80; \ + update-alternatives --install /usr/bin/cc cc /usr/bin/clang 80; \ + update-alternatives --set x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-posix; \ + update-alternatives --set i686-w64-mingw32-g++ /usr/bin/i686-w64-mingw32-g++-posix; \ + /usr/sbin/update-ccache-symlinks; \ + cd /usr/include/c++ && ln -s /usr/lib/llvm-8/include/c++/v1; \ + cd /usr/lib/llvm-8/lib && ln -s libc++abi.so.1 libc++abi.so; -RUN cd bitcoin \ +# VERSION: LBRYcrd 0.17.4.6 +RUN git clone https://github.com/lbryio/lbrycrd \ + && cd lbrycrd \ + && git checkout v17_master + +RUN cd lbrycrd \ && ./autogen.sh \ && ./configure --enable-glibc-back-compat --disable-tests --without-miniupnpc --without-gui --with-incompatible-bdb --disable-hardening --disable-zmq --disable-bench --disable-wallet \ && make -RUN mv bitcoin/src/bitcoind /app/bitcoind \ - && rm -rf bitcoin +RUN mv lbrycrd/src/lbrycrdd /app/lbrycrdd \ + && rm -rf lbrycrd # Build Rosetta Server Components FROM ubuntu:18.04 as rosetta-builder @@ -43,7 +60,7 @@ RUN mkdir -p /app \ && chown -R nobody:nogroup /app WORKDIR /app -RUN apt-get update && apt-get install -y curl make gcc g++ +RUN apt-get update && apt-get install -y curl make gcc g++ git ENV GOLANG_VERSION 1.15.2 ENV GOLANG_DOWNLOAD_SHA256 b49fda1ca29a1946d6bb2a5a6982cf07ccd2aba849289508ee0f9918f6bb4552 ENV GOLANG_DOWNLOAD_URL https://golang.org/dl/go$GOLANG_VERSION.linux-amd64.tar.gz @@ -58,13 +75,13 @@ ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH" # Use native remote build context to build in any directory -COPY . src +COPY . src RUN cd src \ && go build \ && cd .. \ - && mv src/rosetta-bitcoin /app/rosetta-bitcoin \ + && mv src/rosetta-lbry /app/rosetta-lbry \ && mv src/assets/* /app \ - && rm -rf src + && rm -rf src ## Build Final Image FROM ubuntu:18.04 @@ -80,8 +97,8 @@ RUN mkdir -p /app \ WORKDIR /app -# Copy binary from bitcoind-builder -COPY --from=bitcoind-builder /app/bitcoind /app/bitcoind +# Copy binary from lbrycrdd-builder +COPY --from=lbrycrdd-builder /app/lbrycrdd /app/lbrycrdd # Copy binary from rosetta-builder COPY --from=rosetta-builder /app/* /app/ @@ -89,4 +106,4 @@ COPY --from=rosetta-builder /app/* /app/ # Set permissions for everything added to /app RUN chmod -R 755 /app/* -CMD ["/app/rosetta-bitcoin"] +CMD ["/app/rosetta-lbry"] diff --git a/Makefile b/Makefile index 0737d29..4eac6e1 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ GOLINES_CMD=go run github.com/segmentio/golines GOLINT_CMD=go run golang.org/x/lint/golint GOVERALLS_CMD=go run github.com/mattn/goveralls GOIMPORTS_CMD=go run golang.org/x/tools/cmd/goimports -GO_PACKAGES=./services/... ./indexer/... ./bitcoin/... ./configuration/... +GO_PACKAGES=./services/... ./indexer/... ./lbry/... ./configuration/... GO_FOLDERS=$(shell echo ${GO_PACKAGES} | sed -e "s/\.\///g" | sed -e "s/\/\.\.\.//g") TEST_SCRIPT=go test ${GO_PACKAGES} LINT_SETTINGS=golint,misspell,gocyclo,gocritic,whitespace,goconst,gocognit,bodyclose,unconvert,lll,unparam @@ -20,27 +20,27 @@ deps: go get ./... build: - docker build -t rosetta-bitcoin:latest https://github.com/coinbase/rosetta-bitcoin.git + docker build -t rosetta-lbry:latest https://github.com/lbryio/rosetta-lbry.git build-local: - docker build -t rosetta-bitcoin:latest . + docker build -t rosetta-lbry:latest . build-release: # make sure to always set version with vX.X.X - docker build -t rosetta-bitcoin:$(version) .; - docker save rosetta-bitcoin:$(version) | gzip > rosetta-bitcoin-$(version).tar.gz; + docker build -t rosetta-lbry:$(version) .; + docker save rosetta-lbry:$(version) | gzip > rosetta-lbry-$(version).tar.gz; run-mainnet-online: - docker run -d --rm --ulimit "nofile=${NOFILE}:${NOFILE}" -v "${PWD}/bitcoin-data:/data" -e "MODE=ONLINE" -e "NETWORK=MAINNET" -e "PORT=8080" -p 8080:8080 -p 8333:8333 rosetta-bitcoin:latest + docker run -d --rm --ulimit "nofile=${NOFILE}:${NOFILE}" -v "${PWD}/lbry-data:/data" -e "MODE=ONLINE" -e "NETWORK=MAINNET" -e "PORT=8080" -p 8080:8080 -p 8333:8333 rosetta-lbry:latest run-mainnet-offline: - docker run -d --rm -e "MODE=OFFLINE" -e "NETWORK=MAINNET" -e "PORT=8081" -p 8081:8081 rosetta-bitcoin:latest + docker run -d --rm -e "MODE=OFFLINE" -e "NETWORK=MAINNET" -e "PORT=8081" -p 8081:8081 rosetta-lbry:latest run-testnet-online: - docker run -d --rm --ulimit "nofile=${NOFILE}:${NOFILE}" -v "${PWD}/bitcoin-data:/data" -e "MODE=ONLINE" -e "NETWORK=TESTNET" -e "PORT=8080" -p 8080:8080 -p 18333:18333 rosetta-bitcoin:latest + docker run -d --rm --ulimit "nofile=${NOFILE}:${NOFILE}" -v "${PWD}/lbry-data:/data" -e "MODE=ONLINE" -e "NETWORK=TESTNET" -e "PORT=8080" -p 8080:8080 -p 18333:18333 rosetta-lbry:latest run-testnet-offline: - docker run -d --rm -e "MODE=OFFLINE" -e "NETWORK=TESTNET" -e "PORT=8081" -p 8081:8081 rosetta-bitcoin:latest + docker run -d --rm -e "MODE=OFFLINE" -e "NETWORK=TESTNET" -e "PORT=8081" -p 8081:8081 rosetta-lbry:latest train: ./zstd-train.sh $(network) transaction $(data-directory) @@ -71,7 +71,7 @@ check-format: test: ${TEST_SCRIPT} -coverage: +coverage: if [ "${COVERALLS_TOKEN}" ]; then ${TEST_SCRIPT} -coverprofile=c.out -covermode=count; ${GOVERALLS_CMD} -coverprofile=c.out -repotoken ${COVERALLS_TOKEN}; fi coverage-local: diff --git a/README.md b/README.md index 3c71dfe..86566e2 100644 --- a/README.md +++ b/README.md @@ -7,11 +7,11 @@ Rosetta Bitcoin

- - - - - + + + + +

@@ -20,16 +20,19 @@ USE AT YOUR OWN RISK! COINBASE ASSUMES NO RESPONSIBILITY NOR LIABILITY IF THERE

## Overview + `rosetta-bitcoin` provides a reference implementation of the Rosetta API for Bitcoin in Golang. If you haven't heard of the Rosetta API, you can find more information [here](https://rosetta-api.org). ## Features -* Rosetta API implementation (both Data API and Construction API) -* UTXO cache for all accounts (accessible using `/account/balance`) -* Stateless, offline, curve-based transaction construction from any SegWit-Bech32 Address + +- Rosetta API implementation (both Data API and Construction API) +- UTXO cache for all accounts (accessible using `/account/balance`) +- Stateless, offline, curve-based transaction construction from any SegWit-Bech32 Address ## Usage + As specified in the [Rosetta API Principles](https://www.rosetta-api.org/docs/automated_deployment.html), all Rosetta implementations must be deployable via Docker and support running via either an [`online` or `offline` mode](https://www.rosetta-api.org/docs/node_deployment.html#multiple-modes). @@ -38,59 +41,77 @@ all Rosetta implementations must be deployable via Docker and support running vi DOCKER [HERE](https://www.docker.com/get-started).** ### Install + Running the following commands will create a Docker image called `rosetta-bitcoin:latest`. #### From GitHub + To download the pre-built Docker image from the latest release, run: + ```text -curl -sSfL https://raw.githubusercontent.com/coinbase/rosetta-bitcoin/master/install.sh | sh -s +curl -sSfL https://raw.githubusercontent.com/lbryio/rosetta-bitcoin/master/install.sh | sh -s ``` + _Do not try to install rosetta-bitcoin using GitHub Packages!_ #### From Source + After cloning this repository, run: + ```text make build-local ``` ### Run + Running the following commands will start a Docker container in [detached mode](https://docs.docker.com/engine/reference/run/#detached--d) with a data directory at `/bitcoin-data` and the Rosetta API accessible at port `8080`. #### Mainnet:Online + ```text docker run -d --rm --ulimit "nofile=100000:100000" -v "$(pwd)/bitcoin-data:/data" -e "MODE=ONLINE" -e "NETWORK=MAINNET" -e "PORT=8080" -p 8080:8080 -p 8333:8333 rosetta-bitcoin:latest ``` + _If you cloned the repository, you can run `make run-mainnet-online`._ #### Mainnet:Offline + ```text docker run -d --rm -e "MODE=OFFLINE" -e "NETWORK=MAINNET" -e "PORT=8081" -p 8081:8081 rosetta-bitcoin:latest ``` + _If you cloned the repository, you can run `make run-mainnet-offline`._ #### Testnet:Online + ```text docker run -d --rm --ulimit "nofile=100000:100000" -v "$(pwd)/bitcoin-data:/data" -e "MODE=ONLINE" -e "NETWORK=TESTNET" -e "PORT=8080" -p 8080:8080 -p 18333:18333 rosetta-bitcoin:latest ``` + _If you cloned the repository, you can run `make run-testnet-online`._ #### Testnet:Offline + ```text docker run -d --rm -e "MODE=OFFLINE" -e "NETWORK=TESTNET" -e "PORT=8081" -p 8081:8081 rosetta-bitcoin:latest ``` + _If you cloned the repository, you can run `make run-testnet-offline`._ ## System Requirements + `rosetta-bitcoin` has been tested on an [AWS c5.2xlarge instance](https://aws.amazon.com/ec2/instance-types/c5). This instance type has 8 vCPU and 16 GB of RAM. ### Network Settings + To increase the load `rosetta-bitcoin` can handle, it is recommended to tune your OS settings to allow for more connections. On a linux-based OS, you can run the following commands ([source](http://www.tweaked.io/guide/kernel)): + ```text sysctl -w net.ipv4.tcp_tw_reuse=1 sysctl -w net.core.rmem_max=16777216 @@ -99,6 +120,7 @@ sysctl -w net.ipv4.tcp_max_syn_backlog=10000 sysctl -w net.core.somaxconn=10000 sysctl -p (when done) ``` + _We have not tested `rosetta-bitcoin` with `net.ipv4.tcp_tw_recycle` and do not recommend enabling it._ @@ -106,6 +128,7 @@ You should also modify your open file settings to `100000`. This can be done on with the command: `ulimit -n 100000`. ### Memory-Mapped Files + `rosetta-bitcoin` uses [memory-mapped files](https://en.wikipedia.org/wiki/Memory-mapped_file) to persist data in the `indexer`. As a result, you **must** run `rosetta-bitcoin` on a 64-bit architecture (the virtual address space easily exceeds 100s of GBs). @@ -114,10 +137,12 @@ If you receive a kernel OOM, you may need to increase the allocated size of swap on your OS. There is a great tutorial for how to do this on Linux [here](https://linuxize.com/post/create-a-linux-swap-file/). ## Architecture + `rosetta-bitcoin` uses the `syncer`, `storage`, `parser`, and `server` package -from [`rosetta-sdk-go`](https://github.com/coinbase/rosetta-sdk-go) instead +from [`rosetta-sdk-go`](https://github.com/lbryio/rosetta-sdk-go) instead of a new Bitcoin-specific implementation of packages of similar functionality. Below you can find a high-level overview of how everything fits together: + ```text +------------------------------------------------------------------+ | | @@ -157,17 +182,20 @@ you can find a high-level overview of how everything fits together: ``` ### Optimizations -* Automatically prune bitcoind while indexing blocks -* Reduce sync time with concurrent block indexing -* Use [Zstandard compression](https://github.com/facebook/zstd) to reduce the size of data stored on disk -without needing to write a manual byte-level encoding + +- Automatically prune bitcoind while indexing blocks +- Reduce sync time with concurrent block indexing +- Use [Zstandard compression](https://github.com/facebook/zstd) to reduce the size of data stored on disk + without needing to write a manual byte-level encoding #### Concurrent Block Syncing + To speed up indexing, `rosetta-bitcoin` uses concurrent block processing with a "wait free" design (using channels instead of sleeps to signal which threads are unblocked). This allows `rosetta-bitcoin` to fetch multiple inputs from disk while it waits for inputs that appeared in recently processed blocks to save to disk. + ```text +----------+ | bitcoind | @@ -205,30 +233,35 @@ in recently processed blocks to save to disk. ``` ## Testing with rosetta-cli -To validate `rosetta-bitcoin`, [install `rosetta-cli`](https://github.com/coinbase/rosetta-cli#install) + +To validate `rosetta-bitcoin`, [install `rosetta-cli`](https://github.com/lbryio/rosetta-cli#install) and run one of the following commands: -* `rosetta-cli check:data --configuration-file rosetta-cli-conf/testnet/config.json` -* `rosetta-cli check:construction --configuration-file rosetta-cli-conf/testnet/config.json` -* `rosetta-cli check:data --configuration-file rosetta-cli-conf/mainnet/config.json` + +- `rosetta-cli check:data --configuration-file rosetta-cli-conf/testnet/config.json` +- `rosetta-cli check:construction --configuration-file rosetta-cli-conf/testnet/config.json` +- `rosetta-cli check:data --configuration-file rosetta-cli-conf/mainnet/config.json` ## Future Work -* Publish benchamrks for sync speed, storage usage, and load testing -* [Rosetta API `/mempool/transaction`](https://www.rosetta-api.org/docs/MempoolApi.html#mempooltransaction) implementation -* Add CI test using `rosetta-cli` to run on each PR (likely on a regtest network) -* Add performance mode to use unlimited RAM (implementation currently optimized to use <= 16 GB of RAM) -* Support Multi-Sig Sends + +- Publish benchamrks for sync speed, storage usage, and load testing +- [Rosetta API `/mempool/transaction`](https://www.rosetta-api.org/docs/MempoolApi.html#mempooltransaction) implementation +- Add CI test using `rosetta-cli` to run on each PR (likely on a regtest network) +- Add performance mode to use unlimited RAM (implementation currently optimized to use <= 16 GB of RAM) +- Support Multi-Sig Sends _Please reach out on our [community](https://community.rosetta-api.org) if you want to tackle anything on this list!_ ## Development -* `make deps` to install dependencies -* `make test` to run tests -* `make lint` to lint the source code -* `make salus` to check for security concerns -* `make build-local` to build a Docker image from the local context -* `make coverage-local` to generate a coverage report + +- `make deps` to install dependencies +- `make test` to run tests +- `make lint` to lint the source code +- `make salus` to check for security concerns +- `make build-local` to build a Docker image from the local context +- `make coverage-local` to generate a coverage report ## License + This project is available open source under the terms of the [Apache 2.0 License](https://opensource.org/licenses/Apache-2.0). © 2020 Coinbase diff --git a/assets/bitcoin.json b/assets/bitcoin.json deleted file mode 100644 index 27d9d22..0000000 --- a/assets/bitcoin.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "network": { - "blockchain": "Bitcoin", - "network": "Mainnet" - }, - "online_url": "http://localhost:8080", - "data_directory": "", - "http_timeout": 10, - "sync_concurrency": 8, - "transaction_concurrency": 16, - "tip_delay": 300, - "disable_memory_limit": false, - "log_configuration": false, - "data": { - "historical_balance_disabled": true - } -} diff --git a/assets/bitcoin-mainnet.conf b/assets/lbry-mainnet.conf similarity index 53% rename from assets/bitcoin-mainnet.conf rename to assets/lbry-mainnet.conf index 40ea180..34413e7 100644 --- a/assets/bitcoin-mainnet.conf +++ b/assets/lbry-mainnet.conf @@ -1,14 +1,14 @@ ## -## bitcoin.conf configuration file. Lines beginning with # are comments. +## lbry.conf configuration file. Lines beginning with # are comments. ## # DO NOT USE THIS CONFIGURATION FILE IF YOU PLAN TO EXPOSE -# BITCOIND'S RPC PORT PUBLICALLY (THESE INSECURE CREDENTIALS -# COULD LEAD TO AN ATTACK). ROSETTA-BITCOIN USES THE RPC PORT +# LBRYCRDD'S RPC PORT PUBLICALLY (THESE INSECURE CREDENTIALS +# COULD LEAD TO AN ATTACK). ROSETTA-LBRY USES THE RPC PORT # FOR INDEXING AND TRANSACTION BROADCAST BUT NEVER PROVIDES THE -# CALLER ACCESS TO BITCOIND'S RPC PORT. +# CALLER ACCESS TO LBRYCRDD'S RPC PORT. -datadir=/data/bitcoind +datadir=/data/lbrycrdd bind=0.0.0.0 rpcbind=0.0.0.0 bantime=15 @@ -17,8 +17,8 @@ rpcthreads=16 rpcworkqueue=1000 disablewallet=1 txindex=0 -port=8333 -rpcport=8332 +port=9246 +rpcport=9245 rpcuser=rosetta rpcpassword=rosetta diff --git a/assets/bitcoin-testnet.conf b/assets/lbry-testnet.conf similarity index 54% rename from assets/bitcoin-testnet.conf rename to assets/lbry-testnet.conf index 6dac1f9..939c3b4 100644 --- a/assets/bitcoin-testnet.conf +++ b/assets/lbry-testnet.conf @@ -1,14 +1,14 @@ ## -## bitcoin.conf configuration file. Lines beginning with # are comments. +## lbry.conf configuration file. Lines beginning with # are comments. ## # DO NOT USE THIS CONFIGURATION FILE IF YOU PLAN TO EXPOSE -# BITCOIND'S RPC PORT PUBLICALLY (THESE INSECURE CREDENTIALS -# COULD LEAD TO AN ATTACK). ROSETTA-BITCOIN USES THE RPC PORT +# LBRYCRDD'S RPC PORT PUBLICALLY (THESE INSECURE CREDENTIALS +# COULD LEAD TO AN ATTACK). ROSETTA-LBRY USES THE RPC PORT # FOR INDEXING AND TRANSACTION BROADCAST BUT NEVER PROVIDES THE -# CALLER ACCESS TO BITCOIND'S RPC PORT. +# CALLER ACCESS TO LBRYCRDD'S RPC PORT. -datadir=/data/bitcoind +datadir=/data/lbrycrdd bantime=15 rpcallowip=0.0.0.0/0 rpcthreads=16 @@ -23,7 +23,7 @@ prune=1 testnet=1 [test] -port=18333 +port=19246 bind=0.0.0.0 -rpcport=18332 +rpcport=19245 rpcbind=0.0.0.0 diff --git a/assets/lbry.json b/assets/lbry.json new file mode 100644 index 0000000..71d7e39 --- /dev/null +++ b/assets/lbry.json @@ -0,0 +1,17 @@ +{ + "network": { + "blockchain": "LBRY", + "network": "Mainnet" + }, + "online_url": "http://localhost:8080", + "data_directory": "", + "http_timeout": 10, + "sync_concurrency": 8, + "transaction_concurrency": 16, + "tip_delay": 300, + "disable_memory_limit": false, + "log_configuration": false, + "data": { + "historical_balance_disabled": true + } +} diff --git a/bitcoin/client.go b/bitcoin/client.go index bdb1efd..79c002e 100644 --- a/bitcoin/client.go +++ b/bitcoin/client.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package bitcoin +package lbry import ( "bytes" @@ -26,17 +26,17 @@ import ( "strconv" "time" - bitcoinUtils "github.com/coinbase/rosetta-bitcoin/utils" + lbryUtils "github.com/lbryio/rosetta-lbry/utils" "github.com/btcsuite/btcutil" - "github.com/coinbase/rosetta-sdk-go/storage" - "github.com/coinbase/rosetta-sdk-go/types" - "github.com/coinbase/rosetta-sdk-go/utils" + "github.com/lbryio/rosetta-sdk-go/storage" + "github.com/lbryio/rosetta-sdk-go/types" + "github.com/lbryio/rosetta-sdk-go/utils" ) const ( // genesisBlockIndex is the height of the block we consider to be the - // genesis block of the bitcoin blockchain for polling + // genesis block of the lbry blockchain for polling genesisBlockIndex = 0 // requestID is the JSON-RPC request ID we use for making requests. @@ -57,28 +57,28 @@ const ( type requestMethod string const ( - // https://bitcoin.org/en/developer-reference#getblock + // https://lbry.org/en/developer-reference#getblock requestMethodGetBlock requestMethod = "getblock" - // https://bitcoin.org/en/developer-reference#getblockhash + // https://lbry.org/en/developer-reference#getblockhash requestMethodGetBlockHash requestMethod = "getblockhash" - // https://bitcoin.org/en/developer-reference#getblockchaininfo + // https://lbry.org/en/developer-reference#getblockchaininfo requestMethodGetBlockchainInfo requestMethod = "getblockchaininfo" - // https://developer.bitcoin.org/reference/rpc/getpeerinfo.html + // https://developer.lbry.org/reference/rpc/getpeerinfo.html requestMethodGetPeerInfo requestMethod = "getpeerinfo" - // https://developer.bitcoin.org/reference/rpc/pruneblockchain.html + // https://developer.lbry.org/reference/rpc/pruneblockchain.html requestMethodPruneBlockchain requestMethod = "pruneblockchain" - // https://developer.bitcoin.org/reference/rpc/sendrawtransaction.html + // https://developer.lbry.org/reference/rpc/sendrawtransaction.html requestMethodSendRawTransaction requestMethod = "sendrawtransaction" - // https://developer.bitcoin.org/reference/rpc/estimatesmartfee.html + // https://developer.lbry.org/reference/rpc/estimatesmartfee.html requestMethodEstimateSmartFee requestMethod = "estimatesmartfee" - // https://developer.bitcoin.org/reference/rpc/getrawmempool.html + // https://developer.lbry.org/reference/rpc/getrawmempool.html requestMethodRawMempool requestMethod = "getrawmempool" // blockNotFoundErrCode is the RPC error code when a block cannot be found @@ -90,11 +90,11 @@ const ( dialTimeout = 5 * time.Second // timeMultiplier is used to multiply the time - // returned in Bitcoin blocks to be milliseconds. + // returned in lbry blocks to be milliseconds. timeMultiplier = 1000 - // rpc credentials are fixed in rosetta-bitcoin - // because we never expose access to the raw bitcoind + // rpc credentials are fixed in rosetta-lbry + // because we never expose access to the raw lbryd // endpoints (that could be used perform an attack, like // changing our peers). rpcUsername = "rosetta" @@ -110,10 +110,10 @@ var ( ErrJSONRPCError = errors.New("JSON-RPC error") ) -// Client is used to fetch blocks from bitcoind and -// to parse Bitcoin block data into Rosetta types. +// Client is used to fetch blocks from lbryd and +// to parse lbry block data into Rosetta types. // -// We opted not to use existing Bitcoin RPC libraries +// We opted not to use existing lbry RPC libraries // because they don't allow providing context // in each request. type Client struct { @@ -131,7 +131,7 @@ func LocalhostURL(rpcPort int) string { return fmt.Sprintf("http://localhost:%d", rpcPort) } -// NewClient creates a new Bitcoin client. +// NewClient creates a new lbry client. func NewClient( baseURL string, genesisBlockIdentifier *types.BlockIdentifier, @@ -162,7 +162,7 @@ func newHTTPClient(timeout time.Duration) *http.Client { } // NetworkStatus returns the *types.NetworkStatusResponse for -// bitcoind. +// lbryd. func (b *Client) NetworkStatus(ctx context.Context) (*types.NetworkStatusResponse, error) { rawBlock, err := b.getBlock(ctx, nil) if err != nil { @@ -241,7 +241,7 @@ func (b *Client) GetRawBlock( return block, coins, nil } -// ParseBlock returns a parsed bitcoin block given a raw bitcoin +// ParseBlock returns a parsed lbry block given a raw lbry // block and a map of transactions containing inputs. func (b *Client) ParseBlock( ctx context.Context, @@ -264,7 +264,7 @@ func (b *Client) ParseBlock( } // SendRawTransaction submits a serialized transaction -// to bitcoind. +// to lbryd. func (b *Client) SendRawTransaction( ctx context.Context, serializedTx string, @@ -301,14 +301,14 @@ func (b *Client) SuggestedFeeRate( } // PruneBlockchain prunes up to the provided height. -// https://bitcoincore.org/en/doc/0.20.0/rpc/blockchain/pruneblockchain +// https://lbrycore.org/en/doc/0.20.0/rpc/blockchain/pruneblockchain func (b *Client) PruneBlockchain( ctx context.Context, height int64, ) (int64, error) { // Parameters: // 1. Height - // https://developer.bitcoin.org/reference/rpc/pruneblockchain.html#argument-1-height + // https://developer.lbry.org/reference/rpc/pruneblockchain.html#argument-1-height params := []interface{}{height} response := &pruneBlockchainResponse{} @@ -362,7 +362,7 @@ func (b *Client) getBlock( // Parameters: // 1. Block hash (string, required) // 2. Verbosity (integer, optional, default=1) - // https://bitcoin.org/en/developer-reference#getblock + // https://lbry.org/en/developer-reference#getblock params := []interface{}{hash, blockVerbosity} response := &blockResponse{} @@ -448,14 +448,14 @@ func (b *Client) parseBlockData(block *Block) (*types.Block, error) { // getHashFromIndex performs the `getblockhash` JSON-RPC request for the specified // block index, and returns the hash. -// https://bitcoin.org/en/developer-reference#getblockhash +// https://lbry.org/en/developer-reference#getblockhash func (b *Client) getHashFromIndex( ctx context.Context, index int64, ) (string, error) { // Parameters: // 1. Block height (numeric, required) - // https://bitcoin.org/en/developer-reference#getblockhash + // https://lbry.org/en/developer-reference#getblockhash params := []interface{}{index} response := &blockHashResponse{} @@ -472,9 +472,9 @@ func (b *Client) getHashFromIndex( // skipTransactionOperations is used to skip operations on transactions that // contain duplicate UTXOs (which are no longer possible after BIP-30). This -// function mirrors the behavior of a similar commit in bitcoin-core. +// function mirrors the behavior of a similar commit in lbry-core. // -// Source: https://github.com/bitcoin/bitcoin/commit/ab91bf39b7c11e9c86bb2043c24f0f377f1cf514 +// Source: https://github.com/lbry/lbry/commit/ab91bf39b7c11e9c86bb2043c24f0f377f1cf514 func skipTransactionOperations(blockNumber int64, blockHash string, transactionHash string) bool { if blockNumber == 91842 && blockHash == "00000000000a4d0a398161ffc163c503763b1f4360639393e0e4c8e300e0caec" && transactionHash == "d5d27987d2a3dfc724e359870c6644b40e497bdc0589a033220fe15429d88599" { @@ -495,7 +495,7 @@ func (b *Client) parseTransactions( block *Block, coins map[string]*storage.AccountCoin, ) ([]*types.Transaction, error) { - logger := bitcoinUtils.ExtractLogger(ctx, "client") + logger := lbryUtils.ExtractLogger(ctx, "client") if block == nil { return nil, errors.New("error parsing nil block") @@ -571,7 +571,7 @@ func (b *Client) parseTxOperations( txOps := []*types.Operation{} for networkIndex, input := range tx.Inputs { - if bitcoinIsCoinbaseInput(input, txIndex, networkIndex) { + if lbryIsCoinbaseInput(input, txIndex, networkIndex) { txOp, err := b.coinbaseTxOperation(input, int64(len(txOps)), int64(networkIndex)) if err != nil { return nil, err @@ -629,7 +629,7 @@ func (b *Client) parseTxOperations( } // parseOutputTransactionOperation returns the types.Operation for the specified -// `bitcoinOutput` transaction output. +// `lbryOutput` transaction output. func (b *Client) parseOutputTransactionOperation( output *Output, txHash string, @@ -658,7 +658,7 @@ func (b *Client) parseOutputTransactionOperation( CoinAction: types.CoinCreated, } - // If we are unable to parse the output account (i.e. bitcoind + // If we are unable to parse the output account (i.e. lbryd // returns a blank/nonstandard ScriptPubKey), we create an address as the // concatenation of the tx hash and index. // @@ -700,17 +700,17 @@ func (b *Client) getInputTxHash( txIndex int, inputIndex int, ) (string, int64, bool) { - if bitcoinIsCoinbaseInput(input, txIndex, inputIndex) { + if lbryIsCoinbaseInput(input, txIndex, inputIndex) { return "", -1, false } return input.TxHash, input.Vout, true } -// bitcoinIsCoinbaseInput returns whether the specified input is +// lbryIsCoinbaseInput returns whether the specified input is // the coinbase input. The coinbase input is always the first input in the first // transaction, and does not contain a previous transaction hash. -func bitcoinIsCoinbaseInput(input *Input, txIndex int, inputIndex int) bool { +func lbryIsCoinbaseInput(input *Input, txIndex int, inputIndex int) bool { return txIndex == 0 && inputIndex == 0 && input.TxHash == "" && input.Coinbase != "" } @@ -769,7 +769,7 @@ func (b *Client) parseAmount(amount float64) (uint64, error) { return uint64(atomicAmount), nil } -// parseOutputAccount parses a bitcoinScriptPubKey and returns an account +// parseOutputAccount parses a lbryScriptPubKey and returns an account // identifier. The account identifier's address corresponds to the first // address encoded in the script. func (b *Client) parseOutputAccount( @@ -805,7 +805,7 @@ func (b *Client) coinbaseTxOperation( }, nil } -// post makes a HTTP request to a Bitcoin node +// post makes a HTTP request to a lbry node func (b *Client) post( ctx context.Context, method requestMethod, diff --git a/bitcoin/client_test.go b/bitcoin/client_test.go index 4e1ab94..ee3865e 100644 --- a/bitcoin/client_test.go +++ b/bitcoin/client_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package bitcoin +package lbry import ( "context" @@ -24,8 +24,8 @@ import ( "net/http/httptest" "testing" - "github.com/coinbase/rosetta-sdk-go/storage" - "github.com/coinbase/rosetta-sdk-go/types" + "github.com/lbryio/rosetta-sdk-go/storage" + "github.com/lbryio/rosetta-sdk-go/types" "github.com/stretchr/testify/assert" ) diff --git a/bitcoin/node.go b/bitcoin/node.go index f657a10..f44c85e 100644 --- a/bitcoin/node.go +++ b/bitcoin/node.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package bitcoin +package lbry import ( "bufio" @@ -23,14 +23,14 @@ import ( "os/exec" "strings" - "github.com/coinbase/rosetta-bitcoin/utils" + "github.com/lbryio/rosetta-lbry/utils" "golang.org/x/sync/errgroup" ) const ( - bitcoindLogger = "bitcoind" - bitcoindStdErrLogger = "bitcoind stderr" + lbrydLogger = "lbryd" + lbrydStdErrLogger = "lbryd stderr" ) func logPipe(ctx context.Context, pipe io.ReadCloser, identifier string) error { @@ -51,8 +51,8 @@ func logPipe(ctx context.Context, pipe io.ReadCloser, identifier string) error { message = messages[1] } - // Print debug log if from bitcoindLogger - if identifier == bitcoindLogger { + // Print debug log if from lbrydLogger + if identifier == lbrydLogger { logger.Debugw(message) continue } @@ -61,12 +61,12 @@ func logPipe(ctx context.Context, pipe io.ReadCloser, identifier string) error { } } -// StartBitcoind starts a bitcoind daemon in another goroutine +// Startlbryd starts a lbryd daemon in another goroutine // and logs the results to the console. -func StartBitcoind(ctx context.Context, configPath string, g *errgroup.Group) error { - logger := utils.ExtractLogger(ctx, "bitcoind") +func Startlbryd(ctx context.Context, configPath string, g *errgroup.Group) error { + logger := utils.ExtractLogger(ctx, "lbryd") cmd := exec.Command( - "/app/bitcoind", + "/app/lbryd", fmt.Sprintf("--conf=%s", configPath), ) // #nosec G204 @@ -81,21 +81,21 @@ func StartBitcoind(ctx context.Context, configPath string, g *errgroup.Group) er } g.Go(func() error { - return logPipe(ctx, stdout, bitcoindLogger) + return logPipe(ctx, stdout, lbrydLogger) }) g.Go(func() error { - return logPipe(ctx, stderr, bitcoindStdErrLogger) + return logPipe(ctx, stderr, lbrydStdErrLogger) }) if err := cmd.Start(); err != nil { - return fmt.Errorf("%w: unable to start bitcoind", err) + return fmt.Errorf("%w: unable to start lbryd", err) } g.Go(func() error { <-ctx.Done() - logger.Warnw("sending interrupt to bitcoind") + logger.Warnw("sending interrupt to lbryd") return cmd.Process.Signal(os.Interrupt) }) diff --git a/bitcoin/types.go b/bitcoin/types.go index 8942577..59244eb 100644 --- a/bitcoin/types.go +++ b/bitcoin/types.go @@ -12,19 +12,19 @@ // See the License for the specific language governing permissions and // limitations under the License. -package bitcoin +package lbry import ( "fmt" "strings" "github.com/btcsuite/btcd/chaincfg" - "github.com/coinbase/rosetta-sdk-go/types" + "github.com/lbryio/rosetta-sdk-go/types" ) const ( - // Blockchain is Bitcoin. - Blockchain string = "Bitcoin" + // Blockchain is lbry. + Blockchain string = "lbry" // MainnetNetwork is the value of the network // in MainnetNetworkIdentifier. @@ -38,9 +38,9 @@ const ( // used in Currency. Decimals = 8 - // SatoshisInBitcoin is the number of + // SatoshisInlbry is the number of // Satoshis in 1 BTC (10^8). - SatoshisInBitcoin = 100000000 + SatoshisInlbry = 100000000 // InputOpType is used to describe // INPUT. @@ -55,7 +55,7 @@ const ( CoinbaseOpType = "COINBASE" // SuccessStatus is the status of all - // Bitcoin operations because anything + // lbry operations because anything // on-chain is considered successful. SuccessStatus = "SUCCESS" @@ -66,17 +66,17 @@ const ( SkippedStatus = "SKIPPED" // TransactionHashLength is the length - // of any transaction hash in Bitcoin. + // of any transaction hash in lbry. TransactionHashLength = 64 - // NullData is returned by bitcoind + // NullData is returned by lbryd // as the ScriptPubKey.Type for OP_RETURN // locking scripts. NullData = "nulldata" ) // Fee estimate constants -// Source: https://bitcoinops.org/en/tools/calc-size/ +// Source: https://lbryops.org/en/tools/calc-size/ const ( MinFeeRate = float64(0.00001) // nolint:gomnd TransactionOverhead = 12 // 4 version, 2 segwit flag, 1 vin, 1 vout, 4 lock time @@ -135,7 +135,7 @@ var ( ) // ScriptPubKey is a script placed on the output operations -// of a Bitcoin transaction that must be satisfied to spend +// of a lbry transaction that must be satisfied to spend // the output. type ScriptPubKey struct { ASM string `json:"asm"` @@ -146,14 +146,14 @@ type ScriptPubKey struct { } // ScriptSig is a script on the input operations of a -// Bitcoin transaction that satisfies the ScriptPubKey +// lbry transaction that satisfies the ScriptPubKey // on an output being spent. type ScriptSig struct { ASM string `json:"asm"` Hex string `json:"hex"` } -// BlockchainInfo is information about the Bitcoin network. +// BlockchainInfo is information about the lbry network. // This struct only contains the information necessary for // this implementation. type BlockchainInfo struct { @@ -176,7 +176,7 @@ type PeerInfo struct { SyncedHeaders int64 `json:"synced_headers"` } -// Block is a raw Bitcoin block (with verbosity == 2). +// Block is a raw lbry block (with verbosity == 2). type Block struct { Hash string `json:"hash"` Height int64 `json:"height"` @@ -223,7 +223,7 @@ type BlockMetadata struct { Difficulty float64 `json:"difficulty,omitempty"` } -// Transaction is a raw Bitcoin transaction. +// Transaction is a raw lbry transaction. type Transaction struct { Hex string `json:"hex"` Hash string `json:"txid"` @@ -260,7 +260,7 @@ type TransactionMetadata struct { Weight int64 `json:"weight,omitempty"` } -// Input is a raw input in a Bitcoin transaction. +// Input is a raw input in a lbry transaction. type Input struct { TxHash string `json:"txid"` Vout int64 `json:"vout"` @@ -284,7 +284,7 @@ func (i Input) Metadata() (map[string]interface{}, error) { return types.MarshalMap(m) } -// Output is a raw output in a Bitcoin transaction. +// Output is a raw output in a lbry transaction. type Output struct { Value float64 `json:"value"` Index int64 `json:"n"` @@ -301,7 +301,7 @@ func (o Output) Metadata() (map[string]interface{}, error) { } // OperationMetadata is a collection of useful -// metadata from Bitcoin inputs and outputs. +// metadata from lbry inputs and outputs. type OperationMetadata struct { // Coinbase Metadata Coinbase string `json:"coinbase,omitempty"` @@ -499,7 +499,7 @@ func (r rawMempoolResponse) Err() error { // CoinIdentifier converts a tx hash and vout into // the canonical CoinIdentifier.Identifier used in -// rosetta-bitcoin. +// rosetta-lbry. func CoinIdentifier(hash string, vout int64) string { return fmt.Sprintf("%s:%d", hash, vout) } diff --git a/bitcoin/utils.go b/bitcoin/utils.go index 1b9daf7..edf8037 100644 --- a/bitcoin/utils.go +++ b/bitcoin/utils.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package bitcoin +package lbry import ( "fmt" @@ -23,7 +23,7 @@ import ( "github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcutil" - "github.com/coinbase/rosetta-sdk-go/types" + "github.com/lbryio/rosetta-sdk-go/types" ) // ParseCoinIdentifier returns the corresponding hash and index associated diff --git a/configuration/configuration.go b/configuration/configuration.go index 5690077..0aebba8 100644 --- a/configuration/configuration.go +++ b/configuration/configuration.go @@ -22,11 +22,11 @@ import ( "strconv" "time" - "github.com/coinbase/rosetta-bitcoin/bitcoin" + "github.com/lbryio/rosetta-lbry/lbry" "github.com/btcsuite/btcd/chaincfg" - "github.com/coinbase/rosetta-sdk-go/storage" - "github.com/coinbase/rosetta-sdk-go/types" + "github.com/lbryio/rosetta-sdk-go/storage" + "github.com/lbryio/rosetta-sdk-go/types" ) // Mode is the setting that determines if @@ -42,34 +42,34 @@ const ( // to make outbound connections. Offline Mode = "OFFLINE" - // Mainnet is the Bitcoin Mainnet. + // Mainnet is the lbry Mainnet. Mainnet string = "MAINNET" - // Testnet is Bitcoin Testnet3. + // Testnet is lbry Testnet3. Testnet string = "TESTNET" - // mainnetConfigPath is the path of the Bitcoin + // mainnetConfigPath is the path of the lbry // configuration file for mainnet. - mainnetConfigPath = "/app/bitcoin-mainnet.conf" + mainnetConfigPath = "/app/lbry-mainnet.conf" - // testnetConfigPath is the path of the Bitcoin + // testnetConfigPath is the path of the lbry // configuration file for testnet. - testnetConfigPath = "/app/bitcoin-testnet.conf" + testnetConfigPath = "/app/lbry-testnet.conf" // Zstandard compression dictionaries transactionNamespace = "transaction" testnetTransactionDictionary = "/app/testnet-transaction.zstd" mainnetTransactionDictionary = "/app/mainnet-transaction.zstd" - mainnetRPCPort = 8332 - testnetRPCPort = 18332 + mainnetRPCPort = 9245 + testnetRPCPort = 19245 // min prune depth is 288: - // https://github.com/bitcoin/bitcoin/blob/ad2952d17a2af419a04256b10b53c7377f826a27/src/validation.h#L84 + // https://github.com/lbry/lbry/blob/ad2952d17a2af419a04256b10b53c7377f826a27/src/validation.h#L84 pruneDepth = int64(10000) //nolint // min prune height (on mainnet): - // https://github.com/bitcoin/bitcoin/blob/62d137ac3b701aae36c1aa3aa93a83fd6357fde6/src/chainparams.cpp#L102 + // https://github.com/lbry/lbry/blob/62d137ac3b701aae36c1aa3aa93a83fd6357fde6/src/chainparams.cpp#L102 minPruneHeight = int64(100000) //nolint // attempt to prune once an hour @@ -79,8 +79,8 @@ const ( // persistent data. DataDirectory = "/data" - bitcoindPath = "bitcoind" - indexerPath = "indexer" + LBRYcrdPath = "LBRYcrd" + indexerPath = "indexer" // allFilePermissions specifies anyone can do anything // to the file. @@ -120,7 +120,7 @@ type Configuration struct { ConfigPath string Pruning *PruningConfiguration IndexerPath string - BitcoindPath string + LBRYcrdPath string Compressors []*storage.CompressorEntry } @@ -143,9 +143,9 @@ func LoadConfiguration(baseDirectory string) (*Configuration, error) { return nil, fmt.Errorf("%w: unable to create indexer path", err) } - config.BitcoindPath = path.Join(baseDirectory, bitcoindPath) - if err := ensurePathExists(config.BitcoindPath); err != nil { - return nil, fmt.Errorf("%w: unable to create bitcoind path", err) + config.LBRYcrdPath = path.Join(baseDirectory, LBRYcrdPath) + if err := ensurePathExists(config.LBRYcrdPath); err != nil { + return nil, fmt.Errorf("%w: unable to create LBRYcrd path", err) } case Offline: config.Mode = Offline @@ -159,12 +159,12 @@ func LoadConfiguration(baseDirectory string) (*Configuration, error) { switch networkValue { case Mainnet: config.Network = &types.NetworkIdentifier{ - Blockchain: bitcoin.Blockchain, - Network: bitcoin.MainnetNetwork, + Blockchain: lbry.Blockchain, + Network: lbry.MainnetNetwork, } - config.GenesisBlockIdentifier = bitcoin.MainnetGenesisBlockIdentifier - config.Params = bitcoin.MainnetParams - config.Currency = bitcoin.MainnetCurrency + config.GenesisBlockIdentifier = lbry.MainnetGenesisBlockIdentifier + config.Params = lbry.MainnetParams + config.Currency = lbry.MainnetCurrency config.ConfigPath = mainnetConfigPath config.RPCPort = mainnetRPCPort config.Compressors = []*storage.CompressorEntry{ @@ -175,12 +175,12 @@ func LoadConfiguration(baseDirectory string) (*Configuration, error) { } case Testnet: config.Network = &types.NetworkIdentifier{ - Blockchain: bitcoin.Blockchain, - Network: bitcoin.TestnetNetwork, + Blockchain: lbry.Blockchain, + Network: lbry.TestnetNetwork, } - config.GenesisBlockIdentifier = bitcoin.TestnetGenesisBlockIdentifier - config.Params = bitcoin.TestnetParams - config.Currency = bitcoin.TestnetCurrency + config.GenesisBlockIdentifier = lbry.TestnetGenesisBlockIdentifier + config.Params = lbry.TestnetParams + config.Currency = lbry.TestnetCurrency config.ConfigPath = testnetConfigPath config.RPCPort = testnetRPCPort config.Compressors = []*storage.CompressorEntry{ diff --git a/configuration/configuration_test.go b/configuration/configuration_test.go index 07e6925..fa530b4 100644 --- a/configuration/configuration_test.go +++ b/configuration/configuration_test.go @@ -20,11 +20,11 @@ import ( "path" "testing" - "github.com/coinbase/rosetta-bitcoin/bitcoin" + "github.com/lbryio/rosetta-lbry/lbry" - "github.com/coinbase/rosetta-sdk-go/storage" - "github.com/coinbase/rosetta-sdk-go/types" - "github.com/coinbase/rosetta-sdk-go/utils" + "github.com/lbryio/rosetta-sdk-go/storage" + "github.com/lbryio/rosetta-sdk-go/types" + "github.com/lbryio/rosetta-sdk-go/utils" "github.com/stretchr/testify/assert" ) @@ -56,12 +56,12 @@ func TestLoadConfiguration(t *testing.T) { cfg: &Configuration{ Mode: Online, Network: &types.NetworkIdentifier{ - Network: bitcoin.MainnetNetwork, - Blockchain: bitcoin.Blockchain, + Network: lbry.MainnetNetwork, + Blockchain: lbry.Blockchain, }, - Params: bitcoin.MainnetParams, - Currency: bitcoin.MainnetCurrency, - GenesisBlockIdentifier: bitcoin.MainnetGenesisBlockIdentifier, + Params: lbry.MainnetParams, + Currency: lbry.MainnetCurrency, + GenesisBlockIdentifier: lbry.MainnetGenesisBlockIdentifier, Port: 1000, RPCPort: mainnetRPCPort, ConfigPath: mainnetConfigPath, @@ -85,12 +85,12 @@ func TestLoadConfiguration(t *testing.T) { cfg: &Configuration{ Mode: Online, Network: &types.NetworkIdentifier{ - Network: bitcoin.TestnetNetwork, - Blockchain: bitcoin.Blockchain, + Network: lbry.TestnetNetwork, + Blockchain: lbry.Blockchain, }, - Params: bitcoin.TestnetParams, - Currency: bitcoin.TestnetCurrency, - GenesisBlockIdentifier: bitcoin.TestnetGenesisBlockIdentifier, + Params: lbry.TestnetParams, + Currency: lbry.TestnetCurrency, + GenesisBlockIdentifier: lbry.TestnetGenesisBlockIdentifier, Port: 1000, RPCPort: testnetRPCPort, ConfigPath: testnetConfigPath, @@ -143,7 +143,7 @@ func TestLoadConfiguration(t *testing.T) { assert.Contains(t, err.Error(), test.err.Error()) } else { test.cfg.IndexerPath = path.Join(newDir, "indexer") - test.cfg.BitcoindPath = path.Join(newDir, "bitcoind") + test.cfg.lbrydPath = path.Join(newDir, "lbryd") assert.Equal(t, test.cfg, cfg) assert.NoError(t, err) } diff --git a/go.mod b/go.mod index 60d9327..57fc803 100644 --- a/go.mod +++ b/go.mod @@ -1,11 +1,11 @@ -module github.com/coinbase/rosetta-bitcoin +module github.com/lbryio/rosetta-lbry go 1.13 require ( github.com/btcsuite/btcd v0.21.0-beta github.com/btcsuite/btcutil v1.0.2 - github.com/coinbase/rosetta-sdk-go v0.5.9 + github.com/lbryio/rosetta-sdk-go v0.5.9 github.com/dgraph-io/badger/v2 v2.2007.2 github.com/grpc-ecosystem/go-grpc-middleware v1.2.2 github.com/stretchr/testify v1.6.1 diff --git a/go.sum b/go.sum index b2efe12..11b62ed 100644 --- a/go.sum +++ b/go.sum @@ -62,8 +62,8 @@ github.com/client9/misspell v0.3.4 h1:ta993UF76GwbvJcIo3Y68y/M3WxlpEHPWIGDkJYwzJ github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cloudflare/cloudflare-go v0.10.2-0.20190916151808-a80f83b9add9/go.mod h1:1MxXX1Ux4x6mqPmjkUgTP1CdXIBXKX7T+Jk9Gxrmx+U= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= -github.com/coinbase/rosetta-sdk-go v0.5.9 h1:CuGQE3HFmYwdEACJnuOtVI9cofqPsGvq6FdFIzaOPKI= -github.com/coinbase/rosetta-sdk-go v0.5.9/go.mod h1:xd4wYUhV3LkY78SPH8BUhc88rXfn2jYgN9BfiSjbcvM= +github.com/lbryio/rosetta-sdk-go v0.5.9 h1:CuGQE3HFmYwdEACJnuOtVI9cofqPsGvq6FdFIzaOPKI= +github.com/lbryio/rosetta-sdk-go v0.5.9/go.mod h1:xd4wYUhV3LkY78SPH8BUhc88rXfn2jYgN9BfiSjbcvM= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= diff --git a/indexer/balance_storage_handler.go b/indexer/balance_storage_handler.go index 52460a4..b55d7f4 100644 --- a/indexer/balance_storage_handler.go +++ b/indexer/balance_storage_handler.go @@ -17,9 +17,9 @@ package indexer import ( "context" - "github.com/coinbase/rosetta-sdk-go/parser" - "github.com/coinbase/rosetta-sdk-go/storage" - "github.com/coinbase/rosetta-sdk-go/types" + "github.com/lbryio/rosetta-sdk-go/parser" + "github.com/lbryio/rosetta-sdk-go/storage" + "github.com/lbryio/rosetta-sdk-go/types" ) var _ storage.BalanceStorageHandler = (*BalanceStorageHandler)(nil) diff --git a/indexer/balance_storage_helper.go b/indexer/balance_storage_helper.go index c36699d..72a1790 100644 --- a/indexer/balance_storage_helper.go +++ b/indexer/balance_storage_helper.go @@ -17,10 +17,10 @@ package indexer import ( "context" - "github.com/coinbase/rosetta-sdk-go/asserter" - "github.com/coinbase/rosetta-sdk-go/parser" - "github.com/coinbase/rosetta-sdk-go/storage" - "github.com/coinbase/rosetta-sdk-go/types" + "github.com/lbryio/rosetta-sdk-go/asserter" + "github.com/lbryio/rosetta-sdk-go/parser" + "github.com/lbryio/rosetta-sdk-go/storage" + "github.com/lbryio/rosetta-sdk-go/types" ) var _ storage.BalanceStorageHelper = (*BalanceStorageHelper)(nil) diff --git a/indexer/coin_storage_helper.go b/indexer/coin_storage_helper.go index 36a7515..3f1ebd0 100644 --- a/indexer/coin_storage_helper.go +++ b/indexer/coin_storage_helper.go @@ -17,8 +17,8 @@ package indexer import ( "context" - "github.com/coinbase/rosetta-sdk-go/storage" - "github.com/coinbase/rosetta-sdk-go/types" + "github.com/lbryio/rosetta-sdk-go/storage" + "github.com/lbryio/rosetta-sdk-go/types" ) var _ storage.CoinStorageHelper = (*CoinStorageHelper)(nil) diff --git a/indexer/indexer.go b/indexer/indexer.go index 47a3649..a3aff7f 100644 --- a/indexer/indexer.go +++ b/indexer/indexer.go @@ -20,18 +20,18 @@ import ( "fmt" "time" - "github.com/coinbase/rosetta-bitcoin/bitcoin" - "github.com/coinbase/rosetta-bitcoin/configuration" - "github.com/coinbase/rosetta-bitcoin/services" - "github.com/coinbase/rosetta-bitcoin/utils" + "github.com/lbryio/rosetta-lbry/configuration" + "github.com/lbryio/rosetta-lbry/lbry" + "github.com/lbryio/rosetta-lbry/services" + "github.com/lbryio/rosetta-lbry/utils" - "github.com/coinbase/rosetta-sdk-go/asserter" - "github.com/coinbase/rosetta-sdk-go/storage" - "github.com/coinbase/rosetta-sdk-go/syncer" - "github.com/coinbase/rosetta-sdk-go/types" - sdkUtils "github.com/coinbase/rosetta-sdk-go/utils" "github.com/dgraph-io/badger/v2" "github.com/dgraph-io/badger/v2/options" + "github.com/lbryio/rosetta-sdk-go/asserter" + "github.com/lbryio/rosetta-sdk-go/storage" + "github.com/lbryio/rosetta-sdk-go/syncer" + "github.com/lbryio/rosetta-sdk-go/types" + sdkUtils "github.com/lbryio/rosetta-sdk-go/utils" ) const ( @@ -66,10 +66,10 @@ var ( type Client interface { NetworkStatus(context.Context) (*types.NetworkStatusResponse, error) PruneBlockchain(context.Context, int64) (int64, error) - GetRawBlock(context.Context, *types.PartialBlockIdentifier) (*bitcoin.Block, []string, error) + GetRawBlock(context.Context, *types.PartialBlockIdentifier) (*lbry.Block, []string, error) ParseBlock( context.Context, - *bitcoin.Block, + *lbry.Block, map[string]*storage.AccountCoin, ) (*types.Block, error) } @@ -180,8 +180,8 @@ func Initialize( asserter, err := asserter.NewClientWithOptions( config.Network, config.GenesisBlockIdentifier, - bitcoin.OperationTypes, - bitcoin.OperationStatuses, + lbry.OperationTypes, + lbry.OperationStatuses, services.Errors, nil, ) @@ -219,7 +219,7 @@ func Initialize( return i, nil } -// waitForNode returns once bitcoind is ready to serve +// waitForNode returns once lbryd is ready to serve // block queries. func (i *Indexer) waitForNode(ctx context.Context) error { logger := utils.ExtractLogger(ctx, "indexer") @@ -229,15 +229,15 @@ func (i *Indexer) waitForNode(ctx context.Context) error { return nil } - logger.Infow("waiting for bitcoind...") + logger.Infow("waiting for lbryd...") if err := sdkUtils.ContextSleep(ctx, nodeWaitSleep); err != nil { return err } } } -// Sync attempts to index Bitcoin blocks using -// the bitcoin.Client until stopped. +// Sync attempts to index lbry blocks using +// the lbry.Client until stopped. func (i *Indexer) Sync(ctx context.Context) error { if err := i.waitForNode(ctx); err != nil { return fmt.Errorf("%w: failed to wait for node", err) @@ -270,7 +270,7 @@ func (i *Indexer) Sync(ctx context.Context) error { return syncer.Sync(ctx, startIndex, indexPlaceholder) } -// Prune attempts to prune blocks in bitcoind every +// Prune attempts to prune blocks in lbryd every // pruneFrequency. func (i *Indexer) Prune(ctx context.Context) error { logger := utils.ExtractLogger(ctx, "pruner") @@ -289,25 +289,25 @@ func (i *Indexer) Prune(ctx context.Context) error { continue } - // Must meet pruning conditions in bitcoin core + // Must meet pruning conditions in lbry core // Source: - // https://github.com/bitcoin/bitcoin/blob/a63a26f042134fa80356860c109edb25ac567552/src/rpc/blockchain.cpp#L953-L960 + // https://github.com/lbry/lbry/blob/a63a26f042134fa80356860c109edb25ac567552/src/rpc/blockchain.cpp#L953-L960 pruneHeight := head.Index - i.pruningConfig.Depth if pruneHeight <= i.pruningConfig.MinHeight { logger.Infow("waiting to prune", "min prune height", i.pruningConfig.MinHeight) continue } - logger.Infow("attempting to prune bitcoind", "prune height", pruneHeight) + logger.Infow("attempting to prune lbryd", "prune height", pruneHeight) prunedHeight, err := i.client.PruneBlockchain(ctx, pruneHeight) if err != nil { logger.Warnw( - "unable to prune bitcoind", + "unable to prune lbryd", "prune height", pruneHeight, "error", err, ) } else { - logger.Infow("pruned bitcoind", "prune height", prunedHeight) + logger.Infow("pruned lbryd", "prune height", prunedHeight) } } } @@ -418,7 +418,7 @@ func (i *Indexer) NetworkStatus( func (i *Indexer) findCoin( ctx context.Context, - btcBlock *bitcoin.Block, + btcBlock *lbry.Block, coinIdentifier string, ) (*types.Coin, *types.AccountIdentifier, error) { for ctx.Err() == nil { @@ -480,7 +480,7 @@ func (i *Indexer) findCoin( // Put Transaction in WaitTable if doesn't already exist (could be // multiple listeners) - transactionHash := bitcoin.TransactionHash(coinIdentifier) + transactionHash := lbry.TransactionHash(coinIdentifier) val, ok := i.waiter.Get(transactionHash, false) if !ok { val = &waitTableEntry{ @@ -503,7 +503,7 @@ func (i *Indexer) findCoin( func (i *Indexer) checkHeaderMatch( ctx context.Context, - btcBlock *bitcoin.Block, + btcBlock *lbry.Block, ) error { headBlock, err := i.blockStorage.GetHeadBlockIdentifier(ctx) if err != nil && !errors.Is(err, storage.ErrHeadBlockNotFound) { @@ -523,7 +523,7 @@ func (i *Indexer) checkHeaderMatch( func (i *Indexer) findCoins( ctx context.Context, - btcBlock *bitcoin.Block, + btcBlock *lbry.Block, coins []string, ) (map[string]*storage.AccountCoin, error) { if err := i.checkHeaderMatch(ctx, btcBlock); err != nil { @@ -562,7 +562,7 @@ func (i *Indexer) findCoins( shouldAbort := false for _, coinIdentifier := range remainingCoins { // Wait on Channel - txHash := bitcoin.TransactionHash(coinIdentifier) + txHash := lbry.TransactionHash(coinIdentifier) entry, ok := i.waiter.Get(txHash, true) if !ok { return nil, fmt.Errorf("transaction %s not in waiter", txHash) @@ -624,7 +624,7 @@ func (i *Indexer) Block( blockIdentifier *types.PartialBlockIdentifier, ) (*types.Block, error) { // get raw block - var btcBlock *bitcoin.Block + var btcBlock *lbry.Block var coins []string var err error @@ -672,14 +672,14 @@ func (i *Indexer) Block( func (i *Indexer) GetScriptPubKeys( ctx context.Context, coins []*types.Coin, -) ([]*bitcoin.ScriptPubKey, error) { +) ([]*lbry.ScriptPubKey, error) { databaseTransaction := i.database.NewDatabaseTransaction(ctx, false) defer databaseTransaction.Discard(ctx) - scripts := make([]*bitcoin.ScriptPubKey, len(coins)) + scripts := make([]*lbry.ScriptPubKey, len(coins)) for j, coin := range coins { coinIdentifier := coin.CoinIdentifier - transactionHash, networkIndex, err := bitcoin.ParseCoinIdentifier(coinIdentifier) + transactionHash, networkIndex, err := lbry.ParseCoinIdentifier(coinIdentifier) if err != nil { return nil, fmt.Errorf("%w: unable to parse coin identifier", err) } @@ -698,7 +698,7 @@ func (i *Indexer) GetScriptPubKeys( } for _, op := range transaction.Operations { - if op.Type != bitcoin.OutputOpType { + if op.Type != lbry.OutputOpType { continue } @@ -706,7 +706,7 @@ func (i *Indexer) GetScriptPubKeys( continue } - var opMetadata bitcoin.OperationMetadata + var opMetadata lbry.OperationMetadata if err := types.UnmarshalMap(op.Metadata, &opMetadata); err != nil { return nil, fmt.Errorf( "%w: unable to unmarshal operation metadata %+v", diff --git a/indexer/indexer_test.go b/indexer/indexer_test.go index 314a2f5..02bd17e 100644 --- a/indexer/indexer_test.go +++ b/indexer/indexer_test.go @@ -23,13 +23,13 @@ import ( "testing" "time" - "github.com/coinbase/rosetta-bitcoin/bitcoin" - "github.com/coinbase/rosetta-bitcoin/configuration" - mocks "github.com/coinbase/rosetta-bitcoin/mocks/indexer" + "github.com/lbryio/rosetta-lbry/configuration" + "github.com/lbryio/rosetta-lbry/lbry" + mocks "github.com/lbryio/rosetta-lbry/mocks/indexer" - "github.com/coinbase/rosetta-sdk-go/storage" - "github.com/coinbase/rosetta-sdk-go/types" - "github.com/coinbase/rosetta-sdk-go/utils" + "github.com/lbryio/rosetta-sdk-go/storage" + "github.com/lbryio/rosetta-sdk-go/types" + "github.com/lbryio/rosetta-sdk-go/utils" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) @@ -60,10 +60,10 @@ func TestIndexer_Pruning(t *testing.T) { minHeight := int64(200) cfg := &configuration.Configuration{ Network: &types.NetworkIdentifier{ - Network: bitcoin.MainnetNetwork, - Blockchain: bitcoin.Blockchain, + Network: lbry.MainnetNetwork, + Blockchain: lbry.Blockchain, }, - GenesisBlockIdentifier: bitcoin.MainnetGenesisBlockIdentifier, + GenesisBlockIdentifier: lbry.MainnetGenesisBlockIdentifier, Pruning: &configuration.PruningConfiguration{ Frequency: 50 * time.Millisecond, Depth: pruneDepth, @@ -75,7 +75,7 @@ func TestIndexer_Pruning(t *testing.T) { i, err := Initialize(ctx, cancel, cfg, mockClient) assert.NoError(t, err) - // Waiting for bitcoind... + // Waiting for lbryd... mockClient.On("NetworkStatus", ctx).Return(nil, errors.New("not ready")).Once() mockClient.On("NetworkStatus", ctx).Return(&types.NetworkStatusResponse{}, nil).Once() @@ -84,7 +84,7 @@ func TestIndexer_Pruning(t *testing.T) { CurrentBlockIdentifier: &types.BlockIdentifier{ Index: 1000, }, - GenesisBlockIdentifier: bitcoin.MainnetGenesisBlockIdentifier, + GenesisBlockIdentifier: lbry.MainnetGenesisBlockIdentifier, }, nil) // Timeout on first request @@ -132,7 +132,7 @@ func TestIndexer_Pruning(t *testing.T) { parentIdentifier.Hash = getBlockHash(0) } - block := &bitcoin.Block{ + block := &lbry.Block{ Hash: identifier.Hash, Height: identifier.Index, PreviousBlockHash: parentIdentifier.Hash, @@ -225,10 +225,10 @@ func TestIndexer_Transactions(t *testing.T) { mockClient := &mocks.Client{} cfg := &configuration.Configuration{ Network: &types.NetworkIdentifier{ - Network: bitcoin.MainnetNetwork, - Blockchain: bitcoin.Blockchain, + Network: lbry.MainnetNetwork, + Blockchain: lbry.Blockchain, }, - GenesisBlockIdentifier: bitcoin.MainnetGenesisBlockIdentifier, + GenesisBlockIdentifier: lbry.MainnetGenesisBlockIdentifier, IndexerPath: newDir, } @@ -240,13 +240,13 @@ func TestIndexer_Transactions(t *testing.T) { CurrentBlockIdentifier: &types.BlockIdentifier{ Index: 1000, }, - GenesisBlockIdentifier: bitcoin.MainnetGenesisBlockIdentifier, + GenesisBlockIdentifier: lbry.MainnetGenesisBlockIdentifier, }, nil) // Add blocks waitForCheck := make(chan struct{}) type coinBankEntry struct { - Script *bitcoin.ScriptPubKey + Script *lbry.ScriptPubKey Coin *types.Coin Account *types.AccountIdentifier } @@ -271,7 +271,7 @@ func TestIndexer_Transactions(t *testing.T) { rawHash := fmt.Sprintf("block %d transaction %d", i, j) hash := fmt.Sprintf("%x", sha256.Sum256([]byte(rawHash))) coinIdentifier := fmt.Sprintf("%s:%d", hash, index0) - scriptPubKey := &bitcoin.ScriptPubKey{ + scriptPubKey := &lbry.ScriptPubKey{ ASM: coinIdentifier, } marshal, err := types.MarshalMap(scriptPubKey) @@ -286,14 +286,14 @@ func TestIndexer_Transactions(t *testing.T) { Index: 0, NetworkIndex: &index0, }, - Status: bitcoin.SuccessStatus, - Type: bitcoin.OutputOpType, + Status: lbry.SuccessStatus, + Type: lbry.OutputOpType, Account: &types.AccountIdentifier{ Address: rawHash, }, Amount: &types.Amount{ Value: fmt.Sprintf("%d", rand.Intn(1000)), - Currency: bitcoin.TestnetCurrency, + Currency: lbry.TestnetCurrency, }, CoinChange: &types.CoinChange{ CoinAction: types.CoinCreated, @@ -323,7 +323,7 @@ func TestIndexer_Transactions(t *testing.T) { transactions = append(transactions, tx) } - block := &bitcoin.Block{ + block := &lbry.Block{ Hash: identifier.Hash, Height: identifier.Index, PreviousBlockHash: parentIdentifier.Hash, @@ -402,13 +402,13 @@ func TestIndexer_Transactions(t *testing.T) { if currBlock.BlockIdentifier.Index == 1000 { // Ensure ScriptPubKeys are accessible. allCoins := []*types.Coin{} - expectedPubKeys := []*bitcoin.ScriptPubKey{} + expectedPubKeys := []*lbry.ScriptPubKey{} for k, v := range coinBank { allCoins = append(allCoins, &types.Coin{ CoinIdentifier: &types.CoinIdentifier{Identifier: k}, Amount: &types.Amount{ Value: fmt.Sprintf("-%s", v.Coin.Amount.Value), - Currency: bitcoin.TestnetCurrency, + Currency: lbry.TestnetCurrency, }, }) expectedPubKeys = append(expectedPubKeys, v.Script) @@ -443,10 +443,10 @@ func TestIndexer_Reorg(t *testing.T) { mockClient := &mocks.Client{} cfg := &configuration.Configuration{ Network: &types.NetworkIdentifier{ - Network: bitcoin.MainnetNetwork, - Blockchain: bitcoin.Blockchain, + Network: lbry.MainnetNetwork, + Blockchain: lbry.Blockchain, }, - GenesisBlockIdentifier: bitcoin.MainnetGenesisBlockIdentifier, + GenesisBlockIdentifier: lbry.MainnetGenesisBlockIdentifier, IndexerPath: newDir, } @@ -458,13 +458,13 @@ func TestIndexer_Reorg(t *testing.T) { CurrentBlockIdentifier: &types.BlockIdentifier{ Index: 1000, }, - GenesisBlockIdentifier: bitcoin.MainnetGenesisBlockIdentifier, + GenesisBlockIdentifier: lbry.MainnetGenesisBlockIdentifier, }, nil) // Add blocks waitForCheck := make(chan struct{}) type coinBankEntry struct { - Script *bitcoin.ScriptPubKey + Script *lbry.ScriptPubKey Coin *types.Coin Account *types.AccountIdentifier } @@ -490,7 +490,7 @@ func TestIndexer_Reorg(t *testing.T) { rawHash := fmt.Sprintf("block %d transaction %d", i, j) hash := fmt.Sprintf("%x", sha256.Sum256([]byte(rawHash))) coinIdentifier := fmt.Sprintf("%s:%d", hash, index0) - scriptPubKey := &bitcoin.ScriptPubKey{ + scriptPubKey := &lbry.ScriptPubKey{ ASM: coinIdentifier, } marshal, err := types.MarshalMap(scriptPubKey) @@ -505,14 +505,14 @@ func TestIndexer_Reorg(t *testing.T) { Index: 0, NetworkIndex: &index0, }, - Status: bitcoin.SuccessStatus, - Type: bitcoin.OutputOpType, + Status: lbry.SuccessStatus, + Type: lbry.OutputOpType, Account: &types.AccountIdentifier{ Address: rawHash, }, Amount: &types.Amount{ Value: fmt.Sprintf("%d", rand.Intn(1000)), - Currency: bitcoin.TestnetCurrency, + Currency: lbry.TestnetCurrency, }, CoinChange: &types.CoinChange{ CoinAction: types.CoinCreated, @@ -541,7 +541,7 @@ func TestIndexer_Reorg(t *testing.T) { transactions = append(transactions, tx) } - block := &bitcoin.Block{ + block := &lbry.Block{ Hash: identifier.Hash, Height: identifier.Index, PreviousBlockHash: parentIdentifier.Hash, @@ -685,10 +685,10 @@ func TestIndexer_HeaderReorg(t *testing.T) { mockClient := &mocks.Client{} cfg := &configuration.Configuration{ Network: &types.NetworkIdentifier{ - Network: bitcoin.MainnetNetwork, - Blockchain: bitcoin.Blockchain, + Network: lbry.MainnetNetwork, + Blockchain: lbry.Blockchain, }, - GenesisBlockIdentifier: bitcoin.MainnetGenesisBlockIdentifier, + GenesisBlockIdentifier: lbry.MainnetGenesisBlockIdentifier, IndexerPath: newDir, } @@ -700,7 +700,7 @@ func TestIndexer_HeaderReorg(t *testing.T) { CurrentBlockIdentifier: &types.BlockIdentifier{ Index: 1000, }, - GenesisBlockIdentifier: bitcoin.MainnetGenesisBlockIdentifier, + GenesisBlockIdentifier: lbry.MainnetGenesisBlockIdentifier, }, nil) // Add blocks @@ -720,7 +720,7 @@ func TestIndexer_HeaderReorg(t *testing.T) { } transactions := []*types.Transaction{} - block := &bitcoin.Block{ + block := &lbry.Block{ Hash: identifier.Hash, Height: identifier.Index, PreviousBlockHash: parentIdentifier.Hash, @@ -747,7 +747,7 @@ func TestIndexer_HeaderReorg(t *testing.T) { mock.Anything, &types.PartialBlockIdentifier{Index: &identifier.Index}, ).Return( - &bitcoin.Block{ + &lbry.Block{ Hash: identifier.Hash, Height: identifier.Index, PreviousBlockHash: "blah", diff --git a/install.sh b/install.sh index 5f9b4b3..02b6955 100755 --- a/install.sh +++ b/install.sh @@ -20,7 +20,7 @@ set -e usage() { this=$1 cat <