Skip to content

Commit d52a693

Browse files
committed
Merge branch 'develop' into release/1.4
Conflicts: cmd/geth/main.go
2 parents 8241fa5 + 258cc73 commit d52a693

Some content is hidden

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

42 files changed

+2481
-531
lines changed

README.md

Lines changed: 36 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ master | [![Build+Status](https://build.ethdev.com/buildstatusimage?builder=L
99

1010
[![API Reference](
1111
https://camo.githubusercontent.com/915b7be44ada53c290eb157634330494ebe3e30a/68747470733a2f2f676f646f632e6f72672f6769746875622e636f6d2f676f6c616e672f6764646f3f7374617475732e737667
12-
)](https://godoc.org/github.com/ethereum/go-ethereum)
12+
)](https://godoc.org/github.com/ethereum/go-ethereum)
1313
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/ethereum/go-ethereum?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
1414

1515
## Automated development builds
@@ -38,36 +38,47 @@ Once the dependencies are installed, run
3838

3939
## Executables
4040

41-
Go Ethereum comes with several wrappers/executables found in
42-
[the `cmd` directory](https://github.com/ethereum/go-ethereum/tree/develop/cmd):
41+
The go-ethereum project comes with several wrappers/executables found in the `cmd` directory.
4342

44-
Command | |
45-
----------|---------|
46-
`geth` | Ethereum CLI (ethereum command line interface client) |
47-
`bootnode` | runs a bootstrap node for the Discovery Protocol |
48-
`ethtest` | test tool which runs with the [tests](https://github.com/ethereum/tests) suite: `/path/to/test.json > ethtest --test BlockTests --stdin`.
49-
`evm` | is a generic Ethereum Virtual Machine: `evm -code 60ff60ff -gas 10000 -price 0 -dump`. See `-h` for a detailed description. |
50-
`disasm` | disassembles EVM code: `echo "6001" | disasm` |
51-
`rlpdump` | prints RLP structures |
43+
| Command | Description |
44+
|:----------:|-------------|
45+
| **`geth`** | Our main Ethereum CLI client. It is the entry point into the Ethereum network (main-, test- or private net), capable of running as a full node (default) archive node (retaining all historical state) or a light node (retrieving data live). It can be used by other processes as an gateway into the Ethereum network via JSON RPC endpoints exposed on top of HTTP, WebSocket and/or IPC transports. Please see our [Command Line Options](https://github.com/ethereum/go-ethereum/wiki/Command-Line-Options) wiki page for details. |
46+
| `abigen` | Source code generator to convert Ethereum contract definitions into easy to use, compile-time type-safe Go packages. It operates on plain [Ethereum contract ABIs](https://github.com/ethereum/wiki/wiki/Ethereum-Contract-ABI) with expanded functionality if the contract bytecode is also available. However it also accepts Solidity source files, making development much more streamlined. Please see our [Native DApps](https://github.com/ethereum/go-ethereum/wiki/Native-DApps:-Go-bindings-to-Ethereum-contracts) wiki page for details. |
47+
| `bootnode` | Stripped down version of our Ethereum client implementation that only takes part in the network node discovery protocol, but does not run any of the higher level application protocols. It can be used as a lightweight bootstrap node to aid in finding peers in private networks. |
48+
| `disasm` | Bytecode disassembler to convert EVM (Ethereum Virtual Machine) bytecode into more user friendly assembly-like opcodes (e.g. `echo "6001" | disasm`). For details on the individual opcodes, please see pages 22-30 of the [Ethereum Yellow Paper](http://gavwood.com/paper.pdf). |
49+
| `evm` | Developer utility version of the EVM (Ethereum Virtual Machine) that is capable of running bytecode snippets within a configurable environment and execution mode. Its purpose is to allow insolated, fine graned debugging of EVM opcodes (e.g. `evm --code 60ff60ff --debug`). |
50+
| `gethrpctest` | Developer utility tool to support our [ethereum/rpc-test](https://github.com/ethereum/rpc-tests) test suite which validates baseline conformity to the [Ethereum JSON RPC](https://github.com/ethereum/wiki/wiki/JSON-RPC) specs. Please see the [test suite's readme](https://github.com/ethereum/rpc-tests/blob/master/README.md) for details. |
51+
| `rlpdump` | Developer utility tool to convert binary RLP ([Recursive Length Prefix](https://github.com/ethereum/wiki/wiki/RLP)) dumps (data encoding used by the Ethereum protocol both network as well as consensus wise) to user friendlier hierarchical representation (e.g. `rlpdump --hex CE0183FFFFFFC4C304050583616263`). |
5252

53-
## Command line options
53+
## Contribution
5454

55-
`geth` can be configured via command line options, environment variables and config files.
55+
Thank you for considering to help out with the source code! We welcome contributions from
56+
anyone on the internet, and are grateful for even the smallest of fixes!
5657

57-
To get the options available:
58+
If you'd like to contribute to go-ethereum, please fork, fix, commit and send a pull request
59+
for the maintainers to review and merge into the main code base. If you wish to submit more
60+
complex changes though, please check up with the core devs first on [our gitter channel](https://gitter.im/ethereum/go-ethereum)
61+
to ensure those changes are in line with the general philosopy of the project and/or get some
62+
early feedback which can make both your efforts much lighter as well as our review and merge
63+
procedures quick and simple.
5864

59-
geth help
65+
Please make sure your contributions adhere to our coding guidlines:
6066

61-
For further details on options, see the [wiki](https://github.com/ethereum/go-ethereum/wiki/Command-Line-Options)
67+
* Code must adhere to the official Go [formatting](https://golang.org/doc/effective_go.html#formatting) guidelines (i.e. uses [gofmt](https://golang.org/cmd/gofmt/)).
68+
* Code must be documented adherign to the official Go [commentary](https://golang.org/doc/effective_go.html#commentary) guidelines.
69+
* Pull requests need to be based on and opened against the `develop` branch.
70+
* Commit messages should be prefixed with the package(s) they modify.
71+
* E.g. "eth, rpc: make trace configs optional"
6272

63-
## Contribution
73+
Please see the [Developers' Guide](https://github.com/ethereum/go-ethereum/wiki/Developers'-Guide)
74+
for more details on configuring your environment, managing project dependencies and testing procedures.
75+
76+
## License
6477

65-
If you'd like to contribute to go-ethereum please fork, fix, commit and
66-
send a pull request. Commits who do not comply with the coding standards
67-
are ignored (use gofmt!). If you send pull requests make absolute sure that you
68-
commit on the `develop` branch and that you do not merge to master.
69-
Commits that are directly based on master are simply ignored.
78+
The go-ethereum library (i.e. all code outside of the `cmd` directory) is licensed under the
79+
[GNU Lesser General Public License v3.0](http://www.gnu.org/licenses/lgpl-3.0.en.html), also
80+
included in our repository in the `COPYING.LESSER` file.
7081

71-
See [Developers' Guide](https://github.com/ethereum/go-ethereum/wiki/Developers'-Guide)
72-
for more details on configuring your environment, testing, and
73-
dependency management.
82+
The go-ethereum binaries (i.e. all code inside of the `cmd` directory) is licensed under the
83+
[GNU General Public License v3.0](http://www.gnu.org/licenses/gpl-3.0.en.html), also included
84+
in our repository in the `COPYING` file.

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.4.0
1+
1.4.1

accounts/abi/abi.go

Lines changed: 38 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -48,42 +48,6 @@ func JSON(reader io.Reader) (ABI, error) {
4848
return abi, nil
4949
}
5050

51-
// tests, tests whether the given input would result in a successful
52-
// call. Checks argument list count and matches input to `input`.
53-
func (abi ABI) pack(method Method, args ...interface{}) ([]byte, error) {
54-
// variable input is the output appended at the end of packed
55-
// output. This is used for strings and bytes types input.
56-
var variableInput []byte
57-
58-
var ret []byte
59-
for i, a := range args {
60-
input := method.Inputs[i]
61-
// pack the input
62-
packed, err := input.Type.pack(a)
63-
if err != nil {
64-
return nil, fmt.Errorf("`%s` %v", method.Name, err)
65-
}
66-
67-
// check for a slice type (string, bytes, slice)
68-
if input.Type.T == StringTy || input.Type.T == BytesTy || input.Type.IsSlice {
69-
// calculate the offset
70-
offset := len(method.Inputs)*32 + len(variableInput)
71-
// set the offset
72-
ret = append(ret, packNum(reflect.ValueOf(offset), UintTy)...)
73-
// Append the packed output to the variable input. The variable input
74-
// will be appended at the end of the input.
75-
variableInput = append(variableInput, packed...)
76-
} else {
77-
// append the packed value to the input
78-
ret = append(ret, packed...)
79-
}
80-
}
81-
// append the variable input at the end of the packed input
82-
ret = append(ret, variableInput...)
83-
84-
return ret, nil
85-
}
86-
8751
// Pack the given method name to conform the ABI. Method call's data
8852
// will consist of method_id, args0, arg1, ... argN. Method id consists
8953
// of 4 bytes and arguments are all 32 bytes.
@@ -102,11 +66,7 @@ func (abi ABI) Pack(name string, args ...interface{}) ([]byte, error) {
10266
}
10367
method = m
10468
}
105-
// Make sure arguments match up and pack them
106-
if len(args) != len(method.Inputs) {
107-
return nil, fmt.Errorf("argument count mismatch: %d for %d", len(args), len(method.Inputs))
108-
}
109-
arguments, err := abi.pack(method, args...)
69+
arguments, err := method.pack(method, args...)
11070
if err != nil {
11171
return nil, err
11272
}
@@ -126,18 +86,21 @@ func toGoSlice(i int, t Argument, output []byte) (interface{}, error) {
12686
if index+32 > len(output) {
12787
return nil, fmt.Errorf("abi: cannot marshal in to go slice: insufficient size output %d require %d", len(output), index+32)
12888
}
89+
elem := t.Type.Elem
12990

13091
// first we need to create a slice of the type
13192
var refSlice reflect.Value
132-
switch t.Type.T {
93+
switch elem.T {
13394
case IntTy, UintTy, BoolTy: // int, uint, bool can all be of type big int.
13495
refSlice = reflect.ValueOf([]*big.Int(nil))
13596
case AddressTy: // address must be of slice Address
13697
refSlice = reflect.ValueOf([]common.Address(nil))
13798
case HashTy: // hash must be of slice hash
13899
refSlice = reflect.ValueOf([]common.Hash(nil))
100+
case FixedBytesTy:
101+
refSlice = reflect.ValueOf([]byte(nil))
139102
default: // no other types are supported
140-
return nil, fmt.Errorf("abi: unsupported slice type %v", t.Type.T)
103+
return nil, fmt.Errorf("abi: unsupported slice type %v", elem.T)
141104
}
142105
// get the offset which determines the start of this array ...
143106
offset := int(common.BytesToBig(output[index : index+32]).Uint64())
@@ -164,7 +127,7 @@ func toGoSlice(i int, t Argument, output []byte) (interface{}, error) {
164127
)
165128

166129
// set inter to the correct type (cast)
167-
switch t.Type.T {
130+
switch elem.T {
168131
case IntTy, UintTy:
169132
inter = common.BytesToBig(returnOutput)
170133
case BoolTy:
@@ -186,7 +149,7 @@ func toGoSlice(i int, t Argument, output []byte) (interface{}, error) {
186149
// argument in T.
187150
func toGoType(i int, t Argument, output []byte) (interface{}, error) {
188151
// we need to treat slices differently
189-
if t.Type.IsSlice {
152+
if (t.Type.IsSlice || t.Type.IsArray) && t.Type.T != BytesTy && t.Type.T != StringTy && t.Type.T != FixedBytesTy {
190153
return toGoSlice(i, t, output)
191154
}
192155

@@ -217,12 +180,33 @@ func toGoType(i int, t Argument, output []byte) (interface{}, error) {
217180
returnOutput = output[index : index+32]
218181
}
219182

220-
// cast bytes to abi return type
183+
// convert the bytes to whatever is specified by the ABI.
221184
switch t.Type.T {
222-
case IntTy:
223-
return common.BytesToBig(returnOutput), nil
224-
case UintTy:
225-
return common.BytesToBig(returnOutput), nil
185+
case IntTy, UintTy:
186+
bigNum := common.BytesToBig(returnOutput)
187+
188+
// If the type is a integer convert to the integer type
189+
// specified by the ABI.
190+
switch t.Type.Kind {
191+
case reflect.Uint8:
192+
return uint8(bigNum.Uint64()), nil
193+
case reflect.Uint16:
194+
return uint16(bigNum.Uint64()), nil
195+
case reflect.Uint32:
196+
return uint32(bigNum.Uint64()), nil
197+
case reflect.Uint64:
198+
return uint64(bigNum.Uint64()), nil
199+
case reflect.Int8:
200+
return int8(bigNum.Int64()), nil
201+
case reflect.Int16:
202+
return int16(bigNum.Int64()), nil
203+
case reflect.Int32:
204+
return int32(bigNum.Int64()), nil
205+
case reflect.Int64:
206+
return int64(bigNum.Int64()), nil
207+
case reflect.Ptr:
208+
return bigNum, nil
209+
}
226210
case BoolTy:
227211
return common.BytesToBig(returnOutput).Uint64() > 0, nil
228212
case AddressTy:
@@ -328,10 +312,12 @@ func set(dst, src reflect.Value, output Argument) error {
328312
return fmt.Errorf("abi: cannot unmarshal %v in to array of elem %v", src.Type(), dstType.Elem())
329313
}
330314

331-
if dst.Len() < output.Type.Size {
332-
return fmt.Errorf("abi: cannot unmarshal src (len=%d) in to dst (len=%d)", output.Type.Size, dst.Len())
315+
if dst.Len() < output.Type.SliceSize {
316+
return fmt.Errorf("abi: cannot unmarshal src (len=%d) in to dst (len=%d)", output.Type.SliceSize, dst.Len())
333317
}
334318
reflect.Copy(dst, src)
319+
case dstType.Kind() == reflect.Interface:
320+
dst.Set(src)
335321
default:
336322
return fmt.Errorf("abi: cannot unmarshal %v in to %v", src.Type(), dst.Type())
337323
}

0 commit comments

Comments
 (0)