Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: Hal on March 16, 2011, 11:17:33 PM



Title: The first rule of Bitcoin is...
Post by: Hal on March 16, 2011, 11:17:33 PM
Follow the rules!

I've put up a wiki page listing the rules used by the client to process transactions and blocks. It's a bit linear and could benefit from some refactoring, but I didn't want to go too far in terms of pseudocode, because IMO it obscures the logic.

https://en.bitcoin.it/wiki/Protocol_rules (https://en.bitcoin.it/wiki/Protocol_rules)


Title: Re: The first rule of Bitcoin is...
Post by: jgarzik on March 17, 2011, 12:39:09 AM
Good stuff.  Glad this is written down somewhere outside the source code.


Title: Re: The first rule of Bitcoin is...
Post by: Jim Hyslop on March 17, 2011, 01:03:52 AM
Nice work, thanks.

I've added some explanations for some of the more obscure rules, and removed a redundant step.


Title: Re: The first rule of Bitcoin is...
Post by: Gavin Andresen on March 17, 2011, 01:31:58 AM
Very nice!

The 'sig opcount <= 2' rule for tx relaying is slated to change with the 'sendmany' patch I pulled on Monday.

The new rule will be 'sig opcount <= size/34

Code:
    // Checking ECDSA signatures is a CPU bottleneck, so to avoid denial-of-service                                                       
    // attacks disallow transactions with more than one SigOp per 34 bytes.                                                               
    // 34 bytes because a TxOut is:                                                                                                       
    //   20-byte address + 8 byte bitcoin amount + 5 bytes of ops + 1 byte script length                                                 
    if (GetSigOpCount() > nSize / 34 || nSize < 100)
return error("AcceptToMemoryPool() : nonstandard transaction");


Title: Re: The first rule of Bitcoin is...
Post by: JollyGreen on March 17, 2011, 05:07:05 AM
Follow the rules!

I've put up a wiki page listing the rules used by the client to process transactions and blocks. It's a bit linear and could benefit from some refactoring, but I didn't want to go too far in terms of pseudocode, because IMO it obscures the logic.

https://en.bitcoin.it/wiki/Protocol_rules (https://en.bitcoin.it/wiki/Protocol_rules)


This is a great idea, I think we should do this for a lot of the bitcoin code, it took a while to wrap my head around a lot of the algorithms in the bitcoin source.


Title: Re: The first rule of Bitcoin is...
Post by: mitchy on March 19, 2011, 08:09:26 PM
I was very curious and searched for a day to try and learn exactly step by step what the formula was for Generating a Block. A plaintext spec would have helped . I've nearly reached my quota of reading math i barely comprehend :)

Thx for the post and yes I agree to clarifying a lot of the bitcoin code. I searched a few times for an RFC but only found the first whitepaper and misc source.



Title: Re: The first rule of Bitcoin is...
Post by: Mike Hearn on March 21, 2011, 09:54:20 AM
Thanks Hal, this will be very useful.