livepeer / protocol

Livepeer protocol
MIT License
154 stars 45 forks source link

Allow BondingManager users to provide hints for staking actions #350

Closed yondonfu closed 4 years ago

yondonfu commented 4 years ago

This PR allows users of BondingManager to provide hints for staking actions. A hint consists of the address of the previous transcoder in transcoderPool and the address of the next transcoder in transcoderPool. A hint can be calculated by a client off-chain in order to reduce the gas costs for a staking action when the delegate/caller is already in the pool or is about to join the pool - if the hint is the correct insertion position then no linear search is required and if the hint is incorrect (i.e. because the pool ordering changed in between the time of hint calculation and tx inclusion) the contract will start the linear search from the hint.

No functions are removed, but the following functions are added:

Each of these functions correspond to an existing external function that does not allow hints to be passed.

I included the gas report additions from the nv/gas-report branch with a few tweaks (speed up tests, clearer flow, etc.).

Fixes #348

coveralls commented 4 years ago

Pull Request Test Coverage Report for Build 1203


Totals Coverage Status
Change from base Build 1192: 0.0%
Covered Lines: 686
Relevant Lines: 686

💛 - Coveralls
yondonfu commented 4 years ago

Perhaps we could add an integration test for the withHint functions?

Added an integration test file in 51662fa

yondonfu commented 4 years ago

Changes and integration test look good to me. For completeness, could we add a transcoderWithHint though? That one seems to be missing.

Fixed in 6307dfd and 60e908a

yondonfu commented 4 years ago

Rebased!