---
# System prepended metadata

title: PIT Replacement

---

# PIT Replacement
## PIT requirements
Currently PIT supports streaming following events:
* eth transfers
* eth balances
* erc20 transfers
* erc20 balances

### Current implementation
Because of a streaming nature and emitting events for all affected wallets and contracts, following approaches were applied:

* eth transfers built on top of parsing evm traces, building a graph of nested calls representing relations between senders and receivers of eth transfers (see [Parity Traces](https://wiki.parity.io/JSONRPC-trace-module#trace_replayblocktransactions), `trace` mode). 
* eth balances built on top of parsing evm state difs (see [Parity Traces](https://wiki.parity.io/JSONRPC-trace-module#trace_replayblocktransactions), `stateDiff` mode);
* erc20 transfers built on top of parsing event logs, extracting information about transfers by matching hex topic representation with erc20 abi for a transfer function (see [Parity Logs](https://wiki.parity.io/JSONRPC-eth-module.html#eth_getlogs). 
* erc20 balances built on top of parsing state diff storage memory, extracting data about affected wallet (no information about related contract (i.e. token)) and actual balance and matching contract with previously found erc20 transfers (which contains only balance change delta value) by affected address.

### Possible re-implementation based on external data sources: 
* eth transfers: no public api have been found solving this problem.
* eth balances: can be solved by requesting balances one by one for each managed wallet, having no information about affected wallets in a particular transaction/block all managed wallets have to be checked for all related contracts (tokens). One-ny-one requests are required according all known provided external solutions;
* erc20 transfers: can be solved by reimplementing the same approach as it is already implemented in PIT by by matching hex topic representation with erc20 abi for a transfer function.;
* erc20 balances: can be solved by requesting balances one by one for managed wallets and known related contracts (tokens). Affected managed wallets could be found from erc20 transfers.

## Alchemy Api Integration
### Parity Replacement
Required API used by PIT service

| Parity                               | Alchemy                     						    |
| ------------------------------------ | -------------------------------------------------------------------------------| 
|  ✓ eth_blockNumber                   | ✓ eth_blockNumber                 						| 
|  ✓ eth_getBlockByNumber              | ✓ eth_getBlockByNumber            						| 
|  ✓ eth_getBlockByHash                | ✓ eth_getBlockByHash              						| 
|  ✓ eth_getLogs                       | ✓ eth_getLogs                     						| 
|  ✓ eth_getTransactionReceipt         | ✓ eth_getTransactionReceipt       						| 
|  ✓ trace_replayBlockTransactions     | trace_replayBlockTransactions (available to Alchemy users in private beta)     | 
Current version of Alchemy API satisfies all requirements and can replace Parity node.

### PIT Service Replacement

| Feature 		| PIT     					| Parity 										| Alchemy 											|
| ----------------------| ----------------------------------------------|---------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------| 
| Eth transfers 	| Eth transfers stream for all addresses 	| — 											| — 												| 
| Eth balance 		| Eth balances stream for all addresses 	| Eth balance per known address per request. Allow batch requests 			| Eth balance per known address per request 							| 
| Erc20 transfers 	| Erc20 transfers stream for all addresses 	| Could be extracted from event logs 							|Could be extracted from event logs. The same effort as for current PIT implementation required | 
| Erc20 balances	| Erc20 balances stream for all addresses 	| Erc20 balance per known address per known contract per request. Allow batch requests 	| Erc20 balance per known address per all known contracts per request 				| 


## Anyblock Api Integration
### Parity Replacement
Anyblock doesn’t provide Parity-like API as a main feature and insists on using ElasticSearch Api. 
ElasticSearch is almost compatible with PIT model but incompatible with PIT encoders/decoders. New encoders/decoders required for all model entities.

| Parity                               | Anyblock                         						|
| ------------------------------------ | -------------------------------------------------------------------------------| 
|  ✓ eth_blockNumber                   | ✓ could be done via web hooks (requesting the last mined block number)		| 
|  ✓ eth_getBlockByNumber              | ✓ /ethereum/ethereum/mainnet/es/block/search/      				| 
|  ✓ eth_getBlockByHash                | ✓ /ethereum/ethereum/mainnet/es/block/search/      				| 
|  ✓ eth_getLogs                       | ✓  /ethereum/ethereum/mainnet/es/log/search/					| 
|  ✓ eth_getTransactionReceipt         | x*       									| 
|  ✓ trace_replayBlockTransactions     |  /es/trace/search/								| 

* transaction model provided by Anyblock already contains the `gasUsed` field, so we could get rid of Transaction Receipt, but changes into the current flow required.

### PIT Service Replacement

| Feature 		| PIT     					| Parity 										| Anyblock 											|
| ----------------------| ----------------------------------------------|---------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------| 
| Eth transfers 	| Eth transfers stream for all addresses 	| — 											| — 												| 
| Eth balance 		| Eth balances stream for all addresses 	| Eth balance per known address per request. Allow batch requests 			| Batch queries to PostgreSQL DB	 							| 
| Erc20 transfers 	| Erc20 transfers stream for all addresses 	| Could be extracted from event logs 							|Could be extracted from event logs							 	| 
| Erc20 balances	| Erc20 balances stream for all addresses 	| Erc20 balance per known address per known contract per request. Allow batch requests 	| Not supported yet						 				| 

## Blockcypher Api Integration
### Parity Replacement
Blockcypher doesn’t provide Parity-like Api.

| Parity                               | Blockcypher                         						|
| ------------------------------------ | -------------------------------------------------------------------------------| 
|  ✓ eth_blockNumber                   | ✓ could be done via web hooks		| 
|  ✓ eth_getBlockByNumber              | ✓ /blocks/$BLOCK_HEIGHT      				| 
|  ✓ eth_getBlockByHash                | ✓ /blocks/$BLOCK_HASH      				| 
|  ✓ eth_getLogs                       | x					| 
|  ✓ eth_getTransactionReceipt         | x       									| 
|  ✓ trace_replayBlockTransactions     | x								| 

### PIT Service Replacement

| Feature 		| PIT     					| Parity 										| Blockcypher 											|
| ----------------------| ----------------------------------------------|---------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------| 
| Eth transfers 	| Eth transfers stream for all addresses 	| — 											| — 												| 
| Eth balance 		| Eth balances stream for all addresses 	| Eth balance per known address per request. Allow batch requests 			| Eth balance per known address per request	 							| 
| Erc20 transfers 	| Erc20 transfers stream for all addresses 	| Could be extracted from event logs 							| —						 	| 
| Erc20 balances	| Erc20 balances stream for all addresses 	| Erc20 balance per known address per known contract per request. Allow batch requests 	| —						 				| 


## Parity vs. Get
### Model
#### Block
Parity block model contains extra fields:
* author: Address - 20 Bytes - the address of the author of the block (the beneficiary to whom the mining rewards were given)

#### Transaction
Parity transaction model contains extra fields:
* nonce: Quantity - the number of transactions made by the sender prior to this one.
* standardV: Quantity - the standardised V field of the signature (0 or 1).
* raw: Data - raw transaction data
* publicKey: Hash - public key of the signer.
* chainId: Quantity - the chain id of the transaction, if any.
* creates: Hash - creates contract hash
* condition: Object - (optional) conditional submission, Block number in block or timestamp in time or null. (parity-feature)

#### Receipt
Identical

#### Log
Identical

### Api
| Parity                               | Geth                         						|
| ------------------------------------ | -------------------------------------------------------------------------------| 
|  ✓ eth_blockNumber                   | ✓ eth_blockNumber		| 
|  ✓ eth_getBlockByNumber              | ✓ eth_getBlockByNumber      				| 
|  ✓ eth_getBlockByHash                | ✓ eth_getBlockByHash      				| 
|  ✓ eth_getLogs                       | ✓ eth_getLogs					| 
|  ✓ eth_getTransactionReceipt         | ?       									| 
|  ✓ trace_replayBlockTransactions     | ✓ trace_replayBlockTransactions								| 