-
-
Notifications
You must be signed in to change notification settings - Fork 11
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
feat: support period vote tx #305
Conversation
Codecov Report
@@ Coverage Diff @@
## master #305 +/- ##
==========================================
- Coverage 94.88% 94.66% -0.23%
==========================================
Files 66 70 +4
Lines 958 1012 +54
Branches 177 189 +12
==========================================
+ Hits 909 958 +49
- Misses 44 48 +4
- Partials 5 6 +1
Continue to review full report at Codecov.
|
984340e
to
15924f6
Compare
src/period/submitPeriodVote.js
Outdated
bridgeState.account.privateKey | ||
); | ||
|
||
await sendDelayed(periodVoteTx); |
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.
why does this one need to be delayed? isn't tendermint deterministic? so if we got the period full, we are sure it will not go back?
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.
I have no answer to this yet, just used the existing approach: https://github.com/leapdao/leap-node/blob/master/src/eventsRelay.js#L65
src/tx/applyTx/checkPeriodVote.js
Outdated
|
||
// validators are not in consensus on period roots atm | ||
// disabling this until resolved | ||
// https://github.com/leapdao/leap-node/issues/282#issuecomment-519160276 |
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.
issue solved, should this be reenabled?
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.
it is still not working right. I'm fixing it as part of #309 here: https://github.com/leapdao/leap-node/tree/feat/submit-with-cas
TLDR: bad idea to submit period in tx handler. I'm submitting period in block middleware now, PR to follow once done
src/period/index.js
Outdated
setTimeout(async () => { | ||
await submitPeriodVote( |
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.
why did you decide to call submitPeriodVote()
here?
this is called when tendermint is trying to propose a new block (right?), and submitPeriod()
is called as a fallback, in case the selected proposer is offline.
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.
this handler is called every period (checkPeriod
middleware). Right, I'm submitting the vote here as a fallback as well (submitPeriodVote
has a protection against double votes).
updatePeriod
is being called every block and that's where I submit a vote first: https://github.com/leapdao/leap-node/pull/305/files/15924f654aabe89a4492c03fa3c51f7f67b02545#diff-786c9ee7cb87a989994653f4a23150a6R25
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.
i would fix a few small things:
- remove sendDelayed for sending periodVotes
- validate that output index == 0 on all received votes
- remove the code comments
src/txHelpers/submitPeriod.test.js
Outdated
}); | ||
|
||
// describe('period vote', () => { |
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.
no code comments
src/tx/applyTx/checkPeriodVote.js
Outdated
// validators are not in consensus on period roots atm | ||
// disabling this until resolved | ||
// https://github.com/leapdao/leap-node/issues/282#issuecomment-519160276 | ||
// const { result } = checkEnoughVotes(periodRoot, state); |
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.
remove code comments
addressed everything. plus refactored to keep periodVotes in a tendermint |
collect votes in a state to use later for period submission
2716184
to
33bc998
Compare
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.
looks great.
like the tests, CAS bitmap building looks good as well.
...attrs, | ||
}); | ||
|
||
describe('checkPeriodVote', () => { |
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.
❤️
prevHash: '0x5678', | ||
}; | ||
|
||
describe('submit period vote', () => { |
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.
❤️
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.
why votes in the state? wouldn't that make the state grow infinitely?
i feel we should keep votes in bridgeState (with some pruning), and/or in some db, but not in memory forever.
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.
ok, given we prune the votes in the state later (out of scope), accepted
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.
classic
Resolves #282