-
Notifications
You must be signed in to change notification settings - Fork 175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
eth: hints for staking actions #1845
Conversation
Wanted to rework the helpers to get the hints first so we could avoid repeating getting the transcoder pool, transcoder pool size, ... . Then I realised the reason why we went with the functional programming approach for those is because of testability. Using a method on |
Added a fix in the way we calculate the stake amounts, previously posPrev always ended up being 0x00... tested on rinkeby and works now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tested on rinkeby and works now
Can you confirm that the calculated hints are working as expected and the gas costs are reduced relative to if the transactions were submitted without hints (i.e. by posting gas cost differences)?
State before Self bond 5 LPT (16.66 + 5 = 21.66 LPT) :
Transcoder list after transaction (hints match the new position) BondWithHint Transaction: https://rinkeby.etherscan.io/tx/0xd403ade95d4b70b1fc9d6dc84a438775ae8529ebe8acfd1e01f733319046abcb Bond Transaction https://rinkeby.etherscan.io/tx/0x6b3c51ee116b0209b577c6fb13723f2b3c109265e3554469551e608db4c13ea3 For some reason the regular Bond transaction is ~20K gas cheaper, despite the hints being correct. The state update is the same. Unbond 5 LPT
Hints should match the prev and nex positions of the original state (first picture) , they do. UnbondWithHint transaction https://rinkeby.etherscan.io/tx/0x0c22c8f3d3936ad9273e6ee2408ff55d723d5652e2629c5db6377db0f8599ca0 Unbond transaction UnbondWithHint is about 110K gas cheaper RebondWithHint
Hints should again match the ones from the BondWithHint transaction, they do RebondWithHint transaction https://rinkeby.etherscan.io/tx/0x462a94b8bec172deafd584dc3886a5c2a36a011b525e14f86a8543a14e84a364 Rebond transaction https://rinkeby.etherscan.io/tx/0xad50716c5883dced9606ea6debed524d089d97c2896c37cab2f32f3d3b20f51f RebondWithHint is about ~27k gas cheaper |
Can you investigate why this is the case and confirm if the bondWithHint() tx is more expensive than the bond() tx due to a problem with the hints or some other reason? From glancing at the Rinkeby txs, it looks like the two txs for bonding were submitted from the same account one after the other around the same time. Could it be the case that the first bondWithHint() tx changed the transcoder pool ordering such that the second bond() tx (without hints) required less iterations in the transcoder pool (or even no iterations at all) and as a result the bondWithHint() tx ended up being more expensive due to the gas costs associated with including/reading the hints on-chain? I bring this up because we should make sure (if we're not doing so already) that when comparing txs with and without hints that the on-chain transcoder pool state is the same before each tx to make it a fair comparison. |
The The regular I ran these transactions through the tenderly execution tracer and this confirms as much. As you can see in the second image there is no call to
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM after squashing
What does this pull request do? Explain your changes. (required)
This PR adds support for hints when performing staking actions on the Livepeer smart contracts.
Specific updates (required)
eth/Client.go
How did you test each of these updates (required)
Does this pull request close any open issues?
Fixes #1567
Checklist:
make
runs successfully./test.sh
pass