elective-stereophonic
elective-stereophonic
Final notes
Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest Stable Nxt Client: Nxt 1.12.2

Author Topic: Final notes  (Read 7916 times)

kushti

  • Sr. Member
  • ****
  • Karma: +184/-5
  • Offline Offline
  • Posts: 384
  • Nxt Core & Apps Dev
    • View Profile
Final notes
« on: July 03, 2014, 04:56:05 pm »

After some final fixes I submitted code to JLP for merging into develop branch. He noted Voting System as well as other new features will be incorporated after changes to persistence level(all data goes to SQL database instead of bunch of in-memory structures).

Final Voting system specification

This document describes voting system in details and its implementation.

Features

    Different voting models supported(see also community requirements gathered prior this implementation https://wiki.nxtcrypto.org/wiki/Voting_System): voting by account(1 account=1 vote), balance(1 NXT=1 vote) or asset balance(1 QNT=1 vote); choice(choose from min to max number of options) or binary(yes/no for all options) options.

    Voting has finite predefined duration(finish block height, to say preciously)

    Anonymous voting is not supported for now. It could be implemented with Blind signatures(https://en.wikipedia.org/wiki/Blind_signature) but it's not known for now how to implement that over blockchain. Anonymous voting could be implemented by 3rd party services(but voters should trust voting service).

    Leased voting - not implemented

Voting options

Voting models

There are three models for now:

    By account, 1 account = 1 Vote.

    By balance, 1 NXT = 1 Vote.

    By asset, 1 Asset QNT = 1 Vote. Additional parameter specifies an asset ID.

All models could be enhanced by additional parameter, describing min balance(in NXT / QNT).

Counting

Counting happens at the block height stated during poll creation. So poll creator has to specify poll finish block height. And a vote being counted only if it satisfies poll parameters(min balance etc) at that height. Please note, voter could vote with balance < threshold balance(at height where vote has been sent), and it's valid, but a vote could be counted only if balance >= threshold balance at poll finish height.

Binary & Choice Polls

In case of choice poll voter could choose from min to max number of options(min & max are poll parameters). In case of binary poll voter could choose yes (1) or no (0) for every poll option.

Additional parameters

    asset ID - only for voting by asset
    min balance - 0 by default. Vote counts only if account balance(in NXT or QNT in case of asset voting) >= minBalance

Notes

  • 10 confirmations limit used for balance calculation
  • Voting by asset could be started by anyone, not just asset issuer or even asset owner

Implementation

Attachments

There are two kinds of attachments related to voting system: MessagingPollCreation & MessagingVoteCasting. As MessagingPollCreation has many parameters and complex contruction logic, it should be created with PollBuilder helper implementing Builder pattern:

Quote
Long assetId = ...;
PollBuilder pb = new PollBuilder(question, desc, options, finishBlockHeight, optionModel, votingModel)
if(assetId != null) { pb.assetId(assetId); }
Attachment attachment = new Attachment.MessagingPollCreation(pb)

Transaction types

There are two transaction types related to VS: POLL_CREATION and VOTE_CASTING.



Java API


Examples below are in Scala but should be easily understandable for an every Java develope too:

1. Shareholders voting, a shareholder has to have 100 shares of 1000 at least. Please also read description:

Quote
val question = "What are the next features to get done?"
val description = "Please take voting seriously as we have very limited amount of resources. So you have to choose 1 or 2 features out of 5."

val finishBlockHeight = Nxt.getBlockchain.getHeight + 1440

val options = Array("feature A", "feature B", "feature C", "feature D", "feature E")

val optionModel = Poll.OPTION_MODEL_CHOICE
val votingModel = Poll.VOTING_MODEL_ASSET

val pb = new PollBuilder(question, desc, options, finishBlockHeight, optionModel, votingModel)
val assetId: Long = some_getter_function()
pb.minBalance(100)
pb.assetId(ai)
pb.optionsNumRange(1, 2)

issueTxToGodId(new Attachment.MessagingPollCreation(pb), phrase1)

Poll is created! Now time to send a vote:


Quote
val poll = Poll.getAllPolls.find(_.getName == pollData.question).get
val vote = Array(1.toByte, 0.toByte, 0.toByte, 1.toByte, 0.toByte)
val attachment = new Attachment.MessagingVoteCasting(poll.getId, vote)
issueTxToGodId(attachment, phrase2)


As we have choice voting, the vote means "I vote for featureA and featureD". Please note a vote with 3 1s would be invalid(as max number of options to choose is 2). Please also note vote will be not counted if acoount has less than 100 shares.

Say, we have 4 voters, one has 50 shares(so a vote isn't being counted), second has 3 options chosen(so vote is invalid), third has 200 shares and first option chosen, fourth has 400 shares and first&second options chosen. After poll is finished here is the code to get results:


Quote
val pr = Poll.getAllPollResults.find(_.getPollId == poll.getId)

assert(resultsOpt.isDefined) //check we have results

resultsOpt.get match {
    case cpr: nxt.Poll#ChoicePollResults =>
        val m = cpr.getResults
        assert(m("featureA") == 600)
        assert(m("featureB") == 400)
        assert(m("featureC") == 0)
        assert(m("featureD") == 0)
        assert(m("featureE") == 0)

      case _ => throw new IllegalStateException("wrong kind of poll results")
}


HTTP API

will be described later :)
« Last Edit: July 03, 2014, 05:05:53 pm by kushti »
Logged
for donations / messages: NXT-PKXM-WH25-UXXG-CJAVD (alias: kushti)

SAE

  • Jr. Member
  • **
  • Karma: +8/-0
  • Offline Offline
  • Posts: 20
    • View Profile
Re: Final notes
« Reply #1 on: July 03, 2014, 08:55:24 pm »

Great work ;D this will make asset issuance on the decentralized exchange that much more valuable, especially when voting outcomes can effect things like dividend distribution. Really excited by your awesome work!
Logged

Daedelus

  • Hero Member
  • *****
  • Karma: +230/-12
  • Offline Offline
  • Posts: 3280
    • View Profile
Re: Final notes
« Reply #2 on: July 04, 2014, 11:20:43 am »

+1  This might actually please everyone, in one way or the other ;D
Logged
NXT: NXT-4CS7-S4N5-PTH5-A8R2Q

Kora

  • Full Member
  • ***
  • Karma: +27/-2
  • Offline Offline
  • Posts: 193
    • View Profile
Re: Final notes
« Reply #3 on: July 23, 2014, 04:31:27 am »

The ORA project (formerly known as 'Kora') will be distributing assets very soon, and we plan to use the voting system to resolve a few decisions regarding our project.

Quote
There are three models for now:

    By account, 1 account = 1 Vote.

    By balance, 1 NXT = 1 Vote.

    By asset, 1 Asset QNT = 1 Vote. Additional parameter specifies an asset ID.

I have a few questions.
1 - If we use the 'by asset' model for a particular vote, each voter will pay 1 NXT for the transaction, and 1 asset, correct?
2 - If the answer to the question above is 'yes', what happens to the spent asset QNT? Does the forger of that block earn the asset?
3 - Is '1 asset QNT' = 1.0 asset?
4 - If the answer above is 'yes', then other things being equal, it's wise to have a very large asset number if we plan to vote regularly, correct? To make each vote cost less.
5 - If we use 'by account' or 'by balance' voting model, can we retrict the eligible voters to only holders of the asset?
6 - If we use 'by asset' model can we restrict the voter to 1 asset QNT only, or would it be possible for a voter to set any QNT up to their max holding?

Our intention is to have a vote on what to do with our left over stakes as a test case for the voting process, and if it works well we hope to use the voting system regularly to help us with decentralised decision making.

thanks
Logged
ORA threads: BTT threadCryptoFest

kushti

  • Sr. Member
  • ****
  • Karma: +184/-5
  • Offline Offline
  • Posts: 384
  • Nxt Core & Apps Dev
    • View Profile
Re: Final notes
« Reply #4 on: July 23, 2014, 11:11:03 am »

The ORA project (formerly known as 'Kora') will be distributing assets very soon, and we plan to use the voting system to resolve a few decisions regarding our project.

Wow! That's great. I'm sure voting system could give businesses possibilities communication with shareholders never seen before.


I have a few questions.
1 - If we use the 'by asset' model for a particular vote, each voter will pay 1 NXT for the transaction, and 1 asset, correct?
2 - If the answer to the question above is 'yes', what happens to the spent asset QNT? Does the forger of that block earn the asset?

Nope. Vote fee is 1 NXT, no assets being spent.


3 - Is '1 asset QNT' = 1.0 asset?
4 - If the answer above is 'yes', then other things being equal, it's wise to have a very large asset number if we plan to vote regularly, correct? To make each vote cost less.

QNT means minimum and non-divisible asset fraction. E.g. 0.0001 asset for sharkfund, 1 asset for TXTCoinNow. So with 1 sharkfund asset you have 10000 votes, with 1 TXTCoinNow asset - 1 vote. Regarding voting, I see no big difference in 9 votes out of 10 or 9000 votes out of 10000.

5 - If we use 'by account' or 'by balance' voting model, can we retrict the eligible voters to only holders of the asset?
6 - If we use 'by asset' model can we restrict the voter to 1 asset QNT only, or would it be possible for a voter to set any QNT up to their max holding?

Our intention is to have a vote on what to do with our left over stakes as a test case for the voting process, and if it works well we hope to use the voting system regularly to help us with decentralised decision making.

Balance threshold parameter works only as minimum amount of NXTs in case of "by account" or "by balance" voting models. That parameter works as minimum amount of QNTs in case of "by asset" model.  So you can ask only whales, for example. By default threshold is set to zero(so even with 1 QNT a voter have a right to vote).
Logged
for donations / messages: NXT-PKXM-WH25-UXXG-CJAVD (alias: kushti)

Kora

  • Full Member
  • ***
  • Karma: +27/-2
  • Offline Offline
  • Posts: 193
    • View Profile
Re: Final notes
« Reply #5 on: July 24, 2014, 06:21:21 am »

The ORA project (formerly known as 'Kora') will be distributing assets very soon, and we plan to use the voting system to resolve a few decisions regarding our project.

Wow! That's great. I'm sure voting system could give businesses possibilities communication with shareholders never seen before.


I have a few questions.
1 - If we use the 'by asset' model for a particular vote, each voter will pay 1 NXT for the transaction, and 1 asset, correct?
2 - If the answer to the question above is 'yes', what happens to the spent asset QNT? Does the forger of that block earn the asset?

Nope. Vote fee is 1 NXT, no assets being spent.


3 - Is '1 asset QNT' = 1.0 asset?
4 - If the answer above is 'yes', then other things being equal, it's wise to have a very large asset number if we plan to vote regularly, correct? To make each vote cost less.

QNT means minimum and non-divisible asset fraction. E.g. 0.0001 asset for sharkfund, 1 asset for TXTCoinNow. So with 1 sharkfund asset you have 10000 votes, with 1 TXTCoinNow asset - 1 vote. Regarding voting, I see no big difference in 9 votes out of 10 or 9000 votes out of 10000.

5 - If we use 'by account' or 'by balance' voting model, can we retrict the eligible voters to only holders of the asset?
6 - If we use 'by asset' model can we restrict the voter to 1 asset QNT only, or would it be possible for a voter to set any QNT up to their max holding?

Our intention is to have a vote on what to do with our left over stakes as a test case for the voting process, and if it works well we hope to use the voting system regularly to help us with decentralised decision making.

Balance threshold parameter works only as minimum amount of NXTs in case of "by account" or "by balance" voting models. That parameter works as minimum amount of QNTs in case of "by asset" model.  So you can ask only whales, for example. By default threshold is set to zero(so even with 1 QNT a voter have a right to vote).

Thanks for that answer kushti! I think the NXT voting system will work very well for ORA. I've decided to give every ORA stakeholder 5 NXT each to pay for the first 5 votes just to make sure nobody is put off by the fee. After that I think it'll be obvious if the voting system is helping ORA with decentralised decision making.
Logged
ORA threads: BTT threadCryptoFest

wert

  • Full Member
  • ***
  • Karma: +15/-10
  • Offline Offline
  • Posts: 170
    • View Profile
Re: Final notes
« Reply #6 on: July 24, 2014, 08:13:25 am »

The ORA project (formerly known as 'Kora') will be distributing assets very soon, and we plan to use the voting system to resolve a few decisions regarding our project.

Quote
There are three models for now:

    By account, 1 account = 1 Vote.

    By balance, 1 NXT = 1 Vote.

    By asset, 1 Asset QNT = 1 Vote. Additional parameter specifies an asset ID.

I have a few questions.
1 - If we use the 'by asset' model for a particular vote, each voter will pay 1 NXT for the transaction, and 1 asset, correct?
2 - If the answer to the question above is 'yes', what happens to the spent asset QNT? Does the forger of that block earn the asset?
3 - Is '1 asset QNT' = 1.0 asset?
4 - If the answer above is 'yes', then other things being equal, it's wise to have a very large asset number if we plan to vote regularly, correct? To make each vote cost less.
5 - If we use 'by account' or 'by balance' voting model, can we retrict the eligible voters to only holders of the asset?
6 - If we use 'by asset' model can we restrict the voter to 1 asset QNT only, or would it be possible for a voter to set any QNT up to their max holding?

Our intention is to have a vote on what to do with our left over stakes as a test case for the voting process, and if it works well we hope to use the voting system regularly to help us with decentralised decision making.

thanks
Why don't you use Qora? :D
Logged
NXT-MX4G-33RN-MBVK-BPK9D
Spare some change? ^^

kushti

  • Sr. Member
  • ****
  • Karma: +184/-5
  • Offline Offline
  • Posts: 384
  • Nxt Core & Apps Dev
    • View Profile
Re: Final notes
« Reply #7 on: July 28, 2014, 03:12:26 pm »

New article: Shareholders Meeting via Blockchain in 20 Lines of Code ->  http://chepurnoy.org/blog/2014/07/shareholders-meeting-via-blockchain-in-20-lines-of-code/
Logged
for donations / messages: NXT-PKXM-WH25-UXXG-CJAVD (alias: kushti)

kushti

  • Sr. Member
  • ****
  • Karma: +184/-5
  • Offline Offline
  • Posts: 384
  • Nxt Core & Apps Dev
    • View Profile
Re: Final notes
« Reply #8 on: July 28, 2014, 08:39:35 pm »

Stupid question maybe but I assume you are Alexander Chepurnoy?

Oops, I did deanonymization  :)
Logged
for donations / messages: NXT-PKXM-WH25-UXXG-CJAVD (alias: kushti)

Daedelus

  • Hero Member
  • *****
  • Karma: +230/-12
  • Offline Offline
  • Posts: 3280
    • View Profile
Re: Final notes
« Reply #9 on: July 28, 2014, 09:29:34 pm »

Oops, I did deanonymization  :)

