Skip to content

Commit

Permalink
Send pruning point anticone in topological order
Browse files Browse the repository at this point in the history
Fix a UTXO pagination bug
Lengthen the stabilization time for the last DAA test
  • Loading branch information
Kaspa Profiler committed Nov 5, 2021
1 parent 2dddb65 commit 50b05e2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (flow *handleRequestPruningPointUTXOSetFlow) sendPruningPointUTXOSet(
return err
}

if len(pruningPointUTXOs) < step {
if len(pruningPointUTXOs) < step && chunksSent%ibdBatchSize == 0 {
log.Debugf("Finished sending UTXOs for pruning block %s",
msgRequestPruningPointUTXOSet.PruningPointHash)

Expand Down
10 changes: 9 additions & 1 deletion domain/consensus/processes/pruningmanager/pruningmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/kaspanet/kaspad/infrastructure/logger"
"github.com/kaspanet/kaspad/util/staging"
"github.com/pkg/errors"
"sort"
)

// pruningManager resolves and manages the current pruning point
Expand Down Expand Up @@ -928,7 +929,6 @@ func (pm *pruningManager) PruningPointAndItsAnticoneWithTrustedData() ([]*extern
return nil, err
}

blocks = append(blocks, pruningPointWithTrustedData)
for _, blockHash := range pruningPointAnticone {
blockWithTrustedData, err := pm.blockWithTrustedData(stagingArea, blockHash)
if err != nil {
Expand All @@ -938,6 +938,14 @@ func (pm *pruningManager) PruningPointAndItsAnticoneWithTrustedData() ([]*extern
blocks = append(blocks, blockWithTrustedData)
}

// Sorting the blocks in topological order
sort.Slice(blocks, func(i, j int) bool {
return blocks[i].Block.Header.BlueWork().Cmp(blocks[j].Block.Header.BlueWork()) < 0
})

// The pruning point should always come first
blocks = append([]*externalapi.BlockWithTrustedData{pruningPointWithTrustedData}, blocks...)

return blocks, nil
}

Expand Down
2 changes: 1 addition & 1 deletion stability-tests/daa/daa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func TestDAA(t *testing.T) {
},
{
name: "constant exponential hash rate decrease",
runDuration: 15 * time.Minute,
runDuration: 45 * time.Minute,
targetHashNanosecondsFunction: func(totalElapsedDuration time.Duration) int64 {
fromHashNanoseconds := machineHashNanoseconds * 2
toHashNanoseconds := machineHashNanoseconds * 10
Expand Down

0 comments on commit 50b05e2

Please sign in to comment.