Skip to content

Releases: graphprotocol/graph-tooling

v0.16.0

01 Nov 12:32
Compare
Choose a tag to compare

Start block for data sources

Until now, subgraphs were always indexing from the genesis block. This involved scanning the entire chain for relevant blocks, logs and traces, even if the subgraph contracts were only deployed recently.

This was fine initially. However, with more expensive features—such as block and call handlers—being added and more advanced subgraphs being developed, it has often become desirable to skip irrelevant old blocks entirely to speed up indexing.

This is now possible. As of this release, data sources can specify an optional startBlock number in the manifest:

dataSources:
  - name: Gravity
    source:
      address: '0x2E645469f354BB4F5c8a05B3b30A929361cf77eC'
      abi: Gravity
      startBlock: 6000000

The subgraph will then start indexing from this block. If there are multiple data sources with or without start blocks, the earliest of these blocks is used as the starting point. The absence of a startBlock is equivalent to 0 (aka the genesis block).

Other changes

  • Fix exit codes used in graph deploy command.
  • Validate data source network fields. Data sources (and templates) must either have no network set or they must all use the same network value.
  • Dependency updates (glob, tern, jayson, graphql, yaml, eslint).

v0.15.3

22 Oct 08:50
Compare
Choose a tag to compare
  • Remove local code that was accidentally included in v0.15.2.

v0.15.2

17 Oct 17:16
Compare
Choose a tag to compare
  • Fix identifying the subgraph source directory, going upwards from subgraph.yaml (#365).

v0.15.1

04 Oct 16:25
Compare
Choose a tag to compare
  • Catch non-unique data source names (#352).
  • Do not assume that source directory and working directory are the same (#360).

v0.15.0

03 Sep 17:36
Compare
Choose a tag to compare

Fallible contract calls (#332)

Calls to contract functions can fail due to assertions in the contract. Until now there was no way to handle this in subgraphs gracefully. This release introduces new try_someContractFunction call variants that return a result object with reverted and value fields. These can then be used in mappings to handle call failures.

An example can be found in the documentation.

Top-level templates (#319)

Data source templates have been moved to a top-level templates field in the manifest. The data source templates documentation has been updated accordingly.

Top-level templates simplify creating new data sources at runtime: templates can now be referred to from all data sources and can create new data sources from other templates as well.

This also affects subgraph validation and code generation in a few ways. While Graph Node >= 0.15.0 still allows subgraphs with nested templates to run, Graph CLI now rejects such subgraphs. Code generation now puts all generated template classes into a single templates.ts file.

Other Changes

  • Only upload files to IPFS once if they are used in manifests multiple times (#337).
  • Fix subgraph migrations to replace all apiVersion occurrences in manifests (#337).
  • Add support for arrays of Ethereum tuples / Solidity structs (#320).
  • Update dependencies: graphql, ipfs-http-client, gluegun, eslint, jest, eslint-utils, mixin-deep, keytar, lodash.

v0.12.0

16 May 10:26
Compare
Choose a tag to compare

Changes

  • graph init: Skip Etherscan if --abi is provided (#263).
  • graph init: Improve error when an ABI is not found on Etherscan (#266, #267).
  • graph codegen: Fix ugly uncaught exception errors being printed (#262).
  • graph codegen: Add notes in generated files about files being auto-generated (#212, #268).
  • graph codegen: Do not generate code for calling contract functions with no return values (#270, contribution by @fubhy).
  • Fail subgraph validation if callHandler functions are not found in ABIs (#265).
  • Improve type suggestions for fields in the schema for integer/float types (#210, #269).
  • Bump node-keytar dependency from 4.3.0 to 4.6.0 to be able to build on Node.js 12.
  • Add log calls to the example to test compiling subgraphs that use logging.

v0.11.2

09 May 10:40
Compare
Choose a tag to compare

Fix two code generation / name disambiguation bugs that only surfaced after the previous releases had been made.

v0.11.1

09 May 09:45
Compare
Choose a tag to compare

Reduce the package size compared to v0.11.0.

v0.11.0

09 May 09:44
Compare
Choose a tag to compare

Block, transaction and call handlers

Until now, the only triggers for indexing were events. This release adds support for triggering based on blocks and transactions/calls in the form of blockHandlers and callHandlers (in addition to the existing eventHandlers).

From the documentation:

Call Handlers

While events provide an effective way to collect relevant changes to the state of a contract, many contracts avoid generating logs to optimize gas costs. In these cases, a subgraph can subscribe to calls made to the data source contract. This is achieved by defining call handlers referencing the function signature and the mapping handler that will process calls to this function. To process these calls, the mapping handler will receive an EthereumCall as an argument with the typed inputs to and outputs from the call. Calls made at any depth in a transaction's call chain will trigger the mapping, allowing activity with the data source contract through proxy contracts to be captured.

To define a call handler in your manifest simply add a callHandlers array under the data source you would like to subscribe to.

callHandlers:
  - function: createGravatar(string,string)
    handler: handleCreateGravatar

For all applicable functions in contract ABIs, graph codegen now generates dedicated classes, e.g. CreateGravatarCall. These provide access to the address of the contract that was called, the block and transaction that the call happened in as well as typed inputs and outputs for function parameters and return values.

On block handlers:

Block Handlers

In addition to subscribing to contract events or function calls, a subgraph may want to update its data as new blocks are appended to the chain. To achieve this a subgraph can run a function after every block or after blocks that match a predefined filter.

The absense of a filter for a block handler will ensure that the handler is called every block.

A data source can only contain one block handler for each filter type.

blockHandlers:
  - handler: handleBlock
  - handler: handleBlockWithCallToContract
    filter:
      kind: call

For more information about how to define and write call and block handlers, please refer to the documentation.

Note: This feature requires Parity archive nodes with the trace API enabled.

Other changes

  • Fix graph init being called with --abi (#255, #256).
  • Disambiguate event, function, input, output and tuple member names in generated code (#168, #260).
  • Bump graph-ts in subgraphs created by graph init to 0.11.0 (#257).

v0.10.0

25 Apr 15:01
Compare
Choose a tag to compare

Dynamic data sources

Also referred to as dynamic contract subscriptions, as this is currently the main use case.

This feature supports creating new data sources from templates while indexing the subgraph. The motivation behind this is to provide a natural way of indexing registry/factory contracts that reference many other (sub)contracts.

See Define a Subgraph: Dynamic Data Sources in the docs for more details.

On the Graph CLI side of things, validation of data source templates and code generation for data source templates were added.

Anonymous events

Anonymous Solidity events are used by projects like Maker. Supporting them requires filtering events not by their usual signature (e.g. Transfer(address,address)) but by their topic 0 value.

This version adds support for that by allowing event handlers to specify the topic0 value to filter by. For more information see Define a Subgraph: Anonymous Events in the docs.

Other changes

  • Make the keytar dependency optional. Thanks to @iameli from Livepeer for the contribution!
  • Add support for overloaded events and functions by generating code without duplicate types.
  • Fix loading subgraphs in --watch mode.
  • Bump AssemblyScript to AssemblyScript/assemblyscript@36040d5b5312f19a025782b5e366.
  • Add ESLint configuration.