Steem Monsters Tech Talk - Part 2 - Why We Don't Need Smart Contracts

in #steemmonsters6 years ago (edited)

One of the questions I get asked most often when talking about creating a game and associated NFT’s (Non-Fungible Tokens) on the Steem platform is some variation of: “Don’t you need smart contracts for that?” I thought that answering that question would be a good topic for the second "Steem Monsters Tech Talk" post - so here goes!

The answer, thankfully, is no - you do not need smart contracts for it. Everything that we want to achieve in creating a decentralized game requires only an immutable, public ledger, for which the Steem blockchain definitely qualifies. In fact, this could all be done on the Bitcoin blockchain as well, since it is also an immutable, public ledger, however that would be quite slow and expensive, making a blockchain like Steem a much better choice.

Hard vs Soft Consensus


The primary difference between building a game like Steem Monsters on a platform like Ethereum with programmable smart contracts vs a platform like Steem, without them, comes down to the method of consensus that is used.

Implementing the consensus rules within smart contracts that get executed on the blockchain is known as "hard" consensus. If I broadcast a transaction to the Ethereum network saying that I want to transfer a Cryptokitty from my account to another account, the smart contract code will check if I own that Cryptokitty, and, if not, then it will reject the transaction and it will never get included into a block.

In a "soft" consensus system, like Steem Monsters is currently using on the Steem blockchain, I can broadcast a "custom_json" transaction saying that I am transfering a card I don't actually own to someone else, and it will get included into a block.

But, despite being included in a block, anyone can easily see from the public ledger that I don't own that card, and therefore everyone will agree that that transaction is invalid and will ignore it. So the end result is the same in both cases - there is a clear consensus as to what constitutes a valid vs an invalid transaction and the same rules (in this example the rule is that you can't transfer something you don't own) are enforced.

The Hivemind Soft Consensus Layer for Steem


Many of you are probably aware of the Hivemind project that @roadscape is hard at work building for the Steem platform. This is a soft consensus layer that will run on top of the blockchain and will filter out transactions that the blockchain has accepted but that go against the consensus rules agreed upon by the community.

One of the most highly anticipated features that the Hivemind project will enable is the concept of communities which can include content moderation. Let's take an example where there is a community that only allows posts from a specific list of approved accounts. Since it will be a "soft" consensus feature, I can still publish a post to the blockchain in that community even if I am not on the list of approved accounts, but the Hivemind software will ignore that post as invalid since it voilates the soft consensus rules.

It's important to note that these features are all currently possible even without Hivemind - Utopian.io is a moderated community, for example - but they had to do a lot of custom development work to implement the soft consensus rules themselves. Hivemind aims to provide a standardized way to build moderated communities, and much more, without all of the additional development effort.

In future versions of Hivemind, I hope that it will be easily extendable to add new soft consensus standards for things like NFTs. That would make it much quicker and easier to build games like Steem Monsters and lots of other interesting applications as well on the Steem blockchain.

If you break it down, an easily extendable Hivemind software will allow for a system very much like the smart contracts used on platforms like Ethereum to be built on the Steem platform using this concept of "soft" consensus. This is why I'm really much more excited for Hivemind than for any other development on the Steem platform, including SMTs!

Verifiable Code Execution


There's one other topic that still needs to be addressed for running a decentralized application on a blockchain that doesn't allow programmable smart contracts, and that's the concept of verifiable code execution.

This is something that we have yet to implement for Steem Monsters (mainly due to time constraints more than anything else) but that we absolutely will do in the not-too-distant future.

Right now, when you purchase Steem Monsters booster packs, you have no way to verify the code that is being run to choose the cards in your packs. You have to trust that @aggroed and myself are generating the packs in a fair and equitable manner, which means that this portion of the game is currently not decentralized.

This is because the code is being run on private servers that we control, as compared to being run directly on the Blockchain like is possible on platforms like Ethereum. But, despite that we cannot run the code directly on the Steem blockchain, we can still implement the code in a fully verifable manner.

If we seed our random number generator with a non-predictable value generated by the blockchain, such as the block id of the block containing a Steem Monsters pack purchase transaction, and publish the code for choosing the cards in each pack, then anyone would be able to verify that the pack contents were generated via a pre-published algorithm.

In this way, if we were to ever change that algorithm to do something like give ourselves lots of valuable cards, then anyone could see that we were doing that and everyone would likely lose faith in the game and we would lose our reputations within the Steem community.

One thing I would like to note here is that we are currently using the transaction ID of the purchase transfer transaction to seed our random number generator to generate card packs. Since I found out that the transaction ID can be pre-determined, it is not secure, and therefore I have not released the algorithm for generating the cards to prevent anyone from being able to cheat the system.

