Skip to content

Commit

Permalink
Merge branch 'develop' into poc8
Browse files Browse the repository at this point in the history
  • Loading branch information
obscuren committed Feb 13, 2015
2 parents c9985bf + 00fca40 commit 7336dfa
Show file tree
Hide file tree
Showing 495 changed files with 2,209,980 additions and 13,966 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,10 @@
.DS_Store
*/**/.DS_Store
.ethtest

#*
.#*
*#
*~
.project
.settings
12 changes: 12 additions & 0 deletions .mailmap
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Jeffrey Wilcke <[email protected]>
Jeffrey Wilcke <[email protected]> <[email protected]>
Jeffrey Wilcke <[email protected]> <[email protected]>
Jeffrey Wilcke <[email protected]> <[email protected]>

Viktor Trón <[email protected]>

Joseph Goulden <[email protected]>

Nick Savers <[email protected]>

Maran Hidskes <[email protected]>
16 changes: 11 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
language: go
go:
- tip
- 1.4.1
before_install:
- sudo add-apt-repository ppa:ubuntu-sdk-team/ppa -y
- sudo add-apt-repository ppa:beineri/opt-qt54 -y
- sudo apt-get update -qq
- sudo apt-get install -yqq libgmp3-dev qtbase5-private-dev qtdeclarative5-private-dev libqt5opengl5-dev libreadline6-dev
- sudo apt-get install -yqq libgmp3-dev libreadline6-dev qt54quickcontrols qt54webengine
install:
- go get code.google.com/p/go.tools/cmd/goimports
- go get github.com/golang/lint/golint
# - go get golang.org/x/tools/cmd/vet
- if ! go get code.google.com/p/go.tools/cmd/cover; then go get golang.org/x/tools/cmd/cover; fi
- go get github.com/mattn/goveralls
- ETH_DEPS=$(go list -f '{{.Imports}} {{.TestImports}} {{.XTestImports}}' github.com/ethereum/go-ethereum/... | sed -e 's/\[//g' | sed -e 's/\]//g' | sed -e 's/C //g'); if [ "$ETH_DEPS" ]; then go get $ETH_DEPS; fi
- go get gopkg.in/check.v1
- DEPS=$(go list -f '{{.Imports}}' ./... | sed -e 's/\[//g' | sed -e 's/\]//g' | sed -e 's/C //g'); if [ "$DEPS" ]; then go get -d -v $DEPS; fi
before_script:
- gofmt -l -w .
- goimports -l -w .
Expand All @@ -20,6 +21,11 @@ before_script:
# - go test -race ./...
script:
- ./gocoverage.sh
after_success:
- if [ "$COVERALLS_TOKEN" ]; then goveralls -coverprofile=profile.cov -service=travis-ci -repotoken $COVERALLS_TOKEN; fi
env:
- secure: "U2U1AmkU4NJBgKR/uUAebQY87cNL0+1JHjnLOmmXwxYYyj5ralWb1aSuSH3qSXiT93qLBmtaUkuv9fberHVqrbAeVlztVdUsKAq7JMQH+M99iFkC9UiRMqHmtjWJ0ok4COD1sRYixxi21wb/JrMe3M1iL4QJVS61iltjHhVdM64="
global:
- PKG_CONFIG_PATH=/opt/qt54/lib/pkgconfig
- LD_LIBRARY_PATH=/opt/qt54/lib
- secure: "U2U1AmkU4NJBgKR/uUAebQY87cNL0+1JHjnLOmmXwxYYyj5ralWb1aSuSH3qSXiT93qLBmtaUkuv9fberHVqrbAeVlztVdUsKAq7JMQH+M99iFkC9UiRMqHmtjWJ0ok4COD1sRYixxi21wb/JrMe3M1iL4QJVS61iltjHhVdM64="

36 changes: 16 additions & 20 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,35 @@ FROM ubuntu:14.04
## Environment setup
ENV HOME /root
ENV GOPATH /root/go
ENV PATH /go/bin:/root/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
ENV PATH /golang/bin:/root/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
ENV PKG_CONFIG_PATH /opt/qt54/lib/pkgconfig

RUN mkdir -p /root/go
ENV DEBIAN_FRONTEND noninteractive

## Install base dependencies
RUN apt-get update && apt-get upgrade -y
RUN apt-get install -y git mercurial build-essential software-properties-common pkg-config libgmp3-dev libreadline6-dev libpcre3-dev libpcre++-dev
RUN apt-get install -y git mercurial build-essential software-properties-common pkg-config libgmp3-dev libreadline6-dev libpcre3-dev libpcre++-dev mesa-common-dev libglu1-mesa-dev

## Build and install Go
RUN hg clone -u release https://code.google.com/p/go
RUN cd go && hg update go1.4
RUN cd go/src && ./all.bash && go version

## Install GUI dependencies
RUN add-apt-repository ppa:ubuntu-sdk-team/ppa -y
## Install Qt5.4 dependencies from PPA
RUN add-apt-repository ppa:beineri/opt-qt54-trusty -y
RUN apt-get update -y
RUN apt-get install -y qtbase5-private-dev qtdeclarative5-private-dev libqt5opengl5-dev
RUN apt-get install -y qt54quickcontrols qt54webengine

