Skip to content

Conversation

@mainnet-pat
Copy link

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 optional watchMempool optional to steer this new behaviour.

The newly added bch-processor project requires ESM support, so I have updated typeorm-codegen to output code compatible both with CJS and ESM targets. Also I have updated typeorm-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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant