stateroot: make vote/root extensibles live less

These are arbitrary numbers, but that's what C# node uses. maxRetries could be
set lower because we have exponential backoff anyway, but this works too.
This commit is contained in:
Roman Khimov 2021-05-07 12:22:29 +03:00
parent 7c902669bf
commit 4a45abe3e0
3 changed files with 9 additions and 4 deletions

View file

@ -14,6 +14,8 @@ import (
"go.uber.org/zap" "go.uber.org/zap"
) )
const rootValidEndInc = 100
// RelayCallback represents callback for sending validated state roots. // RelayCallback represents callback for sending validated state roots.
type RelayCallback = func(*payload.Extensible) type RelayCallback = func(*payload.Extensible)
@ -91,7 +93,7 @@ func (s *service) sendValidatedRoot(r *state.MPTRoot, acc *wallet.Account) {
ep := &payload.Extensible{ ep := &payload.Extensible{
Category: Category, Category: Category,
ValidBlockStart: r.Index, ValidBlockStart: r.Index,
ValidBlockEnd: r.Index + transaction.MaxValidUntilBlockIncrement, ValidBlockEnd: r.Index + rootValidEndInc,
Sender: priv.GetScriptHash(), Sender: priv.GetScriptHash(),
Data: w.Bytes(), Data: w.Bytes(),
Witness: transaction.Witness{ Witness: transaction.Witness{

View file

@ -71,7 +71,7 @@ func New(cfg config.StateRoot, log *zap.Logger, bc blockchainer.Blockchainer, cb
blockCh: make(chan *block.Block), blockCh: make(chan *block.Block),
done: make(chan struct{}), done: make(chan struct{}),
timePerBlock: time.Duration(bcConf.SecondsPerBlock) * time.Second, timePerBlock: time.Duration(bcConf.SecondsPerBlock) * time.Second,
maxRetries: bcConf.ValidatorsCount + 1, maxRetries: voteValidEndInc,
relayExtensible: cb, relayExtensible: cb,
} }

View file

@ -12,7 +12,10 @@ import (
"go.uber.org/zap" "go.uber.org/zap"
) )
const firstVoteResendDelay = 3 * time.Second const (
voteValidEndInc = 10
firstVoteResendDelay = 3 * time.Second
)
// Run runs service instance in a separate goroutine. // Run runs service instance in a separate goroutine.
func (s *service) Run() { func (s *service) Run() {
@ -85,7 +88,7 @@ func (s *service) signAndSend(r *state.MPTRoot) error {
e := &payload.Extensible{ e := &payload.Extensible{
Category: Category, Category: Category,
ValidBlockStart: r.Index, ValidBlockStart: r.Index,
ValidBlockEnd: r.Index + transaction.MaxValidUntilBlockIncrement, ValidBlockEnd: r.Index + voteValidEndInc,
Sender: acc.PrivateKey().GetScriptHash(), Sender: acc.PrivateKey().GetScriptHash(),
Data: w.Bytes(), Data: w.Bytes(),
Witness: transaction.Witness{ Witness: transaction.Witness{