UNPKG

envio

Version:

A latency and sync speed optimized, developer friendly blockchain data indexer.

677 lines (676 loc) • 19.4 kB
{ "$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": { "description": { "description": "Description of the project", "type": [ "string", "null" ] }, "name": { "description": "Name of the project", "type": "string" }, "ecosystem": { "description": "Ecosystem of the project.", "anyOf": [ { "$ref": "#/$defs/EcosystemTag" }, { "type": "null" } ] }, "schema": { "description": "Custom path to schema.graphql file", "type": [ "string", "null" ] }, "output": { "description": "Path where the generated directory will be placed. By default it's 'generated' relative to the current working directory. If set, it'll be a path relative to the config file location.", "type": [ "string", "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_for_ContractConfig" } }, "networks": { "description": "Configuration of the blockchain networks that the project is deployed on.", "type": "array", "items": { "$ref": "#/$defs/Network" } }, "unordered_multichain_mode": { "description": "A flag to indicate if the indexer should use a single queue for all chains or a queue per chain (default: false)", "type": [ "boolean", "null" ] }, "event_decoder": { "description": "The event decoder to use for the indexer (default: hypersync-client)", "anyOf": [ { "$ref": "#/$defs/EventDecoder" }, { "type": "null" } ] }, "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" ] }, "preload_handlers": { "description": "Makes handlers run twice to enable preload optimisations. Removes handlerWithLoader API, since it's not needed. (recommended, 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", "networks" ], "$defs": { "EcosystemTag": { "type": "string", "enum": [ "evm" ] }, "GlobalContract_for_ContractConfig": { "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": "The relative path to a file where handlers are registered for the given contract", "type": "string" }, "events": { "description": "A list of events that should be indexed on this contract", "type": "array", "items": { "$ref": "#/$defs/EventConfig" } } }, "additionalProperties": false, "required": [ "name", "handler", "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", "chainId", "accessList", "maxFeePerBlobGas", "blobVersionedHashes", "kind", "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" ] }, "Network": { "type": "object", "properties": { "id": { "description": "The public blockchain network ID.", "type": "integer", "format": "uint64", "minimum": 0 }, "rpc_config": { "description": "RPC configuration for utilizing as the network's data-source. Typically optional for chains with HyperSync support, which is highly recommended. HyperSync dramatically enhances performance, providing up to a 1000x speed boost over traditional RPC.", "anyOf": [ { "$ref": "#/$defs/RpcConfig" }, { "type": "null" } ] }, "rpc": { "description": "RPC configuration for your indexer. If not specified otherwise, for networks 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/NetworkRpc" }, { "type": "null" } ] }, "hypersync_config": { "description": "Optional HyperSync Config for additional fine-tuning", "anyOf": [ { "$ref": "#/$defs/HypersyncConfig" }, { "type": "null" } ] }, "confirmed_block_threshold": { "description": "The number of blocks from the head that the indexer should account for in case of reorgs.", "type": [ "integer", "null" ], "format": "int32" }, "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 network", "type": "array", "items": { "$ref": "#/$defs/NetworkContract_for_ContractConfig" } } }, "additionalProperties": false, "required": [ "id", "start_block", "contracts" ] }, "RpcConfig": { "type": "object", "properties": { "url": { "description": "URL of the RPC endpoint. Can be a single URL or an array of URLs. If multiple URLs are provided, the first one will be used as the primary RPC endpoint and the rest will be used as fallbacks.", "anyOf": [ { "type": "string" }, { "type": "array", "items": { "type": "string" } } ] }, "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 } }, "additionalProperties": false, "required": [ "url" ] }, "NetworkRpc": { "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.", "$ref": "#/$defs/For" }, "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 } }, "additionalProperties": false, "required": [ "url", "for" ] }, "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" } ] }, "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" ] }, "NetworkContract_for_ContractConfig": { "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 network start_block. Can be greater than the network 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": "The relative path to a file where handlers are registered for the given contract", "type": "string" }, "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 } ] } } ] }, "EventDecoder": { "type": "string", "enum": [ "viem", "hypersync-client" ] }, "AddressFormat": { "type": "string", "enum": [ "checksum", "lowercase" ] } } }