Michael Offel [ARCHIVE] on Nostr: 📅 Original date posted:2011-07-12 🗒️ Summary of this message: A discussion on ...
📅 Original date posted:2011-07-12
🗒️ Summary of this message: A discussion on the Bitcoin client's codebase, including suggestions for a new clean code base, moving hardcoded values to a chain description file, and the use of boost and Berkeley db. The importance of clean and well-documented code is emphasized.
📝 Original message:Monday, July 11, 2011, 12:31:20 AM, Jeff Garzik wrote:
>> 2. isolation of modules
> It is a long term goal to move towards 'libbitcoin"
What about creating a branch and start libbtc by implementing a small
module like irc or p2p connection handling and use the new lib in the
client. I think this would be a proper start for a new clean code base
without having a non functional client for some time and it also
provides some kind of red line between libbtc (cleaned up code) and
the old code base, making it easy to maintain order.
Would this approach be accepted for a merge?
Monday, July 11, 2011, 12:36:53 AM, Matt Corallo wrote:
>> While I can guess what the CScript class does I would more like to understand the thoughts behind the decision to implement some crypto macros in a compile time interpreter and
>> why Berkeley db 4 is used at all.
> At the time Bitcoin began being built, Ubuntu 9.04 (or was it 9.10?) was
> used, as it offered the oldest libc on the newest OS. Ubuntu 9.04 just
> happened to only have db4.7. For backward compatibility, db4.7 has been
> used ever since (except, for some reason, the osx builds). In 0.4,
> db4.8 will be used. If you are asking why bdb was used to begin with,
> why not? its an excellent db and why reinvent the wheel?
It was more meant as an rhetorical question. A documented decision
would give anyone the chance of arguing against the usage of a library
instead of asking stupid questions. A mailing list archive suits well
for this type of information, so let me try to get some information
here. Db4 is an excellent choice if you need indexed database
functionality without SQL interface. But compared to an stl map lookup
and fopen, fwrite and fclose it is much harder to understand and
brings a lot performance overhead. This is true as long as your
information are small enough to stay in main memory. A stl map storing
file offsets is also not that hard to write and understand. On the
other side using an SQL interface would bring the advantage of
swapping database providers. An enterprise website could use oracle
while the average user could use sqlite. Also is db4 used for any type
of disk storage, this makes files like wallet.dat some kind of hard to
read. It is in no way more secure than storing private key's in an xml
file. But it is much harder to maintain and understand by the user and
the average programer.
> If you are on Windows, why are you on Windows? ;)
I'm forced to to use windows by the type of clients I'm working for.
And during leisure I like to use a System that does not need much
effort to simply do what it is made for. ;)
>>
>> 6. hardcoded values
>>
>> There are tons of hardcoded values for the official and the testnet block chain. It would be a great step to move all chain related settings to a chain description file. This would allow custom chains and clean up the code.
> This one is an interesting debate. There is no real reason to do this
> aside from some questionable code cleanup. Also, there is no reason to
> encourage improperly-implemented alternate chains. Alternate chains
> should be designed in such a way as to share the main chain's difficulty
> as described by Mike on the forum, not just make a new chain and hope it
> sticks.
It is not that interesting as it looks first. There is no good in
running multiple chains for production use. To share the difficulty is
indeed a good start to solve the problem. That's also one of the
things I don't like off the QBitcoin client. What I meant is just
to have the possibility to have all adjustable parameters in one place
and to be able to quickly build an internal testnet without crazy
firewalling to prevent it from dying. The first would allow to detect
problematic ddos protection settings early and giving the average user
the possibility to adjust all important settings if he knows what he
does. That includes not only alternate chains. One could choose to
include transactions only at a higher fee or at no fee at all.
Everyone could do such things by changing the code anyway. But not all
brilliant administrators or users are programmers.
>> The official Bitcoin client should be some kind of an reference project for other clients and must therefore be extra clean and well documented.
> True, but it is much higher priority to clean up the code than comment
> it better, plus there are various other features/more user-facing issues
> that need fixed as well, so...
Good code is the best documentation anyway.
Monday, July 11, 2011, 3:01:51 AM, Luke-Jr wrote:
>> My overall suggestion is to begin a complete rewrite, inspired by the old
>> code rather than moving a lot of "known to be somehow functional" around.
> There are many rewrites in progress, often with much better designs.
There is no other client that uses C and is meant to be a full
implementation and platform independent except QBitcoin. QBitcoin seems
to have no public repository to work on or I have overlooked it ?!?
Starting a new client on my own is just like starting an other never
ending and never used open source project.
>> The official Bitcoin client should be some kind of an reference project
>> for other clients and must therefore be extra clean and well documented.
> Bitcoin is supposed to be an authorityless project. There is no official.
While there is no authority, there is just one fully working client to
look at. This may lead to an working but instable network if other
clients are trying to interpret net.cpp and fail on it in details.
>> *everything else*
> Fix it yourself and submit the changes. If they don't get merged, fork.
As I said, there is no need for an other never ending story. I would
like to know if my affords have a chance to get merged or accepted
before I start to work on it.
Tuesday, July 12, 2011, 4:31:07 AM, Gavin Andresen wrote:
> We'll just tell everybody to stop using bitcoin so much for six months
> or so while we implement a much better client. It will be exactly
> like the bitcoin we have now, except with a much nicer internal
> architecture and much cleaner code-base, and we're pretty sure we can
> get it done in six months if everything goes exactly as planned.
It is some kind of arrogant to believe that anyone would stop using
bitcoin if some programers decide to stop working for some month. And
it is also fond to not fix bugs in the old code base if they appear.
Also there are lots of people out there using old clients anyway. The
important improvement is more about quick extendibility and therefore
more feature rich secure code. This would not only help the official
code base, it would also improve trust and result in better external
bitcoin related projects.
> Then again, it might be easier to modify the
> CRITICAL_SECTION code to detect and report deadlocks (anybody have
> experience doing that?).
That would be true if possible, but I'm pretty sure that the only way
to detect deadlocks is by either analyzing the code or single step
simulating it, what is really tricky on network applications.
Tuesday, July 12, 2011, 6:19:28 AM, Jeff Garzik wrote:
>> While spying on the old code, I noticed one major problem that could be
>> fixed quite easily. That is, the 1 class-per .h/.cpp rule is completely
>> ignored in main.h/cpp and net.h/cpp If all of the classes in the project
>> were re-factored to their own files,
> This is about the last thing we should do, and it's one of the worst
> coding practices of many C++ projects (and unfortunately carried over
> to Java by force). See Knuth and his work on literate programming.
> Putting logically similar code -together- is often more impactful and
> meaningful than splitting up files into dozens (hundreds or thousands,
> in large projects) of tiny, 20-line files.
We seem to have very different opinions on that, but let's try to be
objective. I belive that every class should be able to stand on its
own. That way it can be reused in other projects or situations in the
same project. And it is much more easy to catch and extend class
behavior if it is isolated to one file instead of multiple files or
mixed between other class methods in one file. On the other hand, what
is bad on having 50-80 code files in bitcoin? In terms of source
control it even gives some kind of easier to read history and fewer
merge conflicts. When you start writing a class for exactly one
propose in one specific situation used by one other class you should
think about writing a nested class, which can and should be
implemented in the same cpp file. That way you can achieve you similar
code in one location while accepting the rule others like.
Another nice side effect is the ability to see a class dependency list
be looking at the include listing.
Tuesday, July 12, 2011, 8:21:12 AM, John Smith wrote:
> re:4) I also don't see why boost would be a 'nonstandard
> dependency'. From what I understand, a large part of the new C++0x
> standard is derived from boost. Also C++ compilers are getting
> faster and more smart all the time, so I absolutely don't see "build speed" as a goal.
Don't get me wrong. If boost would be used for something meaningful
there would be no point in removing it. Everything non questionable
about boost does already find its way into most stl implementations.
And everything that find it's way into C++ 0x does it for the reason
that it is better handled by an language extension than by an boost
construct. Otherwise there would be no point in extending the language.
Michael
Published at
2023-06-07 02:04:50Event JSON
{
"id": "10bad963f09cf0056ea073e08b23300838c515f50748b2098d7652a496f12b80",
"pubkey": "4a8239700cd41727170819f472a0378d295f559c9e333f7e73433b91f0a53f6c",
"created_at": 1686103490,
"kind": 1,
"tags": [
[
"e",
"4eaf1439aa67825cabdea581be3956c38ea4a62226b60d5367bace64dca7945b",
"",
"root"
],
[
"e",
"5899bf80fbe4df61445fd814067a29118e97c93f481777869936d1edda489fc6",
"",
"reply"
],
[
"p",
"4a8239700cd41727170819f472a0378d295f559c9e333f7e73433b91f0a53f6c"
]
],
"content": "📅 Original date posted:2011-07-12\n🗒️ Summary of this message: A discussion on the Bitcoin client's codebase, including suggestions for a new clean code base, moving hardcoded values to a chain description file, and the use of boost and Berkeley db. The importance of clean and well-documented code is emphasized.\n📝 Original message:Monday, July 11, 2011, 12:31:20 AM, Jeff Garzik wrote:\n\u003e\u003e 2. isolation of modules\n\u003e It is a long term goal to move towards 'libbitcoin\"\nWhat about creating a branch and start libbtc by implementing a small\nmodule like irc or p2p connection handling and use the new lib in the\nclient. I think this would be a proper start for a new clean code base\nwithout having a non functional client for some time and it also\nprovides some kind of red line between libbtc (cleaned up code) and\nthe old code base, making it easy to maintain order.\nWould this approach be accepted for a merge?\n\n\nMonday, July 11, 2011, 12:36:53 AM, Matt Corallo wrote:\n\u003e\u003e While I can guess what the CScript class does I would more like to understand the thoughts behind the decision to implement some crypto macros in a compile time interpreter and \n\u003e\u003e why Berkeley db 4 is used at all.\n\u003e At the time Bitcoin began being built, Ubuntu 9.04 (or was it 9.10?) was\n\u003e used, as it offered the oldest libc on the newest OS. Ubuntu 9.04 just\n\u003e happened to only have db4.7. For backward compatibility, db4.7 has been\n\u003e used ever since (except, for some reason, the osx builds). In 0.4,\n\u003e db4.8 will be used. If you are asking why bdb was used to begin with,\n\u003e why not? its an excellent db and why reinvent the wheel?\nIt was more meant as an rhetorical question. A documented decision\nwould give anyone the chance of arguing against the usage of a library\ninstead of asking stupid questions. A mailing list archive suits well\nfor this type of information, so let me try to get some information\nhere. Db4 is an excellent choice if you need indexed database\nfunctionality without SQL interface. But compared to an stl map lookup\nand fopen, fwrite and fclose it is much harder to understand and\nbrings a lot performance overhead. This is true as long as your\ninformation are small enough to stay in main memory. A stl map storing\nfile offsets is also not that hard to write and understand. On the\nother side using an SQL interface would bring the advantage of\nswapping database providers. An enterprise website could use oracle\nwhile the average user could use sqlite. Also is db4 used for any type\nof disk storage, this makes files like wallet.dat some kind of hard to\nread. It is in no way more secure than storing private key's in an xml\nfile. But it is much harder to maintain and understand by the user and\nthe average programer.\n\n\u003e If you are on Windows, why are you on Windows? ;)\nI'm forced to to use windows by the type of clients I'm working for.\nAnd during leisure I like to use a System that does not need much\neffort to simply do what it is made for. ;)\n\n\u003e\u003e\n\u003e\u003e 6. hardcoded values\n\u003e\u003e \n\u003e\u003e There are tons of hardcoded values for the official and the testnet block chain. It would be a great step to move all chain related settings to a chain description file. This would allow custom chains and clean up the code.\n\u003e This one is an interesting debate. There is no real reason to do this\n\u003e aside from some questionable code cleanup. Also, there is no reason to\n\u003e encourage improperly-implemented alternate chains. Alternate chains\n\u003e should be designed in such a way as to share the main chain's difficulty\n\u003e as described by Mike on the forum, not just make a new chain and hope it\n\u003e sticks.\nIt is not that interesting as it looks first. There is no good in\nrunning multiple chains for production use. To share the difficulty is\nindeed a good start to solve the problem. That's also one of the\nthings I don't like off the QBitcoin client. What I meant is just\nto have the possibility to have all adjustable parameters in one place\nand to be able to quickly build an internal testnet without crazy\nfirewalling to prevent it from dying. The first would allow to detect\nproblematic ddos protection settings early and giving the average user\nthe possibility to adjust all important settings if he knows what he\ndoes. That includes not only alternate chains. One could choose to\ninclude transactions only at a higher fee or at no fee at all.\nEveryone could do such things by changing the code anyway. But not all\nbrilliant administrators or users are programmers.\n\n\u003e\u003e The official Bitcoin client should be some kind of an reference project for other clients and must therefore be extra clean and well documented.\n\u003e True, but it is much higher priority to clean up the code than comment\n\u003e it better, plus there are various other features/more user-facing issues\n\u003e that need fixed as well, so...\nGood code is the best documentation anyway.\n\nMonday, July 11, 2011, 3:01:51 AM, Luke-Jr wrote:\n\u003e\u003e My overall suggestion is to begin a complete rewrite, inspired by the old\n\u003e\u003e code rather than moving a lot of \"known to be somehow functional\" around.\n\u003e There are many rewrites in progress, often with much better designs.\nThere is no other client that uses C and is meant to be a full\nimplementation and platform independent except QBitcoin. QBitcoin seems\nto have no public repository to work on or I have overlooked it ?!?\nStarting a new client on my own is just like starting an other never\nending and never used open source project.\n\n\u003e\u003e The official Bitcoin client should be some kind of an reference project\n\u003e\u003e for other clients and must therefore be extra clean and well documented.\n\u003e Bitcoin is supposed to be an authorityless project. There is no official.\nWhile there is no authority, there is just one fully working client to\nlook at. This may lead to an working but instable network if other\nclients are trying to interpret net.cpp and fail on it in details.\n\n\u003e\u003e *everything else*\n\u003e Fix it yourself and submit the changes. If they don't get merged, fork.\nAs I said, there is no need for an other never ending story. I would\nlike to know if my affords have a chance to get merged or accepted\nbefore I start to work on it.\n\nTuesday, July 12, 2011, 4:31:07 AM, Gavin Andresen wrote:\n\u003e We'll just tell everybody to stop using bitcoin so much for six months\n\u003e or so while we implement a much better client. It will be exactly\n\u003e like the bitcoin we have now, except with a much nicer internal\n\u003e architecture and much cleaner code-base, and we're pretty sure we can\n\u003e get it done in six months if everything goes exactly as planned.\nIt is some kind of arrogant to believe that anyone would stop using\nbitcoin if some programers decide to stop working for some month. And\nit is also fond to not fix bugs in the old code base if they appear.\nAlso there are lots of people out there using old clients anyway. The\nimportant improvement is more about quick extendibility and therefore\nmore feature rich secure code. This would not only help the official\ncode base, it would also improve trust and result in better external\nbitcoin related projects.\n\n\u003e Then again, it might be easier to modify the\n\u003e CRITICAL_SECTION code to detect and report deadlocks (anybody have\n\u003e experience doing that?).\nThat would be true if possible, but I'm pretty sure that the only way\nto detect deadlocks is by either analyzing the code or single step\nsimulating it, what is really tricky on network applications.\n\nTuesday, July 12, 2011, 6:19:28 AM, Jeff Garzik wrote:\n\u003e\u003e While spying on the old code, I noticed one major problem that could be\n\u003e\u003e fixed quite easily. That is, the 1 class-per .h/.cpp rule is completely\n\u003e\u003e ignored in main.h/cpp and net.h/cpp If all of the classes in the project\n\u003e\u003e were re-factored to their own files,\n\u003e This is about the last thing we should do, and it's one of the worst\n\u003e coding practices of many C++ projects (and unfortunately carried over\n\u003e to Java by force). See Knuth and his work on literate programming.\n\u003e Putting logically similar code -together- is often more impactful and\n\u003e meaningful than splitting up files into dozens (hundreds or thousands,\n\u003e in large projects) of tiny, 20-line files.\nWe seem to have very different opinions on that, but let's try to be\nobjective. I belive that every class should be able to stand on its\nown. That way it can be reused in other projects or situations in the\nsame project. And it is much more easy to catch and extend class\nbehavior if it is isolated to one file instead of multiple files or\nmixed between other class methods in one file. On the other hand, what\nis bad on having 50-80 code files in bitcoin? In terms of source\ncontrol it even gives some kind of easier to read history and fewer\nmerge conflicts. When you start writing a class for exactly one\npropose in one specific situation used by one other class you should\nthink about writing a nested class, which can and should be\nimplemented in the same cpp file. That way you can achieve you similar\ncode in one location while accepting the rule others like.\nAnother nice side effect is the ability to see a class dependency list\nbe looking at the include listing.\n\nTuesday, July 12, 2011, 8:21:12 AM, John Smith wrote:\n\u003e re:4) I also don't see why boost would be a 'nonstandard\n\u003e dependency'. From what I understand, a large part of the new C++0x\n\u003e standard is derived from boost. Also C++ compilers are getting\n\u003e faster and more smart all the time, so I absolutely don't see \"build speed\" as a goal.\nDon't get me wrong. If boost would be used for something meaningful\nthere would be no point in removing it. Everything non questionable\nabout boost does already find its way into most stl implementations.\nAnd everything that find it's way into C++ 0x does it for the reason\nthat it is better handled by an language extension than by an boost\nconstruct. Otherwise there would be no point in extending the language.\n\nMichael",
"sig": "401fc7bc035662dd5b44a0b26f11a6b2ae584b5cb7cac745a3ed1520d8382c67467018e6ac09eaf3853ca9a4f4226b6265bc119365108ce3618fa6416e72c57b"
}