Skip to content

Commit

Permalink
fix: P-507 rename config name discord_litentry_url to litentry_discor…
Browse files Browse the repository at this point in the history
…d_microservice_url, added prod api endpoint for it, and remove twitter_litentry mock and config (#2519)

Co-authored-by: higherordertech <higherordertech>
  • Loading branch information
higherordertech authored Feb 23, 2024
1 parent 9099ea6 commit 717e39f
Show file tree
Hide file tree
Showing 13 changed files with 39 additions and 90 deletions.
3 changes: 1 addition & 2 deletions bitacross-worker/docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,9 @@ services:
environment:
- RUST_LOG=info,litentry_worker=debug,ws=warn,sp_io=error,substrate_api_client=warn,itc_parentchain_light_client=info,jsonrpsee_ws_client=warn,jsonrpsee_ws_server=warn,enclave_runtime=debug,ita_stf=debug,its_rpc_handler=warn,itc_rpc_client=warn,its_consensus_common=debug,its_state=warn,its_consensus_aura=warn,aura*=warn,its_consensus_slots=warn,itp_attestation_handler=debug,http_req=debug,lc_mock_server=warn,itc_rest_client=debug,lc_credentials=debug,lc_identity_verification=debug,lc_stf_task_receiver=debug,lc_stf_task_sender=debug,lc_data_providers=debug,itp_top_pool=debug,itc_parentchain_indirect_calls_executor=debug,
- TWITTER_OFFICIAL_URL=http://localhost:19527
- TWITTER_LITENTRY_URL=http://localhost:19527
- TWITTER_AUTH_TOKEN_V2=
- DISCORD_OFFICIAL_URL=http://localhost:19527
- DISCORD_LITENTRY_URL=http://localhost:19527
- LITENTRY_DISCORD_MICROSERVICE_URL=http://localhost:19527
- DISCORD_AUTH_TOKEN=
- ACHAINABLE_URL=http://localhost:19527
- ACHAINABLE_AUTH_KEY=
Expand Down
9 changes: 3 additions & 6 deletions bitacross-worker/docker/multiworker-docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,9 @@ services:
environment:
- RUST_LOG=info,litentry_worker=debug,ws=warn,sp_io=error,substrate_api_client=warn,itc_parentchain_light_client=info,jsonrpsee_ws_client=warn,jsonrpsee_ws_server=warn,enclave_runtime=debug,ita_stf=debug,its_rpc_handler=warn,itc_rpc_client=warn,its_consensus_common=debug,its_state=warn,its_consensus_aura=warn,aura*=warn,its_consensus_slots=warn,itp_attestation_handler=debug,http_req=debug,lc_mock_server=warn,itc_rest_client=debug,lc_credentials=debug,lc_identity_verification=debug,lc_stf_task_receiver=debug,lc_stf_task_sender=debug,lc_data_providers=debug,itp_top_pool=debug,itc_parentchain_indirect_calls_executor=debug,
- TWITTER_OFFICIAL_URL=http://localhost:19527
- TWITTER_LITENTRY_URL=http://localhost:19527
- TWITTER_AUTH_TOKEN_V2=
- DISCORD_OFFICIAL_URL=http://localhost:19527
- DISCORD_LITENTRY_URL=http://localhost:19527
- LITENTRY_DISCORD_MICROSERVICE_URL=http://localhost:19527
- DISCORD_AUTH_TOKEN=
- ACHAINABLE_URL=http://localhost:19527
- ACHAINABLE_AUTH_KEY=
Expand Down Expand Up @@ -169,10 +168,9 @@ services:
environment:
- RUST_LOG=info,litentry_worker=debug,ws=warn,sp_io=error,substrate_api_client=warn,itc_parentchain_light_client=info,jsonrpsee_ws_client=warn,jsonrpsee_ws_server=warn,enclave_runtime=debug,ita_stf=debug,its_rpc_handler=warn,itc_rpc_client=warn,its_consensus_common=debug,its_state=warn,its_consensus_aura=warn,aura*=warn,its_consensus_slots=warn,itp_attestation_handler=debug,http_req=debug,lc_mock_server=warn,itc_rest_client=debug,lc_credentials=debug,lc_identity_verification=debug,lc_stf_task_receiver=debug,lc_stf_task_sender=debug,lc_data_providers=debug,itp_top_pool=debug,itc_parentchain_indirect_calls_executor=debug,
- TWITTER_OFFICIAL_URL=http://localhost:19527
- TWITTER_LITENTRY_URL=http://localhost:19527
- TWITTER_AUTH_TOKEN_V2=
- DISCORD_OFFICIAL_URL=http://localhost:19527
- DISCORD_LITENTRY_URL=http://localhost:19527
- LITENTRY_DISCORD_MICROSERVICE_URL=http://localhost:19527
- DISCORD_AUTH_TOKEN=
- ACHAINABLE_URL=http://localhost:19527
- ACHAINABLE_AUTH_KEY=
Expand Down Expand Up @@ -219,10 +217,9 @@ services:
environment:
- RUST_LOG=info,litentry_worker=debug,ws=warn,sp_io=error,substrate_api_client=warn,itc_parentchain_light_client=info,jsonrpsee_ws_client=warn,jsonrpsee_ws_server=warn,enclave_runtime=debug,ita_stf=debug,its_rpc_handler=warn,itc_rpc_client=warn,its_consensus_common=debug,its_state=warn,its_consensus_aura=warn,aura*=warn,its_consensus_slots=warn,itp_attestation_handler=debug,http_req=debug,lc_mock_server=warn,itc_rest_client=debug,lc_credentials=debug,lc_identity_verification=debug,lc_stf_task_receiver=debug,lc_stf_task_sender=debug,lc_data_providers=debug,itp_top_pool=debug,itc_parentchain_indirect_calls_executor=debug,
- TWITTER_OFFICIAL_URL=http://localhost:19527
- TWITTER_LITENTRY_URL=http://localhost:19527
- TWITTER_AUTH_TOKEN_V2=
- DISCORD_OFFICIAL_URL=http://localhost:19527
- DISCORD_LITENTRY_URL=http://localhost:19527
- LITENTRY_DISCORD_MICROSERVICE_URL=http://localhost:19527
- DISCORD_AUTH_TOKEN=
- ACHAINABLE_URL=http://localhost:19527
- ACHAINABLE_AUTH_KEY=
Expand Down
3 changes: 1 addition & 2 deletions bitacross-worker/scripts/litentry/release/config.json.eg
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
{
"twitter_official_url": "https://api.twitter.com",
"twitter_litentry_url": "",
"twitter_auth_token_v2": "abcdefghijklmnopqrstuvwxyz",
"discord_official_url": "https://discordapp.com",
"discord_litentry_url": "",
"litentry_discord_microservice_url": "",
"discord_auth_token": "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
"achainable_url": "https://graph.tdf-labs.io/",
"achainable_auth_key": "88888888-4444-4444-4444-1234567890ab",
Expand Down
3 changes: 1 addition & 2 deletions tee-worker/docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,9 @@ services:
environment:
- RUST_LOG=info,litentry_worker=debug,ws=warn,sp_io=error,substrate_api_client=warn,itc_parentchain_light_client=info,jsonrpsee_ws_client=warn,jsonrpsee_ws_server=warn,enclave_runtime=debug,ita_stf=debug,its_rpc_handler=warn,itc_rpc_client=warn,its_consensus_common=debug,its_state=warn,its_consensus_aura=warn,aura*=warn,its_consensus_slots=warn,itp_attestation_handler=debug,http_req=debug,lc_mock_server=warn,itc_rest_client=debug,lc_credentials=debug,lc_identity_verification=debug,lc_stf_task_receiver=debug,lc_stf_task_sender=debug,lc_data_providers=debug,itp_top_pool=debug,itc_parentchain_indirect_calls_executor=debug,
- TWITTER_OFFICIAL_URL=http://localhost:19527
- TWITTER_LITENTRY_URL=http://localhost:19527
- TWITTER_AUTH_TOKEN_V2=
- DISCORD_OFFICIAL_URL=http://localhost:19527
- DISCORD_LITENTRY_URL=http://localhost:19527
- LITENTRY_DISCORD_MICROSERVICE_URL=http://localhost:19527
- DISCORD_AUTH_TOKEN=
- ACHAINABLE_URL=http://localhost:19527
- ACHAINABLE_AUTH_KEY=
Expand Down
9 changes: 3 additions & 6 deletions tee-worker/docker/multiworker-docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,9 @@ services:
environment:
- RUST_LOG=info,litentry_worker=debug,ws=warn,sp_io=error,substrate_api_client=warn,itc_parentchain_light_client=info,jsonrpsee_ws_client=warn,jsonrpsee_ws_server=warn,enclave_runtime=debug,ita_stf=debug,its_rpc_handler=warn,itc_rpc_client=warn,its_consensus_common=debug,its_state=warn,its_consensus_aura=warn,aura*=warn,its_consensus_slots=warn,itp_attestation_handler=debug,http_req=debug,lc_mock_server=warn,itc_rest_client=debug,lc_credentials=debug,lc_identity_verification=debug,lc_stf_task_receiver=debug,lc_stf_task_sender=debug,lc_data_providers=debug,itp_top_pool=debug,itc_parentchain_indirect_calls_executor=debug,
- TWITTER_OFFICIAL_URL=http://localhost:19527
- TWITTER_LITENTRY_URL=http://localhost:19527
- TWITTER_AUTH_TOKEN_V2=
- DISCORD_OFFICIAL_URL=http://localhost:19527
- DISCORD_LITENTRY_URL=http://localhost:19527
- LITENTRY_DISCORD_MICROSERVICE_URL=http://localhost:19527
- DISCORD_AUTH_TOKEN=
- ACHAINABLE_URL=http://localhost:19527
- ACHAINABLE_AUTH_KEY=
Expand Down Expand Up @@ -171,10 +170,9 @@ services:
environment:
- RUST_LOG=info,litentry_worker=debug,ws=warn,sp_io=error,substrate_api_client=warn,itc_parentchain_light_client=info,jsonrpsee_ws_client=warn,jsonrpsee_ws_server=warn,enclave_runtime=debug,ita_stf=debug,its_rpc_handler=warn,itc_rpc_client=warn,its_consensus_common=debug,its_state=warn,its_consensus_aura=warn,aura*=warn,its_consensus_slots=warn,itp_attestation_handler=debug,http_req=debug,lc_mock_server=warn,itc_rest_client=debug,lc_credentials=debug,lc_identity_verification=debug,lc_stf_task_receiver=debug,lc_stf_task_sender=debug,lc_data_providers=debug,itp_top_pool=debug,itc_parentchain_indirect_calls_executor=debug,
- TWITTER_OFFICIAL_URL=http://localhost:19527
- TWITTER_LITENTRY_URL=http://localhost:19527
- TWITTER_AUTH_TOKEN_V2=
- DISCORD_OFFICIAL_URL=http://localhost:19527
- DISCORD_LITENTRY_URL=http://localhost:19527
- LITENTRY_DISCORD_MICROSERVICE_URL=http://localhost:19527
- DISCORD_AUTH_TOKEN=
- ACHAINABLE_URL=http://localhost:19527
- ACHAINABLE_AUTH_KEY=
Expand Down Expand Up @@ -223,10 +221,9 @@ services:
environment:
- RUST_LOG=info,litentry_worker=debug,ws=warn,sp_io=error,substrate_api_client=warn,itc_parentchain_light_client=info,jsonrpsee_ws_client=warn,jsonrpsee_ws_server=warn,enclave_runtime=debug,ita_stf=debug,its_rpc_handler=warn,itc_rpc_client=warn,its_consensus_common=debug,its_state=warn,its_consensus_aura=warn,aura*=warn,its_consensus_slots=warn,itp_attestation_handler=debug,http_req=debug,lc_mock_server=warn,itc_rest_client=debug,lc_credentials=debug,lc_identity_verification=debug,lc_stf_task_receiver=debug,lc_stf_task_sender=debug,lc_data_providers=debug,itp_top_pool=debug,itc_parentchain_indirect_calls_executor=debug,
- TWITTER_OFFICIAL_URL=http://localhost:19527
- TWITTER_LITENTRY_URL=http://localhost:19527
- TWITTER_AUTH_TOKEN_V2=
- DISCORD_OFFICIAL_URL=http://localhost:19527
- DISCORD_LITENTRY_URL=http://localhost:19527
- LITENTRY_DISCORD_MICROSERVICE_URL=http://localhost:19527
- DISCORD_AUTH_TOKEN=
- ACHAINABLE_URL=http://localhost:19527
- ACHAINABLE_AUTH_KEY=
Expand Down
8 changes: 5 additions & 3 deletions tee-worker/litentry/core/assertion-build/src/a2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use lc_data_providers::{
discord_litentry::DiscordLitentryClient, vec_to_string, DataProviderConfig,
};

const VC_A2_SUBJECT_DESCRIPTION: &str = "The user is a member of Litentry Discord.
const VC_A2_SUBJECT_DESCRIPTION: &str = "The user is a member of Litentry Discord.
Server link: https://discord.gg/phBSa3eMX9
Guild ID: 807161594245152800.";
const VC_A2_SUBJECT_TYPE: &str = "Litentry Discord Member";
Expand All @@ -44,7 +44,8 @@ pub fn build(
Error::RequestVCFailed(Assertion::A2(guild_id.clone()), ErrorDetail::ParseError)
})?;

let mut client = DiscordLitentryClient::new(&data_provider_config.discord_litentry_url);
let mut client =
DiscordLitentryClient::new(&data_provider_config.litentry_discord_microservice_url);
for identity in &req.identities {
if let Identity::Discord(address) = &identity.0 {
discord_cnt += 1;
Expand Down Expand Up @@ -94,7 +95,8 @@ mod tests {
#[test]
fn build_a2_works() {
let mut data_provider_config = DataProviderConfig::new();
data_provider_config.set_discord_litentry_url("http://localhost:19527".to_string());
data_provider_config
.set_litentry_discord_microservice_url("http://localhost:19527".to_string());
let guild_id_u: u64 = 919848390156767232;
let guild_id_vec: Vec<u8> = format!("{}", guild_id_u).as_bytes().to_vec();

Expand Down
6 changes: 4 additions & 2 deletions tee-worker/litentry/core/assertion-build/src/a3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ pub fn build(
)
})?;

let mut client = DiscordLitentryClient::new(&data_provider_config.discord_litentry_url);
let mut client =
DiscordLitentryClient::new(&data_provider_config.litentry_discord_microservice_url);
for identity in &req.identities {
if let Identity::Discord(address) = &identity.0 {
let resp = client
Expand Down Expand Up @@ -117,7 +118,8 @@ mod tests {
#[test]
fn build_a3_works() {
let mut data_provider_config = DataProviderConfig::new();
data_provider_config.set_discord_litentry_url("http://localhost:19527".to_string());
data_provider_config
.set_litentry_discord_microservice_url("http://localhost:19527".to_string());
let guild_id_u: u64 = 919848390156767232;
let channel_id_u: u64 = 919848392035794945;
let role_id_u: u64 = 1034083718425493544;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ pub fn build(
})?;

let mut has_role_value = false;
let mut client = DiscordLitentryClient::new(&data_provider_config.discord_litentry_url);
let mut client =
DiscordLitentryClient::new(&data_provider_config.litentry_discord_microservice_url);
for identity in &req.identities {
if let Identity::Discord(address) = &identity.0 {
let resp =
Expand Down Expand Up @@ -110,7 +111,7 @@ mod tests {
let url = run(0).unwrap();
let mut data_provider_conifg = DataProviderConfig::new();

data_provider_conifg.set_discord_litentry_url(url);
data_provider_conifg.set_litentry_discord_microservice_url(url);
data_provider_conifg.set_contest_legend_discord_role_id("1034083718425493544".to_string());
data_provider_conifg.set_sora_quiz_attendee_id("1034083718425493544".to_string());
data_provider_conifg
Expand Down
16 changes: 9 additions & 7 deletions tee-worker/litentry/core/data-providers/src/discord_litentry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
#[cfg(all(not(feature = "std"), feature = "sgx"))]
use crate::sgx_reexport_prelude::*;

use crate::{build_client, vec_to_string, Error, HttpError};
use crate::{build_client_with_cert, vec_to_string, Error, HttpError};
use http::header::CONNECTION;
use http_req::response::Headers;
use itc_rest_client::{
http_client::{DefaultSend, HttpClient},
http_client::{HttpClient, SendWithCertificateVerification},
rest_client::RestClient,
RestGet, RestPath,
};
Expand Down Expand Up @@ -50,14 +50,14 @@ impl RestPath<String> for DiscordResponse {
}

pub struct DiscordLitentryClient {
client: RestClient<HttpClient<DefaultSend>>,
client: RestClient<HttpClient<SendWithCertificateVerification>>,
}

impl DiscordLitentryClient {
pub fn new(url: &str) -> Self {
let mut headers = Headers::new();
headers.insert(CONNECTION.as_str(), "close");
let client = build_client(url, headers);
let client = build_client_with_cert(url, headers);
DiscordLitentryClient { client }
}

Expand Down Expand Up @@ -162,7 +162,7 @@ mod tests {
let _ = env_logger::builder().is_test(true).try_init();
let url = run(0).unwrap();
let mut data_provider_config = DataProviderConfig::new();
data_provider_config.set_discord_litentry_url(url);
data_provider_config.set_litentry_discord_microservice_url(url);
data_provider_config
}

Expand All @@ -171,7 +171,8 @@ mod tests {
let data_provider_config = init();
let guild_id = "919848390156767232".as_bytes().to_vec();
let handler = "againstwar".as_bytes().to_vec();
let mut client = DiscordLitentryClient::new(&data_provider_config.discord_litentry_url);
let mut client =
DiscordLitentryClient::new(&data_provider_config.litentry_discord_microservice_url);
let response = client.check_join(guild_id, handler);
assert!(response.is_ok(), "check join discord error: {:?}", response);
}
Expand All @@ -183,7 +184,8 @@ mod tests {
let channel_id = "919848392035794945".as_bytes().to_vec();
let role_id = "1034083718425493544".as_bytes().to_vec();
let handler = "ericzhang.eth".as_bytes().to_vec();
let mut client = DiscordLitentryClient::new(&data_provider_config.discord_litentry_url);
let mut client =
DiscordLitentryClient::new(&data_provider_config.litentry_discord_microservice_url);
let response = client.check_id_hubber(guild_id, channel_id, role_id, handler);
assert!(response.is_ok(), "check discord id hubber error: {:?}", response);
}
Expand Down
24 changes: 8 additions & 16 deletions tee-worker/litentry/core/data-providers/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,9 @@ impl TokenFromString for ETokenAddress {
#[derive(PartialEq, Eq, Clone, Encode, Decode, Serialize, Deserialize, Debug)]
pub struct DataProviderConfig {
pub twitter_official_url: String,
pub twitter_litentry_url: String,
pub twitter_auth_token_v2: String,
pub discord_official_url: String,
pub discord_litentry_url: String,
pub litentry_discord_microservice_url: String,
pub discord_auth_token: String,
pub achainable_url: String,
pub achainable_auth_key: String,
Expand Down Expand Up @@ -215,10 +214,10 @@ impl DataProviderConfig {
// default prod config
let mut config = DataProviderConfig {
twitter_official_url: "https://api.twitter.com".to_string(),
twitter_litentry_url: "http://127.0.0.1:9527”".to_string(),
twitter_auth_token_v2: "".to_string(),
discord_official_url: "https://discordapp.com".to_string(),
discord_litentry_url: "http://127.0.0.1:9527”".to_string(),
litentry_discord_microservice_url: "https://tee-microservice.litentry.io:9528"
.to_string(),
discord_auth_token: "".to_string(),
achainable_url: "https://label-production.graph.tdf-labs.io/".to_string(),
achainable_auth_key: "".to_string(),
Expand Down Expand Up @@ -255,14 +254,11 @@ impl DataProviderConfig {
if let Ok(v) = env::var("TWITTER_OFFICIAL_URL") {
config.set_twitter_official_url(v);
}
if let Ok(v) = env::var("TWITTER_LITENTRY_URL") {
config.set_twitter_litentry_url(v);
}
if let Ok(v) = env::var("DISCORD_OFFICIAL_URL") {
config.set_discord_official_url(v);
}
if let Ok(v) = env::var("DISCORD_LITENTRY_URL") {
config.set_discord_litentry_url(v);
if let Ok(v) = env::var("LITENTRY_DISCORD_MICROSERVICE_URL") {
config.set_litentry_discord_microservice_url(v);
}
if let Ok(v) = env::var("ACHAINABLE_URL") {
config.set_achainable_url(v);
Expand Down Expand Up @@ -356,10 +352,6 @@ impl DataProviderConfig {
debug!("set_twitter_official_url: {:?}", v);
self.twitter_official_url = v;
}
pub fn set_twitter_litentry_url(&mut self, v: String) {
debug!("set_twitter_litentry_url: {:?}", v);
self.twitter_litentry_url = v;
}
pub fn set_twitter_auth_token_v2(&mut self, v: String) {
debug!("set_twitter_auth_token_v2: {:?}", v);
self.twitter_auth_token_v2 = v;
Expand All @@ -368,9 +360,9 @@ impl DataProviderConfig {
debug!("set_discord_official_url: {:?}", v);
self.discord_official_url = v;
}
pub fn set_discord_litentry_url(&mut self, v: String) {
debug!("set_discord_litentry_url: {:?}", v);
self.discord_litentry_url = v;
pub fn set_litentry_discord_microservice_url(&mut self, v: String) {
debug!("set_litentry_discord_microservice_url: {:?}", v);
self.litentry_discord_microservice_url = v;
}
pub fn set_discord_auth_token(&mut self, v: String) {
debug!("set_discord_auth_token: {:?}", v);
Expand Down
2 changes: 0 additions & 2 deletions tee-worker/litentry/core/mock-server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ pub mod karat_dao;
pub mod litentry_archive;
pub mod moralis;
pub mod nodereal_jsonrpc;
pub mod twitter_litentry;
pub mod twitter_official;
pub mod vip3;

Expand Down Expand Up @@ -60,7 +59,6 @@ pub fn run(port: u16) -> Result<String, RecvError> {
.or(twitter_official::query_retweeted_by())
.or(twitter_official::query_user_by_name())
.or(twitter_official::query_user_by_id())
.or(twitter_litentry::check_follow())
.or(discord_official::query_message())
.or(discord_litentry::check_id_hubber())
.or(discord_litentry::check_join())
Expand Down
38 changes: 0 additions & 38 deletions tee-worker/litentry/core/mock-server/src/twitter_litentry.rs

This file was deleted.

3 changes: 1 addition & 2 deletions tee-worker/local-setup/.env.dev
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ MORALIS_API_KEY=
# The followings are default value.
# Can be skipped; or overwrite within non-production mode.
TWITTER_OFFICIAL_URL=http://localhost:19527
TWITTER_LITENTRY_URL=http://localhost:19527
DISCORD_OFFICIAL_URL=http://localhost:19527
DISCORD_LITENTRY_URL=http://localhost:19527
LITENTRY_DISCORD_MICROSERVICE_URL=http://localhost:19527
ACHAINABLE_URL=http://localhost:19527
CREDENTIAL_ENDPOINT=http://localhost:9933
ONEBLOCK_NOTION_URL=https://abc.com
Expand Down

0 comments on commit 717e39f

Please sign in to comment.