Hacker News new | comments | show | ask | jobs | submit login
[dupe] Bloomberg – Blockchain Company's Smart Contracts Were Dumb (bloomberg.com)
91 points by julian_1 340 days ago | hide | past | web | 29 comments | favorite



A lot of this is predicated on the practicality of writing contracts in conventional code, so let's talk about the state of writing "bug free systems," and the cost. In some cases, there are options that come pretty close. All have huge trade offs and drawbacks.

Model checkers work. You can, with effort, prove programs correct. This works very well for small programs but grows exponentially more complex in the number of branches and variable constraints. Even if you had the computational power you'll quickly hit an inflection point where you're as likely to have a bug in your proof as you are the underlying code.

Life-critical systems style code review works. NASA is very good at writing bug-free C code via a style guide that subsets the language, static analysis/formal methods, and a review process that makes waterfall look agile.

Voing works. In aerospace, code that's responsible for controlling actuators and surfaces is often implemented in three different ways, driving three different actuators. If one implementation returns a different result, majority wins. Same principle for other applications - the output need not be an actuation.

The biggest problem isn't that bug free system are a pipe dream - it's that making one is very expensive, and the cost grows massively as your tolerance for error decreases. This is a community that wants to drive adoption, and that means competing with the status quo. If one of your selling points is that you're saving the cost and complexity of dispute resolution and human constructs, you've gotta factor in the cost of writing bug free contracts in the first place.


You're also talking about systems 20,000x larger than what The DAO contract was [1]. The total DAO contract is roughly 2,000 LOC by my estimate [2].

IMO it probably won't be overly onerous to develop reliable contracts of this size using many of these techniques. It's just so few people have the discipline to delay implementation for design and planning at the level required when it needs to be bug free. Most software developers have no training in how to even begin designing and developing using these techniques.

[1]: Shuttle's primary flight software contains 400,000 LOC http://www.nasa.gov/mission_pages/shuttle/flyout/flyfeature_...

[2]: https://github.com/slockit/DAO


> You're also talking about systems 20,000x larger than what The DAO contract was [1].

It sounds like the contract was underspecified.

In my experience, the basic core logic of a system's usually a pretty small part of the overall codebase - the edge cases and error handling tend to be the bulk of the code.

This tends to be the case in legal contracts, too - 100 pages of boilerplate to make sure the two pages of contract are air-tight.


Writing perfect, bug-free code is merely the first hurdle when designing a smart contract. You also need the code to cover all possible situations correctly. It's here that smart contracts run into the mess we call the 'real world', and there's no proof of correctness that covers that. Smart contract creators need to be perfect programmers, but must also take their programming blinkers off and consider actual usage too.

For example, a few weeks ago, there was a news story about an ethereum prenuptial agreement : http://www.coindesk.com/prenup-ethereum-marriage-obligations... : https://drive.google.com/file/d/0B1MEGeLr7lWiNEE2U2lGdGFvSm8...

Ok, obviously a dumb idea, and not serious (I hope?) But take just one of the contract terms: 'It is stipulated that both the parties should spend at least 100 minutes every 10 days on a date-night'

As someone in r/buttcoin wrote at the time: "In the last ten days, User 1 spent 5 nights at home, 1 night in a wrecked car and 4 nights in Lakeville Hospital. Date night clause has been broken. Marriage terminated."

My point is that coding is the least of the problems with a smart contract. There needs to be a way to handle unexpected circumstances. In the real world, courts do that. In smart contracts, you're out of luck.


You really can never say in code we trust entirely, because we say the same thing about our state of the art encryption today that the Nazis said about enigma in WW2 "It would take more than every human lifetime combined to crack this code!" But then the next paradigm of computing sets in, and you have a Turing machine built, or a Quantum brute force attack become possible on RSA 4096 rendering it as useless as enigma code. The fact of the matter is you can't declare a system that can not update it's own software "Autonomous" - someone will attack.


> Instead, Libya's arguments take the form of: We didn't really mean what those contracts said. We didn't understand them.

[...]

> What JPMorgan did was explicitly allowed by the rules, but that doesn't mean that it was allowed.

