Skip to content

Commit

Permalink
fix(dpos2.0): increase the transaction priority for revertToPow
Browse files Browse the repository at this point in the history
  • Loading branch information
RainFallsSilent committed Apr 15, 2023
1 parent 0728416 commit 992b589
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
5 changes: 5 additions & 0 deletions mempool/txpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ func (mp *TxPool) removeCRAppropriationConflictTransactions() {
}

func (mp *TxPool) appendToTxPool(tx interfaces.Transaction) elaerr.ELAError {
// todo complete me
if tx.IsIllegalProposalTx() || tx.IsIllegalVoteTx() {
return elaerr.Simple(elaerr.ErrTxValidation, nil)
}

txHash := tx.Hash()

// If the transaction is CR appropriation transaction, need to remove
Expand Down
2 changes: 2 additions & 0 deletions pow/revertlistener.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ func (pow *Service) ListenForRevert() {
}
lastBlockTimestamp := int64(pow.arbiters.GetLastBlockTimestamp())
localTimestamp := pow.chain.TimeSource.AdjustedTime().Unix()
log.Info("ListenForRevert lastBlockTimestamp:", lastBlockTimestamp,
"localTimestamp:", localTimestamp, "RevertToPOWNoBlockTime:", pow.chainParams.DPoSConfiguration.RevertToPOWNoBlockTime)
if localTimestamp-lastBlockTimestamp < pow.chainParams.DPoSConfiguration.RevertToPOWNoBlockTime {
continue
}
Expand Down
8 changes: 7 additions & 1 deletion pow/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,12 +281,14 @@ func (pow *Service) GenerateBlock(minerAddr string,
txs := pow.txMemPool.GetTxsInPool()

isHighPriority := func(tx interfaces.Transaction) bool {
if tx.IsIllegalTypeTx() || tx.IsInactiveArbitrators() ||
if tx.IsRevertToPOW() || tx.IsRevertToDPOS() ||
tx.IsIllegalTypeTx() || tx.IsInactiveArbitrators() ||
tx.IsSideChainPowTx() || tx.IsUpdateVersion() ||
tx.IsActivateProducerTx() || tx.IsCRCAppropriationTx() ||
tx.IsCRAssetsRectifyTx() || tx.IsNextTurnDPOSInfoTx() {
return true
}

return false
}

Expand All @@ -303,6 +305,10 @@ func (pow *Service) GenerateBlock(minerAddr string,
var proposalsUsedAmount common.Fixed64
for _, tx := range txs {

if tx.IsIllegalProposalTx() || tx.IsIllegalVoteTx() {
continue
}

size := totalTxsSize + tx.GetSize()
if size > int(pact.MaxBlockContextSize) {
continue
Expand Down

0 comments on commit 992b589

Please sign in to comment.