Skip to content

Commit

Permalink
add selector
Browse files Browse the repository at this point in the history
  • Loading branch information
fborello-lambda committed Nov 8, 2024
1 parent 8b5257a commit 9ef16fd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
20 changes: 16 additions & 4 deletions crates/l2/proposer/prover_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ use std::{
net::{IpAddr, Shutdown, TcpListener, TcpStream},
sync::mpsc::{self, Receiver},
};
use tokio::signal::unix::{signal, SignalKind};
use tokio::{
signal::unix::{signal, SignalKind},
time::sleep,
};
use tracing::{debug, error, info, warn};

use ethereum_rust_core::{
Expand Down Expand Up @@ -164,7 +167,7 @@ impl ProverServer {
panic!("Failed to handle submit_ack: {e}");
}
// Seems to be stopping the prover_server <--> prover_client
//self.handle_proof_submission(block_number, receipt).await?;
self.handle_proof_submission(block_number, receipt).await?;

assert!(block_number == (self.latest_proven_block + 1), "Prover Client submitted an invalid block_number: {block_number}. The last_proved_block is: {}", self.latest_proven_block);
self.latest_proven_block = block_number;
Expand Down Expand Up @@ -233,7 +236,15 @@ impl ProverServer {
//
// The RISC0_DEV_MODE=1 should only be used with DEPLOYER_CONTRACT_VERIFIER=0xAA
let seal = match receipt.0.inner.groth16() {
Ok(inner) => hex::encode(inner.clone().seal),
Ok(inner) => {
// The SELECTOR is used to perform an extra check inside the groth16 verifier contract.
let mut selector =
hex::encode(inner.verifier_parameters.as_bytes().get(..4).unwrap());
info!("SELECTOR(): {selector}");
let seal = hex::encode(inner.clone().seal);
selector.push_str(&seal);
selector
}
Err(_) => hex::encode("00"),
};

Expand Down Expand Up @@ -349,7 +360,8 @@ impl ProverServer {
.await?
.is_none()
{
std::thread::sleep(std::time::Duration::from_secs(1));
warn!("WAITING for Tx Receipt");
sleep(std::time::Duration::from_secs(1)).await;
}

Ok(verify_tx_hash)
Expand Down
2 changes: 2 additions & 0 deletions crates/l2/utils/eth_client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use libsecp256k1::{sign, Message, SecretKey};
use reqwest::Client;
use serde::{Deserialize, Serialize};
use serde_json::json;
use tracing::info;
use transaction::PayloadRLPEncode;

pub mod errors;
Expand Down Expand Up @@ -95,6 +96,7 @@ impl EthClient {
tx: &mut EIP1559Transaction,
private_key: SecretKey,
) -> Result<H256, EthClientError> {
info!("CALLDATA: {:?}", tx.data);
let mut payload = vec![TxType::EIP1559 as u8];
payload.append(tx.encode_payload_to_vec().as_mut());

Expand Down

0 comments on commit 9ef16fd

Please sign in to comment.