But, this means that once we switch to a more secure method, we can then release the original pack generation algorithm which will allow anyone to go back and verify that all the packs that were generated in the past were done fairly and properly.

The same thing can and will be implemented for the battle system once that is released. Just like with pack generation, this will allow anyone to verify that all fights are run in a fair manner, even though the actual code executes on private servers.

Figuring this out as we go...


The tl;dr version of this is that as long as everything that happens is published on an immutable, public ledger, then a fully decentralized, custom application can be achieved without the use of blockchain-level smart contracts by utilizing "soft" consensus and implementing verifiable code execution.

Of course, I've never actually done this before, and it hasn't been done on the Steem blockchain before in any serious way that I'm aware of, so as the section heading says - we are just figuring this out as we go!

There will be bugs, there will be issues, and things will change over time (hopefully for the better), and we really appreciate all of the patience and support from the community as we try to build something that's both groundbreaking for the platform, and lots of fun to play!

Most importantly though, we really value the input from all of you! So, if you feel that I've gotten any of this wrong (which is entirely possible), please let me know, and I'm happy to work together to make sure we get it right!


Banner art by @nateaguila ...except I just added the Steem Monsters logo in the middle :-)

Sort:  

Great write up Matt! This will really help anyone who has trouble understanding the difference between hard and soft consensus.

As I started to read about your thoughts on verifiable code execution I was a little nervous about the thought of the code becoming public. My fear would be that others could game this system to allow them to know when to buy a pack vs not buy a pack and thus game the system that way. I'm very excited to see what you come up with to counteract any potential bad actors.

My fear would be that others could game this system to allow them to know when to buy a pack vs not buy a pack and thus game the system that way.

This is exactly why I have yet to release the code. Once I have a good system in place that I am certain cannot be gamed then I will release that portion of the code so that the game can be fully decentralized.

I'll definitely be following your updates on it! My initial thought was just hash the payment tx against the following block (since 3 second tx wouldn't make the end user wait too long) but then my fear was that would leave BP witnesses with a potential attack vector. I'm 100% confident you'll have the right answer though!

muy buena propuesta

I think it is going to be very hard to find a good solution for this particular problem. Verifiable code execution is a really hard problem, especially when dealing with random numbers. Using the blockchain as a source of randomness is probably not a good solution, since to be truly trust less, you would have to also post the code for generating the randomness from the blockchain, and anyone could again game it.

Maybe You could look into snarks, or starks.

There's so many things I appreciate about this post, most of all are the insights into your thinking in the design of @steemmonsters.

I've been carefully watching the blockchain to reconstruct all of your transactions into a database so I understand almost everything about what you're doing and I've been thinking about the gaps in decentralization so that will be fantastic when you release your pack algorithm.

This post has me thinking about my database as a form of soft consensus validation. That's pretty interesting so I wanna let that sink in.

You have to trust that @aggroed and myself are generating the packs in a fair and equitable manner

I've invested quite a bit of time into @steemmonsters and frankly the fact that both you and @aggroed had already established yourselves in the community as worthy of that trust was a huge factor before I began any work. You've both continued to more than reaffirm my confidence and now you've just made it clear that you're acting with integrity by making decentralization a priority.

I'm excited to see what's next.

Matt, a lot of this is over my head. But I get the gist of your point. I agree that the way in which you guys decided to structure it is better suited on steem so that transaction costs are essentially nil. If we had to pay (even a small amount) to move the cards back and forth, then my opinion is that many would not take the chance that those fees could be raised in the future. Thus, even if the fees were small they would still hold back many entrants. I think you did a great job in your selection.

On another note, I know both you and @aggroed are hard at work doing some great things, and it is appreciated by many. I think you two have single-handedly kept some hope alive at a time when @ned is powering down and steem is plunging. While this isn't a measurable situation, there is no doubt based on my experience that Steem Monsters has proved their worth already!

Can't wait for the games to get started, and as always great job!

Thanks for your continued support! The price action for STEEM, and indeed all cryptos, is unfortunate, but hopefully we can all look back on this one day as nothing more than a great buying opportunity! Regarding @ned's power down, while I would definitely have appreciated some comments from him about that, I highly doubt there is anything to be worried about there.

I agree completely with you on the price coming down being a great buying opportunity. I don't think everyone looks at it that way, but I certainly do. My point is that you guys have kept people excited in a period of time when many would be normally bummed out. So you are helping with retention since many will not feel how we do when prices drop.

I agree also on @ned's power down being for a reason other than cashing out. However as you said, his lack of commentary will lead many people to assume the worst. Again, your game is helping many to ignore his lack of transparency.

Finally, I personally don't care if anyone ever wants to sell anything (steem, or anything else), that is how we establish a true price and I welcome anyone to sell at any time so that the buyers get the best price possible. In other words, I like buying on sale ;)

