Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prover/Codehash Non Power of Two Column Size #618

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion prover/protocol/column/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"github.com/consensys/linea-monorepo/prover/protocol/ifaces"
"github.com/consensys/linea-monorepo/prover/utils"
"github.com/consensys/linea-monorepo/prover/utils/collection"
"github.com/sirupsen/logrus"
)

// Store registers [Natural] for structs that can return the infos given a name
Expand Down Expand Up @@ -63,7 +64,9 @@ func (s *Store) AddToRound(round int, name ifaces.ColID, size int, status Status
}

if !utils.IsPowerOfTwo(size) {
utils.Panic("can't register %v because it has a non-power of two size (%v)", name, size)
adjustedSize := utils.NextPowerOfTwo(size)
logrus.Infof("Can't register %v because it has a non-power of two size (%v). Adjusted size to next power of two: %v", name, size, adjustedSize)
size = adjustedSize
}

// Compute the location of the commitment in the store
Expand Down
5 changes: 4 additions & 1 deletion prover/protocol/wizard/compiled.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,10 @@ func (c *CompiledIOP) InsertCommit(round int, name ifaces.ColID, size int) iface
// - if the size of the column is not a power of 2
// - if a column using the same name has already been registered
func (c *CompiledIOP) InsertColumn(round int, name ifaces.ColID, size int, status column.Status) ifaces.Column {

// Panic if the size is not a power of 2
if !utils.IsPowerOfTwo(size) {
utils.Panic("Registering column %v with a non power of two size = %v", name, size)
}
// @alex: this has actually caught a few typos. When wrongly setting an
// incorrect but very large size here, it will generate a disproportionate
// wizard
Expand Down
11 changes: 4 additions & 7 deletions prover/zkevm/arithmetization/definition.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,14 @@ func (s *schemaScanner) scanColumns() {
module = s.Modules[ctx.Module()]
moduleLimit = s.LimitMap[module.Name]
mult = ctx.LengthMultiplier()
size = int(mult) * moduleLimit
)

// adjust the size , this adjusts the size for interleaved columns and their permuted version.
// Since these are the only columns from corset with non-power of two.
if !utils.IsPowerOfTwo(size) {
size = utils.NextPowerOfTwo(int(mult) * moduleLimit)
}
/*if _, isIL := s.InterleavedColumns[name]; isIL {
continue
}*/

// #nosec G115 -- this bound will not overflow
s.Comp.InsertCommit(0, ifaces.ColID(name), size)
s.Comp.InsertCommit(0, ifaces.ColID(name), int(mult)*moduleLimit)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/consensys/linea-monorepo/prover/protocol/ifaces"
"github.com/consensys/linea-monorepo/prover/protocol/wizard"
sym "github.com/consensys/linea-monorepo/prover/symbolic"
"github.com/consensys/linea-monorepo/prover/utils"
"github.com/consensys/linea-monorepo/prover/zkevm/prover/common"
commonconstraints "github.com/consensys/linea-monorepo/prover/zkevm/prover/common/common_constraints"
"github.com/consensys/linea-monorepo/prover/zkevm/prover/statemanager/mimccodehash"
Expand Down Expand Up @@ -57,7 +58,7 @@ type Module struct {
func NewModule(comp *wizard.CompiledIOP, name string, ss *statesummary.Module, mch *mimccodehash.Module) Module {

name = name + "_CODEHASH_CONSISTENCY"
size := ss.IsActive.Size() + mch.IsActive.Size()
size := utils.NextPowerOfTwo[int](ss.IsActive.Size() + mch.IsActive.Size())

ch := Module{
StateSummaryInput: ss,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestConsistency(t *testing.T) {
mimcCodeHash *mimccodehash.Module
consistency Module
sizeStateSummary = 128
sizeMimcCodeHash = 128
sizeMimcCodeHash = 256
)

define := func(b *wizard.Builder) {
Expand Down
Loading