Giter VIP home page Giter VIP logo

electrumx's Introduction

https://travis-ci.org/kyuupichan/electrumx.svg?branch=master

ElectrumX - Reimplementation of electrum-server

For a future network with bigger blocks.

Licence:MIT
Language:Python (>= 3.5.3)
Author:Neil Booth

Getting Started

See docs/HOWTO.rst. There is also an installer available that simplifies the installation on various Linux-based distributions. There is also an Dockerfile available .

Features

  • Efficient, lightweight reimplementation of electrum-server
  • Fast synchronization of bitcoin mainnet from Genesis. Recent hardware should synchronize in well under 24 hours. The fastest time to height 448k (mid January 2017) reported is under 4h 30m. On the same hardware JElectrum would take around 4 days and electrum-server probably around 1 month.
  • The full Electrum protocol is implemented. The only exception is the blockchain.address.get_proof RPC call, which is not used by Electrum GUI clients, and can only be invoked from the command line.
  • Various configurable means of controlling resource consumption and handling denial of service attacks. These include maximum connection counts, subscription limits per-connection and across all connections, maximum response size, per-session bandwidth limits, and session timeouts.
  • Minimal resource usage once caught up and serving clients; tracking the transaction mempool appears to be the most expensive part.
  • Fully asynchronous processing of new blocks, mempool updates, and client requests. Busy clients should not noticeably impede other clients' requests and notifications, nor the processing of incoming blocks and mempool updates.
  • Daemon failover. More than one daemon can be specified, and ElectrumX will failover round-robin style if the current one fails for any reason.
  • Peer discovery protocol removes need for IRC
  • Coin abstraction makes compatible altcoin and testnet support easy.

Motivation

Mainly for privacy reasons, I have long wanted to run my own Electrum server, but I struggled to set it up or get it to work on my DragonFlyBSD system and lost interest for over a year.

In September 2016 I heard that electrum-server databases were getting large (35-45GB when gzipped), and it would take several weeks to sync from Genesis (and was sufficiently painful that no one seems to have done it for about a year). This made me curious about improvements and after taking a look at the code I decided to try a different approach.

I prefer Python3 over Python2, and the fact that Electrum is stuck on Python2 has been frustrating for a while. It's easier to change the server to Python3 than the client, so I decided to write my effort in Python3.

It also seemed like a good opportunity to learn about asyncio, a wonderful and powerful feature introduced in Python 3.4. Incidentally, asyncio would also make a much better way to implement the Electrum client.

Finally though no fan of most altcoins I wanted to write a codebase that could easily be reused for those alts that are reasonably compatible with Bitcoin. Such an abstraction is also useful for testnets.

Implementation

ElectrumX does not do any pruning or throwing away of history. I want to retain this property for as long as it is feasible, and it appears efficiently achievable for the forseeable future with plain Python.

The following all play a part in making ElectrumX very efficient as a Python blockchain indexer:

  • aggressive caching and batching of DB writes
  • more compact and efficient representation of UTXOs, address index, and history. Electrum Server stores full transaction hash and height for each UTXO, and does the same in its pruned history. In contrast ElectrumX just stores the transaction number in the linear history of transactions. For at least another 5 years this transaction number will fit in a 4-byte integer, and when necessary expanding to 5 or 6 bytes is trivial. ElectrumX can determine block height from a simple binary search of tx counts stored on disk. ElectrumX stores historical transaction hashes in a linear array on disk.
  • placing static append-only metadata indexable by position on disk rather than in levelDB. It would be nice to do this for histories but I cannot think of a way.
  • avoiding unnecessary or redundant computations, such as converting address hashes to human-readable ASCII strings with expensive bignum arithmetic, and then back again.
  • better choice of Python data structures giving lower memory usage as well as faster traversal
  • leveraging asyncio for asynchronous prefetch of blocks to mostly eliminate CPU idling. As a Python program ElectrumX is unavoidably single-threaded in its essence; we must keep that CPU core busy.

Python's asyncio means ElectrumX has no (direct) use for threads and associated complications.

Roadmap

  • Require Python 3.6, which has several performance improvements relevant to ElectrumX
  • offloading more work to synchronize to the client
  • supporting better client privacy
  • wallet server engine
  • new features such as possibly adding label server functionality
  • potentially move some functionality to C or C++

ChangeLog

Version 1.1.1

  • various refactorings, improvement of env var handling
  • update docs to match
  • various optimizations mainly affecting initial sync (Justin Arthur)
  • Dash fixes (cipig)
  • Add ALLOW_ROOT option (Luke Childs)
  • Add BitZeny support, update Monacoin (cryptocoin-junkey)

