Skip to content
This repository has been archived by the owner on Jun 17, 2022. It is now read-only.

Ensuring the tx handler is deterministic #140

Open
Ivshti opened this issue Jun 25, 2018 · 2 comments
Open

Ensuring the tx handler is deterministic #140

Ivshti opened this issue Jun 25, 2018 · 2 comments

Comments

@Ivshti
Copy link

Ivshti commented Jun 25, 2018

IMHO this framework should do more to ensure the tx handling/general behaviour is deterministic

There are a bunch of ways to do this, one of them seems really useful: https://deterministic.js.org

Also this can help: https://nodejs.org/api/vm.html, as it allows to build a sandbox in which the entire context guarantees deterministic behaviour (e.g. Math.random is predictable, etc.); some things might still be tricky,, e.g. floating point arithmetic (not sure if that's non-deterministic in v8 though)

also there's this issue: #11, which has a nice enhancement idea

@veqtor
Copy link

veqtor commented Oct 23, 2018

Random is never a good idea in blockchains, since it's easy for miners to manipulate it by submitting various junk transactions to manipulate current block-hash so as to modify current random state, if it's based on block-hash of previous block, which is the only reliable source of random. What you can do is to have a "contract" or piece of code force a user to commit to a transaction in a block which is ex 5 blocks from now, being their random number seed, and then actually perform the "dice" roll at that time

@mappum
Copy link
Contributor

mappum commented Feb 9, 2019

Currently it's up to the developer to ensure the logic implemented directly in the app is deterministic, but it would definitely be nice to make it harder to accidentally create non-determinism.

There is currently work being done by @keppel to encapsulate contracts into WebAssembly VMs which are purely deterministic by default (I believe this will be published soon).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants