I'm trying to understand how a stratum proxy works, which I think sort of what the stratum part of p2pool is, as well as Slush's stratum proxy. I'm hoping there's a flaw in my logic somewhere or I'm missing something.
Here's how I understand it.
p2pool determines the coinbase needed for the block we're trying to solve. that coinbase, among other things, contains the payout addresses of the users in the sharechain and the amount each user should receive should the block be solved.
according to the stratum docs I've read, the beauty of stratum is that the miner generates the work. for that to happen, the stratum server feeds the miner everything it needs to generate work, including the coinbase, a nonce1, and the required size of nonce2. the miner derives nonce2, which is how the miner is able to generate work. I think in most cases nonce2 is nothing more than a counter, since changing the value by 1 is enough to generate a completely different hash, and maybe just maybe solve a block. Regardless of whether it's a counter or not, the size is still controlled by the stratum server (p2pool in this case).
here's where I'm stuck.
if the nonce2 size is 4 bytes, there are 2^32 different possibilities, or to be precise, 4,294,967,296 possibilities. that's roughly 4.3 billion.
so, p2pool gives the miner the work. if it's a 4 byte nonce2 size, the miner has 4.2billion hashes it can go through before it starts generating the same hashes again, unless p2pool gives it new work. unless I'm missing something, a miner running at 1 gh/s will take 4.2 seconds to go through all those possibilities. an Ant running at 180gh/s will exhaust that in 0.02 seconds.
I have to assume my math is wrong, or nonce2 is much larger than 4 bytes. otherwise my ants are wasting a lot of time.
that's just one worker. let's say there are 10 workers on the pool. p2pool has to be providing unique work to each miner, else each miner will eventually be generating the same hashes, unless nonce2 is sufficiently large, or each gets a different nonce1. I have to think this is working properly, else when a valid block is out there for a certain hash, more than one worker is going to find it, it's just a matter of who gets it first.
now if I consider Slush's stratum proxy, I get more bewildered. let's say you have this stratum proxy sitting between you and a stratum pool. you do that so your 10 ants use one connection instead of 10 connections. the pool feeds the proxy the required work, coinbase info, nonce1, and nonce2 size. the proxy now needs to relay to that to the workers in a way that each will generate unique work, else they are working redundantly. if nonce1 is unchangable, we have the same problems. nonce2 has to be large enough so that each worker gets a large enough space so that it doesn't exhaust the entire space before new work is available and also doesn't cross over into another worker's work.
this leads me to believe:
1 - I'm missing something fundamental
2 - nonce1 can be changed without the pool objecting
3 - nonce2 is much much larger than 4 bytes
can someone help please?
thanks.
M