This repository hosts a tool for deploying Chainlink price feeds into the LocalTerra ecosystem along with a CLI utility for mocking Chainlink Oracle prices Chainlink Data Feeds within LocalTerra.
- Chainlink feeds deployer - Since today LocalTerra comes without any of the main-net/testnets history or data, meaning dApps using Chainlink have no way of testing their integration with Chainlink. Chainlink deployer answer that by deploying oracle price feeds to LocalTerra on its start.
- CLI - a tool designed to give developers control of the Chainlink feeds within LocalTerra. This will enable truly integration and e2e testing for Chainlink dependent dApps.
Navigate to our Quickstart section to get the repo up and running.
For a full deep dive to the project architecture please visit the Chaos Labs blog.
Oracle return values trigger internal state changes in web3 applications. When working on local development environment, once feeds are deployed, the return values are constant. This is because the Chainlink protocol only writes updated values to mainnet or public testnets. Chaos Labs aims to streamline developer productivity while also making it easier to test applications, This tool gives developers the ability to mock return values easily. Now we can test how our contracts / applications react to different types of external data ๐ค. Below, we provide some specific use cases for mocking oracle return values.
LocalChainlink is build for dApp developers to better test the application's integration flows with chainlink. By mocking the returned price developers can test their application's behavior in various market conditions both in development phase as well as part of their CI\CD pipelines.
Moreover, DeFi protocols and applications are at high risk due to volatile market conditions and a myriad of security vectors. Mocking Chainlink Oracle return values in a controlled, siloed testing environment allows us to address 2 common vectors.
Volatility is a DeFi constant and is something that all protocols and applications should test for thoroughly. Internal application and protocol state is often a direct result of Oracle returns values. To further illustrate this let's use an example.
Imagine a lending protocol (Maker, AAVE, Benqi, Spectral.finance, etc..) that accepts Ethereum as collateral against stablecoin loans. What happens on a day like Black Thursday, when Ethereum prices cascade negatively to the tune of ~70% in a 48 hour time frame? Well, a lot of things happen ๐คฆ.
One critical aspect of responding to market volatility is protocol keepers triggering liquidations and thus ensuring protocol solvency.
With the ability to control Oracle return values, simulating such scenarios in your local development environment is possible.
Oracle manipulation is an additional attack vector. With this method, malicious actors research data sources that various oracle consume as sources of truth. When actors possess the ability to manipulate the underlying data source they trigger downstream effects, manifesting in altered Oracle return values. As a result of manipulated data, actors and contracts can trigger various unwanted behaviors such as modified permissions, transaction execution, emergency pausing / shutdown and more.
With the ability to manipulate Chainlink Oracle return values, simulating such scenarios in your local development environment is possible.
node
(version 16.14)docker
docker-compose
typescript
installed globally such that the tsc compiler is availablets-node
git clone https://github.com/ChaosLabsInc/LocalChainlink.git
cd LocalChainlink
npm i
- Installing project libs- In a separate terminal window (spwan a new window in iTerm with cdm+D) run:
docker-compose up
npm run cli
After running the quickstart you should have the following: 2 terminals, 1 running docker-compose of localterra with chainlink depolyer, another running the cli-tool and it should look like this:
Once Chainlink LUNA\USD feed is deployed the terminal will look as follows:
This repo is meant to serve as an implementation spec for deploying price feeds and mocking oracle return values. This is a resource and reference for smart contract developers to implement such strategies and practices as part of their development lifecycle.
- View the deployed price feeds addresses
- Mock price for selected price feed a. select the price feed to configure b. Set the desired price value returned by the price feed c. Mock ๐ค ๐ฅ
- Deploy new price feed a. enter the feed name b. set initial price for feed c. set feed decimals d. deploy
- Start LocalTerra:
$ docker-compose up
Reset the world state:
$ docker-compose up
Before submitting a PR please run the test suite with npm run test.
CLI improvements. Have an idea to make this repo more user friendly? Let us know, or better yet, make a pull request :)