mirror of https://github.com/poanetwork/gecko.git
Merge pull request #250 from aaronbuchwald/debug-staking-disabled
Decouple staking and tls encryption for internode communication
This commit is contained in:
commit
9236eb286f
|
@ -45,7 +45,10 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Track if sybil control is enforced
|
// Track if sybil control is enforced
|
||||||
if !Config.EnableStaking {
|
if !Config.EnableStaking && Config.EnableP2PTLS {
|
||||||
|
log.Warn("Staking is disabled. Sybil control is not enforced.")
|
||||||
|
}
|
||||||
|
if !Config.EnableStaking && !Config.EnableP2PTLS {
|
||||||
log.Warn("Staking and p2p encryption are disabled. Packet spoofing is possible.")
|
log.Warn("Staking and p2p encryption are disabled. Packet spoofing is possible.")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,8 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
errBootstrapMismatch = errors.New("more bootstrap IDs provided than bootstrap IPs")
|
errBootstrapMismatch = errors.New("more bootstrap IDs provided than bootstrap IPs")
|
||||||
|
errStakingRequiresTLS = errors.New("if staking is enabled, network TLS must also be enabled")
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetIPs returns the default IPs for each network
|
// GetIPs returns the default IPs for each network
|
||||||
|
@ -200,7 +201,9 @@ func init() {
|
||||||
|
|
||||||
// Staking:
|
// Staking:
|
||||||
consensusPort := fs.Uint("staking-port", 9651, "Port of the consensus server")
|
consensusPort := fs.Uint("staking-port", 9651, "Port of the consensus server")
|
||||||
fs.BoolVar(&Config.EnableStaking, "staking-tls-enabled", true, "Require TLS to authenticate staking connections")
|
// TODO - keeping same flag for backwards compatibility, should be changed to "staking-enabled"
|
||||||
|
fs.BoolVar(&Config.EnableStaking, "staking-tls-enabled", true, "Enable staking. If enabled, Network TLS is required.")
|
||||||
|
fs.BoolVar(&Config.EnableP2PTLS, "p2p-tls-enabled", true, "Require TLS to authenticate network communication")
|
||||||
fs.StringVar(&Config.StakingKeyFile, "staking-tls-key-file", defaultStakingKeyPath, "TLS private key for staking")
|
fs.StringVar(&Config.StakingKeyFile, "staking-tls-key-file", defaultStakingKeyPath, "TLS private key for staking")
|
||||||
fs.StringVar(&Config.StakingCertFile, "staking-tls-cert-file", defaultStakingCertPath, "TLS certificate for staking")
|
fs.StringVar(&Config.StakingCertFile, "staking-tls-cert-file", defaultStakingCertPath, "TLS certificate for staking")
|
||||||
|
|
||||||
|
@ -318,7 +321,13 @@ func init() {
|
||||||
*bootstrapIDs = strings.Join(defaultBootstrapIDs, ",")
|
*bootstrapIDs = strings.Join(defaultBootstrapIDs, ",")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if Config.EnableStaking {
|
|
||||||
|
if Config.EnableStaking && !Config.EnableP2PTLS {
|
||||||
|
errs.Add(errStakingRequiresTLS)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if Config.EnableP2PTLS {
|
||||||
i := 0
|
i := 0
|
||||||
cb58 := formatting.CB58{}
|
cb58 := formatting.CB58{}
|
||||||
for _, id := range strings.Split(*bootstrapIDs, ",") {
|
for _, id := range strings.Split(*bootstrapIDs, ",") {
|
||||||
|
|
|
@ -34,6 +34,7 @@ type Config struct {
|
||||||
|
|
||||||
// Staking configuration
|
// Staking configuration
|
||||||
StakingIP utils.IPDesc
|
StakingIP utils.IPDesc
|
||||||
|
EnableP2PTLS bool
|
||||||
EnableStaking bool
|
EnableStaking bool
|
||||||
StakingKeyFile string
|
StakingKeyFile string
|
||||||
StakingCertFile string
|
StakingCertFile string
|
||||||
|
|
|
@ -119,7 +119,7 @@ func (n *Node) initNetworking() error {
|
||||||
dialer := network.NewDialer(TCP)
|
dialer := network.NewDialer(TCP)
|
||||||
|
|
||||||
var serverUpgrader, clientUpgrader network.Upgrader
|
var serverUpgrader, clientUpgrader network.Upgrader
|
||||||
if n.Config.EnableStaking {
|
if n.Config.EnableP2PTLS {
|
||||||
cert, err := tls.LoadX509KeyPair(n.Config.StakingCertFile, n.Config.StakingKeyFile)
|
cert, err := tls.LoadX509KeyPair(n.Config.StakingCertFile, n.Config.StakingKeyFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -253,7 +253,7 @@ func (n *Node) initDatabase() error {
|
||||||
// Otherwise, it is a hash of the TLS certificate that this node
|
// Otherwise, it is a hash of the TLS certificate that this node
|
||||||
// uses for P2P communication
|
// uses for P2P communication
|
||||||
func (n *Node) initNodeID() error {
|
func (n *Node) initNodeID() error {
|
||||||
if !n.Config.EnableStaking {
|
if !n.Config.EnableP2PTLS {
|
||||||
n.ID = ids.NewShortID(hashing.ComputeHash160Array([]byte(n.Config.StakingIP.String())))
|
n.ID = ids.NewShortID(hashing.ComputeHash160Array([]byte(n.Config.StakingIP.String())))
|
||||||
n.Log.Info("Set the node's ID to %s", n.ID)
|
n.Log.Info("Set the node's ID to %s", n.ID)
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in New Issue