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

Write Enrollments data to the block. #504

Merged
merged 1 commit into from
Mar 5, 2020

Conversation

TrustHenry
Copy link
Member

@TrustHenry TrustHenry commented Jan 30, 2020

Writing Enrollment data to a block determines the height of the block that can participate in the validation as a validator.
Validators needed for the consensus process can be determined and the number of validators between nodes can be set.

  • The Enrollment data should be recorded only in the enroll start block.
  • The node store the enrolled block height.

Reach consensus on transaction and enrollment set
The enrollments to be included in a block must first
be voted on by the consensus protocol.

Relates to #493 Enrollment data should be written to the block.
Relates to #565 Make Enrollment Part of Consensus

@TrustHenry
Copy link
Member Author

TrustHenry commented Jan 30, 2020

Writing unit test code on ledger.
Ready

@TrustHenry TrustHenry self-assigned this Jan 30, 2020
@TrustHenry TrustHenry added the type-feature An addition to the system introducing new functionalities label Jan 30, 2020
@codecov
Copy link

codecov bot commented Jan 30, 2020

Codecov Report

Merging #504 into v0.x.x will decrease coverage by 0.88%.
The diff coverage is 99.15%.

Impacted file tree graph

@@            Coverage Diff             @@
##           v0.x.x     #504      +/-   ##
==========================================
- Coverage   89.78%   88.89%   -0.89%     
==========================================
  Files          62       61       -1     
  Lines        4463     4556      +93     
==========================================
+ Hits         4007     4050      +43     
- Misses        456      506      +50
Flag Coverage Δ
#integration ?
#unittests 88.89% <99.15%> (+0.27%) ⬆️
Impacted Files Coverage Δ
tests/unit/BlockStorageMultiTx.d 100% <100%> (ø) ⬆️
source/agora/consensus/Validation.d 98.87% <100%> (-0.01%) ⬇️
tests/unit/BlockStorage.d 100% <100%> (ø) ⬆️
source/agora/consensus/data/Block.d 100% <100%> (+0.7%) ⬆️
tests/unit/BlockStorageChecksum.d 100% <100%> (ø) ⬆️
source/agora/node/Ledger.d 96.73% <99.1%> (+0.64%) ⬆️
source/agora/common/Task.d 0% <0%> (-100%) ⬇️
source/agora/node/Node.d 77.38% <0%> (-21.45%) ⬇️
source/agora/common/Config.d 74.64% <0%> (-16.2%) ⬇️
source/agora/network/NetworkManager.d 69.86% <0%> (-4.8%) ⬇️
... and 4 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 40dd4a1...577687c. Read the comment docs.

@AndrejMitrovic
Copy link
Contributor

I'm not sure if the way the commits were split makes sense. All of these seem like they atomically belong together as a single commit.

@Geod24 do you agree?

@TrustHenry
Copy link
Member Author

TrustHenry commented Jan 31, 2020

I'm not sure if the way the commits were split makes sense. All of these seem like they atomically belong together as a single commit.

If this looks like it, I'll make these committs single-commit

@TrustHenry TrustHenry force-pushed the writeEnrollment branch 2 times, most recently from f16eaf7 to 1164b38 Compare January 31, 2020 02:06
source/agora/consensus/data/Block.d Outdated Show resolved Hide resolved
@@ -68,17 +73,21 @@ public class Ledger
pool = the transaction pool
utxo_set = the set of unspent outputs
storage = the block storage
enroll_man = the enrollmentManager
node_config = the node config
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice catch. 👍

source/agora/node/Ledger.d Outdated Show resolved Hide resolved
source/agora/node/Ledger.d Outdated Show resolved Hide resolved
@@ -236,6 +249,11 @@ public class Ledger
if (!this.storage.saveBlock(block))
assert(0);

foreach (enrollment; block.header.enrollments)
if (!this.enroll_man.updateEnrolledHeight(enrollment.utxo_key,
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a great example of what @Geod24 talked about. If updateEnrolledHeight fails, we shut down the node immediately with assert(0);.

But then the question is, why is updateEnrolledHeight returning a boolean status code? It should either throw an Error or just assert(0) itself, and the function should be made nothrow and not return any status code.

I will file a separate issue for this, so you don't have to change anything here @TrustHenry.

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 was thinking the same thing.

source/agora/node/Ledger.d Show resolved Hide resolved
@TrustHenry TrustHenry force-pushed the writeEnrollment branch 5 times, most recently from 7b75d86 to 6384328 Compare February 3, 2020 07:58
@TrustHenry TrustHenry changed the title [WIP] Enrollments data write to the block. Enrollments data write to the block. Feb 3, 2020
@TrustHenry
Copy link
Member Author

Ready for review.

@TrustHenry
Copy link
Member Author

@Geod24 @AndrejMitrovic ping.

@TrustHenry
Copy link
Member Author

I rebased it.

@Geod24
Copy link
Collaborator

Geod24 commented Mar 3, 2020

You can also probably isolate Defines the data used when reaching consensus in its own commit.
The tests are not great though: the init values are all 0, so they don't test much.
For the transaction set, try to use the genesis txs (see Set.from) and for the Enrollment, just add twice this entry

@Geod24
Copy link
Collaborator

Geod24 commented Mar 3, 2020

Needs a rebase too ;)

@Geod24
Copy link
Collaborator

Geod24 commented Mar 4, 2020

This needs a rebase. And perhaps Reach consensus on transaction and enrollment set can be split into its own PR.

@TrustHenry TrustHenry force-pushed the writeEnrollment branch 2 times, most recently from 9cd3d74 to ff3c2b8 Compare March 4, 2020 02:14
@Geod24
Copy link
Collaborator

Geod24 commented Mar 4, 2020

Looks like you removed the consensus commit ?

@TrustHenry
Copy link
Member Author

Except for the part that was an issue here, only the part that registered data was registered on the block was left.
Related issues are #380 , #565
I will make another PR for the Enrollment Consensus part.

@TrustHenry
Copy link
Member Author

Ready to review.

@Geod24
Copy link
Collaborator

Geod24 commented Mar 4, 2020

node-2_1_6744a39c3d6b | 2020-03-04T03:15:17.120102785Z 2020-03-04 03:15:16,842 Error [agora.consensus.protocol.Nominator] - validateValue(): Invalid tx set: Transaction: Input ref not in UTXO

@TrustHenry TrustHenry force-pushed the writeEnrollment branch 2 times, most recently from 7a6c9ef to 15fa382 Compare March 4, 2020 06:36
@Geod24
Copy link
Collaborator

Geod24 commented Mar 4, 2020

I will make another PR for the Enrollment Consensus part.

Could you do it now ? That commit was ready, and it's much better to make consensus before writing to the block :)

@TrustHenry
Copy link
Member Author

I will make another PR for the Enrollment Consensus part.

Could you do it now ? That commit was ready, and it's much better to make consensus before writing to the block :)

I made PR #620

@TrustHenry
Copy link
Member Author

I am doing solving this conflict.

@Geod24
Copy link
Collaborator

Geod24 commented Mar 5, 2020

Ping me when you have rebased, let's get this merged!

Add the elements into the block.
The enrollments update enrolledHeight
Enrollment data should be written to the block For unnittest
@TrustHenry
Copy link
Member Author

@Geod24 ping

@MichaelKim20 MichaelKim20 self-requested a review March 5, 2020 08:51
@Geod24 Geod24 merged commit 7492b80 into bosagora:v0.x.x Mar 5, 2020
@TrustHenry TrustHenry deleted the writeEnrollment branch May 19, 2020 01:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-feature An addition to the system introducing new functionalities
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants