Skip to content

Commit a5ea21c

Browse files
committed
merge
2 parents db24fb7 + 38faf2c commit a5ea21c

File tree

311 files changed

+24802
-8615
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

311 files changed

+24802
-8615
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,5 @@
1515
.#*
1616
*#
1717
*~
18+
.project
19+
.settings

.travis.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
language: go
22
go:
3-
- tip
3+
- 1.4.1
44
before_install:
5-
- sudo add-apt-repository ppa:ubuntu-sdk-team/ppa -y
5+
- sudo add-apt-repository ppa:beineri/opt-qt54 -y
66
- sudo apt-get update -qq
7-
- sudo apt-get install -yqq libgmp3-dev qtbase5-private-dev qtdeclarative5-private-dev libqt5opengl5-dev libreadline6-dev
7+
- sudo apt-get install -yqq libgmp3-dev libreadline6-dev qt54quickcontrols qt54webengine
88
install:
99
- go get code.google.com/p/go.tools/cmd/goimports
1010
- go get github.com/golang/lint/golint
1111
# - go get golang.org/x/tools/cmd/vet
1212
- if ! go get code.google.com/p/go.tools/cmd/cover; then go get golang.org/x/tools/cmd/cover; fi
1313
- go get github.com/mattn/goveralls
14-
- 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
14+
- go get gopkg.in/check.v1
15+
- 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
1516
before_script:
1617
- gofmt -l -w .
1718
- goimports -l -w .
@@ -20,6 +21,11 @@ before_script:
2021
# - go test -race ./...
2122
script:
2223
- ./gocoverage.sh
24+
after_success:
25+
- if [ "$COVERALLS_TOKEN" ]; then goveralls -coverprofile=profile.cov -service=travis-ci -repotoken $COVERALLS_TOKEN; fi
2326
env:
24-
- secure: "U2U1AmkU4NJBgKR/uUAebQY87cNL0+1JHjnLOmmXwxYYyj5ralWb1aSuSH3qSXiT93qLBmtaUkuv9fberHVqrbAeVlztVdUsKAq7JMQH+M99iFkC9UiRMqHmtjWJ0ok4COD1sRYixxi21wb/JrMe3M1iL4QJVS61iltjHhVdM64="
27+
global:
28+
- PKG_CONFIG_PATH=/opt/qt54/lib/pkgconfig
29+
- LD_LIBRARY_PATH=/opt/qt54/lib
30+
- secure: "U2U1AmkU4NJBgKR/uUAebQY87cNL0+1JHjnLOmmXwxYYyj5ralWb1aSuSH3qSXiT93qLBmtaUkuv9fberHVqrbAeVlztVdUsKAq7JMQH+M99iFkC9UiRMqHmtjWJ0ok4COD1sRYixxi21wb/JrMe3M1iL4QJVS61iltjHhVdM64="
2531

Dockerfile

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,39 +3,35 @@ FROM ubuntu:14.04
33
## Environment setup
44
ENV HOME /root
55
ENV GOPATH /root/go
6-
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
6+
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
7+
ENV PKG_CONFIG_PATH /opt/qt54/lib/pkgconfig
78

89
RUN mkdir -p /root/go
910
ENV DEBIAN_FRONTEND noninteractive
1011

1112
## Install base dependencies
1213
RUN apt-get update && apt-get upgrade -y
13-
RUN apt-get install -y git mercurial build-essential software-properties-common pkg-config libgmp3-dev libreadline6-dev libpcre3-dev libpcre++-dev
14+
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
1415

15-
## Build and install Go
16-
RUN hg clone -u release https://code.google.com/p/go
17-
RUN cd go && hg update go1.4
18-
RUN cd go/src && ./all.bash && go version
19-
20-
## Install GUI dependencies
21-
RUN add-apt-repository ppa:ubuntu-sdk-team/ppa -y
16+
## Install Qt5.4 dependencies from PPA
17+
RUN add-apt-repository ppa:beineri/opt-qt54-trusty -y
2218
RUN apt-get update -y
23-
RUN apt-get install -y qtbase5-private-dev qtdeclarative5-private-dev libqt5opengl5-dev
19+
RUN apt-get install -y qt54quickcontrols qt54webengine
20+
21+
## Build and install latest Go
22+
RUN git clone https://go.googlesource.com/go golang
23+
RUN cd golang && git checkout go1.4.1
24+
RUN cd golang/src && ./make.bash && go version
2425

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

