Skip to content

Commit 4e13a09

Browse files
authored
Merge pull request #19370 from karalabe/geth-1.8.24
Backport PR for the v1.8.24 maintenance release
2 parents c942700 + 009d2fe commit 4e13a09

Some content is hidden

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

43 files changed

+536
-172
lines changed

.travis.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ sudo: false
44
matrix:
55
include:
66
- os: linux
7-
dist: trusty
7+
dist: xenial
88
sudo: required
99
go: 1.10.x
1010
script:
@@ -16,7 +16,7 @@ matrix:
1616

1717
# These are the latest Go versions.
1818
- os: linux
19-
dist: trusty
19+
dist: xenial
2020
sudo: required
2121
go: 1.11.x
2222
script:
@@ -43,7 +43,7 @@ matrix:
4343

4444
# This builder only tests code linters on latest version of Go
4545
- os: linux
46-
dist: trusty
46+
dist: xenial
4747
go: 1.11.x
4848
env:
4949
- lint
@@ -55,7 +55,7 @@ matrix:
5555
# This builder does the Ubuntu PPA upload
5656
- if: type = push
5757
os: linux
58-
dist: trusty
58+
dist: xenial
5959
go: 1.11.x
6060
env:
6161
- ubuntu-ppa
@@ -77,7 +77,7 @@ matrix:
7777
# This builder does the Linux Azure uploads
7878
- if: type = push
7979
os: linux
80-
dist: trusty
80+
dist: xenial
8181
sudo: required
8282
go: 1.11.x
8383
env:
@@ -111,7 +111,7 @@ matrix:
111111
# This builder does the Linux Azure MIPS xgo uploads
112112
- if: type = push
113113
os: linux
114-
dist: trusty
114+
dist: xenial
115115
services:
116116
- docker
117117
go: 1.11.x
@@ -139,7 +139,7 @@ matrix:
139139
# This builder does the Android Maven and Azure uploads
140140
- if: type = push
141141
os: linux
142-
dist: trusty
142+
dist: xenial
143143
addons:
144144
apt:
145145
packages:
@@ -206,7 +206,7 @@ matrix:
206206
# This builder does the Azure archive purges to avoid accumulating junk
207207
- if: type = cron
208208
os: linux
209-
dist: trusty
209+
dist: xenial
210210
go: 1.11.x
211211
env:
212212
- azure-purge

cmd/clef/main.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,13 @@ const ExternalAPIVersion = "4.0.0"
5656
const InternalAPIVersion = "3.0.0"
5757

5858
const legalWarning = `
59-
WARNING!
59+
WARNING!
6060
6161
Clef is alpha software, and not yet publically released. This software has _not_ been audited, and there
6262
are no guarantees about the workings of this software. It may contain severe flaws. You should not use this software
63-
unless you agree to take full responsibility for doing so, and know what you are doing.
63+
unless you agree to take full responsibility for doing so, and know what you are doing.
6464
65-
TLDR; THIS IS NOT PRODUCTION-READY SOFTWARE!
65+
TLDR; THIS IS NOT PRODUCTION-READY SOFTWARE!
6666
6767
`
6868

@@ -136,7 +136,7 @@ var (
136136
configdirFlag,
137137
},
138138
Description: `
139-
The init command generates a master seed which Clef can use to store credentials and data needed for
139+
The init command generates a master seed which Clef can use to store credentials and data needed for
140140
the rule-engine to work.`,
141141
}
142142
attestCommand = cli.Command{
@@ -150,10 +150,10 @@ the rule-engine to work.`,
150150
signerSecretFlag,
151151
},
152152
Description: `
153-
The attest command stores the sha256 of the rule.js-file that you want to use for automatic processing of
154-
incoming requests.
153+
The attest command stores the sha256 of the rule.js-file that you want to use for automatic processing of
154+
incoming requests.
155155
156-
Whenever you make an edit to the rule file, you need to use attestation to tell
156+
Whenever you make an edit to the rule file, you need to use attestation to tell
157157
Clef that the file is 'safe' to execute.`,
158158
}
159159

@@ -168,7 +168,7 @@ Clef that the file is 'safe' to execute.`,
168168
signerSecretFlag,
169169
},
170170
Description: `
171-
The setpw command stores a password for a given address (keyfile). If you enter a blank passphrase, it will
171+
The setpw command stores a password for a given address (keyfile). If you enter a blank passphrase, it will
172172
remove any stored credential for that address (keyfile)
173173
`,
174174
}
@@ -258,12 +258,12 @@ func initializeSecrets(c *cli.Context) error {
258258
}
259259
fmt.Printf("A master seed has been generated into %s\n", location)
260260
fmt.Printf(`
261-
This is required to be able to store credentials, such as :
261+
This is required to be able to store credentials, such as :
262262
* Passwords for keystores (used by rule engine)
263263
* Storage for javascript rules
264264
* Hash of rule-file
265265
266-
You should treat that file with utmost secrecy, and make a backup of it.
266+
You should treat that file with utmost secrecy, and make a backup of it.
267267
NOTE: This file does not contain your accounts. Those need to be backed up separately!
268268
269269
`)

