Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Upgrade] Go-Ethereum release v1.9.23 #1217

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
c995914
params: begin v1.9.23 release cycle
karalabe Sep 28, 2020
420b786
accounts/abi: ABI explicit difference between Unpack and UnpackIntoIn…
MariusVanDerWijden Sep 28, 2020
a90e645
mobile: added constructor for big int (#21597)
MariusVanDerWijden Sep 28, 2020
0ddd461
core/vm, params: make 2200 in line with spec (#21605)
holiman Sep 28, 2020
eebfb13
core: free pointer from slice after popping element from price heap (…
aaronbuchwald Sep 28, 2020
a04294d
internal/web3ext: improve eth_getBlockByNumber and eth_getBlockByHash…
mrFranklin Sep 28, 2020
b007df8
light: fix wrong description in a comment (#21573)
azuchi Sep 28, 2020
6660929
p2p/enode: remove unused code (#21612)
mrFranklin Sep 28, 2020
901471f
build: keep geth-sources.jar build result for JavaDoc (#21596)
MariusVanDerWijden Sep 28, 2020
4ee11b0
cmd/bootnode,internal/debug: fix some comments (#21623)
mrFranklin Sep 29, 2020
6c8310e
trie: use stacktrie for Derivesha operation (#21407)
gballet Sep 29, 2020
dad2658
accounts, signer: implement gnosis safe support (#21593)
holiman Sep 29, 2020
053ed9c
trie: polishes to trie committer (#21351)
rjl493456442 Sep 30, 2020
9d1e202
trie: add Commit-sequence tests for stacktrie commit (#21643)
holiman Sep 30, 2020
a15d71a
core/state/snapshot: stop generator if it hits missing trie nodes (#2…
karalabe Oct 5, 2020
d9890a6
cmd/faucet: enable DNS discovery for known networks (#21636)
fjl Oct 5, 2020
2b2fd74
params: update goerli testnet bootnodes (#21659)
q9f Oct 6, 2020
eb87121
core/bloombits: faster generator (#21625)
holiman Oct 6, 2020
e43d827
core/types: optimize bloom filters (#21624)
holiman Oct 6, 2020
716864d
cmd/devp2p/internal/ethtest: improve eth test suite (#21615)
renaynay Oct 7, 2020
015e789
node: relax websocket connection header check (#21646)
fjl Oct 7, 2020
6d29e19
signer/core: don't mismatch reject and no accounts (#21677)
holiman Oct 8, 2020
5e86e4e
p2p/discover: remove use of shared hash instance for key derivation (…
fjl Oct 8, 2020
43cd31e
core/vm: dedup config check in markdown logger (#21655)
gballet Oct 8, 2020
905ed10
eth/downloader: fix data race around the ancientlimit (#21681)
rjl493456442 Oct 9, 2020
19a1c95
eth/downloader: cache parent hash instead of recomputing (#21678)
MariusVanDerWijden Oct 9, 2020
706f5e3
core: fix txpool off-by-one error (#21683)
holiman Oct 9, 2020
86dd005
trie: polish commit function (#21692)
rjl493456442 Oct 12, 2020
66c3eb2
accouts, consensus, core: fix some comments (#21617)
mrFranklin Oct 12, 2020
32341f8
console: fix admin.sleepBlocks (#21629)
de1acr0ix Oct 13, 2020
c37e68e
all: replace RWMutex with Mutex in places where RLock is not used (#2…
mrFranklin Oct 13, 2020
94d1f58
consensus/clique: unexport calcDifficulty and improve comment (#21619)
mrFranklin Oct 13, 2020
348c3bc
trie: fix flaw in stacktrie pool reuse (#21699)
holiman Oct 13, 2020
5c6155f
internal/web3ext: improve some web3 apis (#21639)
mrFranklin Oct 13, 2020
7a5a822
eth, p2p: use truncated names (#21698)
holiman Oct 13, 2020
2a9ea6b
cmd/geth, cmd/utils: fixed flags name (#21700)
Neurone Oct 13, 2020
1e10489
miner: don't interrupt mining after successful sync (#21701)
holiman Oct 13, 2020
1fed223
accounts/keystore: fix flaky test (#21703)
MariusVanDerWijden Oct 13, 2020
bdc7554
params: update CHTs (#21706)
rjl493456442 Oct 14, 2020
4eb01b2
miner: set etherbase even if mining isn't possible at the moment (#21…
holiman Oct 14, 2020
524aaf5
p2p/discover: implement v5.1 wire protocol (#21647)
fjl Oct 14, 2020
8c2f271
params: go-ethereum v1.9.23 stable
fjl Oct 15, 2020
f81409a
Merge master branch into upgrade/go-ethereum/v1.9.23-2021618113714
baptiste-b-pegasys Jun 18, 2021
5d9d65d
fix: adapt to #21091
baptiste-b-pegasys Jun 21, 2021
d1d0c78
fix: revert contract generation
baptiste-b-pegasys Jun 21, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ android:
$(GORUN) build/ci.go aar --local
@echo "Done building."
@echo "Import \"$(GOBIN)/geth.aar\" to use the library."

@echo "Import \"$(GOBIN)/geth-sources.jar\" to add javadocs"
@echo "For more info see https://stackoverflow.com/questions/20994336/android-studio-how-to-attach-javadoc"

ios:
$(GORUN) build/ci.go xcode --local
@echo "Done building."
Expand Down
60 changes: 40 additions & 20 deletions accounts/abi/abi.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,36 +80,56 @@ func (abi ABI) Pack(name string, args ...interface{}) ([]byte, error) {
return append(method.ID, arguments...), nil
}

// Unpack output in v according to the abi specification.
func (abi ABI) Unpack(v interface{}, name string, data []byte) (err error) {
func (abi ABI) getArguments(name string, data []byte) (Arguments, error) {
// since there can't be naming collisions with contracts and events,
// we need to decide whether we're calling a method or an event
var args Arguments
if method, ok := abi.Methods[name]; ok {
if len(data)%32 != 0 {
return fmt.Errorf("abi: improperly formatted output: %s - Bytes: [%+v]", string(data), data)
return nil, fmt.Errorf("abi: improperly formatted output: %s - Bytes: [%+v]", string(data), data)
}
return method.Outputs.Unpack(v, data)
args = method.Outputs
}
if event, ok := abi.Events[name]; ok {
return event.Inputs.Unpack(v, data)
args = event.Inputs
}
return fmt.Errorf("abi: could not locate named method or event")
if args == nil {
return nil, errors.New("abi: could not locate named method or event")
}
return args, nil
}

// Unpack unpacks the output according to the abi specification.
func (abi ABI) Unpack(name string, data []byte) ([]interface{}, error) {
args, err := abi.getArguments(name, data)
if err != nil {
return nil, err
}
return args.Unpack(data)
}

// UnpackIntoInterface unpacks the output in v according to the abi specification.
// It performs an additional copy. Please only use, if you want to unpack into a
// structure that does not strictly conform to the abi structure (e.g. has additional arguments)
func (abi ABI) UnpackIntoInterface(v interface{}, name string, data []byte) error {
args, err := abi.getArguments(name, data)
if err != nil {
return err
}
unpacked, err := args.Unpack(data)
if err != nil {
return err
}
return args.Copy(v, unpacked)
}

// UnpackIntoMap unpacks a log into the provided map[string]interface{}.
func (abi ABI) UnpackIntoMap(v map[string]interface{}, name string, data []byte) (err error) {
// since there can't be naming collisions with contracts and events,
// we need to decide whether we're calling a method or an event
if method, ok := abi.Methods[name]; ok {
if len(data)%32 != 0 {
return fmt.Errorf("abi: improperly formatted output")
}
return method.Outputs.UnpackIntoMap(v, data)
}
if event, ok := abi.Events[name]; ok {
return event.Inputs.UnpackIntoMap(v, data)
args, err := abi.getArguments(name, data)
if err != nil {
return err
}
return fmt.Errorf("abi: could not locate named method or event")
return args.UnpackIntoMap(v, data)
}

// UnmarshalJSON implements json.Unmarshaler interface.
Expand Down Expand Up @@ -250,10 +270,10 @@ func UnpackRevert(data []byte) (string, error) {
if !bytes.Equal(data[:4], revertSelector) {
return "", errors.New("invalid data for unpacking")
}
var reason string
typ, _ := NewType("string", "", nil)
if err := (Arguments{{Type: typ}}).Unpack(&reason, data[4:]); err != nil {
unpacked, err := (Arguments{{Type: typ}}).Unpack(data[4:])
if err != nil {
return "", err
}
return reason, nil
return unpacked[0].(string), nil
}
17 changes: 7 additions & 10 deletions accounts/abi/abi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,18 +181,15 @@ func TestConstructor(t *testing.T) {
if err != nil {
t.Error(err)
}
v := struct {
A *big.Int
B *big.Int
}{new(big.Int), new(big.Int)}
//abi.Unpack(&v, "", packed)
if err := abi.Constructor.Inputs.Unpack(&v, packed); err != nil {
unpacked, err := abi.Constructor.Inputs.Unpack(packed)
if err != nil {
t.Error(err)
}
if !reflect.DeepEqual(v.A, big.NewInt(1)) {

if !reflect.DeepEqual(unpacked[0], big.NewInt(1)) {
t.Error("Unable to pack/unpack from constructor")
}
if !reflect.DeepEqual(v.B, big.NewInt(2)) {
if !reflect.DeepEqual(unpacked[1], big.NewInt(2)) {
t.Error("Unable to pack/unpack from constructor")
}
}
Expand Down Expand Up @@ -743,7 +740,7 @@ func TestUnpackEvent(t *testing.T) {
}
var ev ReceivedEvent

err = abi.Unpack(&ev, "received", data)
err = abi.UnpackIntoInterface(&ev, "received", data)
if err != nil {
t.Error(err)
}
Expand All @@ -752,7 +749,7 @@ func TestUnpackEvent(t *testing.T) {
Sender common.Address
}
var receivedAddrEv ReceivedAddrEvent
err = abi.Unpack(&receivedAddrEv, "receivedAddr", data)
err = abi.UnpackIntoInterface(&receivedAddrEv, "receivedAddr", data)
if err != nil {
t.Error(err)
}
Expand Down
54 changes: 32 additions & 22 deletions accounts/abi/argument.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,28 +76,20 @@ func (arguments Arguments) isTuple() bool {
}

// Unpack performs the operation hexdata -> Go format.
func (arguments Arguments) Unpack(v interface{}, data []byte) error {
func (arguments Arguments) Unpack(data []byte) ([]interface{}, error) {
if len(data) == 0 {
if len(arguments) != 0 {
return fmt.Errorf("abi: attempting to unmarshall an empty string while arguments are expected")
return nil, fmt.Errorf("abi: attempting to unmarshall an empty string while arguments are expected")
}
return nil // Nothing to unmarshal, return
}
// make sure the passed value is arguments pointer
if reflect.Ptr != reflect.ValueOf(v).Kind() {
return fmt.Errorf("abi: Unpack(non-pointer %T)", v)
}
marshalledValues, err := arguments.UnpackValues(data)
if err != nil {
return err
}
if len(marshalledValues) == 0 {
return fmt.Errorf("abi: Unpack(no-values unmarshalled %T)", v)
}
if arguments.isTuple() {
return arguments.unpackTuple(v, marshalledValues)
// Nothing to unmarshal, return default variables
nonIndexedArgs := arguments.NonIndexed()
defaultVars := make([]interface{}, len(nonIndexedArgs))
for index, arg := range nonIndexedArgs {
defaultVars[index] = reflect.New(arg.Type.GetType())
}
return defaultVars, nil
}
return arguments.unpackAtomic(v, marshalledValues[0])
return arguments.UnpackValues(data)
}

// UnpackIntoMap performs the operation hexdata -> mapping of argument name to argument value.
Expand All @@ -122,8 +114,26 @@ func (arguments Arguments) UnpackIntoMap(v map[string]interface{}, data []byte)
return nil
}

// unpackAtomic unpacks ( hexdata -> go ) a single value.
func (arguments Arguments) unpackAtomic(v interface{}, marshalledValues interface{}) error {
// Copy performs the operation go format -> provided struct.
func (arguments Arguments) Copy(v interface{}, values []interface{}) error {
// make sure the passed value is arguments pointer
if reflect.Ptr != reflect.ValueOf(v).Kind() {
return fmt.Errorf("abi: Unpack(non-pointer %T)", v)
}
if len(values) == 0 {
if len(arguments) != 0 {
return fmt.Errorf("abi: attempting to copy no values while %d arguments are expected", len(arguments))
}
return nil // Nothing to copy, return
}
if arguments.isTuple() {
return arguments.copyTuple(v, values)
}
return arguments.copyAtomic(v, values[0])
}

// unpackAtomic unpacks ( hexdata -> go ) a single value
func (arguments Arguments) copyAtomic(v interface{}, marshalledValues interface{}) error {
dst := reflect.ValueOf(v).Elem()
src := reflect.ValueOf(marshalledValues)

Expand All @@ -133,8 +143,8 @@ func (arguments Arguments) unpackAtomic(v interface{}, marshalledValues interfac
return set(dst, src)
}

// unpackTuple unpacks ( hexdata -> go ) a batch of values.
func (arguments Arguments) unpackTuple(v interface{}, marshalledValues []interface{}) error {
// copyTuple copies a batch of values from marshalledValues to v.
func (arguments Arguments) copyTuple(v interface{}, marshalledValues []interface{}) error {
value := reflect.ValueOf(v).Elem()
nonIndexedArgs := arguments.NonIndexed()

Expand Down
15 changes: 11 additions & 4 deletions accounts/abi/bind/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,14 @@ func DeployContract(opts *TransactOpts, abi abi.ABI, bytecode []byte, backend Co
// sets the output to result. The result type might be a single field for simple
// returns, a slice of interfaces for anonymous returns and a struct for named
// returns.
func (c *BoundContract) Call(opts *CallOpts, result interface{}, method string, params ...interface{}) error {
func (c *BoundContract) Call(opts *CallOpts, results *[]interface{}, method string, params ...interface{}) error {
// Don't crash on a lazy user
if opts == nil {
opts = new(CallOpts)
}
if results == nil {
results = new([]interface{})
}
// Pack the input, call and unpack the results
input, err := c.abi.Pack(method, params...)
if err != nil {
Expand Down Expand Up @@ -169,10 +172,14 @@ func (c *BoundContract) Call(opts *CallOpts, result interface{}, method string,
}
}
}
if err != nil {

if len(*results) == 0 {
res, err := c.abi.Unpack(method, output)
*results = res
return err
}
return c.abi.Unpack(result, method, output)
res := *results
return c.abi.UnpackIntoInterface(res[0], method, output)
}

// Transact invokes the (paid) contract method with params as input values.
Expand Down Expand Up @@ -372,7 +379,7 @@ func (c *BoundContract) WatchLogs(opts *WatchOpts, name string, query ...[]inter
// UnpackLog unpacks a retrieved log into the provided output structure.
func (c *BoundContract) UnpackLog(out interface{}, event string, log types.Log) error {
if len(log.Data) > 0 {
if err := c.abi.Unpack(out, event, log.Data); err != nil {
if err := c.abi.UnpackIntoInterface(out, event, log.Data); err != nil {
return err
}
}
Expand Down
7 changes: 3 additions & 4 deletions accounts/abi/bind/base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,10 @@ func TestPassingBlockNumber(t *testing.T) {
},
},
}, mc, nil, nil)
var ret string

blockNumber := big.NewInt(42)

bc.Call(&bind.CallOpts{BlockNumber: blockNumber}, &ret, "something")
bc.Call(&bind.CallOpts{BlockNumber: blockNumber}, nil, "something")

if mc.callContractBlockNumber != blockNumber {
t.Fatalf("CallContract() was not passed the block number")
Expand All @@ -85,7 +84,7 @@ func TestPassingBlockNumber(t *testing.T) {
t.Fatalf("CodeAt() was not passed the block number")
}

bc.Call(&bind.CallOpts{}, &ret, "something")
bc.Call(&bind.CallOpts{}, nil, "something")

if mc.callContractBlockNumber != nil {
t.Fatalf("CallContract() was passed a block number when it should not have been")
Expand All @@ -95,7 +94,7 @@ func TestPassingBlockNumber(t *testing.T) {
t.Fatalf("CodeAt() was passed a block number when it should not have been")
}

bc.Call(&bind.CallOpts{BlockNumber: blockNumber, Pending: true}, &ret, "something")
bc.Call(&bind.CallOpts{BlockNumber: blockNumber, Pending: true}, nil, "something")

if !mc.pendingCallContractCalled {
t.Fatalf("CallContract() was not passed the block number")
Expand Down
4 changes: 2 additions & 2 deletions accounts/abi/bind/bind_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1696,11 +1696,11 @@ func TestGolangBindings(t *testing.T) {
t.Skip("go sdk not found for testing")
}
// Create a temporary workspace for the test suite
ws, err := ioutil.TempDir("", "")
ws, err := ioutil.TempDir("", "binding-test")
if err != nil {
t.Fatalf("failed to create temporary workspace: %v", err)
}
defer os.RemoveAll(ws)
//defer os.RemoveAll(ws)

pkg := filepath.Join(ws, "bindtest")
if err = os.MkdirAll(pkg, 0700); err != nil {
Expand Down
34 changes: 19 additions & 15 deletions accounts/abi/bind/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ var (
// sets the output to result. The result type might be a single field for simple
// returns, a slice of interfaces for anonymous returns and a struct for named
// returns.
func (_{{$contract.Type}} *{{$contract.Type}}Raw) Call(opts *bind.CallOpts, result interface{}, method string, params ...interface{}) error {
func (_{{$contract.Type}} *{{$contract.Type}}Raw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error {
return _{{$contract.Type}}.Contract.{{$contract.Type}}Caller.contract.Call(opts, result, method, params...)
}

Expand All @@ -282,7 +282,7 @@ var (
// sets the output to result. The result type might be a single field for simple
// returns, a slice of interfaces for anonymous returns and a struct for named
// returns.
func (_{{$contract.Type}} *{{$contract.Type}}CallerRaw) Call(opts *bind.CallOpts, result interface{}, method string, params ...interface{}) error {
func (_{{$contract.Type}} *{{$contract.Type}}CallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error {
return _{{$contract.Type}}.Contract.contract.Call(opts, result, method, params...)
}

Expand All @@ -302,19 +302,23 @@ var (
//
// Solidity: {{.Original.String}}
func (_{{$contract.Type}} *{{$contract.Type}}Caller) {{.Normalized.Name}}(opts *bind.CallOpts {{range .Normalized.Inputs}}, {{.Name}} {{bindtype .Type $structs}} {{end}}) ({{if .Structured}}struct{ {{range .Normalized.Outputs}}{{.Name}} {{bindtype .Type $structs}};{{end}} },{{else}}{{range .Normalized.Outputs}}{{bindtype .Type $structs}},{{end}}{{end}} error) {
{{if .Structured}}ret := new(struct{
{{range .Normalized.Outputs}}{{.Name}} {{bindtype .Type $structs}}
{{end}}
}){{else}}var (
{{range $i, $_ := .Normalized.Outputs}}ret{{$i}} = new({{bindtype .Type $structs}})
{{end}}
){{end}}
out := {{if .Structured}}ret{{else}}{{if eq (len .Normalized.Outputs) 1}}ret0{{else}}&[]interface{}{
{{range $i, $_ := .Normalized.Outputs}}ret{{$i}},
{{end}}
}{{end}}{{end}}
err := _{{$contract.Type}}.contract.Call(opts, out, "{{.Original.Name}}" {{range .Normalized.Inputs}}, {{.Name}}{{end}})
return {{if .Structured}}*ret,{{else}}{{range $i, $_ := .Normalized.Outputs}}*ret{{$i}},{{end}}{{end}} err
var out []interface{}
err := _{{$contract.Type}}.contract.Call(opts, &out, "{{.Original.Name}}" {{range .Normalized.Inputs}}, {{.Name}}{{end}})
{{if .Structured}}
outstruct := new(struct{ {{range .Normalized.Outputs}} {{.Name}} {{bindtype .Type $structs}}; {{end}} })
{{range $i, $t := .Normalized.Outputs}}
outstruct.{{.Name}} = out[{{$i}}].({{bindtype .Type $structs}}){{end}}

return *outstruct, err
{{else}}
if err != nil {
return {{range $i, $_ := .Normalized.Outputs}}*new({{bindtype .Type $structs}}), {{end}} err
}
{{range $i, $t := .Normalized.Outputs}}
out{{$i}} := *abi.ConvertType(out[{{$i}}], new({{bindtype .Type $structs}})).(*{{bindtype .Type $structs}}){{end}}

return {{range $i, $t := .Normalized.Outputs}}out{{$i}}, {{end}} err
{{end}}
}

// {{.Normalized.Name}} is a free data retrieval call binding the contract method 0x{{printf "%x" .Original.ID}}.
Expand Down
Loading