-
Notifications
You must be signed in to change notification settings - Fork 38.7k
Big endian support #5510
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Big endian support #5510
Conversation
23b1244 to
db2bac8
Compare
|
I am pleased to report that using this patch I was able to sync from scratch over the network a PPC (debian) host. The old 2.3GHz cpu was pretty slow at verifying eventually taking several seconds per block. """ The whole process took about 33 hours. |
c32fbeb to
289706e
Compare
|
Mac Mini PPC with 512MB RAM just finished testnet sync. Debian GNU/Linux 7.7. No issues so far. Even with few manual stops during the IBD. Generating new wallet was extremely slow... Few compile warnings for signed/unsigned and always true (I will investigate them later). |
src/arith_uint256.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just want to know if we completly stop doing any include ordering/cleanup or even stop following the style we currently have in most files? If the new philosophy is new features before everything else I'm losing the last fun for this project :-/.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry to hear that you don't find fun in many of the much more interesting things you've been doing before, but no - we removed this from the policy because the cost is just not worth the benefits. It requires too much time from maintainers and people writing patches for a very tiny (but non-zero) benefit, so we reverted it for that reason.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Diapolo Every code cleanup -- including those authored by myself -- has review costs and potentially disrupts more important functional work that actually changes behavior for the users.
Style takes a back seat to more practical changes, as it must. It sucks when it's your changes.
Include file ordering is just not important enough to us to care about maintaining it in our own changes. We absolutely value your contributions, but you have to understand how to work with everyone else in the project and judge your impact on other developers, not just the codebase.
We don't have rules, we have guidelines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this is the wrong place for this discussion. But better here then nowhere.
IMO clean code leads to good software quality in general.
Once the code gets a mess, the quality in general will follow.
"A broken window is the start of a vagabonded house". Thats why i honor @Diapolo work on one hand.
But:
1.)
Nowadays, code-structure can be handled by tools like clang-format. There is no need for nits for spaces, indents, etc.
Even if the clang-format output is not stable, i think a re-formatting from time-to-time over the whole code makes sense and will prevent us from thousands of nits and gives us more time to focus on the "real stuff".
2.)
Alphabetic ordering of includes just don't make sense. Someone does it, someone not. I think we don't need nit's for this.
3.)
Cleanup commits like #5616 are okay, but will break (requires rebase) all other and upcoming pull requests in this area. That's why i would recommend to keep these kind of pull request to a minimum. Better provide a large cleanup commit once (at best in a code-quiet time).
To much of cleanup-commit will slow down important work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Include ordering is there for a very good purpose, which is to ensure stand-alone headers. This purpose is just not really all that relevant in a project whose headers are not installed and exported for 3rd party use. Like a DLL based project would need it.
tl;dr dropping the requirement for header-inclusion-ordering makes sense to me.
|
utACK, nothing to complain about. Do you have an idea where the DNS issue lies? |
|
Mmm.. on second thought, I suppose I'd first like to know the result of moving a fully-sync'd .bitcoin dir from a BE machine to a LE one, or the other way around. |
|
@theuni As I mention in the OP, I've tested that, and it worked. UTXO databases and block databases are compatible between BE and LE. I haven't had time to look into the DNS seeding issue. |
|
DNS seeding works OK here on PPC Mac Mini: |
|
I'm moving the bitcoin directory there and back between LE and BE host without issues so far. |
|
@laanwj Ah, I missed that part in the description. Thanks for verifying. @paveljanik Thanks to you as well. |
289706e to
b7af281
Compare
|
Had to rebase over the openssl fix (no code changes or conflicts) to make tests work again. |
|
Added the missing float/double serialization tests and removed the WIP tag. |
9283a50 to
0ed3fdc
Compare
|
Everything seems to be working here as well! I am using a PowerMac G5 with Debian 7; I've been waiting for big endian support for a long time, and can't wait until this is merged into the main release! |
|
Untested ACK. We do have a few special-cased pieces of code for little-endian vs generic. Do we need all of them? I would suggest to either:
|
|
If any core developers would like, I can provide full SSH access to a Debian 7 PowerPC system for testing purposes to make sure future builds work on big endian systems. I would love for this to be integrated in a 0.10 release. |
|
@laanwj I would be fine with just getting rid of all LE optimized code versions here, and later benchmark whether any are worth it to add back. |
- Detect endian instead of stopping configure on big-endian - Add `byteswap.h` and `endian.h` header for compatibility with Windows and other operating systems that don't come with them - Update `crypto/common.h` functions to use compat endian header
|
@ry60003333 This is too late for the 0.10 release, but can make it to 0.11 in july @sipa OK, fine with me, there are two cases of WORDS_BIGENDIAN left and neither of them seems to be in a performance critical place. |
60b9a58 to
f16d769
Compare
|
Untested ACK. |
Serialization type-safety and endianness compatibility.
We've chosen to htons/ntohs explicitly on reading and writing (I do not know why). But as READWRITE already does an endian swap on big endian, this means the port number gets switched around, which was what we were trying to avoid in the first place. So to make this compatible, serialize it as FLATDATA.
Don't ever serialize a size_t or long, their sizes are platform dependent.
Removes variability between LE and BE. As suggested by @sipa.
f16d769 to
a0ae79d
Compare
a0ae79d Replace CBlockHeader::GetHash with call to SerializeHash (Wladimir J. van der Laan) 62b30f0 Add serialize float/double tests (Wladimir J. van der Laan) 9f4fac9 src/txmempool.cpp: make numEntries a uint32_t (Wladimir J. van der Laan) f4e6487 src/arith_256.cpp: bigendian compatibility (Wladimir J. van der Laan) aac3205 src/netbase.h: Fix endian in CNetAddr serialization (Wladimir J. van der Laan) 01f9c34 src/serialize.h: base serialization level endianness neutrality (Wladimir J. van der Laan) 4e853aa src/script/script.h: endian compatibility for PUSHDATA sizes (Wladimir J. van der Laan) 4f92773 src/primitives/transaction.h: endian compatibility in serialization (Wladimir J. van der Laan) 81aeb28 src/primitives/block.cpp: endian compatibility in GetHash (Wladimir J. van der Laan) dec84ca src/net.cpp: endian compatibility in EndMessage (Wladimir J. van der Laan) 556814e src/main.cpp: endian compatibility in packet checksum check (Wladimir J. van der Laan) 3ca5852 src/hash.cpp: endian compatibility (Wladimir J. van der Laan) 4414f5f build: Endian compatibility (Wladimir J. van der Laan)
|
@laanwj 0.11 would work for me! I've been looking forward to being able to run full nodes on IBM POWER servers for a long time now! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we are now also don't try to differentiate the blocks by own headers, standard headers and library headers?
25224a8 Replace CBlockHeader::GetHash with call to SerializeHash (random-zebra) 49a7716 Add serialize float/double tests (random-zebra) 83c6d13 src/txmempool.cpp: make numEntries a uint32_t (random-zebra) 70c6606 src/serialize.h: base serialization level endianness neutrality (random-zebra) 4ad83fe src/script/script.h: endian compatibility for PUSHDATA sizes (random-zebra) 74f1699 src/primitives/transaction.h: endian compatibility in serialization (random-zebra) b5e5de6 src/primitives/block.cpp: endian compatibility in GetHash (random-zebra) b6b4b3e src/net.cpp: endian compatibility in EndMessage (random-zebra) 1d84b73 src/netbase.h: Fix endian in CNetAddr serialization (random-zebra) 4d98939 src/main.cpp: endian compatibility in packet checksum check (random-zebra) fe2727b src/hash.cpp: endian compatibility (random-zebra) Pull request description: First step in getting our serialization code up to par with upstream. Backports bitcoin#5510 with only minor adjustments. > Fix issue bitcoin#888. > > This has been structured so that each compatibility change is one commit that touches only one file. After the initial build change, they are independent. > > Most extensive changes are in 'src/serialize.h: base serialization level endianness neutrality'. I had to replace READDATA and WRITEDATA with functions that take sized integer types to make use of the proper endian.h functions. I'm confident that the end result is the same, although this may require more tests. > > I've tested this on mipsbe32. > > All tests pass > Testnet syncs correctly > Node can successfully function on P2P mainnet Checked that data directory can be copied between endians with no adverse results (only peers.dat required special attention here) > Known issues (to be fixed before merge): > > DNS seeding always comes with 0 results on BE (confirmed as working by @paveljanik on real hardware, must have been issue with my qemu-user setup) ACKs for top commit: furszy: Everything working here, utACK 25224a8 Fuzzbawls: utACK 25224a8 Tree-SHA512: 047e3bd6a7c6bbbd341da1ec3fb7698e19d52e170ba0d475e6f451cbb52e2c55f23a15999da663a8022ddc9df3a5c168f825b779c4afb1fd210b9da680503297
Fix issue #888.
This has been structured so that each compatibility change is one commit that touches only one file. After the initial build change, they are independent.
Most extensive changes are in 'src/serialize.h: base serialization level endianness neutrality'. I had to replace READDATA and WRITEDATA with functions that take sized integer types to make use of the proper
endian.hfunctions. I'm confident that the end result is the same, although this may require more tests.I've tested this on mipsbe32.
Known issues (to be fixed before merge):
DNS seeding always comes with 0 results on BE(confirmed as working by @paveljanik on real hardware, must have been issue with my qemu-user setup)