Version 1.1

See the changelogs below for recent changes. The most important is that for mainnet bitcoin NET must now be mainnet and you must choose a COIN from BitcoinCash and BitcoinSegwit. Similarly for testnets. These coins will likely diverge further in future so it's best they become separate coins now.

  • no longer persist peers, rediscover on restart
  • onion peers only reported if can connect; hard-coded exception removed
  • small fix for blockchain.transaction.broadcast

Version 1.1pre2

  • peerdisc: handle protocol 1.1 server replies
  • issue #251: fix protocol version reported in server.peers.subscribe
  • fix handling of failed transaction broadcast
  • fix typos (SomberNight)
  • doc and test updates
  • dash: return errors in JSON error field for protocol 1.1

Version 1.1pre1

Many changes, mostly to prepare for support of Electrum protocol 1.1 which the next Electrum client release will use.

NOTE: the COIN environment variable is now mandatory, and if you were running for any bitcoin flavour (Cash, Segwit, mainnet or testnet) you will need to update your COIN and NET environment variable settings as the old ones will no longer work.

  • implement protocol version 1.1 and update protocol documentation
  • rework lib/coins.py for the various bitcoin flavours
  • show protocol version in "sessions" ElectrumX RPC call
  • permit HOST envvar to be a comma-separated list
  • daemon abstraction refactoring (erasmospunk)
  • permit alternative event loop policies (based on suggestion / work of JustinTArthur)
  • misc configuration updates (SubPar)
  • add Neblio support (neblioteam) and Bitbay (anoxxxy)
  • HOWTO.rst update for running on privileged port (EagleTM)
  • issues closed: exclude test dirs from installation (#223).

Version 1.0.17

  • fix #227 introduced in 1.0.16

Version 1.0.16

  • updated server lists for post-fork. If you are on the Segwit chain you should have NET be "bitcoin-segwit", and if on the Bitcoin Cash chain continue to use "mainnet".
  • binding address fix for multi-homed machines (mmouse)
  • listen to IPv4 and IPv6 local interfaces
  • add Fujicoin (fujicoin), Crown (Extreemist), RegTest (RCasatta), Monacoin (cryptocoin-junkey)
  • bug fixes and updates (Kefkius, mmouse, thesamesam, cryptocoin-junkey, jtarthur)

Version 1.0.15

  • split server networks faster if a fork is detected
  • minor speedup
  • add Vertcoin support (erasmospunk)
  • update Faircoin (thokon00)

Version 1.0.14

  • revert the changes to mempool handling of 1.0.13; I think they introduced a notification bug

Version 1.0.13

  • improve mempool handling and height notifications
  • add bitcoin-segwit as a new COIN

Version 1.0.12

  • handle legacy daemons, add support for Blackcoin and Peercoin (erasmospunk)
  • implement history compression; can currently only be done from a script with the server down
  • Add dockerfile reference (followtheart)
  • doc, runfile fixes (Henry, emilrus)
  • add bip32 implementation, currently unused
  • daemon compatibility improvements (erasmospunk)
  • permit underscores in hostnames, updated Bitcoin server list

Version 1.0.11

  • disable IRC for bitcoin mainnet
  • remove dead code, allow custom Daemon & BlockProcessor classes (erasmospunk)
  • add SERVER_(SUB)VERSION to banner metavariables (LaoDC)
  • masternode methods for Dash (TheLazier)
  • allow multiple P2SH address versions, implement for Litecoin (pooler)
  • update Bitcoin's TX_COUNT and block height (JWU42)
  • update BU nolnet parameters
  • fix diagnostic typo (anduck)
  • Issues fixed: #180

Neil Booth [email protected] https://github.com/kyuupichan

1BWwXJH3q6PRsizBkSGm2Uw4Sz1urZ5sCj

electrumx's People

Contributors

erasmospunk avatar thelazier avatar bauerj avatar laodc avatar cryptcoin-junkey avatar shsmith avatar valesi avatar sombernight avatar subpar42 avatar cluelessperson avatar protonn avatar pooler avatar fr3aker avatar cipig avatar thokon00 avatar justintarthur avatar xhire avatar thesamesam avatar romanornr avatar mmouse- avatar magichex avatar lahlor avatar followtheart avatar emilrus avatar rcasatta avatar petrkr avatar zhovner avatar nebliodev avatar nmarley avatar lukechilds avatar

Watchers

James Cloos avatar  avatar

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.