Skip to content
This repository has been archived by the owner on Jul 20, 2023. It is now read-only.

refactor: update to new sdk versions #191

Merged
merged 2 commits into from Jun 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
440 changes: 215 additions & 225 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion poi-radio/Cargo.toml
Expand Up @@ -10,7 +10,7 @@ keywords = ["graphprotocol", "data-integrity", "Indexer", "waku", "p2p"]
categories = ["network-programming", "web-programming::http-client"]

[dependencies]
graphcast-sdk = "0.3.3"
graphcast_sdk = { package = "graphcast-sdk", git = "https://github.com/graphops/graphcast-sdk" }
prost = "0.11"
once_cell = "1.17"
chrono = "0.4"
Expand Down
1 change: 1 addition & 0 deletions poi-radio/benches/gossips.rs
Expand Up @@ -53,6 +53,7 @@ fn gossip_poi_bench(c: &mut Criterion) {
persistence_file_path: None,
discv5_enrs: None,
discv5_port: None,
filter_protocol: None,
});

c.bench_function("gossip_poi", move |b| {
Expand Down
8 changes: 5 additions & 3 deletions poi-radio/src/config.rs
Expand Up @@ -15,7 +15,7 @@ use graphcast_sdk::{
init_tracing,
};
use serde::{Deserialize, Serialize};
use tracing::{debug, info};
use tracing::{debug, info, trace};

use crate::state::PersistedState;
use crate::{active_allocation_hashes, syncing_deployment_hashes};
Expand Down Expand Up @@ -269,6 +269,8 @@ pub struct Config {
default_value = "poi-radio"
)]
pub radio_name: String,
#[clap(long, value_name = "FILTER_PROTOCOL", env = "ENABLE_FILTER_PROTOCOL")]
pub filter_protocol: Option<bool>,
}

