The ultimate disincentive system in Casper is forking the contract resulting in loss of the attacker's stake. Is this mechanism possible with any smart contract?

I'm trying to write an oracle contract that incentivizes consensus on some real-world data and want to be able to fork the contract if it comes under attack.

2 Answers 2


Forking a system is, as you suggest, often a good way to provide a layer of security to a consensus system. The thought is that if someone spends some resources to attack the system and put it in a state that the users consider wrong, a new version of that system can be deployed, ideally with any resources still held by the attacker deleted or reassigned, and the users will just ignore the old system and move to the new system.

In practice, forking can mean a few different things.

If you have your own network, like the Bitcoin network or the Ethereum network, you can fork by changing the rules that some of the nodes follow. This splits the system into two different networks, which share the same state at the block before they split, but have divergent state thereafter.

If you're intending your code to run on top of an existing network like Ethereum, you can't change the rules of that network when you fork, and all your data is stored on a single, consistent ledger. Since you can't fork the ledger, you have to somehow create a new data structure on the existing ledger.

One option is that if your resources are all held by the same contract, you can simply deploy a new version of that contract, and everyone will move to that. This works if the main thing the contract is managing is a token, and you (the forking community) are able to persuade anyone interested in that token to move to the new contract. If this is a normal ERC20 token this probably won't work perfectly, as some contracts that talk to the token may not know about the fork, which will likely result in loss of funds, but it may be good enough for your purposes. There is more on the practicalities of this here: https://medium.com/@edmundedgar/what-happens-when-you-try-to-fork-an-ethereum-token-863e3defcf7

Another option is to manage all the branches in a single contract, and always force users to specify the branch. This is the strategy we use in the contract we describe here: https://decentralize.today/get-the-facts-hard-fork-all-the-things-3ea2233da0fd

A third option also maintains the forks in a single contract, but attempts to adjudicate between them to create a "true" fork. This is the strategy used by Augur: When a fork is triggered, users are required to migrate their token ("REP") into one branch or the other branch, and the system eventually treats the branch into which the most REP is migrated as the "true" branch. This has the advantage of exposing a single token interface to other contracts, and not needing other contracts talking to their contract to specify a branch, since there is a "best" branch. The disadvantage is that this process is quite disruptive, so it has to be protected with a system of bonds, which adds complexity and may fail to trigger if the bonds turn out to have been set at the wrong levels. It also can itself be gamed (at a cost) so there is a risk the system will end up in a state where the privileged branch is compromised.

Note that in all cases where there is no "true" branch, the system is likely to be unable to manage external resources like (for a system that runs on top of Ethereum) ETH. All these systems rely on having a native token which can be redefined at will by the community that uses it.


There are a couple of mixed together misconceptions here. Let's see if I can untangle them. (1) The Casper disincentive is not "forking contracts", in fact, I'm not even really sure what "forking contracts" means. Casper will sometimes "slash" a validator's stake if they do something wrong, but I would not call that "forking a contract."

When you say "forking a contract" it sounds like you're thinking of Linux where one can fork a program and have two running versions of the program. Blockchain forks are not like that, but I'm not sure that's what you're saying.

The words "oracle contract" are also a bit unfamiliar. An 'oracle' in the blockchain world, at least as far as I know, is an off-chain piece of software that periodically writes data onto the chain (that is, into a smart contract) as a way of providing data for the smart contract. I don't think most people think of an oracle as being on-chain. (Not that you can't provide data to other contracts from another smart contract, but generally speaking I don't think that's what people mean when they say "oracle.")

Finally, it's unclear what you mean "fork the contract when it comes under attack." Do you mean you want to make the smart contract itself react in some way if someone is trying to hack it? Some people write smart contracts with a "kill" or "pause" switch, but it doesn't sound like that's what you're saying.

Overall, your question is a bit confusing. Maybe you could clarify it a bit.

  • I suppose, what I mean by "forking contracts" is this from one of Vitalik's posts: "if they try to prevent new validators from joining, or execute 51% attacks, then the community can simply coordinate a hard fork and delete the offending validators’ deposits." How exactly is that coordinated and can that be coordinated for any smart contract? Let's say there is a partial lock commit reveal contract which has people stake tokens and vote on some real world event? The majority vote writes data to another contract. Commented Nov 12, 2017 at 4:49
  • Those comments are about Casper, which is a proposed upgrade to the consensus algorithm, not any particular smart contract. The "community" is all the miners. "Simply coordinate" means the consensus algorithm can be written in such a way as to automatically detect and automatically punish bad behavior. All of this is discussing things at a system-wide level--not in any way related to a particular smart contract. Forking happens at a system-wide level. That's why I said there was a misconception when you speak of "forking contracts." Forking contracts (at the level of Casper) never happens. Commented Nov 13, 2017 at 14:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.