This seems like both the biggest feature and the biggest bug of our legal system. On the one hand, the court system exists to adjudicate cases that aren't clear-cut, and often establish precedent in the process. On the other hand, that makes it extremely difficult to construct a system where all the rules are clear cut and have "let the buyer beware" all over them, and not have someone "cheat" and ask the court system to reverse a result that didn't go in their favor. Heads I win, tails the court system might say I win anyway.

If you want a contract where the "spirit of the law" prevails, write it that way. For example, the electricity regulations mentioned in the article could have been written to say "if you find way to arbitrage this and produce infinite money, you're wrong; this is governed by the spirit of the law as interpreted by $governing_body".

But there should be a way to write a "letter of the law" agreement, too, where people can actually rely on the rules. There should exist a sufficiently strong disclaimer that anyone agreeing to it will get summarily rejected from a court saying "you should have known better". There should exist agreements where someone giving their word is ironclad and irreversible.

You can build systems that incorporate human judgment and reversibility on top of such an ironclad rule-based system. But the reverse isn't true: you can't build an ironclad system on top of a system where anyone can cheat by saying "no fair, I lost my money and I didn't really mean it" to a court.

Sometimes, people find it comforting to have a "soft" system backing them up that will look at the human factors involved; for some systems, I do too. But in some cases, you want the comfort of knowing that you can rely on the rules as stated and not someone saying "actually, now that I've lost money I don't like the rules anymore, give me my money back".


One of the things that many legal systems try to enshrine is a principle of fairness. One part of that is acknowledging that many contracts are entered into in a state of information or power asymmetry, which makes it easy for certain parties to create unfair contracts that the counterparty doesn't recognize as unfair or doesn't realize they can argue against.

This is really a good thing. The most tangible example I can come up with is employment law in California: One big thing that distinguishes the labor market in California from other regions is that non-compete clauses are basically unenforceable. Non-compete clauses being a big drag on innovation (since they basically imply that if you have a good idea that is related to your current line of work, and your current employer doesn't see the value, then you're SOL and not allowed to have a go of it), there's a very strong argument to be made that Silicon Valley couldn't have happened in any other jurisdiction.


What would be the use case for "letter of the law" agreements, and how do you avoid massive problems due to buggy contracts as we're seeing?


You don't. There are two conflicting and irreconcilable centres of gravity in law - justice/fairness, and the exploitation of power asymmetries for profit.

Which is why it's literally not possible to reduce a contract to code, and it never will be.

Even if you could produce perfect bug-free code at reasonable cost - a fantasy in itself - you still have to contend with the irreconcilable motivations of the parties to the contract, and the fact that contracts are used to hide motivations as often as they are to reveal them.

It's perfectly possible - common, even - that the motivations are conflicting, irreconcilable, and ambiguous, to the extent that the true practical meaning of a contract can only be defined by an external higher legal and political authority.

Or by one party rolling over. Because making that more likely is what many lawyers get paid for. (And what some of them live for.)


> There are two conflicting and irreconcilable centres of gravity in law - justice/fairness, and the exploitation of power asymmetries for profit.

I don't think that's a reasonable dichotomy. "Letter of the law" isn't exclusively useful for people looking to exploit power asymmetries or create unfairness. It's also useful for smaller entities to protect themselves from threats that larger ones have enough insulation to just weather and survive.


> What would be the use case for "letter of the law" agreements

Consider a service where you take money from a user, and then use that money to run a service on their behalf, in a fully automated fashion. You get $x, you spend $y on a server and bandwidth, and you pocket x-y as profit. But if the user pays for your service on a credit card, they could dispute the $x, and leave you on the hook for $y, which could be arbitrarily large; you can immediately cancel their service, but that doesn't get you the $y you've already spent back. It'd be nice to have an enforceable agreement that "you can cancel at any time and stop paying us, at which point the service goes away, but under no circumstances will we owe you anything".

(This is also one reason why companies often don't offer discounts for paying up-front for a year or more, and credit card processors consider those high-risk: too many people dispute the transaction after a short time and get all their money back, including what they've already paid.)

