Skip to content

Commit 5490437

Browse files
committed
Merge branch 'develop' into release/1.3.2
Conflicts: VERSION cmd/geth/main.go
2 parents e553215 + b0fb48c commit 5490437

Some content is hidden

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

66 files changed

+3539
-1772
lines changed

Makefile

Lines changed: 58 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,17 @@
22
# with Go source code. If you know what GOPATH is then you probably
33
# don't need to bother with make.
44

5-
.PHONY: geth geth-cross geth-linux geth-darwin geth-windows geth-android evm all test travis-test-with-coverage xgo clean
5+
.PHONY: geth geth-cross evm all test travis-test-with-coverage xgo clean
6+
.PHONY: geth-linux geth-linux-arm geth-linux-386 geth-linux-amd64
7+
.PHONY: geth-darwin geth-darwin-386 geth-darwin-amd64
8+
.PHONY: geth-windows geth-windows-386 geth-windows-amd64
9+
.PHONY: geth-android geth-android-16 geth-android-21
10+
611
GOBIN = build/bin
712

13+
CROSSDEPS = https://gmplib.org/download/gmp/gmp-6.0.0a.tar.bz2
14+
GO ?= latest
15+
816
geth:
917
build/env.sh go install -v $(shell build/flags.sh) ./cmd/geth
1018
@echo "Done building."
@@ -14,26 +22,67 @@ geth-cross: geth-linux geth-darwin geth-windows geth-android
1422
@echo "Full cross compilation done:"
1523
@ls -l $(GOBIN)/geth-*
1624

17-
geth-linux: xgo
18-
build/env.sh $(GOBIN)/xgo --dest=$(GOBIN) --deps=https://gmplib.org/download/gmp/gmp-6.0.0a.tar.bz2 --targets=linux/* -v $(shell build/flags.sh) ./cmd/geth
25+
geth-linux: xgo geth-linux-arm geth-linux-386 geth-linux-amd64
1926
@echo "Linux cross compilation done:"
2027
@ls -l $(GOBIN)/geth-linux-*
2128

22-
geth-darwin: xgo
23-
build/env.sh $(GOBIN)/xgo --dest=$(GOBIN) --deps=https://gmplib.org/download/gmp/gmp-6.0.0a.tar.bz2 --targets=darwin/* -v $(shell build/flags.sh) ./cmd/geth
29+
geth-linux-arm: xgo
30+
build/env.sh $(GOBIN)/xgo --go=$(GO) --dest=$(GOBIN) --deps=$(CROSSDEPS) --targets=linux/arm -v $(shell build/flags.sh) ./cmd/geth
31+
@echo "Linux ARM cross compilation done:"
32+
@ls -l $(GOBIN)/geth-linux-* | grep arm
33+
34+
geth-linux-386: xgo
35+
build/env.sh $(GOBIN)/xgo --go=$(GO) --dest=$(GOBIN) --deps=$(CROSSDEPS) --targets=linux/386 -v $(shell build/flags.sh) ./cmd/geth
36+
@echo "Linux 386 cross compilation done:"
37+
@ls -l $(GOBIN)/geth-linux-* | grep 386
38+
39+
geth-linux-amd64: xgo
40+
build/env.sh $(GOBIN)/xgo --go=$(GO) --dest=$(GOBIN) --deps=$(CROSSDEPS) --targets=linux/amd64 -v $(shell build/flags.sh) ./cmd/geth
41+
@echo "Linux amd64 cross compilation done:"
42+
@ls -l $(GOBIN)/geth-linux-* | grep amd64
43+
44+
geth-darwin: xgo geth-darwin-386 geth-darwin-amd64
2445
@echo "Darwin cross compilation done:"
2546
@ls -l $(GOBIN)/geth-darwin-*
2647

