Skip to content
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

Merged
merged 13 commits into from
Aug 9, 2019
Merged

feat: support period vote tx #305

merged 13 commits into from
Aug 9, 2019

Conversation

troggy
Copy link
Member

@troggy troggy commented Aug 1, 2019

  • Validators emit PeriodVote tx when it is time to submit period.
  • Validators collect period votes in a state

Resolves #282

@codecov
Copy link

codecov bot commented Aug 1, 2019

Codecov Report

Merging #305 into master will decrease coverage by 0.22%.
The diff coverage is 92.18%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
src/abis/operator.js 100% <ø> (ø) ⬆️
src/period/utils/checkEnoughVotes.js 0% <0%> (ø)
src/tx/applyTx/checkPeriodVote.js 100% <100%> (ø)
src/txHelpers/submitPeriod.js 94.11% <100%> (+0.17%) ⬆️
src/utils/buildCas.js 100% <100%> (ø)
src/period/submitPeriodVote.js 100% <100%> (ø)
src/period/index.js 100% <100%> (ø) ⬆️
src/tx/applyTx/utils.js 98.55% <100%> (+0.06%) ⬆️
src/block/updatePeriod.js 95.65% <100%> (+0.41%) ⬆️
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 07f94b6...9644584. Read the comment docs.

@troggy troggy marked this pull request as ready for review August 2, 2019 19:41
@troggy troggy force-pushed the feat/support-period-vote branch 2 times, most recently from 984340e to 15924f6 Compare August 8, 2019 10:06
bridgeState.account.privateKey
);

await sendDelayed(periodVoteTx);
Copy link
Member

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?

Copy link
Member Author

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


// validators are not in consensus on period roots atm
// disabling this until resolved
// https://github.com/leapdao/leap-node/issues/282#issuecomment-519160276
Copy link
Member

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?

Copy link
Member Author

@troggy troggy Aug 8, 2019

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

setTimeout(async () => {
await submitPeriodVote(
Copy link
Member

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.

Copy link
Member Author

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

Copy link
Member

@johannbarbie johannbarbie left a 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

});

// describe('period vote', () => {
Copy link
Member

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 Show resolved Hide resolved
// 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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove code comments

@troggy
Copy link
Member Author

troggy commented Aug 8, 2019

addressed everything.

plus refactored to keep periodVotes in a tendermint state, not in a bridgeState. This is the right way to do (see)

@troggy troggy requested a review from johannbarbie August 8, 2019 15:03
@johannbarbie johannbarbie force-pushed the feat/support-period-vote branch from 2716184 to 33bc998 Compare August 9, 2019 10:09
Copy link
Member

@johannbarbie johannbarbie left a 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', () => {
Copy link
Member

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', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

Copy link
Member

@johannbarbie johannbarbie left a 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.

Copy link
Member

@johannbarbie johannbarbie left a 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

Copy link
Member

@johannbarbie johannbarbie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

classic

@troggy troggy merged commit c7ac7c1 into master Aug 9, 2019
@troggy troggy deleted the feat/support-period-vote branch August 9, 2019 14:36
@troggy troggy restored the feat/support-period-vote branch August 9, 2019 14:36
@troggy troggy deleted the feat/support-period-vote branch August 9, 2019 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add support for PERIOD_VOTE tx type
2 participants