envio
Version:
A latency and sync speed optimized, developer friendly blockchain data indexer.
747 lines (746 loc) • 22.2 kB
JSON
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "Envio Config Schema",
"description": "Schema for a YAML config for an envio indexer",
"type": "object",
"properties": {
"name": {
"description": "Name of the project",
"type": "string"
},
"description": {
"description": "Description of the project",
"type": [
"string",
"null"
]
},
"schema": {
"description": "Custom path to schema.graphql file",
"type": [
"string",
"null"
]
},
"handlers": {
"description": "Optional relative path to handlers directory for auto-loading. Defaults to 'src/handlers' if not specified.",
"type": [
"string",
"null"
]
},
"full_batch_size": {
"description": "Target number of events to be processed per batch. Set it to smaller number if you have many Effect API calls which are slow to resolve and can't be batched. (Default: 5000)",
"type": [
"integer",
"null"
],
"format": "uint64",
"minimum": 0
},
"storage": {
"description": "Storage backends the indexer writes data to. Defaults to Postgres when omitted. Set `clickhouse: true` to additionally sync the indexed data to ClickHouse. Mark a backend with `default: true` to store entities that don't have an @storage directive in the schema, e.g. `clickhouse: {default: true}`.",
"anyOf": [
{
"$ref": "#/$defs/StorageConfig"
},
{
"type": "null"
}
]
},
"ecosystem": {
"description": "Ecosystem of the project.",
"anyOf": [
{
"$ref": "#/$defs/EcosystemTag"
},
{
"type": "null"
}
]
},
"contracts": {
"description": "Global contract definitions that must contain all definitions except addresses. You can share a single handler/abi/event definitions for contracts across multiple chains.",
"type": [
"array",
"null"
],
"items": {
"$ref": "#/$defs/GlobalContract"
}
},
"chains": {
"description": "Configuration of the blockchain chains that the project is deployed on.",
"type": "array",
"items": {
"$ref": "#/$defs/Chain"
}
},
"rollback_on_reorg": {
"description": "A flag to indicate if the indexer should rollback to the last known valid block on a reorg. This currently incurs a performance hit on historical sync and is recommended to turn this off while developing (default: true)",
"type": [
"boolean",
"null"
]
},
"save_full_history": {
"description": "A flag to indicate if the indexer should save the full history of events. This is useful for debugging but will increase the size of the database (default: false)",
"type": [
"boolean",
"null"
]
},
"field_selection": {
"description": "Select the block and transaction fields to include in all events globally",
"anyOf": [
{
"$ref": "#/$defs/FieldSelection"
},
{
"type": "null"
}
]
},
"raw_events": {
"description": "If true, the indexer will store the raw event data in the database. This is useful for debugging, but will increase the size of the database and the amount of time it takes to process events (default: false)",
"type": [
"boolean",
"null"
]
},
"address_format": {
"description": "Address format for Ethereum addresses: 'checksum' or 'lowercase' (default: checksum)",
"anyOf": [
{
"$ref": "#/$defs/AddressFormat"
},
{
"type": "null"
}
]
}
},
"additionalProperties": false,
"required": [
"name",
"chains"
],
"$defs": {
"StorageConfig": {
"type": "object",
"properties": {
"postgres": {
"description": "Whether to use Postgres as a storage backend (default: true). Accepts a boolean or an options object (the object form implies the backend is enabled).",
"anyOf": [
{
"type": [
"boolean",
"null"
]
},
{
"type": "object",
"properties": {
"default": {
"description": "Whether entities without an @storage directive are stored in this backend (default: true when Postgres is the only enabled backend, false otherwise).",
"type": [
"boolean",
"null"
]
},
"column_name_format": {
"description": "How entity fields are reflected in the storage column names. `original` keeps the schema.graphql field names as is, `snake_case` converts them to snake_case in the database while keeping the original casing in the exposed APIs. (default: original)",
"type": [
"string",
"null"
],
"enum": [
"original",
"snake_case",
null
]
}
},
"additionalProperties": false
}
]
},
"clickhouse": {
"description": "Whether to additionally sync the indexed data to ClickHouse. Requires Postgres to be enabled (default: false). Accepts a boolean or an options object (the object form implies the backend is enabled).",
"anyOf": [
{
"type": [
"boolean",
"null"
]
},
{
"type": "object",
"properties": {
"default": {
"description": "Whether entities without an @storage directive are stored in this backend (default: false).",
"type": [
"boolean",
"null"
]
},
"column_name_format": {
"description": "How entity fields are reflected in the storage column names. `original` keeps the schema.graphql field names as is, `snake_case` converts them to snake_case in the database while keeping the original casing in the exposed APIs. (default: original)",
"type": [
"string",
"null"
],
"enum": [
"original",
"snake_case",
null
]
}
},
"additionalProperties": false
}
]
}
},
"additionalProperties": false,
"allOf": [
{
"not": {
"properties": {
"postgres": {
"const": false
}
},
"required": [
"postgres"
]
}
},
{
"if": {
"properties": {
"clickhouse": {
"anyOf": [
{
"const": true
},
{
"type": "object"
}
]
}
},
"required": [
"clickhouse"
]
},
"then": {
"properties": {
"postgres": {
"anyOf": [
{
"const": true
},
{
"type": "object"
}
]
}
},
"required": [
"postgres"
]
}
}
]
},
"EcosystemTag": {
"type": "string",
"enum": [
"evm"
]
},
"GlobalContract": {
"type": "object",
"properties": {
"name": {
"description": "A unique project-wide name for this contract (no spaces)",
"type": "string"
},
"abi_file_path": {
"description": "Relative path (from config) to a json abi. If this is used then each configured event should simply be referenced by its name",
"type": [
"string",
"null"
]
},
"handler": {
"description": "Optional relative path to a file where handlers are registered for the given contract. If not provided, handlers can be auto-loaded from src directory.",
"type": [
"string",
"null"
]
},
"events": {
"description": "A list of events that should be indexed on this contract",
"type": "array",
"items": {
"$ref": "#/$defs/EventConfig"
}
}
},
"additionalProperties": false,
"required": [
"name",
"events"
]
},
"EventConfig": {
"type": "object",
"properties": {
"event": {
"description": "The human readable signature of an event 'eg. Transfer(address indexed from, address indexed to, uint256 value)' OR a reference to the name of an event in a json ABI file defined in your contract config. A provided signature will take precedence over what is defined in the json ABI",
"type": "string"
},
"name": {
"description": "Name of the event in the HyperIndex generated code. When ommitted, the event field will be used. Should be unique per contract",
"type": [
"string",
"null"
]
},
"field_selection": {
"description": "Select the block and transaction fields to include in the specific event",
"anyOf": [
{
"$ref": "#/$defs/FieldSelection"
},
{
"type": "null"
}
]
}
},
"additionalProperties": false,
"required": [
"event"
]
},
"FieldSelection": {
"type": "object",
"properties": {
"transaction_fields": {
"description": "The transaction fields to include in the event, or in all events if applied globally",
"type": [
"array",
"null"
],
"items": {
"$ref": "#/$defs/TransactionField"
}
},
"block_fields": {
"description": "The block fields to include in the event, or in all events if applied globally",
"type": [
"array",
"null"
],
"items": {
"$ref": "#/$defs/BlockField"
}
}
},
"additionalProperties": false
},
"TransactionField": {
"type": "string",
"enum": [
"transactionIndex",
"hash",
"from",
"to",
"gas",
"gasPrice",
"maxPriorityFeePerGas",
"maxFeePerGas",
"cumulativeGasUsed",
"effectiveGasPrice",
"gasUsed",
"input",
"nonce",
"value",
"v",
"r",
"s",
"contractAddress",
"logsBloom",
"root",
"status",
"yParity",
"accessList",
"maxFeePerBlobGas",
"blobVersionedHashes",
"type",
"l1Fee",
"l1GasPrice",
"l1GasUsed",
"l1FeeScalar",
"gasUsedForL1",
"authorizationList"
]
},
"BlockField": {
"type": "string",
"enum": [
"parentHash",
"nonce",
"sha3Uncles",
"logsBloom",
"transactionsRoot",
"stateRoot",
"receiptsRoot",
"miner",
"difficulty",
"totalDifficulty",
"extraData",
"size",
"gasLimit",
"gasUsed",
"uncles",
"baseFeePerGas",
"blobGasUsed",
"excessBlobGas",
"parentBeaconBlockRoot",
"withdrawalsRoot",
"l1BlockNumber",
"sendCount",
"sendRoot",
"mixHash"
]
},
"Chain": {
"type": "object",
"properties": {
"id": {
"description": "The public blockchain chain ID.",
"type": "integer",
"format": "uint64",
"minimum": 0
},
"skip": {
"description": "Excludes the chain from indexing and migrations. Code generation is unaffected. For testing, prefer using a test framework instead.",
"type": [
"boolean",
"null"
]
},
"rpc": {
"description": "RPC configuration for your indexer. If not specified otherwise, for chains supported by HyperSync, RPC serves as a fallback for added reliability. For others, it acts as the primary data-source. HyperSync offers significant performance improvements, up to a 1000x faster than traditional RPC.",
"anyOf": [
{
"$ref": "#/$defs/RpcSelection"
},
{
"type": "null"
}
]
},
"hypersync_config": {
"description": "Optional HyperSync Config for additional fine-tuning",
"anyOf": [
{
"$ref": "#/$defs/HypersyncConfig"
},
{
"type": "null"
}
]
},
"max_reorg_depth": {
"description": "The number of blocks from the head that the indexer should account for in case of reorgs.",
"type": [
"integer",
"null"
],
"format": "uint32",
"minimum": 0
},
"block_lag": {
"description": "The number of blocks behind the chain head that the indexer should lag. Useful for avoiding reorg issues by indexing slightly behind the tip.",
"type": [
"integer",
"null"
],
"format": "uint32",
"minimum": 0
},
"start_block": {
"description": "The block at which the indexer should start ingesting data",
"type": "integer",
"format": "uint64",
"minimum": 0
},
"end_block": {
"description": "The block at which the indexer should terminate.",
"type": [
"integer",
"null"
],
"format": "uint64",
"minimum": 0
},
"contracts": {
"description": "All the contracts that should be indexed on the given chain",
"type": [
"array",
"null"
],
"items": {
"$ref": "#/$defs/ChainContract"
}
}
},
"additionalProperties": false,
"required": [
"id",
"start_block"
]
},
"RpcSelection": {
"anyOf": [
{
"type": "string"
},
{
"$ref": "#/$defs/Rpc"
},
{
"type": "array",
"items": {
"$ref": "#/$defs/Rpc"
}
}
]
},
"Rpc": {
"type": "object",
"properties": {
"url": {
"description": "The RPC endpoint URL.",
"type": "string"
},
"for": {
"description": "Determines if this RPC is for historical sync, real-time chain indexing, or as a fallback. If not specified, defaults to \"fallback\" when HyperSync is available for the chain, or \"sync\" otherwise.",
"anyOf": [
{
"$ref": "#/$defs/For"
},
{
"type": "null"
}
]
},
"ws": {
"description": "Optional WebSocket endpoint URL (wss:// or ws://) for real-time block header notifications via eth_subscribe(\"newHeads\"). Provides lower latency than HTTP polling for detecting new blocks.",
"type": [
"string",
"null"
]
},
"initial_block_interval": {
"description": "The starting interval in range of blocks per query",
"type": [
"integer",
"null"
],
"format": "uint32",
"minimum": 0
},
"backoff_multiplicative": {
"description": "After an RPC error, how much to scale back the number of blocks requested at once",
"type": [
"number",
"null"
],
"format": "double"
},
"acceleration_additive": {
"description": "Without RPC errors or timeouts, how much to increase the number of blocks requested by for the next batch",
"type": [
"integer",
"null"
],
"format": "uint32",
"minimum": 0
},
"interval_ceiling": {
"description": "Do not further increase the block interval past this limit",
"type": [
"integer",
"null"
],
"format": "uint32",
"minimum": 0
},
"backoff_millis": {
"description": "After an error, how long to wait before retrying",
"type": [
"integer",
"null"
],
"format": "uint32",
"minimum": 0
},
"fallback_stall_timeout": {
"description": "If a fallback RPC is provided, the amount of time in ms to wait before kicking off the next provider",
"type": [
"integer",
"null"
],
"format": "uint32",
"minimum": 0
},
"query_timeout_millis": {
"description": "How long to wait before cancelling an RPC request",
"type": [
"integer",
"null"
],
"format": "uint32",
"minimum": 0
},
"polling_interval": {
"description": "How frequently (in milliseconds) to check for new blocks in realtime. Default is 1000ms. Note: Setting this higher than block time does not reduce RPC usage as every block is still fetched to check for reorgs.",
"type": [
"integer",
"null"
],
"format": "uint32",
"minimum": 0
}
},
"additionalProperties": false,
"required": [
"url"
]
},
"For": {
"oneOf": [
{
"description": "Use RPC as the main data-source for both historical sync and real-time chain indexing.",
"type": "string",
"const": "sync"
},
{
"description": "Use RPC as a backup for the main data-source. Currently, it acts as a fallback when real-time indexing stalls, with potential for more cases in the future.",
"type": "string",
"const": "fallback"
},
{
"description": "Use RPC for real-time indexing only. HyperSync will be used for historical sync, then automatically switch to this RPC once synced for lower latency.",
"type": "string",
"const": "realtime"
}
]
},
"HypersyncConfig": {
"type": "object",
"properties": {
"url": {
"description": "URL of the HyperSync endpoint (default: The most performant HyperSync endpoint for the network)",
"type": "string"
}
},
"additionalProperties": false,
"required": [
"url"
]
},
"ChainContract": {
"type": "object",
"properties": {
"name": {
"description": "A unique project-wide name for this contract if events and handler are defined OR a reference to the name of contract defined globally at the top level",
"type": "string"
},
"address": {
"description": "A single address or a list of addresses to be indexed. This can be left as null in the case where this contracts addresses will be registered dynamically.",
"$ref": "#/$defs/Addresses"
},
"start_block": {
"description": "The block at which the indexer should start ingesting data for this specific contract. If not specified, uses the chain start_block. Can be greater than the chain start_block for more specific indexing.",
"type": [
"integer",
"null"
],
"format": "uint64",
"minimum": 0
},
"abi_file_path": {
"description": "Relative path (from config) to a json abi. If this is used then each configured event should simply be referenced by its name",
"type": [
"string",
"null"
]
},
"handler": {
"description": "Optional relative path to a file where handlers are registered for the given contract. If not provided, handlers can be auto-loaded from src directory.",
"type": [
"string",
"null"
]
},
"events": {
"description": "A list of events that should be indexed on this contract",
"type": "array",
"items": {
"$ref": "#/$defs/EventConfig"
}
}
},
"additionalProperties": false,
"required": [
"name"
]
},
"Addresses": {
"anyOf": [
{
"anyOf": [
{
"type": "string"
},
{
"type": "integer",
"format": "uint",
"minimum": 0
}
]
},
{
"type": "array",
"items": {
"anyOf": [
{
"type": "string"
},
{
"type": "integer",
"format": "uint",
"minimum": 0
}
]
}
}
]
},
"AddressFormat": {
"type": "string",
"enum": [
"checksum",
"lowercase"
]
}
}
}