Skip to content

Commit

Permalink
release, all: integrate the release service into geth
Browse files Browse the repository at this point in the history
  • Loading branch information
karalabe committed May 2, 2016
1 parent d46da27 commit 586eddf
Show file tree
Hide file tree
Showing 14 changed files with 822 additions and 583 deletions.
5 changes: 3 additions & 2 deletions accounts/abi/bind/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ type ContractCaller interface {
// used when the user does not provide some needed values, but rather leaves it up
// to the transactor to decide.
type ContractTransactor interface {
// Nonce retrieves the current pending nonce associated with an account.
// PendingAccountNonce retrieves the current pending nonce associated with an
// account.
PendingAccountNonce(account common.Address) (uint64, error)

// SuggestGasPrice retrieves the currently suggested gas price to allow a timely
Expand All @@ -62,7 +63,7 @@ type ContractTransactor interface {
EstimateGasLimit(sender common.Address, contract *common.Address, value *big.Int, data []byte) (*big.Int, error)

// SendTransaction injects the transaction into the pending pool for execution.
SendTransaction(*types.Transaction) error
SendTransaction(tx *types.Transaction) error
}

// ContractBackend defines the methods needed to allow operating with contract
Expand Down
59 changes: 37 additions & 22 deletions cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package main

import (
"encoding/hex"
"fmt"
"io/ioutil"
"os"
Expand All @@ -41,31 +42,48 @@ import (
"github.com/ethereum/go-ethereum/metrics"
"github.com/ethereum/go-ethereum/node"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/release"
"github.com/ethereum/go-ethereum/rlp"
)

const (
ClientIdentifier = "Geth"
Version = "1.5.0-unstable"
VersionMajor = 1
VersionMinor = 5
VersionPatch = 0
clientIdentifier = "Geth" // Client identifier to advertise over the network
versionMajor = 1 // Major version component of the current release
versionMinor = 5 // Minor version component of the current release
versionPatch = 0 // Patch version component of the current release
versionMeta = "unstable" // Version metadata to append to the version string

versionOracle = "0x48a117313039b73ab02fb9f73e04a66defe123ec" // Ethereum address of the Geth release oracle
)

var (
gitCommit string // set via linker flagg
nodeNameVersion string
app *cli.App
gitCommit string // Git SHA1 commit hash of the release (set via linker flags)
verString string // Combined textual representation of all the version components
relConfig release.Config // Structured version information and release oracle config
app *cli.App
)

func init() {
if gitCommit == "" {
nodeNameVersion = Version
} else {
nodeNameVersion = Version + "-" + gitCommit[:8]
// Construct the textual version string from the individual components
verString = fmt.Sprintf("%d.%d.%d", versionMajor, versionMinor, versionPatch)
if versionMeta != "" {
verString += "-" + versionMeta
}
if gitCommit != "" {
verString += "-" + gitCommit[:8]
}
// Construct the version release oracle configuration
relConfig.Oracle = common.HexToAddress(versionOracle)

app = utils.NewApp(Version, "the go-ethereum command line interface")
relConfig.Major = uint32(versionMajor)
relConfig.Minor = uint32(versionMinor)
relConfig.Patch = uint32(versionPatch)

commit, _ := hex.DecodeString(gitCommit)
copy(relConfig.Commit[:], commit)

// Initialize the CLI app and start Geth
app = utils.NewApp(verString, "the go-ethereum command line interface")
app.Action = geth
app.HideVersion = true // we have a command to print the version
app.Commands = []cli.Command{
Expand Down Expand Up @@ -257,7 +275,7 @@ func makeDefaultExtra() []byte {
Name string
GoVersion string
Os string
}{uint(VersionMajor<<16 | VersionMinor<<8 | VersionPatch), ClientIdentifier, runtime.Version(), runtime.GOOS}
}{uint(versionMajor<<16 | versionMinor<<8 | versionPatch), clientIdentifier, runtime.Version(), runtime.GOOS}
extra, err := rlp.EncodeToBytes(clientInfo)
if err != nil {
glog.V(logger.Warn).Infoln("error setting canonical miner information:", err)
Expand All @@ -275,7 +293,7 @@ func makeDefaultExtra() []byte {
// It creates a default node based on the command line arguments and runs it in
// blocking mode, waiting for it to be shut down.
func geth(ctx *cli.Context) {
node := utils.MakeSystemNode(ClientIdentifier, nodeNameVersion, makeDefaultExtra(), ctx)
node := utils.MakeSystemNode(clientIdentifier, verString, relConfig, makeDefaultExtra(), ctx)
startNode(ctx, node)
node.Wait()
}
Expand Down Expand Up @@ -339,7 +357,7 @@ func initGenesis(ctx *cli.Context) {
// same time.
func console(ctx *cli.Context) {
// Create and start the node based on the CLI flags
node := utils.MakeSystemNode(ClientIdentifier, nodeNameVersion, makeDefaultExtra(), ctx)
node := utils.MakeSystemNode(clientIdentifier, verString, relConfig, makeDefaultExtra(), ctx)
startNode(ctx, node)

// Attach to the newly started node, and either execute script or become interactive
Expand Down Expand Up @@ -372,7 +390,7 @@ func console(ctx *cli.Context) {
// of the JavaScript files specified as command arguments.
func execScripts(ctx *cli.Context) {
// Create and start the node based on the CLI flags
node := utils.MakeSystemNode(ClientIdentifier, nodeNameVersion, makeDefaultExtra(), ctx)
node := utils.MakeSystemNode(clientIdentifier, verString, relConfig, makeDefaultExtra(), ctx)
startNode(ctx, node)
defer node.Stop()

Expand Down Expand Up @@ -488,11 +506,8 @@ func gpubench(ctx *cli.Context) {
}

func version(c *cli.Context) {
fmt.Println(ClientIdentifier)
fmt.Println("Version:", Version)
if gitCommit != "" {
fmt.Println("Git Commit:", gitCommit)
}
fmt.Println(clientIdentifier)
fmt.Println("Version:", version)
fmt.Println("Protocol Versions:", eth.ProtocolVersions)
fmt.Println("Network Id:", c.GlobalInt(utils.NetworkIdFlag.Name))
fmt.Println("Go Version:", runtime.Version())
Expand Down
14 changes: 6 additions & 8 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import (
"github.com/ethereum/ethash"
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/versions"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/crypto"
Expand All @@ -49,6 +48,7 @@ import (
"github.com/ethereum/go-ethereum/p2p/nat"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/pow"
"github.com/ethereum/go-ethereum/release"
"github.com/ethereum/go-ethereum/rpc"
"github.com/ethereum/go-ethereum/whisper"
)
Expand Down Expand Up @@ -642,7 +642,7 @@ func MakePasswordList(ctx *cli.Context) []string {

// MakeSystemNode sets up a local node, configures the services to launch and
// assembles the P2P protocol stack.
func MakeSystemNode(name, version string, extra []byte, ctx *cli.Context) *node.Node {
func MakeSystemNode(name, version string, relconf release.Config, extra []byte, ctx *cli.Context) *node.Node {
// Avoid conflicting network flags
networks, netFlags := 0, []cli.BoolFlag{DevModeFlag, TestNetFlag, OlympicFlag}
for _, flag := range netFlags {
Expand Down Expand Up @@ -773,12 +773,10 @@ func MakeSystemNode(name, version string, extra []byte, ctx *cli.Context) *node.
Fatalf("Failed to register the Whisper service: %v", err)
}
}

err = stack.Register(func(ctx *node.ServiceContext) (node.Service, error) {
return versions.NewVersionCheck(ctx)
})
if err != nil {
Fatalf("Failed to register the Version Check service: %v", err)
if err := stack.Register(func(ctx *node.ServiceContext) (node.Service, error) {
return release.NewReleaseService(ctx, relconf)
}); err != nil {
Fatalf("Failed to register the Geth release oracle service: %v", err)
}
return stack
}
Expand Down
Loading

0 comments on commit 586eddf

Please sign in to comment.