7 ms·
A blockchain in 200 lines of code
- jamiehoward 10y agoI'm not familiar with blockchains. Super interesting idea.
- logicallee 10y agoI wonder if anyone thought of making a distributed operating system where 1-2 million people could all run a NINTENDO console or something else extremely primitive - but in way that they KNOW no one is pulling any shenanigans. Can you imagine how cool it would be if a million or, say, a hundred million people joined forces to do what a $60 mobile phone can do? This is absolutely the future. No doubt about it. No one can ever conceivably come up with a paradigm as cool as this level of redundancy. And on top of all of this, it even works. (Not as designed, because 51% of miners may be controlled by one entity, but in practice it totally works.)
- frik 10y agosounds like Ethereum: https://en.wikipedia.org/wiki/Ethereum https://en.wikipedia.org/wiki/Ethereum "Ethereum is an open-source, public, blockchain-based distributed computing platform featuring smart contract (scripting) functionality. It provides a decentralized virtual machine, the Ethereum Virtual Machine (EVM). This virtual machine can execute Turing-complete scripts using an international network of public nodes and a token called ether. Gas, an internal transaction pricing mechanism, is used to prevent spam on the network and allocate resources proportionally to the incentive offered by the request" Unrelated, I remember an experiment on Twitch, where hundreds of viewers controlled/played Pokémon Yellow (Gameboy emulator) live on Twitch via chat commands like "left", "right". It more or less worked out fine, but was rather slow progress.
- JoshTriplett 10y ago> Unrelated, I remember an experiment on Twitch, where hundreds of viewers controlled/played Pokémon Yellow (Gameboy emulator) live on Twitch via chat commands like "left", "right". It more or less worked out fine, but was rather slow progress. https://en.wikipedia.org/wiki/Twitch_Plays_Pok%C3%A9mon https://en.wikipedia.org/wiki/Twitch_Plays_Pok%C3%A9mon
- wayn3 10y agoexcept twitch plays pokemon was meant for entertainment. the purposeless waste of resources on bitcoin is a cult, believed to enlighten the world.
- deleted 10y ago[deleted]
- gcr 10y agoBOINC pioneered this sort of shared computation to do massively data parallel experiments for astrophysics research in the early 00s. I think they still do. These days, I think the hardware investment is much lower than the software+infrastructure+social investment of running your experiment on BOINC.
- tech_man7 10y agoThe Golem team (https://golem.network/ https://golem.network/) got their inspiration from BOINC. But now more people will have incentive to share their compute power because they will be paid.
- Lev1a 10y agoIIRC the focus of these kinds of infrastructures has shifted towards protein folding [1] which could IMO prove more useful than astrophysics. [1] https://en.wikipedia.org/wiki/Protein_folding https://en.wikipedia.org/wiki/Protein_folding
- tech_man7 10y agoThat is what Golem is building (https://golem.network/ https://golem.network/). Decentralized compute power that is a global P2P network of PCs. The platform will allow software developers to put their software on top as long as its approved (e.g. to make sure it's not malicious).
- logicallee 10y agoFor anyone reading this later: the above was sarcastic but I left off the /s. I don't think blockchains are that great of a fundamental primitive. Though, independent of application, they were extemely novel.
- tech_man7 10y agoyou don't need a blockchain for computations; only for transferring value from buyer to seller.
- hdhzy 10y agoOne caveat: Bitcoin doesn't choose longest chain by the number of blocks but rather the difficulty, see https://en.bitcoin.it/wiki/Difficulty https://en.bitcoin.it/wiki/Difficulty
- chjj 10y agoMore specifically, it chooses by cumulative work. Bitcoin needs that behavior because of retargetting (a lesser height chain may have required more proof of work to build than a higher height one). If your custom blockchain has a static target, choosing the best chain by height is perfectly fine. Though, I'm not sure how useful a blockchain without retargetting or POW would be.
- tromp 10y agoReal blockchains do have a blockheader.prevHash field to indicate that the previous block is the one satisfying HASH(prevheader) == blockheader.prevHash This one actually adds a blockheader.hash field and instead compares prevheader.hash == blockheader.prevHash Naive indeed:-)
- runeks 10y agoGood video+interactive explanation: https://anders.com/blockchain/ https://anders.com/blockchain/
- bascule 10y agoThough blockchain is an ill-defined term, this seems to be missing the most important part of one: consensus. Bitcoin achieves this in two ways: - Proof-of-Work, which effectively functions as a leader election algorithm - Consensus programs, which mediate any changes to the blockchain. Each Bitcoin transaction has an associated script that determines how it can be spent. A conforming block satisfies all of the scripts for all of the transactions being spent. This particular post illustrates something which I would say is little more than a Merkle tree[1], except it isn't even that. But perhaps it's illustrative for some people. [1]: https://en.wikipedia.org/wiki/Merkle_tree https://en.wikipedia.org/wiki/Merkle_tree
- kordless 10y agoI suppose we could look at consensus as means by which multiple blockchains are collapsed into a single chain which contains the "truth" for multiple entities or aggregates. Once a collapse or consensus occurs, the chain, regardless of who holds it, would contain the truth.
- throwaway91111 10y agoWithout consensus, what distinguishes a block chain from a Merkle tree?
- saurik 10y agoThe Merkle tree is only used within a Bitcoin block to store transactions in an efficient manner; it isn't part of the block chain. A block chain without consensus isn't even a tree: it is just a singly-linked list with cryptographic guarantees that given a linked list node, all previous entries can be "verified". However, as other people have pointed out, this implementation is so incorrect that it fails to even do that: it contains only the hash of the previous data, not the hash of the previous node, so this actually only manages to verify the previous one entry of the chain :/. This is essentially just a linked list :(.
- 10y ago
- mamon 10y agoIs this just me or is this blockchain algorithm really similar to stringing together commits in Git? Can Git be considered "blockchain" application?
- lisper 10y agoYep. Git and blockchains both use Merkle trees to keep a consistent history. https://news.ycombinator.com/item?id=9436847 https://news.ycombinator.com/item?id=9436847
- deleted 10y ago[deleted]
- throwawayish 10y agoThe hash tree (Merkle Tree) is only part of it. The proof-of-work and consensus / voting protocols are the other (main) part.
- OJFord 10y agoWhich this doesn't have.
- oconnor663 10y agoThere are lots of different applications where one part of a data structure refers to another part by its hash. BitTorrent is one. HTTPS certificates also do some of this I think.
- spraak 10y agoI don't understand why someone would use an ES6 feature like arrow funcs, but still use `var`
- inimino 10y agoBecause nothing is wrong with `var` and arrow functions are more concise?
- TheDong 10y ago> nothing is wrong with var Other than having utterly illogical scoping. Which is the entire reason 'let' was introduced and should always be preferred.
- inimino 10y agoPlease. There's nothing illogical about it. It scopes to the function body. Maybe you meant to write "unfamiliar".
- nv-vn 10y agoIt's entirely unintuitive, inconsistent with the syntax, and is generally senseless. "var" lacks an easy to explain meaning because in many cases it doesn't even introduce a variable.
- inimino 10y agoIt ensures that a variable is declared in the current scope. That's the easy to explain meaning. It's inconsistent with other languages which introduce a new scope whenever there are curly braces, but there's nothing inconsistent about the syntax. That's just a matter of taking expectations from other languages and expecting them to work unchanged in JavaScript.
- kang 10y agoThere is not a single use-case that this code can achieve, which you couldn't before the invention of bitcoin. Blockchains are just linked lists; without proof-of-work its useless.
- davidgerard 10y agoThis is a good example of how in 2017, Merkle trees will be renamed "blockchain" in marketing parlance.
- AKifer 10y agoThat's exactly what we need, a Hello world of the blockchain technology. Everybody talks about these data structures while it's very rare to find concrete example of even a simple implementation. It's not helping to be said go look at bitcoin source code.
- carlosgj94 10y agoThis may help you also: https://anders.com/blockchain/ https://anders.com/blockchain/. In fact is quite better, since it adds more info. Also the code of it is on github ;)