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: implements the top-level of the limitless prover #352

Draft
wants to merge 16 commits into
base: main
Choose a base branch
from
Draft
53 changes: 53 additions & 0 deletions prover/protocol/distributed/distributed.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package distributed

import (
"github.com/consensys/linea-monorepo/prover/protocol/compiler/innerproduct"
"github.com/consensys/linea-monorepo/prover/protocol/compiler/mimc"
"github.com/consensys/linea-monorepo/prover/protocol/compiler/specialqueries"
"github.com/consensys/linea-monorepo/prover/protocol/ifaces"
"github.com/consensys/linea-monorepo/prover/protocol/query"
"github.com/consensys/linea-monorepo/prover/protocol/wizard"
)

Expand Down Expand Up @@ -30,6 +34,8 @@ type ModuleDiscoverer interface {
Analyze(comp *wizard.CompiledIOP)
ModuleList(comp *wizard.CompiledIOP) []moduleName
FindModule(col ifaces.Column) moduleName
// given a query and a module name it checks if the query is inside the module
QueryIsInModule(ifaces.Query, moduleName) bool
}

// This transforms the initial wizard. So it is not really the initial
Expand All @@ -39,6 +45,7 @@ type ModuleDiscoverer interface {
// maxNumSegment give the max number of segments in a module.
func Distribute(initialWizard *wizard.CompiledIOP, disc ModuleDiscoverer, maxSegmentSize, maxNumSegment int) DistributedWizard {

prepare(initialWizard)
// analyze the initialWizard to split it to modules.
disc.Analyze(initialWizard)

Expand Down Expand Up @@ -69,10 +76,56 @@ func extractDistModule(
moduleName moduleName,
maxSegmentSize, maxNumSegment int,
) DistributedModule {
// initialize two compiledIOPs, for LPP and GL.
disModule := DistributedModule{
LookupPermProj: &wizard.CompiledIOP{},
GlobalLocal: &wizard.CompiledIOP{},
}

for _, qName := range comp.QueriesNoParams.AllUnignoredKeys() {

// Filter LPP queries
q := comp.QueriesNoParams.Data(qName)

switch v := q.(type) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you have a switch, it would be simpler to have one function for global, one for local and one for lookup, and one for projection and one for permutation. That way you don't have to do a switch in a switch, it's nicer to read that way.

You may want to move the if disc.QueryIsInModule(v, moduleName) our of the switch as it happens in all situations

case query.Inclusion, query.Permutation, query.Projection:
if disc.QueryIsInModule(v, moduleName) {
addToLookupPermProj(disModule.LookupPermProj, q)
}
case query.GlobalConstraint, query.LocalConstraint, query.LocalOpening:
if disc.QueryIsInModule(v, moduleName) {
addToGlobalLocal(disModule.GlobalLocal, q)
}
default:
// Handle other types if necessary
panic("Other type queries are not handled")
}

}
return disModule

}

func addToLookupPermProj(comp *wizard.CompiledIOP, q ifaces.Query) {
panic("unimplemented")
}

func addToGlobalLocal(comp *wizard.CompiledIOP, q ifaces.Query) {
panic("unimplemented")
}

// It builds a CompiledIOP object that contains the consistency checks among the segments.
func aggregator(distModules []DistributedModule, maxNumSegments int) *wizard.CompiledIOP {
panic("unimplemented")
}

// prepare reduces any query to LPP or GL.
// it prepares the columns that depends on whole the witness,e.g., M column for lookups.
func prepare(comp *wizard.CompiledIOP) {
mimc.CompileMiMC(comp)
specialqueries.RangeProof(comp)
specialqueries.CompileFixedPermutations(comp)
innerproduct.Compile(comp)

// prepareLookup(comp)
}
11 changes: 10 additions & 1 deletion prover/protocol/distributed/module_discover.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package distributed

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

// it implement [ModuleDiscoverer], it splits the compiler horizontally.
type HorizontalSplitting struct {
Expand All @@ -14,3 +17,9 @@ func (split HorizontalSplitting) Analyze(comp *wizard.CompiledIOP) {
func (split HorizontalSplitting) Split(comp *wizard.CompiledIOP) {

}

// QueryIsInModule checks if the given query is inside the given module
func (split HorizontalSplitting) QueryIsInModule(ifaces.Query, moduleName) bool {
panic("unimplemented")

}
40 changes: 40 additions & 0 deletions prover/protocol/query/projection.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package query

import (
"github.com/consensys/gnark/frontend"
"github.com/consensys/linea-monorepo/prover/protocol/ifaces"
)

type Projection struct {
ID ifaces.QueryID
ColumnsA, ColumnsB []ifaces.Column
FilterA, FilterB ifaces.Column
}

// NewInclusion constructs an inclusion. Will panic if it is mal-formed
func NewProjection(
id ifaces.QueryID,
columnsA, columnsB []ifaces.Column,
filterA, filterB ifaces.Column,
) Projection {

return Projection{ColumnsA: columnsA, ColumnsB: columnsB, ID: id, FilterA: filterA, FilterB: filterB}
}

// Name implements the [ifaces.Query] interface
func (r Projection) Name() ifaces.QueryID {
return r.ID
}

// Check implements the [ifaces.Query] interface
func (r Projection) Check(run ifaces.Runtime) error {

panic("unimplemented")
}

// GnarkCheck implements the [ifaces.Query] interface. It will panic in this
// construction because we do not have a good way to check the query within a
// circuit
func (i Projection) CheckGnark(api frontend.API, run ifaces.GnarkRuntime) {
panic("UNSUPPORTED : can't check an Projection query directly into the circuit")
}
Loading