Skip to content

Commit

Permalink
added more methodes to module discoverer
Browse files Browse the repository at this point in the history
  • Loading branch information
Soleimani193 committed Dec 17, 2024
1 parent 5237674 commit ab6b7fb
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions prover/protocol/distributed/module_discoverer/module_discoverer.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/consensys/linea-monorepo/prover/protocol/ifaces"
"github.com/consensys/linea-monorepo/prover/protocol/wizard"
"github.com/consensys/linea-monorepo/prover/symbolic"
)

type ModuleName string
Expand Down Expand Up @@ -67,3 +68,40 @@ func (p *PeriodSeperatingModuleDiscoverer) FindModule(col ifaces.Column) ModuleN
}
return "no column found" // Return a default or error value
}

// ColumnIsInModule checks that the given column is inside the given module.
func (p *PeriodSeperatingModuleDiscoverer) ColumnIsInModule(col ifaces.Column, name ModuleName) bool {
for _, c := range p.modules[name] {
if c.GetColID() == col.GetColID() {
return true
}
}
return false
}

// ExpressionIsInModule checks that all the columns in the expression are from the given module.
//
// It does not check the presence of the coins and other metadata.
func (p *PeriodSeperatingModuleDiscoverer) ExpressionIsInModule(expr symbolic.Expression, name ModuleName) bool {
var (
board = expr.Board()
metadata = board.ListVariableMetadata()
b = true
cols []ifaces.Column
)

for _, m := range metadata {
switch v := m.(type) {
case ifaces.Column:
if !p.ColumnIsInModule(v, name) {
b = b && false
cols = append(cols, v)
}
}
}
if len(cols) == 0 {
panic("could not find any column in the expression")
} else {
return b
}
}

0 comments on commit ab6b7fb

Please sign in to comment.