Git Product home page Git Product logo

electrs's Introduction

Esplora - Electrs backend API

A block chain index engine and HTTP API written in Rust based on romanz/electrs.

Used as the backend for the Esplora block explorer powering blockstream.info.

API documentation is available here.

Documentation for the database schema and indexing process is available here.

Installing & indexing

Install Rust, Bitcoin Core (no txindex needed) and the clang and cmake packages, then:

$ git clone https://github.com/blockstream/electrs && cd electrs
$ git checkout new-index
$ cargo run --release --bin electrs -- -vvvv --daemon-dir ~/.bitcoin

# Or for liquid:
$ cargo run --features liquid --release --bin electrs -- -vvvv --network liquid --daemon-dir ~/.liquid

See electrs's original documentation for more detailed instructions. Note that our indexes are incompatible with electrs's and has to be created separately.

The indexes require 610GB of storage after running compaction (as of June 2020), but you'll need to have free space of about double that available during the index compaction process. Creating the indexes should take a few hours on a beefy machine with SSD.

To deploy with Docker, follow the instructions here.

Light mode

For personal or low-volume use, you may set --lightmode to reduce disk storage requirements by roughly 50% at the cost of slower and more expensive lookups.

With this option set, raw transactions and metadata associated with blocks will not be kept in rocksdb (the T, X and M indexes), but instead queried from bitcoind on demand.

Notable changes from Electrs:

  • HTTP REST API in addition to the Electrum JSON-RPC protocol, with extended transaction information (previous outputs, spending transactions, script asm and more).

  • Extended indexes and database storage for improved performance under high load:

    • A full transaction store mapping txids to raw transactions is kept in the database under the prefix t.
    • An index of all spendable transaction outputs is kept under the prefix O.
    • An index of all addresses (encoded as string) is kept under the prefix a to enable by-prefix address search.
    • A map of blockhash to txids is kept in the database under the prefix X.
    • Block stats metadata (number of transactions, size and weight) is kept in the database under the prefix M.

    With these new indexes, bitcoind is no longer queried to serve user requests and is only polled periodically for new blocks and for syncing the mempool.

  • Support for Liquid and other Elements-based networks, including CT, peg-in/out and multi-asset. (requires enabling the liquid feature flag using --features liquid)

CLI options

In addition to electrs's original configuration options, a few new options are also available:

  • --http-addr <addr:port> - HTTP server address/port to listen on (default: 127.0.0.1:3000).
  • --lightmode - enable light mode (see above)
  • --cors <origins> - origins allowed to make cross-site request (optional, defaults to none).
  • --address-search - enables the by-prefix address search index.
  • --index-unspendables - enables indexing of provably unspendable outputs.
  • --utxos-limit <num> - maximum number of utxos to return per address.
  • --electrum-txs-limit <num> - maximum number of txs to return per address in the electrum server (does not apply for the http api).
  • --electrum-banner <text> - welcome banner text for electrum server.

Additional options with the liquid feature:

  • --parent-network <network> - the parent network this chain is pegged to.

Additional options with the electrum-discovery feature:

  • --electrum-hosts <json> - a json map of the public hosts where the electrum server is reachable, in the server.features format.
  • --electrum-announce - announce the electrum server on the electrum p2p server discovery network.

See $ cargo run --release --bin electrs -- --help for the full list of options.

License

MIT

electrs's People

Contributors

andrewtoth avatar daniel-savu avatar darosior avatar greenaddress avatar jamesdorfman avatar junderw avatar mariusz-reichert avatar philippem avatar rcasatta avatar romanz avatar shesek avatar stevenroose avatar yancyribbens avatar yusukeshimizu avatar zpv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

electrs's Issues

Testing with electrum 4.5.4 returns error

From #97 logs

---- test_electrum stdout ----
thread 'test_electrum' panicked at tests/electrum.rs:38:9:
assertion `left == right` failed
  left: Some("0.139")
 right: Some("0.3")
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

GET /address/:address/txs/mempool return only current block data

Hi,

I'm using a self-hosted Electrs instance. I want to retrieve all transactions in the mempool by address, but when I request GET /address/:address/txs/mempool, I only get transactions from the latest block. How can I fix this? Do I need to add something to the configuration?

Thanks!

Versioning

It would be great if this project could introduce versioning. Having a moving target (master or the default branch) makes this somewhat hard to deploy.

Electrs does not work due to rapidly consuming all available memory

Even with 16 GB of RAM and at least 14 GB of RAM available, electrs rapidly consumes all RAM then causes the OS to freeze up. Even when capping the amount of RAM that the process or user can use, it still depletes all the allocated available memory and instead of being throttled, the process is just simply killed.

I am running debian. Is this an issue with debian or electrs? Has anyone ever tried to run an electrs server (I know Blockstream does), if so what do you do to run it successfully?

Use rust bitcoin `deserialize_hex` when upgrading version

          Unrelated to this PR, but I noticed `tx_from_value` (and `block_from_value`) could probably be improved by using rust bitcoin `deserialize_hex` which doesn't allocate the intermediate vector of bytes.

Just noticed the rust bitcoin version we are currently using doesn't have that yet, leaving this here anyway if we want to upgrade in the future.

Originally posted by @RCasatta in #89 (comment)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.