Skip to content

Commit

Permalink
Merge branch 'prover/setup' of github.com:Consensys/linea-monorepo in…
Browse files Browse the repository at this point in the history
…to prover/setup
  • Loading branch information
AlexandreBelling committed Oct 16, 2024
2 parents 06cf469 + 4cdf298 commit c4541de
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 14 deletions.
17 changes: 9 additions & 8 deletions prover/backend/aggregation/craft.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ const (
func collectFields(cfg *config.Config, req *Request) (*CollectedFields, error) {

var (
l2MessageHashes []string
l2MsgBlockOffsets []bool
cf = &CollectedFields{
allL2MessageHashes []string
l2MsgBlockOffsets []bool
cf = &CollectedFields{
L2MsgTreeDepth: l2MsgMerkleTreeDepth,
ParentAggregationLastBlockTimestamp: uint(req.ParentAggregationLastBlockTimestamp),
LastFinalizedL1RollingHash: req.ParentAggregationLastL1RollingHash,
Expand All @@ -55,9 +55,10 @@ func collectFields(cfg *config.Config, req *Request) (*CollectedFields, error) {
for i, execReqFPath := range req.ExecutionProofs {

var (
po = &execution.Response{}
fpath = path.Join(cfg.Execution.DirTo(), execReqFPath)
f = files.MustRead(fpath)
po = &execution.Response{}
l2MessageHashes []string
fpath = path.Join(cfg.Execution.DirTo(), execReqFPath)
f = files.MustRead(fpath)
)

if err := json.NewDecoder(f).Decode(po); err != nil {
Expand Down Expand Up @@ -112,7 +113,7 @@ func collectFields(cfg *config.Config, req *Request) (*CollectedFields, error) {
finalBlock := &po.BlocksData[len(po.BlocksData)-1]
piq, err := public_input.ExecutionSerializable{
L2MsgHashes: l2MessageHashes,
FinalStateRootHash: po.PublicInput.Hex(), // TODO @tabaie make sure this is the right value
FinalStateRootHash: finalBlock.RootHash.Hex(),
FinalBlockNumber: uint64(cf.FinalBlockNumber),
FinalBlockTimestamp: finalBlock.TimeStamp,
FinalRollingHash: cf.L1RollingHash,
Expand Down Expand Up @@ -166,7 +167,7 @@ func collectFields(cfg *config.Config, req *Request) (*CollectedFields, error) {
}

cf.L2MessagingBlocksOffsets = utils.HexEncodeToString(PackOffsets(l2MsgBlockOffsets))
cf.L2MsgRootHashes = PackInMiniTrees(l2MessageHashes)
cf.L2MsgRootHashes = PackInMiniTrees(allL2MessageHashes)

return cf, nil

Expand Down
30 changes: 24 additions & 6 deletions prover/circuits/pi-interconnection/assign.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"encoding/base64"
"errors"
"fmt"
"hash"

"github.com/consensys/gnark-crypto/ecc/bls12-381/fr"
Expand Down Expand Up @@ -121,7 +122,7 @@ func (c *Compiled) Assign(r Request) (a Circuit, err error) {
}

if prevShnarf = shnarf.Compute(); !bytes.Equal(prevShnarf, shnarfs[i]) {
err = errors.New("shnarf mismatch")
err = fmt.Errorf("shnarf mismatch, i:%d, shnarf: %x, prevShnarf: %x, ", i, shnarfs[i], prevShnarf)
return
}
}
Expand Down Expand Up @@ -216,13 +217,30 @@ func (c *Compiled) Assign(r Request) (a Circuit, err error) {
a.ExecutionFPIQ[i] = executionFPI.ToSnarkType().FunctionalPublicInputQSnark
}
// consistency check
if executionFPI.FinalBlockTimestamp != aggregationFPI.FinalBlockTimestamp ||
executionFPI.FinalBlockNumber != aggregationFPI.FinalBlockNumber ||
executionFPI.FinalRollingHash != aggregationFPI.FinalRollingHash ||
executionFPI.FinalRollingHashNumber != aggregationFPI.FinalRollingHashNumber {
err = errors.New("final execution values not matching final aggregation values")
if executionFPI.FinalBlockTimestamp != aggregationFPI.FinalBlockTimestamp {
err = fmt.Errorf("final block timestamps do not match: execution=%x, aggregation=%x",
executionFPI.FinalBlockTimestamp, aggregationFPI.FinalBlockTimestamp)
return
}
if executionFPI.FinalBlockNumber != aggregationFPI.FinalBlockNumber {
err = fmt.Errorf("final block numbers do not match: execution=%v, aggregation=%x",
executionFPI.FinalBlockNumber, aggregationFPI.FinalBlockNumber)
return
}
if executionFPI.FinalRollingHash != [32]byte{} {
if executionFPI.FinalRollingHash != aggregationFPI.FinalRollingHash {
err = fmt.Errorf("final rolling hashes do not match: execution=%x, aggregation=%x",
executionFPI.FinalRollingHash, aggregationFPI.FinalRollingHash)
return
}

if executionFPI.FinalRollingHashNumber != aggregationFPI.FinalRollingHashNumber {
err = fmt.Errorf("final rolling hash numbers do not match: execution=%v, aggregation=%v",
executionFPI.FinalRollingHashNumber, aggregationFPI.FinalRollingHashNumber)
return
}
}

if len(l2MessageHashes) > maxNbL2MessageHashes {
err = errors.New("too many L2 messages")
return
Expand Down

0 comments on commit c4541de

Please sign in to comment.