├── .cargo └── config.toml ├── .devcontainer ├── devcontainer.json └── docker-compose.yml ├── .dockerignore ├── .github ├── ISSUE_TEMPLATE │ ├── bug.yml │ └── feature.yml ├── PULL_REQUEST_TEMPLATE.md ├── dependabot.yml └── workflows │ ├── audit.yml │ ├── ci.yml │ ├── code-coverage.yml │ └── stale.yml ├── .gitignore ├── .ignore ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── Cargo.lock ├── Cargo.toml ├── FUNDING.json ├── LICENSE-APACHE ├── LICENSE-MIT ├── NEWS.md ├── README.md ├── chain ├── common │ ├── Cargo.toml │ ├── proto │ │ └── near-filter-substreams.proto │ ├── src │ │ └── lib.rs │ └── tests │ │ ├── resources │ │ ├── acme.proto │ │ └── firehose │ │ │ └── annotations.proto │ │ └── test-acme.rs ├── ethereum │ ├── Cargo.toml │ ├── build.rs │ ├── examples │ │ └── firehose.rs │ ├── proto │ │ └── ethereum.proto │ ├── src │ │ ├── adapter.rs │ │ ├── buffered_call_cache.rs │ │ ├── capabilities.rs │ │ ├── chain.rs │ │ ├── codec.rs │ │ ├── data_source.rs │ │ ├── env.rs │ │ ├── ethereum_adapter.rs │ │ ├── ingestor.rs │ │ ├── lib.rs │ │ ├── network.rs │ │ ├── polling_block_stream.rs │ │ ├── protobuf │ │ │ ├── .gitignore │ │ │ └── sf.ethereum.r#type.v2.rs │ │ ├── runtime │ │ │ ├── abi.rs │ │ │ ├── mod.rs │ │ │ └── runtime_adapter.rs │ │ ├── tests.rs │ │ ├── transport.rs │ │ └── trigger.rs │ └── tests │ │ └── README.md ├── near │ ├── Cargo.toml │ ├── build.rs │ ├── proto │ │ ├── near.proto │ │ └── substreams-triggers.proto │ └── src │ │ ├── adapter.rs │ │ ├── chain.rs │ │ ├── codec.rs │ │ ├── data_source.rs │ │ ├── lib.rs │ │ ├── protobuf │ │ ├── receipts.v1.rs │ │ └── sf.near.codec.v1.rs │ │ ├── runtime │ │ ├── abi.rs │ │ ├── generated.rs │ │ └── mod.rs │ │ └── trigger.rs └── substreams │ ├── Cargo.toml │ ├── build.rs │ ├── examples │ ├── README.md │ └── substreams.rs │ ├── proto │ └── codec.proto │ └── src │ ├── block_ingestor.rs │ ├── block_stream.rs │ ├── chain.rs │ ├── codec.rs │ ├── data_source.rs │ ├── lib.rs │ ├── mapper.rs │ ├── protobuf │ └── substreams.entity.v1.rs │ └── trigger.rs ├── core ├── Cargo.toml ├── graphman │ ├── Cargo.toml │ └── src │ │ ├── commands │ │ ├── deployment │ │ │ ├── info.rs │ │ │ ├── mod.rs │ │ │ ├── pause.rs │ │ │ ├── reassign.rs │ │ │ ├── resume.rs │ │ │ └── unassign.rs │ │ └── mod.rs │ │ ├── deployment.rs │ │ ├── error.rs │ │ ├── execution_tracker.rs │ │ └── lib.rs ├── graphman_store │ ├── Cargo.toml │ └── src │ │ └── lib.rs ├── src │ ├── lib.rs │ ├── polling_monitor │ │ ├── arweave_service.rs │ │ ├── ipfs_service.rs │ │ ├── metrics.rs │ │ └── mod.rs │ └── subgraph │ │ ├── context │ │ ├── instance │ │ │ ├── hosts.rs │ │ │ └── mod.rs │ │ └── mod.rs │ │ ├── error.rs │ │ ├── inputs.rs │ │ ├── instance_manager.rs │ │ ├── loader.rs │ │ ├── mod.rs │ │ ├── provider.rs │ │ ├── registrar.rs │ │ ├── runner.rs │ │ ├── state.rs │ │ ├── stream.rs │ │ └── trigger_processor.rs └── tests │ ├── README.md │ └── fixtures │ └── ipfs_folder │ └── hello.txt ├── docker ├── Dockerfile ├── README.md ├── bin │ ├── create │ ├── debug │ ├── deploy │ ├── reassign │ └── remove ├── build.sh ├── cloudbuild.yaml ├── docker-compose.yml ├── setup.sh ├── start ├── tag.sh └── wait_for ├── docs ├── adding-a-new-api-version.md ├── aggregations.md ├── config.md ├── environment-variables.md ├── graphman-graphql-api.md ├── graphman.md ├── images │ └── TheGraph_DataFlowDiagram.png ├── implementation │ ├── README.md │ ├── add-chain.md │ ├── metadata.md │ ├── offchain.md │ ├── pruning.md │ ├── schema-generation.md │ ├── sql-query-generation.md │ └── time-travel.md ├── maintenance.md ├── metrics.md ├── sharding.md └── subgraph-manifest.md ├── graph ├── Cargo.toml ├── build.rs ├── derive │ ├── Cargo.toml │ └── src │ │ └── lib.rs ├── examples │ ├── append_row.rs │ ├── stress.rs │ └── validate.rs ├── proto │ ├── cosmos │ │ └── transforms.proto │ ├── ethereum │ │ └── transforms.proto │ ├── firehose.proto │ ├── near │ │ └── transforms.proto │ ├── substreams-rpc.proto │ └── substreams.proto ├── src │ ├── blockchain │ │ ├── block_stream.rs │ │ ├── builder.rs │ │ ├── client.rs │ │ ├── empty_node_capabilities.rs │ │ ├── firehose_block_ingestor.rs │ │ ├── firehose_block_stream.rs │ │ ├── mock.rs │ │ ├── mod.rs │ │ ├── noop_runtime_adapter.rs │ │ ├── substreams_block_stream.rs │ │ └── types.rs │ ├── cheap_clone.rs │ ├── components │ │ ├── ethereum │ │ │ ├── mod.rs │ │ │ └── types.rs │ │ ├── graphql.rs │ │ ├── link_resolver │ │ │ ├── arweave.rs │ │ │ ├── ipfs.rs │ │ │ └── mod.rs │ │ ├── metrics │ │ │ ├── block_state.rs │ │ │ ├── gas.rs │ │ │ ├── mod.rs │ │ │ ├── registry.rs │ │ │ ├── stopwatch.rs │ │ │ └── subgraph.rs │ │ ├── mod.rs │ │ ├── network_provider │ │ │ ├── chain_identifier_validator.rs │ │ │ ├── extended_blocks_check.rs │ │ │ ├── genesis_hash_check.rs │ │ │ ├── mod.rs │ │ │ ├── network_details.rs │ │ │ ├── provider_check.rs │ │ │ └── provider_manager.rs │ │ ├── server │ │ │ ├── index_node.rs │ │ │ ├── mod.rs │ │ │ ├── query.rs │ │ │ └── server.rs │ │ ├── store │ │ │ ├── entity_cache.rs │ │ │ ├── err.rs │ │ │ ├── mod.rs │ │ │ ├── traits.rs │ │ │ └── write.rs │ │ ├── subgraph │ │ │ ├── host.rs │ │ │ ├── instance.rs │ │ │ ├── instance_manager.rs │ │ │ ├── mod.rs │ │ │ ├── proof_of_indexing │ │ │ │ ├── event.rs │ │ │ │ ├── mod.rs │ │ │ │ ├── online.rs │ │ │ │ └── reference.rs │ │ │ ├── provider.rs │ │ │ ├── registrar.rs │ │ │ └── settings.rs │ │ ├── transaction_receipt.rs │ │ ├── trigger_processor.rs │ │ └── versions │ │ │ ├── features.rs │ │ │ ├── mod.rs │ │ │ └── registry.rs │ ├── data │ │ ├── graphql │ │ │ ├── ext.rs │ │ │ ├── load_manager.rs │ │ │ ├── mod.rs │ │ │ ├── object_macro.rs │ │ │ ├── object_or_interface.rs │ │ │ ├── serialization.rs │ │ │ ├── shape_hash.rs │ │ │ └── values.rs │ │ ├── mod.rs │ │ ├── query │ │ │ ├── cache_status.rs │ │ │ ├── error.rs │ │ │ ├── mod.rs │ │ │ ├── query.rs │ │ │ ├── result.rs │ │ │ └── trace.rs │ │ ├── store │ │ │ ├── ethereum.rs │ │ │ ├── id.rs │ │ │ ├── mod.rs │ │ │ ├── scalar │ │ │ │ ├── bigdecimal.rs │ │ │ │ ├── bigint.rs │ │ │ │ ├── bytes.rs │ │ │ │ ├── mod.rs │ │ │ │ └── timestamp.rs │ │ │ └── sql.rs │ │ ├── subgraph │ │ │ ├── api_version.rs │ │ │ ├── features.rs │ │ │ ├── mod.rs │ │ │ ├── schema.rs │ │ │ └── status.rs │ │ └── value.rs │ ├── data_source │ │ ├── causality_region.rs │ │ ├── common.rs │ │ ├── mod.rs │ │ ├── offchain.rs │ │ ├── subgraph.rs │ │ └── tests.rs │ ├── endpoint.rs │ ├── env │ │ ├── graphql.rs │ │ ├── mappings.rs │ │ ├── mod.rs │ │ └── store.rs │ ├── ext │ │ ├── futures.rs │ │ └── mod.rs │ ├── firehose │ │ ├── .gitignore │ │ ├── codec.rs │ │ ├── endpoint_info │ │ │ ├── client.rs │ │ │ ├── info_response.rs │ │ │ └── mod.rs │ │ ├── endpoints.rs │ │ ├── helpers.rs │ │ ├── interceptors.rs │ │ ├── mod.rs │ │ ├── sf.ethereum.transform.v1.rs │ │ ├── sf.firehose.v2.rs │ │ └── sf.near.transform.v1.rs │ ├── ipfs │ │ ├── cache.rs │ │ ├── client.rs │ │ ├── content_path.rs │ │ ├── error.rs │ │ ├── gateway_client.rs │ │ ├── mod.rs │ │ ├── pool.rs │ │ ├── retry_policy.rs │ │ ├── rpc_client.rs │ │ ├── server_address.rs │ │ └── test_utils.rs │ ├── lib.rs │ ├── log │ │ ├── codes.rs │ │ ├── elastic.rs │ │ ├── factory.rs │ │ ├── mod.rs │ │ └── split.rs │ ├── runtime │ │ ├── asc_heap.rs │ │ ├── asc_ptr.rs │ │ ├── gas │ │ │ ├── combinators.rs │ │ │ ├── costs.rs │ │ │ ├── mod.rs │ │ │ ├── ops.rs │ │ │ ├── saturating.rs │ │ │ └── size_of.rs │ │ └── mod.rs │ ├── schema │ │ ├── api.rs │ │ ├── ast.rs │ │ ├── entity_key.rs │ │ ├── entity_type.rs │ │ ├── fulltext.rs │ │ ├── input │ │ │ ├── mod.rs │ │ │ └── sqlexpr.rs │ │ ├── introspection.graphql │ │ ├── meta.graphql │ │ ├── mod.rs │ │ └── test_schemas │ │ │ ├── no_aggregations.graphql │ │ │ ├── no_int8_id.graphql │ │ │ ├── ts_data_mutable.graphql │ │ │ ├── ts_data_no_id.graphql │ │ │ ├── ts_data_no_timestamp.graphql │ │ │ ├── ts_data_not_timeseries.graphql │ │ │ ├── ts_derived_from.graphql │ │ │ ├── ts_empty_intervals.graphql │ │ │ ├── ts_expr_random.graphql │ │ │ ├── ts_expr_simple.graphql │ │ │ ├── ts_expr_syntax_err.graphql │ │ │ ├── ts_id_type_mismatch.graphql │ │ │ ├── ts_invalid_arg.graphql │ │ │ ├── ts_invalid_cumulative.graphql │ │ │ ├── ts_invalid_fn.graphql │ │ │ ├── ts_invalid_interval.graphql │ │ │ ├── ts_invalid_timestamp_aggregation.graphql │ │ │ ├── ts_invalid_timestamp_timeseries.graphql │ │ │ ├── ts_missing_arg.graphql │ │ │ ├── ts_missing_fn.graphql │ │ │ ├── ts_missing_type.graphql │ │ │ ├── ts_no_aggregate.graphql │ │ │ ├── ts_no_id.graphql │ │ │ ├── ts_no_interval.graphql │ │ │ ├── ts_no_timeseries.graphql │ │ │ ├── ts_no_timestamp.graphql │ │ │ ├── ts_valid.graphql │ │ │ ├── ts_valid_cumulative.graphql │ │ │ ├── ts_valid_minimal.graphql │ │ │ └── ts_wrong_interval.graphql │ ├── substreams │ │ ├── codec.rs │ │ ├── mod.rs │ │ └── sf.substreams.v1.rs │ ├── substreams_rpc │ │ ├── codec.rs │ │ ├── mod.rs │ │ ├── sf.firehose.v2.rs │ │ └── sf.substreams.rpc.v2.rs │ ├── task_spawn.rs │ └── util │ │ ├── backoff.rs │ │ ├── bounded_queue.rs │ │ ├── cache_weight.rs │ │ ├── error.rs │ │ ├── futures.rs │ │ ├── herd_cache.rs │ │ ├── intern.rs │ │ ├── jobs.rs │ │ ├── lfu_cache.rs │ │ ├── mem.rs │ │ ├── mod.rs │ │ ├── monitored.rs │ │ ├── ogive.rs │ │ ├── security.rs │ │ ├── stable_hash_glue.rs │ │ ├── stats.rs │ │ ├── timed_cache.rs │ │ └── timed_rw_lock.rs └── tests │ ├── README.md │ └── subgraph_datasource_tests.rs ├── graphql ├── Cargo.toml ├── examples │ └── schema.rs ├── src │ ├── execution │ │ ├── ast.rs │ │ ├── cache.rs │ │ ├── execution.rs │ │ ├── mod.rs │ │ ├── query.rs │ │ └── resolver.rs │ ├── introspection │ │ ├── mod.rs │ │ └── resolver.rs │ ├── lib.rs │ ├── metrics.rs │ ├── query │ │ ├── ast.rs │ │ ├── ext.rs │ │ └── mod.rs │ ├── runner.rs │ ├── store │ │ ├── mod.rs │ │ ├── prefetch.rs │ │ ├── query.rs │ │ └── resolver.rs │ └── values │ │ ├── coercion.rs │ │ └── mod.rs └── tests │ └── README.md ├── justfile ├── node ├── Cargo.toml ├── resources │ └── tests │ │ └── full_config.toml └── src │ ├── bin │ └── manager.rs │ ├── chain.rs │ ├── config.rs │ ├── lib.rs │ ├── main.rs │ ├── manager │ ├── catalog.rs │ ├── color.rs │ ├── commands │ │ ├── assign.rs │ │ ├── chain.rs │ │ ├── check_blocks.rs │ │ ├── config.rs │ │ ├── copy.rs │ │ ├── create.rs │ │ ├── database.rs │ │ ├── deploy.rs │ │ ├── deployment │ │ │ ├── info.rs │ │ │ ├── mod.rs │ │ │ ├── pause.rs │ │ │ ├── reassign.rs │ │ │ ├── restart.rs │ │ │ ├── resume.rs │ │ │ └── unassign.rs │ │ ├── index.rs │ │ ├── listen.rs │ │ ├── mod.rs │ │ ├── provider_checks.rs │ │ ├── prune.rs │ │ ├── query.rs │ │ ├── remove.rs │ │ ├── rewind.rs │ │ ├── run.rs │ │ ├── stats.rs │ │ ├── txn_speed.rs │ │ └── unused_deployments.rs │ ├── deployment.rs │ ├── display.rs │ ├── fmt.rs │ ├── mod.rs │ └── prompt.rs │ ├── network_setup.rs │ ├── opt.rs │ └── store_builder.rs ├── runtime ├── derive │ ├── Cargo.toml │ └── src │ │ └── lib.rs ├── test │ ├── Cargo.toml │ ├── README.md │ ├── src │ │ ├── common.rs │ │ ├── lib.rs │ │ ├── test.rs │ │ ├── test │ │ │ └── abi.rs │ │ └── test_padding.rs │ └── wasm_test │ │ ├── api_version_0_0_4 │ │ ├── abi_classes.ts │ │ ├── abi_classes.wasm │ │ ├── abi_store_value.ts │ │ ├── abi_store_value.wasm │ │ ├── abi_token.ts │ │ ├── abi_token.wasm │ │ ├── abort.ts │ │ ├── abort.wasm │ │ ├── big_int_arithmetic.ts │ │ ├── big_int_arithmetic.wasm │ │ ├── big_int_to_hex.ts │ │ ├── big_int_to_hex.wasm │ │ ├── big_int_to_string.ts │ │ ├── big_int_to_string.wasm │ │ ├── bytes_to_base58.ts │ │ ├── bytes_to_base58.wasm │ │ ├── contract_calls.ts │ │ ├── contract_calls.wasm │ │ ├── crypto.ts │ │ ├── crypto.wasm │ │ ├── data_source_create.ts │ │ ├── data_source_create.wasm │ │ ├── ens_name_by_hash.ts │ │ ├── ens_name_by_hash.wasm │ │ ├── ipfs_cat.ts │ │ ├── ipfs_cat.wasm │ │ ├── ipfs_map.ts │ │ ├── ipfs_map.wasm │ │ ├── json_parsing.ts │ │ ├── json_parsing.wasm │ │ ├── non_terminating.ts │ │ ├── non_terminating.wasm │ │ ├── store.ts │ │ ├── store.wasm │ │ ├── string_to_number.ts │ │ ├── string_to_number.wasm │ │ ├── test_padding.ts │ │ ├── test_padding.wasm │ │ ├── yaml_parsing.ts │ │ └── yaml_parsing.wasm │ │ └── api_version_0_0_5 │ │ ├── abi_classes.ts │ │ ├── abi_classes.wasm │ │ ├── abi_store_value.ts │ │ ├── abi_store_value.wasm │ │ ├── abi_token.ts │ │ ├── abi_token.wasm │ │ ├── abort.ts │ │ ├── abort.wasm │ │ ├── allocate_global.ts │ │ ├── allocate_global.wasm │ │ ├── array_blowup.ts │ │ ├── array_blowup.wasm │ │ ├── big_int_arithmetic.ts │ │ ├── big_int_arithmetic.wasm │ │ ├── big_int_size_limit.ts │ │ ├── big_int_size_limit.wasm │ │ ├── big_int_to_hex.ts │ │ ├── big_int_to_hex.wasm │ │ ├── big_int_to_string.ts │ │ ├── big_int_to_string.wasm │ │ ├── boolean.ts │ │ ├── boolean.wasm │ │ ├── bytes_to_base58.ts │ │ ├── bytes_to_base58.wasm │ │ ├── common │ │ ├── global.ts │ │ ├── types.ts │ │ └── yaml.ts │ │ ├── contract_calls.ts │ │ ├── contract_calls.wasm │ │ ├── crypto.ts │ │ ├── crypto.wasm │ │ ├── data_source_create.ts │ │ ├── data_source_create.wasm │ │ ├── ens_name_by_hash.ts │ │ ├── ens_name_by_hash.wasm │ │ ├── ipfs_block.ts │ │ ├── ipfs_block.wasm │ │ ├── ipfs_cat.ts │ │ ├── ipfs_cat.wasm │ │ ├── ipfs_map.ts │ │ ├── ipfs_map.wasm │ │ ├── json_parsing.ts │ │ ├── json_parsing.wasm │ │ ├── non_terminating.ts │ │ ├── non_terminating.wasm │ │ ├── null_ptr_read.ts │ │ ├── null_ptr_read.wasm │ │ ├── recursion_limit.ts │ │ ├── recursion_limit.wasm │ │ ├── store.ts │ │ ├── store.wasm │ │ ├── string_to_number.ts │ │ ├── string_to_number.wasm │ │ ├── test_padding.ts │ │ ├── test_padding.wasm │ │ ├── yaml_parsing.ts │ │ └── yaml_parsing.wasm └── wasm │ ├── Cargo.toml │ └── src │ ├── asc_abi │ ├── class.rs │ ├── mod.rs │ ├── v0_0_4.rs │ └── v0_0_5.rs │ ├── error.rs │ ├── gas_rules.rs │ ├── host.rs │ ├── host_exports.rs │ ├── lib.rs │ ├── mapping.rs │ ├── module │ ├── context.rs │ ├── instance.rs │ ├── into_wasm_ret.rs │ └── mod.rs │ └── to_from │ ├── external.rs │ └── mod.rs ├── rust-toolchain.toml ├── server ├── graphman │ ├── Cargo.toml │ ├── src │ │ ├── auth.rs │ │ ├── entities │ │ │ ├── block_hash.rs │ │ │ ├── block_number.rs │ │ │ ├── block_ptr.rs │ │ │ ├── command_kind.rs │ │ │ ├── deployment_info.rs │ │ │ ├── deployment_selector.rs │ │ │ ├── deployment_status.rs │ │ │ ├── deployment_version_selector.rs │ │ │ ├── empty_response.rs │ │ │ ├── execution.rs │ │ │ ├── execution_id.rs │ │ │ ├── mod.rs │ │ │ ├── subgraph_health.rs │ │ │ └── warning_response.rs │ │ ├── error.rs │ │ ├── handlers │ │ │ ├── graphql.rs │ │ │ ├── mod.rs │ │ │ └── state.rs │ │ ├── lib.rs │ │ ├── resolvers │ │ │ ├── context.rs │ │ │ ├── deployment_mutation.rs │ │ │ ├── deployment_mutation │ │ │ │ ├── create.rs │ │ │ │ ├── pause.rs │ │ │ │ ├── reassign.rs │ │ │ │ ├── remove.rs │ │ │ │ ├── restart.rs │ │ │ │ ├── resume.rs │ │ │ │ └── unassign.rs │ │ │ ├── deployment_query.rs │ │ │ ├── deployment_query │ │ │ │ └── info.rs │ │ │ ├── execution_query.rs │ │ │ ├── mod.rs │ │ │ ├── mutation_root.rs │ │ │ └── query_root.rs │ │ ├── schema.rs │ │ └── server.rs │ └── tests │ │ ├── auth.rs │ │ ├── deployment_mutation.rs │ │ ├── deployment_query.rs │ │ └── util │ │ ├── client.rs │ │ ├── mod.rs │ │ └── server.rs ├── http │ ├── Cargo.toml │ ├── assets │ │ └── index.html │ ├── src │ │ ├── lib.rs │ │ ├── request.rs │ │ ├── server.rs │ │ ├── service.rs │ │ └── test_utils.rs │ └── tests │ │ ├── response.rs │ │ └── server.rs ├── index-node │ ├── Cargo.toml │ ├── assets │ │ ├── graphiql.css │ │ ├── graphiql.min.js │ │ └── index.html │ └── src │ │ ├── auth.rs │ │ ├── explorer.rs │ │ ├── lib.rs │ │ ├── resolver.rs │ │ ├── schema.graphql │ │ ├── schema.rs │ │ ├── server.rs │ │ └── service.rs ├── json-rpc │ ├── Cargo.toml │ └── src │ │ └── lib.rs └── metrics │ ├── Cargo.toml │ └── src │ └── lib.rs ├── store ├── postgres │ ├── Cargo.toml │ ├── examples │ │ └── layout.rs │ ├── migrations │ │ ├── 2018-07-10-061642_create_entities_table │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2018-07-10-061659_create_history_tables │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2018-07-10-062717_create_history_triggers │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2018-07-10-062730_create_revert_procedures │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2018-08-16-143800_create_entity_change_triggers │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2018-08-22-130000_create_blockchain_tables │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2018-08-22-140000_create_chain_head_update_procedure │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2018-08-29-120000_create_subgraphs_table │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2018-09-07-220000_create_ancestor_lookup_procedure │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2018-09-18-180000_add_ethereum_network_identifiers │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2018-12-02-114100_create_subgraph_deployments_table │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2018-12-03-150000_add_subgraph_cost │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2018-12-21-003727_create_attribute_indexing_procedure │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2019-01-07-120000_remove_subgraphs_deployments_tables │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2019-01-18-195346_update_history_triggers │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2019-01-18-195526_update_revert_procedures │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2019-02-01-045927_add_entities_indexes │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2019-02-04-114900_remove_entity_change_triggers │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2019-02-25-182843_add_pg_stat_statements │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2019-02-26-182914_remove_unassigned_deployment_indexes_procedure │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2019-02-26-183156_cleanup_unassigned_deployment_indexes │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2019-02-27-035443_create_large_notifications │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2019-02-28-190800_update_chain_head_update_procedure │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2019-03-04-235349_empty-ethereum-network-chain-head-update-fix │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2019-03-07-171355_update_history_storage │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2019-03-28-004319_drop_entities_id_indexes │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2019-03-31-010824_short_chain_head_update │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2019-04-19-171709_split_entities │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2019-04-22-190022_remove_unneeded_stored_procs │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2019-05-03-164052_store_entity_count │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2019-05-09-135900_create_subgraphs_entity_history_table │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2019-05-09-232642_ens_names │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2019-05-14-200255_event_meta_data_source_index │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2019-05-15-215022_migrate_entities │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2019-06-05-214320_uncled_chain_head_update │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2019-06-26-164405_index_dynamic_ethereum_contract_data_source_deployment │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2019-07-20-195916_remove_subgraph │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2019-08-02-001120_short_chain_head_update │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2019-09-01-135850_relational_schema │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2019-09-02-230613_create_btree_extension │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2019-10-01-173616_create_eth_call_cache │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2020-01-14-235608_relational_metadata_views │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2020-01-17-013633_remove_unused_procs │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2020-01-24-065338_add_reduce_dim │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2020-03-06-020253_relational-metadata │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2020-03-11-162100_add_data_source_context │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2020-03-25-170527_deployment_graft_base │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2020-04-04-002817_change_deployment_state │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2020-04-10-111111_add_deployment_errors │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2020-05-16-225611_add_deployment_detail_view │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2020-07-07-002933_add_deployment_reorg_counts │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2020-07-31-162138_meta-views │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2020-10-31-150000_deterministic_errors │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2020-11-03-170839_subgraph_name_unique │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2020-11-10-100000_last_healthy_block │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2020-12-11-142000_subgraph_manifest_features │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2020-12-12-000001_remove_migrationg_flag │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2020-12-12-000002_add_shard_to_deployment_schemas │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2020-12-12-000003_remove_deployment_schemas_state │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2020-12-12-000004_sharded_deployment_detail │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2020-12-12-000005_remove_metadata_subgraph │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2020-12-15-000000_remove_nested_templates │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2020-12-7-190800_subgraph_error_changes │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2021-01-07-004939_create_unused_deployments │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2021-01-14-175654_add_network_to_deployment_schemas │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2021-01-14-193022_deployment_schemas_network_not_null │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2021-01-15-013524_drop_deployment_detail │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2021-01-19-033749_add_chains │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2021-01-26-044443_drop_attempt_chain_head_update │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2021-01-26-172953_drop_lookup_ancestor_block │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2021-01-26-173710_add_chains_namespace │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2021-01-26-204036_ethereum_networks_net_ident_not_null │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2021-02-17-205502_simplify_metadata │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2021-02-18-000721_dds_embed_source │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2021-02-18-171423_dds_remove_ethereum_contract_source │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2021-02-24-051050_dds_remove_unused_columns │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2021-02-25-233156_dds_remove_id_block_range │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2021-03-11-010830_fdw │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2021-03-11-231340_subgraph_deployment_changes │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2021-03-12-014815_subgraph_deployment_pkey │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2021-03-12-070453_add_copy_state │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2021-03-16-001809_assignment_deployment │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2021-03-16-165131_subgraph_manifest │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2021-03-19-161012_unused_deployments_pk │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2021-03-20-001347_deployment_schemas_active │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2021-03-24-220541_deployment_schemas_deployment_shard │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2021-05-20-130220_graph_node_version │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2021-05-21-165219_add_created_at_columns_for_deployment_schemas │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2021-06-01-222649_create_stats │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2021-06-14-201635_add_ethereum_hex_to_bytea_function │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2021-07-09-144144_firehose_cursor │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2021-12-02-212506_chain_store_firehose_cursor │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2021-12-05-061157_add_debug_fork │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2022-03-09-07000_call_cache_block_number_idx │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2022-03-21-172028_add_use_bytea_prefix │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2022-03-23-010300_drop-metadata-indexes │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2022-04-26-125552_alter_deployment_schemas_version │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2022-06-12-003442_move_earliest_to_manifest │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2022-09-19-161239_add-raw-manifest-column │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2022-10-13-000000_track_processed_data_source │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2022-11-03-213140_drop_earliest_block │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2022-11-10-185105_add_has_causality_region_column │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2023-01-24-192319_chain_size_view │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2023-02-15-184255_add_manifest_on_sync │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2023-03-06-002954_add_pruning │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2023-03-06-233030_add_last_pruned_block │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2023-03-28-004152_trigger_remap │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2023-05-23-1715-update-subgraph-deployment-assignment │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2023-06-06-054643_create_subgraph_features_table │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2023-06-16-135622_add_network_to_subgraph_features_table │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2023-08-23-143628_add_handlers_to_subgraph_features │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2023-12-15-182102_add_first_last_fn │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2024-01-05-170000_ds_corruption_fix_up │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2024-01-25-133200_change_health_column_format │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2024-02-06-002353_arg_minmax │ │ │ ├── down.sql │ │ │ ├── generate.sh │ │ │ └── up.sql │ │ ├── 2024-06-11-084227_track-more-features-in-subgraph-features │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2024-07-22-140930_track_synced_date │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2024-08-14-205601_store_synced_at_block │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2024-10-01-100427_create_graphman_command_executions_table │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2025-04-08-224710_add_prune_state │ │ │ ├── down.sql │ │ │ └── up.sql │ │ ├── 2025-04-25-163121_prune_error │ │ │ ├── down.sql │ │ │ └── up.sql │ │ └── 2025-05-13-173523_split_subgraph_deployment │ │ │ ├── down.sql │ │ │ └── up.sql │ ├── src │ │ ├── advisory_lock.rs │ │ ├── block_range.rs │ │ ├── block_store.rs │ │ ├── catalog.rs │ │ ├── chain_head_listener.rs │ │ ├── chain_store.rs │ │ ├── copy.rs │ │ ├── deployment.rs │ │ ├── deployment_store.rs │ │ ├── detail.rs │ │ ├── dynds │ │ │ ├── mod.rs │ │ │ ├── private.rs │ │ │ └── shared.rs │ │ ├── fork.rs │ │ ├── functions.rs │ │ ├── graphman │ │ │ ├── mod.rs │ │ │ └── schema.rs │ │ ├── jobs.rs │ │ ├── lib.rs │ │ ├── notification_listener.rs │ │ ├── pool │ │ │ ├── coordinator.rs │ │ │ ├── foreign_server.rs │ │ │ ├── mod.rs │ │ │ └── state_tracker.rs │ │ ├── primary.rs │ │ ├── query_store.rs │ │ ├── relational.rs │ │ ├── relational │ │ │ ├── ddl.rs │ │ │ ├── ddl_tests.rs │ │ │ ├── dsl.rs │ │ │ ├── index.rs │ │ │ ├── prune.rs │ │ │ ├── query_tests.rs │ │ │ ├── rollup.rs │ │ │ └── value.rs │ │ ├── relational_queries.rs │ │ ├── retry.rs │ │ ├── store.rs │ │ ├── store_events.rs │ │ ├── subgraph_store.rs │ │ ├── transaction_receipt.rs │ │ ├── vid_batcher.rs │ │ └── writable.rs │ └── tests │ │ └── README.md └── test-store │ ├── Cargo.toml │ ├── README.md │ ├── config.sharded.toml │ ├── config.simple.toml │ ├── db-reset │ ├── devel │ ├── .gitignore │ ├── docker-compose.yml │ ├── initdb.d │ │ └── init-db.sh │ └── up.sh │ ├── src │ ├── block_store.rs │ ├── lib.rs │ └── store.rs │ └── tests │ ├── chain.rs │ ├── chain │ └── ethereum │ │ ├── full-text.graphql │ │ ├── ipfs-on-ethereum-contracts.ts │ │ ├── ipfs-on-ethereum-contracts.wasm │ │ └── manifest.rs │ ├── core.rs │ ├── core │ ├── fixtures │ │ └── ipfs_folder │ │ │ ├── hello.txt │ │ │ └── random.txt │ └── interfaces.rs │ ├── graph.rs │ ├── graph │ └── entity_cache.rs │ ├── graphql.rs │ ├── graphql │ ├── introspection.rs │ ├── mock_introspection.json │ └── query.rs │ ├── postgres.rs │ └── postgres │ ├── aggregation.rs │ ├── chain_head.rs │ ├── graft.rs │ ├── relational.rs │ ├── relational_bytes.rs │ ├── store.rs │ ├── subgraph.rs │ └── writable.rs ├── substreams ├── substreams-head-tracker │ ├── Cargo.lock │ ├── Cargo.toml │ ├── Makefile │ ├── rust-toolchain.toml │ ├── src │ │ └── lib.rs │ ├── substreams-head-tracker-v1.0.0.spkg │ └── substreams.yaml ├── substreams-trigger-filter │ ├── Cargo.lock │ ├── Cargo.toml │ ├── Makefile │ ├── build.rs │ ├── bun.lockb │ ├── package.json │ ├── proto │ │ ├── near.proto │ │ └── receipts.proto │ ├── rust-toolchain.toml │ ├── schema.graphql │ ├── src │ │ ├── lib.rs │ │ └── pb │ │ │ ├── mod.rs │ │ │ └── receipts.v1.rs │ ├── subgraph.yaml │ ├── substreams-trigger-filter-v0.1.0.spkg │ └── substreams.yaml └── trigger-filters │ ├── Cargo.toml │ └── src │ └── lib.rs └── tests ├── .gitignore ├── Cargo.toml ├── README.md ├── common ├── 1_initial_migration.js ├── 2_deploy_contracts.js ├── Migrations.sol ├── SimpleContract.sol └── build-contracts.sh ├── contracts ├── foundry.toml ├── out │ ├── LimitedContract.sol │ │ └── LimitedContract.json │ ├── OverloadedContract.sol │ │ └── OverloadedContract.json │ ├── RevertingContract.sol │ │ └── RevertingContract.json │ └── SimpleContract.sol │ │ └── SimpleContract.json └── src │ ├── LimitedContract.sol │ ├── OverloadedContract.sol │ ├── RevertingContract.sol │ └── SimpleContract.sol ├── docker-compose.yml ├── integration-tests ├── api-version-v0-0-4 │ ├── abis │ │ └── Contract.abi │ ├── package.json │ ├── schema.graphql │ ├── src │ │ └── mapping.ts │ ├── subgraph.yaml │ ├── test │ │ └── test.js │ └── truffle.js ├── base │ ├── abis │ │ └── Contract.abi │ ├── package.json │ ├── schema.graphql │ ├── src │ │ └── mapping.ts │ └── subgraph.yaml ├── block-handlers │ ├── abis │ │ └── Contract.abi │ ├── package.json │ ├── schema.graphql │ ├── src │ │ └── mapping.ts │ └── subgraph.yaml ├── ethereum-api-tests │ ├── abis │ │ └── Contract.abi │ ├── package.json │ ├── schema.graphql │ ├── src │ │ └── mapping.ts │ └── subgraph.yaml ├── grafted │ ├── abis │ │ └── Contract.abi │ ├── package.json │ ├── schema.graphql │ ├── src │ │ └── mapping.ts │ └── subgraph.yaml ├── host-exports │ ├── abis │ │ └── Contract.abi │ ├── package.json │ ├── schema.graphql │ ├── src │ │ └── mapping.ts │ └── subgraph.yaml ├── int8 │ ├── abis │ │ └── Contract.abi │ ├── package.json │ ├── schema.graphql │ ├── src │ │ └── mapping.ts │ └── subgraph.yaml ├── multiple-subgraph-datasources │ ├── package.json │ ├── schema.graphql │ ├── src │ │ └── mapping.ts │ └── subgraph.yaml ├── non-fatal-errors │ ├── abis │ │ └── Contract.abi │ ├── package.json │ ├── schema.graphql │ ├── src │ │ └── mapping.ts │ └── subgraph.yaml ├── overloaded-functions │ ├── abis │ │ └── Contract.abi │ ├── package.json │ ├── schema.graphql │ ├── src │ │ └── mapping.ts │ └── subgraph.yaml ├── package.json ├── poi-for-failed-subgraph │ ├── abis │ │ └── Contract.abi │ ├── package.json │ ├── schema.graphql │ ├── src │ │ └── mapping.ts │ └── subgraph.yaml ├── remove-then-update │ ├── abis │ │ └── Contract.abi │ ├── package.json │ ├── schema.graphql │ ├── src │ │ └── mapping.ts │ └── subgraph.yaml ├── reverted-calls │ ├── abis │ │ └── Contract.abi │ ├── package.json │ ├── schema.graphql │ ├── src │ │ └── mapping.ts │ └── subgraph.yaml ├── source-subgraph-a │ ├── abis │ │ └── Contract.abi │ ├── package.json │ ├── schema.graphql │ ├── src │ │ └── mapping.ts │ └── subgraph.yaml ├── source-subgraph-b │ ├── abis │ │ └── Contract.abi │ ├── package.json │ ├── schema.graphql │ ├── src │ │ └── mapping.ts │ └── subgraph.yaml ├── source-subgraph │ ├── abis │ │ └── Contract.abi │ ├── package.json │ ├── schema.graphql │ ├── src │ │ └── mapping.ts │ └── subgraph.yaml ├── subgraph-data-sources │ ├── abis │ │ └── Contract.abi │ ├── package.json │ ├── schema.graphql │ ├── src │ │ └── mapping.ts │ └── subgraph.yaml ├── timestamp │ ├── abis │ │ └── Contract.abi │ ├── package.json │ ├── schema.graphql │ ├── src │ │ └── mapping.ts │ └── subgraph.yaml ├── topic-filter │ ├── abis │ │ └── Contract.abi │ ├── package.json │ ├── schema.graphql │ ├── src │ │ └── mapping.ts │ └── subgraph.yaml ├── value-roundtrip │ ├── abis │ │ └── Contract.abi │ ├── package.json │ ├── schema.graphql │ ├── src │ │ └── mapping.ts │ └── subgraph.yaml └── yarn.lock ├── runner-tests ├── api-version │ ├── .gitignore │ ├── abis │ │ └── Contract.abi │ ├── data.0.0.7.json │ ├── data.0.0.8.json │ ├── package.json │ ├── schema.graphql │ ├── src │ │ └── mapping.ts │ └── subgraph.template.yaml ├── arweave-file-data-sources │ ├── abis │ │ └── Contract.abi │ ├── package.json │ ├── schema.graphql │ ├── src │ │ └── mapping.ts │ └── subgraph.yaml ├── block-handlers │ ├── abis │ │ └── Contract.abi │ ├── package.json │ ├── schema.graphql │ ├── src │ │ └── mapping.ts │ └── subgraph.yaml ├── config.simple.toml ├── data-source-revert │ ├── abis │ │ └── Contract.abi │ ├── grafted.yaml │ ├── package.json │ ├── schema.graphql │ ├── src │ │ └── mapping.ts │ ├── subgraph.yaml │ └── updateAndDeploy.js ├── data-source-revert2 │ ├── abis │ │ └── Contract.abi │ ├── package.json │ ├── schema.graphql │ ├── src │ │ └── mapping.ts │ └── subgraph.yaml ├── data-sources │ ├── abis │ │ └── Contract.abi │ ├── package.json │ ├── schema.graphql │ ├── src │ │ └── mapping.ts │ └── subgraph.yaml ├── derived-loaders │ ├── abis │ │ └── Contract.abi │ ├── package.json │ ├── schema.graphql │ ├── src │ │ ├── helpers.ts │ │ └── mapping.ts │ └── subgraph.yaml ├── dynamic-data-source │ ├── abis │ │ └── Contract.abi │ ├── package.json │ ├── schema.graphql │ ├── src │ │ └── mapping.ts │ └── subgraph.yaml ├── end-block │ ├── abis │ │ └── Contract.abi │ ├── package.json │ ├── schema.graphql │ ├── src │ │ └── mapping.ts │ ├── subgraph.yaml │ └── substreams-test-v1.0.1.spkg ├── fatal-error │ ├── abis │ │ └── Contract.abi │ ├── package.json │ ├── schema.graphql │ ├── src │ │ └── mapping.ts │ └── subgraph.yaml ├── file-data-sources │ ├── abis │ │ └── Contract.abi │ ├── package.json │ ├── schema.graphql │ ├── src │ │ └── mapping.ts │ └── subgraph.yaml ├── package.json ├── substreams │ ├── .gitignore │ ├── Cargo.lock │ ├── Cargo.toml │ ├── README.md │ ├── package.json │ ├── proto │ │ └── example.proto │ ├── rust-toolchain.toml │ ├── schema.graphql │ ├── src │ │ └── lib.rs │ ├── subgraph.yaml │ ├── substreams-test-v1.0.1.spkg │ └── substreams.yaml ├── typename │ ├── abis │ │ └── Contract.abi │ ├── package.json │ ├── schema.graphql │ ├── src │ │ └── mapping.ts │ └── subgraph.yaml └── yarn.lock ├── src ├── config.rs ├── contract.rs ├── fixture │ ├── ethereum.rs │ ├── mod.rs │ └── substreams.rs ├── helpers.rs ├── lib.rs ├── macros.rs └── subgraph.rs └── tests ├── integration_tests.rs └── runner_tests.rs /.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [alias] 2 | # Warnings create a lot of noise, we only print errors. 3 | check-clippy = "clippy --no-deps -- --allow warnings" 4 | 5 | # Can be safely removed once Cargo's sparse protocol (see 6 | # https://blog.rust-lang.org/2023/03/09/Rust-1.68.0.html#cargos-sparse-protocol) 7 | # becomes the default. 8 | [registries.crates-io] 9 | protocol = "sparse" 10 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | target 2 | docker/data 3 | node_modules 4 | .dockerignore 5 | .git 6 | .gitignore 7 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphprotocol/graph-node/94fb3f2825a66dd54c628c2866e3b1165d077576/.github/PULL_REQUEST_TEMPLATE.md -------------------------------------------------------------------------------- /.github/workflows/audit.yml: -------------------------------------------------------------------------------- 1 | # See https://github.com/actions-rs/audit-check 2 | name: Security audit 3 | on: 4 | # push: 5 | # paths: 6 | # - '**/Cargo.toml' 7 | # - '**/Cargo.lock' 8 | schedule: 9 | - cron: '0 0 */7 * *' 10 | jobs: 11 | security_audit: 12 | runs-on: ubuntu-latest 13 | timeout-minutes: 10 14 | steps: 15 | - uses: actions/checkout@v4 16 | - uses: rustsec/audit-check@69366f33c96575abad1ee0dba8212993eecbe998 #v2.0.0 17 | with: 18 | token: ${{ secrets.GITHUB_TOKEN }} 19 | -------------------------------------------------------------------------------- /.ignore: -------------------------------------------------------------------------------- 1 | # Make `cargo watch` ignore changes in integration tests 2 | tests/integration-tests/**/build 3 | tests/integration-tests/**/generated 4 | tests/integration-tests/**/node_modules 5 | -------------------------------------------------------------------------------- /FUNDING.json: -------------------------------------------------------------------------------- 1 | { 2 | "drips": { 3 | "ethereum": { 4 | "ownedBy": "0x7630586acda59C53e6b1421B7e097512B74C5236" 5 | } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /chain/common/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "graph-chain-common" 3 | version.workspace = true 4 | edition.workspace = true 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | protobuf = "3.0.2" 10 | protobuf-parse = "3.7.2" 11 | anyhow = "1" 12 | heck = "0.5" 13 | -------------------------------------------------------------------------------- /chain/common/proto/near-filter-substreams.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | import "near.proto"; 4 | 5 | package receipts.v1; 6 | 7 | message BlockAndReceipts { 8 | sf.near.codec.v1.Block block = 1; 9 | repeated sf.near.codec.v1.ExecutionOutcomeWithId outcome = 2; 10 | repeated sf.near.codec.v1.Receipt receipt = 3; 11 | } 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /chain/common/tests/resources/firehose/annotations.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package firehose; 4 | 5 | option go_package = "github.com/streamingfast/pbgo/sf/firehose/v1;pbfirehose"; 6 | 7 | import "google/protobuf/descriptor.proto"; 8 | 9 | extend google.protobuf.FieldOptions { 10 | optional bool required = 77001; 11 | } 12 | -------------------------------------------------------------------------------- /chain/ethereum/build.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | println!("cargo:rerun-if-changed=proto"); 3 | 4 | tonic_build::configure() 5 | .out_dir("src/protobuf") 6 | .compile_protos(&["proto/ethereum.proto"], &["proto"]) 7 | .expect("Failed to compile Firehose Ethereum proto(s)"); 8 | } 9 | -------------------------------------------------------------------------------- /chain/ethereum/src/protobuf/.gitignore: -------------------------------------------------------------------------------- 1 | # For an unknown reason, the build script generates this file but it should not. 2 | # See https://github.com/hyperium/tonic/issues/757 3 | google.protobuf.rs -------------------------------------------------------------------------------- /chain/ethereum/src/runtime/mod.rs: -------------------------------------------------------------------------------- 1 | pub use runtime_adapter::RuntimeAdapter; 2 | 3 | pub mod abi; 4 | pub mod runtime_adapter; 5 | -------------------------------------------------------------------------------- /chain/ethereum/tests/README.md: -------------------------------------------------------------------------------- 1 | Put integration tests for this crate into 2 | `store/test-store/tests/chain/ethereum`. This avoids cyclic dev-dependencies 3 | which make rust-analyzer nearly unusable. Once [this 4 | issue](https://github.com/rust-lang/rust-analyzer/issues/14167) has been 5 | fixed, we can move tests back here 6 | -------------------------------------------------------------------------------- /chain/near/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "graph-chain-near" 3 | version.workspace = true 4 | edition.workspace = true 5 | 6 | [build-dependencies] 7 | tonic-build = { workspace = true } 8 | 9 | [dependencies] 10 | graph = { path = "../../graph" } 11 | prost = { workspace = true } 12 | prost-types = { workspace = true } 13 | serde = { workspace = true } 14 | anyhow = "1" 15 | 16 | graph-runtime-wasm = { path = "../../runtime/wasm" } 17 | graph-runtime-derive = { path = "../../runtime/derive" } 18 | 19 | [dev-dependencies] 20 | diesel = { workspace = true } 21 | trigger-filters.path = "../../substreams/trigger-filters" 22 | -------------------------------------------------------------------------------- /chain/near/build.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | println!("cargo:rerun-if-changed=proto"); 3 | tonic_build::configure() 4 | .out_dir("src/protobuf") 5 | .extern_path(".sf.near.codec.v1", "crate::codec::pbcodec") 6 | .compile_protos( 7 | &["proto/near.proto", "proto/substreams-triggers.proto"], 8 | &["proto"], 9 | ) 10 | .expect("Failed to compile Firehose NEAR proto(s)"); 11 | } 12 | -------------------------------------------------------------------------------- /chain/near/proto/substreams-triggers.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | import "near.proto"; 4 | 5 | package receipts.v1; 6 | 7 | message BlockAndReceipts { 8 | sf.near.codec.v1.Block block = 1; 9 | repeated sf.near.codec.v1.ExecutionOutcomeWithId outcome = 2; 10 | repeated sf.near.codec.v1.Receipt receipt = 3; 11 | } 12 | 13 | -------------------------------------------------------------------------------- /chain/near/src/lib.rs: -------------------------------------------------------------------------------- 1 | mod adapter; 2 | mod chain; 3 | pub mod codec; 4 | mod data_source; 5 | mod runtime; 6 | mod trigger; 7 | 8 | pub use crate::chain::Chain; 9 | pub use crate::chain::NearStreamBuilder; 10 | pub use codec::HeaderOnlyBlock; 11 | -------------------------------------------------------------------------------- /chain/near/src/protobuf/receipts.v1.rs: -------------------------------------------------------------------------------- 1 | // This file is @generated by prost-build. 2 | #[derive(Clone, PartialEq, ::prost::Message)] 3 | pub struct BlockAndReceipts { 4 | #[prost(message, optional, tag = "1")] 5 | pub block: ::core::option::Option, 6 | #[prost(message, repeated, tag = "2")] 7 | pub outcome: ::prost::alloc::vec::Vec, 8 | #[prost(message, repeated, tag = "3")] 9 | pub receipt: ::prost::alloc::vec::Vec, 10 | } 11 | -------------------------------------------------------------------------------- /chain/near/src/runtime/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod abi; 2 | 3 | mod generated; 4 | -------------------------------------------------------------------------------- /chain/substreams/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "graph-chain-substreams" 3 | version.workspace = true 4 | edition.workspace = true 5 | 6 | [build-dependencies] 7 | tonic-build = { workspace = true } 8 | 9 | [dependencies] 10 | graph = { path = "../../graph" } 11 | graph-runtime-wasm = { path = "../../runtime/wasm" } 12 | lazy_static = "1.5.0" 13 | serde = { workspace = true } 14 | prost = { workspace = true } 15 | prost-types = { workspace = true } 16 | anyhow = "1.0" 17 | hex = "0.4.3" 18 | semver = "1.0.23" 19 | base64 = "0.22.1" 20 | 21 | [dev-dependencies] 22 | tokio = { version = "1", features = ["full"] } 23 | -------------------------------------------------------------------------------- /chain/substreams/build.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | println!("cargo:rerun-if-changed=proto"); 3 | tonic_build::configure() 4 | .protoc_arg("--experimental_allow_proto3_optional") 5 | .out_dir("src/protobuf") 6 | .compile_protos(&["proto/codec.proto"], &["proto"]) 7 | .expect("Failed to compile Substreams entity proto(s)"); 8 | } 9 | -------------------------------------------------------------------------------- /chain/substreams/examples/README.md: -------------------------------------------------------------------------------- 1 | ## Substreams example 2 | 3 | 1. Set environmental variables 4 | ```bash 5 | $> export SUBSTREAMS_API_TOKEN=your_sf_token 6 | $> export SUBSTREAMS_ENDPOINT=your_sf_endpoint # you can also not define this one and use the default specified endpoint 7 | $> export SUBSTREAMS_PACKAGE=path_to_your_spkg 8 | ``` 9 | 10 | 2. Run `substreams` example 11 | ```bash 12 | cargo run -p graph-chain-substreams --example substreams [module_name] # for graph entities run `graph_out` 13 | ``` 14 | -------------------------------------------------------------------------------- /chain/substreams/src/codec.rs: -------------------------------------------------------------------------------- 1 | #[rustfmt::skip] 2 | #[path = "protobuf/substreams.entity.v1.rs"] 3 | mod pbsubstreamsentity; 4 | 5 | pub use pbsubstreamsentity::*; 6 | -------------------------------------------------------------------------------- /chain/substreams/src/lib.rs: -------------------------------------------------------------------------------- 1 | mod block_stream; 2 | mod chain; 3 | mod codec; 4 | mod data_source; 5 | mod trigger; 6 | 7 | pub mod block_ingestor; 8 | pub mod mapper; 9 | 10 | pub use crate::chain::Chain; 11 | pub use block_stream::BlockStreamBuilder; 12 | pub use chain::*; 13 | pub use codec::EntityChanges; 14 | pub use data_source::*; 15 | pub use trigger::*; 16 | 17 | pub use codec::Field; 18 | -------------------------------------------------------------------------------- /core/graphman/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "graphman" 3 | version.workspace = true 4 | edition.workspace = true 5 | 6 | [dependencies] 7 | anyhow = { workspace = true } 8 | diesel = { workspace = true } 9 | graph = { workspace = true } 10 | graph-store-postgres = { workspace = true } 11 | graphman-store = { workspace = true } 12 | itertools = { workspace = true } 13 | thiserror = { workspace = true } 14 | tokio = { workspace = true } 15 | -------------------------------------------------------------------------------- /core/graphman/src/commands/deployment/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod info; 2 | pub mod pause; 3 | pub mod reassign; 4 | pub mod resume; 5 | pub mod unassign; 6 | -------------------------------------------------------------------------------- /core/graphman/src/commands/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod deployment; 2 | -------------------------------------------------------------------------------- /core/graphman/src/error.rs: -------------------------------------------------------------------------------- 1 | use thiserror::Error; 2 | 3 | #[derive(Debug, Error)] 4 | pub enum GraphmanError { 5 | #[error("store error: {0:#}")] 6 | Store(#[source] anyhow::Error), 7 | } 8 | 9 | impl From for GraphmanError { 10 | fn from(err: graph::components::store::StoreError) -> Self { 11 | Self::Store(err.into()) 12 | } 13 | } 14 | 15 | impl From for GraphmanError { 16 | fn from(err: diesel::result::Error) -> Self { 17 | Self::Store(err.into()) 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /core/graphman/src/lib.rs: -------------------------------------------------------------------------------- 1 | //! This crate contains graphman commands that can be executed via 2 | //! the GraphQL API as well as via the CLI. 3 | //! 4 | //! Each command is broken into small execution steps to allow different interfaces to perform 5 | //! some additional interface-specific operations between steps. An example of this is printing 6 | //! intermediate information to the user in the CLI, or prompting for additional input. 7 | 8 | mod error; 9 | 10 | pub mod commands; 11 | pub mod deployment; 12 | pub mod execution_tracker; 13 | 14 | pub use self::error::GraphmanError; 15 | pub use self::execution_tracker::GraphmanExecutionTracker; 16 | -------------------------------------------------------------------------------- /core/graphman_store/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "graphman-store" 3 | version.workspace = true 4 | edition.workspace = true 5 | 6 | [dependencies] 7 | anyhow = { workspace = true } 8 | chrono = { workspace = true } 9 | diesel = { workspace = true } 10 | strum = { workspace = true } 11 | -------------------------------------------------------------------------------- /core/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod polling_monitor; 2 | 3 | mod subgraph; 4 | 5 | pub use crate::subgraph::{ 6 | SubgraphAssignmentProvider, SubgraphInstanceManager, SubgraphRegistrar, SubgraphRunner, 7 | SubgraphTriggerProcessor, 8 | }; 9 | -------------------------------------------------------------------------------- /core/src/subgraph/mod.rs: -------------------------------------------------------------------------------- 1 | mod context; 2 | mod error; 3 | mod inputs; 4 | mod instance_manager; 5 | mod loader; 6 | mod provider; 7 | mod registrar; 8 | mod runner; 9 | mod state; 10 | mod stream; 11 | mod trigger_processor; 12 | 13 | pub use self::instance_manager::SubgraphInstanceManager; 14 | pub use self::provider::SubgraphAssignmentProvider; 15 | pub use self::registrar::SubgraphRegistrar; 16 | pub use self::runner::SubgraphRunner; 17 | pub use self::trigger_processor::*; 18 | -------------------------------------------------------------------------------- /core/tests/README.md: -------------------------------------------------------------------------------- 1 | Put integration tests for this crate into `store/test-store/tests/core`. 2 | This avoids cyclic dev-dependencies which make rust-analyzer nearly 3 | unusable. Once [this 4 | issue](https://github.com/rust-lang/rust-analyzer/issues/14167) has been 5 | fixed, we can move tests back here 6 | -------------------------------------------------------------------------------- /core/tests/fixtures/ipfs_folder/hello.txt: -------------------------------------------------------------------------------- 1 | hello world 2 | -------------------------------------------------------------------------------- /docker/bin/create: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | if [ $# != 1 ]; then 4 | echo "usage: create " 5 | exit 1 6 | fi 7 | 8 | api="http://index-node.default/" 9 | 10 | data=$(printf '{"jsonrpc": "2.0", "method": "subgraph_create", "params": {"name":"%s"}, "id":"1"}' "$1") 11 | curl -s -H "content-type: application/json" --data "$data" "$api" 12 | -------------------------------------------------------------------------------- /docker/bin/debug: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | if [ -f "$1" ] 4 | then 5 | exec rust-gdb -c "$1" /usr/local/cargo/bin/graph-node 6 | else 7 | echo "usage: debug " 8 | exit 1 9 | fi 10 | -------------------------------------------------------------------------------- /docker/bin/deploy: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | if [ $# != 3 ]; then 4 | echo "usage: deploy " 5 | exit 1 6 | fi 7 | 8 | api="http://index-node.default/" 9 | 10 | echo "Deploying $1 (deployment $2)" 11 | data=$(printf '{"jsonrpc": "2.0", "method": "subgraph_deploy", "params": {"name":"%s", "ipfs_hash":"%s", "node_id":"%s"}, "id":"1"}' "$1" "$2" "$3") 12 | curl -s -H "content-type: application/json" --data "$data" "$api" 13 | -------------------------------------------------------------------------------- /docker/bin/reassign: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | if [ $# -lt 3 ]; then 4 | echo "usage: reassign " 5 | exit 1 6 | fi 7 | 8 | api="http://index-node.default/" 9 | 10 | echo Assigning to "$3" 11 | data=$(printf '{"jsonrpc": "2.0", "method": "subgraph_reassign", "params": {"name":"%s", "ipfs_hash":"%s", "node_id":"%s"}, "id":"1"}' "$1" "$2" "$3") 12 | curl -s -H "content-type: application/json" --data "$data" "$api" 13 | -------------------------------------------------------------------------------- /docker/bin/remove: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | if [ $# != 1 ]; then 4 | echo "usage: remove " 5 | exit 1 6 | fi 7 | 8 | api="http://index-node.default/" 9 | 10 | data=$(printf '{"jsonrpc": "2.0", "method": "subgraph_remove", "params": {"name":"%s"}, "id":"1"}' "$1") 11 | curl -s -H "content-type: application/json" --data "$data" "$api" 12 | -------------------------------------------------------------------------------- /docs/images/TheGraph_DataFlowDiagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphprotocol/graph-node/94fb3f2825a66dd54c628c2866e3b1165d077576/docs/images/TheGraph_DataFlowDiagram.png -------------------------------------------------------------------------------- /docs/implementation/README.md: -------------------------------------------------------------------------------- 1 | # Implementation Notes 2 | 3 | The files in this directory explain some higher-level concepts about the 4 | implementation of `graph-node`. Explanations that are tied more closely to 5 | the code should go into comments. 6 | 7 | * [Metadata storage](./metadata.md) 8 | * [Schema Generation](./schema-generation.md) 9 | * [Time-travel Queries](./time-travel.md) 10 | * [SQL Query Generation](./sql-query-generation.md) 11 | * [Adding support for a new chain](./add-chain.md) 12 | * [Pruning](./pruning.md) 13 | -------------------------------------------------------------------------------- /graph/derive/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "graph_derive" 3 | version.workspace = true 4 | edition.workspace = true 5 | authors.workspace = true 6 | readme.workspace = true 7 | homepage.workspace = true 8 | repository.workspace = true 9 | license.workspace = true 10 | 11 | [lib] 12 | proc-macro = true 13 | 14 | [dependencies] 15 | syn = { workspace = true } 16 | quote = "1.0" 17 | proc-macro2 = "1.0.95" 18 | heck = "0.5" 19 | 20 | [dev-dependencies] 21 | proc-macro-utils = "0.10.0" 22 | -------------------------------------------------------------------------------- /graph/proto/cosmos/transforms.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package sf.cosmos.transform.v1; 4 | 5 | option go_package = "github.com/figment-networks/proto-cosmos/pb/sf/cosmos/transform/v1;pbtransform"; 6 | 7 | message EventTypeFilter { 8 | repeated string event_types = 1; 9 | } 10 | -------------------------------------------------------------------------------- /graph/src/blockchain/noop_runtime_adapter.rs: -------------------------------------------------------------------------------- 1 | use std::marker::PhantomData; 2 | 3 | use crate::data_source; 4 | 5 | use super::{Blockchain, HostFn, RuntimeAdapter}; 6 | 7 | /// A [`RuntimeAdapter`] that does not expose any host functions. 8 | #[derive(Debug, Clone)] 9 | pub struct NoopRuntimeAdapter(PhantomData); 10 | 11 | impl Default for NoopRuntimeAdapter { 12 | fn default() -> Self { 13 | Self(PhantomData) 14 | } 15 | } 16 | 17 | impl RuntimeAdapter for NoopRuntimeAdapter 18 | where 19 | C: Blockchain, 20 | { 21 | fn host_fns(&self, _ds: &data_source::DataSource) -> anyhow::Result> { 22 | Ok(vec![]) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /graph/src/components/ethereum/mod.rs: -------------------------------------------------------------------------------- 1 | mod types; 2 | 3 | pub use self::types::{ 4 | evaluate_transaction_status, EthereumBlock, EthereumBlockWithCalls, EthereumCall, 5 | LightEthereumBlock, LightEthereumBlockExt, 6 | }; 7 | -------------------------------------------------------------------------------- /graph/src/components/server/index_node.rs: -------------------------------------------------------------------------------- 1 | use crate::{prelude::BlockNumber, schema::InputSchema}; 2 | 3 | /// This is only needed to support the explorer API. 4 | #[derive(Debug)] 5 | pub struct VersionInfo { 6 | pub created_at: String, 7 | pub deployment_id: String, 8 | pub latest_ethereum_block_number: Option, 9 | pub total_ethereum_blocks_count: Option, 10 | pub synced: bool, 11 | pub failed: bool, 12 | pub description: Option, 13 | pub repository: Option, 14 | pub schema: InputSchema, 15 | pub network: String, 16 | } 17 | -------------------------------------------------------------------------------- /graph/src/components/server/mod.rs: -------------------------------------------------------------------------------- 1 | /// Component for running GraphQL queries over HTTP. 2 | pub mod query; 3 | 4 | /// Component for the index node server. 5 | pub mod index_node; 6 | 7 | pub mod server; 8 | -------------------------------------------------------------------------------- /graph/src/components/subgraph/provider.rs: -------------------------------------------------------------------------------- 1 | use async_trait::async_trait; 2 | 3 | use crate::{components::store::DeploymentLocator, prelude::*}; 4 | 5 | /// Common trait for subgraph providers. 6 | #[async_trait] 7 | pub trait SubgraphAssignmentProvider: Send + Sync + 'static { 8 | async fn start( 9 | &self, 10 | deployment: DeploymentLocator, 11 | stop_block: Option, 12 | ) -> Result<(), SubgraphAssignmentProviderError>; 13 | async fn stop( 14 | &self, 15 | deployment: DeploymentLocator, 16 | ) -> Result<(), SubgraphAssignmentProviderError>; 17 | } 18 | -------------------------------------------------------------------------------- /graph/src/components/versions/features.rs: -------------------------------------------------------------------------------- 1 | #[derive(Clone, PartialEq, Eq, Debug, Ord, PartialOrd, Hash)] 2 | pub enum FeatureFlag {} 3 | -------------------------------------------------------------------------------- /graph/src/components/versions/mod.rs: -------------------------------------------------------------------------------- 1 | mod features; 2 | mod registry; 3 | 4 | pub use features::FeatureFlag; 5 | pub use registry::{ApiVersion, VERSIONS}; 6 | -------------------------------------------------------------------------------- /graph/src/data/mod.rs: -------------------------------------------------------------------------------- 1 | /// Data types for dealing with subgraphs. 2 | pub mod subgraph; 3 | 4 | /// Data types for dealing with GraphQL queries. 5 | pub mod query; 6 | 7 | /// Data types for dealing with storing entities. 8 | pub mod store; 9 | 10 | /// Data types for dealing with GraphQL values. 11 | pub mod graphql; 12 | 13 | /// Our representation of values for query results and the like 14 | pub mod value; 15 | -------------------------------------------------------------------------------- /graph/src/data/query/mod.rs: -------------------------------------------------------------------------------- 1 | mod cache_status; 2 | mod error; 3 | mod query; 4 | mod result; 5 | mod trace; 6 | 7 | pub use self::cache_status::CacheStatus; 8 | pub use self::error::{QueryError, QueryExecutionError}; 9 | pub use self::query::{Query, QueryTarget, QueryVariables}; 10 | pub use self::result::{LatestBlockInfo, QueryResult, QueryResults}; 11 | pub use self::trace::Trace; 12 | -------------------------------------------------------------------------------- /graph/src/ext/mod.rs: -------------------------------------------------------------------------------- 1 | ///! Extension traits for external types. 2 | pub mod futures; 3 | -------------------------------------------------------------------------------- /graph/src/firehose/.gitignore: -------------------------------------------------------------------------------- 1 | # For an unknown reason, the build script generates this file but it should not. 2 | # See https://github.com/hyperium/tonic/issues/757 3 | google.protobuf.rs -------------------------------------------------------------------------------- /graph/src/firehose/codec.rs: -------------------------------------------------------------------------------- 1 | #[rustfmt::skip] 2 | #[path = "sf.firehose.v2.rs"] 3 | mod pbfirehose; 4 | 5 | #[rustfmt::skip] 6 | #[path = "sf.ethereum.transform.v1.rs"] 7 | mod pbethereum; 8 | 9 | #[rustfmt::skip] 10 | #[path = "sf.near.transform.v1.rs"] 11 | mod pbnear; 12 | 13 | pub use pbethereum::*; 14 | pub use pbfirehose::*; 15 | pub use pbnear::*; 16 | -------------------------------------------------------------------------------- /graph/src/firehose/endpoint_info/mod.rs: -------------------------------------------------------------------------------- 1 | mod client; 2 | mod info_response; 3 | 4 | pub use client::Client; 5 | pub use info_response::InfoResponse; 6 | -------------------------------------------------------------------------------- /graph/src/firehose/helpers.rs: -------------------------------------------------------------------------------- 1 | use std::sync::Arc; 2 | 3 | use crate::blockchain::Block as BlockchainBlock; 4 | use crate::firehose; 5 | use anyhow::Error; 6 | 7 | pub fn decode_firehose_block( 8 | block_response: &firehose::Response, 9 | ) -> Result, Error> 10 | where 11 | M: prost::Message + BlockchainBlock + Default + 'static, 12 | { 13 | let any_block = block_response 14 | .block 15 | .as_ref() 16 | .expect("block payload information should always be present"); 17 | 18 | Ok(Arc::new(M::decode(any_block.value.as_ref())?)) 19 | } 20 | -------------------------------------------------------------------------------- /graph/src/firehose/mod.rs: -------------------------------------------------------------------------------- 1 | mod codec; 2 | mod endpoint_info; 3 | mod endpoints; 4 | mod helpers; 5 | mod interceptors; 6 | 7 | pub use codec::*; 8 | pub use endpoints::*; 9 | pub use helpers::decode_firehose_block; 10 | -------------------------------------------------------------------------------- /graph/src/schema/test_schemas/no_aggregations.graphql: -------------------------------------------------------------------------------- 1 | # fail @ 0.0.9: AggregationsNotSupported 2 | type Data @entity(timeseries: true) { 3 | id: Bytes! 4 | timestamp: Timestamp! 5 | price: BigDecimal! 6 | } 7 | 8 | type Stats @aggregation(intervals: ["hour", "day"], source: "Data") { 9 | id: Bytes! 10 | timestamp: Timestamp! 11 | sum: BigDecimal! @aggregate(fn: "sum", arg: "price") 12 | } 13 | -------------------------------------------------------------------------------- /graph/src/schema/test_schemas/no_int8_id.graphql: -------------------------------------------------------------------------------- 1 | # fail @ 0.0.9: IdTypeInt8NotSupported 2 | type Thing @entity { 3 | id: Int8! 4 | name: String! 5 | } 6 | -------------------------------------------------------------------------------- /graph/src/schema/test_schemas/ts_data_mutable.graphql: -------------------------------------------------------------------------------- 1 | # fail: MutableTimeseries 2 | type Data @entity(timeseries: true, immutable: false) { 3 | id: Int8! 4 | timestamp: Timestamp! 5 | price: BigDecimal! 6 | } 7 | 8 | type Stats @aggregation(intervals: ["hour", "day"], source: "Data") { 9 | id: Int8! 10 | timestamp: Timestamp! 11 | sum: BigDecimal! @aggregate(fn: "sum", arg: "price") 12 | } 13 | -------------------------------------------------------------------------------- /graph/src/schema/test_schemas/ts_data_no_id.graphql: -------------------------------------------------------------------------------- 1 | # fail: IdFieldMissing 2 | type Data @entity(timeseries: true) { 3 | timestamp: Timestamp! 4 | price: BigDecimal! 5 | } 6 | 7 | type Stats @aggregation(intervals: ["hour", "day"], source: "Data") { 8 | id: Int8! 9 | timestamp: Timestamp! 10 | sum: BigDecimal! @aggregate(fn: "sum", arg: "price") 11 | } 12 | -------------------------------------------------------------------------------- /graph/src/schema/test_schemas/ts_data_no_timestamp.graphql: -------------------------------------------------------------------------------- 1 | # fail: TimestampFieldMissing 2 | type Data @entity(timeseries: true) { 3 | id: Int8! 4 | price: BigDecimal! 5 | } 6 | 7 | type Stats @aggregation(intervals: ["hour", "day"], source: "Data") { 8 | id: Int8! 9 | timestamp: Timestamp! 10 | sum: BigDecimal! @aggregate(fn: "sum", arg: "price") 11 | } 12 | -------------------------------------------------------------------------------- /graph/src/schema/test_schemas/ts_data_not_timeseries.graphql: -------------------------------------------------------------------------------- 1 | # fail: AggregationNonTimeseriesSource 2 | type Data @entity { 3 | id: Int8! 4 | timestamp: Timestamp! 5 | price: BigDecimal! 6 | } 7 | 8 | type Stats @aggregation(intervals: ["hour", "day"], source: "Data") { 9 | id: Int8! 10 | timestamp: Timestamp! 11 | sum: BigDecimal! @aggregate(fn: "sum", arg: "price") 12 | } 13 | -------------------------------------------------------------------------------- /graph/src/schema/test_schemas/ts_derived_from.graphql: -------------------------------------------------------------------------------- 1 | # fail: AggregationDerivedField 2 | type Token @entity { 3 | id: Bytes! 4 | stats: Stats! 5 | } 6 | 7 | type Data @entity(timeseries: true) { 8 | id: Int8! 9 | timestamp: Timestamp! 10 | token: Bytes! 11 | price: BigDecimal! 12 | } 13 | 14 | type Stats @aggregation(intervals: ["hour", "day"], source: "Data") { 15 | id: Int8! 16 | timestamp: Timestamp! 17 | token: Token! @derivedFrom(field: "stats") 18 | max: BigDecimal! @aggregate(fn: "max", arg: "price") 19 | sum: BigDecimal! @aggregate(fn: "sum", arg: "price") 20 | } 21 | -------------------------------------------------------------------------------- /graph/src/schema/test_schemas/ts_empty_intervals.graphql: -------------------------------------------------------------------------------- 1 | # fail: AggregationWrongIntervals 2 | type Token @entity { 3 | id: Bytes! 4 | stats: Stats! 5 | } 6 | 7 | type Data @entity(timeseries: true) { 8 | id: Int8! 9 | timestamp: Timestamp! 10 | token: Token! 11 | price: BigDecimal! 12 | } 13 | 14 | type Stats @aggregation(intervals: [], source: "Data") { 15 | id: Int8! 16 | timestamp: Timestamp! 17 | token: Token! 18 | max: BigDecimal! @aggregate(fn: "max", arg: "price") 19 | sum: BigDecimal! @aggregate(fn: "sum", arg: "price") 20 | } 21 | -------------------------------------------------------------------------------- /graph/src/schema/test_schemas/ts_expr_random.graphql: -------------------------------------------------------------------------------- 1 | # fail: ExprNotSupported("Function random is not supported") 2 | # Random must not be allowed as it would introduce nondeterministic behavior 3 | type Data @entity(timeseries: true) { 4 | id: Int8! 5 | timestamp: Timestamp! 6 | price0: BigDecimal! 7 | price1: BigDecimal! 8 | } 9 | 10 | type Stats @aggregation(intervals: ["hour", "day"], source: "Data") { 11 | id: Int8! 12 | timestamp: Timestamp! 13 | max_price: BigDecimal! @aggregate(fn: "max", arg: "random()") 14 | } 15 | -------------------------------------------------------------------------------- /graph/src/schema/test_schemas/ts_expr_syntax_err.graphql: -------------------------------------------------------------------------------- 1 | # fail: ExprParseError("sql parser error: Expected an expression:, found: EOF") 2 | type Data @entity(timeseries: true) { 3 | id: Int8! 4 | timestamp: Timestamp! 5 | price0: BigDecimal! 6 | price1: BigDecimal! 7 | } 8 | 9 | type Stats @aggregation(intervals: ["hour", "day"], source: "Data") { 10 | id: Int8! 11 | timestamp: Timestamp! 12 | max_price: BigDecimal! @aggregate(fn: "max", arg: "greatest(price0,") 13 | } 14 | -------------------------------------------------------------------------------- /graph/src/schema/test_schemas/ts_id_type_mismatch.graphql: -------------------------------------------------------------------------------- 1 | # fail: IllegalIdType 2 | type Data @entity(timeseries: true) { 3 | id: Bytes! 4 | timestamp: Timestamp! 5 | price: BigDecimal! 6 | } 7 | 8 | type Stats @aggregation(intervals: ["hour", "day"], source: "Data") { 9 | id: Int8! 10 | timestamp: Timestamp! 11 | sum: BigDecimal! @aggregate(fn: "sum", arg: "price") 12 | } 13 | -------------------------------------------------------------------------------- /graph/src/schema/test_schemas/ts_invalid_arg.graphql: -------------------------------------------------------------------------------- 1 | # fail: AggregationNonNumericArg 2 | type Token @entity { 3 | id: Bytes! 4 | stats: Stats! 5 | } 6 | 7 | type Data @entity(timeseries: true) { 8 | id: Int8! 9 | timestamp: Timestamp! 10 | token: Token! 11 | price: BigDecimal! 12 | } 13 | 14 | type Stats @aggregation(intervals: ["hour", "day"], source: "Data") { 15 | id: Int8! 16 | timestamp: Timestamp! 17 | token: Token! 18 | max: BigDecimal! @aggregate(fn: "max", arg: "token") 19 | sum: BigDecimal! @aggregate(fn: "sum", arg: "price") 20 | } 21 | -------------------------------------------------------------------------------- /graph/src/schema/test_schemas/ts_invalid_cumulative.graphql: -------------------------------------------------------------------------------- 1 | # fail: AggregationInvalidCumulative("Stats", "sum") 2 | type Data @entity(timeseries: true) { 3 | id: Int8! 4 | timestamp: Timestamp! 5 | price: BigDecimal! 6 | } 7 | 8 | type Stats @aggregation(intervals: ["hour", "day"], source: "Data") { 9 | id: Int8! 10 | timestamp: Timestamp! 11 | sum: BigDecimal! @aggregate(fn: "sum", arg: "price", cumulative: "maybe") 12 | } 13 | -------------------------------------------------------------------------------- /graph/src/schema/test_schemas/ts_invalid_fn.graphql: -------------------------------------------------------------------------------- 1 | # fail: AggregationInvalidFn 2 | type Token @entity { 3 | id: Bytes! 4 | stats: Stats! 5 | } 6 | 7 | type Data @entity(timeseries: true) { 8 | id: Int8! 9 | timestamp: Timestamp! 10 | token: Token! 11 | price: BigDecimal! 12 | } 13 | 14 | type Stats @aggregation(intervals: ["hour", "day"], source: "Data") { 15 | id: Int8! 16 | timestamp: Timestamp! 17 | token: Token! 18 | doit: BigDecimal! @aggregate(fn: "doit", arg: "price") 19 | } 20 | -------------------------------------------------------------------------------- /graph/src/schema/test_schemas/ts_invalid_interval.graphql: -------------------------------------------------------------------------------- 1 | # fail: AggregationInvalidInterval 2 | type Token @entity { 3 | id: Bytes! 4 | stats: Stats! 5 | } 6 | 7 | type Data @entity(timeseries: true) { 8 | id: Int8! 9 | timestamp: Timestamp! 10 | token: Token! 11 | price: BigDecimal! 12 | } 13 | 14 | type Stats @aggregation(intervals: ["fortnight"], source: "Data") { 15 | id: Int8! 16 | timestamp: Timestamp! 17 | token: Token! 18 | max: BigDecimal! @aggregate(fn: "max", arg: "price") 19 | sum: BigDecimal! @aggregate(fn: "sum", arg: "price") 20 | } 21 | -------------------------------------------------------------------------------- /graph/src/schema/test_schemas/ts_invalid_timestamp_aggregation.graphql: -------------------------------------------------------------------------------- 1 | # fail: InvalidTimestampType("Stats", "Int8") 2 | type Data @entity(timeseries: true) { 3 | id: Int8! 4 | timestamp: Timestamp! 5 | price: BigDecimal! 6 | } 7 | 8 | type Stats @aggregation(intervals: ["hour", "day"], source: "Data") { 9 | id: Int8! 10 | timestamp: Int8! 11 | sum: BigDecimal! @aggregate(fn: "sum", arg: "price") 12 | } 13 | -------------------------------------------------------------------------------- /graph/src/schema/test_schemas/ts_invalid_timestamp_timeseries.graphql: -------------------------------------------------------------------------------- 1 | # fail: InvalidTimestampType("Data", "Int8") 2 | type Data @entity(timeseries: true) { 3 | id: Int8! 4 | timestamp: Int8! 5 | price: BigDecimal! 6 | } 7 | 8 | type Stats @aggregation(intervals: ["hour", "day"], source: "Data") { 9 | id: Int8! 10 | timestamp: Timestamp! 11 | sum: BigDecimal! @aggregate(fn: "sum", arg: "price") 12 | } 13 | -------------------------------------------------------------------------------- /graph/src/schema/test_schemas/ts_missing_arg.graphql: -------------------------------------------------------------------------------- 1 | # fail: AggregationMissingArg 2 | type Token @entity { 3 | id: Bytes! 4 | stats: Stats! 5 | } 6 | 7 | type Data @entity(timeseries: true) { 8 | id: Int8! 9 | timestamp: Timestamp! 10 | token: Token! 11 | price: BigDecimal! 12 | } 13 | 14 | type Stats @aggregation(intervals: ["hour", "day"], source: "Data") { 15 | id: Int8! 16 | timestamp: Timestamp! 17 | token: Token! 18 | max: BigDecimal! @aggregate(fn: "max") 19 | } 20 | -------------------------------------------------------------------------------- /graph/src/schema/test_schemas/ts_missing_fn.graphql: -------------------------------------------------------------------------------- 1 | # fail: AggregationMissingFn 2 | type Token @entity { 3 | id: Bytes! 4 | stats: Stats! 5 | } 6 | 7 | type Data @entity(timeseries: true) { 8 | id: Int8! 9 | timestamp: Timestamp! 10 | token: Token! 11 | price: BigDecimal! 12 | } 13 | 14 | type Stats @aggregation(intervals: ["hour", "day"], source: "Data") { 15 | id: Int8! 16 | timestamp: Timestamp! 17 | token: Token! 18 | max: BigDecimal! @aggregate(arg: "price") 19 | } 20 | -------------------------------------------------------------------------------- /graph/src/schema/test_schemas/ts_missing_type.graphql: -------------------------------------------------------------------------------- 1 | # fail: FieldTypeUnknown 2 | type Data @entity(timeseries: true) { 3 | id: Int8! 4 | timestamp: Timestamp! 5 | token: Token! 6 | price: BigDecimal! 7 | } 8 | 9 | type Stats @aggregation(intervals: ["hour", "day"], source: "Data") { 10 | id: Int8! 11 | timestamp: Timestamp! 12 | token: Token! 13 | max: BigDecimal! @aggregate(fn: "max", arg: "price") 14 | sum: BigDecimal! @aggregate(fn: "sum", arg: "price") 15 | } 16 | -------------------------------------------------------------------------------- /graph/src/schema/test_schemas/ts_no_aggregate.graphql: -------------------------------------------------------------------------------- 1 | # fail: PointlessAggregation 2 | type Token @entity { 3 | id: Bytes! 4 | stats: Stats! 5 | } 6 | 7 | type Data @entity(timeseries: true) { 8 | id: Int8! 9 | timestamp: Timestamp! 10 | token: Token! 11 | price: BigDecimal! 12 | } 13 | 14 | type Stats @aggregation(intervals: ["hour", "day"], source: "Data") { 15 | id: Int8! 16 | timestamp: Timestamp! 17 | token: Token! 18 | } 19 | -------------------------------------------------------------------------------- /graph/src/schema/test_schemas/ts_no_id.graphql: -------------------------------------------------------------------------------- 1 | # fail: IllegalIdType 2 | type Token @entity { 3 | id: Bytes! 4 | stats: Stats! 5 | } 6 | 7 | type Data @entity(timeseries: true) { 8 | id: Int8! 9 | timestamp: Timestamp! 10 | token: Token! 11 | price: BigDecimal! 12 | } 13 | 14 | type Stats @aggregation(intervals: ["hour", "day"], source: "Data") { 15 | timestamp: Timestamp! 16 | token: Token! 17 | max: BigDecimal! @aggregate(fn: "max", arg: "price") 18 | sum: BigDecimal! @aggregate(fn: "sum", arg: "price") 19 | } 20 | -------------------------------------------------------------------------------- /graph/src/schema/test_schemas/ts_no_interval.graphql: -------------------------------------------------------------------------------- 1 | # fail: AggregationMissingIntervals 2 | type Token @entity { 3 | id: Bytes! 4 | stats: Stats! 5 | } 6 | 7 | type Data @entity(timeseries: true) { 8 | id: Int8! 9 | timestamp: Timestamp! 10 | token: Token! 11 | price: BigDecimal! 12 | } 13 | 14 | type Stats @aggregation(source: "Data") { 15 | id: Int8! 16 | timestamp: Timestamp! 17 | token: Token! 18 | max: BigDecimal! @aggregate(fn: "max", arg: "price") 19 | sum: BigDecimal! @aggregate(fn: "sum", arg: "price") 20 | } 21 | -------------------------------------------------------------------------------- /graph/src/schema/test_schemas/ts_no_timeseries.graphql: -------------------------------------------------------------------------------- 1 | # fail: EntityDirectivesMissing 2 | type Stats { 3 | id: Int8! 4 | timestamp: Timestamp! 5 | token: Bytes! 6 | avg: BigDecimal! @aggregate(fn: "avg", arg: "price") 7 | sum: BigInt! @aggregate(fn: "sum", arg: "price") 8 | } 9 | -------------------------------------------------------------------------------- /graph/src/schema/test_schemas/ts_no_timestamp.graphql: -------------------------------------------------------------------------------- 1 | # fail: TimestampFieldMissing 2 | type Token @entity { 3 | id: Bytes! 4 | stats: Stats! 5 | } 6 | 7 | type Data @entity(timeseries: true) { 8 | id: Int8! 9 | timestamp: Timestamp! 10 | token: Token! 11 | price: BigDecimal! 12 | } 13 | 14 | type Stats @aggregation(intervals: ["hour", "day"], source: "Data") { 15 | id: Int8! 16 | token: Token! 17 | max: BigDecimal! @aggregate(fn: "max", arg: "price") 18 | sum: BigDecimal! @aggregate(fn: "sum", arg: "price") 19 | } 20 | -------------------------------------------------------------------------------- /graph/src/schema/test_schemas/ts_valid.graphql: -------------------------------------------------------------------------------- 1 | # valid: Simple example 2 | type Token @entity { 3 | id: Bytes! 4 | stats: Stats! @derivedFrom(field: "token") 5 | } 6 | 7 | type Data @entity(timeseries: true) { 8 | id: Int8! 9 | timestamp: Timestamp! 10 | token: Token! 11 | price: BigDecimal! 12 | } 13 | 14 | type Stats @aggregation(intervals: ["hour", "day"], source: "Data") { 15 | id: Int8! 16 | timestamp: Timestamp! 17 | token: Token! 18 | max: BigDecimal! @aggregate(fn: "max", arg: "price") 19 | sum: BigDecimal! @aggregate(fn: "sum", arg: "price") 20 | } 21 | -------------------------------------------------------------------------------- /graph/src/schema/test_schemas/ts_valid_cumulative.graphql: -------------------------------------------------------------------------------- 1 | # valid: Minimal example 2 | type Data @entity(timeseries: true) { 3 | id: Int8! 4 | timestamp: Timestamp! 5 | price: BigDecimal! 6 | } 7 | 8 | type Stats @aggregation(intervals: ["hour", "day"], source: "Data") { 9 | id: Int8! 10 | timestamp: Timestamp! 11 | sum: BigDecimal! @aggregate(fn: "sum", arg: "price", cumulative: true) 12 | } 13 | -------------------------------------------------------------------------------- /graph/src/schema/test_schemas/ts_valid_minimal.graphql: -------------------------------------------------------------------------------- 1 | # valid: Minimal example 2 | type Data @entity(timeseries: true) { 3 | id: Int8! 4 | timestamp: Timestamp! 5 | price: BigDecimal! 6 | } 7 | 8 | type Stats @aggregation(intervals: ["hour", "day"], source: "Data") { 9 | id: Int8! 10 | timestamp: Timestamp! 11 | sum: BigDecimal! @aggregate(fn: "sum", arg: "price") 12 | } 13 | -------------------------------------------------------------------------------- /graph/src/schema/test_schemas/ts_wrong_interval.graphql: -------------------------------------------------------------------------------- 1 | # fail: AggregationWrongIntervals 2 | type Data @entity(timeseries: true) { 3 | id: Int8! 4 | timestamp: Timestamp! 5 | price: BigDecimal! 6 | } 7 | 8 | type Stats @aggregation(intervals: [60, 1440], source: "Data") { 9 | id: Int8! 10 | timestamp: Timestamp! 11 | sum: BigDecimal! @aggregate(fn: "sum", arg: "price") 12 | } 13 | -------------------------------------------------------------------------------- /graph/src/substreams/codec.rs: -------------------------------------------------------------------------------- 1 | #[rustfmt::skip] 2 | #[path = "sf.substreams.v1.rs"] 3 | mod pbsubstreams; 4 | 5 | pub use pbsubstreams::*; 6 | -------------------------------------------------------------------------------- /graph/src/substreams/mod.rs: -------------------------------------------------------------------------------- 1 | mod codec; 2 | 3 | pub use codec::*; 4 | 5 | use self::module::input::{Input, Params}; 6 | 7 | /// Replace all the existing params with the provided ones. 8 | pub fn patch_module_params(params: String, module: &mut Module) { 9 | let mut inputs = vec![crate::substreams::module::Input { 10 | input: Some(Input::Params(Params { value: params })), 11 | }]; 12 | 13 | inputs.extend(module.inputs.iter().flat_map(|input| match input.input { 14 | None => None, 15 | Some(Input::Params(_)) => None, 16 | Some(_) => Some(input.clone()), 17 | })); 18 | 19 | module.inputs = inputs; 20 | } 21 | -------------------------------------------------------------------------------- /graph/src/substreams_rpc/codec.rs: -------------------------------------------------------------------------------- 1 | #[rustfmt::skip] 2 | #[path = "sf.substreams.rpc.v2.rs"] 3 | mod pbsubstreamsrpc; 4 | 5 | pub use pbsubstreamsrpc::*; 6 | -------------------------------------------------------------------------------- /graph/src/substreams_rpc/mod.rs: -------------------------------------------------------------------------------- 1 | mod codec; 2 | 3 | pub use codec::*; 4 | -------------------------------------------------------------------------------- /graph/src/util/mem.rs: -------------------------------------------------------------------------------- 1 | use std::mem::{transmute, MaybeUninit}; 2 | 3 | /// Temporarily needed until MaybeUninit::write_slice is stabilized. 4 | pub fn init_slice<'a, T>(src: &[T], dst: &'a mut [MaybeUninit]) -> &'a mut [T] 5 | where 6 | T: Copy, 7 | { 8 | unsafe { 9 | let uninit_src: &[MaybeUninit] = transmute(src); 10 | dst.copy_from_slice(uninit_src); 11 | &mut *(dst as *mut [MaybeUninit] as *mut [T]) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /graph/tests/README.md: -------------------------------------------------------------------------------- 1 | Put integration tests for this crate into `store/test-store/tests/graph`. 2 | This avoids cyclic dev-dependencies which make rust-analyzer nearly 3 | unusable. Once [this 4 | issue](https://github.com/rust-lang/rust-analyzer/issues/14167) has been 5 | fixed, we can move tests back here 6 | -------------------------------------------------------------------------------- /graphql/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "graph-graphql" 3 | version.workspace = true 4 | edition.workspace = true 5 | 6 | [dependencies] 7 | crossbeam = "0.8" 8 | graph = { path = "../graph" } 9 | graphql-tools = "0.4.0" 10 | lazy_static = "1.5.0" 11 | stable-hash = { git = "https://github.com/graphprotocol/stable-hash", branch = "main"} 12 | stable-hash_legacy = { git = "https://github.com/graphprotocol/stable-hash", branch = "old", package = "stable-hash" } 13 | parking_lot = "0.12" 14 | anyhow = "1.0" 15 | async-recursion = "1.1.1" 16 | -------------------------------------------------------------------------------- /graphql/src/execution/mod.rs: -------------------------------------------------------------------------------- 1 | mod cache; 2 | /// Implementation of the GraphQL execution algorithm. 3 | mod execution; 4 | mod query; 5 | /// Common trait for field resolvers used in the execution. 6 | mod resolver; 7 | 8 | /// Our representation of a query AST 9 | pub mod ast; 10 | 11 | use stable_hash_legacy::{crypto::SetHasher, StableHasher}; 12 | 13 | pub use self::execution::*; 14 | pub use self::query::Query; 15 | pub use self::resolver::Resolver; 16 | 17 | type QueryHash = ::Out; 18 | -------------------------------------------------------------------------------- /graphql/src/introspection/mod.rs: -------------------------------------------------------------------------------- 1 | mod resolver; 2 | 3 | pub use self::resolver::IntrospectionResolver; 4 | -------------------------------------------------------------------------------- /graphql/src/store/mod.rs: -------------------------------------------------------------------------------- 1 | mod prefetch; 2 | mod query; 3 | mod resolver; 4 | 5 | pub use self::resolver::StoreResolver; 6 | -------------------------------------------------------------------------------- /graphql/src/values/mod.rs: -------------------------------------------------------------------------------- 1 | /// Utilities for coercing GraphQL values based on GraphQL types. 2 | pub mod coercion; 3 | 4 | pub use self::coercion::MaybeCoercible; 5 | -------------------------------------------------------------------------------- /graphql/tests/README.md: -------------------------------------------------------------------------------- 1 | Put integration tests for this crate into `store/test-store/tests/graphql`. 2 | This avoids cyclic dev-dependencies which make rust-analyzer nearly 3 | unusable. Once [this 4 | issue](https://github.com/rust-lang/rust-analyzer/issues/14167) has been 5 | fixed, we can move tests back here 6 | -------------------------------------------------------------------------------- /node/src/lib.rs: -------------------------------------------------------------------------------- 1 | use std::sync::Arc; 2 | 3 | use graph::{prelude::MetricsRegistry, prometheus::Registry}; 4 | 5 | #[macro_use] 6 | extern crate diesel; 7 | 8 | pub mod chain; 9 | pub mod config; 10 | pub mod network_setup; 11 | pub mod opt; 12 | pub mod store_builder; 13 | 14 | pub mod manager; 15 | 16 | pub struct MetricsContext { 17 | pub prometheus: Arc, 18 | pub registry: Arc, 19 | pub prometheus_host: Option, 20 | pub job_name: Option, 21 | } 22 | -------------------------------------------------------------------------------- /node/src/manager/commands/create.rs: -------------------------------------------------------------------------------- 1 | use std::sync::Arc; 2 | 3 | use graph::prelude::{anyhow, Error, SubgraphName, SubgraphStore as _}; 4 | use graph_store_postgres::SubgraphStore; 5 | 6 | pub fn run(store: Arc, name: String) -> Result<(), Error> { 7 | let name = SubgraphName::new(name.clone()) 8 | .map_err(|()| anyhow!("illegal subgraph name `{}`", name))?; 9 | 10 | println!("creating subgraph {}", name); 11 | store.create_subgraph(name)?; 12 | 13 | Ok(()) 14 | } 15 | -------------------------------------------------------------------------------- /node/src/manager/commands/deployment/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod info; 2 | pub mod pause; 3 | pub mod reassign; 4 | pub mod restart; 5 | pub mod resume; 6 | pub mod unassign; 7 | -------------------------------------------------------------------------------- /node/src/manager/commands/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod assign; 2 | pub mod chain; 3 | pub mod check_blocks; 4 | pub mod config; 5 | pub mod copy; 6 | pub mod create; 7 | pub mod database; 8 | pub mod deploy; 9 | pub mod deployment; 10 | pub mod index; 11 | pub mod listen; 12 | pub mod provider_checks; 13 | pub mod prune; 14 | pub mod query; 15 | pub mod remove; 16 | pub mod rewind; 17 | pub mod run; 18 | pub mod stats; 19 | pub mod txn_speed; 20 | pub mod unused_deployments; 21 | -------------------------------------------------------------------------------- /node/src/manager/commands/remove.rs: -------------------------------------------------------------------------------- 1 | use std::sync::Arc; 2 | 3 | use graph::prelude::{anyhow, Error, SubgraphName, SubgraphStore as _}; 4 | use graph_store_postgres::SubgraphStore; 5 | 6 | pub fn run(store: Arc, name: &str) -> Result<(), Error> { 7 | let name = SubgraphName::new(name).map_err(|()| anyhow!("illegal subgraph name `{}`", name))?; 8 | 9 | println!("Removing subgraph {}", name); 10 | store.remove_subgraph(name)?; 11 | 12 | Ok(()) 13 | } 14 | -------------------------------------------------------------------------------- /node/src/manager/mod.rs: -------------------------------------------------------------------------------- 1 | use graph::{ 2 | components::store::SubscriptionManager, 3 | prelude::{anyhow, StoreEventStreamBox}, 4 | }; 5 | 6 | pub mod catalog; 7 | pub mod color; 8 | pub mod commands; 9 | pub mod deployment; 10 | mod display; 11 | pub mod fmt; 12 | pub mod prompt; 13 | 14 | /// A dummy subscription manager that always panics 15 | pub struct PanicSubscriptionManager; 16 | 17 | impl SubscriptionManager for PanicSubscriptionManager { 18 | fn subscribe(&self) -> StoreEventStreamBox { 19 | panic!("we were never meant to call `subscribe`"); 20 | } 21 | } 22 | 23 | pub type CmdResult = Result<(), anyhow::Error>; 24 | -------------------------------------------------------------------------------- /node/src/manager/prompt.rs: -------------------------------------------------------------------------------- 1 | use graph::anyhow; 2 | use std::io::{self, Write}; 3 | 4 | /// Asks users if they are certain about a certain action. 5 | pub fn prompt_for_confirmation(prompt: &str) -> anyhow::Result { 6 | print!("{prompt} [y/N] "); 7 | io::stdout().flush()?; 8 | 9 | let mut answer = String::new(); 10 | io::stdin().read_line(&mut answer)?; 11 | answer.make_ascii_lowercase(); 12 | 13 | match answer.trim() { 14 | "y" | "yes" => Ok(true), 15 | _ => Ok(false), 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /runtime/derive/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "graph-runtime-derive" 3 | version.workspace = true 4 | edition.workspace = true 5 | 6 | [lib] 7 | proc-macro = true 8 | 9 | [dependencies] 10 | syn = { workspace = true } 11 | quote = "1.0" 12 | proc-macro2 = "1.0.95" 13 | heck = "0.5" 14 | -------------------------------------------------------------------------------- /runtime/test/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "graph-runtime-test" 3 | version.workspace = true 4 | edition.workspace = true 5 | 6 | [dependencies] 7 | semver = "1.0" 8 | wasmtime.workspace = true 9 | graph = { path = "../../graph" } 10 | graph-chain-ethereum = { path = "../../chain/ethereum" } 11 | graph-runtime-derive = { path = "../derive" } 12 | graph-runtime-wasm = { path = "../wasm" } 13 | rand.workspace = true 14 | 15 | 16 | [dev-dependencies] 17 | test-store = { path = "../../store/test-store" } 18 | -------------------------------------------------------------------------------- /runtime/test/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![cfg(test)] 2 | pub mod common; 3 | mod test; 4 | 5 | #[cfg(test)] 6 | pub mod test_padding; 7 | 8 | // this used in crate::test_padding module 9 | // graph_runtime_derive::generate_from_rust_type looks for types in crate::protobuf, 10 | // hence this mod presence in crate that uses ASC related macros is required 11 | pub mod protobuf { 12 | pub use super::test_padding::data::*; 13 | } 14 | -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_4/abi_classes.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphprotocol/graph-node/94fb3f2825a66dd54c628c2866e3b1165d077576/runtime/test/wasm_test/api_version_0_0_4/abi_classes.wasm -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_4/abi_store_value.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphprotocol/graph-node/94fb3f2825a66dd54c628c2866e3b1165d077576/runtime/test/wasm_test/api_version_0_0_4/abi_store_value.wasm -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_4/abi_token.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphprotocol/graph-node/94fb3f2825a66dd54c628c2866e3b1165d077576/runtime/test/wasm_test/api_version_0_0_4/abi_token.wasm -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_4/abort.ts: -------------------------------------------------------------------------------- 1 | import "allocator/arena"; 2 | 3 | export { memory }; 4 | 5 | export function abort(): void { 6 | assert(false, "not true") 7 | } 8 | -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_4/abort.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphprotocol/graph-node/94fb3f2825a66dd54c628c2866e3b1165d077576/runtime/test/wasm_test/api_version_0_0_4/abort.wasm -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_4/big_int_arithmetic.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphprotocol/graph-node/94fb3f2825a66dd54c628c2866e3b1165d077576/runtime/test/wasm_test/api_version_0_0_4/big_int_arithmetic.wasm -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_4/big_int_to_hex.ts: -------------------------------------------------------------------------------- 1 | import "allocator/arena"; 2 | 3 | export { memory }; 4 | 5 | declare namespace typeConversion { 6 | function bigIntToHex(n: Uint8Array): String 7 | } 8 | 9 | export function big_int_to_hex(n: Uint8Array): String { 10 | return typeConversion.bigIntToHex(n) 11 | } 12 | -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_4/big_int_to_hex.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphprotocol/graph-node/94fb3f2825a66dd54c628c2866e3b1165d077576/runtime/test/wasm_test/api_version_0_0_4/big_int_to_hex.wasm -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_4/big_int_to_string.ts: -------------------------------------------------------------------------------- 1 | import "allocator/arena"; 2 | 3 | export { memory }; 4 | 5 | declare namespace typeConversion { 6 | function bigIntToString(n: Uint8Array): String 7 | } 8 | 9 | export function big_int_to_string(n: Uint8Array): String { 10 | return typeConversion.bigIntToString(n) 11 | } 12 | -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_4/big_int_to_string.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphprotocol/graph-node/94fb3f2825a66dd54c628c2866e3b1165d077576/runtime/test/wasm_test/api_version_0_0_4/big_int_to_string.wasm -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_4/bytes_to_base58.ts: -------------------------------------------------------------------------------- 1 | import "allocator/arena"; 2 | 3 | export { memory }; 4 | 5 | declare namespace typeConversion { 6 | function bytesToBase58(n: Uint8Array): string 7 | } 8 | 9 | export function bytes_to_base58(n: Uint8Array): string { 10 | return typeConversion.bytesToBase58(n) 11 | } 12 | -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_4/bytes_to_base58.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphprotocol/graph-node/94fb3f2825a66dd54c628c2866e3b1165d077576/runtime/test/wasm_test/api_version_0_0_4/bytes_to_base58.wasm -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_4/contract_calls.ts: -------------------------------------------------------------------------------- 1 | type Address = Uint8Array; 2 | 3 | export declare namespace ethereum { 4 | function call(call: Address): Array
| null 5 | } 6 | 7 | export function callContract(address: Address): void { 8 | ethereum.call(address) 9 | } -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_4/contract_calls.wasm: -------------------------------------------------------------------------------- 1 | asm ``` contract_calls ethereum.callpA !memorytable callContract A  2 |    -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_4/crypto.ts: -------------------------------------------------------------------------------- 1 | import "allocator/arena"; 2 | 3 | export { memory }; 4 | 5 | declare namespace crypto { 6 | function keccak256(input: Uint8Array): Uint8Array 7 | } 8 | 9 | export function hash(input: Uint8Array): Uint8Array { 10 | return crypto.keccak256(input) 11 | } 12 | -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_4/crypto.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphprotocol/graph-node/94fb3f2825a66dd54c628c2866e3b1165d077576/runtime/test/wasm_test/api_version_0_0_4/crypto.wasm -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_4/data_source_create.ts: -------------------------------------------------------------------------------- 1 | import "allocator/arena"; 2 | 3 | export { memory }; 4 | 5 | declare namespace dataSource { 6 | function create(name: string, params: Array): void 7 | } 8 | 9 | export function dataSourceCreate(name: string, params: Array): void { 10 | dataSource.create(name, params) 11 | } 12 | -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_4/data_source_create.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphprotocol/graph-node/94fb3f2825a66dd54c628c2866e3b1165d077576/runtime/test/wasm_test/api_version_0_0_4/data_source_create.wasm -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_4/ens_name_by_hash.ts: -------------------------------------------------------------------------------- 1 | import "allocator/arena"; 2 | 3 | export { memory }; 4 | 5 | declare namespace ens { 6 | function nameByHash(hash: string): string|null 7 | } 8 | 9 | export function nameByHash(hash: string): string|null { 10 | return ens.nameByHash(hash) 11 | } 12 | -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_4/ens_name_by_hash.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphprotocol/graph-node/94fb3f2825a66dd54c628c2866e3b1165d077576/runtime/test/wasm_test/api_version_0_0_4/ens_name_by_hash.wasm -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_4/ipfs_cat.ts: -------------------------------------------------------------------------------- 1 | import "allocator/arena"; 2 | 3 | export { memory }; 4 | 5 | declare namespace typeConversion { 6 | function bytesToString(bytes: Uint8Array): string 7 | } 8 | 9 | declare namespace ipfs { 10 | function cat(hash: String): Uint8Array 11 | } 12 | 13 | export function ipfsCatString(hash: string): string { 14 | return typeConversion.bytesToString(ipfs.cat(hash)) 15 | } 16 | 17 | export function ipfsCat(hash: string): Uint8Array { 18 | return ipfs.cat(hash) 19 | } 20 | -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_4/ipfs_cat.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphprotocol/graph-node/94fb3f2825a66dd54c628c2866e3b1165d077576/runtime/test/wasm_test/api_version_0_0_4/ipfs_cat.wasm -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_4/ipfs_map.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphprotocol/graph-node/94fb3f2825a66dd54c628c2866e3b1165d077576/runtime/test/wasm_test/api_version_0_0_4/ipfs_map.wasm -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_4/json_parsing.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphprotocol/graph-node/94fb3f2825a66dd54c628c2866e3b1165d077576/runtime/test/wasm_test/api_version_0_0_4/json_parsing.wasm -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_4/non_terminating.ts: -------------------------------------------------------------------------------- 1 | import "allocator/arena"; 2 | export { memory }; 3 | 4 | // Test that non-terminating handlers are killed by timeout. 5 | export function loop(): void { 6 | while (true) {} 7 | } 8 | 9 | export function rabbit_hole(): void { 10 | rabbit_hole() 11 | } 12 | -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_4/non_terminating.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphprotocol/graph-node/94fb3f2825a66dd54c628c2866e3b1165d077576/runtime/test/wasm_test/api_version_0_0_4/non_terminating.wasm -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_4/store.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphprotocol/graph-node/94fb3f2825a66dd54c628c2866e3b1165d077576/runtime/test/wasm_test/api_version_0_0_4/store.wasm -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_4/string_to_number.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphprotocol/graph-node/94fb3f2825a66dd54c628c2866e3b1165d077576/runtime/test/wasm_test/api_version_0_0_4/string_to_number.wasm -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_4/test_padding.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphprotocol/graph-node/94fb3f2825a66dd54c628c2866e3b1165d077576/runtime/test/wasm_test/api_version_0_0_4/test_padding.wasm -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_4/yaml_parsing.ts: -------------------------------------------------------------------------------- 1 | import "allocator/arena"; 2 | 3 | import {Bytes, Result} from "../api_version_0_0_5/common/types"; 4 | import {debug, YAMLValue} from "../api_version_0_0_5/common/yaml"; 5 | 6 | export {memory}; 7 | 8 | declare namespace yaml { 9 | function try_fromBytes(data: Bytes): Result; 10 | } 11 | 12 | export function handleYaml(data: Bytes): string { 13 | let result = yaml.try_fromBytes(data); 14 | 15 | if (result.isError) { 16 | return "error"; 17 | } 18 | 19 | return debug(result.value); 20 | } 21 | -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_4/yaml_parsing.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphprotocol/graph-node/94fb3f2825a66dd54c628c2866e3b1165d077576/runtime/test/wasm_test/api_version_0_0_4/yaml_parsing.wasm -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_5/abi_classes.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphprotocol/graph-node/94fb3f2825a66dd54c628c2866e3b1165d077576/runtime/test/wasm_test/api_version_0_0_5/abi_classes.wasm -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_5/abi_store_value.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphprotocol/graph-node/94fb3f2825a66dd54c628c2866e3b1165d077576/runtime/test/wasm_test/api_version_0_0_5/abi_store_value.wasm -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_5/abi_token.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphprotocol/graph-node/94fb3f2825a66dd54c628c2866e3b1165d077576/runtime/test/wasm_test/api_version_0_0_5/abi_token.wasm -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_5/abort.ts: -------------------------------------------------------------------------------- 1 | export * from './common/global' 2 | 3 | export function abort(): void { 4 | assert(false, "not true") 5 | } 6 | -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_5/abort.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphprotocol/graph-node/94fb3f2825a66dd54c628c2866e3b1165d077576/runtime/test/wasm_test/api_version_0_0_5/abort.wasm -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_5/allocate_global.ts: -------------------------------------------------------------------------------- 1 | export * from './common/global' 2 | import { BigInt } from './common/types' 3 | 4 | let globalOne = bigInt.fromString("1") 5 | 6 | declare namespace bigInt { 7 | function fromString(s: string): BigInt 8 | } 9 | 10 | export function assert_global_works(): void { 11 | let localOne = bigInt.fromString("1") 12 | assert(globalOne != localOne) 13 | } 14 | -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_5/allocate_global.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphprotocol/graph-node/94fb3f2825a66dd54c628c2866e3b1165d077576/runtime/test/wasm_test/api_version_0_0_5/allocate_global.wasm -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_5/array_blowup.ts: -------------------------------------------------------------------------------- 1 | export * from './common/global' 2 | import { Bytes, Entity, Value } from './common/types' 3 | 4 | /** Definitions copied from graph-ts/index.ts */ 5 | declare namespace store { 6 | function set(entity: string, id: string, data: Entity): void 7 | } 8 | 9 | export function arrayBlowup(): void { 10 | // 1 GB array. 11 | let s = changetype(new Bytes(1_000_000_000).fill(1)); 12 | 13 | // Repeated 100 times. 14 | let a = new Array(100).fill(s); 15 | 16 | let entity = new Entity(); 17 | entity.set("field", Value.fromBytesArray(a)); 18 | store.set("NonExisting", "foo", entity) 19 | } 20 | 21 | -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_5/array_blowup.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphprotocol/graph-node/94fb3f2825a66dd54c628c2866e3b1165d077576/runtime/test/wasm_test/api_version_0_0_5/array_blowup.wasm -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_5/big_int_arithmetic.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphprotocol/graph-node/94fb3f2825a66dd54c628c2866e3b1165d077576/runtime/test/wasm_test/api_version_0_0_5/big_int_arithmetic.wasm -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_5/big_int_size_limit.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphprotocol/graph-node/94fb3f2825a66dd54c628c2866e3b1165d077576/runtime/test/wasm_test/api_version_0_0_5/big_int_size_limit.wasm -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_5/big_int_to_hex.ts: -------------------------------------------------------------------------------- 1 | export * from './common/global' 2 | 3 | declare namespace typeConversion { 4 | function bigIntToHex(n: Uint8Array): string 5 | } 6 | 7 | export function big_int_to_hex(n: Uint8Array): string { 8 | return typeConversion.bigIntToHex(n) 9 | } 10 | -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_5/big_int_to_hex.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphprotocol/graph-node/94fb3f2825a66dd54c628c2866e3b1165d077576/runtime/test/wasm_test/api_version_0_0_5/big_int_to_hex.wasm -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_5/big_int_to_string.ts: -------------------------------------------------------------------------------- 1 | export * from './common/global' 2 | 3 | declare namespace typeConversion { 4 | function bigIntToString(n: Uint8Array): string 5 | } 6 | 7 | export function big_int_to_string(n: Uint8Array): string { 8 | return typeConversion.bigIntToString(n) 9 | } 10 | -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_5/big_int_to_string.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphprotocol/graph-node/94fb3f2825a66dd54c628c2866e3b1165d077576/runtime/test/wasm_test/api_version_0_0_5/big_int_to_string.wasm -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_5/boolean.ts: -------------------------------------------------------------------------------- 1 | export * from "./common/global" 2 | 3 | export function testReceiveTrue(a: bool): void { 4 | assert(a) 5 | } 6 | 7 | export function testReceiveFalse(a: bool): void { 8 | assert(!a) 9 | } 10 | 11 | export function testReturnTrue(): bool { 12 | return true 13 | } 14 | 15 | export function testReturnFalse(): bool { 16 | return false 17 | } 18 | -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_5/boolean.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphprotocol/graph-node/94fb3f2825a66dd54c628c2866e3b1165d077576/runtime/test/wasm_test/api_version_0_0_5/boolean.wasm -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_5/bytes_to_base58.ts: -------------------------------------------------------------------------------- 1 | export * from './common/global' 2 | 3 | declare namespace typeConversion { 4 | function bytesToBase58(n: Uint8Array): string 5 | } 6 | 7 | export function bytes_to_base58(n: Uint8Array): string { 8 | return typeConversion.bytesToBase58(n) 9 | } 10 | -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_5/bytes_to_base58.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphprotocol/graph-node/94fb3f2825a66dd54c628c2866e3b1165d077576/runtime/test/wasm_test/api_version_0_0_5/bytes_to_base58.wasm -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_5/contract_calls.ts: -------------------------------------------------------------------------------- 1 | export * from './common/global' 2 | import { Address } from './common/types' 3 | 4 | export declare namespace ethereum { 5 | function call(call: Address): Array
| null 6 | } 7 | 8 | export function callContract(address: Address): void { 9 | ethereum.call(address) 10 | } 11 | -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_5/contract_calls.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphprotocol/graph-node/94fb3f2825a66dd54c628c2866e3b1165d077576/runtime/test/wasm_test/api_version_0_0_5/contract_calls.wasm -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_5/crypto.ts: -------------------------------------------------------------------------------- 1 | export * from './common/global' 2 | 3 | declare namespace crypto { 4 | function keccak256(input: Uint8Array): Uint8Array 5 | } 6 | 7 | export function hash(input: Uint8Array): Uint8Array { 8 | return crypto.keccak256(input) 9 | } 10 | -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_5/crypto.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphprotocol/graph-node/94fb3f2825a66dd54c628c2866e3b1165d077576/runtime/test/wasm_test/api_version_0_0_5/crypto.wasm -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_5/data_source_create.ts: -------------------------------------------------------------------------------- 1 | export * from './common/global' 2 | 3 | declare namespace dataSource { 4 | function create(name: string, params: Array): void 5 | } 6 | 7 | export function dataSourceCreate(name: string, params: Array): void { 8 | dataSource.create(name, params) 9 | } 10 | -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_5/data_source_create.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphprotocol/graph-node/94fb3f2825a66dd54c628c2866e3b1165d077576/runtime/test/wasm_test/api_version_0_0_5/data_source_create.wasm -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_5/ens_name_by_hash.ts: -------------------------------------------------------------------------------- 1 | export * from './common/global' 2 | 3 | declare namespace ens { 4 | function nameByHash(hash: string): string|null 5 | } 6 | 7 | export function nameByHash(hash: string): string|null { 8 | return ens.nameByHash(hash) 9 | } 10 | -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_5/ens_name_by_hash.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphprotocol/graph-node/94fb3f2825a66dd54c628c2866e3b1165d077576/runtime/test/wasm_test/api_version_0_0_5/ens_name_by_hash.wasm -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_5/ipfs_block.ts: -------------------------------------------------------------------------------- 1 | export * from './common/global' 2 | 3 | declare namespace typeConversion { 4 | function bytesToHex(bytes: Uint8Array): string 5 | } 6 | 7 | declare namespace ipfs { 8 | function getBlock(hash: String): Uint8Array 9 | } 10 | 11 | export function ipfsBlockHex(hash: string): string { 12 | return typeConversion.bytesToHex(ipfs.getBlock(hash)) 13 | } 14 | -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_5/ipfs_block.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphprotocol/graph-node/94fb3f2825a66dd54c628c2866e3b1165d077576/runtime/test/wasm_test/api_version_0_0_5/ipfs_block.wasm -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_5/ipfs_cat.ts: -------------------------------------------------------------------------------- 1 | export * from './common/global' 2 | 3 | declare namespace typeConversion { 4 | function bytesToString(bytes: Uint8Array): string 5 | } 6 | 7 | declare namespace ipfs { 8 | function cat(hash: String): Uint8Array 9 | } 10 | 11 | export function ipfsCatString(hash: string): string { 12 | return typeConversion.bytesToString(ipfs.cat(hash)) 13 | } 14 | 15 | export function ipfsCat(hash: string): Uint8Array { 16 | return ipfs.cat(hash) 17 | } 18 | -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_5/ipfs_cat.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphprotocol/graph-node/94fb3f2825a66dd54c628c2866e3b1165d077576/runtime/test/wasm_test/api_version_0_0_5/ipfs_cat.wasm -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_5/ipfs_map.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphprotocol/graph-node/94fb3f2825a66dd54c628c2866e3b1165d077576/runtime/test/wasm_test/api_version_0_0_5/ipfs_map.wasm -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_5/json_parsing.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphprotocol/graph-node/94fb3f2825a66dd54c628c2866e3b1165d077576/runtime/test/wasm_test/api_version_0_0_5/json_parsing.wasm -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_5/non_terminating.ts: -------------------------------------------------------------------------------- 1 | export * from './common/global' 2 | 3 | // Test that non-terminating handlers are killed by timeout. 4 | export function loop(): void { 5 | while (true) {} 6 | } 7 | 8 | export function rabbit_hole(): void { 9 | rabbit_hole() 10 | } 11 | -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_5/non_terminating.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphprotocol/graph-node/94fb3f2825a66dd54c628c2866e3b1165d077576/runtime/test/wasm_test/api_version_0_0_5/non_terminating.wasm -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_5/null_ptr_read.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphprotocol/graph-node/94fb3f2825a66dd54c628c2866e3b1165d077576/runtime/test/wasm_test/api_version_0_0_5/null_ptr_read.wasm -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_5/recursion_limit.ts: -------------------------------------------------------------------------------- 1 | export * from './common/global'; 2 | 3 | import { Entity, Value } from './common/types' 4 | 5 | declare namespace store { 6 | function get(entity: string, id: string): Entity | null 7 | function set(entity: string, id: string, data: Entity): void 8 | function remove(entity: string, id: string): void 9 | } 10 | 11 | export function recursionLimit(depth: i32): void { 12 | let user = new Entity(); 13 | var val = Value.fromI32(7); 14 | for (let i = 0; i < depth; i++) { 15 | val = Value.fromArray([val]); 16 | } 17 | user.set("foobar", val); 18 | store.set("User", "user_id", user); 19 | } -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_5/recursion_limit.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphprotocol/graph-node/94fb3f2825a66dd54c628c2866e3b1165d077576/runtime/test/wasm_test/api_version_0_0_5/recursion_limit.wasm -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_5/store.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphprotocol/graph-node/94fb3f2825a66dd54c628c2866e3b1165d077576/runtime/test/wasm_test/api_version_0_0_5/store.wasm -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_5/string_to_number.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphprotocol/graph-node/94fb3f2825a66dd54c628c2866e3b1165d077576/runtime/test/wasm_test/api_version_0_0_5/string_to_number.wasm -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_5/test_padding.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphprotocol/graph-node/94fb3f2825a66dd54c628c2866e3b1165d077576/runtime/test/wasm_test/api_version_0_0_5/test_padding.wasm -------------------------------------------------------------------------------- /runtime/test/wasm_test/api_version_0_0_5/yaml_parsing.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphprotocol/graph-node/94fb3f2825a66dd54c628c2866e3b1165d077576/runtime/test/wasm_test/api_version_0_0_5/yaml_parsing.wasm -------------------------------------------------------------------------------- /runtime/wasm/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "graph-runtime-wasm" 3 | version.workspace = true 4 | edition.workspace = true 5 | 6 | [dependencies] 7 | async-trait = "0.1.50" 8 | ethabi = "17.2" 9 | hex = "0.4.3" 10 | graph = { path = "../../graph" } 11 | bs58 = "0.4.0" 12 | graph-runtime-derive = { path = "../derive" } 13 | semver = "1.0.23" 14 | anyhow = "1.0" 15 | never = "0.1" 16 | 17 | wasmtime.workspace = true 18 | wasm-instrument = { version = "0.2.0", features = ["std", "sign_ext"] } 19 | 20 | # AssemblyScript uses sign extensions 21 | parity-wasm = { version = "0.45", features = ["std", "sign_ext"] } 22 | 23 | serde_yaml = { workspace = true } 24 | -------------------------------------------------------------------------------- /runtime/wasm/src/asc_abi/mod.rs: -------------------------------------------------------------------------------- 1 | // This unecessary nesting of the module should be resolved by further refactoring. 2 | pub mod class; 3 | pub mod v0_0_4; 4 | pub mod v0_0_5; 5 | -------------------------------------------------------------------------------- /runtime/wasm/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod asc_abi; 2 | 3 | mod host; 4 | pub mod to_from; 5 | 6 | /// Public interface of the crate, receives triggers to be processed. 7 | 8 | /// Pre-processes modules and manages their threads. Serves as an interface from `host` to `module`. 9 | pub mod mapping; 10 | 11 | /// WASM module instance. 12 | pub mod module; 13 | 14 | /// Runtime-agnostic implementation of exports to WASM. 15 | pub mod host_exports; 16 | 17 | pub mod error; 18 | mod gas_rules; 19 | 20 | pub use host::RuntimeHostBuilder; 21 | pub use host_exports::HostExports; 22 | pub use mapping::{MappingContext, ValidModule}; 23 | pub use module::{ExperimentalFeatures, WasmInstance}; 24 | -------------------------------------------------------------------------------- /rust-toolchain.toml: -------------------------------------------------------------------------------- 1 | [toolchain] 2 | channel = "stable" 3 | profile = "default" 4 | components = [ "rustfmt" ] 5 | -------------------------------------------------------------------------------- /server/graphman/src/entities/block_ptr.rs: -------------------------------------------------------------------------------- 1 | use async_graphql::SimpleObject; 2 | 3 | use crate::entities::BlockHash; 4 | use crate::entities::BlockNumber; 5 | 6 | #[derive(Clone, Debug, SimpleObject)] 7 | pub struct BlockPtr { 8 | pub hash: BlockHash, 9 | pub number: BlockNumber, 10 | } 11 | 12 | impl From for BlockPtr { 13 | fn from(block_ptr: graph::blockchain::BlockPtr) -> Self { 14 | Self { 15 | hash: block_ptr.hash.into(), 16 | number: block_ptr.number.into(), 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /server/graphman/src/entities/command_kind.rs: -------------------------------------------------------------------------------- 1 | use async_graphql::Enum; 2 | 3 | /// Types of commands that run in the background. 4 | #[derive(Clone, Copy, Debug, PartialEq, Eq, Enum)] 5 | #[graphql(remote = "graphman_store::CommandKind")] 6 | pub enum CommandKind { 7 | RestartDeployment, 8 | } 9 | -------------------------------------------------------------------------------- /server/graphman/src/entities/empty_response.rs: -------------------------------------------------------------------------------- 1 | use async_graphql::SimpleObject; 2 | 3 | /// This type is used when an operation has been successful, 4 | /// but there is no output that can be returned. 5 | #[derive(Clone, Debug, SimpleObject)] 6 | pub struct EmptyResponse { 7 | pub success: bool, 8 | } 9 | 10 | impl EmptyResponse { 11 | /// Returns a successful response. 12 | pub fn new() -> Self { 13 | Self { success: true } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /server/graphman/src/entities/subgraph_health.rs: -------------------------------------------------------------------------------- 1 | use async_graphql::Enum; 2 | 3 | #[derive(Clone, Copy, Debug, PartialEq, Eq, Enum)] 4 | #[graphql(remote = "graph::data::subgraph::schema::SubgraphHealth")] 5 | pub enum SubgraphHealth { 6 | /// Syncing without errors. 7 | Healthy, 8 | 9 | /// Syncing but has errors. 10 | Unhealthy, 11 | 12 | /// No longer syncing due to a fatal error. 13 | Failed, 14 | } 15 | -------------------------------------------------------------------------------- /server/graphman/src/entities/warning_response.rs: -------------------------------------------------------------------------------- 1 | use async_graphql::SimpleObject; 2 | 3 | #[derive(Clone, Debug, SimpleObject)] 4 | pub struct CompletedWithWarnings { 5 | pub success: bool, 6 | pub warnings: Vec, 7 | } 8 | 9 | impl CompletedWithWarnings { 10 | pub fn new(warnings: Vec) -> Self { 11 | Self { 12 | success: true, 13 | warnings, 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /server/graphman/src/error.rs: -------------------------------------------------------------------------------- 1 | use thiserror::Error; 2 | 3 | #[derive(Debug, Error)] 4 | pub enum GraphmanServerError { 5 | #[error("invalid auth token: {0:#}")] 6 | InvalidAuthToken(#[source] anyhow::Error), 7 | 8 | #[error("I/O error: {0:#}")] 9 | Io(#[source] anyhow::Error), 10 | } 11 | -------------------------------------------------------------------------------- /server/graphman/src/handlers/mod.rs: -------------------------------------------------------------------------------- 1 | mod graphql; 2 | mod state; 3 | 4 | pub use self::graphql::graphql_playground_handler; 5 | pub use self::graphql::graphql_request_handler; 6 | pub use self::state::AppState; 7 | -------------------------------------------------------------------------------- /server/graphman/src/handlers/state.rs: -------------------------------------------------------------------------------- 1 | use crate::auth::AuthToken; 2 | 3 | /// The state that is shared between all request handlers. 4 | pub struct AppState { 5 | pub auth_token: AuthToken, 6 | } 7 | -------------------------------------------------------------------------------- /server/graphman/src/lib.rs: -------------------------------------------------------------------------------- 1 | mod auth; 2 | mod entities; 3 | mod error; 4 | mod handlers; 5 | mod resolvers; 6 | mod schema; 7 | mod server; 8 | 9 | pub use self::error::GraphmanServerError; 10 | pub use self::server::GraphmanServer; 11 | pub use self::server::GraphmanServerConfig; 12 | pub use self::server::GraphmanServerManager; 13 | -------------------------------------------------------------------------------- /server/graphman/src/resolvers/deployment_mutation/unassign.rs: -------------------------------------------------------------------------------- 1 | use async_graphql::Result; 2 | use graphman::commands::deployment::unassign::load_assigned_deployment; 3 | use graphman::commands::deployment::unassign::unassign_deployment; 4 | use graphman::deployment::DeploymentSelector; 5 | 6 | use crate::resolvers::context::GraphmanContext; 7 | 8 | pub fn run(ctx: &GraphmanContext, deployment: &DeploymentSelector) -> Result<()> { 9 | let deployment = load_assigned_deployment(ctx.primary_pool.clone(), deployment)?; 10 | unassign_deployment( 11 | ctx.primary_pool.clone(), 12 | ctx.notification_sender.clone(), 13 | deployment, 14 | )?; 15 | 16 | Ok(()) 17 | } 18 | -------------------------------------------------------------------------------- /server/graphman/src/resolvers/mod.rs: -------------------------------------------------------------------------------- 1 | mod context; 2 | mod deployment_mutation; 3 | mod deployment_query; 4 | mod execution_query; 5 | mod mutation_root; 6 | mod query_root; 7 | 8 | pub use self::deployment_mutation::DeploymentMutation; 9 | pub use self::deployment_query::DeploymentQuery; 10 | pub use self::execution_query::ExecutionQuery; 11 | pub use self::mutation_root::MutationRoot; 12 | pub use self::query_root::QueryRoot; 13 | -------------------------------------------------------------------------------- /server/graphman/src/resolvers/mutation_root.rs: -------------------------------------------------------------------------------- 1 | use async_graphql::Object; 2 | 3 | use crate::resolvers::DeploymentMutation; 4 | 5 | /// Note: Converted to GraphQL schema as `mutation`. 6 | pub struct MutationRoot; 7 | 8 | #[Object] 9 | impl MutationRoot { 10 | /// Mutations related to one or multiple deployments. 11 | pub async fn deployment(&self) -> DeploymentMutation { 12 | DeploymentMutation {} 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /server/graphman/src/resolvers/query_root.rs: -------------------------------------------------------------------------------- 1 | use async_graphql::Object; 2 | 3 | use crate::resolvers::DeploymentQuery; 4 | use crate::resolvers::ExecutionQuery; 5 | 6 | /// Note: Converted to GraphQL schema as `query`. 7 | pub struct QueryRoot; 8 | 9 | #[Object] 10 | impl QueryRoot { 11 | /// Queries related to one or multiple deployments. 12 | pub async fn deployment(&self) -> DeploymentQuery { 13 | DeploymentQuery {} 14 | } 15 | 16 | /// Queries related to command executions. 17 | pub async fn execution(&self) -> ExecutionQuery { 18 | ExecutionQuery {} 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /server/graphman/src/schema.rs: -------------------------------------------------------------------------------- 1 | use async_graphql::EmptySubscription; 2 | use async_graphql::Schema; 3 | 4 | use crate::resolvers::MutationRoot; 5 | use crate::resolvers::QueryRoot; 6 | 7 | pub type GraphmanSchema = Schema; 8 | -------------------------------------------------------------------------------- /server/http/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "graph-server-http" 3 | version.workspace = true 4 | edition.workspace = true 5 | 6 | [dependencies] 7 | serde = { workspace = true } 8 | graph = { path = "../../graph" } 9 | graph-graphql = { path = "../../graphql" } 10 | 11 | [dev-dependencies] 12 | graph-core = { path = "../../core" } 13 | -------------------------------------------------------------------------------- /server/http/src/lib.rs: -------------------------------------------------------------------------------- 1 | extern crate graph; 2 | extern crate graph_graphql; 3 | extern crate serde; 4 | 5 | mod request; 6 | mod server; 7 | mod service; 8 | 9 | pub use self::server::GraphQLServer; 10 | pub use self::service::GraphQLService; 11 | 12 | pub mod test_utils; 13 | -------------------------------------------------------------------------------- /server/index-node/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "graph-server-index-node" 3 | version.workspace = true 4 | edition.workspace = true 5 | 6 | [dependencies] 7 | blake3 = "1.8" 8 | graph = { path = "../../graph" } 9 | graph-graphql = { path = "../../graphql" } 10 | graph-chain-ethereum = { path = "../../chain/ethereum" } 11 | graph-chain-near = { path = "../../chain/near" } 12 | graph-chain-substreams = { path = "../../chain/substreams" } 13 | git-testament = "0.2.6" 14 | -------------------------------------------------------------------------------- /server/index-node/src/lib.rs: -------------------------------------------------------------------------------- 1 | mod auth; 2 | mod explorer; 3 | mod resolver; 4 | mod schema; 5 | mod server; 6 | mod service; 7 | 8 | pub use self::auth::PoiProtection; 9 | pub use self::server::IndexNodeServer; 10 | pub use self::service::IndexNodeService; 11 | 12 | #[cfg(debug_assertions)] 13 | pub use self::resolver::IndexNodeResolver; 14 | -------------------------------------------------------------------------------- /server/index-node/src/schema.rs: -------------------------------------------------------------------------------- 1 | use graph::{ 2 | prelude::*, 3 | schema::{ApiSchema, Schema}, 4 | }; 5 | 6 | lazy_static! { 7 | pub static ref SCHEMA: Arc = { 8 | let raw_schema = include_str!("./schema.graphql"); 9 | let document = s::parse_schema(raw_schema).unwrap(); 10 | Arc::new( 11 | ApiSchema::from_graphql_schema( 12 | Schema::new(DeploymentHash::new("indexnode").unwrap(), document).unwrap(), 13 | ) 14 | .unwrap(), 15 | ) 16 | }; 17 | } 18 | 19 | #[test] 20 | fn schema_parses() { 21 | let _ = &*SCHEMA; 22 | } 23 | -------------------------------------------------------------------------------- /server/json-rpc/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "graph-server-json-rpc" 3 | version.workspace = true 4 | edition.workspace = true 5 | 6 | [dependencies] 7 | graph = { path = "../../graph" } 8 | jsonrpsee = { version = "0.15.1", features = ["http-server"] } 9 | serde = { workspace = true } 10 | -------------------------------------------------------------------------------- /server/metrics/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "graph-server-metrics" 3 | version.workspace = true 4 | edition.workspace = true 5 | 6 | [dependencies] 7 | graph = { path = "../../graph" } 8 | -------------------------------------------------------------------------------- /store/postgres/migrations/2018-07-10-061642_create_entities_table/down.sql: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * DROP TABLE 3 | **************************************************************/ 4 | DROP TABLE entities; 5 | -------------------------------------------------------------------------------- /store/postgres/migrations/2018-07-10-061659_create_history_tables/down.sql: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * DROP TABLES 3 | **************************************************************/ 4 | DROP TABLE entity_history; 5 | DROP TABLE event_meta_data; 6 | -------------------------------------------------------------------------------- /store/postgres/migrations/2018-07-10-062730_create_revert_procedures/down.sql: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * DROP FUNCTIONS 3 | **************************************************************/ 4 | DROP FUNCTION jsonb_diff_val(JSONB, JSONB); 5 | DROP FUNCTION revert_row_event(INTEGER, INTEGER); 6 | DROP FUNCTION revert_transaction(INTEGER); 7 | DROP FUNCTION revert_transaction_group(INTEGER[]); 8 | DROP FUNCTION revert_block(VARCHAR); 9 | -------------------------------------------------------------------------------- /store/postgres/migrations/2018-08-22-130000_create_blockchain_tables/down.sql: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * DROP TABLES 3 | **************************************************************/ 4 | DROP TABLE ethereum_blocks; 5 | DROP TABLE ethereum_networks; 6 | -------------------------------------------------------------------------------- /store/postgres/migrations/2018-08-22-140000_create_chain_head_update_procedure/down.sql: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * DROP BLOCK INGESTOR FUNCTIONS 3 | **************************************************************/ 4 | 5 | DROP FUNCTION attempt_chain_head_update(VARCHAR, BIGINT); 6 | -------------------------------------------------------------------------------- /store/postgres/migrations/2018-08-29-120000_create_subgraphs_table/down.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE subgraphs; 2 | -------------------------------------------------------------------------------- /store/postgres/migrations/2018-08-29-120000_create_subgraphs_table/up.sql: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * CREATE TABLE 3 | **************************************************************/ 4 | -- Stores list of immutable subgraphs 5 | CREATE TABLE IF NOT EXISTS subgraphs ( 6 | id VARCHAR PRIMARY KEY, 7 | network_name VARCHAR NOT NULL, 8 | latest_block_hash VARCHAR NOT NULL, 9 | latest_block_number BIGINT NOT NULL 10 | ); 11 | -------------------------------------------------------------------------------- /store/postgres/migrations/2018-09-07-220000_create_ancestor_lookup_procedure/down.sql: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * DROP ANCESTOR LOOKUP FUNCTION 3 | **************************************************************/ 4 | DROP FUNCTION lookup_ancestor_block(VARCHAR, BIGINT); 5 | -------------------------------------------------------------------------------- /store/postgres/migrations/2018-09-18-180000_add_ethereum_network_identifiers/down.sql: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * REMOVE etherum_networks COLUMNS 3 | **************************************************************/ 4 | 5 | ALTER TABLE ethereum_networks 6 | DROP COLUMN net_version, 7 | DROP COLUMN genesis_block_hash; 8 | -------------------------------------------------------------------------------- /store/postgres/migrations/2018-09-18-180000_add_ethereum_network_identifiers/up.sql: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * ADD etherum_networks COLUMNS 3 | **************************************************************/ 4 | 5 | ALTER TABLE ethereum_networks 6 | ADD COLUMN net_version VARCHAR, 7 | ADD COLUMN genesis_block_hash VARCHAR, 8 | ADD CHECK ((net_version IS NULL) = (genesis_block_hash IS NULL)); 9 | -------------------------------------------------------------------------------- /store/postgres/migrations/2018-12-02-114100_create_subgraph_deployments_table/down.sql: -------------------------------------------------------------------------------- 1 | DROP TRIGGER after_deployment_insert ON subgraph_deployments; 2 | DROP TRIGGER after_deployment_update ON subgraph_deployments; 3 | DROP TRIGGER after_deployment_delete ON subgraph_deployments; 4 | 5 | DROP FUNCTION deployment_insert(); 6 | DROP FUNCTION deployment_update(); 7 | DROP FUNCTION deployment_delete(); 8 | 9 | DROP TABLE subgraph_deployments; 10 | -------------------------------------------------------------------------------- /store/postgres/migrations/2018-12-03-150000_add_subgraph_cost/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE subgraph_deployments DROP COLUMN cost; 2 | -------------------------------------------------------------------------------- /store/postgres/migrations/2018-12-03-150000_add_subgraph_cost/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE subgraph_deployments ADD COLUMN cost DECIMAL(12, 4) NOT NULL CHECK (cost >= 0) DEFAULT 1; 2 | -------------------------------------------------------------------------------- /store/postgres/migrations/2018-12-21-003727_create_attribute_indexing_procedure/down.sql: -------------------------------------------------------------------------------- 1 | -- DROP ATTRIBUTE INDEXING FUNCTION 2 | DROP FUNCTION build_attribute_index( 3 | subgraph_id Text, 4 | index_name Text, 5 | index_type Text, 6 | index_operator Text, 7 | attribute_name Text, 8 | entity_name Text 9 | ); -------------------------------------------------------------------------------- /store/postgres/migrations/2019-02-01-045927_add_entities_indexes/down.sql: -------------------------------------------------------------------------------- 1 | -- no work necessary on a down migration; we can live happily 2 | -- with either version of the pk index, but the up one provides 3 | -- better performance 4 | -------------------------------------------------------------------------------- /store/postgres/migrations/2019-02-01-045927_add_entities_indexes/up.sql: -------------------------------------------------------------------------------- 1 | -- Change the order of columns in the pk index for entities 2 | ALTER TABLE entities DROP CONSTRAINT entities_pkey; 3 | ALTER TABLE entities ADD CONSTRAINT 4 | entities_pkey primary key (subgraph, entity, id); 5 | -------------------------------------------------------------------------------- /store/postgres/migrations/2019-02-25-182843_add_pg_stat_statements/down.sql: -------------------------------------------------------------------------------- 1 | DROP EXTENSION IF EXISTS pg_stat_statements; 2 | -------------------------------------------------------------------------------- /store/postgres/migrations/2019-02-25-182843_add_pg_stat_statements/up.sql: -------------------------------------------------------------------------------- 1 | -- The extension requires that the pg_stat_statements DSO is loaded 2 | -- via shared_preload_libraries. Luckily, this is only needed when 3 | -- trying to read from the pg_stat_statements view. Extension 4 | -- creation will succeed either way 5 | CREATE EXTENSION IF NOT EXISTS pg_stat_statements; 6 | -------------------------------------------------------------------------------- /store/postgres/migrations/2019-02-26-182914_remove_unassigned_deployment_indexes_procedure/down.sql: -------------------------------------------------------------------------------- 1 | DROP FUNCTION remove_unassigned_deployment_indexes(); 2 | -------------------------------------------------------------------------------- /store/postgres/migrations/2019-02-26-183156_cleanup_unassigned_deployment_indexes/down.sql: -------------------------------------------------------------------------------- 1 | -- To rebuild a set of indexes simply redeploy the subgraph 2 | -------------------------------------------------------------------------------- /store/postgres/migrations/2019-02-26-183156_cleanup_unassigned_deployment_indexes/up.sql: -------------------------------------------------------------------------------- 1 | -- Remove subgraph attribute indexes for subgraphs without a deployment assignment 2 | SELECT remove_unassigned_deployment_indexes(); 3 | -------------------------------------------------------------------------------- /store/postgres/migrations/2019-02-27-035443_create_large_notifications/down.sql: -------------------------------------------------------------------------------- 1 | drop table large_notifications; 2 | -------------------------------------------------------------------------------- /store/postgres/migrations/2019-02-27-035443_create_large_notifications/up.sql: -------------------------------------------------------------------------------- 1 | create unlogged table large_notifications ( 2 | id serial primary key, 3 | payload varchar not null, 4 | created_at timestamp default current_timestamp not null 5 | ); 6 | 7 | comment on table large_notifications is 8 | 'Table for notifications whose payload is too big to send directly'; 9 | -------------------------------------------------------------------------------- /store/postgres/migrations/2019-03-28-004319_drop_entities_id_indexes/down.sql: -------------------------------------------------------------------------------- 1 | -- This file should undo anything in `up.sql` -------------------------------------------------------------------------------- /store/postgres/migrations/2019-05-03-164052_store_entity_count/down.sql: -------------------------------------------------------------------------------- 1 | -- Remove entityCount from SubgraphDeployment 2 | update subgraphs.entities 3 | set data = data - 'entityCount' 4 | where entity='SubgraphDeployment'; 5 | -------------------------------------------------------------------------------- /store/postgres/migrations/2019-05-09-135900_create_subgraphs_entity_history_table/down.sql: -------------------------------------------------------------------------------- 1 | -- Delete the entity_history table for the subgraph of subgraphs. 2 | drop table subgraphs.entity_history; 3 | -------------------------------------------------------------------------------- /store/postgres/migrations/2019-05-09-135900_create_subgraphs_entity_history_table/up.sql: -------------------------------------------------------------------------------- 1 | -- Create an entity_history table for the subgraph of subgraphs. 2 | create table subgraphs.entity_history ( 3 | id serial primary key, 4 | event_id integer references event_meta_data(id) 5 | on update cascade 6 | on delete cascade, 7 | subgraph varchar not null, 8 | entity varchar not null, 9 | entity_id varchar not null, 10 | data_before jsonb, 11 | reversion bool not null default false, 12 | op_id int2 not null 13 | ); 14 | -------------------------------------------------------------------------------- /store/postgres/migrations/2019-05-09-232642_ens_names/down.sql: -------------------------------------------------------------------------------- 1 | drop table public.ens_names; 2 | -------------------------------------------------------------------------------- /store/postgres/migrations/2019-05-09-232642_ens_names/up.sql: -------------------------------------------------------------------------------- 1 | create table if not exists public.ens_names( 2 | hash varchar primary key, 3 | name varchar not null 4 | ); 5 | -------------------------------------------------------------------------------- /store/postgres/migrations/2019-05-14-200255_event_meta_data_source_index/down.sql: -------------------------------------------------------------------------------- 1 | drop index event_meta_data_source; 2 | -------------------------------------------------------------------------------- /store/postgres/migrations/2019-05-14-200255_event_meta_data_source_index/up.sql: -------------------------------------------------------------------------------- 1 | create index if not exists event_meta_data_source on event_meta_data(source); 2 | -------------------------------------------------------------------------------- /store/postgres/migrations/2019-05-15-215022_migrate_entities/down.sql: -------------------------------------------------------------------------------- 1 | delete from deployment_schemas 2 | where version='public'; 3 | 4 | drop function migrate_entities_tables(varchar, 5 | deployment_schema_version, 6 | varchar); 7 | drop function migrate_entities_data(varchar, 8 | deployment_schema_version, 9 | varchar); 10 | 11 | alter table deployment_schemas 12 | drop column version, 13 | drop column migrating, 14 | drop column state; 15 | 16 | drop type deployment_schema_version; 17 | drop type deployment_schema_state; 18 | -------------------------------------------------------------------------------- /store/postgres/migrations/2019-06-26-164405_index_dynamic_ethereum_contract_data_source_deployment/down.sql: -------------------------------------------------------------------------------- 1 | drop index if exists 2 | subgraphs.manual_dynamic_ethereum_contract_data_source_deployment; 3 | -------------------------------------------------------------------------------- /store/postgres/migrations/2019-06-26-164405_index_dynamic_ethereum_contract_data_source_deployment/up.sql: -------------------------------------------------------------------------------- 1 | create index if not exists 2 | manual_dynamic_ethereum_contract_data_source_deployment 3 | on subgraphs.entities(((data->'deployment'->>'data'))) 4 | where entity='DynamicEthereumContractDataSource'; 5 | -------------------------------------------------------------------------------- /store/postgres/migrations/2019-07-20-195916_remove_subgraph/down.sql: -------------------------------------------------------------------------------- 1 | drop function remove_public_deployments(); 2 | drop function remove_deployment_metadata(ids varchar[]); 3 | drop function list_deployment_entities(ids varchar[]); 4 | -------------------------------------------------------------------------------- /store/postgres/migrations/2019-09-02-230613_create_btree_extension/down.sql: -------------------------------------------------------------------------------- 1 | -- No good reason to drop the btree_gist extension again 2 | -------------------------------------------------------------------------------- /store/postgres/migrations/2019-09-02-230613_create_btree_extension/up.sql: -------------------------------------------------------------------------------- 1 | -- This requires superuser privileges 2 | create extension if not exists btree_gist; 3 | -------------------------------------------------------------------------------- /store/postgres/migrations/2019-10-01-173616_create_eth_call_cache/down.sql: -------------------------------------------------------------------------------- 1 | drop table eth_call_cache; 2 | drop table eth_call_meta; 3 | -------------------------------------------------------------------------------- /store/postgres/migrations/2019-10-01-173616_create_eth_call_cache/up.sql: -------------------------------------------------------------------------------- 1 | create table eth_call_cache ( 2 | id bytea primary key, 3 | return_value bytea not null, 4 | contract_address bytea not null, 5 | block_number integer not null 6 | ); 7 | 8 | create table eth_call_meta ( 9 | contract_address bytea primary key, 10 | accessed_at date not null 11 | ); 12 | -------------------------------------------------------------------------------- /store/postgres/migrations/2020-01-17-013633_remove_unused_procs/down.sql: -------------------------------------------------------------------------------- 1 | -- This file should undo anything in `up.sql` -------------------------------------------------------------------------------- /store/postgres/migrations/2020-01-24-065338_add_reduce_dim/down.sql: -------------------------------------------------------------------------------- 1 | drop function reduce_dim(anyarray); 2 | -------------------------------------------------------------------------------- /store/postgres/migrations/2020-01-24-065338_add_reduce_dim/up.sql: -------------------------------------------------------------------------------- 1 | -- From https://wiki.postgresql.org/wiki/Unnest_multidimensional_array 2 | CREATE OR REPLACE FUNCTION public.reduce_dim(anyarray) 3 | RETURNS SETOF anyarray AS 4 | $function$ 5 | DECLARE 6 | s $1%TYPE; 7 | BEGIN 8 | FOREACH s SLICE 1 IN ARRAY $1 LOOP 9 | RETURN NEXT s; 10 | END LOOP; 11 | RETURN; 12 | END; 13 | $function$ 14 | LANGUAGE plpgsql IMMUTABLE; 15 | -------------------------------------------------------------------------------- /store/postgres/migrations/2020-03-11-162100_add_data_source_context/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE subgraphs.dynamic_ethereum_contract_data_source DROP COLUMN context; 2 | -------------------------------------------------------------------------------- /store/postgres/migrations/2020-03-11-162100_add_data_source_context/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE subgraphs.dynamic_ethereum_contract_data_source ADD COLUMN context text; 2 | -------------------------------------------------------------------------------- /store/postgres/migrations/2020-03-25-170527_deployment_graft_base/down.sql: -------------------------------------------------------------------------------- 1 | alter table subgraphs.subgraph_deployment 2 | drop column graft_block_hash, 3 | drop column graft_block_number, 4 | drop column graft_base; 5 | -------------------------------------------------------------------------------- /store/postgres/migrations/2020-03-25-170527_deployment_graft_base/up.sql: -------------------------------------------------------------------------------- 1 | -- It would seem logical to add a foreign key constraint on graft_base to 2 | -- make sure the base subgraph sticks around. But once we have copied the base 3 | -- subgraph, the graft does not need the base subgraph anymore, and it is 4 | -- therefore perfectly fine if the base gets deleted; the graft_base is 5 | -- purely informational 6 | alter table subgraphs.subgraph_deployment 7 | add column graft_base text, 8 | add column graft_block_hash bytea, 9 | add column graft_block_number numeric; 10 | -------------------------------------------------------------------------------- /store/postgres/migrations/2020-04-04-002817_change_deployment_state/down.sql: -------------------------------------------------------------------------------- 1 | -- Since we are adding a value to an existing enum, and since the 'up' 2 | -- migration is idempotent, we don't worry about reverting that change 3 | -------------------------------------------------------------------------------- /store/postgres/migrations/2020-04-04-002817_change_deployment_state/up.sql: -------------------------------------------------------------------------------- 1 | alter type deployment_schema_state 2 | rename to deployment_schema_state_old; 3 | 4 | create type deployment_schema_state 5 | as enum('ready','tables','init'); 6 | 7 | alter table deployment_schemas 8 | alter column state drop default; 9 | 10 | alter table deployment_schemas 11 | alter column state type deployment_schema_state 12 | using state::text::deployment_schema_state; 13 | 14 | alter table deployment_schemas 15 | alter column state set default 'init'; 16 | 17 | drop type deployment_schema_state_old; 18 | -------------------------------------------------------------------------------- /store/postgres/migrations/2020-04-10-111111_add_deployment_errors/down.sql: -------------------------------------------------------------------------------- 1 | alter table subgraphs.subgraph_deployment drop column health; 2 | alter table subgraphs.subgraph_deployment drop column fatal_error; 3 | alter table subgraphs.subgraph_deployment drop column non_fatal_errors; 4 | drop type subgraph_health; 5 | drop table subgraph_error; 6 | -------------------------------------------------------------------------------- /store/postgres/migrations/2020-07-07-002933_add_deployment_reorg_counts/down.sql: -------------------------------------------------------------------------------- 1 | alter table subgraphs.subgraph_deployment 2 | drop column reorg_count, 3 | drop column current_reorg_depth, 4 | drop column max_reorg_depth; 5 | -------------------------------------------------------------------------------- /store/postgres/migrations/2020-07-07-002933_add_deployment_reorg_counts/up.sql: -------------------------------------------------------------------------------- 1 | alter table subgraphs.subgraph_deployment 2 | add column reorg_count int not null default 0, 3 | add column current_reorg_depth int not null default 0, 4 | add column max_reorg_depth int not null default 0; 5 | -------------------------------------------------------------------------------- /store/postgres/migrations/2020-07-31-162138_meta-views/down.sql: -------------------------------------------------------------------------------- 1 | drop schema if exists meta cascade; 2 | -------------------------------------------------------------------------------- /store/postgres/migrations/2020-10-31-150000_deterministic_errors/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE subgraphs.subgraph_error DROP COLUMN deterministic; 2 | -------------------------------------------------------------------------------- /store/postgres/migrations/2020-10-31-150000_deterministic_errors/up.sql: -------------------------------------------------------------------------------- 1 | -- add `deterministic` column to subgraph_error 2 | alter table 3 | subgraphs.subgraph_error 4 | add 5 | column deterministic boolean not null default false; 6 | -------------------------------------------------------------------------------- /store/postgres/migrations/2020-11-03-170839_subgraph_name_unique/down.sql: -------------------------------------------------------------------------------- 1 | alter table subgraphs.subgraph 2 | drop constraint subgraph_name_uq; 3 | -------------------------------------------------------------------------------- /store/postgres/migrations/2020-11-03-170839_subgraph_name_unique/up.sql: -------------------------------------------------------------------------------- 1 | -- Remove duplicate subgraphs; it should be impossible for 2 | -- subgraphs that have multiple entries to have any versions. 3 | -- The duplication happened because of a race condition in creating 4 | -- subgraphs, but the code checked that there was only one subgraph 5 | -- before deploying a version, and therefore failed 6 | delete from subgraphs.subgraph 7 | where name in (select name from subgraphs.subgraph 8 | group by name having count(*) > 1); 9 | 10 | alter table subgraphs.subgraph 11 | add constraint subgraph_name_uq unique(name); 12 | -------------------------------------------------------------------------------- /store/postgres/migrations/2020-11-10-100000_last_healthy_block/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE subgraphs.subgraph_error DROP COLUMN last_healthy_ethereum_block_hash; 2 | ALTER TABLE subgraphs.subgraph_error DROP COLUMN last_healthy_ethereum_block_number; 3 | -------------------------------------------------------------------------------- /store/postgres/migrations/2020-11-10-100000_last_healthy_block/up.sql: -------------------------------------------------------------------------------- 1 | alter table 2 | subgraphs.subgraph_deployment 3 | add 4 | column last_healthy_ethereum_block_hash bytea; 5 | 6 | alter table 7 | subgraphs.subgraph_deployment 8 | add 9 | column last_healthy_ethereum_block_number numeric; 10 | -------------------------------------------------------------------------------- /store/postgres/migrations/2020-12-11-142000_subgraph_manifest_features/down.sql: -------------------------------------------------------------------------------- 1 | alter table 2 | subgraphs.subgraph_manifest 3 | drop 4 | column features; 5 | -------------------------------------------------------------------------------- /store/postgres/migrations/2020-12-11-142000_subgraph_manifest_features/up.sql: -------------------------------------------------------------------------------- 1 | alter table 2 | subgraphs.subgraph_manifest 3 | add 4 | column features text[] NOT NULL DEFAULT '{}'; 5 | -------------------------------------------------------------------------------- /store/postgres/migrations/2020-12-12-000001_remove_migrationg_flag/down.sql: -------------------------------------------------------------------------------- 1 | alter table deployment_schemas 2 | add column migrating bool not null default false; 3 | -------------------------------------------------------------------------------- /store/postgres/migrations/2020-12-12-000001_remove_migrationg_flag/up.sql: -------------------------------------------------------------------------------- 1 | alter table deployment_schemas 2 | drop column migrating; 3 | -------------------------------------------------------------------------------- /store/postgres/migrations/2020-12-12-000002_add_shard_to_deployment_schemas/down.sql: -------------------------------------------------------------------------------- 1 | alter table deployment_schemas 2 | drop column shard; 3 | -------------------------------------------------------------------------------- /store/postgres/migrations/2020-12-12-000002_add_shard_to_deployment_schemas/up.sql: -------------------------------------------------------------------------------- 1 | alter table deployment_schemas 2 | add column shard text; 3 | update deployment_schemas 4 | set shard = 'primary'; 5 | alter table deployment_schemas 6 | alter column shard set not null; 7 | -------------------------------------------------------------------------------- /store/postgres/migrations/2020-12-12-000003_remove_deployment_schemas_state/down.sql: -------------------------------------------------------------------------------- 1 | create type deployment_schema_state 2 | as enum('ready','tables','init'); 3 | 4 | alter table deployment_schemas 5 | add column state deployment_schema_state not null default 'init'; 6 | -------------------------------------------------------------------------------- /store/postgres/migrations/2020-12-12-000003_remove_deployment_schemas_state/up.sql: -------------------------------------------------------------------------------- 1 | alter table deployment_schemas 2 | drop column state; 3 | 4 | drop type deployment_schema_state; 5 | -------------------------------------------------------------------------------- /store/postgres/migrations/2020-12-12-000005_remove_metadata_subgraph/down.sql: -------------------------------------------------------------------------------- 1 | insert into deployment_schemas(id, subgraph, name, version, shard) 2 | values(0, 'subgraphs', 'subgraphs', 'relational', 'primary'); 3 | -------------------------------------------------------------------------------- /store/postgres/migrations/2020-12-12-000005_remove_metadata_subgraph/up.sql: -------------------------------------------------------------------------------- 1 | delete from deployment_schemas 2 | where id = 0; 3 | -------------------------------------------------------------------------------- /store/postgres/migrations/2020-12-15-000000_remove_nested_templates/down.sql: -------------------------------------------------------------------------------- 1 | alter table 2 | subgraphs.dynamic_ethereum_contract_data_source 3 | add 4 | column templates; 5 | 6 | alter table 7 | subgraphs.ethereum_contract_data_source 8 | add 9 | column templates; 10 | -------------------------------------------------------------------------------- /store/postgres/migrations/2020-12-15-000000_remove_nested_templates/up.sql: -------------------------------------------------------------------------------- 1 | alter table 2 | subgraphs.dynamic_ethereum_contract_data_source 3 | drop 4 | column templates; 5 | 6 | alter table 7 | subgraphs.ethereum_contract_data_source 8 | drop 9 | column templates; 10 | -------------------------------------------------------------------------------- /store/postgres/migrations/2020-12-7-190800_subgraph_error_changes/down.sql: -------------------------------------------------------------------------------- 1 | alter table 2 | subgraphs.subgraph_error 3 | drop 4 | column created_at; 5 | -------------------------------------------------------------------------------- /store/postgres/migrations/2020-12-7-190800_subgraph_error_changes/up.sql: -------------------------------------------------------------------------------- 1 | alter table 2 | subgraphs.subgraph_error 3 | drop 4 | column block_number; 5 | 6 | alter table 7 | subgraphs.subgraph_error 8 | add 9 | column created_at timestamptz NOT NULL DEFAULT now(); 10 | -------------------------------------------------------------------------------- /store/postgres/migrations/2021-01-07-004939_create_unused_deployments/down.sql: -------------------------------------------------------------------------------- 1 | drop table unused_deployments; 2 | -------------------------------------------------------------------------------- /store/postgres/migrations/2021-01-07-004939_create_unused_deployments/up.sql: -------------------------------------------------------------------------------- 1 | create table unused_deployments ( 2 | id text primary key, 3 | unused_at timestamptz not null default now(), 4 | removed_at timestamptz, 5 | 6 | subgraphs text[], 7 | namespace text not null, 8 | shard text not null, 9 | 10 | entity_count int4 not null default 0, 11 | latest_ethereum_block_hash bytea, 12 | latest_ethereum_block_number int4, 13 | failed bool not null default false, 14 | synced bool not null default false 15 | ); 16 | -------------------------------------------------------------------------------- /store/postgres/migrations/2021-01-14-175654_add_network_to_deployment_schemas/down.sql: -------------------------------------------------------------------------------- 1 | alter table deployment_schemas 2 | drop column network; 3 | -------------------------------------------------------------------------------- /store/postgres/migrations/2021-01-14-175654_add_network_to_deployment_schemas/up.sql: -------------------------------------------------------------------------------- 1 | alter table deployment_schemas 2 | add column network text references ethereum_networks(name); 3 | 4 | update deployment_schemas ds 5 | set network = d.network 6 | from subgraphs.subgraph_deployment_detail d 7 | where d.id = ds.subgraph; 8 | -------------------------------------------------------------------------------- /store/postgres/migrations/2021-01-14-193022_deployment_schemas_network_not_null/down.sql: -------------------------------------------------------------------------------- 1 | alter table deployment_schemas 2 | alter column network drop not null; 3 | -------------------------------------------------------------------------------- /store/postgres/migrations/2021-01-14-193022_deployment_schemas_network_not_null/up.sql: -------------------------------------------------------------------------------- 1 | alter table deployment_schemas 2 | alter column network set not null; 3 | -------------------------------------------------------------------------------- /store/postgres/migrations/2021-01-15-013524_drop_deployment_detail/up.sql: -------------------------------------------------------------------------------- 1 | drop view subgraphs.subgraph_deployment_detail; 2 | -------------------------------------------------------------------------------- /store/postgres/migrations/2021-01-19-033749_add_chains/down.sql: -------------------------------------------------------------------------------- 1 | drop table chains; 2 | 3 | alter table deployment_schemas 4 | drop constraint deployment_schemas_network_fkey; 5 | 6 | alter table deployment_schemas 7 | add constraint deployment_schemas_network_fkey 8 | foreign key (network) references ethereum_networks(name); 9 | -------------------------------------------------------------------------------- /store/postgres/migrations/2021-01-26-044443_drop_attempt_chain_head_update/up.sql: -------------------------------------------------------------------------------- 1 | drop function attempt_chain_head_update(varchar, bigint); 2 | -------------------------------------------------------------------------------- /store/postgres/migrations/2021-01-26-172953_drop_lookup_ancestor_block/up.sql: -------------------------------------------------------------------------------- 1 | drop function lookup_ancestor_block(varchar, bigint); 2 | -------------------------------------------------------------------------------- /store/postgres/migrations/2021-01-26-173710_add_chains_namespace/down.sql: -------------------------------------------------------------------------------- 1 | alter table chains 2 | drop column namespace; 3 | alter table ethereum_networks 4 | drop column namespace; 5 | -------------------------------------------------------------------------------- /store/postgres/migrations/2021-01-26-173710_add_chains_namespace/up.sql: -------------------------------------------------------------------------------- 1 | alter table chains 2 | add column namespace text not null 3 | default 'chain' || currval('chains_id_seq'); 4 | -- all chain data so far lives in shared tables in 'public' 5 | update chains set namespace = 'public'; 6 | 7 | alter table ethereum_networks 8 | add column namespace text; 9 | update ethereum_networks set namespace = 'public'; 10 | alter table ethereum_networks 11 | alter column namespace set not null; 12 | -------------------------------------------------------------------------------- /store/postgres/migrations/2021-01-26-204036_ethereum_networks_net_ident_not_null/down.sql: -------------------------------------------------------------------------------- 1 | alter table chains 2 | alter column net_version drop not null, 3 | alter column genesis_block_hash drop not null; 4 | 5 | alter table ethereum_networks 6 | alter column net_version drop not null, 7 | alter column genesis_block_hash drop not null; 8 | -------------------------------------------------------------------------------- /store/postgres/migrations/2021-01-26-204036_ethereum_networks_net_ident_not_null/up.sql: -------------------------------------------------------------------------------- 1 | alter table chains 2 | alter column net_version set not null, 3 | alter column genesis_block_hash set not null; 4 | 5 | alter table ethereum_networks 6 | alter column net_version set not null, 7 | alter column genesis_block_hash set not null; 8 | -------------------------------------------------------------------------------- /store/postgres/migrations/2021-02-17-205502_simplify_metadata/down.sql: -------------------------------------------------------------------------------- 1 | do $$ 2 | begin 3 | raise 'This migration is irreversible'; 4 | end 5 | $$; 6 | -------------------------------------------------------------------------------- /store/postgres/migrations/2021-02-18-000721_dds_embed_source/down.sql: -------------------------------------------------------------------------------- 1 | alter table subgraphs.dynamic_ethereum_contract_data_source 2 | drop column address, 3 | drop column abi, 4 | drop column start_block; 5 | 6 | drop index subgraphs.dynamic_ethereum_contract_data_source_address; 7 | -------------------------------------------------------------------------------- /store/postgres/migrations/2021-02-18-000721_dds_embed_source/up.sql: -------------------------------------------------------------------------------- 1 | alter table subgraphs.dynamic_ethereum_contract_data_source 2 | add column address bytea, 3 | add column abi text, 4 | add column start_block int; 5 | 6 | -- We will use this index in a later migration to quickly identify 7 | -- dds whose ethereum_contract_source has not been copied into the table 8 | -- yet 9 | create index dynamic_ethereum_contract_data_source_address on 10 | subgraphs.dynamic_ethereum_contract_data_source(address); 11 | -------------------------------------------------------------------------------- /store/postgres/migrations/2021-02-18-171423_dds_remove_ethereum_contract_source/down.sql: -------------------------------------------------------------------------------- 1 | do $$ 2 | begin 3 | raise 'This migration is irreversible'; 4 | end 5 | $$; 6 | -------------------------------------------------------------------------------- /store/postgres/migrations/2021-02-24-051050_dds_remove_unused_columns/down.sql: -------------------------------------------------------------------------------- 1 | begin 2 | raise 'This migration is irreversible'; 3 | end 4 | $$; 5 | -------------------------------------------------------------------------------- /store/postgres/migrations/2021-02-24-051050_dds_remove_unused_columns/up.sql: -------------------------------------------------------------------------------- 1 | alter table subgraphs.dynamic_ethereum_contract_data_source 2 | drop column kind, 3 | drop column network; 4 | -------------------------------------------------------------------------------- /store/postgres/migrations/2021-02-25-233156_dds_remove_id_block_range/down.sql: -------------------------------------------------------------------------------- 1 | do $$ 2 | begin 3 | raise 'This migration is irreversible'; 4 | end 5 | $$; 6 | -------------------------------------------------------------------------------- /store/postgres/migrations/2021-02-25-233156_dds_remove_id_block_range/up.sql: -------------------------------------------------------------------------------- 1 | alter table subgraphs.dynamic_ethereum_contract_data_source 2 | drop column id, 3 | drop column block_range; 4 | -------------------------------------------------------------------------------- /store/postgres/migrations/2021-03-11-010830_fdw/down.sql: -------------------------------------------------------------------------------- 1 | drop extension postgres_fdw; 2 | -------------------------------------------------------------------------------- /store/postgres/migrations/2021-03-11-010830_fdw/up.sql: -------------------------------------------------------------------------------- 1 | create extension if not exists postgres_fdw; 2 | -------------------------------------------------------------------------------- /store/postgres/migrations/2021-03-11-231340_subgraph_deployment_changes/down.sql: -------------------------------------------------------------------------------- 1 | do $$ 2 | begin 3 | raise 'This migration is irreversible'; 4 | end 5 | $$; 6 | -------------------------------------------------------------------------------- /store/postgres/migrations/2021-03-11-231340_subgraph_deployment_changes/up.sql: -------------------------------------------------------------------------------- 1 | alter table subgraphs.subgraph_deployment 2 | drop column block_range; 3 | alter table subgraphs.subgraph_deployment 4 | rename column id to deployment; 5 | alter table subgraphs.subgraph_deployment 6 | add column id int; 7 | -------------------------------------------------------------------------------- /store/postgres/migrations/2021-03-12-014815_subgraph_deployment_pkey/down.sql: -------------------------------------------------------------------------------- 1 | do $$ 2 | begin 3 | raise 'This migration is irreversible'; 4 | end 5 | $$; 6 | -------------------------------------------------------------------------------- /store/postgres/migrations/2021-03-12-014815_subgraph_deployment_pkey/up.sql: -------------------------------------------------------------------------------- 1 | update subgraphs.subgraph_deployment d 2 | set id = ds.id 3 | from deployment_schemas ds 4 | where ds.subgraph = d.deployment 5 | and d.id is null; 6 | 7 | alter table subgraphs.subgraph_deployment 8 | drop constraint subgraph_deployment_pkey; 9 | 10 | alter table subgraphs.subgraph_deployment 11 | add primary key(id); 12 | 13 | alter table subgraphs.subgraph_deployment 14 | drop column vid; 15 | -------------------------------------------------------------------------------- /store/postgres/migrations/2021-03-12-070453_add_copy_state/down.sql: -------------------------------------------------------------------------------- 1 | drop table subgraphs.copy_table_state; 2 | drop table subgraphs.copy_state; 3 | drop table active_copies; 4 | -------------------------------------------------------------------------------- /store/postgres/migrations/2021-03-16-001809_assignment_deployment/down.sql: -------------------------------------------------------------------------------- 1 | do $$ 2 | begin 3 | raise 'This migration is irreversible'; 4 | end 5 | $$; 6 | -------------------------------------------------------------------------------- /store/postgres/migrations/2021-03-16-001809_assignment_deployment/up.sql: -------------------------------------------------------------------------------- 1 | alter table subgraphs.subgraph_deployment_assignment 2 | add column new_id int; 3 | 4 | update subgraphs.subgraph_deployment_assignment a 5 | set new_id = ds.id 6 | from deployment_schemas ds 7 | where ds.subgraph = a.id; 8 | 9 | alter table subgraphs.subgraph_deployment_assignment 10 | drop column id, 11 | drop column vid, 12 | drop column block_range, 13 | drop column cost; 14 | 15 | alter table subgraphs.subgraph_deployment_assignment 16 | rename column new_id to id; 17 | 18 | alter table subgraphs.subgraph_deployment_assignment 19 | add primary key(id); 20 | -------------------------------------------------------------------------------- /store/postgres/migrations/2021-03-16-165131_subgraph_manifest/down.sql: -------------------------------------------------------------------------------- 1 | do $$ 2 | begin 3 | raise 'This migration is irreversible'; 4 | end 5 | $$; 6 | -------------------------------------------------------------------------------- /store/postgres/migrations/2021-03-19-161012_unused_deployments_pk/down.sql: -------------------------------------------------------------------------------- 1 | do $$ 2 | begin 3 | raise 'This migration is irreversible'; 4 | end 5 | $$; 6 | -------------------------------------------------------------------------------- /store/postgres/migrations/2021-03-19-161012_unused_deployments_pk/up.sql: -------------------------------------------------------------------------------- 1 | alter table unused_deployments 2 | add column new_id int; 3 | 4 | -- Recover the deployment_schemas.id from existing unused_deployments 5 | -- entries 6 | update unused_deployments 7 | set new_id = replace(namespace, 'sgd', '')::int; 8 | 9 | alter table unused_deployments 10 | rename column id to deployment; 11 | 12 | alter table unused_deployments 13 | rename column new_id to id; 14 | 15 | alter table unused_deployments 16 | drop constraint unused_deployments_pkey; 17 | 18 | alter table unused_deployments 19 | add primary key(id); 20 | -------------------------------------------------------------------------------- /store/postgres/migrations/2021-03-20-001347_deployment_schemas_active/down.sql: -------------------------------------------------------------------------------- 1 | -- This file should undo anything in `up.sql` -------------------------------------------------------------------------------- /store/postgres/migrations/2021-03-20-001347_deployment_schemas_active/up.sql: -------------------------------------------------------------------------------- 1 | alter table deployment_schemas 2 | add column active bool; 3 | 4 | update deployment_schemas 5 | set active = true; 6 | 7 | alter table deployment_schemas 8 | alter column active set not null; 9 | 10 | -- we only allow one active entry per IPFS hash 11 | create unique index deployment_schemas_deployment_active 12 | on deployment_schemas(subgraph) where active; 13 | -------------------------------------------------------------------------------- /store/postgres/migrations/2021-03-24-220541_deployment_schemas_deployment_shard/down.sql: -------------------------------------------------------------------------------- 1 | drop constraint deployment_schemas_subgraph_shard_uq; 2 | 3 | create unique index deployment_schemas_subgraph_key 4 | on deployment_schemas(subgraph); 5 | -------------------------------------------------------------------------------- /store/postgres/migrations/2021-03-24-220541_deployment_schemas_deployment_shard/up.sql: -------------------------------------------------------------------------------- 1 | alter table deployment_schemas 2 | drop constraint deployment_schemas_subgraph_key; 3 | 4 | create unique index deployment_schemas_subgraph_shard_uq 5 | on deployment_schemas(subgraph, shard); 6 | -------------------------------------------------------------------------------- /store/postgres/migrations/2021-05-20-130220_graph_node_version/down.sql: -------------------------------------------------------------------------------- 1 | alter table subgraphs.subgraph_manifest 2 | drop constraint graph_node_versions_fk, 3 | drop column graph_node_version_id; 4 | 5 | drop table if exists subgraphs.graph_node_versions; 6 | -------------------------------------------------------------------------------- /store/postgres/migrations/2021-05-21-165219_add_created_at_columns_for_deployment_schemas/down.sql: -------------------------------------------------------------------------------- 1 | alter table public.deployment_schemas 2 | drop column created_at; 3 | 4 | alter table public.unused_deployments 5 | drop column created_at; 6 | -------------------------------------------------------------------------------- /store/postgres/migrations/2021-05-21-165219_add_created_at_columns_for_deployment_schemas/up.sql: -------------------------------------------------------------------------------- 1 | alter table public.deployment_schemas 2 | add column created_at timestamptz not null default now(); 3 | 4 | alter table public.unused_deployments 5 | add column created_at timestamptz; 6 | 7 | -- use a predefined default date that doesn't have a meaning. 8 | update 9 | public.unused_deployments 10 | set 11 | created_at = '2000-01-01'; 12 | 13 | alter table public.unused_deployments 14 | alter column created_at set not null; 15 | -------------------------------------------------------------------------------- /store/postgres/migrations/2021-06-01-222649_create_stats/down.sql: -------------------------------------------------------------------------------- 1 | drop table subgraphs.table_stats; 2 | -------------------------------------------------------------------------------- /store/postgres/migrations/2021-06-01-222649_create_stats/up.sql: -------------------------------------------------------------------------------- 1 | create table subgraphs.table_stats( 2 | id serial primary key, 3 | deployment int not null 4 | references subgraphs.subgraph_deployment 5 | on delete cascade, 6 | table_name text not null, 7 | is_account_like bool, 8 | unique(deployment, table_name) 9 | ); 10 | -------------------------------------------------------------------------------- /store/postgres/migrations/2021-06-14-201635_add_ethereum_hex_to_bytea_function/down.sql: -------------------------------------------------------------------------------- 1 | drop function if exists ethereum_hex_to_bytea (text); 2 | drop function if exists raise_exception_bytea (text); 3 | -------------------------------------------------------------------------------- /store/postgres/migrations/2021-07-09-144144_firehose_cursor/down.sql: -------------------------------------------------------------------------------- 1 | alter table subgraphs.subgraph_deployment 2 | drop column firehose_cursor; 3 | -------------------------------------------------------------------------------- /store/postgres/migrations/2021-07-09-144144_firehose_cursor/up.sql: -------------------------------------------------------------------------------- 1 | alter table subgraphs.subgraph_deployment 2 | add column firehose_cursor text default null; 3 | -------------------------------------------------------------------------------- /store/postgres/migrations/2021-12-02-212506_chain_store_firehose_cursor/down.sql: -------------------------------------------------------------------------------- 1 | update public.ethereum_networks 2 | set genesis_block_hash = '0000000000000000000000000000000000000000000000000000000000000000' 3 | where name = 'near-mainnet'; 4 | 5 | alter table public.ethereum_networks 6 | drop column head_block_cursor; 7 | -------------------------------------------------------------------------------- /store/postgres/migrations/2021-12-02-212506_chain_store_firehose_cursor/up.sql: -------------------------------------------------------------------------------- 1 | alter table public.ethereum_networks 2 | add column head_block_cursor text default null; 3 | 4 | update public.ethereum_networks 5 | set genesis_block_hash = 'a7110b9052e1be68f7fa8bb4065bf54e731205801878e708db7464ec4b9b8014' 6 | where name = 'near-mainnet'; -------------------------------------------------------------------------------- /store/postgres/migrations/2021-12-05-061157_add_debug_fork/down.sql: -------------------------------------------------------------------------------- 1 | alter table 2 | subgraphs.subgraph_deployment 3 | drop 4 | column debug_fork; 5 | -------------------------------------------------------------------------------- /store/postgres/migrations/2021-12-05-061157_add_debug_fork/up.sql: -------------------------------------------------------------------------------- 1 | alter table 2 | subgraphs.subgraph_deployment 3 | add 4 | column debug_fork text; 5 | -------------------------------------------------------------------------------- /store/postgres/migrations/2022-03-09-07000_call_cache_block_number_idx/down.sql: -------------------------------------------------------------------------------- 1 | drop index eth_call_cache_block_number_idx; 2 | 3 | do $$ 4 | declare 5 | tables cursor for select namespace 6 | from ethereum_networks 7 | where namespace != 'public'; 8 | begin 9 | for table_record in tables loop 10 | execute 11 | 'drop index ' 12 | || table_record.namespace 13 | || '.' 14 | || 'call_cache_block_number_idx'; 15 | end loop; 16 | end; 17 | $$; 18 | -------------------------------------------------------------------------------- /store/postgres/migrations/2022-03-09-07000_call_cache_block_number_idx/up.sql: -------------------------------------------------------------------------------- 1 | create index if not exists 2 | eth_call_cache_block_number_idx 3 | on 4 | eth_call_cache(block_number); 5 | 6 | do $$ 7 | declare 8 | tables cursor for select namespace 9 | from ethereum_networks 10 | where namespace != 'public'; 11 | begin 12 | for table_record in tables loop 13 | execute 14 | 'create index if not exists call_cache_block_number_idx on ' 15 | || table_record.namespace 16 | || '.' 17 | || 'call_cache(block_number)'; 18 | end loop; 19 | end; 20 | $$; 21 | -------------------------------------------------------------------------------- /store/postgres/migrations/2022-03-21-172028_add_use_bytea_prefix/down.sql: -------------------------------------------------------------------------------- 1 | alter table subgraphs.subgraph_manifest 2 | drop column use_bytea_prefix; 3 | -------------------------------------------------------------------------------- /store/postgres/migrations/2022-03-21-172028_add_use_bytea_prefix/up.sql: -------------------------------------------------------------------------------- 1 | alter table subgraphs.subgraph_manifest 2 | add column use_bytea_prefix bool not null default 'f'; 3 | -------------------------------------------------------------------------------- /store/postgres/migrations/2022-03-23-010300_drop-metadata-indexes/down.sql: -------------------------------------------------------------------------------- 1 | -- up only deletes indexes, no need to recreate them 2 | -------------------------------------------------------------------------------- /store/postgres/migrations/2022-06-12-003442_move_earliest_to_manifest/down.sql: -------------------------------------------------------------------------------- 1 | alter table subgraphs.subgraph_deployment 2 | drop column earliest_block_number; 3 | 4 | alter table subgraphs.subgraph_manifest 5 | drop column start_block_number, 6 | drop column start_block_hash; 7 | -------------------------------------------------------------------------------- /store/postgres/migrations/2022-09-19-161239_add-raw-manifest-column/down.sql: -------------------------------------------------------------------------------- 1 | alter table subgraphs.subgraph_manifest drop column raw_yaml; 2 | -------------------------------------------------------------------------------- /store/postgres/migrations/2022-09-19-161239_add-raw-manifest-column/up.sql: -------------------------------------------------------------------------------- 1 | alter table subgraphs.subgraph_manifest add column raw_yaml text; 2 | -------------------------------------------------------------------------------- /store/postgres/migrations/2022-10-13-000000_track_processed_data_source/down.sql: -------------------------------------------------------------------------------- 1 | raise 'This migration is irreversible'; 2 | -------------------------------------------------------------------------------- /store/postgres/migrations/2022-11-03-213140_drop_earliest_block/down.sql: -------------------------------------------------------------------------------- 1 | alter table subgraphs.subgraph_deployment 2 | add column earliest_ethereum_block_number numeric, 3 | add column earliest_ethereum_block_hash bytea; 4 | 5 | update subgraphs.subgraph_deployment d 6 | set earliest_ethereum_block_number = m.start_block_number, 7 | earliest_ethereum_block_hash = m.start_block_hash 8 | from subgraphs.subgraph_manifest m 9 | where m.id = d.id; 10 | -------------------------------------------------------------------------------- /store/postgres/migrations/2022-11-03-213140_drop_earliest_block/up.sql: -------------------------------------------------------------------------------- 1 | alter table subgraphs.subgraph_deployment 2 | drop column earliest_ethereum_block_number, 3 | drop column earliest_ethereum_block_hash; 4 | -------------------------------------------------------------------------------- /store/postgres/migrations/2022-11-10-185105_add_has_causality_region_column/down.sql: -------------------------------------------------------------------------------- 1 | alter table subgraphs.subgraph_manifest drop column entities_with_causality_region; 2 | -------------------------------------------------------------------------------- /store/postgres/migrations/2022-11-10-185105_add_has_causality_region_column/up.sql: -------------------------------------------------------------------------------- 1 | alter table subgraphs.subgraph_manifest add column if not exists entities_with_causality_region text[] not null default array[]::text[]; 2 | -------------------------------------------------------------------------------- /store/postgres/migrations/2023-01-24-192319_chain_size_view/down.sql: -------------------------------------------------------------------------------- 1 | -- This file should undo anything in `up.sql` 2 | 3 | drop view if exists info.all_sizes; 4 | 5 | create view info.all_sizes as 6 | select * from info.subgraph_sizes 7 | union all 8 | select * from info.table_sizes; 9 | 10 | drop materialized view if exists info.chain_sizes; 11 | -------------------------------------------------------------------------------- /store/postgres/migrations/2023-02-15-184255_add_manifest_on_sync/down.sql: -------------------------------------------------------------------------------- 1 | alter table subgraphs.subgraph_manifest 2 | drop column on_sync; 3 | -------------------------------------------------------------------------------- /store/postgres/migrations/2023-02-15-184255_add_manifest_on_sync/up.sql: -------------------------------------------------------------------------------- 1 | alter table subgraphs.subgraph_manifest 2 | add column on_sync text 3 | -- use a check constraint instead of an enum because 4 | -- enums are a pain to update 5 | constraint subgraph_manifest_on_sync_ck check (on_sync in ('activate', 'replace')); 6 | -------------------------------------------------------------------------------- /store/postgres/migrations/2023-03-06-002954_add_pruning/down.sql: -------------------------------------------------------------------------------- 1 | alter table subgraphs.subgraph_manifest 2 | drop column history_blocks; 3 | -------------------------------------------------------------------------------- /store/postgres/migrations/2023-03-06-002954_add_pruning/up.sql: -------------------------------------------------------------------------------- 1 | alter table subgraphs.subgraph_manifest 2 | add column history_blocks int4 3 | not null default 2147483647 4 | check (history_blocks > 0); 5 | -------------------------------------------------------------------------------- /store/postgres/migrations/2023-03-06-233030_add_last_pruned_block/down.sql: -------------------------------------------------------------------------------- 1 | alter table subgraphs.table_stats 2 | drop column last_pruned_block; 3 | -------------------------------------------------------------------------------- /store/postgres/migrations/2023-03-06-233030_add_last_pruned_block/up.sql: -------------------------------------------------------------------------------- 1 | alter table subgraphs.table_stats 2 | add column last_pruned_block int4; 3 | -------------------------------------------------------------------------------- /store/postgres/migrations/2023-03-28-004152_trigger_remap/down.sql: -------------------------------------------------------------------------------- 1 | -- No schema changes, migration is only there to trigger remapping of 2 | -- foreign metadata 3 | -------------------------------------------------------------------------------- /store/postgres/migrations/2023-03-28-004152_trigger_remap/up.sql: -------------------------------------------------------------------------------- 1 | -- No schema changes, migration is only there to trigger remapping of 2 | -- foreign metadata 3 | select 1; 4 | -------------------------------------------------------------------------------- /store/postgres/migrations/2023-05-23-1715-update-subgraph-deployment-assignment/down.sql: -------------------------------------------------------------------------------- 1 | -- Define the 'down' migration to remove the 'paused_at' and 'assigned_at' fields from 'subgraph_deployment_assignment' table 2 | ALTER TABLE subgraphs.subgraph_deployment_assignment 3 | DROP COLUMN paused_at, 4 | DROP COLUMN assigned_at; -------------------------------------------------------------------------------- /store/postgres/migrations/2023-05-23-1715-update-subgraph-deployment-assignment/up.sql: -------------------------------------------------------------------------------- 1 | -- Define the 'up' migration to add the 'paused_at' and 'assigned_at' fields to 'subgraph_deployment_assignment' table 2 | ALTER TABLE subgraphs.subgraph_deployment_assignment 3 | ADD COLUMN paused_at TIMESTAMPTZ NULL, 4 | ADD COLUMN assigned_at TIMESTAMPTZ NULL; -------------------------------------------------------------------------------- /store/postgres/migrations/2023-06-06-054643_create_subgraph_features_table/down.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE subgraph_features; -------------------------------------------------------------------------------- /store/postgres/migrations/2023-06-06-054643_create_subgraph_features_table/up.sql: -------------------------------------------------------------------------------- 1 | -- Creates a new table subgraph_features 2 | create table if not exists subgraphs.subgraph_features ( 3 | id text primary key, 4 | spec_version text not null, 5 | api_version text null, 6 | features text [] not null DEFAULT '{}', 7 | data_sources text [] not null DEFAULT '{}' 8 | ); -------------------------------------------------------------------------------- /store/postgres/migrations/2023-06-16-135622_add_network_to_subgraph_features_table/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE subgraphs.subgraph_features 2 | DROP COLUMN network; -------------------------------------------------------------------------------- /store/postgres/migrations/2023-06-16-135622_add_network_to_subgraph_features_table/up.sql: -------------------------------------------------------------------------------- 1 | TRUNCATE TABLE subgraphs.subgraph_features; 2 | ALTER TABLE subgraphs.subgraph_features 3 | ADD COLUMN network text not null; -------------------------------------------------------------------------------- /store/postgres/migrations/2023-08-23-143628_add_handlers_to_subgraph_features/down.sql: -------------------------------------------------------------------------------- 1 | alter table subgraphs.subgraph_features 2 | drop column handlers; 3 | -------------------------------------------------------------------------------- /store/postgres/migrations/2023-08-23-143628_add_handlers_to_subgraph_features/up.sql: -------------------------------------------------------------------------------- 1 | truncate table subgraphs.subgraph_features; 2 | 3 | alter table 4 | subgraphs.subgraph_features 5 | add 6 | column handlers text [] not null default '{}'; -------------------------------------------------------------------------------- /store/postgres/migrations/2023-12-15-182102_add_first_last_fn/down.sql: -------------------------------------------------------------------------------- 1 | drop aggregate public.last; 2 | drop aggregate public.first; 3 | drop function public.last_agg; 4 | drop function public.first_agg; 5 | -------------------------------------------------------------------------------- /store/postgres/migrations/2024-01-05-170000_ds_corruption_fix_up/down.sql: -------------------------------------------------------------------------------- 1 | -- "I can't go back to yesterday because I was a different person then." 2 | -------------------------------------------------------------------------------- /store/postgres/migrations/2024-06-11-084227_track-more-features-in-subgraph-features/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE subgraphs.subgraph_features 2 | DROP COLUMN IF EXISTS has_declared_calls, 3 | DROP COLUMN IF EXISTS has_bytes_as_ids, 4 | DROP COLUMN IF EXISTS has_aggregations, 5 | DROP COLUMN IF EXISTS immutable_entities; -------------------------------------------------------------------------------- /store/postgres/migrations/2024-06-11-084227_track-more-features-in-subgraph-features/up.sql: -------------------------------------------------------------------------------- 1 | TRUNCATE TABLE subgraphs.subgraph_features; 2 | ALTER TABLE subgraphs.subgraph_features 3 | ADD COLUMN IF NOT EXISTS has_declared_calls BOOLEAN NOT NULL DEFAULT FALSE, 4 | ADD COLUMN IF NOT EXISTS has_bytes_as_ids BOOLEAN NOT NULL DEFAULT FALSE, 5 | ADD COLUMN IF NOT EXISTS has_aggregations BOOLEAN NOT NULL DEFAULT FALSE, 6 | ADD COLUMN IF NOT EXISTS immutable_entities TEXT[] NOT NULL DEFAULT ARRAY[]::TEXT[]; -------------------------------------------------------------------------------- /store/postgres/migrations/2024-08-14-205601_store_synced_at_block/down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE subgraphs.subgraph_deployment DROP COLUMN synced_at_block_number; 2 | ALTER TABLE unused_deployments DROP COLUMN synced_at_block_number; 3 | -------------------------------------------------------------------------------- /store/postgres/migrations/2024-08-14-205601_store_synced_at_block/up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE subgraphs.subgraph_deployment ADD COLUMN synced_at_block_number INT4; 2 | ALTER TABLE unused_deployments ADD COLUMN synced_at_block_number INT4; 3 | -------------------------------------------------------------------------------- /store/postgres/migrations/2024-10-01-100427_create_graphman_command_executions_table/down.sql: -------------------------------------------------------------------------------- 1 | drop table public.graphman_command_executions; 2 | -------------------------------------------------------------------------------- /store/postgres/migrations/2024-10-01-100427_create_graphman_command_executions_table/up.sql: -------------------------------------------------------------------------------- 1 | create table public.graphman_command_executions 2 | ( 3 | id bigserial primary key, 4 | kind varchar not null check (kind in ('restart_deployment')), 5 | status varchar not null check (status in ('initializing', 'running', 'failed', 'succeeded')), 6 | error_message varchar default null, 7 | created_at timestamp with time zone not null, 8 | updated_at timestamp with time zone default null, 9 | completed_at timestamp with time zone default null 10 | ); 11 | -------------------------------------------------------------------------------- /store/postgres/migrations/2025-04-08-224710_add_prune_state/down.sql: -------------------------------------------------------------------------------- 1 | drop table subgraphs.prune_table_state; 2 | drop table subgraphs.prune_state; 3 | -------------------------------------------------------------------------------- /store/postgres/migrations/2025-04-25-163121_prune_error/down.sql: -------------------------------------------------------------------------------- 1 | alter table subgraphs.prune_state 2 | drop column errored_at, 3 | drop column error; 4 | -------------------------------------------------------------------------------- /store/postgres/migrations/2025-04-25-163121_prune_error/up.sql: -------------------------------------------------------------------------------- 1 | alter table subgraphs.prune_state 2 | add column errored_at timestamptz, 3 | add column error text, 4 | add constraint error_ck check ((errored_at is null) = (error is null)); 5 | -------------------------------------------------------------------------------- /store/postgres/src/graphman/schema.rs: -------------------------------------------------------------------------------- 1 | diesel::table! { 2 | public.graphman_command_executions { 3 | id -> BigSerial, 4 | kind -> Varchar, 5 | status -> Varchar, 6 | error_message -> Nullable, 7 | created_at -> Timestamptz, 8 | updated_at -> Nullable, 9 | completed_at -> Nullable, 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /store/postgres/tests/README.md: -------------------------------------------------------------------------------- 1 | Put integration tests for this crate into `store/test-store/tests/postgres`. 2 | This avoids cyclic dev-dependencies which make rust-analyzer nearly 3 | unusable. Once [this 4 | issue](https://github.com/rust-lang/rust-analyzer/issues/14167) has been 5 | fixed, we can move tests back here 6 | -------------------------------------------------------------------------------- /store/test-store/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "test-store" 3 | version.workspace = true 4 | edition.workspace = true 5 | authors = ["Leonardo Yvens "] 6 | description = "Provides static store instance for tests." 7 | 8 | [dependencies] 9 | graph-graphql = { path = "../../graphql" } 10 | graph-node = { path = "../../node" } 11 | graph = { path = "../../graph" } 12 | graph-store-postgres = { path = "../postgres" } 13 | graph-chain-ethereum = { path = "../../chain/ethereum" } 14 | lazy_static = "1.5" 15 | hex-literal = "0.4" 16 | diesel = { workspace = true } 17 | prost-types = { workspace = true } 18 | 19 | [dev-dependencies] 20 | hex = "0.4.3" 21 | pretty_assertions = "1.4.1" 22 | -------------------------------------------------------------------------------- /store/test-store/db-reset: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | resetdb() { 4 | host=$(hostname -s) 5 | db=$1 6 | echo "Reset $db" 7 | dropdb $db && createdb -O graph $db 8 | psql -q -X $db < *mut u8 { 8 | let mut buf = Vec::with_capacity(size); 9 | let ptr = buf.as_mut_ptr(); 10 | 11 | // Runtime is responsible of calling dealloc when no longer needed 12 | std::mem::forget(buf); 13 | ptr 14 | } 15 | 16 | #[no_mangle] 17 | pub unsafe fn dealloc(ptr: *mut u8, size: usize) { 18 | std::mem::drop(Vec::from_raw_parts(ptr, size, size)) 19 | } 20 | -------------------------------------------------------------------------------- /substreams/substreams-head-tracker/substreams-head-tracker-v1.0.0.spkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphprotocol/graph-node/94fb3f2825a66dd54c628c2866e3b1165d077576/substreams/substreams-head-tracker/substreams-head-tracker-v1.0.0.spkg -------------------------------------------------------------------------------- /substreams/substreams-head-tracker/substreams.yaml: -------------------------------------------------------------------------------- 1 | specVersion: v0.1.0 2 | package: 3 | name: substreams_head_tracker 4 | version: v1.0.0 5 | 6 | binaries: 7 | default: 8 | type: wasm/rust-v1 9 | file: ./target/wasm32-unknown-unknown/release/substreams.wasm 10 | 11 | modules: 12 | - name: map_blocks 13 | kind: map 14 | inputs: 15 | - params: string 16 | output: 17 | type: proto:sf.substreams.entity.v1.EntityChanges 18 | -------------------------------------------------------------------------------- /substreams/substreams-trigger-filter/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "substreams-trigger-filter" 3 | version.workspace = true 4 | edition.workspace = true 5 | 6 | [lib] 7 | doc = false 8 | name = "substreams" 9 | crate-type = ["cdylib"] 10 | 11 | [dependencies] 12 | hex = { version = "0.4", default-features = false } 13 | prost.workspace = true 14 | substreams.workspace = true 15 | substreams-entity-change.workspace = true 16 | substreams-near-core.workspace = true 17 | 18 | trigger-filters.path = "../trigger-filters" 19 | 20 | [build-dependencies] 21 | tonic-build.workspace = true 22 | -------------------------------------------------------------------------------- /substreams/substreams-trigger-filter/build.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | println!("cargo:rerun-if-changed=proto"); 3 | tonic_build::configure() 4 | .protoc_arg("--experimental_allow_proto3_optional") 5 | .extern_path( 6 | ".sf.near.codec.v1", 7 | "::substreams_near_core::pb::sf::near::type::v1", 8 | ) 9 | .out_dir("src/pb") 10 | .compile_protos(&["proto/receipts.proto"], &["proto"]) 11 | .expect("Failed to compile Substreams entity proto(s)"); 12 | } 13 | -------------------------------------------------------------------------------- /substreams/substreams-trigger-filter/bun.lockb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphprotocol/graph-node/94fb3f2825a66dd54c628c2866e3b1165d077576/substreams/substreams-trigger-filter/bun.lockb -------------------------------------------------------------------------------- /substreams/substreams-trigger-filter/package.json: -------------------------------------------------------------------------------- 1 | { "dependencies": { "@graphprotocol/graph-cli": "^0.92.0" } } -------------------------------------------------------------------------------- /substreams/substreams-trigger-filter/proto/receipts.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | import "near.proto"; 4 | 5 | package receipts.v1; 6 | 7 | message BlockAndReceipts { 8 | sf.near.codec.v1.Block block = 1; 9 | repeated sf.near.codec.v1.ExecutionOutcomeWithId outcome = 2; 10 | repeated sf.near.codec.v1.Receipt receipt = 3; 11 | } 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /substreams/substreams-trigger-filter/rust-toolchain.toml: -------------------------------------------------------------------------------- 1 | [toolchain] 2 | targets = [ "wasm32-unknown-unknown" ] 3 | -------------------------------------------------------------------------------- /substreams/substreams-trigger-filter/schema.graphql: -------------------------------------------------------------------------------- 1 | type Block @entity { 2 | id: Bytes! 3 | } 4 | 5 | -------------------------------------------------------------------------------- /substreams/substreams-trigger-filter/src/pb/mod.rs: -------------------------------------------------------------------------------- 1 | // @generated 2 | pub mod receipts { 3 | // @@protoc_insertion_point(attribute:receipts.v1) 4 | pub mod v1 { 5 | include!("receipts.v1.rs"); 6 | // @@protoc_insertion_point(receipts.v1) 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /substreams/substreams-trigger-filter/subgraph.yaml: -------------------------------------------------------------------------------- 1 | specVersion: 0.0.5 2 | description: NEAR Blocks Indexing 3 | repository: git@github.com:streamingfast/graph-node-dev.git 4 | schema: 5 | file: ./schema.graphql 6 | dataSources: 7 | - kind: substreams 8 | name: hello-world 9 | network: near-mainnet 10 | source: 11 | package: 12 | moduleName: graph_out 13 | file: substreams-near-hello-world-v0.1.0.spkg 14 | mapping: 15 | kind: substreams/graph-entities 16 | apiVersion: 0.0.7 17 | -------------------------------------------------------------------------------- /substreams/substreams-trigger-filter/substreams-trigger-filter-v0.1.0.spkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphprotocol/graph-node/94fb3f2825a66dd54c628c2866e3b1165d077576/substreams/substreams-trigger-filter/substreams-trigger-filter-v0.1.0.spkg -------------------------------------------------------------------------------- /substreams/trigger-filters/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "trigger-filters" 3 | version.workspace = true 4 | edition.workspace = true 5 | 6 | [dependencies] 7 | anyhow = "1" 8 | -------------------------------------------------------------------------------- /tests/.gitignore: -------------------------------------------------------------------------------- 1 | contracts/cache/ 2 | integration-tests/graph-node.log 3 | integration-tests/*/subgraph.yaml.patched 4 | -------------------------------------------------------------------------------- /tests/common/1_initial_migration.js: -------------------------------------------------------------------------------- 1 | var Migrations = artifacts.require('./Migrations.sol') 2 | 3 | module.exports = function(deployer) { 4 | deployer.deploy(Migrations) 5 | } 6 | -------------------------------------------------------------------------------- /tests/common/2_deploy_contracts.js: -------------------------------------------------------------------------------- 1 | const Contract = artifacts.require('./Contract.sol') 2 | 3 | module.exports = async function(deployer) { 4 | await deployer.deploy(Contract) 5 | } 6 | -------------------------------------------------------------------------------- /tests/common/Migrations.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.8.0; 2 | 3 | contract Migrations { 4 | address public owner; 5 | uint public last_completed_migration; 6 | 7 | constructor() public { 8 | owner = msg.sender; 9 | } 10 | 11 | modifier restricted() { 12 | if (msg.sender == owner) _; 13 | } 14 | 15 | function setCompleted(uint completed) public restricted { 16 | last_completed_migration = completed; 17 | } 18 | 19 | function upgrade(address new_address) public restricted { 20 | Migrations upgraded = Migrations(new_address); 21 | upgraded.setCompleted(last_completed_migration); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /tests/common/SimpleContract.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.8.0; 2 | 3 | 4 | contract Contract { 5 | event Trigger(uint16 x); 6 | 7 | constructor() public { 8 | emit Trigger(0); 9 | } 10 | 11 | function emitTrigger(uint16 x) public { 12 | emit Trigger(x); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /tests/contracts/foundry.toml: -------------------------------------------------------------------------------- 1 | [profile.default] 2 | src = "src" 3 | out = "out" 4 | libs = ["lib"] 5 | 6 | # See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options 7 | -------------------------------------------------------------------------------- /tests/contracts/src/LimitedContract.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | 4 | contract LimitedContract { 5 | event Trigger(); 6 | 7 | constructor() { 8 | emit Trigger(); 9 | } 10 | 11 | function inc(uint256 value) public pure returns (uint256) { 12 | require(value < 10, "can only handle values < 10"); 13 | return value + 1; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tests/contracts/src/OverloadedContract.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | 4 | contract OverloadedContract { 5 | event Trigger(); 6 | 7 | constructor() { 8 | emit Trigger(); 9 | } 10 | 11 | function exampleFunction( 12 | string memory 13 | ) public pure returns (string memory) { 14 | return "string -> string"; 15 | } 16 | 17 | function exampleFunction(uint256) public pure returns (string memory) { 18 | return "uint256 -> string"; 19 | } 20 | 21 | function exampleFunction(bytes32) public pure returns (uint256) { 22 | return 256; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /tests/contracts/src/RevertingContract.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | 4 | contract RevertingContract { 5 | event Trigger(); 6 | 7 | constructor() { 8 | emit Trigger(); 9 | } 10 | 11 | function inc(uint256 value) public pure returns (uint256) { 12 | require(value < 10, "can only handle values < 10"); 13 | return value + 1; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tests/integration-tests/api-version-v0-0-4/schema.graphql: -------------------------------------------------------------------------------- 1 | # The `id` is the block number and `count` the handler invocations at that block. 2 | type DataSourceCount @entity { 3 | id: ID! 4 | count: Int! 5 | } 6 | -------------------------------------------------------------------------------- /tests/integration-tests/api-version-v0-0-4/truffle.js: -------------------------------------------------------------------------------- 1 | require("babel-register"); 2 | require("babel-polyfill"); 3 | 4 | module.exports = { 5 | contracts_directory: "../../common", 6 | migrations_directory: "../../common", 7 | contracts_build_directory: "./truffle_output", 8 | networks: { 9 | test: { 10 | host: "localhost", 11 | port: process.env.GANACHE_TEST_PORT || 18545, 12 | network_id: "*", 13 | gas: "100000000000", 14 | gasPrice: "1", 15 | }, 16 | }, 17 | compilers: { 18 | solc: { 19 | version: "0.8.2" 20 | }, 21 | }, 22 | }; 23 | -------------------------------------------------------------------------------- /tests/integration-tests/base/schema.graphql: -------------------------------------------------------------------------------- 1 | type BaseData @entity(immutable: true) { 2 | id: ID! 3 | data: String! 4 | blockNumber: BigInt! 5 | } -------------------------------------------------------------------------------- /tests/integration-tests/base/src/mapping.ts: -------------------------------------------------------------------------------- 1 | import { ethereum } from '@graphprotocol/graph-ts' 2 | import { BaseData } from '../generated/schema' 3 | 4 | export function handleBlock(block: ethereum.Block): void { 5 | let entity = new BaseData(block.number.toString()) 6 | entity.data = 'from base' 7 | entity.blockNumber = block.number 8 | entity.save() 9 | } -------------------------------------------------------------------------------- /tests/integration-tests/block-handlers/schema.graphql: -------------------------------------------------------------------------------- 1 | type Foo @entity { 2 | id: ID! 3 | value: Int8! 4 | } 5 | 6 | type Initialize @entity { 7 | id: ID! 8 | block: BigInt! 9 | } 10 | 11 | type Block @entity { 12 | id: ID! 13 | number: BigInt! 14 | hash: Bytes! 15 | } 16 | 17 | type BlockFromPollingHandler @entity { 18 | id: ID! 19 | number: BigInt! 20 | hash: Bytes! 21 | } 22 | 23 | type BlockFromOtherPollingHandler @entity { 24 | id: ID! 25 | number: BigInt! 26 | hash: Bytes! 27 | } -------------------------------------------------------------------------------- /tests/integration-tests/ethereum-api-tests/schema.graphql: -------------------------------------------------------------------------------- 1 | type Foo @entity { 2 | id: ID! 3 | balance: BigInt! 4 | hasCode1: Boolean! 5 | hasCode2: Boolean! 6 | } 7 | -------------------------------------------------------------------------------- /tests/integration-tests/grafted/schema.graphql: -------------------------------------------------------------------------------- 1 | type GraftedData @entity(immutable: true) { 2 | id: ID! 3 | data: String! 4 | blockNumber: BigInt! 5 | } -------------------------------------------------------------------------------- /tests/integration-tests/grafted/src/mapping.ts: -------------------------------------------------------------------------------- 1 | import { ethereum } from '@graphprotocol/graph-ts' 2 | import { GraftedData } from '../generated/schema' 3 | 4 | export function handleBlock(block: ethereum.Block): void { 5 | let entity = new GraftedData(block.number.toString()) 6 | entity.data = 'to grafted' 7 | entity.blockNumber = block.number 8 | entity.save() 9 | } -------------------------------------------------------------------------------- /tests/integration-tests/host-exports/schema.graphql: -------------------------------------------------------------------------------- 1 | type Foo @entity { 2 | id: ID! 3 | value: String! 4 | } 5 | -------------------------------------------------------------------------------- /tests/integration-tests/host-exports/subgraph.yaml: -------------------------------------------------------------------------------- 1 | specVersion: 0.0.4 2 | schema: 3 | file: ./schema.graphql 4 | dataSources: 5 | - kind: ethereum/contract 6 | name: Contract 7 | network: test 8 | source: 9 | address: "@SimpleContract@" 10 | abi: Contract 11 | mapping: 12 | kind: ethereum/events 13 | apiVersion: 0.0.6 14 | language: wasm/assemblyscript 15 | abis: 16 | - name: Contract 17 | file: ./abis/Contract.abi 18 | entities: 19 | - Call 20 | eventHandlers: 21 | - event: Trigger(uint16) 22 | handler: handleTrigger 23 | file: ./src/mapping.ts 24 | -------------------------------------------------------------------------------- /tests/integration-tests/int8/schema.graphql: -------------------------------------------------------------------------------- 1 | type Foo @entity { 2 | id: ID! 3 | value: Int8! 4 | } 5 | -------------------------------------------------------------------------------- /tests/integration-tests/int8/src/mapping.ts: -------------------------------------------------------------------------------- 1 | import { Trigger } from "../generated/Contract/Contract"; 2 | import { Foo } from "../generated/schema"; 3 | 4 | export function handleTrigger(event: Trigger): void { 5 | let obj = new Foo("0"); 6 | obj.value = i64.MAX_VALUE; 7 | obj.save(); 8 | 9 | obj = Foo.load("0"); 10 | assert(obj.value == i64.MAX_VALUE, "maybe invalid value"); 11 | } 12 | -------------------------------------------------------------------------------- /tests/integration-tests/int8/subgraph.yaml: -------------------------------------------------------------------------------- 1 | specVersion: 0.0.4 2 | schema: 3 | file: ./schema.graphql 4 | dataSources: 5 | - kind: ethereum/contract 6 | name: Contract 7 | network: test 8 | source: 9 | address: "@SimpleContract@" 10 | abi: Contract 11 | mapping: 12 | kind: ethereum/events 13 | apiVersion: 0.0.6 14 | language: wasm/assemblyscript 15 | abis: 16 | - name: Contract 17 | file: ./abis/Contract.abi 18 | entities: 19 | - Call 20 | eventHandlers: 21 | - event: Trigger(uint16) 22 | handler: handleTrigger 23 | file: ./src/mapping.ts 24 | -------------------------------------------------------------------------------- /tests/integration-tests/multiple-subgraph-datasources/schema.graphql: -------------------------------------------------------------------------------- 1 | type AggregatedData @entity { 2 | id: ID! 3 | sourceA: String 4 | sourceB: String 5 | first: String! 6 | } 7 | -------------------------------------------------------------------------------- /tests/integration-tests/non-fatal-errors/schema.graphql: -------------------------------------------------------------------------------- 1 | type Foo @entity { 2 | id: ID! 3 | } 4 | -------------------------------------------------------------------------------- /tests/integration-tests/overloaded-functions/schema.graphql: -------------------------------------------------------------------------------- 1 | type Call @entity { 2 | id: ID! 3 | value: String! 4 | } 5 | -------------------------------------------------------------------------------- /tests/integration-tests/overloaded-functions/subgraph.yaml: -------------------------------------------------------------------------------- 1 | specVersion: 0.0.4 2 | schema: 3 | file: ./schema.graphql 4 | dataSources: 5 | - kind: ethereum/contract 6 | name: Contract 7 | network: test 8 | source: 9 | address: "@OverloadedContract@" 10 | abi: Contract 11 | mapping: 12 | kind: ethereum/events 13 | apiVersion: 0.0.6 14 | language: wasm/assemblyscript 15 | abis: 16 | - name: Contract 17 | file: ./abis/Contract.abi 18 | entities: 19 | - Call 20 | eventHandlers: 21 | - event: Trigger() 22 | handler: handleTrigger 23 | file: ./src/mapping.ts 24 | -------------------------------------------------------------------------------- /tests/integration-tests/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "workspaces": [ 4 | "*" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /tests/integration-tests/poi-for-failed-subgraph/schema.graphql: -------------------------------------------------------------------------------- 1 | type Call @entity { 2 | id: ID! 3 | value: String! 4 | } 5 | -------------------------------------------------------------------------------- /tests/integration-tests/poi-for-failed-subgraph/src/mapping.ts: -------------------------------------------------------------------------------- 1 | import { Trigger } from "../generated/Contract/Contract"; 2 | import { Call } from "../generated/schema" 3 | 4 | export function handleTrigger(event: Trigger): void { 5 | let call1 = new Call("one") 6 | call1.value = "some value" 7 | call1.save() 8 | 9 | let call2 = new Call("two") 10 | call2.value = "another value" 11 | call2.save() 12 | 13 | assert(false) 14 | } 15 | -------------------------------------------------------------------------------- /tests/integration-tests/poi-for-failed-subgraph/subgraph.yaml: -------------------------------------------------------------------------------- 1 | specVersion: 0.0.4 2 | schema: 3 | file: ./schema.graphql 4 | dataSources: 5 | - kind: ethereum/contract 6 | name: Contract 7 | network: test 8 | source: 9 | address: "@SimpleContract@" 10 | abi: Contract 11 | mapping: 12 | kind: ethereum/events 13 | apiVersion: 0.0.6 14 | language: wasm/assemblyscript 15 | abis: 16 | - name: Contract 17 | file: ./abis/Contract.abi 18 | entities: 19 | - Call 20 | eventHandlers: 21 | - event: Trigger(uint16) 22 | handler: handleTrigger 23 | file: ./src/mapping.ts 24 | -------------------------------------------------------------------------------- /tests/integration-tests/remove-then-update/schema.graphql: -------------------------------------------------------------------------------- 1 | type Foo @entity { 2 | id: ID! 3 | value: String 4 | removed: Boolean! 5 | } 6 | -------------------------------------------------------------------------------- /tests/integration-tests/remove-then-update/subgraph.yaml: -------------------------------------------------------------------------------- 1 | specVersion: 0.0.4 2 | schema: 3 | file: ./schema.graphql 4 | dataSources: 5 | - kind: ethereum/contract 6 | name: Contract 7 | network: test 8 | source: 9 | address: "@SimpleContract@" 10 | abi: Contract 11 | mapping: 12 | kind: ethereum/events 13 | apiVersion: 0.0.6 14 | language: wasm/assemblyscript 15 | abis: 16 | - name: Contract 17 | file: ./abis/Contract.abi 18 | entities: 19 | - Call 20 | eventHandlers: 21 | - event: Trigger(uint16) 22 | handler: handleTrigger 23 | file: ./src/mapping.ts 24 | -------------------------------------------------------------------------------- /tests/integration-tests/reverted-calls/schema.graphql: -------------------------------------------------------------------------------- 1 | type Call @entity { 2 | id: ID! 3 | reverted: Boolean! 4 | returnValue: BigInt 5 | } 6 | -------------------------------------------------------------------------------- /tests/integration-tests/reverted-calls/subgraph.yaml: -------------------------------------------------------------------------------- 1 | specVersion: 0.0.4 2 | schema: 3 | file: ./schema.graphql 4 | dataSources: 5 | - kind: ethereum/contract 6 | name: Contract 7 | network: test 8 | source: 9 | address: "@RevertingContract@" 10 | abi: Contract 11 | mapping: 12 | kind: ethereum/events 13 | apiVersion: 0.0.6 14 | language: wasm/assemblyscript 15 | abis: 16 | - name: Contract 17 | file: ./abis/Contract.abi 18 | entities: 19 | - Call 20 | eventHandlers: 21 | - event: Trigger() 22 | handler: handleTrigger 23 | file: ./src/mapping.ts 24 | -------------------------------------------------------------------------------- /tests/integration-tests/source-subgraph-a/schema.graphql: -------------------------------------------------------------------------------- 1 | type SourceAData @entity(immutable: true) { 2 | id: ID! 3 | data: String! 4 | blockNumber: BigInt! 5 | } -------------------------------------------------------------------------------- /tests/integration-tests/source-subgraph-a/src/mapping.ts: -------------------------------------------------------------------------------- 1 | import { ethereum } from '@graphprotocol/graph-ts' 2 | import { SourceAData } from '../generated/schema' 3 | 4 | export function handleBlock(block: ethereum.Block): void { 5 | let entity = new SourceAData(block.number.toString()) 6 | entity.data = 'from source A' 7 | entity.blockNumber = block.number 8 | entity.save() 9 | } -------------------------------------------------------------------------------- /tests/integration-tests/source-subgraph-b/schema.graphql: -------------------------------------------------------------------------------- 1 | type SourceBData @entity(immutable: true) { 2 | id: ID! 3 | data: String! 4 | blockNumber: BigInt! 5 | } -------------------------------------------------------------------------------- /tests/integration-tests/source-subgraph-b/src/mapping.ts: -------------------------------------------------------------------------------- 1 | import { ethereum } from '@graphprotocol/graph-ts' 2 | import { SourceBData } from '../generated/schema' 3 | 4 | export function handleBlock(block: ethereum.Block): void { 5 | let entity = new SourceBData(block.number.toString()) 6 | entity.data = 'from source B' 7 | entity.blockNumber = block.number 8 | entity.save() 9 | } -------------------------------------------------------------------------------- /tests/integration-tests/source-subgraph/schema.graphql: -------------------------------------------------------------------------------- 1 | type Block @entity(immutable: true) { 2 | id: ID! 3 | number: BigInt! 4 | hash: Bytes! 5 | } 6 | 7 | type Block2 @entity(immutable: true) { 8 | id: ID! 9 | number: BigInt! 10 | hash: Bytes! 11 | testMessage: String 12 | } 13 | -------------------------------------------------------------------------------- /tests/integration-tests/source-subgraph/subgraph.yaml: -------------------------------------------------------------------------------- 1 | specVersion: 1.3.0 2 | schema: 3 | file: ./schema.graphql 4 | dataSources: 5 | - kind: ethereum/contract 6 | name: BlockHandlerTest 7 | network: test 8 | source: 9 | address: "@SimpleContract@" 10 | abi: Contract 11 | startBlock: 1 12 | mapping: 13 | kind: ethereum/events 14 | apiVersion: 0.0.7 15 | language: wasm/assemblyscript 16 | abis: 17 | - name: Contract 18 | file: ./abis/Contract.abi 19 | entities: 20 | - Call 21 | blockHandlers: 22 | - handler: handleBlock 23 | file: ./src/mapping.ts -------------------------------------------------------------------------------- /tests/integration-tests/subgraph-data-sources/abis/Contract.abi: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "anonymous": false, 4 | "inputs": [ 5 | { 6 | "indexed": false, 7 | "internalType": "string", 8 | "name": "testCommand", 9 | "type": "string" 10 | } 11 | ], 12 | "name": "TestEvent", 13 | "type": "event" 14 | } 15 | ] 16 | -------------------------------------------------------------------------------- /tests/integration-tests/subgraph-data-sources/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "subgraph-data-sources", 3 | "version": "0.1.0", 4 | "scripts": { 5 | "codegen": "graph codegen --skip-migrations", 6 | "create:test": "graph create test/subgraph-data-sources --node $GRAPH_NODE_ADMIN_URI", 7 | "deploy:test": "graph deploy test/subgraph-data-sources --version-label v0.0.1 --ipfs $IPFS_URI --node $GRAPH_NODE_ADMIN_URI" 8 | }, 9 | "devDependencies": { 10 | "@graphprotocol/graph-cli": "0.93.4-alpha-20250105163501-f401d0c57c4ba1f1af95a928d447efd63a56ecdc", 11 | "@graphprotocol/graph-ts": "0.36.0-alpha-20241129215038-b75cda9" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /tests/integration-tests/subgraph-data-sources/schema.graphql: -------------------------------------------------------------------------------- 1 | type MirrorBlock @entity { 2 | id: String! 3 | number: BigInt! 4 | hash: Bytes! 5 | testMessage: String 6 | } 7 | -------------------------------------------------------------------------------- /tests/integration-tests/subgraph-data-sources/subgraph.yaml: -------------------------------------------------------------------------------- 1 | specVersion: 1.3.0 2 | schema: 3 | file: ./schema.graphql 4 | dataSources: 5 | - kind: subgraph 6 | name: Contract 7 | network: test 8 | source: 9 | address: 'QmWi3H11QFE2PiWx6WcQkZYZdA5UasaBptUJqGn54MFux5' 10 | startBlock: 0 11 | mapping: 12 | apiVersion: 0.0.7 13 | language: wasm/assemblyscript 14 | entities: 15 | - Gravatar 16 | handlers: 17 | - handler: handleEntity 18 | entity: Block 19 | - handler: handleEntity2 20 | entity: Block2 21 | file: ./src/mapping.ts 22 | -------------------------------------------------------------------------------- /tests/integration-tests/timestamp/schema.graphql: -------------------------------------------------------------------------------- 1 | type Foo @entity { 2 | id: ID! 3 | value: Timestamp! 4 | } 5 | -------------------------------------------------------------------------------- /tests/integration-tests/timestamp/src/mapping.ts: -------------------------------------------------------------------------------- 1 | import { Trigger } from "../generated/Contract/Contract"; 2 | import { Foo } from "../generated/schema"; 3 | 4 | export function handleTrigger(event: Trigger): void { 5 | let obj = new Foo("0"); 6 | obj.value = 1710837304040956; 7 | obj.save(); 8 | 9 | obj = Foo.load("0"); 10 | assert(obj.value == 1710837304040956, "maybe invalid value"); 11 | } 12 | -------------------------------------------------------------------------------- /tests/integration-tests/timestamp/subgraph.yaml: -------------------------------------------------------------------------------- 1 | specVersion: 0.0.4 2 | schema: 3 | file: ./schema.graphql 4 | dataSources: 5 | - kind: ethereum/contract 6 | name: Contract 7 | network: test 8 | source: 9 | address: "@SimpleContract@" 10 | abi: Contract 11 | mapping: 12 | kind: ethereum/events 13 | apiVersion: 0.0.6 14 | language: wasm/assemblyscript 15 | abis: 16 | - name: Contract 17 | file: ./abis/Contract.abi 18 | entities: 19 | - Call 20 | eventHandlers: 21 | - event: Trigger(uint16) 22 | handler: handleTrigger 23 | file: ./src/mapping.ts 24 | -------------------------------------------------------------------------------- /tests/integration-tests/topic-filter/schema.graphql: -------------------------------------------------------------------------------- 1 | type AnotherTriggerEntity @entity { 2 | id: ID! 3 | a: BigInt 4 | b: BigInt 5 | c: BigInt 6 | data: String 7 | } 8 | -------------------------------------------------------------------------------- /tests/integration-tests/topic-filter/src/mapping.ts: -------------------------------------------------------------------------------- 1 | import { Address, ethereum } from "@graphprotocol/graph-ts"; 2 | import { AnotherTrigger } from "../generated/Contract/Contract"; 3 | import { AnotherTriggerEntity } from "../generated/schema"; 4 | 5 | export function handleAnotherTrigger(event: AnotherTrigger): void { 6 | let entity = new AnotherTriggerEntity(event.transaction.hash.toHex()); 7 | entity.a = event.params.a; 8 | entity.b = event.params.b; 9 | entity.c = event.params.c; 10 | entity.data = event.params.data; 11 | entity.save(); 12 | } 13 | -------------------------------------------------------------------------------- /tests/integration-tests/value-roundtrip/schema.graphql: -------------------------------------------------------------------------------- 1 | type Foo @entity { 2 | id: ID! 3 | value: String! 4 | } 5 | -------------------------------------------------------------------------------- /tests/integration-tests/value-roundtrip/src/mapping.ts: -------------------------------------------------------------------------------- 1 | import { Trigger } from "../generated/Contract/Contract"; 2 | import { Foo } from "../generated/schema"; 3 | 4 | export function handleTrigger(event: Trigger): void { 5 | let obj = new Foo("0"); 6 | obj.value = "b\u0000la\u0000"; 7 | obj.save(); 8 | 9 | // Null characters are stripped. 10 | obj = Foo.load("0"); 11 | assert(obj.value == "bla", "nulls not stripped"); 12 | } 13 | -------------------------------------------------------------------------------- /tests/integration-tests/value-roundtrip/subgraph.yaml: -------------------------------------------------------------------------------- 1 | specVersion: 0.0.4 2 | schema: 3 | file: ./schema.graphql 4 | dataSources: 5 | - kind: ethereum/contract 6 | name: Contract 7 | network: test 8 | source: 9 | address: "@SimpleContract@" 10 | abi: Contract 11 | mapping: 12 | kind: ethereum/events 13 | apiVersion: 0.0.6 14 | language: wasm/assemblyscript 15 | abis: 16 | - name: Contract 17 | file: ./abis/Contract.abi 18 | entities: 19 | - Call 20 | eventHandlers: 21 | - event: Trigger(uint16) 22 | handler: handleTrigger 23 | file: ./src/mapping.ts 24 | -------------------------------------------------------------------------------- /tests/runner-tests/api-version/.gitignore: -------------------------------------------------------------------------------- 1 | subgraph-0.0.7.yaml 2 | subgraph-0.0.8.yaml -------------------------------------------------------------------------------- /tests/runner-tests/api-version/abis/Contract.abi: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "anonymous": false, 4 | "inputs": [ 5 | { 6 | "indexed": false, 7 | "internalType": "string", 8 | "name": "testCommand", 9 | "type": "string" 10 | } 11 | ], 12 | "name": "TestEvent", 13 | "type": "event" 14 | } 15 | ] 16 | -------------------------------------------------------------------------------- /tests/runner-tests/api-version/data.0.0.7.json: -------------------------------------------------------------------------------- 1 | { 2 | "apiVersion": "0.0.7" 3 | } 4 | -------------------------------------------------------------------------------- /tests/runner-tests/api-version/data.0.0.8.json: -------------------------------------------------------------------------------- 1 | { 2 | "apiVersion": "0.0.8" 3 | } 4 | -------------------------------------------------------------------------------- /tests/runner-tests/api-version/schema.graphql: -------------------------------------------------------------------------------- 1 | type TestResult @entity { 2 | id: ID! 3 | message: String! 4 | } 5 | -------------------------------------------------------------------------------- /tests/runner-tests/api-version/src/mapping.ts: -------------------------------------------------------------------------------- 1 | import { Entity, Value, store } from "@graphprotocol/graph-ts"; 2 | import { TestEvent } from "../generated/Contract/Contract"; 3 | import { TestResult } from "../generated/schema"; 4 | 5 | export function handleTestEvent(event: TestEvent): void { 6 | let testResult = new TestResult(event.params.testCommand); 7 | testResult.message = event.params.testCommand; 8 | let testResultEntity = testResult as Entity; 9 | testResultEntity.set( 10 | "invalid_field", 11 | Value.fromString("This is an invalid field"), 12 | ); 13 | store.set("TestResult", testResult.id, testResult); 14 | testResult.save(); 15 | } 16 | -------------------------------------------------------------------------------- /tests/runner-tests/api-version/subgraph.template.yaml: -------------------------------------------------------------------------------- 1 | specVersion: 0.0.4 2 | schema: 3 | file: ./schema.graphql 4 | dataSources: 5 | - kind: ethereum/contract 6 | name: Contract 7 | network: test 8 | source: 9 | address: "0x0000000000000000000000000000000000000000" 10 | abi: Contract 11 | mapping: 12 | kind: ethereum/events 13 | apiVersion: {{apiVersion}} 14 | language: wasm/assemblyscript 15 | abis: 16 | - name: Contract 17 | file: ./abis/Contract.abi 18 | entities: 19 | - Call 20 | eventHandlers: 21 | - event: TestEvent(string) 22 | handler: handleTestEvent 23 | file: ./src/mapping.ts -------------------------------------------------------------------------------- /tests/runner-tests/arweave-file-data-sources/abis/Contract.abi: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "anonymous": false, 4 | "inputs": [ 5 | { 6 | "indexed": false, 7 | "internalType": "string", 8 | "name": "testCommand", 9 | "type": "string" 10 | } 11 | ], 12 | "name": "TestEvent", 13 | "type": "event" 14 | } 15 | ] 16 | -------------------------------------------------------------------------------- /tests/runner-tests/arweave-file-data-sources/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "arweave-file-data-sources", 3 | "version": "0.1.0", 4 | "scripts": { 5 | "codegen": "graph codegen --skip-migrations", 6 | "create:test": "graph create test/file-data-sources --node $GRAPH_NODE_ADMIN_URI", 7 | "deploy:test": "graph deploy test/file-data-sources --version-label v0.0.1 --ipfs $IPFS_URI --node $GRAPH_NODE_ADMIN_URI" 8 | }, 9 | "devDependencies": { 10 | "@graphprotocol/graph-cli": "0.60.0", 11 | "@graphprotocol/graph-ts": "0.31.0" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /tests/runner-tests/arweave-file-data-sources/schema.graphql: -------------------------------------------------------------------------------- 1 | type File @entity { 2 | id: ID! 3 | content: String! 4 | } 5 | 6 | -------------------------------------------------------------------------------- /tests/runner-tests/block-handlers/abis/Contract.abi: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "anonymous": false, 4 | "inputs": [ 5 | { 6 | "indexed": false, 7 | "internalType": "string", 8 | "name": "testCommand", 9 | "type": "string" 10 | } 11 | ], 12 | "name": "TestEvent", 13 | "type": "event" 14 | } 15 | ] 16 | -------------------------------------------------------------------------------- /tests/runner-tests/block-handlers/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "block-handlers", 3 | "version": "0.1.0", 4 | "scripts": { 5 | "codegen": "graph codegen --skip-migrations", 6 | "create:test": "graph create test/block-handlers --node $GRAPH_NODE_ADMIN_URI", 7 | "deploy:test": "graph deploy test/block-handlers --version-label v0.0.1 --ipfs $IPFS_URI --node $GRAPH_NODE_ADMIN_URI" 8 | }, 9 | "devDependencies": { 10 | "@graphprotocol/graph-cli": "0.60.0", 11 | "@graphprotocol/graph-ts": "0.31.0" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /tests/runner-tests/block-handlers/schema.graphql: -------------------------------------------------------------------------------- 1 | type BlockFromPollingHandler @entity { 2 | id: ID! 3 | number: BigInt! 4 | hash: Bytes! 5 | } 6 | 7 | type BlockFromOtherPollingHandler @entity { 8 | id: ID! 9 | number: BigInt! 10 | hash: Bytes! 11 | } -------------------------------------------------------------------------------- /tests/runner-tests/data-source-revert/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "data-source-revert", 3 | "version": "0.1.0", 4 | "scripts": { 5 | "codegen": "graph codegen --skip-migrations", 6 | "deploy:test": "graph deploy test/data-source-revert --version-label v0.0.1 --ipfs $IPFS_URI --node $GRAPH_NODE_ADMIN_URI", 7 | "deploy:test-grafted": "node updateAndDeploy.js" 8 | }, 9 | "devDependencies": { 10 | "@graphprotocol/graph-cli": "0.60.0", 11 | "@graphprotocol/graph-ts": "0.31.0" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /tests/runner-tests/data-source-revert/schema.graphql: -------------------------------------------------------------------------------- 1 | # The `id` is the block number and `count` the handler invocations at that block. 2 | type DataSourceCount @entity { 3 | id: ID! 4 | count: Int! 5 | } 6 | -------------------------------------------------------------------------------- /tests/runner-tests/data-source-revert2/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "data-source-revert2", 3 | "version": "0.1.0", 4 | "scripts": { 5 | "codegen": "graph codegen --skip-migrations", 6 | "deploy:test": "graph deploy test/data-source-revert2 --version-label v0.0.1 --ipfs $IPFS_URI --node $GRAPH_NODE_ADMIN_URI" 7 | }, 8 | "devDependencies": { 9 | "@graphprotocol/graph-cli": "0.60.0", 10 | "@graphprotocol/graph-ts": "0.31.0" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /tests/runner-tests/data-source-revert2/schema.graphql: -------------------------------------------------------------------------------- 1 | # The `id` is the block number and `count` the handler invocations at that block. 2 | type DataSourceCount @entity { 3 | id: ID! 4 | count: Int! 5 | } 6 | -------------------------------------------------------------------------------- /tests/runner-tests/data-sources/abis/Contract.abi: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "anonymous": false, 4 | "inputs": [ 5 | { 6 | "indexed": false, 7 | "internalType": "string", 8 | "name": "testCommand", 9 | "type": "string" 10 | } 11 | ], 12 | "name": "TestEvent", 13 | "type": "event" 14 | } 15 | ] 16 | -------------------------------------------------------------------------------- /tests/runner-tests/data-sources/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "data-sources", 3 | "version": "0.1.0", 4 | "scripts": { 5 | "codegen": "graph codegen --skip-migrations", 6 | "create:test": "graph create test/data-sources --node $GRAPH_NODE_ADMIN_URI", 7 | "deploy:test": "graph deploy test/data-sources --version-label v0.0.1 --ipfs $IPFS_URI --node $GRAPH_NODE_ADMIN_URI" 8 | }, 9 | "devDependencies": { 10 | "@graphprotocol/graph-cli": "0.60.0", 11 | "@graphprotocol/graph-ts": "0.31.0" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /tests/runner-tests/data-sources/schema.graphql: -------------------------------------------------------------------------------- 1 | type Data @entity { 2 | id: ID! 3 | foo: String 4 | bar: Int 5 | isTest: Boolean 6 | } 7 | -------------------------------------------------------------------------------- /tests/runner-tests/data-sources/src/mapping.ts: -------------------------------------------------------------------------------- 1 | import { BigInt, dataSource, ethereum, log } from "@graphprotocol/graph-ts"; 2 | import { Data } from "../generated/schema"; 3 | 4 | export function handleBlock(block: ethereum.Block): void { 5 | let foo = dataSource.context().getString("foo"); 6 | let bar = dataSource.context().getI32("bar"); 7 | let isTest = dataSource.context().getBoolean("isTest"); 8 | if (block.number == BigInt.fromI32(0)) { 9 | let data = new Data("0"); 10 | data.foo = foo; 11 | data.bar = bar; 12 | data.isTest = isTest; 13 | data.save(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tests/runner-tests/derived-loaders/abis/Contract.abi: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "anonymous": false, 4 | "inputs": [ 5 | { 6 | "indexed": false, 7 | "internalType": "string", 8 | "name": "testCommand", 9 | "type": "string" 10 | } 11 | ], 12 | "name": "TestEvent", 13 | "type": "event" 14 | } 15 | ] 16 | -------------------------------------------------------------------------------- /tests/runner-tests/derived-loaders/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "derived-loaders", 3 | "version": "0.1.0", 4 | "scripts": { 5 | "codegen": "graph codegen --skip-migrations", 6 | "create:test": "graph create test/derived-loaders --node $GRAPH_NODE_ADMIN_URI", 7 | "deploy:test": "graph deploy test/derived-loaders --version-label v0.0.1 --ipfs $IPFS_URI --node $GRAPH_NODE_ADMIN_URI" 8 | }, 9 | "devDependencies": { 10 | "@graphprotocol/graph-cli": "0.60.0", 11 | "@graphprotocol/graph-ts": "0.31.0" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /tests/runner-tests/derived-loaders/subgraph.yaml: -------------------------------------------------------------------------------- 1 | specVersion: 0.0.4 2 | schema: 3 | file: ./schema.graphql 4 | dataSources: 5 | - kind: ethereum/contract 6 | name: Contract 7 | network: test 8 | source: 9 | address: "0x0000000000000000000000000000000000000000" 10 | abi: Contract 11 | mapping: 12 | kind: ethereum/events 13 | apiVersion: 0.0.6 14 | language: wasm/assemblyscript 15 | abis: 16 | - name: Contract 17 | file: ./abis/Contract.abi 18 | entities: 19 | - Call 20 | eventHandlers: 21 | - event: TestEvent(string) 22 | handler: handleTestEvent 23 | file: ./src/mapping.ts 24 | -------------------------------------------------------------------------------- /tests/runner-tests/dynamic-data-source/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "dynamic-data-source", 3 | "version": "0.1.0", 4 | "scripts": { 5 | "codegen": "graph codegen --skip-migrations", 6 | "create:test": "graph create test/dynamic-data-source --node $GRAPH_NODE_ADMIN_URI", 7 | "deploy:test": "graph deploy test/dynamic-data-source --version-label v0.0.1 --ipfs $IPFS_URI --node $GRAPH_NODE_ADMIN_URI" 8 | }, 9 | "devDependencies": { 10 | "@graphprotocol/graph-cli": "0.60.0", 11 | "@graphprotocol/graph-ts": "0.31.0" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /tests/runner-tests/dynamic-data-source/schema.graphql: -------------------------------------------------------------------------------- 1 | type Foo @entity { 2 | id: ID! 3 | value: String! 4 | } 5 | -------------------------------------------------------------------------------- /tests/runner-tests/dynamic-data-source/src/mapping.ts: -------------------------------------------------------------------------------- 1 | import { Trigger } from "../generated/Contract/Contract"; 2 | import {Foo} from "../generated/schema"; 3 | 4 | 5 | export function handleTrigger(event: Trigger): void { 6 | let id = `${event.block.hash.toHexString()}${event.address.toHexString()}`; 7 | let foo = new Foo(id); 8 | foo.save(); 9 | } 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /tests/runner-tests/end-block/abis/Contract.abi: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "anonymous": false, 4 | "inputs": [ 5 | { 6 | "indexed": false, 7 | "internalType": "string", 8 | "name": "testCommand", 9 | "type": "string" 10 | } 11 | ], 12 | "name": "TestEvent", 13 | "type": "event" 14 | } 15 | ] 16 | -------------------------------------------------------------------------------- /tests/runner-tests/end-block/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "end-block", 3 | "version": "0.1.0", 4 | "scripts": { 5 | "codegen": "graph codegen --skip-migrations", 6 | "create:test": "graph create test/end-block --node $GRAPH_NODE_ADMIN_URI", 7 | "deploy:test": "graph deploy test/end-block --version-label v0.0.1 --ipfs $IPFS_URI --node $GRAPH_NODE_ADMIN_URI" 8 | }, 9 | "devDependencies": { 10 | "@graphprotocol/graph-cli": "0.54.0-alpha-20230727052453-1e0e6e5", 11 | "@graphprotocol/graph-ts": "0.30.0" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /tests/runner-tests/end-block/schema.graphql: -------------------------------------------------------------------------------- 1 | type Block @entity { 2 | id: ID! 3 | hash: String! 4 | number: BigInt! 5 | } 6 | 7 | type TestEventEntity @entity { 8 | id: ID! 9 | blockHash: String! 10 | blockNumber: BigInt! 11 | command: String! 12 | } 13 | -------------------------------------------------------------------------------- /tests/runner-tests/end-block/substreams-test-v1.0.1.spkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphprotocol/graph-node/94fb3f2825a66dd54c628c2866e3b1165d077576/tests/runner-tests/end-block/substreams-test-v1.0.1.spkg -------------------------------------------------------------------------------- /tests/runner-tests/fatal-error/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "fatal-error", 3 | "version": "0.1.0", 4 | "scripts": { 5 | "codegen": "graph codegen --skip-migrations", 6 | "create:test": "graph create test/fatal-error --node $GRAPH_NODE_ADMIN_URI", 7 | "deploy:test": "graph deploy test/fatal-error --version-label v0.0.1 --ipfs $IPFS_URI --node $GRAPH_NODE_ADMIN_URI" 8 | }, 9 | "devDependencies": { 10 | "@graphprotocol/graph-cli": "0.60.0", 11 | "@graphprotocol/graph-ts": "0.31.0" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /tests/runner-tests/fatal-error/schema.graphql: -------------------------------------------------------------------------------- 1 | type Call @entity { 2 | id: ID! 3 | value: String! 4 | } 5 | -------------------------------------------------------------------------------- /tests/runner-tests/fatal-error/src/mapping.ts: -------------------------------------------------------------------------------- 1 | import { ethereum } from "@graphprotocol/graph-ts"; 2 | 3 | export function handleBlock(block: ethereum.Block): void { 4 | if (block.number.toI32() == 3) { 5 | assert(false) 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /tests/runner-tests/fatal-error/subgraph.yaml: -------------------------------------------------------------------------------- 1 | specVersion: 0.0.4 2 | schema: 3 | file: ./schema.graphql 4 | dataSources: 5 | - kind: ethereum/contract 6 | name: Contract 7 | network: test 8 | source: 9 | address: "0xCfEB869F69431e42cdB54A4F4f105C19C080A601" 10 | abi: Contract 11 | mapping: 12 | kind: ethereum/events 13 | apiVersion: 0.0.6 14 | language: wasm/assemblyscript 15 | abis: 16 | - name: Contract 17 | file: ./abis/Contract.abi 18 | entities: 19 | - Call 20 | blockHandlers: 21 | - handler: handleBlock 22 | file: ./src/mapping.ts 23 | -------------------------------------------------------------------------------- /tests/runner-tests/file-data-sources/abis/Contract.abi: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "anonymous": false, 4 | "inputs": [ 5 | { 6 | "indexed": false, 7 | "internalType": "string", 8 | "name": "testCommand", 9 | "type": "string" 10 | }, 11 | { 12 | "indexed": false, 13 | "internalType": "string", 14 | "name": "data", 15 | "type": "string" 16 | } 17 | ], 18 | "name": "TestEvent", 19 | "type": "event" 20 | } 21 | ] 22 | -------------------------------------------------------------------------------- /tests/runner-tests/file-data-sources/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "file-data-sources", 3 | "version": "0.1.0", 4 | "scripts": { 5 | "codegen": "graph codegen --skip-migrations", 6 | "create:test": "graph create test/file-data-sources --node $GRAPH_NODE_ADMIN_URI", 7 | "deploy:test": "graph deploy test/file-data-sources --version-label v0.0.1 --ipfs $IPFS_URI --node $GRAPH_NODE_ADMIN_URI" 8 | }, 9 | "devDependencies": { 10 | "@graphprotocol/graph-cli": "0.60.0", 11 | "@graphprotocol/graph-ts": "0.31.0" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /tests/runner-tests/file-data-sources/schema.graphql: -------------------------------------------------------------------------------- 1 | type FileEntity @entity { 2 | id: ID! 3 | content: String! 4 | foo: Foo @relation 5 | } 6 | 7 | type Foo @entity { 8 | id: ID! 9 | ipfs: FileEntity @derivedFrom(field: "foo") 10 | } 11 | -------------------------------------------------------------------------------- /tests/runner-tests/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "workspaces": [ 4 | "*" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /tests/runner-tests/substreams/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | .idea 3 | src/pb/ 4 | node_modules/ -------------------------------------------------------------------------------- /tests/runner-tests/substreams/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "substreams-ethereum-quickstart" 3 | version = "1.0.0" 4 | edition = "2021" 5 | 6 | [lib] 7 | name = "substreams" 8 | crate-type = ["cdylib"] 9 | 10 | [dependencies] 11 | substreams = "0.5" 12 | substreams-ethereum = "0.9" 13 | substreams-entity-change = "1.3" 14 | 15 | [profile.release] 16 | lto = true 17 | opt-level = 's' 18 | strip = "debuginfo" 19 | -------------------------------------------------------------------------------- /tests/runner-tests/substreams/proto/example.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package example; 4 | 5 | message Contracts { 6 | repeated Contract contracts = 1; 7 | } 8 | 9 | message Contract { 10 | string address = 1; 11 | uint64 blockNumber = 2; 12 | string timestamp = 3; 13 | uint64 ordinal = 4; 14 | } -------------------------------------------------------------------------------- /tests/runner-tests/substreams/rust-toolchain.toml: -------------------------------------------------------------------------------- 1 | [toolchain] 2 | components = ["rustfmt"] 3 | targets = ["wasm32-unknown-unknown"] 4 | -------------------------------------------------------------------------------- /tests/runner-tests/substreams/schema.graphql: -------------------------------------------------------------------------------- 1 | type Contract @entity { 2 | id: ID! 3 | 4 | "The timestamp when the contract was deployed" 5 | timestamp: String! 6 | 7 | "The block number of the contract deployment" 8 | blockNumber: BigInt! 9 | } 10 | -------------------------------------------------------------------------------- /tests/runner-tests/substreams/subgraph.yaml: -------------------------------------------------------------------------------- 1 | specVersion: 0.0.4 2 | description: Ethereum Contract Tracking Subgraph (powered by Substreams) 3 | repository: https://github.com/graphprotocol/graph-tooling 4 | schema: 5 | file: schema.graphql 6 | dataSources: 7 | - kind: substreams 8 | name: substream_test 9 | network: test 10 | source: 11 | package: 12 | moduleName: graph_out 13 | file: substreams-test-v1.0.1.spkg 14 | mapping: 15 | kind: substreams/graph-entities 16 | apiVersion: 0.0.6 17 | -------------------------------------------------------------------------------- /tests/runner-tests/substreams/substreams-test-v1.0.1.spkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphprotocol/graph-node/94fb3f2825a66dd54c628c2866e3b1165d077576/tests/runner-tests/substreams/substreams-test-v1.0.1.spkg -------------------------------------------------------------------------------- /tests/runner-tests/typename/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "typename", 3 | "version": "0.1.0", 4 | "scripts": { 5 | "codegen": "graph codegen --skip-migrations", 6 | "create:test": "graph create test/typename --node $GRAPH_NODE_ADMIN_URI", 7 | "deploy:test": "graph deploy test/typename --version-label v0.0.1 --ipfs $IPFS_URI --node $GRAPH_NODE_ADMIN_URI" 8 | }, 9 | "devDependencies": { 10 | "@graphprotocol/graph-cli": "0.50.0", 11 | "@graphprotocol/graph-ts": "0.30.0" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /tests/runner-tests/typename/schema.graphql: -------------------------------------------------------------------------------- 1 | type ExampleEntity @entity { 2 | id: ID! 3 | } 4 | -------------------------------------------------------------------------------- /tests/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod config; 2 | pub mod contract; 3 | pub mod fixture; 4 | pub mod helpers; 5 | #[macro_use] 6 | pub mod macros; 7 | pub mod subgraph; 8 | 9 | pub use config::{Config, DbConfig, EthConfig, CONFIG}; 10 | --------------------------------------------------------------------------------