PoS - How does it really work? Long and maybe confusing thread incoming ;)


#101

The time it takes to mint is variable, and is based on a bunch of different variables: the age of your coins, the amount of coins you are using to mint, the number of other people attempting to mint at the same time. You are competing to solve a block, and there’s certainly a factor of “luck” in the attempt, too.

As I understand it, if you leave your client open and have coins that are mature and available to mint, your wallet will attempt to solve for the next block once per second. While it doesn’t need to be continuously open, if you close it you won’t be attempting to solve during the time you are offline. On the other hand, there’s no penalty for stopping/restarting your wallet client, because you’ll just pick up where you left off.

To get an idea of how long it takes to solve a block using proof-of-stake, you can check out the Peerchain.net site. In the “Latest Blocks” section at the top, you’ll be able to see which were solved with PoS, and when they were solved, how old the stake was that was used to solve it.

For example, block 97687 was solved just a few minutes ago. It was a proof-of-stake block that used 47.61 PPC as the stake that had been held for 239.57 days.


#102

How do all these factors change things? Am I more likely to mint if the coins are older? I thought that older coins just means you get more from minting them? Am I more likely to get a successful mint block if I’m using “more” coins? What are “more” coins? Does my client aggregate all the coins that came in at all its addresses when it mints? Or just the coins sitting in one address? If so, is it more advantageous to me for internally transfer all my coins to one address?

As I understand it, if you leave your client open and have coins that are mature and available to mint, your wallet will attempt to solve for the next block once per second. While it doesn't need to be continuously open, if you close it you won't be attempting to solve during the time you are offline. On the other hand, there's no penalty for stopping/restarting your wallet client, because you'll just pick up where you left off.

Thanks. That was helpful.

To get an idea of how long it takes to solve a block using proof-of-stake, you can check out the [url=http://peerchain.net/]Peerchain.net[/url] site. In the "Latest Blocks" section at the top, you'll be able to see which were solved with PoS, and when they were solved, how old the stake was that was used to solve it.

For example, block 97687 was solved just a few minutes ago. It was a proof-of-stake block that used 47.61 PPC as the stake that had been held for 239.57 days.

I see there’s a “difficulty” with PoS. How is the diff calculated? Similarly to PoW, in that it’s based on how many people are PoS minting?


#103
Am I more likely to mint if the coins are older? I thought that older coins just means you get more from minting them? Am I more likely to get a successful mint block if I'm using "more" coins? What are "more" coins?

You chances of minting are dependent on the “coin age” of mature coins available in an address you control. Coins are mature when they’ve sat static in an address for more than 30 days. Between Day 30 and Day 90, the chances you’ll solve a block increase as your coin age increases. After Day 90, you’ll stop getting gaining an advantage, but you’ll continue to attempt to solve the current block as if you are perpetually at Day 90. The reward for solving a block, when you do, will be calculated using the “real” coin age (Day 1 until whatever day it is when you solve it).

The stake’s coin days are calculated based on the number of coins used, so someone who attempts to use 1 PPC to solve a stake will have at maximum 90 coin days, where someone who uses a stake of 1000 PPC will have 90000 coin days. However, one thing to consider is that it’s still not a “sure thing” for the person who has more coin days at stake to win. For example, right now, I’m attempting to mint with a stake that is larger than most of the recent ones that solved PoS blocks (well, not 97689, that was a lot larger than mine!).

Does my client aggregate all the coins that came in at all its addresses when it mints? Or just the coins sitting in one address? If so, is it more advantageous to me for internally transfer all my coins to one address?

From what I’ve seen in the code, and from what I’ve read on the subject, each address is treated individually by your client. I asked Sunny King for clarification on the matter of whether or not the client is concurrently trying to solve blocks with any addresses that have inputs that meet the requirements for maturity, or if it picks the address that has the highest matured coin age and uses that exclusively. I’ll share the answer with the community once I hear back.

Consolidation into a single address could give you an advantage, but there are other factors to consider (security, anonymity) that may outweigh the benefit. That’s a decision you’ll need to make, but remember that if you move your coins into a single address, that the transaction used to do that will reset those coins’ coin age back to zero (just like any outgoing transaction would).

I see there's a "difficulty" with PoS. How is the diff calculated? Similarly to PoW, in that it's based on how many people are PoS minting?

This is a question that I asked Sunny King, too, because I don’t quite understand what it means. I understand how the difficulty works (it’s used to ensure consistent block spacing), but what I’m not quite sure about is if it’s related to the number of concurrent people attempting to mint, ala the PoW difficulty, or if there’s another mechanism that calculates it. Sigmike, ppcman, alertness, fuzzybear or others in the community who have more experience with the code may be able to better articulate how this works.


#104

So, how does “luck” factor with PoS in this regards? For instance, I know that when I’m mining in a pool, or if I were solo mining, and I’m mining with a 1 Th/s machine, I’m much more likely to get a block than with a 1 MH/s machine. In fact, the 1 MH/s machine pretty much a chance that’s hard to distinguish from 0 in finding a block.

So I suppose what I’m asking is, does “luck” function similarly with PoS? If someone is trying to mint 100K coins, and I’m trying to mint 1 coin, they have 9M coin days and I have 90. If “luck” functions like it does in PoW, it’s not worth it for me to mint; I’m never going to find a block.

The stake's coin days are calculated based on the number of coins used, so someone who attempts to use 1 PPC to solve a stake will have at maximum 90 coin days, where someone who uses a stake of 1000 PPC will have 90000 coin days. However, one thing to consider is that it's still not a "sure thing" for the person who has more coin days at stake to win. For example, right now, I'm attempting to mint with a stake that is larger than most of the recent ones that solved PoS blocks ([i]well, not 97689, that was a lot larger than mine[/i]!).

See my query above.

From what I've seen in the code, and from what I've read on the subject, each address is treated individually by your client. I asked Sunny King for clarification on the matter of whether or not the client is concurrently trying to solve blocks with any addresses that have inputs that meet the requirements for maturity, or if it picks the address that has the highest matured coin age and uses that exclusively. I'll share the answer with the community once I hear back.

Consolidation into a single address could give you an advantage, but there are other factors to consider (security, anonymity) that may outweigh the benefit. That’s a decision you’ll need to make, but remember that if you move your coins into a single address, that the transaction used to do that will reset those coins’ coin age back to zero (just like any outgoing transaction would).

I’d be interested in hearing Sunny’s answer as well. I agree that there’s tradeoffs that might mean things to different people in terms of security.

This is a question that I asked Sunny King, too, because I don't quite understand what it means. I understand how the difficulty works (it's used to ensure consistent block spacing), but what I'm not quite sure about is if it's related to the number of concurrent people attempting to mint, ala the PoW difficulty, or if there's another mechanism that calculates it. [b]Sigmike[/b], [b]ppcman[/b], [b]alertness[/b], [b]fuzzybear[/b] or others in the community who have more experience with the code may be able to better articulate how this works.

