diff --git a/.travis.yml b/.travis.yml index cbbc5a6a67..9827bc5c01 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,6 @@ sudo: required language: go go_import_path: github.com/ethereum/go-ethereum -services: skip jobs: include: @@ -42,8 +41,7 @@ jobs: - stage: Github release script: - - make tomo - - mv build/bin/tomo build/bin/tomo-linux-amd64 + - make tomo-linux-amd64 deploy: provider: releases api_key: $GITHUB_TOKEN @@ -54,44 +52,47 @@ jobs: branch: master tags: true - - stage: Build and push tomochain/tomochain image + - stage: Build and push untagged commit into image tomochain services: - docker - before_install: + install: skip + before_script: - docker build -t tomochain/tomochain . - docker run tomochain/tomochain - install: skip - script: skip - deploy: - - provider: script - script: - - bash docker_push.sh latest - - bash docker_push.sh $TRAVIS_BUILD_ID - on: - branch: master - tags: false - - provider: script - script: - - bash docker_push.sh latest - - bash docker_push.sh $TRAVIS_TAG - on: - branch: master - tags: true + script: + - echo "$DOCKER_PASSWORD" | docker login --username "$DOCKER_USERNAME" --password-stdin + - docker tag tomochain/tomochain tomochain/tomochain:latest + - docker push tomochain/tomochain:latest + - docker tag tomochain/tomochain tomochain/tomochain:$TRAVIS_BUILD_ID + - docker push tomochain/tomochain:$TRAVIS_BUILD_ID + after_success: + - curl -X POST $INFRA_IMAGE_REBUILD_HOOK - - stage: Trigger rebuild of tomochain/infra-tomochain image - sudo: false + - stage: Build and push tagged commit into image tomochain + services: + - docker install: skip - script: bash docker_rebuild.sh + before_script: + - docker build -t tomochain/tomochain . + - docker run tomochain/tomochain + script: + - echo "$DOCKER_PASSWORD" | docker login --username "$DOCKER_USERNAME" --password-stdin + - docker tag tomochain/tomochain tomochain/tomochain:latest + - docker push tomochain/tomochain:latest + - docker tag tomochain/tomochain tomochain/tomochain:$TRAVIS_TAG + - docker push tomochain/tomochain:$TRAVIS_TAG + after_success: + - curl -X POST $INFRA_IMAGE_REBUILD_HOOK stages: - name: Lint - name: Build and test - name: Github release if: type != pull_request AND branch = master AND tag = true AND repo = tomochain/tomochain - - name: Build and push tomochain/tomochain image - if: type != pull_request AND branch = master AND repo = tomochain/tomochain - - name: Trigger rebuild of tomochain/infra-tomochain image - if: type != pull_request AND branch = master AND repo = tomochain/tomochain + - name: Build and push untagged commit into image tomochain + if: type != pull_request AND branch = master AND tag IS blank AND repo = tomochain/tomochain + - name: Build and push tagged commit into image tomochain + if: type != pull_request AND branch = master AND tag = true AND repo = tomochain/tomochain notifications: slack: diff --git a/Makefile b/Makefile index 6b3cc8a0e5..4492228ac8 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,6 @@ -# This Makefile is meant to be used by people that do not usually work -# with Go source code. If you know what GOPATH is then you probably -# don't need to bother with make. - -.PHONY: tomo android ios tomo-cross swarm evm all test clean +.PHONY: tomo tomo-cross evm all test clean .PHONY: tomo-linux tomo-linux-386 tomo-linux-amd64 tomo-linux-mips64 tomo-linux-mips64le -.PHONY: tomo-linux-arm tomo-linux-arm-5 tomo-linux-arm-6 tomo-linux-arm-7 tomo-linux-arm64 .PHONY: tomo-darwin tomo-darwin-386 tomo-darwin-amd64 -.PHONY: tomo-windows tomo-windows-386 tomo-windows-amd64 GOBIN = $(shell pwd)/build/bin GOFMT = gofmt @@ -26,50 +20,27 @@ bootnode: @echo "Done building." @echo "Run \"$(GOBIN)/bootnode\" to launch a bootnode." -swarm: - build/env.sh go run build/ci.go install ./cmd/swarm +puppeth: + build/env.sh go run build/ci.go install ./cmd/puppeth @echo "Done building." - @echo "Run \"$(GOBIN)/swarm\" to launch swarm." + @echo "Run \"$(GOBIN)/puppeth\" to launch puppeth." all: build/env.sh go run build/ci.go install -android: - build/env.sh go run build/ci.go aar --local - @echo "Done building." - @echo "Import \"$(GOBIN)/tomo.aar\" to use the library." - -ios: - build/env.sh go run build/ci.go xcode --local - @echo "Done building." - @echo "Import \"$(GOBIN)/tomo.framework\" to use the library." - test: all build/env.sh go run build/ci.go test clean: rm -fr build/_workspace/pkg/ $(GOBIN)/* -# The devtools target installs tools required for 'go generate'. -# You need to put $GOBIN (or $GOPATH/bin) in your PATH to use 'go generate'. - -devtools: - env GOBIN= go get -u golang.org/x/tools/cmd/stringer - env GOBIN= go get -u github.com/kevinburke/go-bindata/go-bindata - env GOBIN= go get -u github.com/fjl/gencodec - env GOBIN= go get -u github.com/golang/protobuf/protoc-gen-go - env GOBIN= go install ./cmd/abigen - @type "npm" 2> /dev/null || echo 'Please install node.js and npm' - @type "solc" 2> /dev/null || echo 'Please install solc' - @type "protoc" 2> /dev/null || echo 'Please install protoc' - # Cross Compilation Targets (xgo) -tomo-cross: tomo-linux tomo-darwin tomo-windows tomo-android tomo-ios +tomo-cross: tomo-linux tomo-darwin @echo "Full cross compilation done:" @ls -ld $(GOBIN)/tomo-* -tomo-linux: tomo-linux-386 tomo-linux-amd64 tomo-linux-arm tomo-linux-mips64 tomo-linux-mips64le +tomo-linux: tomo-linux-386 tomo-linux-amd64 tomo-linux-mips64 tomo-linux-mips64le @echo "Linux cross compilation done:" @ls -ld $(GOBIN)/tomo-linux-* @@ -83,30 +54,6 @@ tomo-linux-amd64: @echo "Linux amd64 cross compilation done:" @ls -ld $(GOBIN)/tomo-linux-* | grep amd64 -tomo-linux-arm: tomo-linux-arm-5 tomo-linux-arm-6 tomo-linux-arm-7 tomo-linux-arm64 - @echo "Linux ARM cross compilation done:" - @ls -ld $(GOBIN)/tomo-linux-* | grep arm - -tomo-linux-arm-5: - build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=linux/arm-5 -v ./cmd/tomo - @echo "Linux ARMv5 cross compilation done:" - @ls -ld $(GOBIN)/tomo-linux-* | grep arm-5 - -tomo-linux-arm-6: - build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=linux/arm-6 -v ./cmd/tomo - @echo "Linux ARMv6 cross compilation done:" - @ls -ld $(GOBIN)/tomo-linux-* | grep arm-6 - -tomo-linux-arm-7: - build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=linux/arm-7 -v ./cmd/tomo - @echo "Linux ARMv7 cross compilation done:" - @ls -ld $(GOBIN)/tomo-linux-* | grep arm-7 - -tomo-linux-arm64: - build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=linux/arm64 -v ./cmd/tomo - @echo "Linux ARM64 cross compilation done:" - @ls -ld $(GOBIN)/tomo-linux-* | grep arm64 - tomo-linux-mips: build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=linux/mips --ldflags '-extldflags "-static"' -v ./cmd/tomo @echo "Linux MIPS cross compilation done:" @@ -141,20 +88,6 @@ tomo-darwin-amd64: @echo "Darwin amd64 cross compilation done:" @ls -ld $(GOBIN)/tomo-darwin-* | grep amd64 -tomo-windows: tomo-windows-386 tomo-windows-amd64 - @echo "Windows cross compilation done:" - @ls -ld $(GOBIN)/tomo-windows-* - -tomo-windows-386: - build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=windows/386 -v ./cmd/tomo - @echo "Windows 386 cross compilation done:" - @ls -ld $(GOBIN)/tomo-windows-* | grep 386 - -tomo-windows-amd64: - build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=windows/amd64 -v ./cmd/tomo - @echo "Windows amd64 cross compilation done:" - @ls -ld $(GOBIN)/geth-windows-* | grep amd64 - gofmt: $(GOFMT) -s -w $(GO_FILES) $(GIT) checkout vendor diff --git a/VERSION b/VERSION deleted file mode 100644 index bfa363e76e..0000000000 --- a/VERSION +++ /dev/null @@ -1 +0,0 @@ -1.8.4 diff --git a/build/ci.go b/build/ci.go index 1d95ca0bf0..487f386896 100644 --- a/build/ci.go +++ b/build/ci.go @@ -26,14 +26,8 @@ Available commands are: install [ -arch architecture ] [ -cc compiler ] [ packages... ] -- builds packages and executables test [ -coverage ] [ packages... ] -- runs the tests lint -- runs certain pre-selected linters - archive [ -arch architecture ] [ -type zip|tar ] [ -signer key-envvar ] [ -upload dest ] -- archives build artefacts importkeys -- imports signing keys from env - debsrc [ -signer key-id ] [ -upload dest ] -- creates a debian source package - nsis -- creates a Windows NSIS installer - aar [ -local ] [ -sign key-id ] [-deploy repo] [ -upload dest ] -- creates an Android archive - xcode [ -local ] [ -sign key-id ] [-deploy repo] [ -upload dest ] -- creates an iOS XCode framework xgo [ -alltools ] [ options ] -- cross builds according to options - purge [ -store blobstore ] [ -days threshold ] -- purges old archives from the blobstore For all commands, -n prevents execution of external programs (dry run mode). @@ -41,9 +35,6 @@ For all commands, -n prevents execution of external programs (dry run mode). package main import ( - "bufio" - "bytes" - "encoding/base64" "flag" "fmt" "go/parser" @@ -53,21 +44,13 @@ import ( "os" "os/exec" "path/filepath" - "regexp" "runtime" "strings" - "time" "github.com/ethereum/go-ethereum/internal/build" ) var ( - // Files that end up in the geth*.zip archive. - gethArchiveFiles = []string{ - "COPYING", - executablePath("geth"), - } - // Files that end up in the geth-alltools*.zip archive. allToolsArchiveFiles = []string{ "COPYING", @@ -80,49 +63,6 @@ var ( executablePath("swarm"), executablePath("wnode"), } - - // A debian package is created for all executables listed here. - debExecutables = []debExecutable{ - { - Name: "abigen", - Description: "Source code generator to convert Ethereum contract definitions into easy to use, compile-time type-safe Go packages.", - }, - { - Name: "bootnode", - Description: "Ethereum bootnode.", - }, - { - Name: "evm", - Description: "Developer utility version of the EVM (Ethereum Virtual Machine) that is capable of running bytecode snippets within a configurable environment and execution mode.", - }, - { - Name: "geth", - Description: "Ethereum CLI client.", - }, - { - Name: "puppeth", - Description: "Ethereum private network manager.", - }, - { - Name: "rlpdump", - Description: "Developer utility tool that prints RLP structures.", - }, - { - Name: "swarm", - Description: "Ethereum Swarm daemon and tools", - }, - { - Name: "wnode", - Description: "Ethereum Whisper diagnostic tool", - }, - } - - // Distros for which packages are created. - // Note: vivid is unsupported because there is no golang-1.6 package for it. - // Note: wily is unsupported because it was officially deprecated on lanchpad. - // Note: yakkety is unsupported because it was officially deprecated on lanchpad. - // Note: zesty is unsupported because it was officially deprecated on lanchpad. - debDistros = []string{"trusty", "xenial", "artful", "bionic"} ) var GOBIN, _ = filepath.Abs(filepath.Join("build", "bin")) @@ -150,20 +90,8 @@ func main() { doTest(os.Args[2:]) case "lint": doLint(os.Args[2:]) - case "archive": - doArchive(os.Args[2:]) - case "debsrc": - doDebianSource(os.Args[2:]) - case "nsis": - doWindowsInstaller(os.Args[2:]) - case "aar": - doAndroidArchive(os.Args[2:]) - case "xcode": - doXCodeFramework(os.Args[2:]) case "xgo": doXgo(os.Args[2:]) - case "purge": - doPurge(os.Args[2:]) default: log.Fatal("unknown command ", os.Args[1]) } @@ -345,586 +273,6 @@ func doLint(cmdline []string) { } } -// Release Packaging - -func doArchive(cmdline []string) { - var ( - arch = flag.String("arch", runtime.GOARCH, "Architecture cross packaging") - atype = flag.String("type", "zip", "Type of archive to write (zip|tar)") - signer = flag.String("signer", "", `Environment variable holding the signing key (e.g. LINUX_SIGNING_KEY)`) - upload = flag.String("upload", "", `Destination to upload the archives (usually "gethstore/builds")`) - ext string - ) - flag.CommandLine.Parse(cmdline) - switch *atype { - case "zip": - ext = ".zip" - case "tar": - ext = ".tar.gz" - default: - log.Fatal("unknown archive type: ", atype) - } - - var ( - env = build.Env() - base = archiveBasename(*arch, env) - geth = "geth-" + base + ext - alltools = "geth-alltools-" + base + ext - ) - maybeSkipArchive(env) - if err := build.WriteArchive(geth, gethArchiveFiles); err != nil { - log.Fatal(err) - } - if err := build.WriteArchive(alltools, allToolsArchiveFiles); err != nil { - log.Fatal(err) - } - for _, archive := range []string{geth, alltools} { - if err := archiveUpload(archive, *upload, *signer); err != nil { - log.Fatal(err) - } - } -} - -func archiveBasename(arch string, env build.Environment) string { - platform := runtime.GOOS + "-" + arch - if arch == "arm" { - platform += os.Getenv("GOARM") - } - if arch == "android" { - platform = "android-all" - } - if arch == "ios" { - platform = "ios-all" - } - return platform + "-" + archiveVersion(env) -} - -func archiveVersion(env build.Environment) string { - version := build.VERSION() - if isUnstableBuild(env) { - version += "-unstable" - } - if env.Commit != "" { - version += "-" + env.Commit[:8] - } - return version -} - -func archiveUpload(archive string, blobstore string, signer string) error { - // If signing was requested, generate the signature files - if signer != "" { - pgpkey, err := base64.StdEncoding.DecodeString(os.Getenv(signer)) - if err != nil { - return fmt.Errorf("invalid base64 %s", signer) - } - if err := build.PGPSignFile(archive, archive+".asc", string(pgpkey)); err != nil { - return err - } - } - // If uploading to Azure was requested, push the archive possibly with its signature - if blobstore != "" { - auth := build.AzureBlobstoreConfig{ - Account: strings.Split(blobstore, "/")[0], - Token: os.Getenv("AZURE_BLOBSTORE_TOKEN"), - Container: strings.SplitN(blobstore, "/", 2)[1], - } - if err := build.AzureBlobstoreUpload(archive, filepath.Base(archive), auth); err != nil { - return err - } - if signer != "" { - if err := build.AzureBlobstoreUpload(archive+".asc", filepath.Base(archive+".asc"), auth); err != nil { - return err - } - } - } - return nil -} - -// skips archiving for some build configurations. -func maybeSkipArchive(env build.Environment) { - if env.IsPullRequest { - log.Printf("skipping because this is a PR build") - os.Exit(0) - } - if env.IsCronJob { - log.Printf("skipping because this is a cron job") - os.Exit(0) - } - if env.Branch != "master" && !strings.HasPrefix(env.Tag, "v1.") { - log.Printf("skipping because branch %q, tag %q is not on the whitelist", env.Branch, env.Tag) - os.Exit(0) - } -} - -// Debian Packaging - -func doDebianSource(cmdline []string) { - var ( - signer = flag.String("signer", "", `Signing key name, also used as package author`) - upload = flag.String("upload", "", `Where to upload the source package (usually "ppa:ethereum/ethereum")`) - workdir = flag.String("workdir", "", `Output directory for packages (uses temp dir if unset)`) - now = time.Now() - ) - flag.CommandLine.Parse(cmdline) - *workdir = makeWorkdir(*workdir) - env := build.Env() - maybeSkipArchive(env) - - // Import the signing key. - if b64key := os.Getenv("PPA_SIGNING_KEY"); b64key != "" { - key, err := base64.StdEncoding.DecodeString(b64key) - if err != nil { - log.Fatal("invalid base64 PPA_SIGNING_KEY") - } - gpg := exec.Command("gpg", "--import") - gpg.Stdin = bytes.NewReader(key) - build.MustRun(gpg) - } - - // Create the packages. - for _, distro := range debDistros { - meta := newDebMetadata(distro, *signer, env, now) - pkgdir := stageDebianSource(*workdir, meta) - debuild := exec.Command("debuild", "-S", "-sa", "-us", "-uc") - debuild.Dir = pkgdir - build.MustRun(debuild) - - changes := fmt.Sprintf("%s_%s_source.changes", meta.Name(), meta.VersionString()) - changes = filepath.Join(*workdir, changes) - if *signer != "" { - build.MustRunCommand("debsign", changes) - } - if *upload != "" { - build.MustRunCommand("dput", *upload, changes) - } - } -} - -func makeWorkdir(wdflag string) string { - var err error - if wdflag != "" { - err = os.MkdirAll(wdflag, 0744) - } else { - wdflag, err = ioutil.TempDir("", "geth-build-") - } - if err != nil { - log.Fatal(err) - } - return wdflag -} - -func isUnstableBuild(env build.Environment) bool { - if env.Tag != "" { - return false - } - return true -} - -type debMetadata struct { - Env build.Environment - - // go-ethereum version being built. Note that this - // is not the debian package version. The package version - // is constructed by VersionString. - Version string - - Author string // "name ", also selects signing key - Distro, Time string - Executables []debExecutable -} - -type debExecutable struct { - Name, Description string -} - -func newDebMetadata(distro, author string, env build.Environment, t time.Time) debMetadata { - if author == "" { - // No signing key, use default author. - author = "Ethereum Builds " - } - return debMetadata{ - Env: env, - Author: author, - Distro: distro, - Version: build.VERSION(), - Time: t.Format(time.RFC1123Z), - Executables: debExecutables, - } -} - -// Name returns the name of the metapackage that depends -// on all executable packages. -func (meta debMetadata) Name() string { - if isUnstableBuild(meta.Env) { - return "ethereum-unstable" - } - return "ethereum" -} - -// VersionString returns the debian version of the packages. -func (meta debMetadata) VersionString() string { - vsn := meta.Version - if meta.Env.Buildnum != "" { - vsn += "+build" + meta.Env.Buildnum - } - if meta.Distro != "" { - vsn += "+" + meta.Distro - } - return vsn -} - -// ExeList returns the list of all executable packages. -func (meta debMetadata) ExeList() string { - names := make([]string, len(meta.Executables)) - for i, e := range meta.Executables { - names[i] = meta.ExeName(e) - } - return strings.Join(names, ", ") -} - -// ExeName returns the package name of an executable package. -func (meta debMetadata) ExeName(exe debExecutable) string { - if isUnstableBuild(meta.Env) { - return exe.Name + "-unstable" - } - return exe.Name -} - -// ExeConflicts returns the content of the Conflicts field -// for executable packages. -func (meta debMetadata) ExeConflicts(exe debExecutable) string { - if isUnstableBuild(meta.Env) { - // Set up the conflicts list so that the *-unstable packages - // cannot be installed alongside the regular version. - // - // https://www.debian.org/doc/debian-policy/ch-relationships.html - // is very explicit about Conflicts: and says that Breaks: should - // be preferred and the conflicting files should be handled via - // alternates. We might do this eventually but using a conflict is - // easier now. - return "ethereum, " + exe.Name - } - return "" -} - -func stageDebianSource(tmpdir string, meta debMetadata) (pkgdir string) { - pkg := meta.Name() + "-" + meta.VersionString() - pkgdir = filepath.Join(tmpdir, pkg) - if err := os.Mkdir(pkgdir, 0755); err != nil { - log.Fatal(err) - } - - // Copy the source code. - build.MustRunCommand("git", "checkout-index", "-a", "--prefix", pkgdir+string(filepath.Separator)) - - // Put the debian build files in place. - debian := filepath.Join(pkgdir, "debian") - build.Render("build/deb.rules", filepath.Join(debian, "rules"), 0755, meta) - build.Render("build/deb.changelog", filepath.Join(debian, "changelog"), 0644, meta) - build.Render("build/deb.control", filepath.Join(debian, "control"), 0644, meta) - build.Render("build/deb.copyright", filepath.Join(debian, "copyright"), 0644, meta) - build.RenderString("8\n", filepath.Join(debian, "compat"), 0644, meta) - build.RenderString("3.0 (native)\n", filepath.Join(debian, "source/format"), 0644, meta) - for _, exe := range meta.Executables { - install := filepath.Join(debian, meta.ExeName(exe)+".install") - docs := filepath.Join(debian, meta.ExeName(exe)+".docs") - build.Render("build/deb.install", install, 0644, exe) - build.Render("build/deb.docs", docs, 0644, exe) - } - - return pkgdir -} - -// Windows installer - -func doWindowsInstaller(cmdline []string) { - // Parse the flags and make skip installer generation on PRs - var ( - arch = flag.String("arch", runtime.GOARCH, "Architecture for cross build packaging") - signer = flag.String("signer", "", `Environment variable holding the signing key (e.g. WINDOWS_SIGNING_KEY)`) - upload = flag.String("upload", "", `Destination to upload the archives (usually "gethstore/builds")`) - workdir = flag.String("workdir", "", `Output directory for packages (uses temp dir if unset)`) - ) - flag.CommandLine.Parse(cmdline) - *workdir = makeWorkdir(*workdir) - env := build.Env() - maybeSkipArchive(env) - - // Aggregate binaries that are included in the installer - var ( - devTools []string - allTools []string - gethTool string - ) - for _, file := range allToolsArchiveFiles { - if file == "COPYING" { // license, copied later - continue - } - allTools = append(allTools, filepath.Base(file)) - if filepath.Base(file) == "geth.exe" { - gethTool = file - } else { - devTools = append(devTools, file) - } - } - - // Render NSIS scripts: Installer NSIS contains two installer sections, - // first section contains the geth binary, second section holds the dev tools. - templateData := map[string]interface{}{ - "License": "COPYING", - "Geth": gethTool, - "DevTools": devTools, - } - build.Render("build/nsis.geth.nsi", filepath.Join(*workdir, "geth.nsi"), 0644, nil) - build.Render("build/nsis.install.nsh", filepath.Join(*workdir, "install.nsh"), 0644, templateData) - build.Render("build/nsis.uninstall.nsh", filepath.Join(*workdir, "uninstall.nsh"), 0644, allTools) - build.Render("build/nsis.pathupdate.nsh", filepath.Join(*workdir, "PathUpdate.nsh"), 0644, nil) - build.Render("build/nsis.envvarupdate.nsh", filepath.Join(*workdir, "EnvVarUpdate.nsh"), 0644, nil) - build.CopyFile(filepath.Join(*workdir, "SimpleFC.dll"), "build/nsis.simplefc.dll", 0755) - build.CopyFile(filepath.Join(*workdir, "COPYING"), "COPYING", 0755) - - // Build the installer. This assumes that all the needed files have been previously - // built (don't mix building and packaging to keep cross compilation complexity to a - // minimum). - version := strings.Split(build.VERSION(), ".") - if env.Commit != "" { - version[2] += "-" + env.Commit[:8] - } - installer, _ := filepath.Abs("geth-" + archiveBasename(*arch, env) + ".exe") - build.MustRunCommand("makensis.exe", - "/DOUTPUTFILE="+installer, - "/DMAJORVERSION="+version[0], - "/DMINORVERSION="+version[1], - "/DBUILDVERSION="+version[2], - "/DARCH="+*arch, - filepath.Join(*workdir, "geth.nsi"), - ) - - // Sign and publish installer. - if err := archiveUpload(installer, *upload, *signer); err != nil { - log.Fatal(err) - } -} - -// Android archives - -func doAndroidArchive(cmdline []string) { - var ( - local = flag.Bool("local", false, `Flag whether we're only doing a local build (skip Maven artifacts)`) - signer = flag.String("signer", "", `Environment variable holding the signing key (e.g. ANDROID_SIGNING_KEY)`) - deploy = flag.String("deploy", "", `Destination to deploy the archive (usually "https://oss.sonatype.org")`) - upload = flag.String("upload", "", `Destination to upload the archive (usually "gethstore/builds")`) - ) - flag.CommandLine.Parse(cmdline) - env := build.Env() - - // Sanity check that the SDK and NDK are installed and set - if os.Getenv("ANDROID_HOME") == "" { - log.Fatal("Please ensure ANDROID_HOME points to your Android SDK") - } - if os.Getenv("ANDROID_NDK") == "" { - log.Fatal("Please ensure ANDROID_NDK points to your Android NDK") - } - // Build the Android archive and Maven resources - build.MustRun(goTool("get", "golang.org/x/mobile/cmd/gomobile", "golang.org/x/mobile/cmd/gobind")) - build.MustRun(gomobileTool("init", "--ndk", os.Getenv("ANDROID_NDK"))) - build.MustRun(gomobileTool("bind", "--target", "android", "--javapkg", "org.ethereum", "-v", "github.com/ethereum/go-ethereum/mobile")) - - if *local { - // If we're building locally, copy bundle to build dir and skip Maven - os.Rename("geth.aar", filepath.Join(GOBIN, "geth.aar")) - return - } - meta := newMavenMetadata(env) - build.Render("build/mvn.pom", meta.Package+".pom", 0755, meta) - - // Skip Maven deploy and Azure upload for PR builds - maybeSkipArchive(env) - - // Sign and upload the archive to Azure - archive := "geth-" + archiveBasename("android", env) + ".aar" - os.Rename("geth.aar", archive) - - if err := archiveUpload(archive, *upload, *signer); err != nil { - log.Fatal(err) - } - // Sign and upload all the artifacts to Maven Central - os.Rename(archive, meta.Package+".aar") - if *signer != "" && *deploy != "" { - // Import the signing key into the local GPG instance - if b64key := os.Getenv(*signer); b64key != "" { - key, err := base64.StdEncoding.DecodeString(b64key) - if err != nil { - log.Fatalf("invalid base64 %s", *signer) - } - gpg := exec.Command("gpg", "--import") - gpg.Stdin = bytes.NewReader(key) - build.MustRun(gpg) - } - // Upload the artifacts to Sonatype and/or Maven Central - repo := *deploy + "/service/local/staging/deploy/maven2" - if meta.Develop { - repo = *deploy + "/content/repositories/snapshots" - } - build.MustRunCommand("mvn", "gpg:sign-and-deploy-file", - "-settings=build/mvn.settings", "-Durl="+repo, "-DrepositoryId=ossrh", - "-DpomFile="+meta.Package+".pom", "-Dfile="+meta.Package+".aar") - } -} - -func gomobileTool(subcmd string, args ...string) *exec.Cmd { - cmd := exec.Command(filepath.Join(GOBIN, "gomobile"), subcmd) - cmd.Args = append(cmd.Args, args...) - cmd.Env = []string{ - "GOPATH=" + build.GOPATH(), - "PATH=" + GOBIN + string(os.PathListSeparator) + os.Getenv("PATH"), - } - for _, e := range os.Environ() { - if strings.HasPrefix(e, "GOPATH=") || strings.HasPrefix(e, "PATH=") { - continue - } - cmd.Env = append(cmd.Env, e) - } - return cmd -} - -type mavenMetadata struct { - Version string - Package string - Develop bool - Contributors []mavenContributor -} - -type mavenContributor struct { - Name string - Email string -} - -func newMavenMetadata(env build.Environment) mavenMetadata { - // Collect the list of authors from the repo root - contribs := []mavenContributor{} - if authors, err := os.Open("AUTHORS"); err == nil { - defer authors.Close() - - scanner := bufio.NewScanner(authors) - for scanner.Scan() { - // Skip any whitespace from the authors list - line := strings.TrimSpace(scanner.Text()) - if line == "" || line[0] == '#' { - continue - } - // Split the author and insert as a contributor - re := regexp.MustCompile("([^<]+) <(.+)>") - parts := re.FindStringSubmatch(line) - if len(parts) == 3 { - contribs = append(contribs, mavenContributor{Name: parts[1], Email: parts[2]}) - } - } - } - // Render the version and package strings - version := build.VERSION() - if isUnstableBuild(env) { - version += "-SNAPSHOT" - } - return mavenMetadata{ - Version: version, - Package: "geth-" + version, - Develop: isUnstableBuild(env), - Contributors: contribs, - } -} - -// XCode frameworks - -func doXCodeFramework(cmdline []string) { - var ( - local = flag.Bool("local", false, `Flag whether we're only doing a local build (skip Maven artifacts)`) - signer = flag.String("signer", "", `Environment variable holding the signing key (e.g. IOS_SIGNING_KEY)`) - deploy = flag.String("deploy", "", `Destination to deploy the archive (usually "trunk")`) - upload = flag.String("upload", "", `Destination to upload the archives (usually "gethstore/builds")`) - ) - flag.CommandLine.Parse(cmdline) - env := build.Env() - - // Build the iOS XCode framework - build.MustRun(goTool("get", "golang.org/x/mobile/cmd/gomobile", "golang.org/x/mobile/cmd/gobind")) - build.MustRun(gomobileTool("init")) - bind := gomobileTool("bind", "--target", "ios", "--tags", "ios", "-v", "github.com/ethereum/go-ethereum/mobile") - - if *local { - // If we're building locally, use the build folder and stop afterwards - bind.Dir, _ = filepath.Abs(GOBIN) - build.MustRun(bind) - return - } - archive := "geth-" + archiveBasename("ios", env) - if err := os.Mkdir(archive, os.ModePerm); err != nil { - log.Fatal(err) - } - bind.Dir, _ = filepath.Abs(archive) - build.MustRun(bind) - build.MustRunCommand("tar", "-zcvf", archive+".tar.gz", archive) - - // Skip CocoaPods deploy and Azure upload for PR builds - maybeSkipArchive(env) - - // Sign and upload the framework to Azure - if err := archiveUpload(archive+".tar.gz", *upload, *signer); err != nil { - log.Fatal(err) - } - // Prepare and upload a PodSpec to CocoaPods - if *deploy != "" { - meta := newPodMetadata(env, archive) - build.Render("build/pod.podspec", "Geth.podspec", 0755, meta) - build.MustRunCommand("pod", *deploy, "push", "Geth.podspec", "--allow-warnings", "--verbose") - } -} - -type podMetadata struct { - Version string - Commit string - Archive string - Contributors []podContributor -} - -type podContributor struct { - Name string - Email string -} - -func newPodMetadata(env build.Environment, archive string) podMetadata { - // Collect the list of authors from the repo root - contribs := []podContributor{} - if authors, err := os.Open("AUTHORS"); err == nil { - defer authors.Close() - - scanner := bufio.NewScanner(authors) - for scanner.Scan() { - // Skip any whitespace from the authors list - line := strings.TrimSpace(scanner.Text()) - if line == "" || line[0] == '#' { - continue - } - // Split the author and insert as a contributor - re := regexp.MustCompile("([^<]+) <(.+)>") - parts := re.FindStringSubmatch(line) - if len(parts) == 3 { - contribs = append(contribs, podContributor{Name: parts[1], Email: parts[2]}) - } - } - } - version := build.VERSION() - if isUnstableBuild(env) { - version += "-unstable." + env.Buildnum - } - return podMetadata{ - Archive: archive, - Version: version, - Commit: env.Commit, - Contributors: contribs, - } -} - // Cross compilation func doXgo(cmdline []string) { @@ -976,62 +324,3 @@ func xgoTool(args []string) *exec.Cmd { } return cmd } - -// Binary distribution cleanups - -func doPurge(cmdline []string) { - var ( - store = flag.String("store", "", `Destination from where to purge archives (usually "gethstore/builds")`) - limit = flag.Int("days", 30, `Age threshold above which to delete unstalbe archives`) - ) - flag.CommandLine.Parse(cmdline) - - if env := build.Env(); !env.IsCronJob { - log.Printf("skipping because not a cron job") - os.Exit(0) - } - // Create the azure authentication and list the current archives - auth := build.AzureBlobstoreConfig{ - Account: strings.Split(*store, "/")[0], - Token: os.Getenv("AZURE_BLOBSTORE_TOKEN"), - Container: strings.SplitN(*store, "/", 2)[1], - } - blobs, err := build.AzureBlobstoreList(auth) - if err != nil { - log.Fatal(err) - } - // Iterate over the blobs, collect and sort all unstable builds - for i := 0; i < len(blobs); i++ { - if !strings.Contains(blobs[i].Name, "unstable") { - blobs = append(blobs[:i], blobs[i+1:]...) - i-- - } - } - for i := 0; i < len(blobs); i++ { - for j := i + 1; j < len(blobs); j++ { - iTime, err := time.Parse(time.RFC1123, blobs[i].Properties.LastModified) - if err != nil { - log.Fatal(err) - } - jTime, err := time.Parse(time.RFC1123, blobs[j].Properties.LastModified) - if err != nil { - log.Fatal(err) - } - if iTime.After(jTime) { - blobs[i], blobs[j] = blobs[j], blobs[i] - } - } - } - // Filter out all archives more recent that the given threshold - for i, blob := range blobs { - timestamp, _ := time.Parse(time.RFC1123, blob.Properties.LastModified) - if time.Since(timestamp) < time.Duration(*limit)*24*time.Hour { - blobs = blobs[:i] - break - } - } - // Delete all marked as such and return - if err := build.AzureBlobstoreDelete(auth, blobs); err != nil { - log.Fatal(err) - } -} diff --git a/build/deb.changelog b/build/deb.changelog deleted file mode 100644 index 83f804a833..0000000000 --- a/build/deb.changelog +++ /dev/null @@ -1,5 +0,0 @@ -{{.Name}} ({{.VersionString}}) {{.Distro}}; urgency=low - - * git build of {{.Env.Commit}} - - -- {{.Author}} {{.Time}} diff --git a/build/deb.control b/build/deb.control deleted file mode 100644 index 33c1a779f4..0000000000 --- a/build/deb.control +++ /dev/null @@ -1,25 +0,0 @@ -Source: {{.Name}} -Section: science -Priority: extra -Maintainer: {{.Author}} -Build-Depends: debhelper (>= 8.0.0), golang-1.10 -Standards-Version: 3.9.5 -Homepage: https://ethereum.org -Vcs-Git: git://github.com/ethereum/go-ethereum.git -Vcs-Browser: https://github.com/ethereum/go-ethereum - -Package: {{.Name}} -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 .}} -Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends} -Built-Using: ${misc:Built-Using} -Description: {{.Description}} - {{.Description}} -{{end}} diff --git a/build/deb.copyright b/build/deb.copyright deleted file mode 100644 index 513be45b19..0000000000 --- a/build/deb.copyright +++ /dev/null @@ -1,14 +0,0 @@ -Copyright 2016 The go-ethereum Authors - -go-ethereum is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -go-ethereum is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with go-ethereum. If not, see . diff --git a/build/deb.docs b/build/deb.docs deleted file mode 100644 index 62deb04972..0000000000 --- a/build/deb.docs +++ /dev/null @@ -1 +0,0 @@ -AUTHORS diff --git a/build/deb.install b/build/deb.install deleted file mode 100644 index 7dc76e1f56..0000000000 --- a/build/deb.install +++ /dev/null @@ -1 +0,0 @@ -build/bin/{{.Name}} usr/bin diff --git a/build/deb.rules b/build/deb.rules deleted file mode 100644 index 7f286569ea..0000000000 --- a/build/deb.rules +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/make -f -# -*- makefile -*- - -# Uncomment this to turn on verbose mode. -#export DH_VERBOSE=1 - -override_dh_auto_build: - build/env.sh /usr/lib/go-1.10/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: - -%: - dh $@ diff --git a/build/mvn.pom b/build/mvn.pom deleted file mode 100644 index 7670246ba9..0000000000 --- a/build/mvn.pom +++ /dev/null @@ -1,57 +0,0 @@ - - 4.0.0 - - org.ethereum - geth - {{.Version}} - aar - - Android Ethereum Client - Android port of the go-ethereum libraries and node - https://github.com/ethereum/go-ethereum - 2015 - - - - GNU Lesser General Public License, Version 3.0 - https://www.gnu.org/licenses/lgpl-3.0.en.html - repo - - - - - Ethereum - https://ethereum.org - - - - - karalabe - Péter Szilágyi - peterke@gmail.com - https://github.com/karalabe - - https://www.gravatar.com/avatar/2ecbf0f5b4b79eebf8c193e5d324357f?s=256 - - - - - {{range .Contributors}} - - {{.Name}} - {{.Email}} - {{end}} - - - - GitHub Issues - https://github.com/ethereum/go-ethereum/issues/ - - - - https://github.com/ethereum/go-ethereum - - diff --git a/build/mvn.settings b/build/mvn.settings deleted file mode 100644 index 406b409b9b..0000000000 --- a/build/mvn.settings +++ /dev/null @@ -1,24 +0,0 @@ - - - - ossrh - ${env.ANDROID_SONATYPE_USERNAME} - ${env.ANDROID_SONATYPE_PASSWORD} - - - - - ossrh - - true - - - gpg - - - - - diff --git a/build/nsis.envvarupdate.nsh b/build/nsis.envvarupdate.nsh deleted file mode 100644 index 9c3ecbe337..0000000000 --- a/build/nsis.envvarupdate.nsh +++ /dev/null @@ -1,327 +0,0 @@ -/** - * EnvVarUpdate.nsh - * : Environmental Variables: append, prepend, and remove entries - * - * WARNING: If you use StrFunc.nsh header then include it before this file - * with all required definitions. This is to avoid conflicts - * - * Usage: - * ${EnvVarUpdate} "ResultVar" "EnvVarName" "Action" "RegLoc" "PathString" - * - * Credits: - * Version 1.0 - * * Cal Turney (turnec2) - * * Amir Szekely (KiCHiK) and e-circ for developing the forerunners of this - * function: AddToPath, un.RemoveFromPath, AddToEnvVar, un.RemoveFromEnvVar, - * WriteEnvStr, and un.DeleteEnvStr - * * Diego Pedroso (deguix) for StrTok - * * Kevin English (kenglish_hi) for StrContains - * * Hendri Adriaens (Smile2Me), Diego Pedroso (deguix), and Dan Fuhry - * (dandaman32) for StrReplace - * - * Version 1.1 (compatibility with StrFunc.nsh) - * * techtonik - * - * http://nsis.sourceforge.net/Environmental_Variables:_append%2C_prepend%2C_and_remove_entries - * - */ - - -!ifndef ENVVARUPDATE_FUNCTION -!define ENVVARUPDATE_FUNCTION -!verbose push -!verbose 3 -!include "LogicLib.nsh" -!include "WinMessages.NSH" -!include "StrFunc.nsh" - -; ---- Fix for conflict if StrFunc.nsh is already includes in main file ----------------------- -!macro _IncludeStrFunction StrFuncName - !ifndef ${StrFuncName}_INCLUDED - ${${StrFuncName}} - !endif - !ifndef Un${StrFuncName}_INCLUDED - ${Un${StrFuncName}} - !endif - !define un.${StrFuncName} "${Un${StrFuncName}}" -!macroend - -!insertmacro _IncludeStrFunction StrTok -!insertmacro _IncludeStrFunction StrStr -!insertmacro _IncludeStrFunction StrRep - -; ---------------------------------- Macro Definitions ---------------------------------------- -!macro _EnvVarUpdateConstructor ResultVar EnvVarName Action Regloc PathString - Push "${EnvVarName}" - Push "${Action}" - Push "${RegLoc}" - Push "${PathString}" - Call EnvVarUpdate - Pop "${ResultVar}" -!macroend -!define EnvVarUpdate '!insertmacro "_EnvVarUpdateConstructor"' - -!macro _unEnvVarUpdateConstructor ResultVar EnvVarName Action Regloc PathString - Push "${EnvVarName}" - Push "${Action}" - Push "${RegLoc}" - Push "${PathString}" - Call un.EnvVarUpdate - Pop "${ResultVar}" -!macroend -!define un.EnvVarUpdate '!insertmacro "_unEnvVarUpdateConstructor"' -; ---------------------------------- Macro Definitions end------------------------------------- - -;----------------------------------- EnvVarUpdate start---------------------------------------- -!define hklm_all_users 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"' -!define hkcu_current_user 'HKCU "Environment"' - -!macro EnvVarUpdate UN - -Function ${UN}EnvVarUpdate - - Push $0 - Exch 4 - Exch $1 - Exch 3 - Exch $2 - Exch 2 - Exch $3 - Exch - Exch $4 - Push $5 - Push $6 - Push $7 - Push $8 - Push $9 - Push $R0 - - /* After this point: - ------------------------- - $0 = ResultVar (returned) - $1 = EnvVarName (input) - $2 = Action (input) - $3 = RegLoc (input) - $4 = PathString (input) - $5 = Orig EnvVar (read from registry) - $6 = Len of $0 (temp) - $7 = tempstr1 (temp) - $8 = Entry counter (temp) - $9 = tempstr2 (temp) - $R0 = tempChar (temp) */ - - ; Step 1: Read contents of EnvVarName from RegLoc - ; - ; Check for empty EnvVarName - ${If} $1 == "" - SetErrors - DetailPrint "ERROR: EnvVarName is blank" - Goto EnvVarUpdate_Restore_Vars - ${EndIf} - - ; Check for valid Action - ${If} $2 != "A" - ${AndIf} $2 != "P" - ${AndIf} $2 != "R" - SetErrors - DetailPrint "ERROR: Invalid Action - must be A, P, or R" - Goto EnvVarUpdate_Restore_Vars - ${EndIf} - - ${If} $3 == HKLM - ReadRegStr $5 ${hklm_all_users} $1 ; Get EnvVarName from all users into $5 - ${ElseIf} $3 == HKCU - ReadRegStr $5 ${hkcu_current_user} $1 ; Read EnvVarName from current user into $5 - ${Else} - SetErrors - DetailPrint 'ERROR: Action is [$3] but must be "HKLM" or HKCU"' - Goto EnvVarUpdate_Restore_Vars - ${EndIf} - - ; Check for empty PathString - ${If} $4 == "" - SetErrors - DetailPrint "ERROR: PathString is blank" - Goto EnvVarUpdate_Restore_Vars - ${EndIf} - - ; Make sure we've got some work to do - ${If} $5 == "" - ${AndIf} $2 == "R" - SetErrors - DetailPrint "$1 is empty - Nothing to remove" - Goto EnvVarUpdate_Restore_Vars - ${EndIf} - - ; Step 2: Scrub EnvVar - ; - StrCpy $0 $5 ; Copy the contents to $0 - ; Remove spaces around semicolons (NOTE: spaces before the 1st entry or - ; after the last one are not removed here but instead in Step 3) - ${If} $0 != "" ; If EnvVar is not empty ... - ${Do} - ${${UN}StrStr} $7 $0 " ;" - ${If} $7 == "" - ${ExitDo} - ${EndIf} - ${${UN}StrRep} $0 $0 " ;" ";" ; Remove ';' - ${Loop} - ${Do} - ${${UN}StrStr} $7 $0 "; " - ${If} $7 == "" - ${ExitDo} - ${EndIf} - ${${UN}StrRep} $0 $0 "; " ";" ; Remove ';' - ${Loop} - ${Do} - ${${UN}StrStr} $7 $0 ";;" - ${If} $7 == "" - ${ExitDo} - ${EndIf} - ${${UN}StrRep} $0 $0 ";;" ";" - ${Loop} - - ; Remove a leading or trailing semicolon from EnvVar - StrCpy $7 $0 1 0 - ${If} $7 == ";" - StrCpy $0 $0 "" 1 ; Change ';' to '' - ${EndIf} - StrLen $6 $0 - IntOp $6 $6 - 1 - StrCpy $7 $0 1 $6 - ${If} $7 == ";" - StrCpy $0 $0 $6 ; Change ';' to '' - ${EndIf} - ; DetailPrint "Scrubbed $1: [$0]" ; Uncomment to debug - ${EndIf} - - /* Step 3. Remove all instances of the target path/string (even if "A" or "P") - $6 = bool flag (1 = found and removed PathString) - $7 = a string (e.g. path) delimited by semicolon(s) - $8 = entry counter starting at 0 - $9 = copy of $0 - $R0 = tempChar */ - - ${If} $5 != "" ; If EnvVar is not empty ... - StrCpy $9 $0 - StrCpy $0 "" - StrCpy $8 0 - StrCpy $6 0 - - ${Do} - ${${UN}StrTok} $7 $9 ";" $8 "0" ; $7 = next entry, $8 = entry counter - - ${If} $7 == "" ; If we've run out of entries, - ${ExitDo} ; were done - ${EndIf} ; - - ; Remove leading and trailing spaces from this entry (critical step for Action=Remove) - ${Do} - StrCpy $R0 $7 1 - ${If} $R0 != " " - ${ExitDo} - ${EndIf} - StrCpy $7 $7 "" 1 ; Remove leading space - ${Loop} - ${Do} - StrCpy $R0 $7 1 -1 - ${If} $R0 != " " - ${ExitDo} - ${EndIf} - StrCpy $7 $7 -1 ; Remove trailing space - ${Loop} - ${If} $7 == $4 ; If string matches, remove it by not appending it - StrCpy $6 1 ; Set 'found' flag - ${ElseIf} $7 != $4 ; If string does NOT match - ${AndIf} $0 == "" ; and the 1st string being added to $0, - StrCpy $0 $7 ; copy it to $0 without a prepended semicolon - ${ElseIf} $7 != $4 ; If string does NOT match - ${AndIf} $0 != "" ; and this is NOT the 1st string to be added to $0, - StrCpy $0 $0;$7 ; append path to $0 with a prepended semicolon - ${EndIf} ; - - IntOp $8 $8 + 1 ; Bump counter - ${Loop} ; Check for duplicates until we run out of paths - ${EndIf} - - ; Step 4: Perform the requested Action - ; - ${If} $2 != "R" ; If Append or Prepend - ${If} $6 == 1 ; And if we found the target - DetailPrint "Target is already present in $1. It will be removed and" - ${EndIf} - ${If} $0 == "" ; If EnvVar is (now) empty - StrCpy $0 $4 ; just copy PathString to EnvVar - ${If} $6 == 0 ; If found flag is either 0 - ${OrIf} $6 == "" ; or blank (if EnvVarName is empty) - DetailPrint "$1 was empty and has been updated with the target" - ${EndIf} - ${ElseIf} $2 == "A" ; If Append (and EnvVar is not empty), - StrCpy $0 $0;$4 ; append PathString - ${If} $6 == 1 - DetailPrint "appended to $1" - ${Else} - DetailPrint "Target was appended to $1" - ${EndIf} - ${Else} ; If Prepend (and EnvVar is not empty), - StrCpy $0 $4;$0 ; prepend PathString - ${If} $6 == 1 - DetailPrint "prepended to $1" - ${Else} - DetailPrint "Target was prepended to $1" - ${EndIf} - ${EndIf} - ${Else} ; If Action = Remove - ${If} $6 == 1 ; and we found the target - DetailPrint "Target was found and removed from $1" - ${Else} - DetailPrint "Target was NOT found in $1 (nothing to remove)" - ${EndIf} - ${If} $0 == "" - DetailPrint "$1 is now empty" - ${EndIf} - ${EndIf} - - ; Step 5: Update the registry at RegLoc with the updated EnvVar and announce the change - ; - ClearErrors - ${If} $3 == HKLM - WriteRegExpandStr ${hklm_all_users} $1 $0 ; Write it in all users section - ${ElseIf} $3 == HKCU - WriteRegExpandStr ${hkcu_current_user} $1 $0 ; Write it to current user section - ${EndIf} - - IfErrors 0 +4 - MessageBox MB_OK|MB_ICONEXCLAMATION "Could not write updated $1 to $3" - DetailPrint "Could not write updated $1 to $3" - Goto EnvVarUpdate_Restore_Vars - - ; "Export" our change - SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000 - - EnvVarUpdate_Restore_Vars: - ; - ; Restore the user's variables and return ResultVar - Pop $R0 - Pop $9 - Pop $8 - Pop $7 - Pop $6 - Pop $5 - Pop $4 - Pop $3 - Pop $2 - Pop $1 - Push $0 ; Push my $0 (ResultVar) - Exch - Pop $0 ; Restore his $0 - -FunctionEnd - -!macroend ; EnvVarUpdate UN -!insertmacro EnvVarUpdate "" -!insertmacro EnvVarUpdate "un." -;----------------------------------- EnvVarUpdate end---------------------------------------- - -!verbose pop -!endif \ No newline at end of file diff --git a/build/nsis.geth.nsi b/build/nsis.geth.nsi deleted file mode 100644 index 1034f30235..0000000000 --- a/build/nsis.geth.nsi +++ /dev/null @@ -1,70 +0,0 @@ -# Builds a Windows installer with NSIS. -# It expects the following command line arguments: -# - OUTPUTFILE, filename of the installer (without extension) -# - MAJORVERSION, major build version -# - MINORVERSION, minor build version -# - BUILDVERSION, build id version -# -# The created installer executes the following steps: -# 1. install geth for all users -# 2. install optional development tools such as abigen -# 3. create an uninstaller -# 4. configures the Windows firewall for geth -# 5. create geth, attach and uninstall start menu entries -# 6. configures the registry that allows Windows to manage the package through its platform tools -# 7. adds the environment system wide variable ETHEREUM_SOCKET -# 8. adds the install directory to %PATH% -# -# Requirements: -# - NSIS, http://nsis.sourceforge.net/Main_Page -# - NSIS Large Strings build, http://nsis.sourceforge.net/Special_Builds -# - SFP, http://nsis.sourceforge.net/NSIS_Simple_Firewall_Plugin (put dll in NSIS\Plugins\x86-ansi) -# -# After intalling NSIS extra the NSIS Large Strings build zip and replace the makensis.exe and the -# files found in Stub. -# -# based on: http://nsis.sourceforge.net/A_simple_installer_with_start_menu_shortcut_and_uninstaller -# -# TODO: -# - sign installer -CRCCheck on - -!define GROUPNAME "Ethereum" -!define APPNAME "Geth" -!define DESCRIPTION "Official Go implementation of the Ethereum protocol" -!addplugindir .\ - -# Require admin rights on NT6+ (When UAC is turned on) -RequestExecutionLevel admin - -# Use LZMA compression -SetCompressor /SOLID lzma - -!include LogicLib.nsh -!include PathUpdate.nsh -!include EnvVarUpdate.nsh - -!macro VerifyUserIsAdmin -UserInfo::GetAccountType -pop $0 -${If} $0 != "admin" # Require admin rights on NT4+ - messageBox mb_iconstop "Administrator rights required!" - setErrorLevel 740 # ERROR_ELEVATION_REQUIRED - quit -${EndIf} -!macroend - -function .onInit - # make vars are global for all users since geth is installed global - setShellVarContext all - !insertmacro VerifyUserIsAdmin - - ${If} ${ARCH} == "amd64" - StrCpy $InstDir "$PROGRAMFILES64\${APPNAME}" - ${Else} - StrCpy $InstDir "$PROGRAMFILES32\${APPNAME}" - ${Endif} -functionEnd - -!include install.nsh -!include uninstall.nsh diff --git a/build/nsis.install.nsh b/build/nsis.install.nsh deleted file mode 100644 index 57ef5a37c6..0000000000 --- a/build/nsis.install.nsh +++ /dev/null @@ -1,103 +0,0 @@ -Name "geth ${MAJORVERSION}.${MINORVERSION}.${BUILDVERSION}" # VERSION variables set through command line arguments -InstallDir "$InstDir" -OutFile "${OUTPUTFILE}" # set through command line arguments - -# Links for "Add/Remove Programs" -!define HELPURL "https://github.com/ethereum/go-ethereum/issues" -!define UPDATEURL "https://github.com/ethereum/go-ethereum/releases" -!define ABOUTURL "https://github.com/ethereum/go-ethereum#ethereum-go" -!define /date NOW "%Y%m%d" - -PageEx license - LicenseData {{.License}} -PageExEnd - -# Install geth binary -Section "Geth" GETH_IDX - SetOutPath $INSTDIR - file {{.Geth}} - - # Create start menu launcher - createDirectory "$SMPROGRAMS\${APPNAME}" - createShortCut "$SMPROGRAMS\${APPNAME}\${APPNAME}.lnk" "$INSTDIR\geth.exe" "--fast" "--cache=512" - createShortCut "$SMPROGRAMS\${APPNAME}\Attach.lnk" "$INSTDIR\geth.exe" "attach" "" "" - createShortCut "$SMPROGRAMS\${APPNAME}\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "" "" - - # Firewall - remove rules (if exists) - SimpleFC::AdvRemoveRule "Geth incoming peers (TCP:30303)" - SimpleFC::AdvRemoveRule "Geth outgoing peers (TCP:30303)" - SimpleFC::AdvRemoveRule "Geth UDP discovery (UDP:30303)" - - # Firewall - add rules - SimpleFC::AdvAddRule "Geth incoming peers (TCP:30303)" "" 6 1 1 2147483647 1 "$INSTDIR\geth.exe" "" "" "Ethereum" 30303 "" "" "" - SimpleFC::AdvAddRule "Geth outgoing peers (TCP:30303)" "" 6 2 1 2147483647 1 "$INSTDIR\geth.exe" "" "" "Ethereum" "" 30303 "" "" - SimpleFC::AdvAddRule "Geth UDP discovery (UDP:30303)" "" 17 2 1 2147483647 1 "$INSTDIR\geth.exe" "" "" "Ethereum" "" 30303 "" "" - - # Set default IPC endpoint (https://github.com/ethereum/EIPs/issues/147) - ${EnvVarUpdate} $0 "ETHEREUM_SOCKET" "R" "HKLM" "\\.\pipe\geth.ipc" - ${EnvVarUpdate} $0 "ETHEREUM_SOCKET" "A" "HKLM" "\\.\pipe\geth.ipc" - - # Add instdir to PATH - Push "$INSTDIR" - Call AddToPath -SectionEnd - -# Install optional develop tools. -Section /o "Development tools" DEV_TOOLS_IDX - SetOutPath $INSTDIR - {{range .DevTools}}file {{.}} - {{end}} -SectionEnd - -# Return on top of stack the total size (as DWORD) of the selected/installed sections. -Var GetInstalledSize.total -Function GetInstalledSize - StrCpy $GetInstalledSize.total 0 - - ${if} ${SectionIsSelected} ${GETH_IDX} - SectionGetSize ${GETH_IDX} $0 - IntOp $GetInstalledSize.total $GetInstalledSize.total + $0 - ${endif} - - ${if} ${SectionIsSelected} ${DEV_TOOLS_IDX} - SectionGetSize ${DEV_TOOLS_IDX} $0 - IntOp $GetInstalledSize.total $GetInstalledSize.total + $0 - ${endif} - - IntFmt $GetInstalledSize.total "0x%08X" $GetInstalledSize.total - Push $GetInstalledSize.total -FunctionEnd - -# Write registry, Windows uses these values in various tools such as add/remove program. -# PowerShell: Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, InstallLocation, InstallDate | Format-Table –AutoSize -function .onInstSuccess - # Save information in registry in HKEY_LOCAL_MACHINE branch, Windows add/remove functionality depends on this - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "DisplayName" "${GROUPNAME} - ${APPNAME} - ${DESCRIPTION}" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "UninstallString" "$\"$INSTDIR\uninstall.exe$\"" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "QuietUninstallString" "$\"$INSTDIR\uninstall.exe$\" /S" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "InstallLocation" "$INSTDIR" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "InstallDate" "${NOW}" - # Wait for Alex - #WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "DisplayIcon" "$\"$INSTDIR\logo.ico$\"" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "Publisher" "${GROUPNAME}" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "HelpLink" "${HELPURL}" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "URLUpdateInfo" "${UPDATEURL}" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "URLInfoAbout" "${ABOUTURL}" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "DisplayVersion" "${MAJORVERSION}.${MINORVERSION}.${BUILDVERSION}" - WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "VersionMajor" ${MAJORVERSION} - WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "VersionMinor" ${MINORVERSION} - # There is no option for modifying or repairing the install - WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "NoModify" 1 - WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "NoRepair" 1 - - Call GetInstalledSize - Pop $0 - WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "EstimatedSize" "$0" - - # Create uninstaller - writeUninstaller "$INSTDIR\uninstall.exe" -functionEnd - -Page components -Page directory -Page instfiles diff --git a/build/nsis.pathupdate.nsh b/build/nsis.pathupdate.nsh deleted file mode 100644 index f54b7e3e13..0000000000 --- a/build/nsis.pathupdate.nsh +++ /dev/null @@ -1,153 +0,0 @@ -!include "WinMessages.nsh" - -; see https://support.microsoft.com/en-us/kb/104011 -!define Environ 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"' -; HKEY_LOCAL_MACHINE = 0x80000002 - -; AddToPath - Appends dir to PATH -; (does not work on Win9x/ME) -; -; Usage: -; Push "dir" -; Call AddToPath -Function AddToPath - Exch $0 - Push $1 - Push $2 - Push $3 - Push $4 - - ; NSIS ReadRegStr returns empty string on string overflow - ; Native calls are used here to check actual length of PATH - ; $4 = RegOpenKey(HKEY_LOCAL_MACHINE, "SYSTEM\CurrentControlSet\Control\Session Manager\Environment", &$3) - System::Call "advapi32::RegOpenKey(i 0x80000002, t'SYSTEM\CurrentControlSet\Control\Session Manager\Environment', *i.r3) i.r4" - IntCmp $4 0 0 done done - - ; $4 = RegQueryValueEx($3, "PATH", (DWORD*)0, (DWORD*)0, &$1, ($2=NSIS_MAX_STRLEN, &$2)) - ; RegCloseKey($3) - System::Call "advapi32::RegQueryValueEx(i $3, t'PATH', i 0, i 0, t.r1, *i ${NSIS_MAX_STRLEN} r2) i.r4" - System::Call "advapi32::RegCloseKey(i $3)" - - IntCmp $4 234 0 +4 +4 ; $4 == ERROR_MORE_DATA - DetailPrint "AddToPath: original length $2 > ${NSIS_MAX_STRLEN}" - MessageBox MB_OK "PATH not updated, original length $2 > ${NSIS_MAX_STRLEN}" - Goto done - - IntCmp $4 0 +5 ; $4 != NO_ERROR - IntCmp $4 2 +3 ; $4 != ERROR_FILE_NOT_FOUND - DetailPrint "AddToPath: unexpected error code $4" - Goto done - StrCpy $1 "" - - ; Check if already in PATH - Push "$1;" - Push "$0;" - Call StrStr - Pop $2 - StrCmp $2 "" 0 done - Push "$1;" - Push "$0\;" - Call StrStr - Pop $2 - StrCmp $2 "" 0 done - - ; Prevent NSIS string overflow - StrLen $2 $0 - StrLen $3 $1 - IntOp $2 $2 + $3 - IntOp $2 $2 + 2 ; $2 = strlen(dir) + strlen(PATH) + sizeof(";") - IntCmp $2 ${NSIS_MAX_STRLEN} +4 +4 0 - DetailPrint "AddToPath: new length $2 > ${NSIS_MAX_STRLEN}" - MessageBox MB_OK "PATH not updated, new length $2 > ${NSIS_MAX_STRLEN}." - Goto done - - ; Append dir to PATH - DetailPrint "Add to PATH: $0" - StrCpy $2 $1 1 -1 - StrCmp $2 ";" 0 +2 - StrCpy $1 $1 -1 ; remove trailing ';' - StrCmp $1 "" +2 ; no leading ';' - StrCpy $0 "$1;$0" - - WriteRegExpandStr ${Environ} "PATH" $0 - SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000 - -done: - Pop $4 - Pop $3 - Pop $2 - Pop $1 - Pop $0 -FunctionEnd - - -; RemoveFromPath - Removes dir from PATH -; -; Usage: -; Push "dir" -; Call RemoveFromPath -Function un.RemoveFromPath - Exch $0 - Push $1 - Push $2 - Push $3 - Push $4 - Push $5 - Push $6 - - ; NSIS ReadRegStr returns empty string on string overflow - ; Native calls are used here to check actual length of PATH - ; $4 = RegOpenKey(HKEY_LOCAL_MACHINE, "SYSTEM\CurrentControlSet\Control\Session Manager\Environment", &$3) - System::Call "advapi32::RegOpenKey(i 0x80000002, t'SYSTEM\CurrentControlSet\Control\Session Manager\Environment', *i.r3) i.r4" - IntCmp $4 0 0 done done - - ; $4 = RegQueryValueEx($3, "PATH", (DWORD*)0, (DWORD*)0, &$1, ($2=NSIS_MAX_STRLEN, &$2)) - ; RegCloseKey($3) - System::Call "advapi32::RegQueryValueEx(i $3, t'PATH', i 0, i 0, t.r1, *i ${NSIS_MAX_STRLEN} r2) i.r4" - System::Call "advapi32::RegCloseKey(i $3)" - - IntCmp $4 234 0 +4 +4 ; $4 == ERROR_MORE_DATA - DetailPrint "RemoveFromPath: original length $2 > ${NSIS_MAX_STRLEN}" - MessageBox MB_OK "PATH not updated, original length $2 > ${NSIS_MAX_STRLEN}" - Goto done - - IntCmp $4 0 +5 ; $4 != NO_ERROR - IntCmp $4 2 +3 ; $4 != ERROR_FILE_NOT_FOUND - DetailPrint "RemoveFromPath: unexpected error code $4" - Goto done - StrCpy $1 "" - - ; length < ${NSIS_MAX_STRLEN} -> ReadRegStr can be used - ReadRegStr $1 ${Environ} "PATH" - StrCpy $5 $1 1 -1 - StrCmp $5 ";" +2 - StrCpy $1 "$1;" ; ensure trailing ';' - Push $1 - Push "$0;" - Call un.StrStr - Pop $2 ; pos of our dir - StrCmp $2 "" done - - DetailPrint "Remove from PATH: $0" - StrLen $3 "$0;" - StrLen $4 $2 - StrCpy $5 $1 -$4 ; $5 is now the part before the path to remove - StrCpy $6 $2 "" $3 ; $6 is now the part after the path to remove - StrCpy $3 "$5$6" - StrCpy $5 $3 1 -1 - StrCmp $5 ";" 0 +2 - StrCpy $3 $3 -1 ; remove trailing ';' - WriteRegExpandStr ${Environ} "PATH" $3 - SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000 - -done: - Pop $6 - Pop $5 - Pop $4 - Pop $3 - Pop $2 - Pop $1 - Pop $0 -FunctionEnd - - diff --git a/build/nsis.simplefc.dll b/build/nsis.simplefc.dll deleted file mode 100644 index 73b7d9634d..0000000000 Binary files a/build/nsis.simplefc.dll and /dev/null differ diff --git a/build/nsis.simplefc.source.zip b/build/nsis.simplefc.source.zip deleted file mode 100644 index d7476022ad..0000000000 Binary files a/build/nsis.simplefc.source.zip and /dev/null differ diff --git a/build/nsis.uninstall.nsh b/build/nsis.uninstall.nsh deleted file mode 100644 index 6358faa74e..0000000000 --- a/build/nsis.uninstall.nsh +++ /dev/null @@ -1,33 +0,0 @@ -Section "Uninstall" - # uninstall for all users - setShellVarContext all - - # Delete (optionally) installed files - {{range $}}Delete $INSTDIR\{{.}} - {{end}} - Delete $INSTDIR\uninstall.exe - - # Delete install directory - rmDir $INSTDIR - - # Delete start menu launcher - Delete "$SMPROGRAMS\${APPNAME}\${APPNAME}.lnk" - Delete "$SMPROGRAMS\${APPNAME}\Attach.lnk" - Delete "$SMPROGRAMS\${APPNAME}\Uninstall.lnk" - rmDir "$SMPROGRAMS\${APPNAME}" - - # Firewall - remove rules if exists - SimpleFC::AdvRemoveRule "Geth incoming peers (TCP:30303)" - SimpleFC::AdvRemoveRule "Geth outgoing peers (TCP:30303)" - SimpleFC::AdvRemoveRule "Geth UDP discovery (UDP:30303)" - - # Remove IPC endpoint (https://github.com/ethereum/EIPs/issues/147) - ${un.EnvVarUpdate} $0 "ETHEREUM_SOCKET" "R" "HKLM" "\\.\pipe\geth.ipc" - - # Remove install directory from PATH - Push "$INSTDIR" - Call un.RemoveFromPath - - # Cleanup registry (deletes all sub keys) - DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" -SectionEnd diff --git a/build/pod.podspec b/build/pod.podspec deleted file mode 100644 index 2c14c280c7..0000000000 --- a/build/pod.podspec +++ /dev/null @@ -1,22 +0,0 @@ -Pod::Spec.new do |spec| - spec.name = 'Geth' - spec.version = '{{.Version}}' - spec.license = { :type => 'GNU Lesser General Public License, Version 3.0' } - spec.homepage = 'https://github.com/ethereum/go-ethereum' - spec.authors = { {{range .Contributors}} - '{{.Name}}' => '{{.Email}}',{{end}} - } - spec.summary = 'iOS Ethereum Client' - spec.source = { :git => 'https://github.com/ethereum/go-ethereum.git', :commit => '{{.Commit}}' } - - spec.platform = :ios - spec.ios.deployment_target = '9.0' - spec.ios.vendored_frameworks = 'Frameworks/Geth.framework' - - spec.prepare_command = <<-CMD - curl https://gethstore.blob.core.windows.net/builds/{{.Archive}}.tar.gz | tar -xvz - mkdir Frameworks - mv {{.Archive}}/Geth.framework Frameworks - rm -rf {{.Archive}} - CMD -end diff --git a/build/update-license.go b/build/update-license.go deleted file mode 100644 index 22e4033428..0000000000 --- a/build/update-license.go +++ /dev/null @@ -1,395 +0,0 @@ -// +build none - -/* -This command generates GPL license headers on top of all source files. -You can run it once per month, before cutting a release or just -whenever you feel like it. - - go run update-license.go - -All authors (people who have contributed code) are listed in the -AUTHORS file. The author names are mapped and deduplicated using the -.mailmap file. You can use .mailmap to set the canonical name and -address for each author. See git-shortlog(1) for an explanation of the -.mailmap format. - -Please review the resulting diff to check whether the correct -copyright assignments are performed. -*/ - -package main - -import ( - "bufio" - "bytes" - "fmt" - "io/ioutil" - "log" - "os" - "os/exec" - "path/filepath" - "regexp" - "runtime" - "sort" - "strconv" - "strings" - "sync" - "text/template" - "time" -) - -var ( - // only files with these extensions will be considered - extensions = []string{".go", ".js", ".qml"} - - // paths with any of these prefixes will be skipped - skipPrefixes = []string{ - // boring stuff - "vendor/", "tests/testdata/", "build/", - // don't relicense vendored sources - "cmd/internal/browser", - "consensus/ethash/xor.go", - "crypto/bn256/", - "crypto/ecies/", - "crypto/secp256k1/curve.go", - "crypto/sha3/", - "internal/jsre/deps", - "log/", - "common/bitutil/bitutil", - // don't license generated files - "contracts/chequebook/contract/code.go", - } - - // paths with this prefix are licensed as GPL. all other files are LGPL. - gplPrefixes = []string{"cmd/"} - - // this regexp must match the entire license comment at the - // beginning of each file. - licenseCommentRE = regexp.MustCompile(`^//\s*(Copyright|This file is part of).*?\n(?://.*?\n)*\n*`) - - // this text appears at the start of AUTHORS - authorsFileHeader = "# This is the official list of go-ethereum authors for copyright purposes.\n\n" -) - -// this template generates the license comment. -// its input is an info structure. -var licenseT = template.Must(template.New("").Parse(` -// Copyright {{.Year}} The go-ethereum Authors -// This file is part of {{.Whole false}}. -// -// {{.Whole true}} is free software: you can redistribute it and/or modify -// it under the terms of the GNU {{.License}} as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// {{.Whole true}} is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU {{.License}} for more details. -// -// You should have received a copy of the GNU {{.License}} -// along with {{.Whole false}}. If not, see . - -`[1:])) - -type info struct { - file string - Year int64 -} - -func (i info) License() string { - if i.gpl() { - return "General Public License" - } - return "Lesser General Public License" -} - -func (i info) ShortLicense() string { - if i.gpl() { - return "GPL" - } - return "LGPL" -} - -func (i info) Whole(startOfSentence bool) string { - if i.gpl() { - return "go-ethereum" - } - if startOfSentence { - return "The go-ethereum library" - } - return "the go-ethereum library" -} - -func (i info) gpl() bool { - for _, p := range gplPrefixes { - if strings.HasPrefix(i.file, p) { - return true - } - } - return false -} - -func main() { - var ( - files = getFiles() - filec = make(chan string) - infoc = make(chan *info, 20) - wg sync.WaitGroup - ) - - writeAuthors(files) - - go func() { - for _, f := range files { - filec <- f - } - close(filec) - }() - for i := runtime.NumCPU(); i >= 0; i-- { - // getting file info is slow and needs to be parallel. - // it traverses git history for each file. - wg.Add(1) - go getInfo(filec, infoc, &wg) - } - go func() { - wg.Wait() - close(infoc) - }() - writeLicenses(infoc) -} - -func skipFile(path string) bool { - if strings.Contains(path, "/testdata/") { - return true - } - for _, p := range skipPrefixes { - if strings.HasPrefix(path, p) { - return true - } - } - return false -} - -func getFiles() []string { - cmd := exec.Command("git", "ls-tree", "-r", "--name-only", "HEAD") - var files []string - err := doLines(cmd, func(line string) { - if skipFile(line) { - return - } - ext := filepath.Ext(line) - for _, wantExt := range extensions { - if ext == wantExt { - goto keep - } - } - return - keep: - files = append(files, line) - }) - if err != nil { - log.Fatal("error getting files:", err) - } - return files -} - -var authorRegexp = regexp.MustCompile(`\s*[0-9]+\s*(.*)`) - -func gitAuthors(files []string) []string { - cmds := []string{"shortlog", "-s", "-n", "-e", "HEAD", "--"} - cmds = append(cmds, files...) - cmd := exec.Command("git", cmds...) - var authors []string - err := doLines(cmd, func(line string) { - m := authorRegexp.FindStringSubmatch(line) - if len(m) > 1 { - authors = append(authors, m[1]) - } - }) - if err != nil { - log.Fatalln("error getting authors:", err) - } - return authors -} - -func readAuthors() []string { - content, err := ioutil.ReadFile("AUTHORS") - if err != nil && !os.IsNotExist(err) { - log.Fatalln("error reading AUTHORS:", err) - } - var authors []string - for _, a := range bytes.Split(content, []byte("\n")) { - if len(a) > 0 && a[0] != '#' { - authors = append(authors, string(a)) - } - } - // Retranslate existing authors through .mailmap. - // This should catch email address changes. - authors = mailmapLookup(authors) - return authors -} - -func mailmapLookup(authors []string) []string { - if len(authors) == 0 { - return nil - } - cmds := []string{"check-mailmap", "--"} - cmds = append(cmds, authors...) - cmd := exec.Command("git", cmds...) - var translated []string - err := doLines(cmd, func(line string) { - translated = append(translated, line) - }) - if err != nil { - log.Fatalln("error translating authors:", err) - } - return translated -} - -func writeAuthors(files []string) { - merge := make(map[string]bool) - // Add authors that Git reports as contributorxs. - // This is the primary source of author information. - for _, a := range gitAuthors(files) { - merge[a] = true - } - // Add existing authors from the file. This should ensure that we - // never lose authors, even if Git stops listing them. We can also - // add authors manually this way. - for _, a := range readAuthors() { - merge[a] = true - } - // Write sorted list of authors back to the file. - var result []string - for a := range merge { - result = append(result, a) - } - sort.Strings(result) - content := new(bytes.Buffer) - content.WriteString(authorsFileHeader) - for _, a := range result { - content.WriteString(a) - content.WriteString("\n") - } - fmt.Println("writing AUTHORS") - if err := ioutil.WriteFile("AUTHORS", content.Bytes(), 0644); err != nil { - log.Fatalln(err) - } -} - -func getInfo(files <-chan string, out chan<- *info, wg *sync.WaitGroup) { - for file := range files { - stat, err := os.Lstat(file) - if err != nil { - fmt.Printf("ERROR %s: %v\n", file, err) - continue - } - if !stat.Mode().IsRegular() { - continue - } - if isGenerated(file) { - continue - } - info, err := fileInfo(file) - if err != nil { - fmt.Printf("ERROR %s: %v\n", file, err) - continue - } - out <- info - } - wg.Done() -} - -func isGenerated(file string) bool { - fd, err := os.Open(file) - if err != nil { - return false - } - defer fd.Close() - buf := make([]byte, 2048) - n, _ := fd.Read(buf) - buf = buf[:n] - for _, l := range bytes.Split(buf, []byte("\n")) { - if bytes.HasPrefix(l, []byte("// Code generated")) { - return true - } - } - return false -} - -// fileInfo finds the lowest year in which the given file was committed. -func fileInfo(file string) (*info, error) { - info := &info{file: file, Year: int64(time.Now().Year())} - cmd := exec.Command("git", "log", "--follow", "--find-renames=80", "--find-copies=80", "--pretty=format:%ai", "--", file) - err := doLines(cmd, func(line string) { - y, err := strconv.ParseInt(line[:4], 10, 64) - if err != nil { - fmt.Printf("cannot parse year: %q", line[:4]) - } - if y < info.Year { - info.Year = y - } - }) - return info, err -} - -func writeLicenses(infos <-chan *info) { - for i := range infos { - writeLicense(i) - } -} - -func writeLicense(info *info) { - fi, err := os.Stat(info.file) - if os.IsNotExist(err) { - fmt.Println("skipping (does not exist)", info.file) - return - } - if err != nil { - log.Fatalf("error stat'ing %s: %v\n", info.file, err) - } - content, err := ioutil.ReadFile(info.file) - if err != nil { - log.Fatalf("error reading %s: %v\n", info.file, err) - } - // Construct new file content. - buf := new(bytes.Buffer) - licenseT.Execute(buf, info) - if m := licenseCommentRE.FindIndex(content); m != nil && m[0] == 0 { - buf.Write(content[:m[0]]) - buf.Write(content[m[1]:]) - } else { - buf.Write(content) - } - // Write it to the file. - if bytes.Equal(content, buf.Bytes()) { - fmt.Println("skipping (no changes)", info.file) - return - } - fmt.Println("writing", info.ShortLicense(), info.file) - if err := ioutil.WriteFile(info.file, buf.Bytes(), fi.Mode()); err != nil { - log.Fatalf("error writing %s: %v", info.file, err) - } -} - -func doLines(cmd *exec.Cmd, f func(string)) error { - stdout, err := cmd.StdoutPipe() - if err != nil { - return err - } - if err := cmd.Start(); err != nil { - return err - } - s := bufio.NewScanner(stdout) - for s.Scan() { - f(s.Text()) - } - if s.Err() != nil { - return s.Err() - } - if err := cmd.Wait(); err != nil { - return fmt.Errorf("%v (for %s)", err, strings.Join(cmd.Args, " ")) - } - return nil -} diff --git a/cmd/puppeth/wizard_genesis.go b/cmd/puppeth/wizard_genesis.go index 5b2706f6d6..ac7b1f175d 100644 --- a/cmd/puppeth/wizard_genesis.go +++ b/cmd/puppeth/wizard_genesis.go @@ -118,6 +118,10 @@ func (w *wizard) makeGenesis() { genesis.Config.Clique.Epoch = uint64(w.readDefaultInt(990)) genesis.Config.Clique.RewardCheckpoint = genesis.Config.Clique.Epoch + fmt.Println() + fmt.Println("How many blocks before checkpoint need to prepare new set of masternodes? (default = 50)") + genesis.Config.Clique.Gap = uint64(w.readDefaultInt(50)) + case choice == "3": genesis.Difficulty = big.NewInt(1) genesis.Config.Clique = ¶ms.CliqueConfig{ @@ -169,10 +173,14 @@ func (w *wizard) makeGenesis() { } fmt.Println() - fmt.Println("How many blocks per checkpoint? (default = 990)") + fmt.Println("How many blocks per epoch? (default = 990)") epochNumber := w.readDefaultInt(990) genesis.Config.Clique.RewardCheckpoint = uint64(epochNumber) + fmt.Println() + fmt.Println("How many blocks before checkpoint need to prepare new set of masternodes? (default = 50)") + genesis.Config.Clique.Gap = uint64(w.readDefaultInt(50)) + // Validator Smart Contract Code pKey, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") addr := crypto.PubkeyToAddress(pKey.PublicKey) diff --git a/contracts/validator/contract/TomoValidator.sol b/contracts/validator/contract/TomoValidator.sol index a518565843..03e205694e 100644 --- a/contracts/validator/contract/TomoValidator.sol +++ b/contracts/validator/contract/TomoValidator.sol @@ -9,12 +9,12 @@ contract TomoValidator { event Unvote(address _voter, address _candidate, uint256 _cap); event Propose(address _owner, address _candidate, uint256 _cap); event Resign(address _owner, address _candidate); - event SetNodeUrl(address _owner, address _candidate, string _nodeUrl); + event SetNodeId(address _owner, address _candidate, string _nodeId); event Withdraw(address _owner, uint256 _blockNumber, uint256 _cap); struct ValidatorState { address owner; - string nodeUrl; + string nodeId; bool isCandidate; uint256 cap; mapping(address => uint256) voters; @@ -94,7 +94,7 @@ contract TomoValidator { candidates.push(_candidates[i]); validatorsState[_candidates[i]] = ValidatorState({ owner: _firstOwner, - nodeUrl: '', + nodeId: '', isCandidate: true, cap: _caps[i] }); @@ -103,11 +103,11 @@ contract TomoValidator { } } - function propose(address _candidate, string _nodeUrl) external payable onlyValidCandidateCap onlyNotCandidate(_candidate) { + function propose(address _candidate, string _nodeId) external payable onlyValidCandidateCap onlyNotCandidate(_candidate) { candidates.push(_candidate); validatorsState[_candidate] = ValidatorState({ owner: msg.sender, - nodeUrl: _nodeUrl, + nodeId: _nodeId, isCandidate: true, cap: msg.value }); @@ -134,8 +134,8 @@ contract TomoValidator { return validatorsState[_candidate].cap; } - function getCandidateNodeUrl(address _candidate) public view returns(string) { - return validatorsState[_candidate].nodeUrl; + function getCandidateNodeId(address _candidate) public view returns(string) { + return validatorsState[_candidate].nodeId; } function getCandidateOwner(address _candidate) public view returns(address) { @@ -170,9 +170,9 @@ contract TomoValidator { emit Unvote(msg.sender, _candidate, _cap); } - function setNodeUrl(address _candidate, string _nodeUrl) public onlyOwner(_candidate) { - validatorsState[_candidate].nodeUrl = _nodeUrl; - emit SetNodeUrl(msg.sender, _candidate, _nodeUrl); + function setNodeId(address _candidate, string _nodeId) public onlyOwner(_candidate) { + validatorsState[_candidate].nodeId = _nodeId; + emit SetNodeId(msg.sender, _candidate, _nodeId); } function resign(address _candidate) public onlyOwner(_candidate) onlyCandidate(_candidate) { diff --git a/contracts/validator/contract/validator.go b/contracts/validator/contract/validator.go index 67be0eaeb4..f17c62da35 100644 --- a/contracts/validator/contract/validator.go +++ b/contracts/validator/contract/validator.go @@ -177,10 +177,10 @@ func (_SafeMath *SafeMathTransactorRaw) Transact(opts *bind.TransactOpts, method } // TomoValidatorABI is the input ABI used to generate the binding from. -const TomoValidatorABI = "[{\"constant\":false,\"inputs\":[{\"name\":\"_candidate\",\"type\":\"address\"},{\"name\":\"_cap\",\"type\":\"uint256\"}],\"name\":\"unvote\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"getCandidates\",\"outputs\":[{\"name\":\"\",\"type\":\"address[]\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_candidate\",\"type\":\"address\"}],\"name\":\"getVoters\",\"outputs\":[{\"name\":\"\",\"type\":\"address[]\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"getWithdrawBlockNumbers\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256[]\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_candidate\",\"type\":\"address\"},{\"name\":\"_voter\",\"type\":\"address\"}],\"name\":\"getVoterCap\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"candidates\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_blockNumber\",\"type\":\"uint256\"},{\"name\":\"_index\",\"type\":\"uint256\"}],\"name\":\"withdraw\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_candidate\",\"type\":\"address\"}],\"name\":\"getCandidateCap\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_candidate\",\"type\":\"address\"}],\"name\":\"vote\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_candidate\",\"type\":\"address\"},{\"name\":\"_nodeUrl\",\"type\":\"string\"}],\"name\":\"setNodeUrl\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"candidateCount\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"voterWithdrawDelay\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_candidate\",\"type\":\"address\"}],\"name\":\"resign\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_candidate\",\"type\":\"address\"}],\"name\":\"getCandidateOwner\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"maxValidatorNumber\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"candidateWithdrawDelay\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_candidate\",\"type\":\"address\"}],\"name\":\"isCandidate\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"minCandidateCap\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_candidate\",\"type\":\"address\"},{\"name\":\"_nodeUrl\",\"type\":\"string\"}],\"name\":\"propose\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_candidate\",\"type\":\"address\"}],\"name\":\"getCandidateNodeUrl\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"name\":\"_candidates\",\"type\":\"address[]\"},{\"name\":\"_caps\",\"type\":\"uint256[]\"},{\"name\":\"_firstOwner\",\"type\":\"address\"},{\"name\":\"_minCandidateCap\",\"type\":\"uint256\"},{\"name\":\"_maxValidatorNumber\",\"type\":\"uint256\"},{\"name\":\"_candidateWithdrawDelay\",\"type\":\"uint256\"},{\"name\":\"_voterWithdrawDelay\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"_voter\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"_candidate\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"_cap\",\"type\":\"uint256\"}],\"name\":\"Vote\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"_voter\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"_candidate\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"_cap\",\"type\":\"uint256\"}],\"name\":\"Unvote\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"_owner\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"_candidate\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"_cap\",\"type\":\"uint256\"}],\"name\":\"Propose\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"_owner\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"_candidate\",\"type\":\"address\"}],\"name\":\"Resign\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"_owner\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"_candidate\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"_nodeUrl\",\"type\":\"string\"}],\"name\":\"SetNodeUrl\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"_owner\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"_blockNumber\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"_cap\",\"type\":\"uint256\"}],\"name\":\"Withdraw\",\"type\":\"event\"}]" +const TomoValidatorABI = "[{\"constant\":false,\"inputs\":[{\"name\":\"_candidate\",\"type\":\"address\"},{\"name\":\"_cap\",\"type\":\"uint256\"}],\"name\":\"unvote\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"getCandidates\",\"outputs\":[{\"name\":\"\",\"type\":\"address[]\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_candidate\",\"type\":\"address\"}],\"name\":\"getVoters\",\"outputs\":[{\"name\":\"\",\"type\":\"address[]\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"getWithdrawBlockNumbers\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256[]\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_candidate\",\"type\":\"address\"},{\"name\":\"_voter\",\"type\":\"address\"}],\"name\":\"getVoterCap\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"candidates\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_blockNumber\",\"type\":\"uint256\"},{\"name\":\"_index\",\"type\":\"uint256\"}],\"name\":\"withdraw\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_candidate\",\"type\":\"address\"}],\"name\":\"getCandidateCap\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_candidate\",\"type\":\"address\"},{\"name\":\"_nodeId\",\"type\":\"string\"}],\"name\":\"setNodeId\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_candidate\",\"type\":\"address\"}],\"name\":\"vote\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_candidate\",\"type\":\"address\"}],\"name\":\"getCandidateNodeId\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"candidateCount\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"voterWithdrawDelay\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_candidate\",\"type\":\"address\"}],\"name\":\"resign\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_candidate\",\"type\":\"address\"}],\"name\":\"getCandidateOwner\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"maxValidatorNumber\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"candidateWithdrawDelay\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_candidate\",\"type\":\"address\"}],\"name\":\"isCandidate\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"minCandidateCap\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_candidate\",\"type\":\"address\"},{\"name\":\"_nodeId\",\"type\":\"string\"}],\"name\":\"propose\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"name\":\"_candidates\",\"type\":\"address[]\"},{\"name\":\"_caps\",\"type\":\"uint256[]\"},{\"name\":\"_firstOwner\",\"type\":\"address\"},{\"name\":\"_minCandidateCap\",\"type\":\"uint256\"},{\"name\":\"_maxValidatorNumber\",\"type\":\"uint256\"},{\"name\":\"_candidateWithdrawDelay\",\"type\":\"uint256\"},{\"name\":\"_voterWithdrawDelay\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"_voter\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"_candidate\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"_cap\",\"type\":\"uint256\"}],\"name\":\"Vote\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"_voter\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"_candidate\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"_cap\",\"type\":\"uint256\"}],\"name\":\"Unvote\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"_owner\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"_candidate\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"_cap\",\"type\":\"uint256\"}],\"name\":\"Propose\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"_owner\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"_candidate\",\"type\":\"address\"}],\"name\":\"Resign\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"_owner\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"_candidate\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"_nodeId\",\"type\":\"string\"}],\"name\":\"SetNodeId\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"_owner\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"_blockNumber\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"_cap\",\"type\":\"uint256\"}],\"name\":\"Withdraw\",\"type\":\"event\"}]" // TomoValidatorBin is the compiled bytecode used for deploying new contracts. -const TomoValidatorBin = `0x6060604052600360045534156200001557600080fd5b604051620016af380380620016af833981016040528080518201919060200180518201919060200180519190602001805191906020018051919060200180519190602001805160058690556006859055600784905560088190559150600090505b87518110156200028757600380546001810162000094838262000295565b916000526020600020900160008a8481518110620000ae57fe5b90602001906020020151909190916101000a815481600160a060020a030219169083600160a060020a031602179055505060806040519081016040528087600160a060020a03168152602001602060405190810160409081526000825290825260016020830152018883815181106200012357fe5b906020019060200201519052600160008a84815181106200014057fe5b90602001906020020151600160a060020a03168152602081019190915260400160002081518154600160a060020a031916600160a060020a03919091161781556020820151816001019080516200019c929160200190620002c1565b50604082015160028201805460ff191691151591909117905560608201516003909101555060026000898381518110620001d257fe5b90602001906020020151600160a060020a03168152602081019190915260400160002080546001810162000207838262000295565b50600091825260208220018054600160a060020a031916600160a060020a038916179055600554600380549192600192909190859081106200024557fe5b6000918252602080832090910154600160a060020a0390811684528382019490945260409283018220938b168252600490930190925290205560010162000076565b505050505050505062000366565b815481835581811511620002bc57600083815260209020620002bc91810190830162000346565b505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106200030457805160ff191683800117855562000334565b8280016001018555821562000334579182015b828111156200033457825182559160200191906001019062000317565b506200034292915062000346565b5090565b6200036391905b808211156200034257600081556001016200034d565b90565b61133980620003766000396000f3006060604052600436106101115763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166302aa9be2811461011657806306a49fce1461013a5780632d15cc04146101a05780632f9c4bba146101bf578063302b6872146101d25780633477ee2e14610209578063441a3e701461023b57806358e7525f146102545780636dd7d8ea14610273578063a3ec796514610287578063a9a981a3146102e6578063a9ff959e146102f9578063ae6e43f51461030c578063b642facd1461032b578063d09f1ab41461034a578063d161c7671461035d578063d51b9e9314610370578063d55b7dff146103a3578063d6f0948c146103b6578063da67b599146103d6575b600080fd5b341561012157600080fd5b610138600160a060020a036004351660243561046c565b005b341561014557600080fd5b61014d610634565b60405160208082528190810183818151815260200191508051906020019060200280838360005b8381101561018c578082015183820152602001610174565b505050509050019250505060405180910390f35b34156101ab57600080fd5b61014d600160a060020a036004351661069d565b34156101ca57600080fd5b61014d61072a565b34156101dd57600080fd5b6101f7600160a060020a03600435811690602435166107ac565b60405190815260200160405180910390f35b341561021457600080fd5b61021f6004356107db565b604051600160a060020a03909116815260200160405180910390f35b341561024657600080fd5b610138600435602435610803565b341561025f57600080fd5b6101f7600160a060020a036004351661096a565b610138600160a060020a0360043516610988565b341561029257600080fd5b61013860048035600160a060020a03169060446024803590810190830135806020601f82018190048102016040519081016040528181529291906020840183838082843750949650610b3595505050505050565b34156102f157600080fd5b6101f7610c46565b341561030457600080fd5b6101f7610c4c565b341561031757600080fd5b610138600160a060020a0360043516610c52565b341561033657600080fd5b61021f600160a060020a0360043516610ec5565b341561035557600080fd5b6101f7610ee3565b341561036857600080fd5b6101f7610ee9565b341561037b57600080fd5b61038f600160a060020a0360043516610eef565b604051901515815260200160405180910390f35b34156103ae57600080fd5b6101f7610f10565b61013860048035600160a060020a03169060248035908101910135610f16565b34156103e157600080fd5b6103f5600160a060020a036004351661114c565b60405160208082528190810183818151815260200191508051906020019080838360005b83811015610431578082015183820152602001610419565b50505050905090810190601f16801561045e5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b600160a060020a038083166000908152600160209081526040808320339094168352600490930190529081205483908390819010156104aa57600080fd5b600160a060020a0385166000908152600160205260409020600301546104d6908563ffffffff61121216565b600160a060020a0380871660009081526001602090815260408083206003810195909555339093168252600490930190925290205461051b908563ffffffff61121216565b600160a060020a038087166000908152600160209081526040808320339094168352600490930190522055600854610559904363ffffffff61122416565b600160a060020a03331660009081526020818152604080832084845290915290205490935061058e908563ffffffff61122416565b600160a060020a03331660008181526020818152604080832088845280835290832094909455918152905260019081018054909181016105ce838261123a565b5060009182526020909120018390557faa0e554f781c3c3b2be110a0557f260f11af9a8aa2c64bc1e7a31dbb21e32fa2338686604051600160a060020a039384168152919092166020820152604080820192909252606001905180910390a15050505050565b61063c611263565b600380548060200260200160405190810160405280929190818152602001828054801561069257602002820191906000526020600020905b8154600160a060020a03168152600190910190602001808311610674575b505050505090505b90565b6106a5611263565b6002600083600160a060020a0316600160a060020a0316815260200190815260200160002080548060200260200160405190810160405280929190818152602001828054801561071e57602002820191906000526020600020905b8154600160a060020a03168152600190910190602001808311610700575b50505050509050919050565b610732611263565b60008033600160a060020a0316600160a060020a0316815260200190815260200160002060010180548060200260200160405190810160405280929190818152602001828054801561069257602002820191906000526020600020905b81548152602001906001019080831161078f575050505050905090565b600160a060020a0391821660009081526001602090815260408083209390941682526004909201909152205490565b60038054829081106107e957fe5b600091825260209091200154600160a060020a0316905081565b6000828282821161081357600080fd5b438290101561082157600080fd5b600160a060020a0333166000908152602081815260408083208584529091528120541161084d57600080fd5b600160a060020a033316600090815260208190526040902060010180548391908390811061087757fe5b6000918252602090912001541461088d57600080fd5b600160a060020a033316600081815260208181526040808320898452808352908320805490849055938352919052600101805491945090859081106108ce57fe5b6000918252602082200155600160a060020a03331683156108fc0284604051600060405180830381858888f19350505050151561090a57600080fd5b7ff279e6a1f5e320cca91135676d9cb6e44ca8a08c0b88342bcdb1144f6511b5683386856040518084600160a060020a0316600160a060020a03168152602001838152602001828152602001935050505060405180910390a15050505050565b600160a060020a031660009081526001602052604090206003015490565b600160a060020a038116600090815260016020526040902060020154819060ff1615156109b457600080fd5b600160a060020a0382166000908152600160205260409020600301546109e0903463ffffffff61122416565b600160a060020a038084166000908152600160209081526040808320600381019590955533909316825260049093019092529020541515610a7657600160a060020a0382166000908152600260205260409020805460018101610a43838261123a565b506000918252602090912001805473ffffffffffffffffffffffffffffffffffffffff191633600160a060020a03161790555b600160a060020a038083166000908152600160209081526040808320339094168352600490930190522054610ab1903463ffffffff61122416565b600160a060020a03808416600090815260016020908152604080832033948516845260040190915290819020929092557f66a9138482c99e9baf08860110ef332cc0c23b4a199a53593d8db0fc8f96fbfc918490349051600160a060020a039384168152919092166020820152604080820192909252606001905180910390a15050565b600160a060020a038281166000908152600160205260409020548391338116911614610b6057600080fd5b600160a060020a038316600090815260016020819052604090912001828051610b8d929160200190611275565b507f63f303264cd4b7a198f0163f96e0b6b1f972f9b73359a70c44241b862879d8a4338484604051600160a060020a0380851682528316602082015260606040820181815290820183818151815260200191508051906020019080838360005b83811015610c05578082015183820152602001610bed565b50505050905090810190601f168015610c325780820380516001836020036101000a031916815260200191505b5094505050505060405180910390a1505050565b60045481565b60085481565b600160a060020a038181166000908152600160205260408120549091829182918591338216911614610c8357600080fd5b600160a060020a038516600090815260016020526040902060020154859060ff161515610caf57600080fd5b600160a060020a0386166000908152600160205260408120600201805460ff191690556004805460001901905594505b600354851015610d615785600160a060020a0316600386815481101515610d0257fe5b600091825260209091200154600160a060020a03161415610d56576003805486908110610d2b57fe5b6000918252602090912001805473ffffffffffffffffffffffffffffffffffffffff19169055610d61565b600190940193610cdf565b600160a060020a038087166000818152600160208181526040808420339096168452600486018252832054939092529052600390910154909450610dab908563ffffffff61121216565b600160a060020a03808816600090815260016020908152604080832060038101959095553390931682526004909301909252812055600754610df3904363ffffffff61122416565b600160a060020a033316600090815260208181526040808320848452909152902054909350610e28908563ffffffff61122416565b600160a060020a0333166000818152602081815260408083208884528083529083209490945591815290526001908101805490918101610e68838261123a565b5060009182526020909120018390557f4edf3e325d0063213a39f9085522994a1c44bea5f39e7d63ef61260a1e58c6d33387604051600160a060020a039283168152911660208201526040908101905180910390a1505050505050565b600160a060020a039081166000908152600160205260409020541690565b60065481565b60075481565b600160a060020a031660009081526001602052604090206002015460ff1690565b60055481565b600554341015610f2557600080fd5b600160a060020a038316600090815260016020526040902060020154839060ff1615610f5057600080fd5b6003805460018101610f62838261123a565b506000918252602090912001805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03861617905560806040519081016040528033600160a060020a0316815260200184848080601f016020809104026020016040519081016040528181529291906020840183838082843750505092845250506001602080840182905234604094850152600160a060020a03891660009081529190529190912090508151815473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a039190911617815560208201518160010190805161104d929160200190611275565b50604082015160028201805460ff1916911515919091179055606082015160039091015550600160a060020a03808516600081815260016020818152604080842033909616845260049586018252808420349055855483019095559282526002909252919091208054909181016110c4838261123a565b506000918252602090912001805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0386161790557f7635f1d87b47fba9f2b09e56eb4be75cca030e0cb179c1602ac9261d39a8f5c1338534604051600160a060020a039384168152919092166020820152604080820192909252606001905180910390a150505050565b611154611263565b6001600083600160a060020a0316600160a060020a031681526020019081526020016000206001018054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561071e5780601f106111e55761010080835404028352916020019161071e565b820191906000526020600020905b8154815290600101906020018083116111f35750939695505050505050565b60008282111561121e57fe5b50900390565b60008282018381101561123357fe5b9392505050565b81548183558181151161125e5760008381526020902061125e9181019083016112f3565b505050565b60206040519081016040526000815290565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106112b657805160ff19168380011785556112e3565b828001600101855582156112e3579182015b828111156112e35782518255916020019190600101906112c8565b506112ef9291506112f3565b5090565b61069a91905b808211156112ef57600081556001016112f95600a165627a7a72305820f127973d29fa5a4d12a54a58f7c375498148977e320761f9cefa40f5ea2afa680029` +const TomoValidatorBin = `0x6060604052600360045534156200001557600080fd5b604051620016af380380620016af833981016040528080518201919060200180518201919060200180519190602001805191906020018051919060200180519190602001805160058690556006859055600784905560088190559150600090505b87518110156200028757600380546001810162000094838262000295565b916000526020600020900160008a8481518110620000ae57fe5b90602001906020020151909190916101000a815481600160a060020a030219169083600160a060020a031602179055505060806040519081016040528087600160a060020a03168152602001602060405190810160409081526000825290825260016020830152018883815181106200012357fe5b906020019060200201519052600160008a84815181106200014057fe5b90602001906020020151600160a060020a03168152602081019190915260400160002081518154600160a060020a031916600160a060020a03919091161781556020820151816001019080516200019c929160200190620002c1565b50604082015160028201805460ff191691151591909117905560608201516003909101555060026000898381518110620001d257fe5b90602001906020020151600160a060020a03168152602081019190915260400160002080546001810162000207838262000295565b50600091825260208220018054600160a060020a031916600160a060020a038916179055600554600380549192600192909190859081106200024557fe5b6000918252602080832090910154600160a060020a0390811684528382019490945260409283018220938b168252600490930190925290205560010162000076565b505050505050505062000366565b815481835581811511620002bc57600083815260209020620002bc91810190830162000346565b505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106200030457805160ff191683800117855562000334565b8280016001018555821562000334579182015b828111156200033457825182559160200191906001019062000317565b506200034292915062000346565b5090565b6200036391905b808211156200034257600081556001016200034d565b90565b61133980620003766000396000f3006060604052600436106101115763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166302aa9be2811461011657806306a49fce1461013a5780632d15cc04146101a05780632f9c4bba146101bf578063302b6872146101d25780633477ee2e14610209578063441a3e701461023b57806358e7525f146102545780636a000d74146102735780636dd7d8ea146102d25780637d40257f146102e6578063a9a981a31461037c578063a9ff959e1461038f578063ae6e43f5146103a2578063b642facd146103c1578063d09f1ab4146103e0578063d161c767146103f3578063d51b9e9314610406578063d55b7dff14610439578063d6f0948c1461044c575b600080fd5b341561012157600080fd5b610138600160a060020a036004351660243561046c565b005b341561014557600080fd5b61014d610634565b60405160208082528190810183818151815260200191508051906020019060200280838360005b8381101561018c578082015183820152602001610174565b505050509050019250505060405180910390f35b34156101ab57600080fd5b61014d600160a060020a036004351661069d565b34156101ca57600080fd5b61014d61072a565b34156101dd57600080fd5b6101f7600160a060020a03600435811690602435166107ac565b60405190815260200160405180910390f35b341561021457600080fd5b61021f6004356107db565b604051600160a060020a03909116815260200160405180910390f35b341561024657600080fd5b610138600435602435610803565b341561025f57600080fd5b6101f7600160a060020a036004351661096a565b341561027e57600080fd5b61013860048035600160a060020a03169060446024803590810190830135806020601f8201819004810201604051908101604052818152929190602084018383808284375094965061098895505050505050565b610138600160a060020a0360043516610a99565b34156102f157600080fd5b610305600160a060020a0360043516610c46565b60405160208082528190810183818151815260200191508051906020019080838360005b83811015610341578082015183820152602001610329565b50505050905090810190601f16801561036e5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561038757600080fd5b6101f7610d0c565b341561039a57600080fd5b6101f7610d12565b34156103ad57600080fd5b610138600160a060020a0360043516610d18565b34156103cc57600080fd5b61021f600160a060020a0360043516610f8b565b34156103eb57600080fd5b6101f7610fa9565b34156103fe57600080fd5b6101f7610faf565b341561041157600080fd5b610425600160a060020a0360043516610fb5565b604051901515815260200160405180910390f35b341561044457600080fd5b6101f7610fd6565b61013860048035600160a060020a03169060248035908101910135610fdc565b600160a060020a038083166000908152600160209081526040808320339094168352600490930190529081205483908390819010156104aa57600080fd5b600160a060020a0385166000908152600160205260409020600301546104d6908563ffffffff61121216565b600160a060020a0380871660009081526001602090815260408083206003810195909555339093168252600490930190925290205461051b908563ffffffff61121216565b600160a060020a038087166000908152600160209081526040808320339094168352600490930190522055600854610559904363ffffffff61122416565b600160a060020a03331660009081526020818152604080832084845290915290205490935061058e908563ffffffff61122416565b600160a060020a03331660008181526020818152604080832088845280835290832094909455918152905260019081018054909181016105ce838261123a565b5060009182526020909120018390557faa0e554f781c3c3b2be110a0557f260f11af9a8aa2c64bc1e7a31dbb21e32fa2338686604051600160a060020a039384168152919092166020820152604080820192909252606001905180910390a15050505050565b61063c611263565b600380548060200260200160405190810160405280929190818152602001828054801561069257602002820191906000526020600020905b8154600160a060020a03168152600190910190602001808311610674575b505050505090505b90565b6106a5611263565b6002600083600160a060020a0316600160a060020a0316815260200190815260200160002080548060200260200160405190810160405280929190818152602001828054801561071e57602002820191906000526020600020905b8154600160a060020a03168152600190910190602001808311610700575b50505050509050919050565b610732611263565b60008033600160a060020a0316600160a060020a0316815260200190815260200160002060010180548060200260200160405190810160405280929190818152602001828054801561069257602002820191906000526020600020905b81548152602001906001019080831161078f575050505050905090565b600160a060020a0391821660009081526001602090815260408083209390941682526004909201909152205490565b60038054829081106107e957fe5b600091825260209091200154600160a060020a0316905081565b6000828282821161081357600080fd5b438290101561082157600080fd5b600160a060020a0333166000908152602081815260408083208584529091528120541161084d57600080fd5b600160a060020a033316600090815260208190526040902060010180548391908390811061087757fe5b6000918252602090912001541461088d57600080fd5b600160a060020a033316600081815260208181526040808320898452808352908320805490849055938352919052600101805491945090859081106108ce57fe5b6000918252602082200155600160a060020a03331683156108fc0284604051600060405180830381858888f19350505050151561090a57600080fd5b7ff279e6a1f5e320cca91135676d9cb6e44ca8a08c0b88342bcdb1144f6511b5683386856040518084600160a060020a0316600160a060020a03168152602001838152602001828152602001935050505060405180910390a15050505050565b600160a060020a031660009081526001602052604090206003015490565b600160a060020a0382811660009081526001602052604090205483913381169116146109b357600080fd5b600160a060020a0383166000908152600160208190526040909120018280516109e0929160200190611275565b507f0e421c04ccd34fafbe77c6b2f9384de8c5c4795114325fedb698a6ce62b2d744338484604051600160a060020a0380851682528316602082015260606040820181815290820183818151815260200191508051906020019080838360005b83811015610a58578082015183820152602001610a40565b50505050905090810190601f168015610a855780820380516001836020036101000a031916815260200191505b5094505050505060405180910390a1505050565b600160a060020a038116600090815260016020526040902060020154819060ff161515610ac557600080fd5b600160a060020a038216600090815260016020526040902060030154610af1903463ffffffff61122416565b600160a060020a038084166000908152600160209081526040808320600381019590955533909316825260049093019092529020541515610b8757600160a060020a0382166000908152600260205260409020805460018101610b54838261123a565b506000918252602090912001805473ffffffffffffffffffffffffffffffffffffffff191633600160a060020a03161790555b600160a060020a038083166000908152600160209081526040808320339094168352600490930190522054610bc2903463ffffffff61122416565b600160a060020a03808416600090815260016020908152604080832033948516845260040190915290819020929092557f66a9138482c99e9baf08860110ef332cc0c23b4a199a53593d8db0fc8f96fbfc918490349051600160a060020a039384168152919092166020820152604080820192909252606001905180910390a15050565b610c4e611263565b6001600083600160a060020a0316600160a060020a031681526020019081526020016000206001018054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561071e5780601f10610cdf5761010080835404028352916020019161071e565b820191906000526020600020905b815481529060010190602001808311610ced5750939695505050505050565b60045481565b60085481565b600160a060020a038181166000908152600160205260408120549091829182918591338216911614610d4957600080fd5b600160a060020a038516600090815260016020526040902060020154859060ff161515610d7557600080fd5b600160a060020a0386166000908152600160205260408120600201805460ff191690556004805460001901905594505b600354851015610e275785600160a060020a0316600386815481101515610dc857fe5b600091825260209091200154600160a060020a03161415610e1c576003805486908110610df157fe5b6000918252602090912001805473ffffffffffffffffffffffffffffffffffffffff19169055610e27565b600190940193610da5565b600160a060020a038087166000818152600160208181526040808420339096168452600486018252832054939092529052600390910154909450610e71908563ffffffff61121216565b600160a060020a03808816600090815260016020908152604080832060038101959095553390931682526004909301909252812055600754610eb9904363ffffffff61122416565b600160a060020a033316600090815260208181526040808320848452909152902054909350610eee908563ffffffff61122416565b600160a060020a0333166000818152602081815260408083208884528083529083209490945591815290526001908101805490918101610f2e838261123a565b5060009182526020909120018390557f4edf3e325d0063213a39f9085522994a1c44bea5f39e7d63ef61260a1e58c6d33387604051600160a060020a039283168152911660208201526040908101905180910390a1505050505050565b600160a060020a039081166000908152600160205260409020541690565b60065481565b60075481565b600160a060020a031660009081526001602052604090206002015460ff1690565b60055481565b600554341015610feb57600080fd5b600160a060020a038316600090815260016020526040902060020154839060ff161561101657600080fd5b6003805460018101611028838261123a565b506000918252602090912001805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03861617905560806040519081016040528033600160a060020a0316815260200184848080601f016020809104026020016040519081016040528181529291906020840183838082843750505092845250506001602080840182905234604094850152600160a060020a03891660009081529190529190912090508151815473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0391909116178155602082015181600101908051611113929160200190611275565b50604082015160028201805460ff1916911515919091179055606082015160039091015550600160a060020a038085166000818152600160208181526040808420339096168452600495860182528084203490558554830190955592825260029092529190912080549091810161118a838261123a565b506000918252602090912001805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0386161790557f7635f1d87b47fba9f2b09e56eb4be75cca030e0cb179c1602ac9261d39a8f5c1338534604051600160a060020a039384168152919092166020820152604080820192909252606001905180910390a150505050565b60008282111561121e57fe5b50900390565b60008282018381101561123357fe5b9392505050565b81548183558181151161125e5760008381526020902061125e9181019083016112f3565b505050565b60206040519081016040526000815290565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106112b657805160ff19168380011785556112e3565b828001600101855582156112e3579182015b828111156112e35782518255916020019190600101906112c8565b506112ef9291506112f3565b5090565b61069a91905b808211156112ef57600081556001016112f95600a165627a7a72305820a422640f0a57494daef9fc6216d5369240b95deaca2773f8c354cdfdecc913940029` // DeployTomoValidator deploys a new Ethereum contract, binding an instance of TomoValidator to it. func DeployTomoValidator(auth *bind.TransactOpts, backend bind.ContractBackend, _candidates []common.Address, _caps []*big.Int, _firstOwner common.Address, _minCandidateCap *big.Int, _maxValidatorNumber *big.Int, _candidateWithdrawDelay *big.Int, _voterWithdrawDelay *big.Int) (common.Address, *types.Transaction, *TomoValidator, error) { @@ -441,30 +441,30 @@ func (_TomoValidator *TomoValidatorCallerSession) GetCandidateCap(_candidate com return _TomoValidator.Contract.GetCandidateCap(&_TomoValidator.CallOpts, _candidate) } -// GetCandidateNodeUrl is a free data retrieval call binding the contract method 0xda67b599. +// GetCandidateNodeId is a free data retrieval call binding the contract method 0x7d40257f. // -// Solidity: function getCandidateNodeUrl(_candidate address) constant returns(string) -func (_TomoValidator *TomoValidatorCaller) GetCandidateNodeUrl(opts *bind.CallOpts, _candidate common.Address) (string, error) { +// Solidity: function getCandidateNodeId(_candidate address) constant returns(string) +func (_TomoValidator *TomoValidatorCaller) GetCandidateNodeId(opts *bind.CallOpts, _candidate common.Address) (string, error) { var ( ret0 = new(string) ) out := ret0 - err := _TomoValidator.contract.Call(opts, out, "getCandidateNodeUrl", _candidate) + err := _TomoValidator.contract.Call(opts, out, "getCandidateNodeId", _candidate) return *ret0, err } -// GetCandidateNodeUrl is a free data retrieval call binding the contract method 0xda67b599. +// GetCandidateNodeId is a free data retrieval call binding the contract method 0x7d40257f. // -// Solidity: function getCandidateNodeUrl(_candidate address) constant returns(string) -func (_TomoValidator *TomoValidatorSession) GetCandidateNodeUrl(_candidate common.Address) (string, error) { - return _TomoValidator.Contract.GetCandidateNodeUrl(&_TomoValidator.CallOpts, _candidate) +// Solidity: function getCandidateNodeId(_candidate address) constant returns(string) +func (_TomoValidator *TomoValidatorSession) GetCandidateNodeId(_candidate common.Address) (string, error) { + return _TomoValidator.Contract.GetCandidateNodeId(&_TomoValidator.CallOpts, _candidate) } -// GetCandidateNodeUrl is a free data retrieval call binding the contract method 0xda67b599. +// GetCandidateNodeId is a free data retrieval call binding the contract method 0x7d40257f. // -// Solidity: function getCandidateNodeUrl(_candidate address) constant returns(string) -func (_TomoValidator *TomoValidatorCallerSession) GetCandidateNodeUrl(_candidate common.Address) (string, error) { - return _TomoValidator.Contract.GetCandidateNodeUrl(&_TomoValidator.CallOpts, _candidate) +// Solidity: function getCandidateNodeId(_candidate address) constant returns(string) +func (_TomoValidator *TomoValidatorCallerSession) GetCandidateNodeId(_candidate common.Address) (string, error) { + return _TomoValidator.Contract.GetCandidateNodeId(&_TomoValidator.CallOpts, _candidate) } // GetCandidateOwner is a free data retrieval call binding the contract method 0xb642facd. @@ -703,23 +703,23 @@ func (_TomoValidator *TomoValidatorCallerSession) VoterWithdrawDelay() (*big.Int // Propose is a paid mutator transaction binding the contract method 0xd6f0948c. // -// Solidity: function propose(_candidate address, _nodeUrl string) returns() -func (_TomoValidator *TomoValidatorTransactor) Propose(opts *bind.TransactOpts, _candidate common.Address, _nodeUrl string) (*types.Transaction, error) { - return _TomoValidator.contract.Transact(opts, "propose", _candidate, _nodeUrl) +// Solidity: function propose(_candidate address, _nodeId string) returns() +func (_TomoValidator *TomoValidatorTransactor) Propose(opts *bind.TransactOpts, _candidate common.Address, _nodeId string) (*types.Transaction, error) { + return _TomoValidator.contract.Transact(opts, "propose", _candidate, _nodeId) } // Propose is a paid mutator transaction binding the contract method 0xd6f0948c. // -// Solidity: function propose(_candidate address, _nodeUrl string) returns() -func (_TomoValidator *TomoValidatorSession) Propose(_candidate common.Address, _nodeUrl string) (*types.Transaction, error) { - return _TomoValidator.Contract.Propose(&_TomoValidator.TransactOpts, _candidate, _nodeUrl) +// Solidity: function propose(_candidate address, _nodeId string) returns() +func (_TomoValidator *TomoValidatorSession) Propose(_candidate common.Address, _nodeId string) (*types.Transaction, error) { + return _TomoValidator.Contract.Propose(&_TomoValidator.TransactOpts, _candidate, _nodeId) } // Propose is a paid mutator transaction binding the contract method 0xd6f0948c. // -// Solidity: function propose(_candidate address, _nodeUrl string) returns() -func (_TomoValidator *TomoValidatorTransactorSession) Propose(_candidate common.Address, _nodeUrl string) (*types.Transaction, error) { - return _TomoValidator.Contract.Propose(&_TomoValidator.TransactOpts, _candidate, _nodeUrl) +// Solidity: function propose(_candidate address, _nodeId string) returns() +func (_TomoValidator *TomoValidatorTransactorSession) Propose(_candidate common.Address, _nodeId string) (*types.Transaction, error) { + return _TomoValidator.Contract.Propose(&_TomoValidator.TransactOpts, _candidate, _nodeId) } // Resign is a paid mutator transaction binding the contract method 0xae6e43f5. @@ -743,25 +743,25 @@ func (_TomoValidator *TomoValidatorTransactorSession) Resign(_candidate common.A return _TomoValidator.Contract.Resign(&_TomoValidator.TransactOpts, _candidate) } -// SetNodeUrl is a paid mutator transaction binding the contract method 0xa3ec7965. +// SetNodeId is a paid mutator transaction binding the contract method 0x6a000d74. // -// Solidity: function setNodeUrl(_candidate address, _nodeUrl string) returns() -func (_TomoValidator *TomoValidatorTransactor) SetNodeUrl(opts *bind.TransactOpts, _candidate common.Address, _nodeUrl string) (*types.Transaction, error) { - return _TomoValidator.contract.Transact(opts, "setNodeUrl", _candidate, _nodeUrl) +// Solidity: function setNodeId(_candidate address, _nodeId string) returns() +func (_TomoValidator *TomoValidatorTransactor) SetNodeId(opts *bind.TransactOpts, _candidate common.Address, _nodeId string) (*types.Transaction, error) { + return _TomoValidator.contract.Transact(opts, "setNodeId", _candidate, _nodeId) } -// SetNodeUrl is a paid mutator transaction binding the contract method 0xa3ec7965. +// SetNodeId is a paid mutator transaction binding the contract method 0x6a000d74. // -// Solidity: function setNodeUrl(_candidate address, _nodeUrl string) returns() -func (_TomoValidator *TomoValidatorSession) SetNodeUrl(_candidate common.Address, _nodeUrl string) (*types.Transaction, error) { - return _TomoValidator.Contract.SetNodeUrl(&_TomoValidator.TransactOpts, _candidate, _nodeUrl) +// Solidity: function setNodeId(_candidate address, _nodeId string) returns() +func (_TomoValidator *TomoValidatorSession) SetNodeId(_candidate common.Address, _nodeId string) (*types.Transaction, error) { + return _TomoValidator.Contract.SetNodeId(&_TomoValidator.TransactOpts, _candidate, _nodeId) } -// SetNodeUrl is a paid mutator transaction binding the contract method 0xa3ec7965. +// SetNodeId is a paid mutator transaction binding the contract method 0x6a000d74. // -// Solidity: function setNodeUrl(_candidate address, _nodeUrl string) returns() -func (_TomoValidator *TomoValidatorTransactorSession) SetNodeUrl(_candidate common.Address, _nodeUrl string) (*types.Transaction, error) { - return _TomoValidator.Contract.SetNodeUrl(&_TomoValidator.TransactOpts, _candidate, _nodeUrl) +// Solidity: function setNodeId(_candidate address, _nodeId string) returns() +func (_TomoValidator *TomoValidatorTransactorSession) SetNodeId(_candidate common.Address, _nodeId string) (*types.Transaction, error) { + return _TomoValidator.Contract.SetNodeId(&_TomoValidator.TransactOpts, _candidate, _nodeId) } // Unvote is a paid mutator transaction binding the contract method 0x02aa9be2. @@ -1074,9 +1074,9 @@ func (_TomoValidator *TomoValidatorFilterer) WatchResign(opts *bind.WatchOpts, s }), nil } -// TomoValidatorSetNodeUrlIterator is returned from FilterSetNodeUrl and is used to iterate over the raw logs and unpacked data for SetNodeUrl events raised by the TomoValidator contract. -type TomoValidatorSetNodeUrlIterator struct { - Event *TomoValidatorSetNodeUrl // Event containing the contract specifics and raw log +// TomoValidatorSetNodeIdIterator is returned from FilterSetNodeId and is used to iterate over the raw logs and unpacked data for SetNodeId events raised by the TomoValidator contract. +type TomoValidatorSetNodeIdIterator struct { + Event *TomoValidatorSetNodeId // Event containing the contract specifics and raw log contract *bind.BoundContract // Generic contract to use for unpacking event data event string // Event name to use for unpacking event data @@ -1090,7 +1090,7 @@ type TomoValidatorSetNodeUrlIterator struct { // Next advances the iterator to the subsequent event, returning whether there // are any more events found. In case of a retrieval or parsing error, false is // returned and Error() can be queried for the exact failure. -func (it *TomoValidatorSetNodeUrlIterator) Next() bool { +func (it *TomoValidatorSetNodeIdIterator) Next() bool { // If the iterator failed, stop iterating if it.fail != nil { return false @@ -1099,7 +1099,7 @@ func (it *TomoValidatorSetNodeUrlIterator) Next() bool { if it.done { select { case log := <-it.logs: - it.Event = new(TomoValidatorSetNodeUrl) + it.Event = new(TomoValidatorSetNodeId) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -1114,7 +1114,7 @@ func (it *TomoValidatorSetNodeUrlIterator) Next() bool { // Iterator still in progress, wait for either a data or an error event select { case log := <-it.logs: - it.Event = new(TomoValidatorSetNodeUrl) + it.Event = new(TomoValidatorSetNodeId) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -1130,43 +1130,43 @@ func (it *TomoValidatorSetNodeUrlIterator) Next() bool { } // Error returns any retrieval or parsing error occurred during filtering. -func (it *TomoValidatorSetNodeUrlIterator) Error() error { +func (it *TomoValidatorSetNodeIdIterator) Error() error { return it.fail } // Close terminates the iteration process, releasing any pending underlying // resources. -func (it *TomoValidatorSetNodeUrlIterator) Close() error { +func (it *TomoValidatorSetNodeIdIterator) Close() error { it.sub.Unsubscribe() return nil } -// TomoValidatorSetNodeUrl represents a SetNodeUrl event raised by the TomoValidator contract. -type TomoValidatorSetNodeUrl struct { +// TomoValidatorSetNodeId represents a SetNodeId event raised by the TomoValidator contract. +type TomoValidatorSetNodeId struct { Owner common.Address Candidate common.Address - NodeUrl string + NodeId string Raw types.Log // Blockchain specific contextual infos } -// FilterSetNodeUrl is a free log retrieval operation binding the contract event 0x63f303264cd4b7a198f0163f96e0b6b1f972f9b73359a70c44241b862879d8a4. +// FilterSetNodeId is a free log retrieval operation binding the contract event 0x0e421c04ccd34fafbe77c6b2f9384de8c5c4795114325fedb698a6ce62b2d744. // -// Solidity: event SetNodeUrl(_owner address, _candidate address, _nodeUrl string) -func (_TomoValidator *TomoValidatorFilterer) FilterSetNodeUrl(opts *bind.FilterOpts) (*TomoValidatorSetNodeUrlIterator, error) { +// Solidity: event SetNodeId(_owner address, _candidate address, _nodeId string) +func (_TomoValidator *TomoValidatorFilterer) FilterSetNodeId(opts *bind.FilterOpts) (*TomoValidatorSetNodeIdIterator, error) { - logs, sub, err := _TomoValidator.contract.FilterLogs(opts, "SetNodeUrl") + logs, sub, err := _TomoValidator.contract.FilterLogs(opts, "SetNodeId") if err != nil { return nil, err } - return &TomoValidatorSetNodeUrlIterator{contract: _TomoValidator.contract, event: "SetNodeUrl", logs: logs, sub: sub}, nil + return &TomoValidatorSetNodeIdIterator{contract: _TomoValidator.contract, event: "SetNodeId", logs: logs, sub: sub}, nil } -// WatchSetNodeUrl is a free log subscription operation binding the contract event 0x63f303264cd4b7a198f0163f96e0b6b1f972f9b73359a70c44241b862879d8a4. +// WatchSetNodeId is a free log subscription operation binding the contract event 0x0e421c04ccd34fafbe77c6b2f9384de8c5c4795114325fedb698a6ce62b2d744. // -// Solidity: event SetNodeUrl(_owner address, _candidate address, _nodeUrl string) -func (_TomoValidator *TomoValidatorFilterer) WatchSetNodeUrl(opts *bind.WatchOpts, sink chan<- *TomoValidatorSetNodeUrl) (event.Subscription, error) { +// Solidity: event SetNodeId(_owner address, _candidate address, _nodeId string) +func (_TomoValidator *TomoValidatorFilterer) WatchSetNodeId(opts *bind.WatchOpts, sink chan<- *TomoValidatorSetNodeId) (event.Subscription, error) { - logs, sub, err := _TomoValidator.contract.WatchLogs(opts, "SetNodeUrl") + logs, sub, err := _TomoValidator.contract.WatchLogs(opts, "SetNodeId") if err != nil { return nil, err } @@ -1176,8 +1176,8 @@ func (_TomoValidator *TomoValidatorFilterer) WatchSetNodeUrl(opts *bind.WatchOpt select { case log := <-logs: // New log arrived, parse the event and forward to the user - event := new(TomoValidatorSetNodeUrl) - if err := _TomoValidator.contract.UnpackLog(event, "SetNodeUrl", log); err != nil { + event := new(TomoValidatorSetNodeId) + if err := _TomoValidator.contract.UnpackLog(event, "SetNodeId", log); err != nil { return err } event.Raw = log diff --git a/core/blockchain.go b/core/blockchain.go index 5befe215fc..0f0b5f569a 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -62,7 +62,6 @@ const ( // BlockChainVersion ensures that an incompatible database forces a resync from scratch. BlockChainVersion = 3 - M1Gap = 5 ) // CacheConfig contains the configuration values for the trie caching/pruning @@ -1193,7 +1192,7 @@ func (bc *BlockChain) insertChain(chain types.Blocks) (int, []interface{}, []*ty CheckpointCh <- 1 } // prepare set of masternodes for the next epoch - if (chain[i].NumberU64() % bc.chainConfig.Clique.Epoch) == (bc.chainConfig.Clique.Epoch - M1Gap) { + if (chain[i].NumberU64() % bc.chainConfig.Clique.Epoch) == (bc.chainConfig.Clique.Epoch - bc.chainConfig.Clique.Gap) { M1Ch <- 1 } } diff --git a/docker_push.sh b/docker_push.sh deleted file mode 100755 index bc708c2730..0000000000 --- a/docker_push.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -echo "$DOCKER_PASSWORD" | docker login --username "$DOCKER_USERNAME" --password-stdin -docker tag tomochain/tomochain tomochain/tomochain:$1 -docker push tomochain/tomochain:$1 diff --git a/docker_rebuild.sh b/docker_rebuild.sh deleted file mode 100755 index 7b88f346a2..0000000000 --- a/docker_rebuild.sh +++ /dev/null @@ -1 +0,0 @@ -curl -X POST $INFRA_IMAGE_REBUILD_HOOK diff --git a/internal/build/archive.go b/internal/build/archive.go deleted file mode 100644 index ac680ba63d..0000000000 --- a/internal/build/archive.go +++ /dev/null @@ -1,185 +0,0 @@ -// Copyright 2016 The go-ethereum Authors -// This file is part of the go-ethereum library. -// -// The go-ethereum library is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// The go-ethereum library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with the go-ethereum library. If not, see . - -package build - -import ( - "archive/tar" - "archive/zip" - "compress/gzip" - "fmt" - "io" - "os" - "path/filepath" - "strings" -) - -type Archive interface { - // Directory adds a new directory entry to the archive and sets the - // directory for subsequent calls to Header. - Directory(name string) error - - // Header adds a new file to the archive. The file is added to the directory - // set by Directory. The content of the file must be written to the returned - // writer. - Header(os.FileInfo) (io.Writer, error) - - // Close flushes the archive and closes the underlying file. - Close() error -} - -func NewArchive(file *os.File) (Archive, string) { - switch { - case strings.HasSuffix(file.Name(), ".zip"): - return NewZipArchive(file), strings.TrimSuffix(file.Name(), ".zip") - case strings.HasSuffix(file.Name(), ".tar.gz"): - return NewTarballArchive(file), strings.TrimSuffix(file.Name(), ".tar.gz") - default: - return nil, "" - } -} - -// AddFile appends an existing file to an archive. -func AddFile(a Archive, file string) error { - fd, err := os.Open(file) - if err != nil { - return err - } - defer fd.Close() - fi, err := fd.Stat() - if err != nil { - return err - } - w, err := a.Header(fi) - if err != nil { - return err - } - if _, err := io.Copy(w, fd); err != nil { - return err - } - return nil -} - -// WriteArchive creates an archive containing the given files. -func WriteArchive(name string, files []string) (err error) { - archfd, err := os.Create(name) - if err != nil { - return err - } - - defer func() { - archfd.Close() - // Remove the half-written archive on failure. - if err != nil { - os.Remove(name) - } - }() - archive, basename := NewArchive(archfd) - if archive == nil { - return fmt.Errorf("unknown archive extension") - } - fmt.Println(name) - if err := archive.Directory(basename); err != nil { - return err - } - for _, file := range files { - fmt.Println(" +", filepath.Base(file)) - if err := AddFile(archive, file); err != nil { - return err - } - } - return archive.Close() -} - -type ZipArchive struct { - dir string - zipw *zip.Writer - file io.Closer -} - -func NewZipArchive(w io.WriteCloser) Archive { - return &ZipArchive{"", zip.NewWriter(w), w} -} - -func (a *ZipArchive) Directory(name string) error { - a.dir = name + "/" - return nil -} - -func (a *ZipArchive) Header(fi os.FileInfo) (io.Writer, error) { - head, err := zip.FileInfoHeader(fi) - if err != nil { - return nil, fmt.Errorf("can't make zip header: %v", err) - } - head.Name = a.dir + head.Name - head.Method = zip.Deflate - w, err := a.zipw.CreateHeader(head) - if err != nil { - return nil, fmt.Errorf("can't add zip header: %v", err) - } - return w, nil -} - -func (a *ZipArchive) Close() error { - if err := a.zipw.Close(); err != nil { - return err - } - return a.file.Close() -} - -type TarballArchive struct { - dir string - tarw *tar.Writer - gzw *gzip.Writer - file io.Closer -} - -func NewTarballArchive(w io.WriteCloser) Archive { - gzw := gzip.NewWriter(w) - tarw := tar.NewWriter(gzw) - return &TarballArchive{"", tarw, gzw, w} -} - -func (a *TarballArchive) Directory(name string) error { - a.dir = name + "/" - return a.tarw.WriteHeader(&tar.Header{ - Name: a.dir, - Mode: 0755, - Typeflag: tar.TypeDir, - }) -} - -func (a *TarballArchive) Header(fi os.FileInfo) (io.Writer, error) { - head, err := tar.FileInfoHeader(fi, "") - if err != nil { - return nil, fmt.Errorf("can't make tar header: %v", err) - } - head.Name = a.dir + head.Name - if err := a.tarw.WriteHeader(head); err != nil { - return nil, fmt.Errorf("can't add tar header: %v", err) - } - return a.tarw, nil -} - -func (a *TarballArchive) Close() error { - if err := a.tarw.Close(); err != nil { - return err - } - if err := a.gzw.Close(); err != nil { - return err - } - return a.file.Close() -} diff --git a/internal/build/azure.go b/internal/build/azure.go deleted file mode 100644 index 2081a9a0b1..0000000000 --- a/internal/build/azure.go +++ /dev/null @@ -1,111 +0,0 @@ -// Copyright 2016 The go-ethereum Authors -// This file is part of the go-ethereum library. -// -// The go-ethereum library is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// The go-ethereum library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with the go-ethereum library. If not, see . - -package build - -import ( - "fmt" - "os" - - storage "github.com/Azure/azure-storage-go" -) - -// AzureBlobstoreConfig is an authentication and configuration struct containing -// the data needed by the Azure SDK to interact with a speicifc container in the -// blobstore. -type AzureBlobstoreConfig struct { - Account string // Account name to authorize API requests with - Token string // Access token for the above account - Container string // Blob container to upload files into -} - -// AzureBlobstoreUpload uploads a local file to the Azure Blob Storage. Note, this -// method assumes a max file size of 64MB (Azure limitation). Larger files will -// need a multi API call approach implemented. -// -// See: https://msdn.microsoft.com/en-us/library/azure/dd179451.aspx#Anchor_3 -func AzureBlobstoreUpload(path string, name string, config AzureBlobstoreConfig) error { - if *DryRunFlag { - fmt.Printf("would upload %q to %s/%s/%s\n", path, config.Account, config.Container, name) - return nil - } - // Create an authenticated client against the Azure cloud - rawClient, err := storage.NewBasicClient(config.Account, config.Token) - if err != nil { - return err - } - client := rawClient.GetBlobService() - - // Stream the file to upload into the designated blobstore container - in, err := os.Open(path) - if err != nil { - return err - } - defer in.Close() - - info, err := in.Stat() - if err != nil { - return err - } - return client.CreateBlockBlobFromReader(config.Container, name, uint64(info.Size()), in, nil) -} - -// AzureBlobstoreList lists all the files contained within an azure blobstore. -func AzureBlobstoreList(config AzureBlobstoreConfig) ([]storage.Blob, error) { - // Create an authenticated client against the Azure cloud - rawClient, err := storage.NewBasicClient(config.Account, config.Token) - if err != nil { - return nil, err - } - client := rawClient.GetBlobService() - - // List all the blobs from the container and return them - container := client.GetContainerReference(config.Container) - - blobs, err := container.ListBlobs(storage.ListBlobsParameters{ - MaxResults: 1024 * 1024 * 1024, // Yes, fetch all of them - Timeout: 3600, // Yes, wait for all of them - }) - if err != nil { - return nil, err - } - return blobs.Blobs, nil -} - -// AzureBlobstoreDelete iterates over a list of files to delete and removes them -// from the blobstore. -func AzureBlobstoreDelete(config AzureBlobstoreConfig, blobs []storage.Blob) error { - if *DryRunFlag { - for _, blob := range blobs { - fmt.Printf("would delete %s (%s) from %s/%s\n", blob.Name, blob.Properties.LastModified, config.Account, config.Container) - } - return nil - } - // Create an authenticated client against the Azure cloud - rawClient, err := storage.NewBasicClient(config.Account, config.Token) - if err != nil { - return err - } - client := rawClient.GetBlobService() - - // Iterate over the blobs and delete them - for _, blob := range blobs { - if err := client.DeleteBlob(config.Container, blob.Name, nil); err != nil { - return err - } - } - return nil -} diff --git a/internal/build/pgp.go b/internal/build/pgp.go deleted file mode 100644 index 79ab9c06f1..0000000000 --- a/internal/build/pgp.go +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2016 The go-ethereum Authors -// This file is part of the go-ethereum library. -// -// The go-ethereum library is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// The go-ethereum library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with the go-ethereum library. If not, see . - -// signFile reads the contents of an input file and signs it (in armored format) -// with the key provided, placing the signature into the output file. - -package build - -import ( - "bytes" - "fmt" - "os" - - "golang.org/x/crypto/openpgp" -) - -// PGPSignFile parses a PGP private key from the specified string and creates a -// signature file into the output parameter of the input file. -// -// Note, this method assumes a single key will be container in the pgpkey arg, -// furthermore that it is in armored format. -func PGPSignFile(input string, output string, pgpkey string) error { - // Parse the keyring and make sure we only have a single private key in it - keys, err := openpgp.ReadArmoredKeyRing(bytes.NewBufferString(pgpkey)) - if err != nil { - return err - } - if len(keys) != 1 { - return fmt.Errorf("key count mismatch: have %d, want %d", len(keys), 1) - } - // Create the input and output streams for signing - in, err := os.Open(input) - if err != nil { - return err - } - defer in.Close() - - out, err := os.Create(output) - if err != nil { - return err - } - defer out.Close() - - // Generate the signature and return - return openpgp.ArmoredDetachSign(out, keys[0], in, nil) -} diff --git a/internal/build/util.go b/internal/build/util.go index c6e059f0df..a24099acfb 100644 --- a/internal/build/util.go +++ b/internal/build/util.go @@ -29,7 +29,6 @@ import ( "path/filepath" "runtime" "strings" - "text/template" ) var DryRunFlag = flag.Bool("n", false, "dry run, don't execute commands") @@ -60,15 +59,6 @@ func GOPATH() string { return os.Getenv("GOPATH") } -// VERSION returns the content of the VERSION file. -func VERSION() string { - version, err := ioutil.ReadFile("VERSION") - if err != nil { - log.Fatal(err) - } - return string(bytes.TrimSpace(version)) -} - var warnedAboutGit bool // RunGit runs a git subcommand and returns its output. @@ -98,34 +88,6 @@ func readGitFile(file string) string { return strings.TrimSpace(string(content)) } -// Render renders the given template file into outputFile. -func Render(templateFile, outputFile string, outputPerm os.FileMode, x interface{}) { - tpl := template.Must(template.ParseFiles(templateFile)) - render(tpl, outputFile, outputPerm, x) -} - -// RenderString renders the given template string into outputFile. -func RenderString(templateContent, outputFile string, outputPerm os.FileMode, x interface{}) { - tpl := template.Must(template.New("").Parse(templateContent)) - render(tpl, outputFile, outputPerm, x) -} - -func render(tpl *template.Template, outputFile string, outputPerm os.FileMode, x interface{}) { - if err := os.MkdirAll(filepath.Dir(outputFile), 0755); err != nil { - log.Fatal(err) - } - out, err := os.OpenFile(outputFile, os.O_CREATE|os.O_WRONLY|os.O_EXCL, outputPerm) - if err != nil { - log.Fatal(err) - } - if err := tpl.Execute(out, x); err != nil { - log.Fatal(err) - } - if err := out.Close(); err != nil { - log.Fatal(err) - } -} - // CopyFile copies a file. func CopyFile(dst, src string, mode os.FileMode) { if err := os.MkdirAll(filepath.Dir(dst), 0755); err != nil { diff --git a/miner/worker.go b/miner/worker.go index 5fef89d736..8177cde851 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -588,7 +588,7 @@ func (self *worker) commitNewWork() { core.CheckpointCh <- 1 } // prepare set of masternodes for the next epoch - if (work.Block.NumberU64() % work.config.Clique.Epoch) == (work.config.Clique.Epoch - core.M1Gap) { + if (work.Block.NumberU64() % work.config.Clique.Epoch) == (work.config.Clique.Epoch - work.config.Clique.Gap) { core.M1Ch <- 1 } } diff --git a/params/config.go b/params/config.go index e6ce0828d5..4bed78cc54 100644 --- a/params/config.go +++ b/params/config.go @@ -137,6 +137,7 @@ type CliqueConfig struct { Epoch uint64 `json:"epoch"` // Epoch length to reset votes and checkpoint Reward uint64 `json:"reward"` // Block reward - unit Ether RewardCheckpoint uint64 `json:"rewardCheckpoint"` // Checkpoint block for calculate rewards. + Gap uint64 `json:"gap"` // Gap time preparing for the next epoch } // String implements the stringer interface, returning the consensus engine details.