mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 10:22:23 +00:00
Merge pull request #194 from ngtuna/signed-recently
adjust condition for `signed recently` check
This commit is contained in:
commit
904ba5312a
3 changed files with 54 additions and 50 deletions
|
|
@ -20,12 +20,12 @@ import (
|
|||
"bufio"
|
||||
"errors"
|
||||
"fmt"
|
||||
"gopkg.in/urfave/cli.v1"
|
||||
"io"
|
||||
"os"
|
||||
"reflect"
|
||||
"unicode"
|
||||
"strings"
|
||||
"gopkg.in/urfave/cli.v1"
|
||||
"unicode"
|
||||
|
||||
"github.com/ethereum/go-ethereum/cmd/utils"
|
||||
"github.com/ethereum/go-ethereum/dashboard"
|
||||
|
|
@ -151,7 +151,7 @@ func makeConfigNode(ctx *cli.Context) (*node.Node, tomoConfig) {
|
|||
ctx.Set(utils.NATFlag.Name, cfg.NAT)
|
||||
}
|
||||
|
||||
// read passwords from enviroment
|
||||
// read passwords from environment
|
||||
passwords := []string{}
|
||||
for _, env := range cfg.Account.Passwords {
|
||||
if trimmed := strings.TrimSpace(env); trimmed != "" {
|
||||
|
|
|
|||
|
|
@ -321,9 +321,7 @@ func startNode(ctx *cli.Context, stack *node.Node, cfg tomoConfig) {
|
|||
log.Info("Enabled staking node!!!")
|
||||
}
|
||||
defer close(core.CheckpointCh)
|
||||
for {
|
||||
select {
|
||||
case <-core.CheckpointCh:
|
||||
for range core.CheckpointCh {
|
||||
log.Info("Checkpoint!!! It's time to reconcile node's state...")
|
||||
ok, err := ethereum.ValidateStaker()
|
||||
if err != nil {
|
||||
|
|
@ -356,7 +354,6 @@ func startNode(ctx *cli.Context, stack *node.Node, cfg tomoConfig) {
|
|||
log.Info("Enabled staking node!!!")
|
||||
}
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -575,10 +575,12 @@ func (c *Posv) verifySeal(chain consensus.ChainReader, header *types.Header, par
|
|||
return errUnauthorized
|
||||
}
|
||||
}
|
||||
if len(masternodes) > 1 {
|
||||
for seen, recent := range snap.Recents {
|
||||
if recent == signer {
|
||||
// Signer is among recents, only fail if the current block doesn't shift it out
|
||||
if limit := uint64(len(masternodes)/2 + 1); seen > number-limit {
|
||||
// There is only case that we don't allow signer to create two continuous blocks.
|
||||
if limit := uint64(2); seen > number-limit {
|
||||
// Only take into account the non-epoch blocks
|
||||
if number%c.config.Epoch != 0 {
|
||||
return errUnauthorized
|
||||
|
|
@ -586,6 +588,7 @@ func (c *Posv) verifySeal(chain consensus.ChainReader, header *types.Header, par
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
@ -755,10 +758,13 @@ func (c *Posv) Seal(chain consensus.ChainReader, block *types.Block, stop <-chan
|
|||
}
|
||||
}
|
||||
// If we're amongst the recent signers, wait for the next block
|
||||
// only check recent signers if there are more than one signer.
|
||||
if len(masternodes) > 1 {
|
||||
for seen, recent := range snap.Recents {
|
||||
if recent == signer {
|
||||
// Signer is among recents, only wait if the current block doesn't shift it out
|
||||
if limit := uint64(len(masternodes)/2 + 1); number < limit || seen > number-limit {
|
||||
// There is only case that we don't allow signer to create two continuous blocks.
|
||||
if limit := uint64(2); number < limit || seen > number-limit {
|
||||
// Only take into account the non-epoch blocks
|
||||
if number%c.config.Epoch != 0 {
|
||||
log.Info("Debugging", "len(masternodes)", len(masternodes), "number", number, "limit", limit, "seen", seen, "recent", recent.String(), "snap.Recents", snap.Recents)
|
||||
|
|
@ -769,6 +775,7 @@ func (c *Posv) Seal(chain consensus.ChainReader, block *types.Block, stop <-chan
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
select {
|
||||
case <-stop:
|
||||
return nil, nil
|
||||
|
|
|
|||
Loading…
Reference in a new issue