Git Product home page Git Product logo

4788asm's Introduction

4788asm

This is an ekt implementation of the EIP-4788 system contract. It is 100 bytes once assembled.

Getting Started

To setup a dev environment capable of assembling, analyzing, and executing the repository's assembly you will need to install foundry and etk. This can be accomplished by running:

$ curl -L https://foundry.paradigm.xyz | bash
$ cargo install --features cli etk-asm etk-dasm

Building

To assemble src/main.etk you will need to invoke eas:

$ eas src/main.etk
3373fffffffffffffffffffffffffffffffffffffffe14604457602036146024575f5ffd5b620180005f350680545f35146037575f5ffd5b6201800001545f5260205ff35b6201800042064281555f359062018000015500

It's also possible to remove the etk preproccessing by doing a roundtrip -- first assembling the program, then disassembling the program:

$ disease --code 0x$(eas src/main.etk)
   0:   caller
   1:   push20 0xfffffffffffffffffffffffffffffffffffffffe
  16:   eq
  17:   push1 0x44
  19:   jumpi

  1a:   push1 0x20
  1c:   calldatasize
  1d:   eq
  1e:   push1 0x24
  20:   jumpi

  21:   push0
  22:   push0
  23:   revert

  24:   jumpdest
  25:   push3 0x018000
  29:   push0
  2a:   calldataload
  2b:   mod
  2c:   dup1
  2d:   sload
  2e:   push0
  2f:   calldataload
  30:   eq
  31:   push1 0x37
  33:   jumpi

  34:   push0
  35:   push0
  36:   revert

  37:   jumpdest
  38:   push3 0x018000
  3c:   add
  3d:   sload
  3e:   push0
  3f:   mstore
  40:   push1 0x20
  42:   push0
  43:   return

  44:   jumpdest
  45:   push3 0x018000
  49:   timestamp
  4a:   mod
  4b:   timestamp
  4c:   dup2
  4d:   sstore
  4e:   push0
  4f:   calldataload
  50:   swap1
  51:   push3 0x018000
  55:   add
  56:   sstore
  57:   stop

Control-flow Graph

There are several tools to generate a control-flow graph. We'll demostrate evm-cfg here:

evm-cfg $(eas src/main.etk) | dot -Tpng -o cfg.png

note: you will also need graphviz installed to use the dot utility.

cfg.png

cfg.png

Testing

The tests can be executed using the builder-wrapper script with the same arguments as forge:

$ ./build-wrapper test
[โ †] Compiling...
No files changed, compilation skipped

Running 2 tests for test/Contract.t.sol:ContractTest
[PASS] testRead() (gas: 18514)
[PASS] testUpdate() (gas: 53953)
Test result: ok. 2 passed; 0 failed; 0 skipped; finished in 3.35ms
Ran 1 test suites: 2 tests passed, 0 failed, 0 skipped (2 total tests)

A step-by-step debugger can be brought up using ./build-wrapper test --debug {test name}.

4788asm's People

Contributors

holiman avatar lightclient 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.