impl Config {
Expand Down Expand Up @@ -321,7 +323,7 @@ impl Config {
self.waku_host.clone(),
self.waku_port.clone(),
self.waku_addr.clone(),
Some(false),
self.filter_protocol,
self.discv5_enrs.clone(),
self.discv5_port,
)
Expand Down Expand Up @@ -361,7 +363,7 @@ impl Config {
//TODO: set up synchronous panic hook as part of PersistedState functions
// panic_hook(&path);
let state = PersistedState::load_cache(path);
debug!(
trace!(
state = tracing::field::debug(&state),
"Loaded Persisted state cache"
);
Expand Down
4 changes: 2 additions & 2 deletions test-runner/Cargo.toml
Expand Up @@ -21,9 +21,9 @@ categories = [
]

[dependencies]
waku = { version = "0.1.0", package = "waku-bindings" }
waku = { version = "0.1.1", package = "waku-bindings" }
test-utils = { path = "../test-utils" }
graphcast-sdk = "0.3.3"
graphcast_sdk = { package = "graphcast-sdk", git = "https://github.com/graphops/graphcast-sdk" }
poi-radio = { path = "../poi-radio" }
tokio = { version = "1.1.1", features = ["full", "rt"] }
tracing = "0.1"
Expand Down
4 changes: 2 additions & 2 deletions test-sender/Cargo.toml
Expand Up @@ -21,8 +21,8 @@ categories = [
]

[dependencies]
waku = { version = "0.1.0", package = "waku-bindings" }
graphcast-sdk = "0.3.3"
waku = { version = "0.1.1", package = "waku-bindings" }
graphcast_sdk = { package = "graphcast-sdk", git = "https://github.com/graphops/graphcast-sdk" }
poi-radio = { path = "../poi-radio" }
tokio = { version = "1.1.1", features = ["full", "rt"] }
tracing = "0.1"
Expand Down
30 changes: 19 additions & 11 deletions test-sender/src/main.rs
Expand Up @@ -5,15 +5,15 @@ use graphcast_sdk::{
build_wallet,
graphcast_agent::{
message_typing::GraphcastMessage,
waku_handling::{connect_multiaddresses, gather_nodes},
waku_handling::{connect_multiaddresses, gather_nodes, get_dns_nodes},
},
init_tracing,
networks::NetworkName,
};
use poi_radio::RadioPayloadMessage;
use rand::RngCore;
use ring::digest;
use tracing::info;
use tracing::{error, info};
use waku::{
waku_new, GossipSubParams, ProtocolId, WakuContentTopic, WakuNodeConfig, WakuPubSubTopic,
};
Expand All @@ -38,7 +38,7 @@ fn generate_random_poi() -> String {
pub async fn main() {
std::env::set_var(
"RUST_LOG",
"off,hyper=off,graphcast_sdk=trace,poi_radio=trace,poi-radio-e2e-tests=trace",
"off,hyper=off,graphcast_sdk=trace,poi_radio=trace,test_sender=trace",
);
init_tracing("pretty".to_string()).expect("Could not set up global default subscriber for logger, check environmental variable `RUST_LOG` or the CLI input `log-level");

Expand All @@ -48,6 +48,14 @@ pub async fn main() {
..Default::default()
};

let pubsub_topic = WakuPubSubTopic::from_str("/waku/2/graphcast-v0-testnet/proto").unwrap();

let discv5_nodes: Vec<String> = get_dns_nodes(&pubsub_topic)
.into_iter()
.filter(|d| d.enr.is_some())
.map(|d| d.enr.unwrap().to_string())
.collect::<Vec<String>>();

let node_config = WakuNodeConfig {
host: IpAddr::from_str("127.0.0.1").ok(),
port: Some(60002),
Expand All @@ -56,11 +64,11 @@ pub async fn main() {
keep_alive_interval: None,
relay: Some(false), // Default true - will receive all msg on relay
min_peers_to_publish: Some(0), // Default 0
filter: Some(true), // Default false
filter: Some(true), // Default false¡
log_level: None,
relay_topics: [].to_vec(),
discv5: Some(false),
discv5_bootstrap_nodes: [].to_vec(),
discv5_bootstrap_nodes: discv5_nodes,
discv5_udp_port: None,
store: None,
database_url: None,
Expand Down Expand Up @@ -94,8 +102,6 @@ pub async fn main() {
.await
.unwrap();

let pubsub_topic = WakuPubSubTopic::from_str("/waku/2/graphcast-v0-testnet/proto").unwrap();

let nodes = gather_nodes(vec![], &pubsub_topic);
// Connect to peers on the filter protocol
connect_multiaddresses(nodes, &node_handle, ProtocolId::Filter);
Expand All @@ -108,13 +114,15 @@ pub async fn main() {
);
let content_topic = WakuContentTopic::from_str(&content_topic).unwrap();

let sent = graphcast_message.send_to_waku(
if let Err(e) = graphcast_message.send_to_waku(
&node_handle,
WakuPubSubTopic::from_str("/waku/2/graphcast-v0-testnet/proto").unwrap(),
content_topic,
);

info!("Message is sent {:?}", sent);
) {
error!("Failed to send message: {:?}", e);
} else {
info!("Message sent successfully");
}

sleep(Duration::from_secs(5));
}
Expand Down
4 changes: 2 additions & 2 deletions test-utils/Cargo.toml
Expand Up @@ -21,8 +21,8 @@ categories = [
]

[dependencies]
waku = { version = "0.1.0", package = "waku-bindings" }
graphcast-sdk = "0.3.3"
waku = { version = "0.1.1", package = "waku-bindings" }
graphcast_sdk = { package = "graphcast-sdk", git = "https://github.com/graphops/graphcast-sdk" }
poi-radio = { path = "../poi-radio" }
tokio = { version = "1.1.1", features = ["full", "rt"] }
tracing = "0.1"
Expand Down
1 change: 1 addition & 0 deletions test-utils/src/config.rs
Expand Up @@ -47,5 +47,6 @@ pub fn test_config(
telegram_token: None,
discv5_enrs: None,
discv5_port: None,
filter_protocol: None,
}
}