-
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 will make serialization more efficient and reduce the size of the responses. 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} ```
- Loading branch information
Showing
11 changed files
with
85 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,59 @@ | ||
//! 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_proof_generation_dal() | ||
.insert_tee_proof_generation_job(batch_no, tee_type) | ||
.await?; | ||
let signature = vec![0, 1, 2, 3, 4]; | ||
let pubkey = vec![5, 6, 7, 8, 9]; | ||
let proof_vec = vec![10, 11, 12, 13, 14]; | ||
storage | ||
.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.is_none()); | ||
|
||
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