Bitcoin Forum
December 15, 2024, 10:57:17 AM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: The first rule of Bitcoin is...  (Read 1567 times)
Hal (OP)
VIP
Sr. Member
*
expert
Offline Offline

Activity: 314
Merit: 4276



View Profile
March 16, 2011, 11:17:33 PM
 #1

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

Hal Finney
jgarzik
Legendary
*
qt
Offline Offline

Activity: 1596
Merit: 1100


View Profile
March 17, 2011, 12:39:09 AM
 #2

Good stuff.  Glad this is written down somewhere outside the source code.

Jeff Garzik, Bloq CEO, former bitcoin core dev team; opinions are my own.
Visit bloq.com / metronome.io
Donations / tip jar: 1BrufViLKnSWtuWGkryPsKsxonV2NQ7Tcj
Jim Hyslop
Member
**
Offline Offline

Activity: 98
Merit: 20


View Profile
March 17, 2011, 01:03:52 AM
 #3

Nice work, thanks.

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

Like my answer? Did I help? Tips gratefully accepted here: 1H6wM8Xj8GNrhqWBrnDugd8Vf3nAfZgMnq
Gavin Andresen
Legendary
*
qt
Offline Offline

Activity: 1652
Merit: 2311


Chief Scientist


View Profile WWW
March 17, 2011, 01:31:58 AM
 #4

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");

How often do you get the chance to work on a potentially world-changing project?
JollyGreen
Newbie
*
Offline Offline

Activity: 42
Merit: 0


View Profile
March 17, 2011, 05:07:05 AM
 #5

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


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.
mitchy
Newbie
*
Offline Offline

Activity: 6
Merit: 0


View Profile WWW
March 19, 2011, 08:09:26 PM
 #6

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 Smiley

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.

Mike Hearn
Legendary
*
expert
Offline Offline

Activity: 1526
Merit: 1134


View Profile
March 21, 2011, 09:54:20 AM
 #7

Thanks Hal, this will be very useful.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!