Skip to content

tokamak-network/solEVM

 
 

Repository files navigation

CP challenge for Tokamak

Discord

Implementation Status

Support Storage

  • support storage field on contract
  • support storage field to local VM
  • support OPcode SSTORE, SLOAD
  • support storage 필드 in merkle tree offchain

Verification of external code in offchain

  • support external call(verification of a contract code in offchain)

Verification of ERC20 token method

  • support log field in execution state
  • verification of ERC-20 contract method(balanceOf)
  • verification of ERC-20 contract method(transfer)

Support Stateful

  • support Account
  • support transfer ETH in contract
  • support ETH transfer

Support CALL like OPCODES

  • implementation of arranging execution steps of CALLER and CALLEE
  • implementation of submitting merkle proof for state
  • support OPcode CALL
  • support OPcode DELEGATECALL
  • support OPcode STATICCALL

Support State Transition Function

  • support charging UPFRONT COST
  • support refunding TX FEE
  • support block's reward in case of last transaction

Optimization

  • implementation of compact storage
  • implementation of compact return data
  • implementation of compact log

Integration with Clients

  • integration with Plasma EVM client(GO porting)

Misc

  • support OPcode(BALANCE, GASLIMIT, EXTCODESIZE, EXTCODECOPY, EXTCODEHASH, RETURNDATASIZE)

Setup

$ git clone https://github.com/Onther-Tech/solEVM.git ./
$ npm install

Test

You can run the tests of verification game :

$ ./scripts/test_geth.sh test/contracts/[Test File].js

If you want to look into more details or debug for development you can do like this :

$ DEBUG=vgame-test ./scripts/test_geth.sh test/contracts/[Test File].js

You can run the test of offchain stepper(Offchain VM) :

$ node test/utils/testStepper.js

You can run the test of offchain stepper when to execute CALL(Offchain VM) :

$ npm run test:utils:call

You can compile all contracts :

$ npm run compile:contracts

Usage

describe('Fixture for Dispute/Verifier Logic #1', function () {    
    
    const code = ['runtime bytecode'];
    const data = ['callData'];
    const tStorage = ['0x + hex'];
    
    let steps;
    let copy;
    let merkle;
    const runtime = new HydratedRuntime();

    beforeEach(async () => {
      steps = await runtime.run({ code, data, pc: 0, tStorage: tStorage });
      copy = JSON.stringify(steps);
      merkle = new Merkelizer().run(steps, code, data, tStorage);
    });

Input

  • code [runtime bytecode] - bytes
  • data [callData] - bytes
  • stack [hex number] - 32bytes
  • mem [hex number] - 32bytes
  • tStorage [slot, value, slot, value, ...] - 32bytes

Test Status

Test Files Case Pass / Fail / Not Yet
dispute.storage.js OPCODE SLOAD, SSTORE Support Pass
dispute.log.js OPCODE LOG Support Pass
dispute.balanceOf.js ERC20 balanceOf Verification Pass
dispute.transfer.js ERC20 transfer Verification Pass
- OPCODE CALL, DELEGATECALL, STATICCALL Support Not Yet
- OPCODE CREATE, CREATE2 Support Not Yet

Test Case

Case
both have the same result, solver wins
challenger has an output error somewhere
solver has an output error somewhere
challenger first step missing
solver first step missing
challenger last step gone
solver last step gone
challenger wrong memory output
solver wrong memory output
challenger wrong stack output
solver wrong stack output
challenger wrong opcode
solver wrong opcode
only two steps, both wrong but doesn\'t end with OP.REVERT or RETURN = challenger wins
solver misses steps in between
solver with one invalid step
challenger with one invalid step
solver with one invalid step against LOG
challenger with one invalid step against LOG

About

Partial implementation of the Ethereum runtime in Solidity (PoC)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 59.5%
  • Solidity 40.1%
  • Shell 0.4%