I’d be interested in knowing the answer to this as well.


#105

Found some prior info from Sunny in 2013:

The protocol upgrade [in 0.3.0] involves replacing the proof-of-stake difficulty as the hash modifier for proof-of-stake (we call it stake modifier).

Hash modifier was mentioned in Weekly update #27:

www.peercointalk.org/index.php?topic=5.msg28#msg28

first the proof-of-stake hash modifier is switched to one computed from roughly 9 days worth of blocks. The blocks are grouped and 64 blocks are selected based on a ‘selection hash’. Then each selected block contributes one bit to the modifier. The purpose of stake modifier is to prevent stake owner from manipulating future stake generation at the time the coin is confirmed into block chain.
Two other protocol changes are made: stake hash weight now starts from 0 at 30-day minimum age requirement; coinstake timestamp now must match block timestamp.


#106

[quote=“ppcman, post:105, topic:648”]Found some prior info from Sunny in 2013:

The protocol upgrade [in 0.3.0] involves replacing the proof-of-stake difficulty as the hash modifier for proof-of-stake (we call it stake modifier).

Hash modifier was mentioned in Weekly update #27:

www.peercointalk.org/index.php?topic=5.msg28#msg28

first the proof-of-stake hash modifier is switched to one computed from roughly 9 days worth of blocks. The blocks are grouped and 64 blocks are selected based on a ‘selection hash’. Then each selected block contributes one bit to the modifier. The purpose of stake modifier is to prevent stake owner from manipulating future stake generation at the time the coin is confirmed into block chain.
Two other protocol changes are made: stake hash weight now starts from 0 at 30-day minimum age requirement; coinstake timestamp now must match block timestamp.[/quote]

Uh…can you dumb that down a bit for me?


#107

Yeah. Stake generation is fair, seems to be working well, and any earlier problems that surfaced have been fixed.

The actual mechanics of how someone wins a proof-of-stake block are long and complex and not easily described because there are so many different variables involved. People “want to know” but then when it gets too complex in the description they can’t follow it anymore. :stuck_out_tongue:

It’s something I don’t want to get too involved in, I’m personally happy with the way it’s working now, and speaking for myself, I don’t want to know every itty bitty tiny detail. I just don’t. I’m more of a user than a developer.

So I’ll bow out of this discussion at this point.


#108

Yeah. Stake generation is fair, seems to be working well, and any earlier problems that surfaced have been fixed.

The actual mechanics of how someone wins a proof-of-stake block are long and complex and not easily described because there are so many different variables involved. People “want to know” but then when it gets too complex in the description they can’t follow it anymore. :stuck_out_tongue:

It’s something I don’t want to get too involved in, I’m personally happy with the way it’s working now, and speaking for myself, I don’t want to know every itty bitty tiny detail. I just don’t. I’m more of a user than a developer.

So I’ll bow out of this discussion at this point.[/quote]

Sorry.

I’m just trying to understand how PoS works in terms of what I should be doing to maximize my chances of finding blocks by minting.


#109

Oh, that’s easy. This is what I do:

  1. Buy as many coins as you can afford

  2. Proof-of-stake is based on coins held in a particular wallet address
    AND
    based on a single transaction when coins were transferred to that wallet

    (if you mine a lot, and transfer frequently small “pieces” of coins, it isn’t as good as if you transfer a large amount of coins)

  3. Hold them for as long as you can

  4. Leave your wallet in minting mode as much as you can (This doesn’t mean for 1 hour while you constantly glance at the screen) This means for 3-4 days as a start 72-96 hours.

If you don’t get a minted block after leaving it open for 3-4 days, then close it, and try this again a week or two later. This is the way I’ve been minting my coins.

The most important thing to remember is that your 1% interest per year will happen either sooner, or later, depending on how much you participate in the minting process. (and the quantity of coins in a single transaction)


#110

