Skip to content

Commit

Permalink
Revert shuffling algorithm for block TXs (#5839) (#5842)
Browse files Browse the repository at this point in the history
Fixes the error introduced in 1.4.5 that changes the order of the TX shuffle in blocks
  • Loading branch information
fasmat committed Apr 12, 2024
1 parent abe0eab commit ac8c41a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

See [RELEASE](./RELEASE.md) for workflow instructions.

## Release v1.4.6

### Improvements

* [#5839](https://github.com/spacemeshos/go-spacemesh/pull/5839) Fix a bug where nodes would stop agreeing on the order
of TX within a block.

## Release v1.4.5

### Improvements
Expand Down
2 changes: 1 addition & 1 deletion blocks/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"fmt"
"math"
"math/big"
"math/rand/v2"
"math/rand"
"sort"

"github.com/seehuhn/mt19937"
Expand Down
7 changes: 2 additions & 5 deletions txs/conservative_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ package txs

import (
"context"
"encoding/binary"
"fmt"
"math"
"math/rand/v2"
"math/rand"
"time"

"github.com/spacemeshos/go-spacemesh/common/types"
Expand Down Expand Up @@ -108,9 +107,7 @@ func getProposalTXs(
return result
}
// randomly select transactions from the predicted block.
var seed [32]byte
binary.LittleEndian.PutUint64(seed[:], uint64(time.Now().UnixNano()))
rng := rand.New(rand.NewChaCha8(seed))
rng := rand.New(rand.NewSource(time.Now().UnixNano()))
return ShuffleWithNonceOrder(logger, rng, numTXs, predictedBlock, byAddrAndNonce)
}

Expand Down
2 changes: 1 addition & 1 deletion txs/utils.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package txs

import (
"math/rand/v2"
"math/rand"

"github.com/spacemeshos/go-spacemesh/common/types"
"github.com/spacemeshos/go-spacemesh/log"
Expand Down

0 comments on commit ac8c41a

Please sign in to comment.