Skip to content

Commit

Permalink
feat: tx simulator (#1613)
Browse files Browse the repository at this point in the history
Ref: celestiaorg/celestia-app#1256,
celestiaorg/celestia-app#1535

This commit introduces a new package `txsim` for contolled fuzz testing at a
transaction level. It's purpose is to simulate a wide range of possible
user interactions while also being able to apply a considerable load to
the network.
  • Loading branch information
cmwaters authored Apr 20, 2023
1 parent 4dc4b72 commit 20845fa
Show file tree
Hide file tree
Showing 16 changed files with 1,514 additions and 15 deletions.
2 changes: 1 addition & 1 deletion app/estimate_square_size.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func estimateSquareSize(normalTxs [][]byte, blobTxs []core.BlobTx) (squareSize u
// estimate as much
totalSharesUsed := uint64(txSharesUsed + pfbTxSharesUsed + blobSharesUsed)
totalSharesUsed *= 2
minSize := uint64(math.Sqrt(float64(totalSharesUsed)))
minSize := uint64(math.Ceil(math.Sqrt(float64(totalSharesUsed))))
squareSize = shares.RoundUpPowerOfTwo(minSize)
if squareSize >= appconsts.DefaultMaxSquareSize {
squareSize = appconsts.DefaultMaxSquareSize
Expand Down
6 changes: 3 additions & 3 deletions app/estimate_square_size_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ func Test_estimateSquareSize(t *testing.T) {
}
tests := []test{
{"empty block", 0, 0, 0, appconsts.DefaultMinSquareSize},
{"one normal tx", 1, 0, 0, appconsts.DefaultMinSquareSize},
{"one normal tx", 1, 0, 0, 2},
{"one small pfb small block", 0, 1, 100, 2},
{"mixed small block", 10, 12, 500, 16},
{"small block 2", 0, 12, 1000, 16},
{"mixed medium block 2", 10, 20, 10000, 32},
{"one large pfb large block", 0, 1, 1000000, 64},
{"one large pfb large block", 0, 1, 1000000, appconsts.DefaultMaxSquareSize},
{"one hundred large pfb large block", 0, 100, 100000, appconsts.DefaultMaxSquareSize},
{"one hundred large pfb medium block", 100, 100, 100000, appconsts.DefaultMaxSquareSize},
{"mixed transactions large block", 100, 100, 100000, appconsts.DefaultMaxSquareSize},
Expand Down Expand Up @@ -75,7 +75,7 @@ func Test_estimateSquareSize_MultiBlob(t *testing.T) {
func() [][]int {
return blobfactory.Repeat([]int{1000}, 10)
},
8, 8,
16, 8,
},
{
"10 multiblob 4 share transactions",
Expand Down
Loading

0 comments on commit 20845fa

Please sign in to comment.