V3.0.0 of SubQuery is a large release with a lot of new features. Although there are no breaking changes we felt that there was a large enough improvement to justify a major version bump. To use these new features please make sure to use the latest versions of the SubQuery dependencies in your project.
This allows users to upgrade projects at specific heights. This is useful with the network where there is currently no way to update a project if the contracts need updating or the chain has upgrades.
As the project manifest gets more complex when we add more features it gets very hard to know how to write. It's now possible to write your manifest in typescript. This means that you get a fully typed project manifest with documentation and examples in your editor.
import { SubstrateDatasourceKind, SubstrateHandlerKind, SubstrateProject } from "@subql/types";
// Can expand the Datasource processor types via the genreic param
const project: SubstrateProject = {
specVersion: "1.0.0",
version: '1.0.0',
runner: {
node: {
name: '@subql/node',
version: "*",
},
query: {
name: '@subql/query',
version: "*"
},
},
schema: {
file: './schema.graphql'
},
network: {
chainId: '0x91b171bb158e2d3848fa23a9f1c25182fb8e20313b2c1eb49219da7a70ce90c3',
bypassBlocks: [5, '1-10'],
endpoint: 'wss://polkadot.api.onfinality.io/public-ws'
},
dataSources: [
{
kind: SubstrateDatasourceKind.Runtime,
startBlock: 1,
mapping: {
file: './dist/index.js',
handlers: [
{
kind: SubstrateHandlerKind.Block,
handler: 'handleBlock',
filter: {
modulo: 5,
}
},
{
kind: SubstrateHandlerKind.Call,
handler: 'handleCall',
filter: {
module: 'balances',
method: 'Deposit',
success: true,
}
},
{
kind: SubstrateHandlerKind.Event,
handler: 'handleEvent',
filter: {
module: 'balances',
method: 'Deposit',
}
}
]
}
}
],
}
export default project;
// TODO docs
Ethereum and Substrate support this new option that can be specified in your manifest. If the project only has event handlers and data from transactions/extrinsics isn't used within the handlers then this option can be used to speed up indexing, reduce RPC requests and memory usage. Other SDKs will get this feature in the future.
You can update your handlers to use the new types if you have this setting enabled:
Before:
async function handleTransfer(event: TransferLog): Promise<void> {
...
}
After:
async function handleTransfer(event: LightTransferLog): Promise<void> {
...
}
Before:
async function handleTransfer(event: SubstrateEvent): Promise<void> {
...
}
After:
async function handleTransfer(event: LightSubstrateEvent): Promise<void> {
...
}
Proof-of-indexing has been rebuilt to be much simpler. It has removed the Merkle Mountain Range dependency and data. POI should now be much more reliable and less buggy. When you first upgrade to 3.0 a migration step will be made to existing projects using the old POI. If the project used a file based MMR you can manually delete these files once the upgrade is complete.
A long requested feature has been to query data by multiple fields from within mapping handlers. There is now a getByFields
method to do this. See the documentation for more details.
Like with the Ethereum SDK we will now generate more specific types for messages. These types are generated from the chain types protobufs as well as for Cosmwasm contracts.
- Improved load balancing amongst workers
- Faster block fetching. Rather than fetching in batches they are now fetched with a moving window
- When multiple RPC endpoints are provided if one of them fails on startup it won't stop the indexer from starting