Skip to content

Commit

Permalink
Worker needs to prune expired ETXs before building blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
wizeguyy committed Jul 19, 2023
1 parent 817df18 commit de6ef47
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
7 changes: 2 additions & 5 deletions core/types/etx_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ package types

import (
"github.com/dominant-strategies/go-quai/common"
)

const (
EtxExpirationAge = 100 // With 10s blocks, ETX expire after ~24hrs
"github.com/dominant-strategies/go-quai/params"
)

// The EtxSet maps an ETX hash to the ETX and block number in which it became available.
Expand Down Expand Up @@ -37,7 +34,7 @@ func (set *EtxSet) Update(newInboundEtxs Transactions, currentHeight uint64) {
// Remove expired ETXs
for txHash, entry := range *set {
availableAtBlock := entry.Height
etxExpirationHeight := availableAtBlock + EtxExpirationAge
etxExpirationHeight := availableAtBlock + params.EtxExpirationAge
if currentHeight > etxExpirationHeight {
delete(*set, txHash)
}
Expand Down
1 change: 1 addition & 0 deletions core/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,7 @@ func (w *worker) fillTransactions(interrupt *int32, env *environment, block *typ
if etxSet == nil {
return
}
etxSet.Update(types.Transactions{}, block.NumberU64()) // Prune any expired ETXs
pending, err := w.txPool.TxPoolPending(true, etxSet)
if err != nil {
return
Expand Down
1 change: 1 addition & 0 deletions params/protocol_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const (
ETXPrimeMaxFraction int = common.NumRegionsInPrime * common.NumZonesInRegion // The maximum fraction of transactions for cross-prime ETXs
ETXRLimitMin int = 10 // Minimum possible cross-region ETX limit
ETXPLimitMin int = 10 // Minimum possible cross-prime ETX limit
EtxExpirationAge uint64 = 100 // Number of blocks an ETX may wait for inclusion at the destination

Sha3Gas uint64 = 30 // Once per SHA3 operation.
Sha3WordGas uint64 = 6 // Once per word of the SHA3 operation's data.
Expand Down

0 comments on commit de6ef47

Please sign in to comment.