- Don’t Decentralize Everything
I have spent a lot of time recently working on EOS smart contracts and before that spent time working on dapps for other chains. This is actually going to be the first post in a series primarily aimed at developers but there are some insights that I think are very important to users of and investors in EOS projects.
With the introduction of the dApp people clamor for having everything decentralized. While this may be a noble goal it really isn’t practical in many cases. At current prices (and I use the term current loosely because it will change a lot while I am writing this, to say nothing of how much it may change by the time you are reading it) it cost .56 USD to get 1 millisecond of cpu time. When I started the article about ten minutes before writing this sentence it was .98 USD per ms. If you are not a developer you probably aren’t used to tracking anything by the millisecond so let me give you an example of a dapp and how much cpu they have staked and how much of that they use.
One of the dApps I am heavily invested in is betdice. They have very heavy usage and so are a great example of an app that uses a lot of on chain resources. They currently have 6893791 EOS staked for cpu in just one of their contracts. At current EOS price of $3.12 that means that they have about 21 Million USD staked in cpu on that contract. Imagine the kind of hardware one could purchase for 21 Million dollars. On the EOS mainnet that buys them about 3.4 hours of cpu time per day.
If you could move just half of the processing off chain you get to put 10 million dollars back in your pocket.
Now, for a gambling dApp that EOS is a small amount to have to stake when compared with the profits that it produces but imagine if instead of randomized rolls for gambling it was a dapp that was handling the logic for a game of chess. One assumption I will make is that this dapp allows you to play chess against another person with a wager between the two of you. I make this assumption because if you were just playing for fun I can’t imagine why you would need the game on the blockchain at all.
The decentralized purist would argue that for each move the player sends their move to the chain and the smart contract checks to verify the move is legal, saves the new board state and checks for a win condition. If the game is over the contract would send the funds to the winner. Basically none of the logic should exist on a centralized server somewhere.
If however you were to run all of the logic on a centralized server you could still have moves sent over the blockchain which would give you the ability to reconstruct a game at any time. So user a sends a message to the chess contract with the desired move. A centralized server running somewhere can read the messages and handle all of the logic and then the centralized server calls the contract with an updated board state and a flag to notify if the board state results in victory. If that flag is set the contract could contain logic to verify that the board state does indeed mean victory before paying the victor.
On even the most underpowered laptop checking to see if the state of a chess board results in victory is trivial in terms of cpu usage but if you had to pay for every millisecond of cpu time it would not be so trivial. It would be an interesting project to set up contracts that worked fully decentralized and partially decentralized and measure the difference in costs for the two but I’ll leave that to someone with more free time than I have at the moment.
So if you are an investor try to look into how the developer is using the blockchain. Are they efficiently putting the resources to use or are they just wasting money by decentralizing portions of a dapp that provides no real benefit to the end user? If you are developer make sure that every single line of code you write for your smart contract needs to be in that contract because it will cost you ram fees and it will cost your users CPU.