Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjustive block period #4491

Draft
wants to merge 8 commits into
base: dev
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Cleanup.
  • Loading branch information
Frozen committed Sep 1, 2023
commit 7105f78fa9036f5761b2342ba872ca1f92752c51
23 changes: 10 additions & 13 deletions node/node_newblock.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,16 @@ func (node *Node) ProposeNewBlock(commitSigs chan []byte) (*types.Block, error)
utils.Logger().Err(err).Msg("Failed to fetch pending transactions")
return nil, err
}
var (
blockIsEmpty = len(pendingPoolTxs) == 0
featureActivated = blockchain.Config().IsOneSecond(header.Epoch())
notTooLong = started.Add(maxBlockTimeout).After(time.Now()) // we can delay block creation for maxBlockTimeout
)
if blockIsEmpty && featureActivated && notTooLong {
// then we can skip block creating and wait for more transactions
<-time.After(250 * time.Millisecond)
continue
}
pendingPlainTxs := map[common.Address]types.Transactions{}
pendingStakingTxs := staking.StakingTransactions{}
for addr, poolTxs := range pendingPoolTxs {
Expand All @@ -191,19 +201,6 @@ func (node *Node) ProposeNewBlock(commitSigs chan []byte) (*types.Block, error)
pendingPlainTxs[addr] = plainTxsPerAcc
}
}
var (
blockIsEmpty = len(pendingPlainTxs) == 0 && len(pendingStakingTxs) == 0
featureActivated = blockchain.Config().IsOneSecond(header.Epoch())
notTooLong = started.Add(maxBlockTimeout).After(time.Now()) // we can delay block creation for maxBlockTimeout
// TODO
notEpochChangingBlocks = true // better not to delay that blocks, because they are needed asap
)

if blockIsEmpty && featureActivated && notTooLong && notEpochChangingBlocks {
// then we can skip block creating and wait for more transactions
<-time.After(250 * time.Millisecond)
continue
}

// Try commit normal and staking transactions based on the current state
// The successfully committed transactions will be put in the proposed block
Expand Down