mirror of
https://github.com/vacp2p/linea-monorepo.git
synced 2026-01-09 04:08:01 -05:00
fixed race condition in the prepareWitnesses function: before the fix, goroutine used to change numEffWitnesses but the top-level method did not wait for goroutine to complete, that caused the usage of the numEffWitnesses before it change in the other methods (#939)
This commit is contained in:
@@ -134,7 +134,7 @@ func (ci *CircuitAlignmentInput) prepareWitnesses(run *wizard.ProverRuntime) {
|
||||
return ci.witnesses[ii].Fill(ci.nbPublicInputs, 0, witnessFillers[ii])
|
||||
})
|
||||
}
|
||||
go func() {
|
||||
wg.Go(func() error {
|
||||
var filled int
|
||||
for j := 0; j < dataCol.Len(); j++ {
|
||||
mask := maskCol.Get(j)
|
||||
@@ -144,7 +144,7 @@ func (ci *CircuitAlignmentInput) prepareWitnesses(run *wizard.ProverRuntime) {
|
||||
data := dataCol.Get(j)
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
return nil
|
||||
case witnessFillers[filled/ci.nbPublicInputs] <- data:
|
||||
}
|
||||
filled++
|
||||
@@ -160,7 +160,7 @@ func (ci *CircuitAlignmentInput) prepareWitnesses(run *wizard.ProverRuntime) {
|
||||
for filled < ci.nbPublicInputs*ci.NbCircuitInstances {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
return nil
|
||||
case witnessFillers[filled/ci.nbPublicInputs] <- ci.InputFiller(filled/ci.nbPublicInputs, filled%ci.nbPublicInputs):
|
||||
}
|
||||
filled++
|
||||
@@ -168,7 +168,9 @@ func (ci *CircuitAlignmentInput) prepareWitnesses(run *wizard.ProverRuntime) {
|
||||
close(witnessFillers[(filled-1)/ci.nbPublicInputs])
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
return nil
|
||||
})
|
||||
if err := wg.Wait(); err != nil {
|
||||
utils.Panic("fill witness: %v", err.Error())
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user