Skip to content

Implement Staking module#335

Merged
HoOngEe merged 8 commits intoCodeChain-io:moldfrom
HoOngEe:module/staking
May 19, 2020
Merged

Implement Staking module#335
HoOngEe merged 8 commits intoCodeChain-io:moldfrom
HoOngEe:module/staking

Conversation

@HoOngEe
Copy link
Contributor

@HoOngEe HoOngEe commented Apr 20, 2020

I tried to simulate staking logic previously is operating inside the host.
If it is merged into mold, the following tasks should be carried out.

  1. Remove staking logic from the host.
  2. Modify TopLevelState to store only CompactValidatorSet which contains only validators' public key and abstract voting powers.
  3. Remove parameters only used by Staking.

Followings are not implemented yet:

  1. Executing ReportDoubleVote and banning malicious validators.
  2. Creating transactions from higher level input (e.g. graphQL mutation request)

@HoOngEe HoOngEe added the do-not-merge Do not merge this PR label Apr 20, 2020
@HoOngEe HoOngEe force-pushed the module/staking branch 3 times, most recently from 2ce9b7a to a590692 Compare April 21, 2020 11:41
@HoOngEe HoOngEe added the mold Module system label Apr 24, 2020
@HoOngEe HoOngEe force-pushed the module/staking branch 3 times, most recently from dae54a8 to b041e0f Compare April 27, 2020 07:44
@byeongjee byeongjee mentioned this pull request May 4, 2020
@HoOngEe HoOngEe force-pushed the module/staking branch 5 times, most recently from 1c60b78 to 2671658 Compare May 14, 2020 07:17
@HoOngEe HoOngEe force-pushed the module/staking branch 12 times, most recently from 0f9bfd3 to 2ed365b Compare May 14, 2020 09:14
@HoOngEe HoOngEe requested a review from sgkim126 May 14, 2020 09:37
@HoOngEe HoOngEe changed the title [WIP] Implement Staking module Implement Staking module May 14, 2020
@HoOngEe
Copy link
Contributor Author

HoOngEe commented May 14, 2020

Details will be modified after coordinator - module interface is fixed.

@HoOngEe
Copy link
Contributor Author

HoOngEe commented May 19, 2020

@sgkim126 @majecty
I checked all the modifications in the pr #388. Before applying the changes in staking module, I have two concerns.

  1. transaction_index in a "block" could not be resolved from the module level. I naively thought that adding transaction_index when executing transactions based on the index in staking-transactions. However, it also produces another complexity. We're now using an interface function prepare_transactions which includes transaction executions to determine post-processing transactions(previously implicit) based on the state after execution. After the post-processing transactions are included, the index will be changed so the index when creating a block and the index after being delivered are different. Manually ignoring post-processing transactions when calculating the index is a possible way but unnatural.
  2. Host-side validator ordering is important because it matches with the bitset in headers. In a modules system a host-side validator only stores a public key and an abstract voting power. To follow the new rule, host should additionally stores nominated_at_block_number and nominated_at_transaction_index. I don't think it's a general requirements for modules to determine those things as a tie-breaker.

@HoOngEe
Copy link
Contributor Author

HoOngEe commented May 19, 2020

After a discussion @majecty
I realized I misunderstood the boundary the second is no more a problem. The norm of host-side ordering is public-key so only staking module is entirely responsible for tie-breaking.
For the first one, I'll rename the variables and apply the change.

It applies the changes in CodeChain-io#388. NextValidators and CurrentValidators
are sorted by public key. As a tiebreaker Candidate and Validator
utilize the nomination start block number and transaction index.
@HoOngEe HoOngEe removed the do-not-merge Do not merge this PR label May 19, 2020
@HoOngEe HoOngEe merged commit 5d000da into CodeChain-io:mold May 19, 2020
@HoOngEe HoOngEe deleted the module/staking branch May 19, 2020 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mold Module system

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants