Skip to content

Commit

Permalink
perf(merkle): enable parallelized hasher (berachain#1700)
Browse files Browse the repository at this point in the history
  • Loading branch information
calbera authored Jul 5, 2024
1 parent c0edb58 commit 9d0d8d0
Show file tree
Hide file tree
Showing 18 changed files with 150 additions and 81 deletions.
1 change: 1 addition & 0 deletions beacond/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ require (
github.com/bits-and-blooms/bitset v1.13.0 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.3 // indirect
github.com/bufbuild/protocompile v0.14.0 // indirect
github.com/cespare/cp v1.1.1 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/chzyer/readline v1.5.1 // indirect
github.com/cockroachdb/errors v1.11.3 // indirect
Expand Down
4 changes: 2 additions & 2 deletions beacond/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ github.com/bufbuild/protocompile v0.14.0/go.mod h1:N6J1NYzkspJo3ZwyL4Xjvli86XOj1
github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4=
github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/cespare/cp v0.1.0 h1:SE+dxFebS7Iik5LK0tsi1k9ZCxEaFX4AjQmoyA+1dJk=
github.com/cespare/cp v0.1.0/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW+s=
github.com/cespare/cp v1.1.1 h1:nCb6ZLdB7NRaqsm91JtQTAme2SKJzXVsdPIPkyJr1MU=
github.com/cespare/cp v1.1.1/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW+s=
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
Expand Down
1 change: 1 addition & 0 deletions build/tools/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ require (
github.com/butuzov/mirror v1.2.0 // indirect
github.com/catenacyber/perfsprint v0.7.1 // indirect
github.com/ccojocar/zxcvbn-go v1.0.2 // indirect
github.com/cespare/cp v1.1.1 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/charithe/durationcheck v0.0.10 // indirect
github.com/chavacava/garif v0.1.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions build/tools/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ github.com/ccojocar/zxcvbn-go v1.0.2/go.mod h1:g1qkXtUSvHP8lhHp5GrSmTz6uWALGRMQd
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/cespare/cp v0.1.0 h1:SE+dxFebS7Iik5LK0tsi1k9ZCxEaFX4AjQmoyA+1dJk=
github.com/cespare/cp v0.1.0/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW+s=
github.com/cespare/cp v1.1.1 h1:nCb6ZLdB7NRaqsm91JtQTAme2SKJzXVsdPIPkyJr1MU=
github.com/cespare/cp v1.1.1/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW+s=
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
Expand Down
1 change: 1 addition & 0 deletions mod/cli/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ require (
require (
github.com/berachain/beacon-kit/mod/chain-spec v0.0.0-20240705193247-d464364483df // indirect
github.com/bufbuild/protocompile v0.14.0 // indirect
github.com/cespare/cp v1.1.1 // indirect
github.com/cockroachdb/fifo v0.0.0-20240616162244-4768e80dfb9a // indirect
github.com/ethereum/go-ethereum v1.14.6 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
Expand Down
4 changes: 2 additions & 2 deletions mod/cli/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ github.com/bufbuild/protocompile v0.14.0/go.mod h1:N6J1NYzkspJo3ZwyL4Xjvli86XOj1
github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4=
github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/cespare/cp v0.1.0 h1:SE+dxFebS7Iik5LK0tsi1k9ZCxEaFX4AjQmoyA+1dJk=
github.com/cespare/cp v0.1.0/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW+s=
github.com/cespare/cp v1.1.1 h1:nCb6ZLdB7NRaqsm91JtQTAme2SKJzXVsdPIPkyJr1MU=
github.com/cespare/cp v1.1.1/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW+s=
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
Expand Down
1 change: 1 addition & 0 deletions mod/execution/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ require (
github.com/berachain/beacon-kit/mod/chain-spec v0.0.0-20240703145037-b5612ab256db // indirect
github.com/bits-and-blooms/bitset v1.13.0 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.3 // indirect
github.com/cespare/cp v1.1.1 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/cockroachdb/errors v1.11.3 // indirect
github.com/cockroachdb/fifo v0.0.0-20240616162244-4768e80dfb9a // indirect
Expand Down
4 changes: 2 additions & 2 deletions mod/execution/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ github.com/btcsuite/btcd/btcec/v2 v2.3.3 h1:6+iXlDKE8RMtKsvK0gshlXIuPbyWM/h84Ens
github.com/btcsuite/btcd/btcec/v2 v2.3.3/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04=
github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 h1:59Kx4K6lzOW5w6nFlA0v5+lk/6sjybR934QNHSJZPTQ=
github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc=
github.com/cespare/cp v0.1.0 h1:SE+dxFebS7Iik5LK0tsi1k9ZCxEaFX4AjQmoyA+1dJk=
github.com/cespare/cp v0.1.0/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW+s=
github.com/cespare/cp v1.1.1 h1:nCb6ZLdB7NRaqsm91JtQTAme2SKJzXVsdPIPkyJr1MU=
github.com/cespare/cp v1.1.1/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW+s=
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
Expand Down
1 change: 1 addition & 0 deletions mod/geth-primitives/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ require (
github.com/bits-and-blooms/bitset v1.13.0 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.3 // indirect
github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 // indirect
github.com/cespare/cp v1.1.1 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/cockroachdb/errors v1.11.3 // indirect
github.com/cockroachdb/fifo v0.0.0-20240616162244-4768e80dfb9a // indirect
Expand Down
4 changes: 2 additions & 2 deletions mod/geth-primitives/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ github.com/btcsuite/btcd/btcec/v2 v2.3.3 h1:6+iXlDKE8RMtKsvK0gshlXIuPbyWM/h84Ens
github.com/btcsuite/btcd/btcec/v2 v2.3.3/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04=
github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 h1:59Kx4K6lzOW5w6nFlA0v5+lk/6sjybR934QNHSJZPTQ=
github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc=
github.com/cespare/cp v0.1.0 h1:SE+dxFebS7Iik5LK0tsi1k9ZCxEaFX4AjQmoyA+1dJk=
github.com/cespare/cp v0.1.0/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW+s=
github.com/cespare/cp v1.1.1 h1:nCb6ZLdB7NRaqsm91JtQTAme2SKJzXVsdPIPkyJr1MU=
github.com/cespare/cp v1.1.1/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW+s=
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
Expand Down
1 change: 1 addition & 0 deletions mod/node-core/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ require (
github.com/VictoriaMetrics/fastcache v1.12.2 // indirect
github.com/berachain/beacon-kit/mod/chain-spec v0.0.0-20240705193247-d464364483df // indirect
github.com/bufbuild/protocompile v0.14.0 // indirect
github.com/cespare/cp v1.1.1 // indirect
github.com/cockroachdb/fifo v0.0.0-20240616162244-4768e80dfb9a // indirect
github.com/holiman/bloomfilter/v2 v2.0.3 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
Expand Down
4 changes: 2 additions & 2 deletions mod/node-core/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ github.com/bufbuild/protocompile v0.14.0/go.mod h1:N6J1NYzkspJo3ZwyL4Xjvli86XOj1
github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4=
github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/cespare/cp v0.1.0 h1:SE+dxFebS7Iik5LK0tsi1k9ZCxEaFX4AjQmoyA+1dJk=
github.com/cespare/cp v0.1.0/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW+s=
github.com/cespare/cp v1.1.1 h1:nCb6ZLdB7NRaqsm91JtQTAme2SKJzXVsdPIPkyJr1MU=
github.com/cespare/cp v1.1.1/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW+s=
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
Expand Down
2 changes: 1 addition & 1 deletion mod/primitives/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ require (
github.com/minio/sha256-simd v1.0.1
github.com/prysmaticlabs/gohashtree v0.0.4-beta
github.com/stretchr/testify v1.9.0
golang.org/x/sync v0.7.0
)

require (
Expand Down Expand Up @@ -72,7 +73,6 @@ require (
github.com/yusufpapurcu/wmi v1.2.4 // indirect
golang.org/x/crypto v0.25.0 // indirect
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.22.0 // indirect
golang.org/x/text v0.16.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
Expand Down
98 changes: 93 additions & 5 deletions mod/primitives/pkg/merkle/hasher.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@
package merkle

import (
"runtime"
"unsafe"

"github.com/berachain/beacon-kit/mod/errors"
"github.com/berachain/beacon-kit/mod/primitives/pkg/crypto"
"github.com/berachain/beacon-kit/mod/primitives/pkg/math"
"github.com/berachain/beacon-kit/mod/primitives/pkg/merkle/zero"
"github.com/prysmaticlabs/gohashtree"
"golang.org/x/sync/errgroup"
)

const (
Expand Down Expand Up @@ -125,17 +127,103 @@ func (rh *RootHasher[RootT]) NewRootWithDepth(
return h, nil
}

// BuildParentTreeRoots calls BuildParentTreeRootsWithNRoutines with the
// number of routines set to runtime.GOMAXPROCS(0)-1.
//
// TODO: enable parallelization.
// BuildParentTreeRoots calls BuildParentTreeRootsWithNRoutines to
// parallelize the hashing process.
func BuildParentTreeRoots[RootT ~[32]byte](
outputList, inputList []RootT,
) error {
return gohashtree.Hash(
return BuildParentTreeRootsWithNRoutines(
//#nosec:G103 // on purpose.
*(*[][32]byte)(unsafe.Pointer(&outputList)),
//#nosec:G103 // on purpose.
*(*[][32]byte)(unsafe.Pointer(&inputList)),
MinParallelizationSize,
)
}

// BuildParentTreeRootsWithNRoutines optimizes hashing of a list of roots
// using CPU-specific vector instructions and parallel processing. This
// method adapts to the host machine's hardware for potential performance
// gains over sequential hashing.
//
// NOTE: Currently we use `runtime.GOMAXPROCS(0)-1` as the number of
// goroutines to use.
//
// TODO: We do not use generics here due to the gohashtree library not
// supporting generics.
func BuildParentTreeRootsWithNRoutines(
outputList, inputList [][32]byte, minParallelizationSize int,
) error {
// Validate input list length.
inputLength := len(inputList)
if inputLength%2 != 0 {
return ErrOddLengthTreeRoots
}

// If the input list is small, hash it using the default method since
// the overhead of parallelizing the hashing process is not worth it.
if inputLength < minParallelizationSize {
return gohashtree.Hash(outputList, inputList)
}

// Get the number of goroutines to use.
//
// TODO: parameterize n and allow this to be specified by caller.
n := runtime.GOMAXPROCS(0) - 1

// Otherwise parallelize the hashing process for large inputs.
groupSize := inputLength / (two * (n + 1))
twiceGroupSize := two * groupSize
eg := new(errgroup.Group)

// Use a buffer to store the results of the hashing process.
//
// TODO: Move to re-usable buffer.
outputLength := inputLength / two
workingSpace := make([][32]byte, outputLength)

// If n is 0 the parallelization is disabled and the whole inputList is
// hashed in the main goroutine at the end of this function.
for j := range n {
eg.Go(func() error {
// inputList: [-------------------2*groupSize-------------------]
// ______^ ____^ ^ ^
// | | | |
// j*2*groupSize (j+1)*2*groupSize (j+2)*2*groupSize End
//
// workingSpace: [---------groupSize---------]
// ^ ^
// | |
// j*groupSize (j+1)*groupSize
//
// Each goroutine processes a segment of inputList that is twice as
// large as the segment it fills in workingSpace. This is because
// the
// hash operation reduces the size of the input by half.
// Define the segment of the inputList each goroutine will process.
segmentStart := j * twiceGroupSize
segmentEnd := (j + 1) * twiceGroupSize

return gohashtree.Hash(
workingSpace[j*groupSize:],
inputList[segmentStart:segmentEnd],
)
})
}

// Hash the last segment of the inputList.
if err := gohashtree.Hash(
workingSpace[n*groupSize:],
inputList[n*twiceGroupSize:],
); err != nil {
return err
}

defer func() {
// Copy the results from workingSpace to outputList
copy(outputList, workingSpace)
outputList = outputList[:outputLength]
}()

return eg.Wait()
}
79 changes: 29 additions & 50 deletions mod/primitives/pkg/merkle/hasher_fuzz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,82 +21,66 @@
package merkle_test

import (
"runtime"
"testing"

"github.com/berachain/beacon-kit/mod/primitives/pkg/constants"
"github.com/berachain/beacon-kit/mod/primitives/pkg/merkle"
)

func FuzzHashTreeRoot(f *testing.F) {
// Seed corpus with a variety of sizes, including edge cases
//
// Test with empty slice
f.Add(make([]byte, 0), true, 1, merkle.MinParallelizationSize)
f.Add(make([]byte, 0), true, merkle.MinParallelizationSize)
// Just below a single block size
f.Add(
make([]byte, 31), true,
runtime.GOMAXPROCS(0)-1, merkle.MinParallelizationSize,
make([]byte, 31), true, merkle.MinParallelizationSize,
)
// Exactly one block size
f.Add(
make([]byte, 32), true,
runtime.GOMAXPROCS(0)+1, merkle.MinParallelizationSize,
make([]byte, 32), true, merkle.MinParallelizationSize,
)
// Just above a single block size
f.Add(
make([]byte, 33), true,
runtime.GOMAXPROCS(0)*2, merkle.MinParallelizationSize,
make([]byte, 33), true, merkle.MinParallelizationSize,
)
// Multiple blocks
f.Add(
make([]byte, 64), true,
runtime.GOMAXPROCS(0)*4, merkle.MinParallelizationSize,
make([]byte, 64), true, merkle.MinParallelizationSize,
)
// Larger input
f.Add(
make([]byte, 1024), true,
3, merkle.MinParallelizationSize,
make([]byte, 1024), true, merkle.MinParallelizationSize,
)
// Just below MinParallelizationSize leaves
f.Add(
make([]byte, merkle.MinParallelizationSize-2), false,
300, merkle.MinParallelizationSize,
merkle.MinParallelizationSize,
)
// Exactly MinParallelizationSize leaves
f.Add(
make([]byte, merkle.MinParallelizationSize), false,
merkle.MinParallelizationSize,
)
// Just above MinParallelizationSize leaves
f.Add(
make([]byte, merkle.MinParallelizationSize+2), false,
merkle.MinParallelizationSize,
)
// Double MinParallelizationSize leaves
f.Add(
make([]byte, 2*merkle.MinParallelizationSize), false,
merkle.MinParallelizationSize,
)

// NOTE: All of the below cases which use parallelization are flaky.
//
// // Exactly MinParallelizationSize leaves
// f.Add(
// make([]byte, merkle.MinParallelizationSize), false,
// 1, merkle.MinParallelizationSize,
// )
// // Just above MinParallelizationSize leaves
// f.Add(
// make([]byte, merkle.MinParallelizationSize+2), false,
// 64, merkle.MinParallelizationSize,
// )
// // Double MinParallelizationSize leaves
// f.Add(
// make([]byte, 2*merkle.MinParallelizationSize), false,
// runtime.GOMAXPROCS(0)-1, merkle.MinParallelizationSize,
// )
// Max Txs leaves
// f.Add(
// make([]byte, int(constants.MaxTxsPerPayload)),
// runtime.GOMAXPROCS(0)-1,
// merkle.MinParallelizationSize,
// )
// Max Bytes Per Tx leaves
// f.Add(
// make([]byte, int(constants.MaxBytesPerTx)),
// runtime.GOMAXPROCS(0)-1,
// merkle.MinParallelizationSize,
// )
f.Add(
make([]byte, int(constants.MaxTxsPerPayload)), false,
merkle.MinParallelizationSize,
)

f.Fuzz(func(
t *testing.T,
original []byte, isLeaves bool,
numRoutines, minParallelizationSize int,
original []byte, isLeaves bool, minParallelizationSize int,
) {
// Extend the fuzzed input to 32 byte leaves if not in leaves format.
if !isLeaves {
Expand Down Expand Up @@ -124,13 +108,8 @@ func FuzzHashTreeRoot(f *testing.F) {
expectError = true
}

// NOTE: skipping any inputs which use parallelization for now.
if len(input) >= minParallelizationSize {
return
}

requireGoHashTreeEquivalence(
t, input, numRoutines, minParallelizationSize, expectError,
t, input, minParallelizationSize, expectError,
)
})
}
Loading

0 comments on commit 9d0d8d0

Please sign in to comment.