forked from cerc-io/plugeth
cmd/geth, cmd/utils, eth: advertise both eth/60 and eth/61
This commit is contained in:
parent
ba95e445e1
commit
393d675690
@ -261,7 +261,6 @@ JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Conso
|
|||||||
utils.ExecFlag,
|
utils.ExecFlag,
|
||||||
utils.WhisperEnabledFlag,
|
utils.WhisperEnabledFlag,
|
||||||
utils.VMDebugFlag,
|
utils.VMDebugFlag,
|
||||||
utils.ProtocolVersionFlag,
|
|
||||||
utils.NetworkIdFlag,
|
utils.NetworkIdFlag,
|
||||||
utils.RPCCORSDomainFlag,
|
utils.RPCCORSDomainFlag,
|
||||||
utils.VerbosityFlag,
|
utils.VerbosityFlag,
|
||||||
@ -598,7 +597,7 @@ func version(c *cli.Context) {
|
|||||||
if gitCommit != "" {
|
if gitCommit != "" {
|
||||||
fmt.Println("Git Commit:", gitCommit)
|
fmt.Println("Git Commit:", gitCommit)
|
||||||
}
|
}
|
||||||
fmt.Println("Protocol Version:", c.GlobalInt(utils.ProtocolVersionFlag.Name))
|
fmt.Println("Protocol Versions:", eth.ProtocolVersions)
|
||||||
fmt.Println("Network Id:", c.GlobalInt(utils.NetworkIdFlag.Name))
|
fmt.Println("Network Id:", c.GlobalInt(utils.NetworkIdFlag.Name))
|
||||||
fmt.Println("Go Version:", runtime.Version())
|
fmt.Println("Go Version:", runtime.Version())
|
||||||
fmt.Println("OS:", runtime.GOOS)
|
fmt.Println("OS:", runtime.GOOS)
|
||||||
|
@ -82,11 +82,6 @@ var (
|
|||||||
Usage: "Data directory to be used",
|
Usage: "Data directory to be used",
|
||||||
Value: DirectoryString{common.DefaultDataDir()},
|
Value: DirectoryString{common.DefaultDataDir()},
|
||||||
}
|
}
|
||||||
ProtocolVersionFlag = cli.IntFlag{
|
|
||||||
Name: "protocolversion",
|
|
||||||
Usage: "ETH protocol version (integer)",
|
|
||||||
Value: eth.ProtocolVersion,
|
|
||||||
}
|
|
||||||
NetworkIdFlag = cli.IntFlag{
|
NetworkIdFlag = cli.IntFlag{
|
||||||
Name: "networkid",
|
Name: "networkid",
|
||||||
Usage: "Network Id (integer)",
|
Usage: "Network Id (integer)",
|
||||||
@ -359,7 +354,6 @@ func MakeEthConfig(clientID, version string, ctx *cli.Context) *eth.Config {
|
|||||||
return ð.Config{
|
return ð.Config{
|
||||||
Name: common.MakeName(clientID, version),
|
Name: common.MakeName(clientID, version),
|
||||||
DataDir: ctx.GlobalString(DataDirFlag.Name),
|
DataDir: ctx.GlobalString(DataDirFlag.Name),
|
||||||
ProtocolVersion: ctx.GlobalInt(ProtocolVersionFlag.Name),
|
|
||||||
GenesisNonce: ctx.GlobalInt(GenesisNonceFlag.Name),
|
GenesisNonce: ctx.GlobalInt(GenesisNonceFlag.Name),
|
||||||
BlockChainVersion: ctx.GlobalInt(BlockchainVersionFlag.Name),
|
BlockChainVersion: ctx.GlobalInt(BlockchainVersionFlag.Name),
|
||||||
SkipBcVersionCheck: false,
|
SkipBcVersionCheck: false,
|
||||||
|
@ -58,7 +58,6 @@ var (
|
|||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Name string
|
Name string
|
||||||
ProtocolVersion int
|
|
||||||
NetworkId int
|
NetworkId int
|
||||||
GenesisNonce int
|
GenesisNonce int
|
||||||
|
|
||||||
@ -226,7 +225,6 @@ type Ethereum struct {
|
|||||||
autodagquit chan bool
|
autodagquit chan bool
|
||||||
etherbase common.Address
|
etherbase common.Address
|
||||||
clientVersion string
|
clientVersion string
|
||||||
ethVersionId int
|
|
||||||
netVersionId int
|
netVersionId int
|
||||||
shhVersionId int
|
shhVersionId int
|
||||||
}
|
}
|
||||||
@ -291,6 +289,11 @@ func New(config *Config) (*Ethereum, error) {
|
|||||||
nodeDb := filepath.Join(config.DataDir, "nodes")
|
nodeDb := filepath.Join(config.DataDir, "nodes")
|
||||||
|
|
||||||
// Perform database sanity checks
|
// Perform database sanity checks
|
||||||
|
/*
|
||||||
|
// The databases were previously tied to protocol versions. Currently we
|
||||||
|
// are moving away from this decision as approaching Frontier. The below
|
||||||
|
// check was left in for now but should eventually be just dropped.
|
||||||
|
|
||||||
d, _ := blockDb.Get([]byte("ProtocolVersion"))
|
d, _ := blockDb.Get([]byte("ProtocolVersion"))
|
||||||
protov := int(common.NewValue(d).Uint())
|
protov := int(common.NewValue(d).Uint())
|
||||||
if protov != config.ProtocolVersion && protov != 0 {
|
if protov != config.ProtocolVersion && protov != 0 {
|
||||||
@ -298,7 +301,8 @@ func New(config *Config) (*Ethereum, error) {
|
|||||||
return nil, fmt.Errorf("Database version mismatch. Protocol(%d / %d). `rm -rf %s`", protov, config.ProtocolVersion, path)
|
return nil, fmt.Errorf("Database version mismatch. Protocol(%d / %d). `rm -rf %s`", protov, config.ProtocolVersion, path)
|
||||||
}
|
}
|
||||||
saveProtocolVersion(blockDb, config.ProtocolVersion)
|
saveProtocolVersion(blockDb, config.ProtocolVersion)
|
||||||
glog.V(logger.Info).Infof("Protocol Version: %v, Network Id: %v", config.ProtocolVersion, config.NetworkId)
|
*/
|
||||||
|
glog.V(logger.Info).Infof("Protocol Versions: %v, Network Id: %v", ProtocolVersions, config.NetworkId)
|
||||||
|
|
||||||
if !config.SkipBcVersionCheck {
|
if !config.SkipBcVersionCheck {
|
||||||
b, _ := blockDb.Get([]byte("BlockchainVersion"))
|
b, _ := blockDb.Get([]byte("BlockchainVersion"))
|
||||||
@ -321,7 +325,6 @@ func New(config *Config) (*Ethereum, error) {
|
|||||||
DataDir: config.DataDir,
|
DataDir: config.DataDir,
|
||||||
etherbase: common.HexToAddress(config.Etherbase),
|
etherbase: common.HexToAddress(config.Etherbase),
|
||||||
clientVersion: config.Name, // TODO should separate from Name
|
clientVersion: config.Name, // TODO should separate from Name
|
||||||
ethVersionId: config.ProtocolVersion,
|
|
||||||
netVersionId: config.NetworkId,
|
netVersionId: config.NetworkId,
|
||||||
NatSpec: config.NatSpec,
|
NatSpec: config.NatSpec,
|
||||||
MinerThreads: config.MinerThreads,
|
MinerThreads: config.MinerThreads,
|
||||||
@ -345,7 +348,7 @@ func New(config *Config) (*Ethereum, error) {
|
|||||||
|
|
||||||
eth.blockProcessor = core.NewBlockProcessor(stateDb, extraDb, eth.pow, eth.chainManager, eth.EventMux())
|
eth.blockProcessor = core.NewBlockProcessor(stateDb, extraDb, eth.pow, eth.chainManager, eth.EventMux())
|
||||||
eth.chainManager.SetProcessor(eth.blockProcessor)
|
eth.chainManager.SetProcessor(eth.blockProcessor)
|
||||||
eth.protocolManager = NewProtocolManager(config.ProtocolVersion, config.NetworkId, eth.eventMux, eth.txPool, eth.pow, eth.chainManager)
|
eth.protocolManager = NewProtocolManager(config.NetworkId, eth.eventMux, eth.txPool, eth.pow, eth.chainManager)
|
||||||
|
|
||||||
eth.miner = miner.New(eth, eth.EventMux(), eth.pow)
|
eth.miner = miner.New(eth, eth.EventMux(), eth.pow)
|
||||||
eth.miner.SetGasPrice(config.GasPrice)
|
eth.miner.SetGasPrice(config.GasPrice)
|
||||||
@ -358,7 +361,7 @@ func New(config *Config) (*Ethereum, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
protocols := []p2p.Protocol{eth.protocolManager.SubProtocol}
|
protocols := append([]p2p.Protocol{}, eth.protocolManager.SubProtocols...)
|
||||||
if config.Shh {
|
if config.Shh {
|
||||||
protocols = append(protocols, eth.whisper.Protocol())
|
protocols = append(protocols, eth.whisper.Protocol())
|
||||||
}
|
}
|
||||||
@ -495,7 +498,7 @@ func (s *Ethereum) PeerCount() int { return s.net.PeerCoun
|
|||||||
func (s *Ethereum) Peers() []*p2p.Peer { return s.net.Peers() }
|
func (s *Ethereum) Peers() []*p2p.Peer { return s.net.Peers() }
|
||||||
func (s *Ethereum) MaxPeers() int { return s.net.MaxPeers }
|
func (s *Ethereum) MaxPeers() int { return s.net.MaxPeers }
|
||||||
func (s *Ethereum) ClientVersion() string { return s.clientVersion }
|
func (s *Ethereum) ClientVersion() string { return s.clientVersion }
|
||||||
func (s *Ethereum) EthVersion() int { return s.ethVersionId }
|
func (s *Ethereum) EthVersion() int { return int(s.protocolManager.SubProtocols[0].Version) }
|
||||||
func (s *Ethereum) NetVersion() int { return s.netVersionId }
|
func (s *Ethereum) NetVersion() int { return s.netVersionId }
|
||||||
func (s *Ethereum) ShhVersion() int { return s.shhVersionId }
|
func (s *Ethereum) ShhVersion() int { return s.shhVersionId }
|
||||||
func (s *Ethereum) Downloader() *downloader.Downloader { return s.protocolManager.downloader }
|
func (s *Ethereum) Downloader() *downloader.Downloader { return s.protocolManager.downloader }
|
||||||
@ -504,7 +507,7 @@ func (s *Ethereum) Downloader() *downloader.Downloader { return s.protocolMana
|
|||||||
func (s *Ethereum) Start() error {
|
func (s *Ethereum) Start() error {
|
||||||
jsonlogger.LogJson(&logger.LogStarting{
|
jsonlogger.LogJson(&logger.LogStarting{
|
||||||
ClientString: s.net.Name,
|
ClientString: s.net.Name,
|
||||||
ProtocolVersion: ProtocolVersion,
|
ProtocolVersion: s.EthVersion(),
|
||||||
})
|
})
|
||||||
err := s.net.Start()
|
err := s.net.Start()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -560,7 +563,7 @@ done:
|
|||||||
func (s *Ethereum) StartForTest() {
|
func (s *Ethereum) StartForTest() {
|
||||||
jsonlogger.LogJson(&logger.LogStarting{
|
jsonlogger.LogJson(&logger.LogStarting{
|
||||||
ClientString: s.net.Name,
|
ClientString: s.net.Name,
|
||||||
ProtocolVersion: ProtocolVersion,
|
ProtocolVersion: s.EthVersion(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -667,6 +670,11 @@ func (self *Ethereum) StopAutoDAG() {
|
|||||||
glog.V(logger.Info).Infof("Automatic pregeneration of ethash DAG OFF (ethash dir: %s)", ethash.DefaultDir)
|
glog.V(logger.Info).Infof("Automatic pregeneration of ethash DAG OFF (ethash dir: %s)", ethash.DefaultDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
// The databases were previously tied to protocol versions. Currently we
|
||||||
|
// are moving away from this decision as approaching Frontier. The below
|
||||||
|
// code was left in for now but should eventually be just dropped.
|
||||||
|
|
||||||
func saveProtocolVersion(db common.Database, protov int) {
|
func saveProtocolVersion(db common.Database, protov int) {
|
||||||
d, _ := db.Get([]byte("ProtocolVersion"))
|
d, _ := db.Get([]byte("ProtocolVersion"))
|
||||||
protocolVersion := common.NewValue(d).Uint()
|
protocolVersion := common.NewValue(d).Uint()
|
||||||
@ -675,6 +683,7 @@ func saveProtocolVersion(db common.Database, protov int) {
|
|||||||
db.Put([]byte("ProtocolVersion"), common.NewValue(protov).Bytes())
|
db.Put([]byte("ProtocolVersion"), common.NewValue(protov).Bytes())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
func saveBlockchainVersion(db common.Database, bcVersion int) {
|
func saveBlockchainVersion(db common.Database, bcVersion int) {
|
||||||
d, _ := db.Get([]byte("BlockchainVersion"))
|
d, _ := db.Get([]byte("BlockchainVersion"))
|
||||||
|
@ -49,7 +49,7 @@ type ProtocolManager struct {
|
|||||||
fetcher *fetcher.Fetcher
|
fetcher *fetcher.Fetcher
|
||||||
peers *peerSet
|
peers *peerSet
|
||||||
|
|
||||||
SubProtocol p2p.Protocol
|
SubProtocols []p2p.Protocol
|
||||||
|
|
||||||
eventMux *event.TypeMux
|
eventMux *event.TypeMux
|
||||||
txSub event.Subscription
|
txSub event.Subscription
|
||||||
@ -68,8 +68,8 @@ type ProtocolManager struct {
|
|||||||
|
|
||||||
// NewProtocolManager returns a new ethereum sub protocol manager. The Ethereum sub protocol manages peers capable
|
// NewProtocolManager returns a new ethereum sub protocol manager. The Ethereum sub protocol manages peers capable
|
||||||
// with the ethereum network.
|
// with the ethereum network.
|
||||||
func NewProtocolManager(protocolVersion, networkId int, mux *event.TypeMux, txpool txPool, pow pow.PoW, chainman *core.ChainManager) *ProtocolManager {
|
func NewProtocolManager(networkId int, mux *event.TypeMux, txpool txPool, pow pow.PoW, chainman *core.ChainManager) *ProtocolManager {
|
||||||
// Create the protocol manager and initialize peer handlers
|
// Create the protocol manager with the base fields
|
||||||
manager := &ProtocolManager{
|
manager := &ProtocolManager{
|
||||||
eventMux: mux,
|
eventMux: mux,
|
||||||
txpool: txpool,
|
txpool: txpool,
|
||||||
@ -79,16 +79,22 @@ func NewProtocolManager(protocolVersion, networkId int, mux *event.TypeMux, txpo
|
|||||||
txsyncCh: make(chan *txsync),
|
txsyncCh: make(chan *txsync),
|
||||||
quitSync: make(chan struct{}),
|
quitSync: make(chan struct{}),
|
||||||
}
|
}
|
||||||
manager.SubProtocol = p2p.Protocol{
|
// Initiate a sub-protocol for every implemented version we can handle
|
||||||
|
manager.SubProtocols = make([]p2p.Protocol, len(ProtocolVersions))
|
||||||
|
for i := 0; i < len(manager.SubProtocols); i++ {
|
||||||
|
version := ProtocolVersions[i]
|
||||||
|
|
||||||
|
manager.SubProtocols[i] = p2p.Protocol{
|
||||||
Name: "eth",
|
Name: "eth",
|
||||||
Version: uint(protocolVersion),
|
Version: version,
|
||||||
Length: ProtocolLength,
|
Length: ProtocolLengths[i],
|
||||||
Run: func(p *p2p.Peer, rw p2p.MsgReadWriter) error {
|
Run: func(p *p2p.Peer, rw p2p.MsgReadWriter) error {
|
||||||
peer := manager.newPeer(protocolVersion, networkId, p, rw)
|
peer := manager.newPeer(int(version), networkId, p, rw)
|
||||||
manager.newPeerCh <- peer
|
manager.newPeerCh <- peer
|
||||||
return manager.handle(peer)
|
return manager.handle(peer)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Construct the different synchronisation mechanisms
|
// Construct the different synchronisation mechanisms
|
||||||
manager.downloader = downloader.New(manager.eventMux, manager.chainman.HasBlock, manager.chainman.GetBlock, manager.chainman.InsertChain, manager.removePeer)
|
manager.downloader = downloader.New(manager.eventMux, manager.chainman.HasBlock, manager.chainman.GetBlock, manager.chainman.InsertChain, manager.removePeer)
|
||||||
|
|
||||||
|
@ -7,11 +7,15 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Supported versions of the eth protocol (first is primary).
|
||||||
|
var ProtocolVersions = []uint{61, 60}
|
||||||
|
|
||||||
|
// Number of implemented message corresponding to different protocol versions.
|
||||||
|
var ProtocolLengths = []uint64{9, 8}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
ProtocolVersion = 60
|
|
||||||
NetworkId = 0
|
NetworkId = 0
|
||||||
ProtocolLength = uint64(8)
|
ProtocolMaxMsgSize = 10 * 1024 * 1024 // Maximum cap on the size of a protocol message
|
||||||
ProtocolMaxMsgSize = 10 * 1024 * 1024
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// eth protocol message codes
|
// eth protocol message codes
|
||||||
@ -24,6 +28,7 @@ const (
|
|||||||
GetBlocksMsg
|
GetBlocksMsg
|
||||||
BlocksMsg
|
BlocksMsg
|
||||||
NewBlockMsg
|
NewBlockMsg
|
||||||
|
BlockHashesFromNumbers
|
||||||
)
|
)
|
||||||
|
|
||||||
type errCode int
|
type errCode int
|
||||||
|
Loading…
Reference in New Issue
Block a user