-
Notifications
You must be signed in to change notification settings - Fork 617
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
(WIP)feat/upgrade5 prover #1557
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[toolchain] | ||
channel = "nightly-2024-01-25" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
#![feature(lazy_cell)] | ||
#![allow(internal_features)] | ||
#![feature(core_intrinsics)] | ||
|
||
mod config; | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -8,17 +8,19 @@ pub type CommonHash = H256; | |||||||||||||||||||||||||||||
#[derive(Debug, Clone, Copy, PartialEq)] | ||||||||||||||||||||||||||||||
pub enum TaskType { | ||||||||||||||||||||||||||||||
Undefined, | ||||||||||||||||||||||||||||||
Chunk, | ||||||||||||||||||||||||||||||
ChunkHalo2, | ||||||||||||||||||||||||||||||
ChunkSp1, | ||||||||||||||||||||||||||||||
Comment on lines
+11
to
+12
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Update required: Several files still use the old The verification has found multiple files that need to be updated to use the new
These references need to be updated to use either 🔗 Analysis chainVerify the impact of TaskType enum changes. The renaming of Let's verify the usage of these enum variants: Also applies to: 20-23, 36-39 Update remaining references to The verification reveals several files still using the old
Let's verify if these are the only instances and check their context: 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Search for any remaining references to the old Chunk variant
rg -l "TaskType::Chunk"
# Search for places where TaskType is used to ensure they handle the new ChunkSp1 variant
rg -A 5 "TaskType::"
Length of output: 11203 Script: #!/bin/bash
# Show the context around TaskType::Chunk usage
rg -B 3 -A 3 "TaskType::Chunk"
# Check if there are any other enum variants we might have missed
ast-grep --pattern 'enum TaskType {
$$$
}'
Length of output: 7946 |
||||||||||||||||||||||||||||||
Batch, | ||||||||||||||||||||||||||||||
Bundle, | ||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
impl TaskType { | ||||||||||||||||||||||||||||||
fn from_u8(v: u8) -> Self { | ||||||||||||||||||||||||||||||
match v { | ||||||||||||||||||||||||||||||
1 => TaskType::Chunk, | ||||||||||||||||||||||||||||||
1 => TaskType::ChunkHalo2, | ||||||||||||||||||||||||||||||
2 => TaskType::Batch, | ||||||||||||||||||||||||||||||
3 => TaskType::Bundle, | ||||||||||||||||||||||||||||||
4 => TaskType::ChunkSp1, | ||||||||||||||||||||||||||||||
_ => TaskType::Undefined, | ||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
|
@@ -31,9 +33,10 @@ impl Serialize for TaskType { | |||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||
match *self { | ||||||||||||||||||||||||||||||
TaskType::Undefined => serializer.serialize_u8(0), | ||||||||||||||||||||||||||||||
TaskType::Chunk => serializer.serialize_u8(1), | ||||||||||||||||||||||||||||||
TaskType::ChunkHalo2 => serializer.serialize_u8(1), | ||||||||||||||||||||||||||||||
TaskType::Batch => serializer.serialize_u8(2), | ||||||||||||||||||||||||||||||
TaskType::Bundle => serializer.serialize_u8(3), | ||||||||||||||||||||||||||||||
TaskType::ChunkSp1 => serializer.serialize_u8(4), | ||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
|
@@ -56,15 +59,19 @@ impl Default for TaskType { | |||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | ||||||||||||||||||||||||||||||
pub enum ProverType { | ||||||||||||||||||||||||||||||
Chunk, | ||||||||||||||||||||||||||||||
ChunkHalo2, | ||||||||||||||||||||||||||||||
ChunkSp1, | ||||||||||||||||||||||||||||||
ChunkAll, | ||||||||||||||||||||||||||||||
Batch, | ||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
impl ProverType { | ||||||||||||||||||||||||||||||
fn from_u8(v: u8) -> Self { | ||||||||||||||||||||||||||||||
match v { | ||||||||||||||||||||||||||||||
1 => ProverType::Chunk, | ||||||||||||||||||||||||||||||
1 => ProverType::ChunkHalo2, | ||||||||||||||||||||||||||||||
2 => ProverType::Batch, | ||||||||||||||||||||||||||||||
3 => ProverType::ChunkSp1, | ||||||||||||||||||||||||||||||
4 => ProverType::ChunkAll, | ||||||||||||||||||||||||||||||
_ => { | ||||||||||||||||||||||||||||||
panic!("invalid prover_type") | ||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
Comment on lines
+71
to
77
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Consider returning Result instead of panicking. The - fn from_u8(v: u8) -> Self {
+ fn from_u8(v: u8) -> Result<Self, &'static str> {
match v {
- 1 => ProverType::ChunkHalo2,
- 2 => ProverType::Batch,
- 3 => ProverType::ChunkSp1,
- 4 => ProverType::ChunkAll,
- _ => {
- panic!("invalid prover_type")
- }
+ 1 => Ok(ProverType::ChunkHalo2),
+ 2 => Ok(ProverType::Batch),
+ 3 => Ok(ProverType::ChunkSp1),
+ 4 => Ok(ProverType::ChunkAll),
+ _ => Err("invalid prover_type")
}
} 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||
|
@@ -73,8 +80,10 @@ impl ProverType { | |||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
pub fn to_u8(self) -> u8 { | ||||||||||||||||||||||||||||||
match self { | ||||||||||||||||||||||||||||||
ProverType::Chunk => 1, | ||||||||||||||||||||||||||||||
ProverType::ChunkHalo2 => 1, | ||||||||||||||||||||||||||||||
ProverType::Batch => 2, | ||||||||||||||||||||||||||||||
ProverType::ChunkSp1 => 3, | ||||||||||||||||||||||||||||||
ProverType::ChunkAll => 4, | ||||||||||||||||||||||||||||||
Comment on lines
+83
to
+86
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Consider using a const array to define variant mappings. The serialization values are duplicated across multiple methods. Consider defining them once to improve maintainability: impl ProverType {
const VARIANT_MAPPINGS: [(ProverType, u8); 4] = [
(ProverType::ChunkHalo2, 1),
(ProverType::Batch, 2),
(ProverType::ChunkSp1, 3),
(ProverType::ChunkAll, 4),
];
fn to_u8(self) -> u8 {
Self::VARIANT_MAPPINGS
.iter()
.find(|(variant, _)| *variant == self)
.map(|(_, value)| *value)
.unwrap()
}
} Also applies to: 97-100 |
||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
|
@@ -85,8 +94,10 @@ impl Serialize for ProverType { | |||||||||||||||||||||||||||||
S: Serializer, | ||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||
match *self { | ||||||||||||||||||||||||||||||
ProverType::Chunk => serializer.serialize_u8(1), | ||||||||||||||||||||||||||||||
ProverType::ChunkHalo2 => serializer.serialize_u8(1), | ||||||||||||||||||||||||||||||
ProverType::Batch => serializer.serialize_u8(2), | ||||||||||||||||||||||||||||||
ProverType::ChunkSp1 => serializer.serialize_u8(3), | ||||||||||||||||||||||||||||||
ProverType::ChunkAll => serializer.serialize_u8(4), | ||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
mod common; | ||
mod darwin; | ||
mod darwin_v2; | ||
mod euclid; | ||
|
||
use super::geth_client::GethClient; | ||
use crate::{ | ||
|
@@ -9,8 +9,8 @@ use crate::{ | |
utils::get_task_types, | ||
}; | ||
use anyhow::{bail, Result}; | ||
use darwin::DarwinHandler; | ||
use darwin_v2::DarwinV2Handler; | ||
use euclid::EuclidHandler; | ||
use std::{cell::RefCell, collections::HashMap, rc::Rc}; | ||
|
||
type HardForkName = String; | ||
|
@@ -61,7 +61,7 @@ impl<'a> CircuitsHandlerProvider<'a> { | |
&config.low_version_circuit.hard_fork_name | ||
); | ||
AssetsDirEnvConfig::enable_first(); | ||
DarwinHandler::new( | ||
DarwinV2Handler::new( | ||
prover_type, | ||
&config.low_version_circuit.params_path, | ||
&config.low_version_circuit.assets_path, | ||
Comment on lines
+64
to
67
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Implementation for Sp1 task type is incomplete The codebase shows several issues with the Sp1 task type implementation:
This indicates that while the task type is defined, its actual implementation is missing or incomplete. 🔗 Analysis chainVerify task type handling in both handlers. Since this PR aims to support Sp1 tasks, let's verify the implementation of task type handling in both handlers. Also applies to: 87-91 Let me gather more information about the implementation of task handlers, particularly focusing on the Sp1 chunk proof generation. 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Description: Verify task type handling in both handlers
# Test 1: Search for TaskType handling in both handlers
echo "Searching for TaskType handling..."
rg -A 5 "match.*TaskType" prover/src/
# Test 2: Search for Sp1 specific handling
echo "Searching for Sp1 task handling..."
rg -A 5 "ChunkSp1" prover/src/
Length of output: 5091 Script: #!/bin/bash
# Search for Sp1 chunk proof generation implementation
echo "Searching for Sp1 chunk proof generation..."
rg -A 10 "fn gen_sp1_chunk_proof" prover/src/
# Search for ChunkProver struct implementation
echo "Searching for ChunkProver implementation..."
rg -A 10 "struct ChunkProver" prover/src/
Length of output: 1968 |
||
|
@@ -84,7 +84,7 @@ impl<'a> CircuitsHandlerProvider<'a> { | |
&config.high_version_circuit.hard_fork_name | ||
); | ||
AssetsDirEnvConfig::enable_second(); | ||
DarwinV2Handler::new( | ||
EuclidHandler::new( | ||
prover_type, | ||
&config.high_version_circuit.params_path, | ||
&config.high_version_circuit.assets_path, | ||
|
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.
💡 Codebase verification
Error handling needs improvement in task fetching
The verification revealed some concerns in the error handling:
fetch_task
result is unwrapped intask_processor.rs
without proper error contextKey locations that need attention:
prover/src/task_processor.rs
: Replacefetch_result.unwrap()
with proper error handlingprover/src/prover.rs
: Consider adding more specific error types for the new prover type cases🔗 Analysis chain
LGTM! Verify error handling for edge cases.
The task fetching logic correctly handles the new prover types and includes appropriate error handling.
Let's verify the error handling paths are tested:
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 90
Script:
Length of output: 2325