## Build and install latest Go
RUN git clone https://go.googlesource.com/go golang
RUN cd golang && git checkout go1.4.1
RUN cd golang/src && ./make.bash && go version

## Fetch and install serpent-go
RUN go get -v -d github.com/ethereum/serpent-go
WORKDIR $GOPATH/src/github.com/ethereum/serpent-go
# RUN git checkout master
RUN git submodule update --init
RUN go install -v
# this is a workaround, to make sure that docker's cache is invalidated whenever the git repo changes
ADD https://api.github.com/repos/ethereum/go-ethereum/git/refs/heads/develop file_does_not_exist

# Fetch and install go-ethereum
RUN go get -v -d github.com/ethereum/go-ethereum/...
## Fetch and install go-ethereum
RUN go get -u -v -d github.com/ethereum/go-ethereum/...
WORKDIR $GOPATH/src/github.com/ethereum/go-ethereum
# RUN git checkout develop
RUN ETH_DEPS=$(go list -f '{{.Imports}} {{.TestImports}} {{.XTestImports}}' github.com/ethereum/go-ethereum/... | sed -e 's/\[//g' | sed -e 's/\]//g' | sed -e 's/C //g'); if [ "$ETH_DEPS" ]; then go get $ETH_DEPS; fi
RUN go install -v ./cmd/ethereum

