Coder Social home page Coder Social logo

rogercoll / optimistic-roll-in Goto Github PK

View Code? Open in Web Editor NEW

This project forked from circle-free/optimistic-roll-in

0.0 2.0 0.0 4.49 MB

Layer-Agnostic Optimistic Roll-Ins For Isolated-State-Transitions - A Proof of Concept

License: MIT License

Solidity 23.62% JavaScript 76.38%

optimistic-roll-in's Introduction

optimistic-roll-in

Status

Just a Proof Of Concept, with Smart Contracts and JS Client. Only "happy path" tested. No security review. Feedback welcome and wanted.

Brief

If your contract(s) has any functionality that results in isolated state changes for individual accounts (which means you could rewrite certain function to take in the user's state, and some arguments, and result in a new state, via a pure function) then this library should allow your users to perform Optimistic Roll Ins. Effectively, your users can assert their intent to the chain, by providing their current state, the call data they would have sent to the chain normally, and their expected new state, and optimistically update their state, without wasting any gas actually performing the on-chain verifications and logic. They can perform as many of these state transitions as they want, one at a time, or even cheeper in batch (allowing for offline play and syncing afterwards), and any other users can validate their proposed state changes after the fact, and prove if anyone committed fraud. Users can enter and exit this "optimistic" state at will (some conditions) so that they can perform non-optimistic transitions that are the result on non-pure functions in your contract.

Things to note:

  • There is a small overhead for each call, associated with the Optimistic functionality, so if all or most of your normal state transitions are cheaper than that, then it may not make sense to use this. The overhead varies, depending on the type of data.
  • This is ideal for things like games that have some single-player component, since many account state transitions don't rely on the shared world's state.
  • This is ideal for things that involve very expensive proofs (like ZKPs, where 90%+ of transaction gas is spent verifying the proof), since they can be performed optimistically, and verified offline by others, and challenged on-chain.
  • This is not ideal not ideal if the "world state" (i.e. global/shared variables) are used throughout your code, since it means your state transitions are not "pure".
  • There is no L2 here. As a matter of fact, this is layer-agnostic, which means that while it could run on its own on mainnet, it could theoretically run on EVM-based L2s (like Optimism / Optimistic Roll Up).

Examples and more coming soon. Feel free to reach out with questions.

optimistic-roll-in's People

Contributors

deluca-mike avatar fish-sammy avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.