- 
                Notifications
    You must be signed in to change notification settings 
- Fork 628
feat: openvm euclid v2 #1613
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
feat: openvm euclid v2 #1613
Conversation
…submit multiple batches in a single transaction
…ntextID logic to support multiple batches by concatenating batch hashes
Co-authored-by: noelwei <fan@scroll.io>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
♻️ Duplicate comments (2)
coordinator/internal/logic/provertask/batch_prover_task.go (2)
224-228: 🛠️ Refactor suggestionAdd null check for OpenVMChunkProof metadata
When accessing fields from
openvmProof.MetaData.ChunkInfo, there's no check to ensure it's not nil, which could lead to a panic.if openvmProof, ok := proof.(*message.OpenVMChunkProof); ok { + if openvmProof.MetaData.ChunkInfo == nil { + return nil, fmt.Errorf("missing ChunkInfo in OpenVMChunkProof for chunk hash: %s", chunk.Hash) + } chunkInfo.InitialBlockNumber = openvmProof.MetaData.ChunkInfo.InitialBlockNumber chunkInfo.BlockCtxs = openvmProof.MetaData.ChunkInfo.BlockCtxs chunkInfo.TxDataLength = openvmProof.MetaData.ChunkInfo.TxDataLength }
291-298: 🛠️ Refactor suggestionAdd safety checks and use constants for BlobDataProof parsing
The code directly accesses byte ranges in
dbBatch.BlobDataProofwithout validating its length or using named constants for offsets, which could lead to panic if the input is malformed.// Memory layout of `BlobDataProof`: used in Codec.BlobDataProofForPointEvaluation() // | z | y | kzg_commitment | kzg_proof | // |---------|---------|----------------|-----------| // | bytes32 | bytes32 | bytes48 | bytes48 | +const ( + blobDataProofMinLength = 160 // Minimum length for valid BlobDataProof + kzgCommitmentOffset = 64 // Start offset for KZG commitment + kzgProofOffset = 112 // Start offset for KZG proof + byte48Length = 48 // Length of Byte48 fields +) + +// Ensure BlobDataProof has sufficient length to extract all fields +if len(dbBatch.BlobDataProof) < blobDataProofMinLength { + return nil, fmt.Errorf("BlobDataProof length insufficient: got %d bytes, need at least %d bytes", + len(dbBatch.BlobDataProof), blobDataProofMinLength) +} + taskDetail.KzgProof = message.Byte48{Big: hexutil.Big(*new(big.Int).SetBytes(dbBatch.BlobDataProof[kzgProofOffset:kzgProofOffset+byte48Length]))} taskDetail.KzgCommitment = message.Byte48{Big: hexutil.Big(*new(big.Int).SetBytes(dbBatch.BlobDataProof[kzgCommitmentOffset:kzgCommitmentOffset+byte48Length]))}
🧹 Nitpick comments (6)
common/types/message/message.go (6)
1-11: Add appropriate import sorting for math/bigThe import for
math/bigis added but not sorted according to standard Go conventions (standard libraries first, then third-party imports).import ( "encoding/json" "errors" "fmt" - "math/big" + "math/big" "github.com/scroll-tech/go-ethereum/common" "github.com/scroll-tech/go-ethereum/common/hexutil" )
48-54: Clarify comment on ForkName field usageThe comment for the
ForkNamefield is ambiguous. Improve the documentation to clarify the expected values and usage.type ChunkTaskDetail struct { - // use one of the string of EuclidFork / EuclidV2Fork + // ForkName must be one of the constants: EuclidFork or EuclidV2Fork ForkName string `json:"fork_name"` BlockHashes []common.Hash `json:"block_hashes"` PrevMsgQueueHash common.Hash `json:"prev_msg_queue_hash"` }
56-74: Fix typo in Byte48 MarshalText commentThere's a typo in the comment for the
MarshalTextmethod.func (e Byte48) MarshalText() ([]byte, error) { i := e.ToInt() - // overrite encode big + // override encode big if sign := i.Sign(); sign < 0 { // sanity check return nil, errors.New("Byte48 must be positive integer") } else { s := i.Text(16) if len(s) > 96 { - return nil, errors.New("integer Exceed 384bit") + return nil, errors.New("integer exceeds 384 bits") } return []byte(fmt.Sprintf("0x%0*s", 96, s)), nil } }
121-135: Add documentation for new ChunkInfo fieldsThe new fields added to the ChunkInfo struct lack documentation explaining their purpose and usage.
type ChunkInfo struct { ChainID uint64 `json:"chain_id"` PrevStateRoot common.Hash `json:"prev_state_root"` PostStateRoot common.Hash `json:"post_state_root"` WithdrawRoot common.Hash `json:"withdraw_root"` DataHash common.Hash `json:"data_hash"` IsPadding bool `json:"is_padding"` TxBytes []byte `json:"tx_bytes"` TxBytesHash common.Hash `json:"tx_data_digest"` PrevMsgQueueHash common.Hash `json:"prev_msg_queue_hash"` + // Hash of the message queue after processing the chunk PostMsgQueueHash common.Hash `json:"post_msg_queue_hash"` + // Total length of transaction data in bytes TxDataLength uint64 `json:"tx_data_length"` + // Initial L2 block number in the chunk InitialBlockNumber uint64 `json:"initial_block_number"` + // Context information for each block in the chunk BlockCtxs []BlockContextV2 `json:"block_ctxs"` }
137-144: Add documentation for BlockContextV2 structThe new
BlockContextV2struct lacks documentation explaining its purpose and how it differs from any potential previous version.+// BlockContextV2 contains metadata about a block in the EuclidV2 fork, +// providing context for verification and execution type BlockContextV2 struct { + // Unix timestamp of the block Timestamp uint64 `json:"timestamp"` + // Base fee per gas in the block BaseFee hexutil.Big `json:"base_fee"` + // Gas limit of the block GasLimit uint64 `json:"gas_limit"` + // Number of transactions in the block NumTxs uint16 `json:"num_txs"` + // Number of L1 messages in the block NumL1Msgs uint16 `json:"num_l1_msgs"` }
330-339: Document purpose of new OpenVMBatchInfo message queue fieldsThe new fields
PrevMsgQueueHashandPostMsgQueueHashlack documentation about their purpose.type OpenVMBatchInfo struct { ParentBatchHash common.Hash `json:"parent_batch_hash"` ParentStateRoot common.Hash `json:"parent_state_root"` StateRoot common.Hash `json:"state_root"` WithdrawRoot common.Hash `json:"withdraw_root"` BatchHash common.Hash `json:"batch_hash"` ChainID uint64 `json:"chain_id"` + // Hash of the message queue before processing the batch PrevMsgQueueHash common.Hash `json:"prev_msg_queue_hash"` + // Hash of the message queue after processing the batch PostMsgQueueHash common.Hash `json:"post_msg_queue_hash"` }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
- zkvm-prover/Cargo.lockis excluded by- !**/*.lock
📒 Files selected for processing (3)
- common/types/message/message.go(7 hunks)
- coordinator/internal/logic/provertask/batch_prover_task.go(6 hunks)
- zkvm-prover/Cargo.toml(2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- zkvm-prover/Cargo.toml
🧰 Additional context used
🧬 Code Definitions (2)
coordinator/internal/logic/provertask/batch_prover_task.go (3)
coordinator/internal/types/auth.go (1)
Hash(134-141)common/types/message/message.go (11)
Halo2ChunkProof(168-178)
ChunkInfo(121-135)
OpenVMChunkProof(310-318)
ProofTypeBatch(43-43)
ChunkProof(153-155)
BatchTaskDetail(100-110)
EuclidV2Fork(15-15)
EuclidV2ForkNameForProver(18-18)
EuclidFork(14-14)
EuclidForkNameForProver(17-17)
Byte48(57-59)coordinator/internal/orm/batch.go (2)
Batch(18-72)
Batch(80-82)
common/types/message/message.go (1)
coordinator/internal/types/auth.go (1)
Hash(134-141)
🔇 Additional comments (9)
common/types/message/message.go (6)
13-19: Excellent addition of fork constants for proper versioningThe renaming of
euclidForktoEuclidForkenhances public accessibility, and the addition of EuclidV2 constants establishes proper versioning support. This change enables better backward compatibility and smooth transitions between fork versions.
76-97: Well-implemented custom JSON marshaling for Byte48The implementation of custom unmarshaling is thorough with proper validation for string format, hex decoding, and byte length. Using this custom approach for 48-byte values handles the 384-bit integers that exceed the default hexutil.Big limit of 256 bits.
100-110: Add documentation comment for BlobBytes encodingThe
BlobBytesfield lacks documentation about its encoding expectations. Past review comments highlighted the need for this clarification.type BatchTaskDetail struct { // use one of the string of EuclidFork / EuclidV2Fork ForkName string `json:"fork_name"` ChunkInfos []*ChunkInfo `json:"chunk_infos"` ChunkProofs []ChunkProof `json:"chunk_proofs"` BatchHeader interface{} `json:"batch_header"` + // BlobBytes contains the raw blob data in binary format (not base64 encoded) BlobBytes []byte `json:"blob_bytes"` KzgProof Byte48 `json:"kzg_proof,omitempty"` KzgCommitment Byte48 `json:"kzg_commitment,omitempty"` ChallengeDigest common.Hash `json:"challenge_digest,omitempty"` }
158-165: Good implementation of fork-aware proof creationThe update to include both
EuclidForkandEuclidV2Forkin the switch case maintains backward compatibility while supporting the new fork version.
191-199: Consistent fork handling in BatchProof creationThe pattern of supporting both forks in the switch statement is well-maintained across all proof creation functions.
248-256: Consistent approach for BundleProof creationThe update to include both
EuclidForkandEuclidV2Forkin the switch case maintains the same pattern used in other proof creation functions, ensuring consistency across the codebase.coordinator/internal/logic/provertask/batch_prover_task.go (3)
219-223: Improved variable naming and null checkThe variable rename from
haloProottohalo2Proofimproves code readability, and the null check forhalo2Proof.ChunkInfoprevents potential null pointer dereference.
249-251: Good addition of debug logsAdding debug logs with task details improves observability and will be helpful during troubleshooting sessions. The correct task type
message.ProofTypeBatch.String()is now used in the log message.
261-271: Well-structured fork name mappingThe implementation correctly maps internal fork names to the prover-specific fork names, maintaining a clear separation between internal and external representations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
rollup/go.mod (1)
3-4: Toolchain Declaration SimplificationThe removal of the explicit toolchain declaration (previously something like
toolchain go1.22.2) in favor of the simplergo 1.22declaration reduces verbosity. Please ensure that this change aligns with your build and tooling expectations, especially if any tooling-specific features were previously tied to the removed declaration.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (3)
- coordinator/go.sumis excluded by- !**/*.sum
- go.work.sumis excluded by- !**/*.sum
- rollup/go.sumis excluded by- !**/*.sum
📒 Files selected for processing (2)
- coordinator/go.mod(1 hunks)
- rollup/go.mod(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- coordinator/go.mod
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: tests
🔇 Additional comments (1)
rollup/go.mod (1)
14-14: Dependency Version Update for da-codecThe version of
github.com/scroll-tech/da-codechas been updated tov0.1.3-0.20250401062930-9f9f53898493. Please verify that this updated version is compatible with the rest of your modules and that there are no breaking changes. It would be beneficial to cross-check against any upstream release notes or test the integration in your CI to ensure system stability.
| Just note: the new  I do not quite prefer such an implement (maybe at least we should branch/tag that updating) but anyway, acceptable for me | 
Purpose or design rationale of this PR
This PR:
euclidv2dependencies of provers and coordinator's verifier.euclidv2in proof handling.euclidv2verifier in coordinator.euclidv2handler in prover.darwinv2,euclid,euclidv2verifiers in coordinator.