diff options
-rw-r--r-- | build/ci-notes.md | 12 | ||||
-rw-r--r-- | build/ci.go | 3 | ||||
-rw-r--r-- | build/deb.control | 4 | ||||
-rw-r--r-- | build/deb.rules | 2 | ||||
-rw-r--r-- | cmd/geth/main.go | 2 | ||||
-rw-r--r-- | cmd/geth/usage.go | 17 | ||||
-rw-r--r-- | common/compiler/solidity.go | 95 | ||||
-rw-r--r-- | common/compiler/solidity_test.go | 37 | ||||
-rw-r--r-- | consensus/ethash/ethash.go | 13 | ||||
-rw-r--r-- | eth/config.go | 1 |
10 files changed, 90 insertions, 96 deletions
diff --git a/build/ci-notes.md b/build/ci-notes.md index cd2ba8bb2..7574bfffa 100644 --- a/build/ci-notes.md +++ b/build/ci-notes.md @@ -5,9 +5,9 @@ for Ubuntu. Packages are built for the all Ubuntu versions which are supported b Canonical: - Trusty Tahr (14.04 LTS) -- Wily Werewolf (15.10) - Xenial Xerus (16.04 LTS) - Yakkety Yak (16.10) +- Zesty Zapus (17.04) Packages of develop branch commits have suffix -unstable and cannot be installed alongside the stable version. Switching between release streams requires user intervention. @@ -21,18 +21,18 @@ variable which Travis CI makes available to certain builds. We want to build go-ethereum with the most recent version of Go, irrespective of the Go version that is available in the main Ubuntu repository. In order to make this possible, our PPA depends on the ~gophers/ubuntu/archive PPA. Our source package build-depends on -golang-1.7, which is co-installable alongside the regular golang package. PPA dependencies +golang-1.8, which is co-installable alongside the regular golang package. PPA dependencies can be edited at https://launchpad.net/%7Eethereum/+archive/ubuntu/ethereum/+edit-dependencies ## Building Packages Locally (for testing) You need to run Ubuntu to do test packaging. -Add the gophers PPA and install Go 1.7 and Debian packaging tools: +Add the gophers PPA and install Go 1.8 and Debian packaging tools: $ sudo apt-add-repository ppa:gophers/ubuntu/archive $ sudo apt-get update - $ sudo apt-get install build-essential golang-1.7 devscripts debhelper + $ sudo apt-get install build-essential golang-1.8 devscripts debhelper Create the source packages: @@ -40,10 +40,10 @@ Create the source packages: Then go into the source package directory for your running distribution and build the package: - $ cd dist/ethereum-unstable-1.5.0+xenial + $ cd dist/ethereum-unstable-1.6.0+xenial $ dpkg-buildpackage Built packages are placed in the dist/ directory. $ cd .. - $ dpkg-deb -c geth-unstable_1.5.0+xenial_amd64.deb + $ dpkg-deb -c geth-unstable_1.6.0+xenial_amd64.deb diff --git a/build/ci.go b/build/ci.go index 5e63c2411..8b6ebe74c 100644 --- a/build/ci.go +++ b/build/ci.go @@ -292,7 +292,8 @@ func doTest(cmdline []string) { // Run analysis tools before the tests. build.MustRun(goTool("vet", packages...)) if *misspell { - spellcheck(packages) + // TODO(karalabe): Reenable after false detection is fixed: https://github.com/client9/misspell/issues/105 + // spellcheck(packages) } // Run the actual tests. gotest := goTool("test", buildFlags(env)...) diff --git a/build/deb.control b/build/deb.control index d39393d29..7394754ef 100644 --- a/build/deb.control +++ b/build/deb.control @@ -2,7 +2,7 @@ Source: {{.Name}} Section: science Priority: extra Maintainer: {{.Author}} -Build-Depends: debhelper (>= 8.0.0), golang-1.7 +Build-Depends: debhelper (>= 8.0.0), golang-1.8 Standards-Version: 3.9.5 Homepage: https://ethereum.org Vcs-Git: git://github.com/ethereum/go-ethereum.git @@ -13,7 +13,7 @@ Architecture: any Depends: ${misc:Depends}, {{.ExeList}} Description: Meta-package to install geth and other tools Meta-package to install geth and other tools - + {{range .Executables}} Package: {{$.ExeName .}} Conflicts: {{$.ExeConflicts .}} diff --git a/build/deb.rules b/build/deb.rules index 11efe15fc..b3fe5267f 100644 --- a/build/deb.rules +++ b/build/deb.rules @@ -5,7 +5,7 @@ #export DH_VERBOSE=1 override_dh_auto_build: - build/env.sh /usr/lib/go-1.7/bin/go run build/ci.go install -git-commit={{.Env.Commit}} -git-branch={{.Env.Branch}} -git-tag={{.Env.Tag}} -buildnum={{.Env.Buildnum}} -pull-request={{.Env.IsPullRequest}} + build/env.sh /usr/lib/go-1.8/bin/go run build/ci.go install -git-commit={{.Env.Commit}} -git-branch={{.Env.Branch}} -git-tag={{.Env.Tag}} -buildnum={{.Env.Buildnum}} -pull-request={{.Env.IsPullRequest}} override_dh_auto_test: diff --git a/cmd/geth/main.go b/cmd/geth/main.go index 5fb50c4ad..c2d719d95 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -55,7 +55,7 @@ func init() { // Initialize the CLI app and start Geth app.Action = geth app.HideVersion = true // we have a command to print the version - app.Copyright = "Copyright 2013-2016 The go-ethereum Authors" + app.Copyright = "Copyright 2013-2017 The go-ethereum Authors" app.Commands = []cli.Command{ // See chaincmd.go: initCommand, diff --git a/cmd/geth/usage.go b/cmd/geth/usage.go index a172b4775..457728154 100644 --- a/cmd/geth/usage.go +++ b/cmd/geth/usage.go @@ -30,7 +30,7 @@ import ( var AppHelpTemplate = `NAME: {{.App.Name}} - {{.App.Usage}} - Copyright 2013-2016 The go-ethereum Authors + Copyright 2013-2017 The go-ethereum Authors USAGE: {{.App.HelpName}} [options]{{if .App.Commands}} command [command options]{{end}} {{if .App.ArgsUsage}}{{.App.ArgsUsage}}{{else}}[arguments...]{{end}} @@ -64,14 +64,15 @@ var AppHelpFlagGroups = []flagGroup{ { Name: "ETHEREUM", Flags: []cli.Flag{ + configFileFlag, utils.DataDirFlag, utils.KeyStoreDirFlag, utils.NetworkIdFlag, utils.TestNetFlag, utils.DevModeFlag, + utils.SyncModeFlag, + utils.EthStatsURLFlag, utils.IdentityFlag, - utils.FastSyncFlag, - utils.LightModeFlag, utils.LightServFlag, utils.LightPeersFlag, utils.LightKDFFlag, @@ -132,6 +133,7 @@ var AppHelpFlagGroups = []flagGroup{ utils.NATFlag, utils.NoDiscoverFlag, utils.DiscoveryV5Flag, + utils.NetrestrictFlag, utils.NodeKeyFileFlag, utils.NodeKeyHexFlag, }, @@ -163,12 +165,19 @@ var AppHelpFlagGroups = []flagGroup{ { Name: "LOGGING AND DEBUGGING", Flags: append([]cli.Flag{ - utils.EthStatsURLFlag, utils.MetricsEnabledFlag, utils.FakePoWFlag, + utils.NoCompactionFlag, }, debug.Flags...), }, { + Name: "DEPRECATED", + Flags: []cli.Flag{ + utils.FastSyncFlag, + utils.LightModeFlag, + }, + }, + { Name: "EXPERIMENTAL", Flags: []cli.Flag{ utils.WhisperEnabledFlag, diff --git a/common/compiler/solidity.go b/common/compiler/solidity.go index d27bddd9f..abb803989 100644 --- a/common/compiler/solidity.go +++ b/common/compiler/solidity.go @@ -25,20 +25,11 @@ import ( "io/ioutil" "os/exec" "regexp" + "strconv" "strings" - - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/crypto" ) -var ( - versionRegexp = regexp.MustCompile(`[0-9]+\.[0-9]+\.[0-9]+`) - solcParams = []string{ - "--combined-json", "bin,abi,userdoc,devdoc", - "--add-std", // include standard lib contracts - "--optimize", // code optimizer switched on - } -) +var versionRegexp = regexp.MustCompile(`([0-9]+)\.([0-9]+)\.([0-9]+)`) type Contract struct { Code string `json:"code"` @@ -54,17 +45,33 @@ type ContractInfo struct { AbiDefinition interface{} `json:"abiDefinition"` UserDoc interface{} `json:"userDoc"` DeveloperDoc interface{} `json:"developerDoc"` + Metadata string `json:"metadata"` } // Solidity contains information about the solidity compiler. type Solidity struct { Path, Version, FullVersion string + Major, Minor, Patch int } // --combined-output format type solcOutput struct { - Contracts map[string]struct{ Bin, Abi, Devdoc, Userdoc string } - Version string + Contracts map[string]struct { + Bin, Abi, Devdoc, Userdoc, Metadata string + } + Version string +} + +func (s *Solidity) makeArgs() []string { + p := []string{ + "--combined-json", "bin,abi,userdoc,devdoc", + "--add-std", // include standard lib contracts + "--optimize", // code optimizer switched on + } + if s.Major > 0 || s.Minor > 4 || s.Patch > 6 { + p[1] += ",metadata" + } + return p } // SolidityVersion runs solc and parses its version output. @@ -75,13 +82,23 @@ func SolidityVersion(solc string) (*Solidity, error) { var out bytes.Buffer cmd := exec.Command(solc, "--version") cmd.Stdout = &out - if err := cmd.Run(); err != nil { + err := cmd.Run() + if err != nil { + return nil, err + } + matches := versionRegexp.FindStringSubmatch(out.String()) + if len(matches) != 4 { + return nil, fmt.Errorf("can't parse solc version %q", out.String()) + } + s := &Solidity{Path: cmd.Path, FullVersion: out.String(), Version: matches[0]} + if s.Major, err = strconv.Atoi(matches[1]); err != nil { return nil, err } - s := &Solidity{ - Path: cmd.Path, - FullVersion: out.String(), - Version: versionRegexp.FindString(out.String()), + if s.Minor, err = strconv.Atoi(matches[2]); err != nil { + return nil, err + } + if s.Patch, err = strconv.Atoi(matches[3]); err != nil { + return nil, err } return s, nil } @@ -91,13 +108,14 @@ func CompileSolidityString(solc, source string) (map[string]*Contract, error) { if len(source) == 0 { return nil, errors.New("solc: empty source string") } - if solc == "" { - solc = "solc" + s, err := SolidityVersion(solc) + if err != nil { + return nil, err } - args := append(solcParams, "--") - cmd := exec.Command(solc, append(args, "-")...) + args := append(s.makeArgs(), "--") + cmd := exec.Command(s.Path, append(args, "-")...) cmd.Stdin = strings.NewReader(source) - return runsolc(cmd, source) + return s.run(cmd, source) } // CompileSolidity compiles all given Solidity source files. @@ -109,15 +127,16 @@ func CompileSolidity(solc string, sourcefiles ...string) (map[string]*Contract, if err != nil { return nil, err } - if solc == "" { - solc = "solc" + s, err := SolidityVersion(solc) + if err != nil { + return nil, err } - args := append(solcParams, "--") - cmd := exec.Command(solc, append(args, sourcefiles...)...) - return runsolc(cmd, source) + args := append(s.makeArgs(), "--") + cmd := exec.Command(s.Path, append(args, sourcefiles...)...) + return s.run(cmd, source) } -func runsolc(cmd *exec.Cmd, source string) (map[string]*Contract, error) { +func (s *Solidity) run(cmd *exec.Cmd, source string) (map[string]*Contract, error) { var stderr, stdout bytes.Buffer cmd.Stderr = &stderr cmd.Stdout = &stdout @@ -128,7 +147,6 @@ func runsolc(cmd *exec.Cmd, source string) (map[string]*Contract, error) { if err := json.Unmarshal(stdout.Bytes(), &output); err != nil { return nil, err } - shortVersion := versionRegexp.FindString(output.Version) // Compilation succeeded, assemble and return the contracts. contracts := make(map[string]*Contract) @@ -151,12 +169,13 @@ func runsolc(cmd *exec.Cmd, source string) (map[string]*Contract, error) { Info: ContractInfo{ Source: source, Language: "Solidity", - LanguageVersion: shortVersion, - CompilerVersion: shortVersion, - CompilerOptions: strings.Join(solcParams, " "), + LanguageVersion: s.Version, + CompilerVersion: s.Version, + CompilerOptions: strings.Join(s.makeArgs(), " "), AbiDefinition: abi, UserDoc: userdoc, DeveloperDoc: devdoc, + Metadata: info.Metadata, }, } } @@ -174,13 +193,3 @@ func slurpFiles(files []string) (string, error) { } return concat.String(), nil } - -// SaveInfo serializes info to the given file and returns its Keccak256 hash. -func SaveInfo(info *ContractInfo, filename string) (common.Hash, error) { - infojson, err := json.Marshal(info) - if err != nil { - return common.Hash{}, err - } - contenthash := common.BytesToHash(crypto.Keccak256(infojson)) - return contenthash, ioutil.WriteFile(filename, infojson, 0600) -} diff --git a/common/compiler/solidity_test.go b/common/compiler/solidity_test.go index f16637547..0da3bb337 100644 --- a/common/compiler/solidity_test.go +++ b/common/compiler/solidity_test.go @@ -17,14 +17,8 @@ package compiler import ( - "encoding/json" - "io/ioutil" - "os" "os/exec" - "path" "testing" - - "github.com/ethereum/go-ethereum/common" ) const ( @@ -36,7 +30,6 @@ contract test { } } ` - testInfo = `{"source":"\ncontract test {\n /// @notice Will multiply ` + "`a`" + ` by 7.\n function multiply(uint a) returns(uint d) {\n return a * 7;\n }\n}\n","language":"Solidity","languageVersion":"0.1.1","compilerVersion":"0.1.1","compilerOptions":"--binary file --json-abi file --add-std 1","abiDefinition":[{"constant":false,"inputs":[{"name":"a","type":"uint256"}],"name":"multiply","outputs":[{"name":"d","type":"uint256"}],"type":"function"}],"userDoc":{"methods":{"multiply(uint256)":{"notice":"Will multiply ` + "`a`" + ` by 7."}}},"developerDoc":{"methods":{}}}` ) func skipWithoutSolc(t *testing.T) { @@ -57,7 +50,10 @@ func TestCompiler(t *testing.T) { } c, ok := contracts["test"] if !ok { - t.Fatal("info for contract 'test' not present in result") + c, ok = contracts["<stdin>:test"] + if !ok { + t.Fatal("info for contract 'test' not present in result") + } } if c.Code == "" { t.Error("empty code") @@ -79,28 +75,3 @@ func TestCompileError(t *testing.T) { } t.Logf("error: %v", err) } - -func TestSaveInfo(t *testing.T) { - var cinfo ContractInfo - err := json.Unmarshal([]byte(testInfo), &cinfo) - if err != nil { - t.Errorf("%v", err) - } - filename := path.Join(os.TempDir(), "solctest.info.json") - os.Remove(filename) - cinfohash, err := SaveInfo(&cinfo, filename) - if err != nil { - t.Errorf("error extracting info: %v", err) - } - got, err := ioutil.ReadFile(filename) - if err != nil { - t.Errorf("error reading '%v': %v", filename, err) - } - if string(got) != testInfo { - t.Errorf("incorrect info.json extracted, expected:\n%s\ngot\n%s", testInfo, string(got)) - } - wantHash := common.HexToHash("0x22450a77f0c3ff7a395948d07bc1456881226a1b6325f4189cb5f1254a824080") - if cinfohash != wantHash { - t.Errorf("content hash for info is incorrect. expected %v, got %v", wantHash.Hex(), cinfohash.Hex()) - } -} diff --git a/consensus/ethash/ethash.go b/consensus/ethash/ethash.go index d284e7b00..b028f50e6 100644 --- a/consensus/ethash/ethash.go +++ b/consensus/ethash/ethash.go @@ -130,13 +130,16 @@ func memoryMapAndGenerate(path string, size uint64, generator func(buffer []uint data := buffer[len(dumpMagic):] generator(data) - if err := mem.Flush(); err != nil { - mem.Unmap() - dump.Close() + if err := mem.Unmap(); err != nil { + return nil, nil, nil, err + } + if err := dump.Close(); err != nil { + return nil, nil, nil, err + } + if err := os.Rename(temp, path); err != nil { return nil, nil, nil, err } - os.Rename(temp, path) - return dump, mem, data, nil + return memoryMap(path) } // cache wraps an ethash cache with some metadata to allow easier concurrent use. diff --git a/eth/config.go b/eth/config.go index 90300bc05..7049940d3 100644 --- a/eth/config.go +++ b/eth/config.go @@ -34,6 +34,7 @@ import ( // DefaultConfig contains default settings for use on the Ethereum main net. var DefaultConfig = Config{ SyncMode: downloader.FastSync, + EthashCacheDir: "ethash", EthashCachesInMem: 2, EthashCachesOnDisk: 3, EthashDatasetsInMem: 1, |