Skip to content
streamflow
Switch branches/tags
Code

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
Apr 25, 2017

CircleCI Coverage Status

Livepeer Protocol

Ethereum smart contracts used for the Livepeer protocol. These contracts govern the logic for:

  • Livepeer Token (LPT) ownership
  • Bonding and delegating LPT to elect active workers
  • Distributing inflationary rewards and fees to active participants
  • Time progression in the protocol
  • ETH escrow and ticket validation for a probabilistic micropayment protocol used to pay for transcoding work

Documentation

For a general overview of the protocol see:

The contracts are based off of the technical protocol specification.

Development

All contributions and bug fixes are welcome as pull requests back into the repo.

ERC20 Note

The Livepeer token is implemented as an ERC20 token in token/LivepeerToken.sol which inherits from the OpenZeppelin ERC20 token contract and all implemented ERC20 functions will revert if the operation is not successful. However, the ERC20 spec does not require functions to revert and instead requires functions to return true if the operation succeed and false if the operation fails. The contracts bonding/BondingManager.sol and token/Minter.sol do not check the return value of ERC20 functions and instead assume that they will revert if the operation fails. The Livepeer token contract is already deployed on mainnet and its implementation should not change so this is not a problem. However, if for some reason the implementation ever does change, developers should keep in mind that bonding/BondingManager.sol and token/Minter.sol do not check the return value of ERC20 functions.

ABIEncoderV2 Note

At the moment, the following contract files use the experimental ABIEncoderV2 Solidity compiler feature:

  • pm/TicketBroker.sol
  • pm/MReserve.sol
  • pm/MixinReserve.sol
  • pm/MixinTicketBrokerCore.sol
  • pm/MixinWrappers.sol

There have been bugs related to ABIEncoderV2 in the past and it is still experimental so developers should pay attention to the list of bugs associated with ABIEncoderV2 when making any contract code changes that involve ABIEncoderV2 and should make sure to use a compiler version with the necessary fixes. The primary motivation behind enabling ABIEncoderV2 in these contract files is to allow for Solidity structs to be passed as function arguments.

Install

Make sure Node.js v10.17.0 is installed.

git clone https://github.com/livepeer/protocol.git
cd protocol
npm install

Build

Compile the contracts and build artifacts used for testing and deployment.

npm run compile

Clean

Remove existing build artifacts.

npm run clean

Lint

The project uses ESLint for Javascript linting and Solium for Solidity linting.

npm run lint

Run Tests

All tests will be executed against an instance of ganache-cli.

To run all tests:

npm run test

To run unit tests only:

npm run test:unit

To run integration tests only:

npm run test:integration

To run gas reporting tests (via eth-gas-reporter) only:

npm run test:gas

To run tests with coverage (via solidity-coverage) reporting:

npm run test:coverage

Deployment

Make sure that an ETH node is accessible and that the network being deployed to is supported by the truffle.js configuration.

npm run migrate