32-
# Fetch and install go-ethereum
33-
RUN go get -v -d github.com/ethereum/go-ethereum/...
29+
## Fetch and install go-ethereum
30+
RUN go get -u -v -d github.com/ethereum/go-ethereum/...
3431
WORKDIR $GOPATH/src/github.com/ethereum/go-ethereum
35-
# RUN git checkout develop
3632
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
3733
RUN go install -v ./cmd/ethereum
3834

39-
# Run JSON RPC
35+
## Run & expose JSON RPC
4036
ENTRYPOINT ["ethereum", "-rpc=true", "-rpcport=8080"]
4137
EXPOSE 8080

README.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,26 @@
1-
[![Bugs](https://badge.waffle.io/ethereum/go-ethereum.png?label=bug&title=Bugs)](https://waffle.io/ethereum/go-ethereum)
2-
[![Stories in Ready](https://badge.waffle.io/ethereum/go-ethereum.png?label=ready&title=Ready)](https://waffle.io/ethereum/go-ethereum)
3-
[![Stories in
4-
Progress](https://badge.waffle.io/ethereum/go-ethereum.svg?label=in%20progress&title=In Progress)](http://waffle.io/ethereum/go-ethereum)
5-
6-
Ethereum
7-
========
8-
9-
[![Build
10-
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
11-
Status](http://build.ethdev.com/buildstatusimage?builder=Linux%20Go%20develop%20branch)](http://build.ethdev.com:8010/builders/Linux%20Go%20develop%20branch/builds/-1) develop
12-
[![Coverage Status](https://coveralls.io/repos/ethereum/go-ethereum/badge.png?branch=tests)](https://coveralls.io/r/ethereum/go-ethereum?branch=tests) tests
1+
## Ethereum Go
132

143
Ethereum Go Client © 2014 Jeffrey Wilcke.
154

16-
Current state: Proof of Concept 0.8
5+
| Linux | OSX | Windows
6+
----------|---------|-----|--------
7+
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
8+
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
9+
10+
[![Bugs](https://badge.waffle.io/ethereum/go-ethereum.png?label=bug&title=Bugs)](https://waffle.io/ethereum/go-ethereum)
11+
[![Stories in Ready](https://badge.waffle.io/ethereum/go-ethereum.png?label=ready&title=Ready)](https://waffle.io/ethereum/go-ethereum)
12+
[![Stories in Progress](https://badge.waffle.io/ethereum/go-ethereum.svg?label=in%20progress&title=In Progress)](http://waffle.io/ethereum/go-ethereum)
13+
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/ethereum/go-ethereum?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
1714

18-
Ethereum is currently in its testing phase.
1915

2016
Build
2117
=====
2218

23-
To build Mist (GUI):
19+
Mist (GUI):
2420

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

27-
To build the node (CLI):
23+
Ethereum (CLI):
2824

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

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

36-
* [[OS X](http://build.ethdev.com/builds/OSX%20Go%20develop%20branch/latest/app/)]
32+
* [[OS X](http://build.ethdev.com/builds/OSX%20Go%20develop%20branch/Mist-OSX-latest.dmg)]
3733
* [Windows] Coming soon™
3834
* [Linux] Coming soon™
3935

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

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

107-
When you comment put meaningfull comments. Describe in detail what you
106+
When you comment put meaningful comments. Describe in detail what you
108107
want to achieve.
109108

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

127+

accounts/abi/abi.go

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
package abi
2+
3+
import (
4+
"encoding/json"
5+
"fmt"
6+
"io"
7+
"strings"
8+
9+
"github.com/ethereum/go-ethereum/crypto"
10+
)
11+
12+
// Callable method given a `Name` and whether the method is a constant.
13+
// If the method is `Const` no transaction needs to be created for this
14+
// particular Method call. It can easily be simulated using a local VM.
15+
// For example a `Balance()` method only needs to retrieve something
16+
// from the storage and therefor requires no Tx to be send to the
17+
// network. A method such as `Transact` does require a Tx and thus will
18+
// be flagged `true`.
19+
// Input specifies the required input parameters for this gives method.
20+
type Method struct {
21+
Name string
22+
Const bool
23+
Input []Argument
24+
Return Type // not yet implemented
25+
}
26+
27+
// Returns the methods string signature according to the ABI spec.
28+
//
29+
// Example
30+
//
31+
// function foo(uint32 a, int b) = "foo(uint32,int256)"
32+
//
33+
// Please note that "int" is substitute for its canonical representation "int256"
34+
func (m Method) String() (out string) {
35+
out += m.Name
36+
types := make([]string, len(m.Input))
37+
i := 0
38+
for _, input := range m.Input {
39+
types[i] = input.Type.String()
40+
i++
41+
}
42+
out += "(" + strings.Join(types, ",") + ")"
43+
44+
return
45+
}
46+
47+
func (m Method) Id() []byte {
48+
return crypto.Sha3([]byte(m.String()))[:4]
49+
}
50+
51+
// Argument holds the name of the argument and the corresponding type.
52+
// Types are used when packing and testing arguments.
53+
type Argument struct {
54+
Name string
55+
Type Type
56+
}
57+
58+
func (a *Argument) UnmarshalJSON(data []byte) error {
59+
var extarg struct {
60+
Name string
61+
Type string
62+
}
63+
err := json.Unmarshal(data, &extarg)
64+
if err != nil {
65+
return fmt.Errorf("argument json err: %v", err)
66+
}
67+
68+
a.Type, err = NewType(extarg.Type)
69+
if err != nil {
70+
return err
71+
}
72+
a.Name = extarg.Name
73+
74+
return nil
75+
}
76+
77+
// The ABI holds information about a contract's context and available
78+
// invokable methods. It will allow you to type check function calls and
79+
// packs data accordingly.
80+
type ABI struct {
81+
Methods map[string]Method
82+
}
83+
84+
// tests, tests whether the given input would result in a successful
85+
// call. Checks argument list count and matches input to `input`.
86+
func (abi ABI) pack(name string, args ...interface{}) ([]byte, error) {
87+
method := abi.Methods[name]
88+
89+
var ret []byte
90+
for i, a := range args {
91+
input := method.Input[i]
92+
93+
packed, err := input.Type.pack(a)
94+
if err != nil {
95+
return nil, fmt.Errorf("`%s` %v", name, err)
96+
}
97+
ret = append(ret, packed...)
98+
99+
}
100+
101+
return ret, nil
102+
}
103+
104+
// Pack the given method name to conform the ABI. Method call's data
105+
// will consist of method_id, args0, arg1, ... argN. Method id consists
106+
// of 4 bytes and arguments are all 32 bytes.
107+
// Method ids are created from the first 4 bytes of the hash of the
108+
// methods string signature. (signature = baz(uint32,string32))
109+
func (abi ABI) Pack(name string, args ...interface{}) ([]byte, error) {
110+
method, exist := abi.Methods[name]
111+
if !exist {
112+
return nil, fmt.Errorf("method '%s' not found", name)
113+
}
114+
115+
// start with argument count match
116+
if len(args) != len(method.Input) {
117+
return nil, fmt.Errorf("argument count mismatch: %d for %d", len(args), len(method.Input))
118+
}
119+
120+
arguments, err := abi.pack(name, args...)
121+
if err != nil {
122+
return nil, err
123+
}
124+
125+
// Set function id
126+
packed := abi.Methods[name].Id()
127+
packed = append(packed, arguments...)
128+
129+
return packed, nil
130+
}
131+
132+
func (abi *ABI) UnmarshalJSON(data []byte) error {
133+
var methods []Method
134+
if err := json.Unmarshal(data, &methods); err != nil {
135+
return err
136+
}
137+
138+
abi.Methods = make(map[string]Method)
139+
for _, method := range methods {
140+
abi.Methods[method.Name] = method
141+
}
142+
143+
return nil
144+
}
145+
146+
func JSON(reader io.Reader) (ABI, error) {
147+
dec := json.NewDecoder(reader)
148+
149+
var abi ABI
150+
if err := dec.Decode(&abi); err != nil {
151+
return ABI{}, err
152+
}
153+
154+
return abi, nil
155+
}

0 commit comments

Comments
 (0)