It tries all your coins (minus reserve, see http://www.peercointalk.org/index.php?topic=2196.msg17906#msg17906).
The code is here: https://github.com/ppcoin/ppcoin/blob/master/src/wallet.cpp#L1240
It select all your coins (in the same way as when you want to send them), and tries to find a “kernel” for each transaction (lines 1248 and 1268).

[quote=“Ben, post:103, topic:648”]

I see there’s a “difficulty” with PoS. How is the diff calculated? Similarly to PoW, in that it’s based on how many people are PoS minting?

This is a question that I asked Sunny King, too, because I don’t quite understand what it means. I understand how the difficulty works (it’s used to ensure consistent block spacing), but what I’m not quite sure about is if it’s related to the number of concurrent people attempting to mint, ala the PoW difficulty, or if there’s another mechanism that calculates it. Sigmike, ppcman, alertness, fuzzybear or others in the community who have more experience with the code may be able to better articulate how this works.[/quote]

It seems to work almost the same way in PoS and PoW. But there’s a difference with bitcoin: the difficulty is adjusted after every block, not after a certain time.

The only factors seems to be the time between the last two blocks, the previous difficulty and the target spacing (10 minutes).

The code is here: https://github.com/ppcoin/ppcoin/blob/master/src/main.cpp#L902


#111

[quote=“Blackbird, post:104, topic:648”]So, how does “luck” factor with PoS in this regards? For instance, I know that when I’m mining in a pool, or if I were solo mining, and I’m mining with a 1 Th/s machine, I’m much more likely to get a block than with a 1 MH/s machine. In fact, the 1 MH/s machine pretty much a chance that’s hard to distinguish from 0 in finding a block.

So I suppose what I’m asking is, does “luck” function similarly with PoS? If someone is trying to mint 100K coins, and I’m trying to mint 1 coin, they have 9M coin days and I have 90. If “luck” functions like it does in PoW, it’s not worth it for me to mint; I’m never going to find a block.[/quote]

Whether not your chances of minting with a very small stake are indistinguishable from zero or not, it is something that can and has happened. See this earlier post of mine for a link to the block where a 1.03 PPC stake solved a block after 90 days. Don’t let it discourage you, because the reward for solving the block, whenever it happens, will continue to accumulate. In any case, it’s not just for the reward, but remember that attempting to mint is contributing to the Peercoin network’s security and that’s a benefit to you and everyone else who holds Peercoin.

As an aside, I’ve been thinking about the M supply of peercoins and their relationship to minting. As the number of peercoins circulation are distributed – through transactions – to more and more addresses over time, I’m anticipating that the number of large PPC stakes will gradually go down. It’s just a hypothesis right now, and I don’t yet have data points to validate it, but I’m keeping the question open.


#112

And thank you Sigmike and ppcman, I’ll review the links and see if I can get my head around the way that blocks are solved with proof-of-stake. At a basic level it makes sense to me, but I need to test my understanding of it against a couple of scenarios to make sure I really understand what it means.


#113

The hash modifier is not the difficulty. This hash is there only to prevent people from guessing when they may find a PoS block before they make the transaction.
If it was not there someone could try to find a set of transactions that’d maximize the chances to find multiple blocks in a row.

It’s described here: https://github.com/ppcoin/ppcoin/blob/master/src/kernel.cpp#L113


#114

Yes, that is correct. The hash modifier is not the difficulty. Thanks for clearing that up.

Half the people want to make sure proof-of-stake isn’t easily attacked, and to be honest, it really isn’t. Yet we have all these naysayers (usually showing up on reddit) who don’t really understand the mechanics of PoS and built in safety mechanisms. They continually attempt to spread FUD because they don’t own any Peercoin or want to sway people to their own idea of a good coin.

The other of half of people just genuinely want to mint coins to ensure they are doing things to help their chances. For that, I understand.

This is why I hope future versions of the QT can have a “minting watcher” or something like cgminer’s output, that shows the minting process in action, so people can watch in awe and excitement while their minter churns away and reports its progress.


#115

Thank you all for your responses. I understand it a lot better now.

From what sigmike said: because the wallet mints coins using the same function it uses to send, there’s no need to combine coins into single addresses. Let me sketch out my understanding.

If I have two received addresses: 1 has 2 PPC; the other has 10 PPC. I get the 2 on Day 0, and the 10 on Day 10. When Day 30 comes along, my wallet will try to mint the 2. If it has not minted the 2 by Day 40, the wallet will try to mint both the 2 and the 10 at the same time, as 12. Am I correct in that?

Are you saying there’s no way to enter a console and see the minting process?


#116

There is, it’s just that the current “official” build of PPCoin-Qt (v0.3.0) doesn’t include a debug console built in and there’s no publicly accessible method to ask the daemon to report back minting status. You can parse your debug.log file and watch for “a block was found” messages, but that’s not ideal because it doesn’t echo anything in-progress.


#117

Ben, perhaps you can give an example of what minting information is available with ppcoind (or peercoind) itself.

It’s very basic, as far as I know, it doesn’t show you every failed attempt to mint a block, etc, etc.


#118

[quote=“ppcman, post:117, topic:648”]Ben, perhaps you can give an example of what minting information is available with ppcoind (or peercoind) itself.

It’s very basic, as far as I know, it doesn’t show you every failed attempt to mint a block, etc, etc.[/quote]

I noticed my initial statement wasn’t clear. I was indicating that there is a debug console for the QT client, but that there isn’t a command (that I can find) to show anything related to the minting process.

The only place I’ve seen anything related to it is when I review the debug.log file, but that’s only after a block has been solved.


#119

[quote=“sigmike, post:110, topic:648”]…
It tries all your coins (minus reserve, see http://www.peercointalk.org/index.php?topic=2196.msg17906#msg17906).
The code is here: https://github.com/ppcoin/ppcoin/blob/master/src/wallet.cpp#L1240
It select all your coins (in the same way as when you want to send them), and tries to find a “kernel” for each transaction (lines 1248 and 1268).

It seems to work almost the same way in PoS and PoW. But there’s a difference with bitcoin: the difficulty is adjusted after every block, not after a certain time.

The only factors seems to be the time between the last two blocks, the previous difficulty and the target spacing (10 minutes).
…[/quote]

Thanks for the definitive answers backed with source code.


#120

There is, it’s just that the current “official” build of PPCoin-Qt (v0.3.0) doesn’t include a debug console built in and there’s no publicly accessible method to ask the daemon to report back minting status. You can parse your debug.log file and watch for “a block was found” messages, but that’s not ideal because it doesn’t echo anything in-progress.[/quote]
I’ve been thinking for a while too and even looked at some of the code. The best you would be able to get out that it is the event of looking and comparing with other clients every second as I understand. However this gives no indication of progress or your chances to mint.

What one really would like to see is how close you would be to mint a block. As that is apparently all based on chance and the model (and experimental calculator) I posted earlier, you won’t be able to find any useful data in the network itself. What I hoped for is that one of us would be able to find the amount of competing online coinage every second or would be able to calculate the coinage online from the blockchain or elsewhere, but I’m getting to the believe it is really not possible/non-existing.

BTW if anyone has any other ideas to progress the model (or any assumptions) I posted earlier in this thread, it would be highly appreciated. If it appears to be stable, we might include it in the existing minting calculator.