I deleted my post  ;D
Logged
NXT: NXT-4CS7-S4N5-PTH5-A8R2Q

kushti

  • Sr. Member
  • ****
  • Karma: +184/-5
  • Offline Offline
  • Posts: 384
  • Nxt Core & Apps Dev
    • View Profile
Re: Final notes
« Reply #10 on: July 29, 2014, 10:32:41 am »

Oops, I did deanonymization  :)

I deleted my post  ;D

No worries, that's not an issue :)
Logged
for donations / messages: NXT-PKXM-WH25-UXXG-CJAVD (alias: kushti)

sv3n

  • Sr. Member
  • ****
  • Karma: +29/-0
  • Offline Offline
  • Posts: 268
    • View Profile
Re: Final notes
« Reply #11 on: July 31, 2014, 12:09:55 pm »

For this system, is it adding a new transaction type, or is this something that is piggybacked onto the Arbitrary Message system?

If it is a new transaction type, do new types have to be integrated into the core, or are they simply an extension/plugin that any user can download if they wish?  If this can be integrated ad hoc, then how do users not running this extension know if it's a valid transaction to be added to the blockchain?

Sorry for asking all these noob questions, but I'm super interested in getting into NXT, and would even like to contribute some projects, but first I gotta learn a few more basics :)
Logged
NXT-QK6T-BTVP-N8SL-9ZLD4

