News for hackers. Stuff that matters.
Re:Deconstructing the DAO Attack: A Brief Code Tour by tinco on Saturday June 18, 2016 @10:29AM (#11928764)
In addition to this the language is not explicit enough. Even standard Haskell wouldn't be safe enough for a program that manages $250MM directly without safe guards.

In addition to typesafety, it would have to be both explicitly typed at the lowest possible granularity and annotated with pre and post conditions.

Not only did this code allow a bunch of tokens be transferred without compensation, it left the whole accounting system in a corrupted state! One that could have easily been detected and verified at any point.

This line:

    ```
        Transfer(msg.sender, 0, balances[msg.sender]);
    ```
Should have looked like this:

    ```
        // postcondition: balances[msg.sender] == 0
        Transfer(msg.sender, 0, balances[msg.sender]) :: Action<Transfer>;

    // Compiler result:
    // # Error 1: line XX expected type Action<Transfer> but instead got type Transfer
    // # Error 2: line XX violates postcondition, expected balances[msg.sender] == 0, got balances[msg.sender] != 0
    ```
And the whole function 'splitDao' should have a type annotation that completely captures the possible actions it might encompass, and pre- and postconditions that at the very least constrain the result of the function to not corrupt the accounting of the DAO (i.e. it should still have as many tokens as it believes it has).

It's nice that Vitalik Buterin is a genius, but it shows that this guy is only 22 and dropped out of university because anyone with a degree in computer science knows about this stuff and its importance in high reliability systems. He should have known the contract language should have had typechecked side effect and he should have known proper pre- postconditions would have been the least he should have done.

Re:Deconstructing the DAO Attack: A Brief Code Tour by dang on Saturday June 18, 2016 @01:24PM (#11929581)
> It's nice that Vitalik Buterin is a genius, but it shows that this guy is only 22 and dropped out of university because anyone with a degree in computer science knows about this stuff

Personal attacks, which this crosses into, are not ok on Hacker News. Please edit such stuff out of your comments here.

We detached this subthread from https://news.ycombinator.com/item?id=11928562 and marked it off-topic.

Re:Deconstructing the DAO Attack: A Brief Code Tour by tinco on Saturday June 18, 2016 @01:54PM (#11929765)
Hi Dang, my apologies, I can no longer edit the comment, please feel free to snip that paragraph out.

I guess I felt the need to accuse someone as I felt frustrated. News like this really smears not only cryptocurrencies but software engineering in general. A single typo cost these people $50M is what they claim, but the reality is that the whole system was recklessly engineered. I guess I'm also saddened that so much money was put behind something that was so clearly recklessly engineered.

Would it been a crazy idea just to invest a million or two of the $250M to pay a Formal Methods team at any university in the world to give the language a quick do-over?

Re:Deconstructing the DAO Attack: A Brief Code Tour by kartickv on Saturday June 18, 2016 @11:32PM (#11931674)
FWIW I didn't interpret this as a personal attack, but as a critical contribution to this discussion: We can't have financial software built by 22-year old dropouts. A new social network? Sure. A game? Sure. A todo list app? Sure. Financial software? No.

If it was phrased as "person XYZ is an asshole!" then I would agree that it's a personal attack.

Re:Deconstructing the DAO Attack: A Brief Code Tour by egg_head on Monday June 20, 2016 @02:36AM (#11936428)
He is stating facts, except for the last clause which is an opinion which does not apply to the main subject.
Re:Deconstructing the DAO Attack: A Brief Code Tour by whazor on Saturday June 18, 2016 @12:00PM (#11929143)
To counter your attack on Buterin, he is aware that writing safe contract code requires proofs and type safety. That is why solidity is compiled to EVM code, so that improved languages could incorporate this. Solidity is built for rapid innovation and user friendliness. Buterin is now more busy with sharding and scaling issues.
Re:Deconstructing the DAO Attack: A Brief Code Tour by jacquesm on Saturday June 18, 2016 @12:34PM (#11929284)
> Buterin is now more busy with sharding and scaling issues.

Those are currently not the issues that require attention.

You can make it as fast and as large as you want, if it is broken at the root that's all pointless. First walk, then run. I'd be more impressed with a much smaller system without sharding and massive scaling properties if it was bullet proof.

Re:Deconstructing the DAO Attack: A Brief Code Tour by whazor on Saturday June 18, 2016 @03:20PM (#11930148)
Ethereum is a turing machine that runs code, programming languages are more high level. Creating an ADA-like language is trivial compared to making a scalable blockchain that supports computation.

Ethereum itself is more bullet proof, as there are multiple implementations and the description of the protocol better defined and has proofs inside.

Re:Deconstructing the DAO Attack: A Brief Code Tour by jacquesm on Saturday June 18, 2016 @04:18PM (#11930432)
> Ethereum is a turing machine that runs code

That's the whole problem in a nutshell. I highly doubt that is the road to a viable solution but I'm patient enough to be proven wrong in the longer term. But anything that is Turing complete automatically implies that anything layered on top of it will incorporate such niceties as being impossible to formally verify due to the halting problem.

In other words: the only way to establish whether or not the code will try anything funny is to run it.

Re:Deconstructing the DAO Attack: A Brief Code Tour by lomnakkus on Saturday June 18, 2016 @06:16PM (#11930875)
Not sure why you're being downvoted. This is the problem.

Whenever you want any guarantees about anything you implement a very restricted[1] subset of what a TM can do... at least if you're allowing users to input arbirtrary programs[2]. If you don't restrict to a non-TC language... you're -- in so many words -- fucked. (Hence the "hack".)

[1] Preferably using a statically typed PL, for obvious reasons. There's actually a thing these days where non-TC languages can actually "do things". My favorite moniker for this is "pacman-complete" (coined by Edwin Brady, I believe.)

[2] Having looked at a few .sol files earlier, they at least look TC, having general recursion and all.

Re:Deconstructing the DAO Attack: A Brief Code Tour by quonn on Saturday June 18, 2016 @07:55PM (#11931174)
> But anything that is Turing complete automatically implies that anything layered on top of it will incorporate such niceties as being impossible to formally verify due to the halting problem.

Not sure I follow here... You can certainly run a non-turing-complete language on top of a turing-complete one and anything in that language could potentially be verifiable.

Re:Deconstructing the DAO Attack: A Brief Code Tour by powera on Saturday June 18, 2016 @12:02PM (#11929154)
People did lose $200 million dollars. Why is he focusing on scaling?

Edit: apparently the thefts so far are "only" 45 million.

Re:Deconstructing the DAO Attack: A Brief Code Tour by marvy on Saturday June 18, 2016 @12:22PM (#11929230)
So that they can lose $2 billion instead :)

Just kidding; bad joke; I just couldn't resist.

Re:Deconstructing the DAO Attack: A Brief Code Tour by jsprogrammer on Saturday June 18, 2016 @12:24PM (#11929236)
I thought only a fifth of ~$115 million has been sequestered (apparently the action will be rolled back)?
Re:Deconstructing the DAO Attack: A Brief Code Tour by egg_head on Monday June 20, 2016 @02:38AM (#11936434)
When I had my own start up companies or worked for those of my friends, we ensured that the first few sets of big customers got white glove treatment from the executive team....

This is what happens when one does not do that. :)

Re:Deconstructing the DAO Attack: A Brief Code Tour by tmalsburg2 on Saturday June 18, 2016 @10:32AM (#11928771)
One solution might be to design a safe language that compiles to the the language used in Ethereum. Not sure if possible within the given constraints.
Re:Deconstructing the DAO Attack: A Brief Code Tour by krapp on Saturday June 18, 2016 @10:43AM (#11928823)
Wouldn't it be better to just rewrite everything in that safe language and abandon whatever Ethereum is written in?
Re:Deconstructing the DAO Attack: A Brief Code Tour by tmalsburg2 on Saturday June 18, 2016 @10:51AM (#11928855)
Sure, but many people are so deeply invested in Etherum that I doubt that it's going to happen. But perhaps there will be a competing system.
Re:Deconstructing the DAO Attack: A Brief Code Tour by jacquesm on Saturday June 18, 2016 @11:37AM (#11929048)
The only person who is currently really deeply invested is the hacker. The rest, not so much.
Re:Deconstructing the DAO Attack: A Brief Code Tour by wildlogic on Saturday June 18, 2016 @12:09PM (#11929182)
Hah.
Re:Deconstructing the DAO Attack: A Brief Code Tour by eudox on Saturday June 18, 2016 @10:36AM (#11928790)
The problem then becomes ensuring that only code compiled from that language can run.
Re:Deconstructing the DAO Attack: A Brief Code Tour by tmalsburg2 on Saturday June 18, 2016 @10:38AM (#11928802)
Just let people use whatever they want. Those who write unsafe contracts will get bitten but that's ok.
Re:Deconstructing the DAO Attack: A Brief Code Tour by dangero on Saturday June 18, 2016 @11:16AM (#11928962)
Seems like this option is now invalid since the devs have now shown their unwillingness to let their pet contracts 'get bitten'.
Re:Deconstructing the DAO Attack: A Brief Code Tour by Atwood on Saturday June 18, 2016 @11:18AM (#11928973)
ПРЕДУПРЕЖДЕНИЕ! ^objects in mirror are larger than they appear.
Re:Deconstructing the DAO Attack: A Brief Code Tour by pmoriarty on Saturday June 18, 2016 @01:25PM (#11929586)
"It's nice that Vitalik Buterin is a genius, but it shows that this guy is only 22 and dropped out of university because anyone with a degree in computer science knows about this stuff and its importance in high reliability systems."

I wouldn't be so hard on the kid. Now, the due diligence that should have been performed by the corporations that sank millions in to this project, who actually do hire plenty of people who are well educated and should have known better is another matter.

But I suppose jumping in early in to the tulip craze and riding it for all its worth is more important than taking the time and effort to make sure the system is reliable and robust before it goes live.

Re:Deconstructing the DAO Attack: A Brief Code Tour by vessenes on Saturday June 18, 2016 @01:30PM (#11929616)
Well, ​Dr. Chris Reitwiessner is in charge of the solidity project I believe.

I have been told he's not big on functional / richly typed systems, but I don't have any actual knowledge.