-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tee): use hex serialization for RPC responses
Following Anton's suggestion, we have switched to hex serialization for API/RPC requests and responses. Previously, we used default JSON serialization for Vec<u8>, which resulted in a lengthy comma-separated list of integers. This change standardizes serialization, making it more efficient and reducing the size of the responses. The previous format, with a series of comma-separated integers for pubkey-like fields, looked odd. Then: ``` curl -X POST\ -H "Content-Type: application/json" \ --data '{"jsonrpc": "2.0", "id": 1, "method": "unstable_getTeeProofs", "params": [491882, "Sgx"] }' \ https://mainnet.era.zksync.io {"jsonrpc":"2.0","result":[{"attestation":[3,0,2,0,0,0,0,0,10,<dozens of comma-separated integers here> ``` Now: ``` $ curl -X POST \ -H "Content-Type: application/json" \ --data '{"jsonrpc": "2.0", "id": 1, "method": "unstable_getTeeProofs", "params": [1, "sgx"] }' \ http://localhost:3050 {"jsonrpc":"2.0","result":[{"l1BatchNumber":1,"teeType":"sgx","pubkey":"0506070809","signature":"0001020304","proof":"0a0b0c0d0e","provedAt":"2024-09-16T11:53:38.253033Z","attestation":"0403020100"}],"id":1} ``` This change needs to be deployed in lockstep with: matter-labs/teepot#209.
- Loading branch information
Showing
12 changed files
with
96 additions
and
8 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
//! Tests for the `unstable` Web3 namespace. | ||
use zksync_types::tee_types::TeeType; | ||
use zksync_web3_decl::namespaces::UnstableNamespaceClient; | ||
|
||
use super::*; | ||
|
||
#[derive(Debug)] | ||
struct GetTeeProofsTest {} | ||
|
||
impl GetTeeProofsTest { | ||
fn new() -> Self { | ||
Self {} | ||
} | ||
} | ||
|
||
#[async_trait] | ||
impl HttpTest for GetTeeProofsTest { | ||
async fn test( | ||
&self, | ||
client: &DynClient<L2>, | ||
pool: &ConnectionPool<Core>, | ||
) -> anyhow::Result<()> { | ||
let batch_no = L1BatchNumber(1337); | ||
let tee_type = TeeType::Sgx; | ||
let proof = client.tee_proofs(batch_no, Some(tee_type)).await?; | ||
|
||
assert!(proof.is_empty()); | ||
|
||
let mut storage = pool.connection().await.unwrap(); | ||
storage | ||
.tee_verifier_input_producer_dal() | ||
.create_tee_verifier_input_producer_job(batch_no) | ||
.await?; | ||
|
||
let pubkey = vec![0xDE, 0xAD, 0xBE, 0xEF]; | ||
let attestation = vec![0xC0, 0xFF, 0xEE]; | ||
let mut tee_proof_generation_dal = storage.tee_proof_generation_dal(); | ||
tee_proof_generation_dal | ||
.save_attestation(&pubkey, &attestation) | ||
.await?; | ||
tee_proof_generation_dal | ||
.insert_tee_proof_generation_job(batch_no, tee_type) | ||
.await?; | ||
|
||
let signature = vec![0, 1, 2, 3, 4]; | ||
let proof_vec = vec![5, 6, 7, 8, 9]; | ||
tee_proof_generation_dal | ||
.save_proof_artifacts_metadata(batch_no, tee_type, &pubkey, &signature, &proof_vec) | ||
.await?; | ||
|
||
let proofs = client.tee_proofs(batch_no, Some(tee_type)).await?; | ||
assert!(proofs.len() == 1); | ||
let proof = &proofs[0]; | ||
assert!(proof.l1_batch_number == batch_no); | ||
assert!(proof.tee_type == Some(tee_type)); | ||
assert!(proof.pubkey.as_ref() == Some(&pubkey)); | ||
assert!(proof.signature.as_ref() == Some(&signature)); | ||
assert!(proof.proof.as_ref() == Some(&proof_vec)); | ||
assert!(proof.attestation.as_ref() == Some(&attestation)); | ||
|
||
Ok(()) | ||
} | ||
} | ||
|
||
#[tokio::test] | ||
async fn get_tee_proofs() { | ||
test_http_server(GetTeeProofsTest::new()).await; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.