Code Monkey home page Code Monkey logo

solvm's Introduction

solvm: The EVM inside the EVM

WTF?

A (slightly) stripped down version of the EVM implemented on top of the EVM using yul and solidity.

Why?

idk, for fun. Its a fun memory-management challenge. Also I've always wanted scripting in solidity and this is a step in that direction.

How?

A dynamic in-memory array is used as a jump table for ops. A dynamic in-memory array is used for the simulated EVM's stack variables. The simulated EVM's memory is held at a moveable offset and can move if needed (unlikely unless stack is forced to move).

Limits

Currently no context switching opcodes (all flavors of call). We can simulate a lot of these in memory if want though, just haven't gotten around to it.

Also bugs. Probably many bugs.

And gas. There are large one-time gas costs, that get amortized with more ops (but not a ton).

Example

contract EvmTest is DSTest {
    function testMul() public {
        Evm evm;
        // pass in raw bytecode and it evaluates it
        // does 1 * 3 and returns it
        (bool succ, bytes memory ret) = evm.evaluate(hex"600160030260205260206000F3");
        (uint256 r) = abi.decode(ret, (uint256));
        assertTrue(succ);
        assertEq(r, 3);
    }
}

solvm's People

Contributors

brockelmore avatar karmacoma-eth avatar

Stargazers

 avatar Tilak Madichetti avatar  avatar GorrilaObserver avatar 0xSimulacra avatar raxhvl avatar Tony H Dillion avatar Bob Liu avatar Erhan avatar dimitry avatar Kishan Sudani avatar AndrewZ avatar chirag-bgh avatar iri avatar eth_sign avatar  avatar  avatar Márcio Coutinho avatar Tiago Carvalho avatar Paco avatar 333satoru avatar Daniel Zhou avatar Ethan Cemer avatar Sparx avatar jrccrj avatar ChainKhan avatar Ryan avatar Elyx0 avatar beskay avatar Git-money-bee avatar Anna Zank avatar Sergio avatar Eito Miyamura avatar Security.eth avatar  avatar gmhacker.eth avatar  avatar Anto avatar gullintanni avatar John C avatar  avatar Aaryamann Challani avatar Chen Kai avatar juancito avatar sayan avatar Roman Hossain Shaon avatar Eugenio avatar Kell (K42) avatar Franfran avatar Pankaj Jagtap avatar Sourav Kumar Nanda avatar Georgii Molchanov avatar  avatar Harshad Dewangan avatar Suthan Somadeva avatar 0x4E33 avatar Rajkumar avatar techer.eth avatar Kamil Chmielewski avatar Kethic avatar 5/9 avatar Yaz Khoury avatar  avatar  avatar Alessio Delmonti avatar Bless Hukporti avatar Andrej avatar johann bestowrous avatar syjcnss avatar Krister Olsson avatar Rydamez Ochoa avatar G avatar afrideva avatar Panagiotis Ganelis avatar FreshPizza avatar jiangplus avatar Mathieu avatar Paweł Bylica avatar Aliaksei avatar Elias Tazartes avatar  avatar danilowhk avatar GaryB avatar  avatar Eddie avatar Tarrence van As avatar bloc13k avatar indigo avatar advaith avatar Vasiliy Yorkin avatar nicolas avatar Noy avatar Genghis Goose avatar  avatar Paul Razvan Berg avatar Phy avatar bixia avatar clandestine.eth avatar Zihan Zheng avatar Darpit Rangari avatar

Watchers

James Cloos avatar Michael Demarais avatar gmh 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.