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

Upgrade#4 #1394

Merged
merged 44 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
1b6886b
init
georgehao Jun 24, 2024
1a739cd
faet(db): add bundle table (#1395)
colinlyguo Jun 25, 2024
664c042
Merge branch 'develop' into feat/upgrade4
georgehao Jun 26, 2024
54adbb3
feat(common): add hardfork util functions supporting both height and …
colinlyguo Jun 27, 2024
fb43e87
feat(rollup-db): add bundle hash (#1401)
colinlyguo Jun 27, 2024
229809a
feat(rollup-relayer): support commitBatchWithBlobProof (#1397)
colinlyguo Jun 27, 2024
e679052
feat(common): update types as per upgrade4 (#1409)
roynalnaruto Jul 1, 2024
0b32509
Merge branch 'develop' into feat/upgrade4
colinlyguo Jul 2, 2024
beee0c2
feat(coordinator): enhance batch proof sanity check (#1408)
colinlyguo Jul 2, 2024
bc9bc5d
feat(rollup-relayer): finalize bundle (#1411)
colinlyguo Jul 8, 2024
380dbba
feat(coordinator): upgrade 4 (#1399)
georgehao Jul 8, 2024
7196c5c
Merge branch 'develop' into feat/upgrade4
colinlyguo Jul 8, 2024
abe66c6
feat(prover): supporting upgrade4 (#1412)
amoylan2 Jul 8, 2024
c758aa6
fix: build coordinator and bridge-history images (#1421)
colinlyguo Jul 10, 2024
61a3af5
enable push tag to build docker
georgehao Jul 10, 2024
3567f5b
feat(prover): upgrade zkevm-circuits version (#1424)
amoylan2 Jul 11, 2024
a2e8b6a
libzkp and coordinator updates (preparation for Upgrade4) (#1419)
roynalnaruto Jul 11, 2024
2392d34
enable chunk proof verify (#1432)
georgehao Jul 11, 2024
622ce7b
feat(prover): upgrade zkevm-circuits to same as coordinator's with ch…
amoylan2 Jul 12, 2024
04a893a
feat: enable process pending bundles (#1433)
georgehao Jul 12, 2024
3716c5a
bump prover (upgrade #4) (#1437)
roynalnaruto Jul 18, 2024
d516949
fix ProcessPendingBundles record not found (#1444)
georgehao Jul 18, 2024
8b779ff
prover(branch): `release/v0.12.0` (#1446)
roynalnaruto Jul 18, 2024
76a9d6f
fix init bundle vk map (#1447)
georgehao Jul 18, 2024
8960d0f
fix(prover): fix panic issue when trying to get curie's bundle vk (#1…
amoylan2 Jul 18, 2024
c34883e
fix lint issue (#1450)
amoylan2 Jul 18, 2024
f95eaec
feat(prover): upgrade darwin's zkevm-circuits branch (#1451)
amoylan2 Jul 18, 2024
74c197e
update codec version (#1448)
georgehao Jul 18, 2024
768226c
Merge branch 'develop' into feat/upgrade4
colinlyguo Jul 18, 2024
07dc2c9
Merge branch 'develop' into feat/upgrade4
colinlyguo Jul 18, 2024
17b7e5c
Feat/upgrade4 prover print more error (#1454)
amoylan2 Jul 19, 2024
8f273f7
fix coordinator bug (#1455)
georgehao Jul 19, 2024
c87c356
fix typo (#1456)
georgehao Jul 19, 2024
0c10663
update zkcircuit (#1457)
georgehao Jul 19, 2024
82f39aa
fix bundle task detail bug (#1460)
georgehao Jul 19, 2024
f1fae1f
feat(libzkp): different paths for assets of lower and higher versions…
roynalnaruto Jul 26, 2024
f76fa41
fix config typo
georgehao Jul 26, 2024
796e77d
feat(libzkp,prover): upgrade zkevm-circuits to v0.12.0 (#1465)
amoylan2 Jul 29, 2024
56e6d48
fix conflict
georgehao Jul 30, 2024
d2ff088
Update coordinator/cmd/tool/tool.go
georgehao Jul 30, 2024
a22aa8d
chore: cleanup libzkp interfaces used by coordinator and update da-co…
colinlyguo Jul 30, 2024
5159168
Merge branch 'develop' into feat/upgrade4
colinlyguo Jul 30, 2024
0108046
refactor: remove unused code and fix typos (#1470)
colinlyguo Jul 31, 2024
4f098b4
chore: auto version bump [bot]
georgehao Jul 31, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
520 changes: 150 additions & 370 deletions prover/Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions prover/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ ethers-core = { git = "https://github.com/scroll-tech/ethers-rs.git", branch = "
ethers-providers = { git = "https://github.com/scroll-tech/ethers-rs.git", branch = "v2.0.7" }
halo2_proofs = { git = "https://github.com/scroll-tech/halo2.git", branch = "v1.1" }
snark-verifier-sdk = { git = "https://github.com/scroll-tech/snark-verifier", branch = "develop", default-features = false, features = ["loader_halo2", "loader_evm", "halo2-pse"] }
prover = { git = "https://github.com/scroll-tech/zkevm-circuits.git", branch = "v0.10", default-features = false, features = ["parallel_syn", "scroll", "shanghai"] }
prover_next = { git = "https://github.com/scroll-tech/zkevm-circuits.git", tag = "v0.11.4", package = "prover", default-features = false, features = ["parallel_syn", "scroll"] }
prover_curie = { git = "https://github.com/scroll-tech/zkevm-circuits.git", tag = "v0.11.4", package = "prover", default-features = false, features = ["parallel_syn", "scroll"] }
prover_darwin = { git = "https://github.com/scroll-tech/zkevm-circuits.git", branch = "feat/agg_recursion", package = "prover", default-features = false, features = ["parallel_syn", "scroll"] }
base64 = "0.13.1"
reqwest = { version = "0.12.4", features = ["gzip"] }
reqwest-middleware = "0.3"
Expand Down
4 changes: 0 additions & 4 deletions prover/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,10 @@ endif

prover:
GO_TAG=${GO_TAG} GIT_REV=${GIT_REV} ZK_VERSION=${ZK_VERSION} cargo build --release
rm -rf ./lib && mkdir ./lib
find target/ -name "libzktrie.so" | xargs -I{} cp {} ./lib

tests_binary:
cargo clean && cargo test --release --no-run
ls target/release/deps/prover* | grep -v "\.d" | xargs -I{} ln -sf {} ./prover.test
rm -rf ./lib && mkdir ./lib
find target/ -name "libzktrie.so" | xargs -I{} cp {} ./lib

lint:
cargo check --all-features
Expand Down
7 changes: 3 additions & 4 deletions prover/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use anyhow::{bail, Result};
use serde::{Deserialize, Serialize};
use std::fs::File;

use crate::types::ProofType;
use crate::types::ProverType;

#[derive(Debug, Serialize, Deserialize)]
pub struct CircuitConfig {
Expand All @@ -24,14 +24,13 @@ pub struct L2GethConfig {
pub endpoint: String,
}

#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Deserialize)]
pub struct Config {
pub prover_name: String,
pub keystore_path: String,
pub keystore_password: String,
pub db_path: String,
#[serde(default)]
pub proof_type: ProofType,
pub prover_type: ProverType,
pub low_version_circuit: CircuitConfig,
pub high_version_circuit: CircuitConfig,
pub coordinator: CoordinatorConfig,
Expand Down
8 changes: 7 additions & 1 deletion prover/src/coordinator_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ pub struct CoordinatorClient<'a> {
key_signer: Rc<KeySigner>,
rt: Runtime,
listener: Box<dyn Listener>,
vks: Vec<String>,
}

impl<'a> CoordinatorClient<'a> {
pub fn new(
config: &'a Config,
key_signer: Rc<KeySigner>,
listener: Box<dyn Listener>,
vks: Vec<String>,
) -> Result<Self> {
let rt = tokio::runtime::Builder::new_current_thread()
.enable_all()
Expand All @@ -46,6 +48,7 @@ impl<'a> CoordinatorClient<'a> {
key_signer,
rt,
listener,
vks,
};
client.login()?;
Ok(client)
Expand All @@ -68,12 +71,15 @@ impl<'a> CoordinatorClient<'a> {
challenge: token.clone(),
prover_name: self.config.prover_name.clone(),
prover_version: crate::version::get_version(),
prover_types: vec![self.config.prover_type],
vks: self.vks.clone(),
};

let buffer = login_message.rlp();
let buffer = rlp::encode(&login_message);
let signature = self.key_signer.sign_buffer(&buffer)?;
let login_request = LoginRequest {
message: login_message,
public_key: self.key_signer.get_public_key(),
signature,
};
let login_response = self.rt.block_on(api.login(&login_request, &token))?;
Expand Down
43 changes: 27 additions & 16 deletions prover/src/coordinator_client/types.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::errors::ErrorCode;
use crate::types::{ProofFailureType, ProofStatus};
use rlp::RlpStream;
use crate::types::{ProofFailureType, ProofStatus, ProverType, TaskType};
use rlp::{Encodable, RlpStream};
use serde::{Deserialize, Serialize};

#[derive(Deserialize)]
Expand All @@ -15,23 +15,36 @@ pub struct LoginMessage {
pub challenge: String,
pub prover_name: String,
pub prover_version: String,
pub prover_types: Vec<ProverType>,
pub vks: Vec<String>,
}

impl LoginMessage {
pub fn rlp(&self) -> Vec<u8> {
let mut rlp = RlpStream::new();
let num_fields = 3;
rlp.begin_list(num_fields);
rlp.append(&self.prover_name);
rlp.append(&self.prover_version);
rlp.append(&self.challenge);
rlp.out().freeze().into()
impl Encodable for LoginMessage {
fn rlp_append(&self, s: &mut RlpStream) {
let num_fields = 5;
s.begin_list(num_fields);
s.append(&self.challenge);
s.append(&self.prover_version);
s.append(&self.prover_name);
// The ProverType in go side is an type alias of uint8
// A uint8 slice is treated as a string when doing the rlp encoding
let prover_types = self
.prover_types
.iter()
.map(|prover_type: &ProverType| prover_type.to_u8())
.collect::<Vec<u8>>();
s.append(&prover_types);
s.begin_list(self.vks.len());
for vk in &self.vks {
s.append(vk);
}
}
}

#[derive(Serialize, Deserialize)]
pub struct LoginRequest {
pub message: LoginMessage,
pub public_key: String,
pub signature: String,
}

Expand All @@ -45,16 +58,15 @@ pub type ChallengeResponseData = LoginResponseData;

#[derive(Default, Serialize, Deserialize)]
pub struct GetTaskRequest {
pub task_type: crate::types::ProofType,
pub task_types: Vec<TaskType>,
pub prover_height: Option<u64>,
pub vks: Vec<String>,
}

#[derive(Serialize, Deserialize)]
pub struct GetTaskResponseData {
pub uuid: String,
pub task_id: String,
pub task_type: crate::types::ProofType,
pub task_type: TaskType,
pub task_data: String,
pub hard_fork_name: String,
}
Expand All @@ -63,12 +75,11 @@ pub struct GetTaskResponseData {
pub struct SubmitProofRequest {
pub uuid: String,
pub task_id: String,
pub task_type: crate::types::ProofType,
pub task_type: TaskType,
pub status: ProofStatus,
pub proof: String,
pub failure_type: Option<ProofFailureType>,
pub failure_msg: Option<String>,
pub hard_fork_name: String,
}

#[derive(Serialize, Deserialize)]
Expand Down
2 changes: 1 addition & 1 deletion prover/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
log::info!(
"prover start successfully. name: {}, type: {:?}, publickey: {}, version: {}",
config.prover_name,
config.proof_type,
config.prover_type,
prover.get_public_key(),
version::get_version(),
);
Expand Down
33 changes: 15 additions & 18 deletions prover/src/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ use crate::{
coordinator_client::{listener::Listener, types::*, CoordinatorClient},
geth_client::GethClient,
key_signer::KeySigner,
types::{ProofFailureType, ProofStatus, ProofType},
types::{ProofFailureType, ProofStatus, ProverType},
utils::get_task_types,
zk_circuits_handler::{CircuitsHandler, CircuitsHandlerProvider},
};

Expand All @@ -24,16 +25,11 @@ pub struct Prover<'a> {

impl<'a> Prover<'a> {
pub fn new(config: &'a Config, coordinator_listener: Box<dyn Listener>) -> Result<Self> {
let proof_type = config.proof_type;
let prover_type = config.prover_type;
let keystore_path = &config.keystore_path;
let keystore_password = &config.keystore_password;

let key_signer = Rc::new(KeySigner::new(keystore_path, keystore_password)?);
let coordinator_client =
CoordinatorClient::new(config, Rc::clone(&key_signer), coordinator_listener)
.context("failed to create coordinator_client")?;

let geth_client = if config.proof_type == ProofType::Chunk {
let geth_client = if config.prover_type == ProverType::Chunk {
Some(Rc::new(RefCell::new(
GethClient::new(
&config.prover_name,
Expand All @@ -45,9 +41,16 @@ impl<'a> Prover<'a> {
None
};

let provider = CircuitsHandlerProvider::new(proof_type, config, geth_client.clone())
let provider = CircuitsHandlerProvider::new(prover_type, config, geth_client.clone())
.context("failed to create circuits handler provider")?;

let vks = provider.init_vks(prover_type, config, geth_client.clone());

let key_signer = Rc::new(KeySigner::new(keystore_path, keystore_password)?);
let coordinator_client =
CoordinatorClient::new(config, Rc::clone(&key_signer), coordinator_listener, vks)
.context("failed to create coordinator_client")?;

let prover = Prover {
config,
key_signer: Rc::clone(&key_signer),
Expand All @@ -59,23 +62,19 @@ impl<'a> Prover<'a> {
Ok(prover)
}

pub fn get_proof_type(&self) -> ProofType {
self.config.proof_type
}

pub fn get_public_key(&self) -> String {
self.key_signer.get_public_key()
}

pub fn fetch_task(&self) -> Result<Task> {
log::info!("[prover] start to fetch_task");
let mut req = GetTaskRequest {
task_type: self.get_proof_type(),
task_types: get_task_types(self.config.prover_type),
prover_height: None,
vks: self.circuits_handler_provider.borrow().get_vks(),
// vks: self.circuits_handler_provider.borrow().get_vks(),
};

if self.get_proof_type() == ProofType::Chunk {
if self.config.prover_type == ProverType::Chunk {
let latest_block_number = self.get_latest_block_number_value()?;
if let Some(v) = latest_block_number {
if v.as_u64() == 0 {
Expand Down Expand Up @@ -130,7 +129,6 @@ impl<'a> Prover<'a> {
task_type: proof_detail.proof_type,
status: ProofStatus::Ok,
proof: proof_detail.proof_data,
hard_fork_name: task.hard_fork_name.clone(),
..Default::default()
};

Expand All @@ -151,7 +149,6 @@ impl<'a> Prover<'a> {
status: ProofStatus::Error,
failure_type: Some(failure_type),
failure_msg: Some(error.to_string()),
hard_fork_name: task.hard_fork_name.clone(),
..Default::default()
};
self.do_submit(&request)
Expand Down
Loading
Loading