Giter Site home page Giter Site logo

pirapira / bamboo Goto Github PK

View Code? Open in Web Editor NEW
324.0 33.0 39.0 1.14 MB

Bamboo see https://github.com/cornellblockchain/bamboo

License: Apache License 2.0

Shell 0.12% OCaml 99.57% Makefile 0.12% JavaScript 0.14% Standard ML 0.06%
bamboo programming-language language evm ethereum ethereum-contract

bamboo's Introduction

Bamboo: a language for morphing smart contracts

Cornell Blockchain says they can now maintain the Bamboo compiler. https://github.com/CornellBlockchain/bamboo


Join the chat at https://gitter.im/bbo-dev/Lobby

Build Status

Bamboo is a programming language for Ethereum contracts. Bamboo makes state transition explicit and avoids reentrance problems by default. See manifest for the motivation, or tutorial if you want to deploy something first, or semantics if you need something resembling a definition.

Example Bamboo Code

Compiler

The Bamboo compiler sometimes produces bytecode, which needs to be tested.

As preparation,

  • install opam with OCaml 4.04.1
  • opam install bamboo should install bamboo.

When you check out this repository,

bamboo < src/parse/examples/006auction_first_case.bbo

produces a bytecode. Do not trust the output as the compiler still contains bugs probably.

bamboo --abi < src/parse/examples/006auction_first_case.bbo

prints ABI.

[{"type": "constructor", "inputs":[{"name": "_beneficiary", "type": "address"},{"name": "_bidding_time", "type": "uint256"},{"name": "_highest_bid", "type": "uint256"}], "name": "auction", "outputs":[], "payable": true},{"type":"fallback","inputs": [],"outputs": [],"payable": true}]

Developing Bamboo

To try Bamboo in your local environment, run make dep from the project folder. That should install all dependencies. Once the installation process is done, run eval $(opam config env) and then you can build all targets using make, and run the tests with make test.

When you modify the OCaml source of Bamboo, you can try your version by

$ make
$ ./lib/bs/native/bamboo.native < src/parse/examples/006auction_first_case.bbo

Embark

An Embark plugin for Bamboo is available. To use it, first install Embark and add then add the plugin to your DApp.

npm install -g embark
embark new AppName
cd AppName
npm install embark-bamboo --save

then add embark-bamboo to the plugins section in embark.json:

  "plugins": {
    "embark-bamboo": {}
  }

Afterwards Embark will recognize .bbo files and compile them with Bamboo.

How to Contribute

  • notice problems and point them out. create issues.
  • test the bytecode like this, but using other examples. You might find bugs in the compiler.
  • write new Bamboo code and test the compiler.
  • join the Gitter channel.
  • spread a rumor to your friends who are into programming languages.

Related Work

Linden Scripting Language

Linden Scripting Language has similar organization of code according to states.

Obsidian

Obsidian is another programming language that models smart contracts as state machines. Obsidian even tracks states of the contracts statically.

bamboo's People

Contributors

aupiff avatar djrtwo avatar estensen avatar gitter-badger avatar hugo-dc avatar iurimatias avatar jchavarri avatar joelburget avatar pirapira avatar tjade273 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bamboo's Issues

The ordering of calldata is reversed

At commit cf55d36 , make test shows

argument x at Calldata offset 72, size 32
argument b at Calldata offset 64, size 32
argument c at Calldata offset 32, size 8
argument d at Calldata offset 0, size 32

for a source that looks like

case (int a(bytes32 x, bytes32 b, uint8 c, bytes32 d)) {

The ordering of arguments are reversed.

"Account unknown" failure during end-to-end test

In the account_unknown branch, a strange error appears

$ make end-to-end && ./end-to-end.native
ocamlbuild -use-ocamlfind -Is src/ast,src/parse,src/lib,src/codegen -package batteries -package cryptokit -package rope -package rpclib -package rpclib.unix -package unix -package rpclib.json -package ppx_deriving -package ppx_deriving_rpc -use-menhir src/exec/end-to-end.native
Finished, 91 targets (91 cached) in 00:00:00.
connected
got result 0x100000000000000000000000000000000000000000
Fatal error: exception Failure("Expected string, got '{jsonrpc:S(2.0);error:{code:I(0);data:N;message:S(Account unknown.)};id:I(0)}'")

assertion failure in lib_test

case0 01f42fe4 0c11dedd
Fatal error: exception File "lib/lib_test.ml", line 21, characters 11-17: Assertion failed

Maybe we can use the Keccak implementation in the eth-isabelle project.

a_mem_to_str: codecopy not implemented

Implement events

Currently compiled examples do not contain events. This issue keeps track of implementing the events.

bbo: add an option to emit the json ABI

./bbo.native --abi < parse/examples/00b_auction_more.bbo should return

[{"constant":false,"inputs":[],"name":"bid","outputs":[{"name":"","type":"bool"}],"payable":true,"type":"function"},{"constant":false,"inputs":[],"name":"bidding_time","outputs":[{"name":"","type":"uint256"}],"payable":true,"type":"function"},{"constant":false,"inputs":[],"name":"highest_bid","outputs":[{"name":"","type":"uint256"}],"payable":true,"type":"function"},{"inputs":[{"name":"","type":"address"},{"name":"","type":"uint256"},{"name":"","type":"uint256"}],"payable":true,"type":"constructor"},{"payable":true,"type":"fallback"}]

Maybe without payable attributes.

Use PUSH4 for tags

Currently PUSH32 is used for pushing jump destinations, but PUSH4 seems enough (of course the compiler should check the value being pushed fits the width).

reserve names starting with `pre_`

When the source contains an identifier with pre_, the compiler should error out, saying "names starting with pre_ is reserved for future use."

highest_bid function seems to be returning a too long data

Currently, end-to-end.native shows:

got answer: 0x000000000000000000000000000000000000000000000000000000000000006400000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000

However, this should just be 0x0000000000000000000000000000000000000000000000000000000000000064.

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.