kushti

  • Sr. Member
  • ****
  • Karma: +184/-5
  • Offline Offline
  • Posts: 384
  • Nxt Core & Apps Dev
    • View Profile
Re: Final notes
« Reply #12 on: July 31, 2014, 02:33:01 pm »

For this system, is it adding a new transaction type, or is this something that is piggybacked onto the Arbitrary Message system?

If it is a new transaction type, do new types have to be integrated into the core, or are they simply an extension/plugin that any user can download if they wish?  If this can be integrated ad hoc, then how do users not running this extension know if it's a valid transaction to be added to the blockchain?

Sorry for asking all these noob questions, but I'm super interested in getting into NXT, and would even like to contribute some projects, but first I gotta learn a few more basics :)

1. There are two new transaction types in the core, say, CREATE_POLL & CAST_VOTE.
2. You are welcome! If you are Java/Scala dev, feel free to ask me any questions regarding developing around NXT
Logged
for donations / messages: NXT-PKXM-WH25-UXXG-CJAVD (alias: kushti)

sv3n

  • Sr. Member
  • ****
  • Karma: +29/-0
  • Offline Offline
  • Posts: 268
    • View Profile
Re: Final notes
« Reply #13 on: July 31, 2014, 02:39:47 pm »

Thanks!
Logged
NXT-QK6T-BTVP-N8SL-9ZLD4