# Run JSON RPC
## Run & expose JSON RPC
ENTRYPOINT ["ethereum", "-rpc=true", "-rpcport=8080"]
EXPOSE 8080
38 changes: 19 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,26 @@
[![Bugs](https://badge.waffle.io/ethereum/go-ethereum.png?label=bug&title=Bugs)](https://waffle.io/ethereum/go-ethereum)
[![Stories in Ready](https://badge.waffle.io/ethereum/go-ethereum.png?label=ready&title=Ready)](https://waffle.io/ethereum/go-ethereum)
[![Stories in
Progress](https://badge.waffle.io/ethereum/go-ethereum.svg?label=in%20progress&title=In Progress)](http://waffle.io/ethereum/go-ethereum)

Ethereum
========

[![Build
Status](http://build.ethdev.com/buildstatusimage?builder=Linux%20Go%20master%20branch)](http://build.ethdev.com:8010/builders/Linux%20Go%20master%20branch/builds/-1) master [![Build
Status](http://build.ethdev.com/buildstatusimage?builder=Linux%20Go%20develop%20branch)](http://build.ethdev.com:8010/builders/Linux%20Go%20develop%20branch/builds/-1) develop
[![Coverage Status](https://coveralls.io/repos/ethereum/go-ethereum/badge.png?branch=tests)](https://coveralls.io/r/ethereum/go-ethereum?branch=tests) tests
## Ethereum Go

Ethereum Go Client © 2014 Jeffrey Wilcke.

Current state: Proof of Concept 0.8
| Linux | OSX | Windows
----------|---------|-----|--------
develop | [![Build+Status](http://build.ethdev.com/buildstatusimage?builder=Linux%20Go%20develop%20branch)](http://build.ethdev.com/builders/Linux%20Go%20develop%20branch/builds/-1) | [![Build+Status](http://build.ethdev.com/buildstatusimage?builder=Linux%20Go%20develop%20branch)](http://build.ethdev.com/builders/OSX%20Go%20develop%20branch/builds/-1) | N/A
master | [![Build+Status](http://build.ethdev.com/buildstatusimage?builder=Linux%20Go%20master%20branch)](http://build.ethdev.com/builders/Linux%20Go%20master%20branch/builds/-1) | [![Build+Status](http://build.ethdev.com/buildstatusimage?builder=OSX%20Go%20master%20branch)](http://build.ethdev.com/builders/OSX%20Go%20master%20branch/builds/-1) | N/A

[![Bugs](https://badge.waffle.io/ethereum/go-ethereum.png?label=bug&title=Bugs)](https://waffle.io/ethereum/go-ethereum)
[![Stories in Ready](https://badge.waffle.io/ethereum/go-ethereum.png?label=ready&title=Ready)](https://waffle.io/ethereum/go-ethereum)
[![Stories in Progress](https://badge.waffle.io/ethereum/go-ethereum.svg?label=in%20progress&title=In Progress)](http://waffle.io/ethereum/go-ethereum)
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/ethereum/go-ethereum?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)

Ethereum is currently in its testing phase.

Build
=====

To build Mist (GUI):
Mist (GUI):

`go get github.com/ethereum/go-ethereum/cmd/mist`

To build the node (CLI):
Ethereum (CLI):

`go get github.com/ethereum/go-ethereum/cmd/ethereum`

Expand All @@ -33,7 +29,7 @@ For further, detailed, build instruction please see the [Wiki](https://github.co
Automated (dev) builds
======================

* [[OS X](http://build.ethdev.com/builds/OSX%20Go%20develop%20branch/latest/app/)]
* [[OS X](http://build.ethdev.com/builds/OSX%20Go%20develop%20branch/Mist-OSX-latest.dmg)]
* [Windows] Coming soon&trade;
* [Linux] Coming soon&trade;

Expand All @@ -46,9 +42,12 @@ Go Ethereum comes with several binaries found in
* `mist` Official Ethereum Browser
* `ethereum` Ethereum CLI
* `ethtest` test tool which runs with the [tests](https://github.com/ethereum/testes) suit:
`ethtest "`cat myfile.json`"`.
`cat file | ethtest`.
* `evm` is a generic Ethereum Virtual Machine: `evm -code 60ff60ff -gas
10000 -price 0 -dump`. See `-h` for a detailed description.
* `rlpdump` converts a rlp stream to `interface{}`.
* `peerserver` simple P2P (noi-ethereum) peer server.
* `disasm` disassembles EVM code: `echo "6001" | disasm`

General command line options
============================
Expand Down Expand Up @@ -104,7 +103,7 @@ Style](http://golang.org/doc/effective_go.html#formatting).
Unless structs fields are supposed to be directly accesible, provide
Getters and hide the fields through Go's exporting facility.

When you comment put meaningfull comments. Describe in detail what you
When you comment put meaningful comments. Describe in detail what you
want to achieve.

*wrong*
Expand All @@ -125,3 +124,4 @@ expect you to write tests for me so I don't have to test your code
manually. (If you want to contribute by just writing tests that's fine
too!)


155 changes: 155 additions & 0 deletions accounts/abi/abi.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
package abi

import (
"encoding/json"
"fmt"
"io"
"strings"

"github.com/ethereum/go-ethereum/crypto"
)

// Callable method given a `Name` and whether the method is a constant.
// If the method is `Const` no transaction needs to be created for this
// particular Method call. It can easily be simulated using a local VM.
// For example a `Balance()` method only needs to retrieve something
// from the storage and therefor requires no Tx to be send to the
// network. A method such as `Transact` does require a Tx and thus will
// be flagged `true`.
// Input specifies the required input parameters for this gives method.
type Method struct {
Name string
Const bool
Input []Argument
Return Type // not yet implemented
}

// Returns the methods string signature according to the ABI spec.
//
// Example
//
// function foo(uint32 a, int b) = "foo(uint32,int256)"
//
// Please note that "int" is substitute for its canonical representation "int256"
func (m Method) String() (out string) {
out += m.Name
types := make([]string, len(m.Input))
i := 0
for _, input := range m.Input {
types[i] = input.Type.String()
i++
}
out += "(" + strings.Join(types, ",") + ")"

return
}

func (m Method) Id() []byte {
return crypto.Sha3([]byte(m.String()))[:4]
}

// Argument holds the name of the argument and the corresponding type.
// Types are used when packing and testing arguments.
type Argument struct {
Name string
Type Type
}

func (a *Argument) UnmarshalJSON(data []byte) error {
var extarg struct {
Name string
Type string
}
err := json.Unmarshal(data, &extarg)
if err != nil {
return fmt.Errorf("argument json err: %v", err)
}

a.Type, err = NewType(extarg.Type)
if err != nil {
return err
}
a.Name = extarg.Name

return nil
}

// The ABI holds information about a contract's context and available
// invokable methods. It will allow you to type check function calls and
// packs data accordingly.
type ABI struct {
Methods map[string]Method
}

// tests, tests whether the given input would result in a successful
// call. Checks argument list count and matches input to `input`.
func (abi ABI) pack(name string, args ...interface{}) ([]byte, error) {
method := abi.Methods[name]

var ret []byte
for i, a := range args {
input := method.Input[i]

packed, err := input.Type.pack(a)
if err != nil {
return nil, fmt.Errorf("`%s` %v", name, err)
}
ret = append(ret, packed...)

}

return ret, nil
}

// Pack the given method name to conform the ABI. Method call's data
// will consist of method_id, args0, arg1, ... argN. Method id consists
// of 4 bytes and arguments are all 32 bytes.
// Method ids are created from the first 4 bytes of the hash of the
// methods string signature. (signature = baz(uint32,string32))
func (abi ABI) Pack(name string, args ...interface{}) ([]byte, error) {
method, exist := abi.Methods[name]
if !exist {
return nil, fmt.Errorf("method '%s' not found", name)
}

// start with argument count match
if len(args) != len(method.Input) {
return nil, fmt.Errorf("argument count mismatch: %d for %d", len(args), len(method.Input))
}

arguments, err := abi.pack(name, args...)
if err != nil {
return nil, err
}

// Set function id
packed := abi.Methods[name].Id()
packed = append(packed, arguments...)

return packed, nil
}

func (abi *ABI) UnmarshalJSON(data []byte) error {
var methods []Method
if err := json.Unmarshal(data, &methods); err != nil {
return err
}

abi.Methods = make(map[string]Method)
for _, method := range methods {
abi.Methods[method.Name] = method
}

return nil
}

func JSON(reader io.Reader) (ABI, error) {
dec := json.NewDecoder(reader)

var abi ABI
if err := dec.Decode(&abi); err != nil {
return ABI{}, err
}

return abi, nil
}
Loading

0 comments on commit 7336dfa

Please sign in to comment.