27-
geth-windows: xgo
28-
build/env.sh $(GOBIN)/xgo --dest=$(GOBIN) --deps=https://gmplib.org/download/gmp/gmp-6.0.0a.tar.bz2 --targets=windows/* -v $(shell build/flags.sh) ./cmd/geth
48+
geth-darwin-386: xgo
49+
build/env.sh $(GOBIN)/xgo --go=$(GO) --dest=$(GOBIN) --deps=$(CROSSDEPS) --targets=darwin/386 -v $(shell build/flags.sh) ./cmd/geth
50+
@echo "Darwin 386 cross compilation done:"
51+
@ls -l $(GOBIN)/geth-darwin-* | grep 386
52+
53+
geth-darwin-amd64: xgo
54+
build/env.sh $(GOBIN)/xgo --go=$(GO) --dest=$(GOBIN) --deps=$(CROSSDEPS) --targets=darwin/amd64 -v $(shell build/flags.sh) ./cmd/geth
55+
@echo "Darwin amd64 cross compilation done:"
56+
@ls -l $(GOBIN)/geth-darwin-* | grep amd64
57+
58+
geth-windows: xgo geth-windows-386 geth-windows-amd64
2959
@echo "Windows cross compilation done:"
3060
@ls -l $(GOBIN)/geth-windows-*
3161

32-
geth-android: xgo
33-
build/env.sh $(GOBIN)/xgo --dest=$(GOBIN) --deps=https://gmplib.org/download/gmp/gmp-6.0.0a.tar.bz2 --targets=android-16/*,android-21/* -v $(shell build/flags.sh) ./cmd/geth
62+
geth-windows-386: xgo
63+
build/env.sh $(GOBIN)/xgo --go=$(GO) --dest=$(GOBIN) --deps=$(CROSSDEPS) --targets=windows/386 -v $(shell build/flags.sh) ./cmd/geth
64+
@echo "Windows 386 cross compilation done:"
65+
@ls -l $(GOBIN)/geth-windows-* | grep 386
66+
67+
geth-windows-amd64: xgo
68+
build/env.sh $(GOBIN)/xgo --go=$(GO) --dest=$(GOBIN) --deps=$(CROSSDEPS) --targets=windows/amd64 -v $(shell build/flags.sh) ./cmd/geth
69+
@echo "Windows amd64 cross compilation done:"
70+
@ls -l $(GOBIN)/geth-windows-* | grep amd64
71+
72+
geth-android: xgo geth-android-16 geth-android-21
3473
@echo "Android cross compilation done:"
3574
@ls -l $(GOBIN)/geth-android-*
3675

