Setup discord example to show how to increase max transcript size. (#485)

This commit is contained in:
yuroitaki
2024-05-20 11:40:43 +08:00
committed by GitHub
parent 3506791df1
commit 23450a3d38
2 changed files with 16 additions and 18 deletions

View File

@@ -17,13 +17,18 @@ use tlsn_prover::tls::{Prover, ProverConfig};
// Setting of the application server
const SERVER_DOMAIN: &str = "discord.com";
// Setting of the notary server — make sure these are the same with those in ../../../notary-server
// Setting of the notary server — make sure these are the same with the config in ../../../notary-server
const NOTARY_HOST: &str = "127.0.0.1";
const NOTARY_PORT: u16 = 7047;
// Configuration of notarization
const NOTARY_MAX_SENT: usize = 1 << 12;
const NOTARY_MAX_RECV: usize = 1 << 14;
// P/S: If the following limits are increased, please ensure max-transcript-size of
// the notary server's config (../../../notary-server) is increased too, where
// max-transcript-size = MAX_SENT_DATA + MAX_RECV_DATA
//
// Maximum number of bytes that can be sent from prover to server
const MAX_SENT_DATA: usize = 1 << 12;
// Maximum number of bytes that can be received by prover from server
const MAX_RECV_DATA: usize = 1 << 14;
#[tokio::main]
async fn main() {
@@ -38,8 +43,8 @@ async fn main() {
let (notary_tls_socket, session_id) = request_notarization(
NOTARY_HOST,
NOTARY_PORT,
Some(NOTARY_MAX_SENT),
Some(NOTARY_MAX_RECV),
Some(MAX_SENT_DATA),
Some(MAX_RECV_DATA),
)
.await;
@@ -47,6 +52,8 @@ async fn main() {
let config = ProverConfig::builder()
.id(session_id)
.server_dns(SERVER_DOMAIN)
.max_sent_data(MAX_SENT_DATA)
.max_recv_data(MAX_RECV_DATA)
.build()
.unwrap();

View File

@@ -19,14 +19,10 @@ const SERVER_DOMAIN: &str = "twitter.com";
const ROUTE: &str = "i/api/1.1/dm/conversation";
const USER_AGENT: &str = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36";
// Setting of the notary server — make sure these are the same with those in ../../../notary-server
// Setting of the notary server — make sure these are the same with the config in ../../../notary-server
const NOTARY_HOST: &str = "127.0.0.1";
const NOTARY_PORT: u16 = 7047;
// Configuration of notarization
const NOTARY_MAX_SENT: usize = 1 << 12;
const NOTARY_MAX_RECV: usize = 1 << 14;
#[tokio::main]
async fn main() {
tracing_subscriber::fmt::init();
@@ -38,13 +34,8 @@ async fn main() {
let access_token = env::var("ACCESS_TOKEN").unwrap();
let csrf_token = env::var("CSRF_TOKEN").unwrap();
let (notary_tls_socket, session_id) = request_notarization(
NOTARY_HOST,
NOTARY_PORT,
Some(NOTARY_MAX_SENT),
Some(NOTARY_MAX_RECV),
)
.await;
let (notary_tls_socket, session_id) =
request_notarization(NOTARY_HOST, NOTARY_PORT, None, None).await;
// Basic default prover config using the session_id returned from /session endpoint just now
let config = ProverConfig::builder()