I can imagine many more scenarios that rely on "once you have the money it can't go away", that don't work nearly as well with reversible transactions.

> how do you avoid massive problems due to buggy contracts as we're seeing?

In cases where you want human judgment as a safety precaution, write it in at the top level of the contract. "Notwithstanding anything else, all transactions are reversible for up to X days based on the judgment of Y, to be supplied via Z mechanism; if such judgment is not supplied, the transaction becomes immutable after those X days have passed." (Or, if you want, "all transactions can be disputed for up to X days, which will then hold them for judgment by Y for up to Z days".) The equivalent of "don't run untrusted software in ring 0"; the "pure letter of the law" space is ring 0, and many things could be built on one or more layers of indirection above that.

In cases where you don't want human judgment, then you avoid buggy contacts the same way you avoid buggy software: get a lot of people looking at it, and limit how much you trust things that haven't been heavily hammered on for years. Anyone investing millions into a "smart contract" today is taking an absurd risk.

You could also purchase insurance of some kind. If the price of that insurance is absurd, that should tell you something. But not every transaction should have to price in built-in insurance (and actuaries to properly price it).


I don't understand why current contracts don't suffice for that scenario. If the user disputes payment for services already rendered, you can sue them as things are now, and you'll win. It doesn't usually happen just because the cost is too high, but I don't see that this would change for "don't apply reasonableness, just read the letter of the agreement" contracts.

Or just ask people to pay you in cash.


> I don't understand why current contracts don't suffice for that scenario. If the user disputes payment for services already rendered, you can sue them as things are now, and you'll win. It doesn't usually happen just because the cost is too high, but I don't see that this would change for "don't apply reasonableness, just read the letter of the agreement" contracts.

If you have to sue to recover the money, you're out the money until you win, and you might not win. You're also out the money if the entity you try to sue can't be sued, which can happen for a variety of reasons, such as "already pulled the money into a different jurisdiction you can't touch", or otherwise "doesn't have the money to recover". And in any case, it isn't worth the trouble unless the transaction is large enough, which is why most service businesses have to budget a certain amount for losses due to fraud.

I'm not sure why you think an unbreakable agreement wouldn't fix that, assuming it was actually enforceable as such.

> Or just ask people to pay you in cash.

Cash doesn't function for online services (with very rare exceptions). And even for a cash transaction, people can sue you and demand their cash back.