Darkhorse

  • Hero Member
  • *****
  • Karma: +61/-8
  • Offline Offline
  • Posts: 1016
  • Keep It Simple
    • View Profile
Re: Final notes
« Reply #14 on: August 08, 2014, 05:02:49 am »

Any idea on timeline to go live?
Logged
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬  ▄▀▀▀▀▀▀▀▀▄  ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬●  nimirum  ●▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
▬▬▬ ◖ENDING CENSHORSIP ONLINE◗  ◖ ICO OPEN NOW◗ ▬▬▬

kushti

  • Sr. Member
  • ****
  • Karma: +184/-5
  • Offline Offline
  • Posts: 384
  • Nxt Core & Apps Dev
    • View Profile
Re: Final notes
« Reply #15 on: August 11, 2014, 12:54:35 pm »

Any idea on timeline to go live?

Current JLP's plan is 1.4
Logged
for donations / messages: NXT-PKXM-WH25-UXXG-CJAVD (alias: kushti)

Brangdon

  • Hero Member
  • *****
  • Karma: +229/-25
  • Offline Offline
  • Posts: 1389
  • Quality is addictive.
    • View Profile
Re: Final notes
« Reply #16 on: September 10, 2014, 07:31:36 pm »

All models could be enhanced by additional parameter, describing min balance(in NXT / QNT).
Did no-one suggest a quorum parameter? "A quorum is the minimum number of members of a deliberative assembly (a body that uses parliamentary procedure, such as a legislature) necessary to conduct the business of that group." For example, if you are voting by asset, it could be useful to require that at least 50% of the assets issued be cast in the vote for the vote to be considered valid. In the American Constitution 12th Amendment, it sometimes talks of a quorum of 2/3rds of members being needed to elect a President.

