Skip to content

defi-wonderland/EBO-core

Repository files navigation

EBO - Epoch Block Oracle

Caution

The code has not been audited yet, tread with caution.

Caution

After the established thawing period the losing pledgers can withdraw their stake from Horizon.
Rewards from dispute escalations should be claimed or the losing pledgers slashed before that period ends to ensure that funds are available.

Overview

EBO is a mechanism for clock synchronization in the multichain world. It allows The Graph to permissionlessly sync up clocks between the protocol chain (Arbitrum) and multiple other chains supported by them to pay rewards to indexers.

Setup

This project uses Foundry. To build it locally, run:

git clone [email protected]:defi-wonderland/EBO-core.git
cd EBO-core
yarn install
yarn build

Available Commands

Make sure to set ARBITRUM_RPC environment variable before running end-to-end tests.

Yarn Command Description
yarn build Compile all contracts.
yarn coverage See forge coverage report.
yarn deploy:arbitrum Deploy the contracts to Arbitrum mainnet.
yarn test Run all unit and integration tests.
yarn test:unit Run unit tests.
yarn test:deep Run unit tests with 5000 fuzz runs.
yarn test:integration Run integration tests.

Design

EBO uses Prophet. A versatile and fully adaptable optimistic oracle solution that allows users to set custom modules to achieve the functionality they need. It works by implementing multiple modules to get the resulting block in other chains for an epoch in the protocol chain.

Modules

RequestModule

The custom EBORequestModule holds the parameters for the request. Including the epoch and the requested chain to fetch the data.

ResponseModule

EBO uses the BondedResponseModule built for Prophet which allows users to respond to a request by locking a bond.

DisputeModule

Prophet's BondEscalationModule is used to solve disputes by starting a bond escalation process.

ResolutionModule

ArbitratorModule allows an arbitrator appointed by The Graph's council to be the ultimate source of truth in case a dispute can't be closed by bond escalation.

FinalityModule

The new EBOFinalityModule emits events with the finalized data so it can be indexed by a subgraph.

Periphery

AccountingExtension

Provides integration with The Graph's Horizon Staking contract for bonding tokens.

EBORequestCreator

Simplifies request creation and validates requested data.

Warning

Only allows one pair of epoch-chainId request to be active at a time.

CouncilArbitrator

Simplifies the interaction by The Graph's arbitrator with the ResolutionModule by doing multiple actions in one transaction.

Flows

Alt text

Setup

  1. Install Foundry by following the instructions from their repository.
  2. Copy the .env.example file to .env and fill in the variables.
  3. Install the dependencies by running: yarn install. In case there is an error with the commands, run foundryup and try them again.

Build

The default way to build the code is suboptimal but fast, you can run it via:

yarn build

In order to build a more optimized code (via IR), run:

yarn build:optimized

Running tests

Unit tests should be isolated from any externalities, while Integration usually run in a fork of the blockchain. In this boilerplate you will find example of both.

In order to run both unit and integration tests, run:

yarn test

In order to just run unit tests, run:

yarn test:unit

In order to run unit tests and run way more fuzzing than usual (5x), run:

yarn test:unit:deep

In order to just run integration tests, run:

yarn test:integration

In order to just run the echidna fuzzing campaign (requires Echidna installed), run:

yarn test:fuzz

In order to just run the symbolic execution tests (requires Halmos installed), run:

yarn test:symbolic

In order to check your current code coverage, run:

yarn coverage

Deploy & verify

Setup

Configure the .env variables.

Import your private keys into Foundry's encrypted keystore:

cast wallet import $ARBITRUM_DEPLOYER_NAME --interactive

Arbitrum

yarn deploy:arbitrum

The deployments are stored in ./broadcast

See the Foundry Book for available options.

Licensing

The primary license for EBO contracts is GPL-3.0, see LICENSE.

Contributors

EBO was built with ❤️ by Wonderland.

Wonderland is a team of top Web3 researchers, developers, and operators who believe that the future needs to be open-source, permissionless, and decentralized.

DeFi sucks, but Wonderland is here to make it better.

About

Epoch Block Oracle contracts

Resources

License

Stars

Watchers

Forks

Languages