To clarify something: I don't think that the entire economy should use "rules as written" transactions; I think that would be an incredibly bad idea. For example, I want to store the majority of my savings somewhere that follows "spirit of the law", and has some protections and recourse for transactions I don't want. And I spend money on credit cards, confident that I can call up American Express if something goes horribly wrong. (I've never had to do so.)

I do think it should be possible for me to intentionally and verifiably move a small amount of money from my bank account in a "rules as intended" system into a transactional account in a "rules as written" system, and then use it to conduct a transaction in that system. (Moving the funds is necessarily governed by "rules as intended" protections provided by my bank, as for example I would want some recourse from my bank if that transaction wasn't initiated by me. That then gives the bank an incentive to make absolutely sure they have valid authorization from me.)


I thought you were proposing a way of writing a normal paper (or PDF) contract which would have some legally-enforceable clause saying, "Don't try to interpret the intent of this, it means exactly what it says." To enforce such a contract in the event of a breach, you'd still get the usual legal machinery involved, but the court would skip the part where they try to apply reasonableness standards or figure out intent, and would just go straight to figuring out which party is correct and what the remedy should be according to the contract.

Did I misunderstand the idea?


I was talking abstractly about both contracts-as-code and literal-text-contracts somewhat interchangeably, focusing mostly on the effect rather than the implementation. Sorry for the ambiguity.

A well-established mechanism for text contracts to say "this means exactly what it says" would be quite useful for a wide variety of applications, though it would be limited by the need for minimal interpretation of natural-language text.

A form of contracts-as-code would also be useful for the much narrower set of applications in which code can completely describe the implications/performance/etc of the contract.


The ability to dismiss any grievances with "tough luck" for one. A mechanistic system that engulfs and defines human activity rather than being defined by it, another: it is immune to politics. Just guesses from me; i don't think blockchain tech addresses any aspects of society that i personally find problematic.


But there should be a way to write a "letter of the law" agreement, too, where people can actually rely on the rules. There should exist a sufficiently strong disclaimer that anyone agreeing to it will get summarily rejected from a court saying "you should have known better". There should exist agreements where someone giving their word is ironclad and irreversible.

These would be great to make people sign at gunpoint!


I want to understand the mindset and ideologies of people who think DAO is a good idea. Holding this belief is correlated with a lot of other ideas in particular, strands of right libertarian thought, and a heavy emphasis on technology and technocracy (i.e. government by technical expertise).

Beneath that though, i think there's an undercurrent of something that feels like misanthropy: a strong desire to replace political human beings interacting in order to resolve conflicting interest, reconcile conflicting experiences and pursue common interest with purely economic agents that interact with each other through free (read: mechanistic) markets and algorithmic contracts.

It feels like there is an unspoken need to be able to tell every human being who has a problem "too bad", and a need for a societal structure that is maximally ""rational"" and unassailable by human political action.

Obviously this would be a strawman if i said any particular person or group specifically held these beliefs. It's an amalgamate of various ideas I've seen pop up in the same places at the same time. Call me a skeptic of any thought that leans in this direction.


While the cryptocurrency conversation online is dominated by right-libertarians, I think you'll find that a lot of hard/radical leftwing direct-action types are very much obsessed with cryptocurrency and structures like the DAO. I personally don't look at the cryptocurrency scene/DAO with anything more than bemusement, but I think that community is often presented in a very unpleasant light (look at the weird nerds!).

A more charitable stereotype might be that cryptocurrencies and automated contracts appeal to anyone who thinks that they can design (through their technical expertise) a better world than the current political elites. I'm not saying that they're right or that their line of thought hasn't been historically responsible for atrocities, but I don't think it's fair to paint them as sociopaths.


Certainly didn't mean to imply that you have to be a sociopath to like cryptocurrency! That would be unfair and ridiculous. I think it's more like an allergy to what one considers politics.

The benefits of cryptocurrency i've seen argued for in left libertarian circles don't propose some narrative where it supplants the current structures of government. I think a lot of leftists would reason (certainly, I reason this way) that cryptocurrency's much touted benefits are in conflict with capitalism and could not support capitalism at all. This is at odds with the right libertarian ambitions for the technology: right libertarians love capitalism and the crypto enthusiasts on that side of the spectrum think it would be great for capitalism! It's a fundamental disagreement. I've heard about bitcoin being used to great effect by left wing insurgencies like Rojava. It is useful in its current form as a subversive means of transmitting resources.

I'm not familiar with the left wing arguments for cryptocurrency as a transformative tool for structuring new societies. It sounds like technocracy and vanguardism and, well, we know how that's played out.


"Do what I say, not what you think I mean. No takebacks, because crypto. Oh, shit, wait, actually, do what you think I mean. No, really."


This has been marked a dupe.. Where is the duplicate?


>Just because rules are dumb and you are smart, that doesn't always mean that you get to take advantage of them.

Then they rules are a sham. They are meaningless. If the "rules" in a contract are just vague suggestions, then the contract is basically useless.


No, it doesn't. It simply means that the rules in the contract are not the only rules that govern the agreement.


If that were the only problem, we could rectify it by explicitly enumerating those rules in the contract. However, it unquestionably lowers the utility of contracts if they are forced to have certain terms (explicit or implicit) included.


Indeed, it does unquestionably lower the utility of contracts that each individual contract does not have the ability to create for itself its own entire public policy and jurisprudence. We've generally decided contracts shouldn't have that much utility.


>By definition! If the code could be hacked, the code allowed for the hack

wat? can't people just realise it was a loophole and hence unacceptable?


Loopholes are generally legal, by definition.


A single instance, yes but we're talking about a platform. It's closer to bug than a feature.




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | DMCA | Apply to YC | Contact

Search: