Skip to content

Commit

Permalink
fix!: TestMaxBlockSize flake
Browse files Browse the repository at this point in the history
  • Loading branch information
rootulp committed Mar 5, 2024
1 parent f3fb834 commit 98a3373
Show file tree
Hide file tree
Showing 13 changed files with 18 additions and 13 deletions.
1 change: 1 addition & 0 deletions app/extend_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ func ExtendBlock(data coretypes.Data, appVersion uint64) (*rsmt2d.ExtendedDataSq
dataSquare, err := square.Construct(
data.Txs.ToSliceOfBytes(),
appconsts.SquareSizeUpperBound(appVersion),
appconsts.SquareSizeUpperBound(appVersion),
appconsts.SubtreeRootThreshold(appVersion),
)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions app/prepare_proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ func (app *App) PrepareProposal(req abci.RequestPrepareProposal) abci.ResponsePr
// The txs returned are the ones used in the square and block
dataSquare, txs, err := square.Build(txs,
app.GovSquareSizeUpperBound(sdkCtx),
appconsts.SquareSizeUpperBound(app.GetBaseApp().AppVersion(sdkCtx)),
appconsts.SubtreeRootThreshold(app.GetBaseApp().AppVersion(sdkCtx)),
)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions app/process_proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ func (app *App) ProcessProposal(req abci.RequestProcessProposal) (resp abci.Resp
dataSquare, err := square.Construct(
req.BlockData.Txs,
app.GovSquareSizeUpperBound(sdkCtx),
appconsts.SquareSizeUpperBound(app.GetBaseApp().AppVersion(sdkCtx)),
subtreeRootThreshold,
)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion app/test/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ func (s *IntegrationTestSuite) SetupSuite() {

func (s *IntegrationTestSuite) TestMaxBlockSize() {
t := s.T()
t.Skip() // skip this test because it is flaky.

singleBlobTxGen := func(c client.Context) []coretypes.Tx {
return blobfactory.RandBlobTxsWithAccounts(
Expand Down Expand Up @@ -245,6 +244,7 @@ func (s *IntegrationTestSuite) TestShareInclusionProof() {

// get the blob shares
shareRange, err := square.BlobShareRange(blockRes.Block.Txs.ToSliceOfBytes(), int(txResp.Index), 0,
appconsts.DefaultSquareSizeUpperBound,
appconsts.DefaultSquareSizeUpperBound,
appconsts.DefaultSubtreeRootThreshold,
)
Expand Down
4 changes: 2 additions & 2 deletions app/test/process_proposal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ func TestProcessProposal(t *testing.T) {
Txs: coretypes.Txs(sendTxs).ToSliceOfBytes(),
},
mutator: func(d *tmproto.Data) {
dataSquare, err := square.Construct(d.Txs, appconsts.DefaultSquareSizeUpperBound, appconsts.DefaultSubtreeRootThreshold)
dataSquare, err := square.Construct(d.Txs, appconsts.DefaultSquareSizeUpperBound, appconsts.DefaultSquareSizeUpperBound, appconsts.DefaultSubtreeRootThreshold)
require.NoError(t, err)

b := shares.NewEmptyBuilder().ImportRawShare(dataSquare[1].ToBytes())
Expand Down Expand Up @@ -363,7 +363,7 @@ func TestProcessProposal(t *testing.T) {
}

func calculateNewDataHash(t *testing.T, txs [][]byte) []byte {
dataSquare, err := square.Construct(txs, appconsts.DefaultSquareSizeUpperBound, appconsts.DefaultSubtreeRootThreshold)
dataSquare, err := square.Construct(txs, appconsts.DefaultSquareSizeUpperBound, appconsts.DefaultSquareSizeUpperBound, appconsts.DefaultSubtreeRootThreshold)
require.NoError(t, err)
eds, err := da.ExtendShares(shares.ToBytes(dataSquare))
require.NoError(t, err)
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ require (
)

replace (
github.com/celestiaorg/go-square => ../go-square
github.com/cosmos/cosmos-sdk => github.com/celestiaorg/cosmos-sdk v1.20.1-sdk-v0.46.16
// Pin to ledger-cosmos-go v0.12.4 to avoid a breaking change introduced in v0.13.0
// The following replace statement can be removed when we upgrade to cosmos-sdk >= v0.50.0
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,6 @@ github.com/celestiaorg/celestia-core v1.35.0-tm-v0.34.29 h1:sXERzNXgyHyqTKNQx4S2
github.com/celestiaorg/celestia-core v1.35.0-tm-v0.34.29/go.mod h1:weZR4wYx1Vcw3g1Jc5G8VipG4M+KUDSqeIzyyWszmsQ=
github.com/celestiaorg/cosmos-sdk v1.20.1-sdk-v0.46.16 h1:9U9UthIJSOyVjabD5PkD6aczvqlWOyAFTOXw0duPT5k=
github.com/celestiaorg/cosmos-sdk v1.20.1-sdk-v0.46.16/go.mod h1:Tvsc3YnqvflXTYC8xIy/Q07Es95xZ1pZC/imoKogtbg=
github.com/celestiaorg/go-square v1.0.0-rc0 h1:QtYyGICIWAx7t9k29s28hpZa8CjbDOZv3fgKSEAt7JI=
github.com/celestiaorg/go-square v1.0.0-rc0/go.mod h1:OtnFhGj0zfWwaC7AEBI4Bn7Fyy2cUp/X5K3kWn7niCs=
github.com/celestiaorg/go-square/merkle v0.0.0-20240117232118-fd78256df076 h1:PYInrsYzrDIsZW9Yb86OTi2aEKuPcpgJt6Mc0Jlc/yg=
github.com/celestiaorg/go-square/merkle v0.0.0-20240117232118-fd78256df076/go.mod h1:hlidgivKyvv7m4Yl2Fdf2mSTmazZYxX8+bnr5IQrI98=
github.com/celestiaorg/knuu v0.10.0 h1:uYO6hVsoCAJ/Q4eV0Pn8CLbbupGAjD56xQc4y2t4lf0=
Expand Down
2 changes: 1 addition & 1 deletion pkg/proof/proof.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func NewTxInclusionProof(txs [][]byte, txIndex, appVersion uint64) (ShareProof,
return ShareProof{}, fmt.Errorf("txIndex %d out of bounds", txIndex)
}

builder, err := square.NewBuilder(appconsts.SquareSizeUpperBound(appVersion), appconsts.SubtreeRootThreshold(appVersion), txs...)
builder, err := square.NewBuilder(appconsts.SquareSizeUpperBound(appVersion), appconsts.SquareSizeUpperBound(appVersion), appconsts.SubtreeRootThreshold(appVersion), txs...)
if err != nil {
return ShareProof{}, err
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/proof/proof_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func TestNewShareInclusionProof(t *testing.T) {
txs := testfactory.GenerateRandomTxs(50, 500)
txs = append(txs, blobTxs...)

dataSquare, err := square.Construct(txs.ToSliceOfBytes(), appconsts.SquareSizeUpperBound(appconsts.LatestVersion), appconsts.SubtreeRootThreshold(appconsts.LatestVersion))
dataSquare, err := square.Construct(txs.ToSliceOfBytes(), appconsts.SquareSizeUpperBound(appconsts.LatestVersion), appconsts.SquareSizeUpperBound(appconsts.LatestVersion), appconsts.SubtreeRootThreshold(appconsts.LatestVersion))
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -231,7 +231,7 @@ func TestNewShareInclusionProof(t *testing.T) {
func TestAllSharesInclusionProof(t *testing.T) {
txs := testfactory.GenerateRandomTxs(243, 500)

dataSquare, err := square.Construct(txs.ToSliceOfBytes(), appconsts.SquareSizeUpperBound(appconsts.LatestVersion), appconsts.SubtreeRootThreshold(appconsts.LatestVersion))
dataSquare, err := square.Construct(txs.ToSliceOfBytes(), appconsts.SquareSizeUpperBound(appconsts.LatestVersion), appconsts.SquareSizeUpperBound(appconsts.LatestVersion), appconsts.SubtreeRootThreshold(appconsts.LatestVersion))
require.NoError(t, err)
assert.Equal(t, 256, len(dataSquare))

Expand Down
2 changes: 1 addition & 1 deletion pkg/proof/querier.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func QueryShareInclusionProof(_ sdk.Context, path []string, req abci.RequestQuer
// construct the data square from the block data. As we don't have
// access to the application's state machine we use the upper bound
// square size instead of the square size dictated from governance
dataSquare, err := square.Construct(pbb.Data.Txs, appconsts.SquareSizeUpperBound(pbb.Header.Version.App), appconsts.SubtreeRootThreshold(pbb.Header.Version.App))
dataSquare, err := square.Construct(pbb.Data.Txs, appconsts.SquareSizeUpperBound(pbb.Header.Version.App), appconsts.SquareSizeUpperBound(pbb.Header.Version.App), appconsts.SubtreeRootThreshold(pbb.Header.Version.App))
if err != nil {
return nil, err
}
Expand Down
1 change: 1 addition & 0 deletions test/util/malicious/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ func TestMaliciousTestNode(t *testing.T) {
require.Equal(t, block.Block.DataHash.Bytes(), dah.Hash())

correctSquare, err := square.Construct(block.Block.Txs.ToSliceOfBytes(),
appconsts.DefaultSquareSizeUpperBound,
appconsts.DefaultSquareSizeUpperBound,
appconsts.DefaultSubtreeRootThreshold,
)
Expand Down
4 changes: 2 additions & 2 deletions test/util/malicious/out_of_order_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type ExportFn func(builder *square.Builder) (square.Square, error)
// not check the underlying validity of the transactions.
// Errors should not occur and would reflect a violation in an invariant.
func Build(txs [][]byte, appVersion uint64, maxSquareSize int, efn ExportFn) (square.Square, [][]byte, error) {
builder, err := square.NewBuilder(maxSquareSize, appconsts.SubtreeRootThreshold(appVersion))
builder, err := square.NewBuilder(maxSquareSize, appconsts.SquareSizeUpperBound(appVersion), appconsts.SubtreeRootThreshold(appVersion))
if err != nil {
return nil, nil, err
}
Expand All @@ -49,7 +49,7 @@ func Build(txs [][]byte, appVersion uint64, maxSquareSize int, efn ExportFn) (sq
// square. This mimics the functionality of the normal Construct function, but
// acts maliciously by not following some of the block validity rules.
func Construct(txs [][]byte, appVersion uint64, maxSquareSize int, efn ExportFn) (square.Square, error) {
builder, err := square.NewBuilder(maxSquareSize, appconsts.SubtreeRootThreshold(appVersion), txs...)
builder, err := square.NewBuilder(maxSquareSize, appconsts.SquareSizeUpperBound(appVersion), appconsts.SubtreeRootThreshold(appVersion), txs...)
if err != nil {
return nil, err
}
Expand Down
6 changes: 4 additions & 2 deletions x/blobstream/client/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,10 @@ func txCmd() *cobra.Command {

version := blockRes.Block.Header.Version.App
maxSquareSize := appconsts.SquareSizeUpperBound(version)
squareSizeUpperBound := appconsts.SquareSizeUpperBound(version)
subtreeRootThreshold := appconsts.SubtreeRootThreshold(version)

shareRange, err := square.TxShareRange(blockRes.Block.Data.Txs.ToSliceOfBytes(), int(tx.Index), maxSquareSize, subtreeRootThreshold)
shareRange, err := square.TxShareRange(blockRes.Block.Data.Txs.ToSliceOfBytes(), int(tx.Index), maxSquareSize, squareSizeUpperBound, subtreeRootThreshold)
if err != nil {
return err
}
Expand Down Expand Up @@ -148,8 +149,9 @@ func blobCmd() *cobra.Command {

version := blockRes.Block.Header.Version.App
maxSquareSize := appconsts.SquareSizeUpperBound(version)
squareSizeUpperBound := appconsts.SquareSizeUpperBound(version)
subtreeRootThreshold := appconsts.SubtreeRootThreshold(version)
blobShareRange, err := square.BlobShareRange(blockRes.Block.Txs.ToSliceOfBytes(), int(tx.Index), int(blobIndex), maxSquareSize, subtreeRootThreshold)
blobShareRange, err := square.BlobShareRange(blockRes.Block.Txs.ToSliceOfBytes(), int(tx.Index), int(blobIndex), maxSquareSize, squareSizeUpperBound, subtreeRootThreshold)
if err != nil {
return err
}
Expand Down

0 comments on commit 98a3373

Please sign in to comment.