cmd/faucet/faucet.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ func (f *faucet) loop() {
579579
go func() {
580580
for head := range update {
581581
// New chain head arrived, query the current stats and stream to clients
582-
timestamp := time.Unix(head.Time.Int64(), 0)
582+
timestamp := time.Unix(int64(head.Time), 0)
583583
if time.Since(timestamp) > time.Hour {
584584
log.Warn("Skipping faucet refresh, head too old", "number", head.Number, "hash", head.Hash(), "age", common.PrettyAge(timestamp))
585585
continue

cmd/geth/main.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,6 @@ var (
125125
utils.VMEnableDebugFlag,
126126
utils.NetworkIdFlag,
127127
utils.ConstantinopleOverrideFlag,
128-
utils.RPCCORSDomainFlag,
129-
utils.RPCVirtualHostsFlag,
130128
utils.EthStatsURLFlag,
131129
utils.MetricsEnabledFlag,
132130
utils.FakePoWFlag,
@@ -150,6 +148,7 @@ var (
150148
utils.WSAllowedOriginsFlag,
151149
utils.IPCDisabledFlag,
152150
utils.IPCPathFlag,
151+
utils.RPCGlobalGasCap,
153152
}
154153

155154
whisperFlags = []cli.Flag{

cmd/geth/usage.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ var AppHelpFlagGroups = []flagGroup{
153153
utils.RPCListenAddrFlag,
154154
utils.RPCPortFlag,
155155
utils.RPCApiFlag,
156+
utils.RPCGlobalGasCap,
156157
utils.WSEnabledFlag,
157158
utils.WSListenAddrFlag,
158159
utils.WSPortFlag,

cmd/utils/flags.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,10 @@ var (
411411
Name: "vmdebug",
412412
Usage: "Record information useful for VM and contract debugging",
413413
}
414+
RPCGlobalGasCap = cli.Uint64Flag{
415+
Name: "rpc.gascap",
416+
Usage: "Sets a cap on gas that can be used in eth_call/estimateGas",
417+
}
414418
// Logging and debug settings
415419
EthStatsURLFlag = cli.StringFlag{
416420
Name: "ethstats",
@@ -1256,6 +1260,9 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) {
12561260
if ctx.GlobalIsSet(EVMInterpreterFlag.Name) {
12571261
cfg.EVMInterpreter = ctx.GlobalString(EVMInterpreterFlag.Name)
12581262
}
1263+
if ctx.GlobalIsSet(RPCGlobalGasCap.Name) {
1264+
cfg.RPCGasCap = new(big.Int).SetUint64(ctx.GlobalUint64(RPCGlobalGasCap.Name))
1265+
}
12591266

12601267
// Override any default configs for hard coded networks.
12611268
switch {

common/fdlimit/fdlimit_darwin.go

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// Copyright 2019 The go-ethereum Authors
2+
// This file is part of the go-ethereum library.
3+
//
4+
// The go-ethereum library is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU Lesser General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// The go-ethereum library is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU Lesser General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU Lesser General Public License
15+
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
16+
17+
package fdlimit
18+
19+
import "syscall"
20+
21+
// hardlimit is the number of file descriptors allowed at max by the kernel.
22+
const hardlimit = 10240
23+
24+
// Raise tries to maximize the file descriptor allowance of this process
25+
// to the maximum hard-limit allowed by the OS.
26+
// Returns the size it was set to (may differ from the desired 'max')
27+
func Raise(max uint64) (uint64, error) {
28+
// Get the current limit
29+
var limit syscall.Rlimit
30+
if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &limit); err != nil {
31+
return 0, err
32+
}
33+
// Try to update the limit to the max allowance
34+
limit.Cur = limit.Max
35+
if limit.Cur > max {
36+
limit.Cur = max
37+
}
38+
if err := syscall.Setrlimit(syscall.RLIMIT_NOFILE, &limit); err != nil {
39+
return 0, err
40+
}
41+
// MacOS can silently apply further caps, so retrieve the actually set limit
42+
if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &limit); err != nil {
43+
return 0, err
44+
}
45+
return limit.Cur, nil
46+
}
47+
48+
// Current retrieves the number of file descriptors allowed to be opened by this
49+
// process.
50+
func Current() (int, error) {
51+
var limit syscall.Rlimit
52+
if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &limit); err != nil {
53+
return 0, err
54+
}
55+
return int(limit.Cur), nil
56+
}
57+
58+
// Maximum retrieves the maximum number of file descriptors this process is
59+
// allowed to request for itself.
60+
func Maximum() (int, error) {
61+
// Retrieve the maximum allowed by dynamic OS limits
62+
var limit syscall.Rlimit
63+
if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &limit); err != nil {
64+
return 0, err
65+
}
66+
// Cap it to OPEN_MAX (10240) because macos is a special snowflake
67+
if limit.Max > hardlimit {
68+
limit.Max = hardlimit
69+
}
70+
return int(limit.Max), nil
71+
}

common/fdlimit/fdlimit_unix.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// You should have received a copy of the GNU Lesser General Public License
1515
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
1616

17-
// +build linux darwin netbsd openbsd solaris
17+
// +build linux netbsd openbsd solaris
1818

1919
package fdlimit
2020

common/fdlimit/fdlimit_windows.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package fdlimit
1818

1919
import "fmt"
2020

21+
// hardlimit is the number of file descriptors allowed at max by the kernel.
2122
const hardlimit = 16384
2223

2324
// Raise tries to maximize the file descriptor allowance of this process

consensus/clique/clique.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ func (c *Clique) verifyHeader(chain consensus.ChainReader, header *types.Header,
279279
number := header.Number.Uint64()
280280

281281
// Don't waste time checking blocks from the future
282-
if header.Time.Cmp(big.NewInt(time.Now().Unix())) > 0 {
282+
if header.Time > uint64(time.Now().Unix()) {
283283
return consensus.ErrFutureBlock
284284
}
285285
// Checkpoint blocks need to enforce zero beneficiary
@@ -351,7 +351,7 @@ func (c *Clique) verifyCascadingFields(chain consensus.ChainReader, header *type
351351
if parent == nil || parent.Number.Uint64() != number-1 || parent.Hash() != header.ParentHash {
352352
return consensus.ErrUnknownAncestor
353353
}
354-
if parent.Time.Uint64()+c.config.Period > header.Time.Uint64() {
354+
if parent.Time+c.config.Period > header.Time {
355355
return ErrInvalidTimestamp
356356
}
357357
// Retrieve the snapshot needed to verify this header and cache it
@@ -570,9 +570,9 @@ func (c *Clique) Prepare(chain consensus.ChainReader, header *types.Header) erro
570570
if parent == nil {
571571
return consensus.ErrUnknownAncestor
572572
}
573-
header.Time = new(big.Int).Add(parent.Time, new(big.Int).SetUint64(c.config.Period))
574-
if header.Time.Int64() < time.Now().Unix() {
575-
header.Time = big.NewInt(time.Now().Unix())
573+
header.Time = parent.Time + c.config.Period
574+
if header.Time < uint64(time.Now().Unix()) {
575+
header.Time = uint64(time.Now().Unix())
576576
}
577577
return nil
578578
}
@@ -637,7 +637,7 @@ func (c *Clique) Seal(chain consensus.ChainReader, block *types.Block, results c
637637
}
638638
}
639639
// Sweet, the protocol permits us to sign the block, wait for our time
640-
delay := time.Unix(header.Time.Int64(), 0).Sub(time.Now()) // nolint: gosimple
640+
delay := time.Unix(int64(header.Time), 0).Sub(time.Now()) // nolint: gosimple
641641
if header.Difficulty.Cmp(diffNoTurn) == 0 {
642642
// It's not our turn explicitly to sign, delay it a bit
643643
wiggle := time.Duration(len(snap.Signers)/2+1) * wiggleTime

0 commit comments

Comments
 (0)