3 Sep 2021
Timestamps and Info:
In Developer Highlights #6 I had the pleasure of speaking with Petko Pavlovski "Aximoatic Aardvark" from Limechain. Limechain delivers professional Blockchain & DLT services for enterprises and entrepreneurs.
Many of you already know Petko from the discord community, as he frequently helps other members. Petko has been working on Matchstick - a unit testing framework for The Graph. This is a gamechanger for subgraph development! You can now test changes to your code in mere milliseconds.
In this video we cover everything you need to know about Matchstick. From installing to writing different tests.
Watch the full episode, or jump straight to each topic using the timestamps below
00:00 Intro - Limechain
Matchstick
02:36 Why use Matchstick?
03:45 Example Subgraph
05:53 Installing Matchstick
Mock Event
08:11 Writing a test
09:55 Instantiating a mock event
12:38 Calling a handler
13:20 Writing an assertion
14:30 Clearing the store
14:58 Export runTests() in the mappings
15:28 Running a test
16:54 What a failed test look like
Hydrated Store
17:36 Hydrating the store with a certain state
19:00 Running a test on the hydrated store
Mock Function
19:38 Github repository with examples
20:18 Example mapping
21:09 Mocking a smart contract function
24:06 Calling the mocked function
26:55 Forcing a function to revert
Logging
28:44 Shell Script for "Build and Test"
29:19 Test execution time
29:55 Logging
31:38 Assert helper functions
32:42 Different logging functions
Other Topics
33:48 Event metadata
35:41 Matchstick channel in The Graph Discord
36:01 Github improvement board
Limechain: https://limechain.tech
Matchstick Repository: https://github.com/LimeChain/matchstick/
Demo Repository: https://github.com/LimeChain/demo-subgraph
Matchstick Tutorial https://limechain.tech/blog/matchstick-what-it-is-and-how-to-use-it/
In Developer Highlights #6 I had the pleasure of speaking with Petko Pavlovski "Aximoatic Aardvark" from Limechain. Limechain delivers professional Blockchain & DLT services for enterprises and entrepreneurs.
Many of you already know Petko from the discord community, as he frequently helps other members. Petko has been working on Matchstick - a unit testing framework for The Graph. This is a gamechanger for subgraph development! You can now test changes to your code in mere milliseconds.
In this video we cover everything you need to know about Matchstick. From installing to writing different tests.
Watch the full episode, or jump straight to each topic using the timestamps below
00:00 Intro - Limechain
Matchstick
02:36 Why use Matchstick?
03:45 Example Subgraph
05:53 Installing Matchstick
Mock Event
08:11 Writing a test
09:55 Instantiating a mock event
12:38 Calling a handler
13:20 Writing an assertion
14:30 Clearing the store
14:58 Export runTests() in the mappings
15:28 Running a test
16:54 What a failed test look like
Hydrated Store
17:36 Hydrating the store with a certain state
19:00 Running a test on the hydrated store
Mock Function
19:38 Github repository with examples
20:18 Example mapping
21:09 Mocking a smart contract function
24:06 Calling the mocked function
26:55 Forcing a function to revert
Logging
28:44 Shell Script for "Build and Test"
29:19 Test execution time
29:55 Logging
31:38 Assert helper functions
32:42 Different logging functions
Other Topics
33:48 Event metadata
35:41 Matchstick channel in The Graph Discord
36:01 Github improvement board
Limechain: https://limechain.tech
Matchstick Repository: https://github.com/LimeChain/matchstick/
Demo Repository: https://github.com/LimeChain/demo-subgraph
Matchstick Tutorial https://limechain.tech/blog/matchstick-what-it-is-and-how-to-use-it/
- 2 participants
- 37 minutes
2 Aug 2021
Timestamps and Info:
In Developer Highlights #5 we invite David from Synthetix to talk about Supporting Multiple Networks
Synthetix is a protocol that enables the issuance of synthetic assets on the Ethereum blockchain. This allows anyone, anywhere to gain on-chain exposure to a vast range of assets.
https://synthetix.io
Synthetix are developing their subgraphs with a microservice approach. They have 13 "subgraph bundles", most of which are indexing multiple networks. In total they manage an impressive 46 subgraphs across 4 networks. They manage their subgraphs using javascript. We discuss the benefits of their approach, and David gives us an introduction to their code. Are you managing a large number of subgraphs for your dApp? If so, I highly recommend watching the full video, and to study synthetix' codebase.
We also talk about indexing Proxy Contracts, and the benefits of having the proxy contract itself emit an event whenever an underlying contract is changed. Synthetix have found a very smart way to track updates to the chainlink price feeds. If you rely on chainlink price feeds, this segment is a must-watch.
Watch the full episode, or jump straight to each topic using the timestamps below.
00:00 Introduction
Supporting Multiple Networks
04:02 46 subgraphs
06:19 Benefits of using multiple subgraphs
08:15 Using Javascript instead of yaml
11:30 Benefits of using javascript over mustache
Synthetix' Subgraph Code
15:01 Version json file
18:50 Scripts for Build and Deploy
23:18 Synthetix repository
24:37 Curating Subgraphs
26:54 Handling Chainlink rates - Code Fragment
Proxies and Chainlink price feeds.
32:25 Subgraph development advice
33:38 Proxy Contracts emitting events
35:24 Tracking Chainlink Proxies
39:21 Chainlink on Optimism
In Developer Highlights #5 we invite David from Synthetix to talk about Supporting Multiple Networks
Synthetix is a protocol that enables the issuance of synthetic assets on the Ethereum blockchain. This allows anyone, anywhere to gain on-chain exposure to a vast range of assets.
https://synthetix.io
Synthetix are developing their subgraphs with a microservice approach. They have 13 "subgraph bundles", most of which are indexing multiple networks. In total they manage an impressive 46 subgraphs across 4 networks. They manage their subgraphs using javascript. We discuss the benefits of their approach, and David gives us an introduction to their code. Are you managing a large number of subgraphs for your dApp? If so, I highly recommend watching the full video, and to study synthetix' codebase.
We also talk about indexing Proxy Contracts, and the benefits of having the proxy contract itself emit an event whenever an underlying contract is changed. Synthetix have found a very smart way to track updates to the chainlink price feeds. If you rely on chainlink price feeds, this segment is a must-watch.
Watch the full episode, or jump straight to each topic using the timestamps below.
00:00 Introduction
Supporting Multiple Networks
04:02 46 subgraphs
06:19 Benefits of using multiple subgraphs
08:15 Using Javascript instead of yaml
11:30 Benefits of using javascript over mustache
Synthetix' Subgraph Code
15:01 Version json file
18:50 Scripts for Build and Deploy
23:18 Synthetix repository
24:37 Curating Subgraphs
26:54 Handling Chainlink rates - Code Fragment
Proxies and Chainlink price feeds.
32:25 Subgraph development advice
33:38 Proxy Contracts emitting events
35:24 Tracking Chainlink Proxies
39:21 Chainlink on Optimism
- 2 participants
- 41 minutes
5 Jul 2021
Timestamps and Info:
In Developer Highlights #4, we get to speak to Nacho Mazzara, Engineering manager at Decentraland and Co-Founder of pine.finance.
Decentraland is a fully decentralized world owned by its users. The world is continously evolving, and last month they launched their Wearables Editor. This that lets anyone create and publish their own "Wearables" and "Collections". In this episode, we learn how the collections are created using a "factory" type contract, and how decentraland is using templates to dynamically index these contracts.
pine.finance was born at ETH Berlin 2019. It is a protocol for automated and decentralized limit orders on any DEX. The creation of limit orders are done using a regular ERC20 transfer, with added extra data. This lets users forego the approval function, saving gas and time.
Watch the full episode, or jump straight to each topic using the timestamps below.
00:00 Introduction
01:36 Templates - Initializing data sources
06:35 Templates - Indexing dynamically created data sources
07:36 Decentraland - How a collection gets created
10:58 Decentraland - Fetching data from an api
14:56 Decentraland - How data- and imagefiles are handled.
20:12 Pine.Finance - Deterministic contracts using CREATE2
21:38 Pine.Finance - Using a single transfer to create a DEX limit order
24:44 Mappings - Using extra data to create mappings
30:42 Pine.Finance - Requiring higher gas limit than net gas used.
34:31 Pine.Finance - Benefits of utilizing a normal transaction
36:09 Pine.Finance - Relayers
38:01 Pine.Finance - A drawback of utilizing extra data
In Developer Highlights #4, we get to speak to Nacho Mazzara, Engineering manager at Decentraland and Co-Founder of pine.finance.
Decentraland is a fully decentralized world owned by its users. The world is continously evolving, and last month they launched their Wearables Editor. This that lets anyone create and publish their own "Wearables" and "Collections". In this episode, we learn how the collections are created using a "factory" type contract, and how decentraland is using templates to dynamically index these contracts.
pine.finance was born at ETH Berlin 2019. It is a protocol for automated and decentralized limit orders on any DEX. The creation of limit orders are done using a regular ERC20 transfer, with added extra data. This lets users forego the approval function, saving gas and time.
Watch the full episode, or jump straight to each topic using the timestamps below.
00:00 Introduction
01:36 Templates - Initializing data sources
06:35 Templates - Indexing dynamically created data sources
07:36 Decentraland - How a collection gets created
10:58 Decentraland - Fetching data from an api
14:56 Decentraland - How data- and imagefiles are handled.
20:12 Pine.Finance - Deterministic contracts using CREATE2
21:38 Pine.Finance - Using a single transfer to create a DEX limit order
24:44 Mappings - Using extra data to create mappings
30:42 Pine.Finance - Requiring higher gas limit than net gas used.
34:31 Pine.Finance - Benefits of utilizing a normal transaction
36:09 Pine.Finance - Relayers
38:01 Pine.Finance - A drawback of utilizing extra data
- 2 participants
- 39 minutes
7 Jun 2021
Timestamps and Info:
Developer Highlights #3 | “Building ambitious subgraphs” Part 2
Sebastian Siemssen & Ivan Herger | Enzyme Finance
In the third Developer Highlights, we continue our talk with Ivan Herger and Sebastian Siemssen from Enzyme Finance. If you haven't seen the first part, I highly recommend checking it out:
https://youtu.be/4V2o5YJooOM
In this part we take on our most requested topic for developer highlights - subgraph performance. Ivan and Sebastian have two years of experience making subgraphs for Enzyme Finance. Learn how they have optimized their subgraph to meet the scaling requirements of a truly ambitious DeFi subgraph.
00:00 Overview
Performance Tips - Manifest
02:25 Setting a startblock
03:44 Choosing what handlers to use
04:11 Avoiding contract calls
05:13 Contract calls are run at block number
08:12 Avoid block handlers
10:45 Filtering events in the manifest
12:46 Observing all ERC20 Transfer Events
Performance Tips - Mappings
14:36 Filtering events in the mappings
17:21 Avoiding redundancy with "internal" data
19:13 Saving entities without loading
20:08 Using helper Functions.
23:53 Save/Load calls are cached
Performance Tips - Schema
25:38 Reverse Lookups (derivedFrom)
27:33 Reverse Lookups example
28:32 Using the Schema to store state (counting+)
31:02 Subgraph design trick - Makeshift cron handler
Performance Tips - Querying
32:20 Include both lower and upper bounds
Timeseries data tracking
34:51 Using timewindows
37:19 Timewindows in the schema
40:29 Benefits of using timewindows
41:06 Using timewindows for tracking other states
43:18 Daily and hourly timewindows
44:22 Querying timeranges using time-travel queries
47:30 Loading the last record of the previous timewindow
AssemblyScript Quirks
50:42 Array utilities
52:54 Assemblyscript array bug
54:03 Scope not being inherited into closures
55:33 Other utilities
Developer Highlights #3 | “Building ambitious subgraphs” Part 2
Sebastian Siemssen & Ivan Herger | Enzyme Finance
In the third Developer Highlights, we continue our talk with Ivan Herger and Sebastian Siemssen from Enzyme Finance. If you haven't seen the first part, I highly recommend checking it out:
https://youtu.be/4V2o5YJooOM
In this part we take on our most requested topic for developer highlights - subgraph performance. Ivan and Sebastian have two years of experience making subgraphs for Enzyme Finance. Learn how they have optimized their subgraph to meet the scaling requirements of a truly ambitious DeFi subgraph.
00:00 Overview
Performance Tips - Manifest
02:25 Setting a startblock
03:44 Choosing what handlers to use
04:11 Avoiding contract calls
05:13 Contract calls are run at block number
08:12 Avoid block handlers
10:45 Filtering events in the manifest
12:46 Observing all ERC20 Transfer Events
Performance Tips - Mappings
14:36 Filtering events in the mappings
17:21 Avoiding redundancy with "internal" data
19:13 Saving entities without loading
20:08 Using helper Functions.
23:53 Save/Load calls are cached
Performance Tips - Schema
25:38 Reverse Lookups (derivedFrom)
27:33 Reverse Lookups example
28:32 Using the Schema to store state (counting+)
31:02 Subgraph design trick - Makeshift cron handler
Performance Tips - Querying
32:20 Include both lower and upper bounds
Timeseries data tracking
34:51 Using timewindows
37:19 Timewindows in the schema
40:29 Benefits of using timewindows
41:06 Using timewindows for tracking other states
43:18 Daily and hourly timewindows
44:22 Querying timeranges using time-travel queries
47:30 Loading the last record of the previous timewindow
AssemblyScript Quirks
50:42 Array utilities
52:54 Assemblyscript array bug
54:03 Scope not being inherited into closures
55:33 Other utilities
- 3 participants
- 58 minutes
3 May 2021
Timestamps and Info:
Developer Highlights #2 | “Building ambitious subgraphs” Part 1
Sebastian Siemssen & Ivan Herger | Enzyme Finance
For the second Developer Highlights, we get to speak with Sebastian Siemssen & Ivan Herger.
Ivan and Sebastian are long time members and developers in our community and have been working on subgraphs for Enzyme Finance (formerly Melon Protocol) for more than 2 years. They are going to share the challenges they faced and the lessons they learned along the way. In this episode we’ll explore some of the more demanding event tracking, data aggregation and scaling requirements of a DeFi subgraph and the patterns and solutions they came up with to solve them.
This is the first of two parts. You can find the second part here:
https://www.youtube.com/watch?v=4V2o5YJooOM
00:00 Episode overview
02:54 Enzyme Finance - Protocol overview
09:43 Enzyme Finance - How subgraphs are used
17:06 Enzyme Finance - How the subgraph performance have increased
19:39 Smart Contract Design - Write events with data retrieval in mind
23:18 Smart Contract Design - Upgradable contracts (proxy pattern)
25:40 Schema Design - Build the schema close to the data Requirements
27:11 Schema Design - Limitations to filter and sort
30:21 Schema Design - Low/High level data
32:22 Schema Design - Upgradable Protocols
33:58 Pagination - Capabilities and limitations
38:23 Pagination - Exactly-once Guarantees
40:38 Pagination - Counting
42:01 Avoiding Fatal Errors - About
45:03 Avoiding Fatal Errors - Try/catch
49:25 Avoiding Fatal Errors - Don't throw exceptions
51:06 Avoiding Fatal Errors - nonFatalErrors
54:02 Avoiding Fatal Errors - Required properties in the schema
55:55 Mappings - Save/Load performance Impact
00:57:20 Interfaces - An often missed feature
00:58:40 Interfaces - Union Types
01:00:45 Interfaces - Type Field
01:02:41 Interfaces - Entity Utils
The Graph Webpage: https://thegraph.com/
The Graph Discord https://discord.gg/vtvv7FP
The Graph Forum: https://forum.thegraph.com/
Developer Highlights #2 | “Building ambitious subgraphs” Part 1
Sebastian Siemssen & Ivan Herger | Enzyme Finance
For the second Developer Highlights, we get to speak with Sebastian Siemssen & Ivan Herger.
Ivan and Sebastian are long time members and developers in our community and have been working on subgraphs for Enzyme Finance (formerly Melon Protocol) for more than 2 years. They are going to share the challenges they faced and the lessons they learned along the way. In this episode we’ll explore some of the more demanding event tracking, data aggregation and scaling requirements of a DeFi subgraph and the patterns and solutions they came up with to solve them.
This is the first of two parts. You can find the second part here:
https://www.youtube.com/watch?v=4V2o5YJooOM
00:00 Episode overview
02:54 Enzyme Finance - Protocol overview
09:43 Enzyme Finance - How subgraphs are used
17:06 Enzyme Finance - How the subgraph performance have increased
19:39 Smart Contract Design - Write events with data retrieval in mind
23:18 Smart Contract Design - Upgradable contracts (proxy pattern)
25:40 Schema Design - Build the schema close to the data Requirements
27:11 Schema Design - Limitations to filter and sort
30:21 Schema Design - Low/High level data
32:22 Schema Design - Upgradable Protocols
33:58 Pagination - Capabilities and limitations
38:23 Pagination - Exactly-once Guarantees
40:38 Pagination - Counting
42:01 Avoiding Fatal Errors - About
45:03 Avoiding Fatal Errors - Try/catch
49:25 Avoiding Fatal Errors - Don't throw exceptions
51:06 Avoiding Fatal Errors - nonFatalErrors
54:02 Avoiding Fatal Errors - Required properties in the schema
55:55 Mappings - Save/Load performance Impact
00:57:20 Interfaces - An often missed feature
00:58:40 Interfaces - Union Types
01:00:45 Interfaces - Type Field
01:02:41 Interfaces - Entity Utils
The Graph Webpage: https://thegraph.com/
The Graph Discord https://discord.gg/vtvv7FP
The Graph Forum: https://forum.thegraph.com/
- 3 participants
- 1:04 hours
5 Apr 2021
Juanmardefago will teach us how we can utilize dynamic data sources (templates) to make our subgraph a bit more future proof. If your dApp deploys contracts using a Factory or Proxy patterns, this video will be invaluable to you! Through a practical example, you will learn to leverage templates in your own subgraph, as well as learn the limitations of this method.
00:00 Intro
03:46 Using templates
17:42 What handlers can be used?
19:43 What are the benefits of using an event handler?
28:48 Can you filter which contracts are indexed?
31:35 Using templates with proxies
32:42 What are proxies ?
35:13 What if a new datasource need data from prior blocks?
37:36 Possible workaround.
The Graph Webpage: https://thegraph.com/
The Graph Discord https://discord.gg/vtvv7FP
The Graph Forum: https://forum.thegraph.com/
00:00 Intro
03:46 Using templates
17:42 What handlers can be used?
19:43 What are the benefits of using an event handler?
28:48 Can you filter which contracts are indexed?
31:35 Using templates with proxies
32:42 What are proxies ?
35:13 What if a new datasource need data from prior blocks?
37:36 Possible workaround.
The Graph Webpage: https://thegraph.com/
The Graph Discord https://discord.gg/vtvv7FP
The Graph Forum: https://forum.thegraph.com/
- 2 participants
- 42 minutes