Skip to content

Commit

Permalink
chore!: rename GovSquareSizeUpperBound
Browse files Browse the repository at this point in the history
  • Loading branch information
rootulp committed Jul 26, 2023
1 parent af1a07a commit d96e6a0
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 15 deletions.
2 changes: 1 addition & 1 deletion app/prepare_proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (app *App) PrepareProposal(req abci.RequestPrepareProposal) abci.ResponsePr

// build the square from the set of valid and prioritised transactions.
// The txs returned are the ones used in the square and block
dataSquare, txs, err := square.Build(txs, app.GetBaseApp().AppVersion(), app.GovSquareSizeUpperBound(sdkCtx))
dataSquare, txs, err := square.Build(txs, app.GetBaseApp().AppVersion(), app.GetMaxSquareSize(sdkCtx))
if err != nil {
panic(err)
}
Expand Down
2 changes: 1 addition & 1 deletion app/process_proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func (app *App) ProcessProposal(req abci.RequestProcessProposal) (resp abci.Resp
}

// Construct the data square from the block's transactions
dataSquare, err := square.Construct(req.BlockData.Txs, app.GetBaseApp().AppVersion(), app.GovSquareSizeUpperBound(sdkCtx))
dataSquare, err := square.Construct(req.BlockData.Txs, app.GetBaseApp().AppVersion(), app.GetMaxSquareSize(sdkCtx))
if err != nil {
logInvalidPropBlockError(app.Logger(), req.Header, "failure to compute data square from transactions:", err)
return reject()
Expand Down
22 changes: 13 additions & 9 deletions app/square_size.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
)

// GovSquareSizeUpperBound returns the maximum square size that can be used for a block
// using the governance parameter blob.GovMaxSquareSize.
func (app *App) GovSquareSizeUpperBound(ctx sdk.Context) int {
// GetMaxSquareSize returns the maximum square size that can be used for a
// block.
func (app *App) GetMaxSquareSize(ctx sdk.Context) int {
// TODO: fix hack that forces the max square size for the first height to
// 64. This is due to our fork of the sdk not initializing state before
// BeginBlock of the first block. This is remedied in versions of the sdk
Expand All @@ -18,11 +18,15 @@ func (app *App) GovSquareSizeUpperBound(ctx sdk.Context) int {
return int(appconsts.DefaultGovMaxSquareSize)
}

gmax := int(app.BlobKeeper.GovMaxSquareSize(ctx))
// perform a secondary check on the max square size.
if gmax > appconsts.SquareSizeUpperBound(app.AppVersion()) {
gmax = appconsts.SquareSizeUpperBound(app.AppVersion())
}
govMax := int(app.BlobKeeper.GovMaxSquareSize(ctx))
upperBound := appconsts.SquareSizeUpperBound(app.AppVersion())

return min(govMax, upperBound)
}

return gmax
func min(a, b int) int {
if a < b {
return a
}
return b
}
6 changes: 3 additions & 3 deletions pkg/appconsts/versioned_consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ func SubtreeRootThreshold(_ uint64) int {
return v1.SubtreeRootThreshold
}

// SquareSizeUpperBound is the maximum original square width possible
// for a version of the state machine. The maximum is decided through
// governance. See `DefaultGovMaxSquareSize`.
// SquareSizeUpperBound is the maximum original square width possible for a
// version of the state machine. In other words, this value acts as an upper
// bound for GovMaxSquareSize.
func SquareSizeUpperBound(_ uint64) int {
return v1.SquareSizeUpperBound
}
Expand Down
2 changes: 1 addition & 1 deletion test/util/malicious/out_of_order_prepare.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (a *App) OutOfOrderPrepareProposal(req abci.RequestPrepareProposal) abci.Re

// build the square from the set of valid and prioritised transactions.
// The txs returned are the ones used in the square and block
dataSquare, txs, err := Build(txs, a.GetBaseApp().AppVersion(), a.GovSquareSizeUpperBound(sdkCtx), OutOfOrderExport)
dataSquare, txs, err := Build(txs, a.GetBaseApp().AppVersion(), a.GetMaxSquareSize(sdkCtx), OutOfOrderExport)
if err != nil {
panic(err)
}
Expand Down

0 comments on commit d96e6a0

Please sign in to comment.