Right now, when you purchase Steem Monsters booster packs, you have no way to verify the code that is being run to choose the cards in your packs. You have to trust that @aggroed and myself are generating the packs in a fair and equitable manner, which means that this portion of the game is currently not decentralized.

And even then, decentralized computing has its own trust issues to deal with concerning random number generation. A trusted, centralized, RNG is actually a lot easier to deal with. Since the results of pack opening is on the ledger, we can monitor for hijinks like messing with drop rates or 'lucky' users.

Thank you for this informative post. As I had mentioned previously I would love to see that you are able to transfer cards without interaction with the website. All you needed to do to realise this is to scan the whole blockchain.

I would love that too and it is definitely on the to-do list!

I would love that too
And it is definitely
On the to-do list!

                 - yabapmatt


I'm a bot. I detect haiku.

Ha, I had no idea my comment was a haiku! This is amazing, love it!

Sounds great. Thank you for the feedback.

That's a very interesting way to handle a decentralized processus on the Steem blockchain! I'm currently working on this POC that would go along very well with Steem Monsters. This is basically a distributed permissioned database driven by smart contracts. These smart contracts are deployed and triggered by the Steem blockchain via the post mechanic hence anyone that has a Steem account can interact with this database (also everyone can host this database as the orchestrator is the Steem blockchain).

I can most definetely imagine projects like Steem Monsters being hosted on this sidechain!

Wow this is a super cool project! I really need to take the time to study this further!

Excellent response and well explained!

Totally support you guys and love the interaction with the community - that will go far in developing this! :)
Keep it up!

A lot of this is over my head but the hard and soft consensus intrigues me. If steem is soft and someone imposes infinite amount data on blockchain for verification will that not bogg down the whole steem system? Thanks.

Usage of the steem blockchain is still limited by bandwidth determined by your stake in Steem Power. So that's how it prevents the system being bogged down.

You got a 25.00% Upvote and Resteem from @ebargains, as well as upvotes from our curation trail followers!

If you are looking to earn a passive no hassle return on your Steem Power, delegate your SP to @ebargains by clicking on one of the ready to delegate links:
50SP | 100SP | 250SP | 500SP | 1000SP | 5000SP | Custom Amount

You will earn 90% of the voting service's earnings based on your delegated SP's prorated share of the service's SP pool daily! That is up to 38.5% APR! You can also undelegate at anytime.

We are also a very profitable curation trail leader on https://steemauto.com/. Follow @ebargains today and earn more on curation rewards!

hi @yabapmatt, i'm curious, once smart contract becomes available in future versions of SMT, would you consider porting the game cards over to some unique version of tokens with different values, not unlike a flavor of ER721 (Conforming to Non-Fungible aka Unique Tokens) used by crytokitty

SMTs are not the same as custom programmable smart contracts offered by platforms like Ethereum and there are no plans to add anything like that to Steem. The point of this post was to show even without smart contracts we can still achieve the same goals that we could with ERC-721 tokens on Ethereum.

...i'm curious, once smart contract becomes available in future versions* of SMT, would you consider porting the game cards over to some unique version of tokens with different value...

that was a probable though practical questions of making the collection value of your game cards truly NFT and trustless

to simply rule out what i said just because we both know that when the first version of SMT comes out that there isn't yet smart contract isn't the point, it's highly likely the ideas of contracts have cross @ned, @sneak, and other's mind, and most likely have gone beyond the drawing boards of the rather secretive Steemit Inc (and honestly, i rather they keep it secret and just put in the herculean effort to create a prototype than put it as a proposal like in bitshares 3.0 and not really do anything after 1.5 years of announcing it)

but i would address your point nonetheless as i was hoping you would address mine:

the very first concept of ETH that came out also did not have a promise of smart contact, infact that was developed in later version, and was only officially announced (albeit shortly) after Ethereum's genesis

now, the additional point you also brought up in this post is:

Most importantly though, we really value the input from all of you! So, if you feel that I've gotten any of this wrong (which is entirely possible), please let me know, and I'm happy to work together to make sure we get it right!

for about 1 month, i have happily encourage and endorse @Steemmonsters to almost everyone who has asked me about it in my community, including the developers in our group

and to tell you the truth, i had to answer with hope of some possible positive outcome of future non-fungible (proof and certified unique cards that's unquestionable and can be easily certified beyond 1 account and 1 centralized access control - say a hybrid hard and soft would be interesting) and can automate part trust-less with minimal exposure to human error and server security (avoiding ala. @utopian-io thief of posting tokens situation) in the future

i hope this comes across as nothing but to open up a discussion, as i'm clearly just a fellow steem investor (and yes, I'm still buying now at these dangerously low prices) and community and witness supporter, i would really like to see what is the exit road-map you would be open to considering as the implementer of your collectible card game