76+
geth-android-16: xgo
77+
build/env.sh $(GOBIN)/xgo --go=$(GO) --dest=$(GOBIN) --deps=$(CROSSDEPS) --targets=android-16/* -v $(shell build/flags.sh) ./cmd/geth
78+
@echo "Android 16 cross compilation done:"
79+
@ls -l $(GOBIN)/geth-android-16-*
80+
81+
geth-android-21: xgo
82+
build/env.sh $(GOBIN)/xgo --go=$(GO) --dest=$(GOBIN) --deps=$(CROSSDEPS) --targets=android-21/* -v $(shell build/flags.sh) ./cmd/geth
83+
@echo "Android 21 cross compilation done:"
84+
@ls -l $(GOBIN)/geth-android-21-*
85+
3786
evm:
3887
build/env.sh $(GOROOT)/bin/go install -v $(shell build/flags.sh) ./cmd/evm
3988
@echo "Done building."

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.3.1
1+
1.3.2

accounts/abi/abi.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import (
3636
type Method struct {
3737
Name string
3838
Const bool
39-
Input []Argument
39+
Inputs []Argument
4040
Return Type // not yet implemented
4141
}
4242

@@ -49,9 +49,9 @@ type Method struct {
4949
// Please note that "int" is substitute for its canonical representation "int256"
5050
func (m Method) String() (out string) {
5151
out += m.Name
52-
types := make([]string, len(m.Input))
52+
types := make([]string, len(m.Inputs))
5353
i := 0
54-
for _, input := range m.Input {
54+
for _, input := range m.Inputs {
5555
types[i] = input.Type.String()
5656
i++
5757
}
@@ -104,7 +104,7 @@ func (abi ABI) pack(name string, args ...interface{}) ([]byte, error) {
104104

105105
var ret []byte
106106
for i, a := range args {
107-
input := method.Input[i]
107+
input := method.Inputs[i]
108108

109109
packed, err := input.Type.pack(a)
110110
if err != nil {
@@ -129,8 +129,8 @@ func (abi ABI) Pack(name string, args ...interface{}) ([]byte, error) {
129129
}
130130

131131
// start with argument count match
132-
if len(args) != len(method.Input) {
133-
return nil, fmt.Errorf("argument count mismatch: %d for %d", len(args), len(method.Input))
132+
if len(args) != len(method.Inputs) {
133+
return nil, fmt.Errorf("argument count mismatch: %d for %d", len(args), len(method.Inputs))
134134
}
135135

136136
arguments, err := abi.pack(name, args...)

accounts/abi/abi_test.go

Lines changed: 62 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,35 +18,38 @@ package abi
1818

1919
import (
2020
"bytes"
21+
"fmt"
22+
"log"
2123
"math/big"
2224
"reflect"
2325
"strings"
2426
"testing"
2527

28+
"github.com/ethereum/go-ethereum/common"
2629
"github.com/ethereum/go-ethereum/crypto"
2730
)
2831

2932
const jsondata = `
3033
[
3134
{ "name" : "balance", "const" : true },
32-
{ "name" : "send", "const" : false, "input" : [ { "name" : "amount", "type" : "uint256" } ] }
35+
{ "name" : "send", "const" : false, "inputs" : [ { "name" : "amount", "type" : "uint256" } ] }
3336
]`
3437

3538
const jsondata2 = `
3639
[
3740
{ "name" : "balance", "const" : true },
38-
{ "name" : "send", "const" : false, "input" : [ { "name" : "amount", "type" : "uint256" } ] },
39-
{ "name" : "test", "const" : false, "input" : [ { "name" : "number", "type" : "uint32" } ] },
40-
{ "name" : "string", "const" : false, "input" : [ { "name" : "input", "type" : "string" } ] },
41-
{ "name" : "bool", "const" : false, "input" : [ { "name" : "input", "type" : "bool" } ] },
42-
{ "name" : "address", "const" : false, "input" : [ { "name" : "input", "type" : "address" } ] },
43-
{ "name" : "string32", "const" : false, "input" : [ { "name" : "input", "type" : "string32" } ] },
44-
{ "name" : "uint64[2]", "const" : false, "input" : [ { "name" : "input", "type" : "uint64[2]" } ] },
45-
{ "name" : "uint64[]", "const" : false, "input" : [ { "name" : "input", "type" : "uint64[]" } ] },
46-
{ "name" : "foo", "const" : false, "input" : [ { "name" : "input", "type" : "uint32" } ] },
47-
{ "name" : "bar", "const" : false, "input" : [ { "name" : "input", "type" : "uint32" }, { "name" : "string", "type" : "uint16" } ] },
48-
{ "name" : "slice", "const" : false, "input" : [ { "name" : "input", "type" : "uint32[2]" } ] },
49-
{ "name" : "slice256", "const" : false, "input" : [ { "name" : "input", "type" : "uint256[2]" } ] }
41+
{ "name" : "send", "const" : false, "inputs" : [ { "name" : "amount", "type" : "uint256" } ] },
42+
{ "name" : "test", "const" : false, "inputs" : [ { "name" : "number", "type" : "uint32" } ] },
43+
{ "name" : "string", "const" : false, "inputs" : [ { "name" : "inputs", "type" : "string" } ] },
44+
{ "name" : "bool", "const" : false, "inputs" : [ { "name" : "inputs", "type" : "bool" } ] },
45+
{ "name" : "address", "const" : false, "inputs" : [ { "name" : "inputs", "type" : "address" } ] },
46+
{ "name" : "string32", "const" : false, "inputs" : [ { "name" : "inputs", "type" : "string32" } ] },
47+
{ "name" : "uint64[2]", "const" : false, "inputs" : [ { "name" : "inputs", "type" : "uint64[2]" } ] },
48+
{ "name" : "uint64[]", "const" : false, "inputs" : [ { "name" : "inputs", "type" : "uint64[]" } ] },
49+
{ "name" : "foo", "const" : false, "inputs" : [ { "name" : "inputs", "type" : "uint32" } ] },
50+
{ "name" : "bar", "const" : false, "inputs" : [ { "name" : "inputs", "type" : "uint32" }, { "name" : "string", "type" : "uint16" } ] },
51+
{ "name" : "slice", "const" : false, "inputs" : [ { "name" : "inputs", "type" : "uint32[2]" } ] },
52+
{ "name" : "slice256", "const" : false, "inputs" : [ { "name" : "inputs", "type" : "uint256[2]" } ] }
5053
]`
5154

5255
func TestType(t *testing.T) {
@@ -344,3 +347,49 @@ func TestPackSliceBig(t *testing.T) {
344347
t.Errorf("expected %x got %x", sig, packed)
345348
}
346349
}
350+
351+
func ExampleJSON() {
352+
const definition = `[{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"isBar","outputs":[{"name":"","type":"bool"}],"type":"function"}]`
353+
354+
abi, err := JSON(strings.NewReader(definition))
355+
if err != nil {
356+
log.Fatalln(err)
357+
}
358+
out, err := abi.Pack("isBar", common.HexToAddress("01"))
359+
if err != nil {
360+
log.Fatalln(err)
361+
}
362+
363+
fmt.Printf("%x\n", out)
364+
// Output:
365+
// 1f2c40920000000000000000000000000000000000000000000000000000000000000001
366+
}
367+
368+
func TestBytes(t *testing.T) {
369+
const definition = `[
370+
{ "name" : "balance", "const" : true, "inputs" : [ { "name" : "address", "type" : "bytes20" } ] },
371+
{ "name" : "send", "const" : false, "inputs" : [ { "name" : "amount", "type" : "uint256" } ] }
372+
]`
373+
374+
abi, err := JSON(strings.NewReader(definition))
375+
if err != nil {
376+
t.Fatal(err)
377+
}
378+
ok := make([]byte, 20)
379+
_, err = abi.Pack("balance", ok)
380+
if err != nil {
381+
t.Error(err)
382+
}
383+
384+
toosmall := make([]byte, 19)
385+
_, err = abi.Pack("balance", toosmall)
386+
if err != nil {
387+
t.Error(err)
388+
}
389+
390+
toobig := make([]byte, 21)
391+
_, err = abi.Pack("balance", toobig)
392+
if err == nil {
393+
t.Error("expected error")
394+
}
395+
}

accounts/abi/type.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ type Type struct {
4343
stringKind string // holds the unparsed string for deriving signatures
4444
}
4545

46-
// New type returns a fully parsed Type given by the input string or an error if it can't be parsed.
46+
// NewType returns a fully parsed Type given by the input string or an error if it can't be parsed.
4747
//
4848
// Strings can be in the format of:
4949
//
@@ -130,6 +130,10 @@ func NewType(t string) (typ Type, err error) {
130130
if vsize > 0 {
131131
typ.Size = 32
132132
}
133+
case "bytes":
134+
typ.Kind = reflect.Slice
135+
typ.Type = byte_ts
136+
typ.Size = vsize
133137
default:
134138
return Type{}, fmt.Errorf("unsupported arg type: %s", t)
135139
}
@@ -200,7 +204,13 @@ func (t Type) pack(v interface{}) ([]byte, error) {
200204
} else {
201205
return common.LeftPadBytes(common.Big0.Bytes(), 32), nil
202206
}
207+
case reflect.Array:
208+
if v, ok := value.Interface().(common.Address); ok {
209+
return t.pack(v[:])
210+
} else if v, ok := value.Interface().(common.Hash); ok {
211+
return t.pack(v[:])
212+
}
203213
}
204214

205-
panic("unreached")
215+
return nil, fmt.Errorf("ABI: bad input given %T", value.Kind())
206216
}

0 commit comments

Comments
 (0)