2 ms·
If you know where the documentation for the most popular DeFi system, Bitcoin, is, then by all means share it. • What does the peer-to-peer network protocol lo
by wizzwizz4 5y ago
If you know where the documentation for the most popular DeFi system, Bitcoin, is, then by all means share it.
• What does the peer-to-peer network protocol look like?
• How do I make a transaction / mine a block?
I know how to do this using end-user wallet applications, but the open protocols are so very well documented that I'm sure you can find this information easily.
The pages that show up in search results[0][1] don't really have this information. It gives me a high-level overview, tells me that it uses TCP and which port it uses, and gives the structure of the TCP packets (with some examples), but there's a whole load of stuff that's just never defined. To actually understand what's going on, I then have to read the source code.
And… making a transaction?[3] Mining a block?[2] No chance. I know it's “double SHA256” and that's about it. (I can look at the source code to find out, sure… but an open standard? Open secret, more like. The flaming whitepaper[4] is more useful than these docs.)
This is Bitcoin, the best-known, most-popular, (presumably) best-documented DeFi system on the 'net. Ethereum has… a blog post, an onlinelibrary.wiley.com book and an academic article. I don't even want to know what other stuff has. Most DeFi garbage barely has a whitepaper.
[0]: https://developer.bitcoin.org/devguide/p2p_network.html https://developer.bitcoin.org/devguide/p2p_network.html
[1]: https://developer.bitcoin.org/reference/p2p_networking.html https://developer.bitcoin.org/reference/p2p_networking.html
[2]: https://developer.bitcoin.org/reference/block_chain.html#serialized-blocks https://developer.bitcoin.org/reference/block_chain.html#ser...
[3]: https://developer.bitcoin.org/reference/transactions.html https://developer.bitcoin.org/reference/transactions.html
[4]: https://bitcoin.org/bitcoin.pdf https://bitcoin.org/bitcoin.pdf (which has apparently been taken down…?) https://web.archive.org/web/20140320135003if_/https://bitcoin.org/bitcoin.pdf https://web.archive.org/web/20140320135003if_/https://bitcoi...
- spinny 5y ago"How do I make a transaction / mine a block?" that's a "how does it works ?" kind of question, you need to know how all the small parts work to explain the functionality. Yes, some aspects you need to look at the code, others you will find documented i would recommend https://learnmeabitcoin.com/ https://learnmeabitcoin.com/ which has very in-depth resources but it seems to be down at the moment
- wizzwizz4 5y ago> you need to know how all the small parts work to explain the functionality. I know how all the small parts work. It's not new technology. I just don't know how Bitcoin does it! To mine a block, you: • collect a load of transactions (somehow) • validate them (the obvious stuff, plus the special transaction type requirements, plus unspecified “consensus“ magic I can't find anywhere) • put them in a block (somehow) along with the hash of the most recent block • keep changing a certain bit of the block until SHA256(f(SHA256(block))) is low enough (with some f: digest → bitstring) But I can't fill in the gaps.
- spinny 5y agocollect a load of transactions (somehow): by this you mean the mempool. the implementation is client dependent, it uses the p2p network to receive new txs, thats what you need to look at to know how to "get txs from the network". some implementations have better documentation. if you need to look at code i would recommend the go implementation https://github.com/btcsuite https://github.com/btcsuite just because it looks cleaner to me. validate them: your best resource for this is code. your client needs to keep old consensus code around and use it to verify block under the older rules (your client will do a full sync at some point) rules for formatting a transactions and blocks (and a byte by byte explanation) can be found on https://learnmeabitcoin.com/ https://learnmeabitcoin.com/ as mentioned (probably will be up soon) keep changing a certain bit of the block until SHA256(f(SHA256(block))) is low enough (with some f: digest → bitstring): yes. you set the block nonce to mine. finding a block means that the hash256() operation (sha256(sha256(block))) returns an hash with at least D (either left or right most, can't recall right now) bits set to 0, where D is the current difficult, which is adjusted by the network to make the 10min/block average time
- wizzwizz4 5y agoAh, so “you have to look at the code” is a feature, not a bug. That makes some sense, I suppose. > finding a block means that the hash256() operation (sha256(sha256(block))) returns an hash with at least D (either left or right most, can't recall right now) bits set to 0, where D is the current difficult, which is adjusted by the network to make the 10min/block average time This is a lies-to-children explanation. Bitcoin actually uses less-than a certain value (source: [0]). The tricky part is that a SHA-256 digest is a 256-bit number, and the SHA-256 function's input is a sequence of bits; the SHA-256 specification explicitly declines to specify a canonical representation of that 256-bit number, so it can't be used as the input to SHA-256 without explaining how it's being used. I can't find anywhere what this intermediate function (the one I called f) actually is. There are only half a dozen obvious possibilities (bits from most→least, or least→most, and the four normal ways of doing ASCII hex digests) so it's not that hard to guess, given an example… but still. It's the principle of the matter; it's all under-documented. (Thanks for the rest of the info by the way. You've given me leads I wouldn't otherwise have been able to easily find.) [0]: https://en.bitcoin.it/wiki/Difficulty https://en.bitcoin.it/wiki/Difficulty
- erulabs 5y agoCalling Bitcoin defi slightly stretches the definition. Typically defi relates to smart contracts - of which there is plenty of documentation, and which is vastly -not- built on Bitcoin. Saying “Bitcoin is defi and look, no defi docs!” is ignorant and best and aggressively disingenuous at worst. Yes BTC is decentralized finance, but it’s not the same as “DeFi” strictly speaking. If you want to read some “DeFi docs”, there are PLENTY - you can start here: https://docs.soliditylang.org/en/v0.8.10/ https://docs.soliditylang.org/en/v0.8.10/
- wizzwizz4 5y agoBitcoin does have smart contracts; it has its own bytecode language. What about it isn't “DeFi”?
- erulabs 5y agoYou appear to be enraged that a specific open-source project you chose doesn't have good enough documentation for a specific feature you want, which is not the main aim of the project. Not sure I can help. Additionally, all the answers to your question are contained in my first comment.
- wizzwizz4 5y agoI don't intend to appear enraged; that's certainly not the case! (I'm amused and sarcastic, if anything.) I know it's a tangent, but if you could explain why you have this perception, I'd be grateful. > that a specific open-source project you chose It was but an example; I assert the rest are also like that. I chose Bitcoin because it is the biggest, but I could just as easily have chosen Ethereum (as I have already said). > doesn't have good enough documentation for a specific feature you want, which is not the main aim of the project. If not making transactions, blocks, and mining, what is the main aim of Bitcoin? > Additionally, all the answers to your question are contained in my first comment. You provided a link to the documentation for Solidity, one of many high-level languages over the Ethereum VM. While it provides a little documentation of Ethereum bytecode, and a high-level overview of how Ethereum is used to handle smart contracts, this isn't Ethereum documentation. The answers are not to be found there. (And I don't expect you to help; I'm aware that the answers aren't easy to find. That's my whole point!)