[WIP] Support ESM targets, add BCH support #361
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds support for BCH blockchain. Its distinct feature is the 0-confirmation of transactions, which means that all transactions included into mempool in-between 10-minute blocks are contributing to the real-time final state of the blockchain.
The mempool tracking and rollback was added to database. In this implementation I treat mempool transactions to be those included in a special hot block with height -2. Mempool tracking kicks-in as soon as hot datasource reaches the blockchain tip (util/util-internal-processor-tools/src/datasource.ts). Upon new block arrival we roll back the mempool hot block and reapplying the confirmed transactions again in context of new block. The
Runner
now has an optionalwatchMempool
optional to steer this new behaviour.The newly added
bch-processor
project requires ESM support, so I have updatedtypeorm-codegen
to output code compatible both with CJS and ESM targets. Also I have updatedtypeorm-migration
to optionally output (steered with--esm true
option) ESM compatible migration scripts.The new
bch-processor
was developed on the base of EVM batch processor and mimics its behaviour at large extent. Currently there is no cold ingest possible from squid gateways, so all blocks are ingested from RPC, which makes the squid sync sluggish. Current RPC implementation is based on requests made both to ElectrumX indexing servers (blockchain tip, historical transactions) and from BCH's P2P network layer (raw blocks, raw mempool, mempool notifications).A sample squid to index BCH native tokens was deployed to demonstrate the new BCH processor at http://squid.pat.mn (self-hosted) and on SQD cloud platform. Its source code is available at https://github.com/mainnet-pat/bch-cashtokens-subsquid
Looking for your feedback and eager to contribute to enable the BCH Gateway/Portal support.