I guess it doesn't matter too much if the result of the vote is being interpreted by humans, because they can just ignore votes where the quorum wasn't achieved. However, when the output of the vote is used to drive an automated process, it would become important. I just write this suggestion, that we set transaction fees by a special kind of vote that NRS implements the result of directly, and when I wrote that I just assumed that the voting system allowed for a quorum.
Logged

Sebastien256

  • Hero Member
  • *****
  • Karma: +169/-24
  • Offline Offline
  • Posts: 2823
  • ^LOOK UP^ = Nxt community!
    • View Profile
Re: Final notes
« Reply #17 on: September 10, 2014, 08:10:43 pm »

All models could be enhanced by additional parameter, describing min balance(in NXT / QNT).
Did no-one suggest a quorum parameter? "A quorum is the minimum number of members of a deliberative assembly (a body that uses parliamentary procedure, such as a legislature) necessary to conduct the business of that group." For example, if you are voting by asset, it could be useful to require that at least 50% of the assets issued be cast in the vote for the vote to be considered valid. In the American Constitution 12th Amendment, it sometimes talks of a quorum of 2/3rds of members being needed to elect a President.

I guess it doesn't matter too much if the result of the vote is being interpreted by humans, because they can just ignore votes where the quorum wasn't achieved. However, when the output of the vote is used to drive an automated process, it would become important. I just write this suggestion, that we set transaction fees by a special kind of vote that NRS implements the result of directly, and when I wrote that I just assumed that the voting system allowed for a quorum.

good idea +1
Logged
Please drop your ideas concerning Nxt and/or NRS in this topic -> List of feature request for Nxt and/or NRS (with the full list in OP).

kushti

  • Sr. Member
  • ****
  • Karma: +184/-5
  • Offline Offline
  • Posts: 384
  • Nxt Core & Apps Dev
    • View Profile
Re: Final notes
« Reply #18 on: October 28, 2014, 09:28:39 pm »

1. Quorum is for application layer I guess
2. Quorum parameter exists in 2-phased transactions.
Logged
for donations / messages: NXT-PKXM-WH25-UXXG-CJAVD (alias: kushti)
 

elective-stereophonic
elective-stereophonic
assembly
assembly