both init_1 and init_2 topics

This commit is contained in:
Evan Feenstra
2023-07-07 13:15:32 -07:00
parent 249c5f9d8e
commit e6f8ea8e34
9 changed files with 36 additions and 26 deletions

10
Cargo.lock generated
View File

@@ -1195,7 +1195,7 @@ checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4"
[[package]]
name = "lss-connector"
version = "0.1.0"
source = "git+https://github.com/stakwork/sphinx-rs.git?rev=78d8c989bed15f63e5cc7df42e19ee7117c33807#78d8c989bed15f63e5cc7df42e19ee7117c33807"
source = "git+https://github.com/stakwork/sphinx-rs.git?rev=38d7fa25e860b61a813ca8c3fad17f699daf2f08#38d7fa25e860b61a813ca8c3fad17f699daf2f08"
dependencies = [
"anyhow",
"log",
@@ -1775,7 +1775,7 @@ dependencies = [
[[package]]
name = "sphinx-auther"
version = "0.1.12"
source = "git+https://github.com/stakwork/sphinx-rs.git?rev=78d8c989bed15f63e5cc7df42e19ee7117c33807#78d8c989bed15f63e5cc7df42e19ee7117c33807"
source = "git+https://github.com/stakwork/sphinx-rs.git?rev=38d7fa25e860b61a813ca8c3fad17f699daf2f08#38d7fa25e860b61a813ca8c3fad17f699daf2f08"
dependencies = [
"anyhow",
"base64",
@@ -1787,7 +1787,7 @@ dependencies = [
[[package]]
name = "sphinx-crypter"
version = "0.1.0"
source = "git+https://github.com/stakwork/sphinx-rs.git?rev=78d8c989bed15f63e5cc7df42e19ee7117c33807#78d8c989bed15f63e5cc7df42e19ee7117c33807"
source = "git+https://github.com/stakwork/sphinx-rs.git?rev=38d7fa25e860b61a813ca8c3fad17f699daf2f08#38d7fa25e860b61a813ca8c3fad17f699daf2f08"
dependencies = [
"anyhow",
"chacha20poly1305",
@@ -1798,7 +1798,7 @@ dependencies = [
[[package]]
name = "sphinx-glyph"
version = "0.1.2"
source = "git+https://github.com/stakwork/sphinx-rs.git?rev=78d8c989bed15f63e5cc7df42e19ee7117c33807#78d8c989bed15f63e5cc7df42e19ee7117c33807"
source = "git+https://github.com/stakwork/sphinx-rs.git?rev=38d7fa25e860b61a813ca8c3fad17f699daf2f08#38d7fa25e860b61a813ca8c3fad17f699daf2f08"
dependencies = [
"anyhow",
"hex",
@@ -1850,7 +1850,7 @@ dependencies = [
[[package]]
name = "sphinx-signer"
version = "0.1.0"
source = "git+https://github.com/stakwork/sphinx-rs.git?rev=78d8c989bed15f63e5cc7df42e19ee7117c33807#78d8c989bed15f63e5cc7df42e19ee7117c33807"
source = "git+https://github.com/stakwork/sphinx-rs.git?rev=38d7fa25e860b61a813ca8c3fad17f699daf2f08#38d7fa25e860b61a813ca8c3fad17f699daf2f08"
dependencies = [
"anyhow",
"bip39",

8
broker/Cargo.lock generated
View File

@@ -1702,7 +1702,7 @@ dependencies = [
[[package]]
name = "lss-connector"
version = "0.1.0"
source = "git+https://github.com/stakwork/sphinx-rs?rev=78d8c989bed15f63e5cc7df42e19ee7117c33807#78d8c989bed15f63e5cc7df42e19ee7117c33807"
source = "git+https://github.com/stakwork/sphinx-rs?rev=38d7fa25e860b61a813ca8c3fad17f699daf2f08#38d7fa25e860b61a813ca8c3fad17f699daf2f08"
dependencies = [
"anyhow",
"lightning-storage-server",
@@ -3311,7 +3311,7 @@ dependencies = [
[[package]]
name = "sphinx-auther"
version = "0.1.12"
source = "git+https://github.com/stakwork/sphinx-rs?rev=78d8c989bed15f63e5cc7df42e19ee7117c33807#78d8c989bed15f63e5cc7df42e19ee7117c33807"
source = "git+https://github.com/stakwork/sphinx-rs?rev=38d7fa25e860b61a813ca8c3fad17f699daf2f08#38d7fa25e860b61a813ca8c3fad17f699daf2f08"
dependencies = [
"anyhow",
"base64 0.13.1",
@@ -3323,7 +3323,7 @@ dependencies = [
[[package]]
name = "sphinx-glyph"
version = "0.1.2"
source = "git+https://github.com/stakwork/sphinx-rs?rev=78d8c989bed15f63e5cc7df42e19ee7117c33807#78d8c989bed15f63e5cc7df42e19ee7117c33807"
source = "git+https://github.com/stakwork/sphinx-rs?rev=38d7fa25e860b61a813ca8c3fad17f699daf2f08#38d7fa25e860b61a813ca8c3fad17f699daf2f08"
dependencies = [
"anyhow",
"hex",
@@ -3369,7 +3369,7 @@ dependencies = [
[[package]]
name = "sphinx-signer"
version = "0.1.0"
source = "git+https://github.com/stakwork/sphinx-rs?rev=78d8c989bed15f63e5cc7df42e19ee7117c33807#78d8c989bed15f63e5cc7df42e19ee7117c33807"
source = "git+https://github.com/stakwork/sphinx-rs?rev=38d7fa25e860b61a813ca8c3fad17f699daf2f08#38d7fa25e860b61a813ca8c3fad17f699daf2f08"
dependencies = [
"anyhow",
"bip39",

View File

@@ -35,8 +35,8 @@ vls-protocol = { git = "https://gitlab.com/lightning-signer/validating-li
vls-protocol-client = { git = "https://gitlab.com/lightning-signer/validating-lightning-signer.git", rev = "e199c70cbacd3404e7cecf95bb75ca02afd4cffd" }
vls-proxy = { git = "https://gitlab.com/lightning-signer/validating-lightning-signer.git", rev = "e199c70cbacd3404e7cecf95bb75ca02afd4cffd" }
lss-connector = { git = "https://github.com/stakwork/sphinx-rs", rev = "78d8c989bed15f63e5cc7df42e19ee7117c33807" }
sphinx-signer = { git = "https://github.com/stakwork/sphinx-rs", rev = "78d8c989bed15f63e5cc7df42e19ee7117c33807" }
lss-connector = { git = "https://github.com/stakwork/sphinx-rs", rev = "38d7fa25e860b61a813ca8c3fad17f699daf2f08" }
sphinx-signer = { git = "https://github.com/stakwork/sphinx-rs", rev = "38d7fa25e860b61a813ca8c3fad17f699daf2f08" }
# lss-connector = { path = "../../sphinx-rs/lss-connector" }
# sphinx-signer = { path = "../../sphinx-rs/signer" }

View File

@@ -35,7 +35,7 @@ async fn send_init(
msg_bytes: Vec<u8>,
mqtt_tx: &mpsc::Sender<ChannelRequest>,
) -> Result<InitResponse> {
let reply = ChannelRequest::send(topics::INIT_MSG, msg_bytes, &mqtt_tx).await?;
let reply = ChannelRequest::send(topics::INIT_1_MSG, msg_bytes, &mqtt_tx).await?;
let ir = Response::from_slice(&reply)?.as_init()?;
Ok(ir)
}
@@ -44,7 +44,7 @@ async fn send_created(
msg_bytes: Vec<u8>,
mqtt_tx: &mpsc::Sender<ChannelRequest>,
) -> Result<SignerMutations> {
let reply2 = ChannelRequest::send(topics::INIT_MSG, msg_bytes, &mqtt_tx).await?;
let reply2 = ChannelRequest::send(topics::INIT_2_MSG, msg_bytes, &mqtt_tx).await?;
let cr = Response::from_slice(&reply2)?.as_created()?;
Ok(cr)
}
@@ -111,7 +111,7 @@ async fn dance_step_1(
mqtt_tx: &mpsc::Sender<ChannelRequest>,
) -> Result<InitResponse> {
let init_bytes = lss_conn.make_init_msg().await?;
let reply = ChannelRequest::send_for(cid, topics::INIT_MSG, init_bytes, mqtt_tx).await?;
let reply = ChannelRequest::send_for(cid, topics::INIT_1_MSG, init_bytes, mqtt_tx).await?;
let ir = Response::from_slice(&reply)?.as_init()?;
Ok(ir)
}
@@ -123,7 +123,7 @@ async fn dance_step_2(
ir: &InitResponse,
) -> Result<()> {
let state_bytes = lss_conn.get_created_state_msg(ir).await?;
let reply2 = ChannelRequest::send_for(cid, topics::INIT_MSG, state_bytes, mqtt_tx).await?;
let reply2 = ChannelRequest::send_for(cid, topics::INIT_2_MSG, state_bytes, mqtt_tx).await?;
let cr = Response::from_slice(&reply2)?.as_created()?;
lss_conn.handle(Response::Created(cr)).await?;
Ok(())

View File

@@ -111,7 +111,7 @@ pub fn start_broker(
} else {
// VLS, CONTROL, LSS
let pld = f.publish.payload.to_vec();
if topic_end == topics::INIT_RES {
if topic_end == topics::INIT_1_RES || topic_end == topics::INIT_2_RES {
if let Err(e) = init_tx.send((cid, topic_end, pld)) {
log::error!("failed to pub to init_tx! {:?}", e);
}
@@ -225,7 +225,9 @@ fn subs(cid: &str, mut ltx: LinkTx) {
ltx.subscribe(format!("{}/{}", cid, topics::ERROR)).unwrap();
ltx.subscribe(format!("{}/{}", cid, topics::LSS_RES))
.unwrap();
ltx.subscribe(format!("{}/{}", cid, topics::INIT_RES))
ltx.subscribe(format!("{}/{}", cid, topics::INIT_1_RES))
.unwrap();
ltx.subscribe(format!("{}/{}", cid, topics::INIT_2_RES))
.unwrap();
}

View File

@@ -19,10 +19,10 @@ serde_json = { version = "1.0.81", default-features = false }
serde_urlencoded = "0.7.1"
url = "2"
lss-connector = { git = "https://github.com/stakwork/sphinx-rs.git", default-features = false, rev = "78d8c989bed15f63e5cc7df42e19ee7117c33807" }
lss-connector = { git = "https://github.com/stakwork/sphinx-rs.git", default-features = false, rev = "38d7fa25e860b61a813ca8c3fad17f699daf2f08" }
# lss-connector = { path = "../../sphinx-rs/lss-connector", default-features = false }
sphinx-crypter = { git = "https://github.com/stakwork/sphinx-rs.git", rev = "78d8c989bed15f63e5cc7df42e19ee7117c33807" }
sphinx-signer = { git = "https://github.com/stakwork/sphinx-rs.git", optional = true, rev = "78d8c989bed15f63e5cc7df42e19ee7117c33807" }
sphinx-crypter = { git = "https://github.com/stakwork/sphinx-rs.git", rev = "38d7fa25e860b61a813ca8c3fad17f699daf2f08" }
sphinx-signer = { git = "https://github.com/stakwork/sphinx-rs.git", optional = true, rev = "38d7fa25e860b61a813ca8c3fad17f699daf2f08" }
# sphinx-signer = { path = "../../sphinx-rs/signer", optional = true }
anyhow.workspace = true

View File

@@ -113,7 +113,8 @@ pub fn make_client(
tx.send(CoreEvent::VlsMessage(data))
.expect("couldnt send Event::VlsMessage");
} else if topic.ends_with(topics::LSS_MSG)
|| topic.ends_with(topics::INIT_MSG)
|| topic.ends_with(topics::INIT_1_MSG)
|| topic.ends_with(topics::INIT_2_MSG)
{
log::debug!("received data len {}", data.len());
tx.send(CoreEvent::LssMessage(data))

View File

@@ -38,7 +38,8 @@ pub enum Event {
pub const ROOT_STORE: &str = "/sdcard/store";
pub const SUB_TOPICS: &[&str] = &[
topics::INIT_MSG,
topics::INIT_1_MSG,
topics::INIT_2_MSG,
topics::LSS_MSG,
topics::VLS,
topics::CONTROL,
@@ -231,7 +232,12 @@ fn restart_esp_if_memory_low() {
let size = esp_idf_sys::heap_caps_get_free_size(4);
let block = esp_idf_sys::heap_caps_get_largest_free_block(4);
let threshold = 35000;
log::info!("Available DRAM: {}, Max block: {}, Restart Threshold: {}", size, block, threshold);
log::info!(
"Available DRAM: {}, Max block: {}, Restart Threshold: {}",
size,
block,
threshold
);
if block < threshold {
log::info!("Restarting esp!");
esp_idf_sys::esp_restart();

View File

@@ -27,8 +27,8 @@ pub fn init_lss(
};
let (lss_signer, res1) = LssSigner::new(&handler_builder, &server_pubkey);
let lss_res_topic = format!("{}/{}", client_id, topics::INIT_RES);
mqtt.publish(&lss_res_topic, QOS, false, &res1)
let lss_res_1_topic = format!("{}/{}", client_id, topics::INIT_1_RES);
mqtt.publish(&lss_res_1_topic, QOS, false, &res1)
.expect("could not publish LSS response");
let created = loop {
@@ -40,7 +40,8 @@ pub fn init_lss(
};
let (root_handler, res2) = lss_signer.build_with_lss(created, handler_builder)?;
mqtt.publish(&lss_res_topic, QOS, false, &res2)
let lss_res_2_topic = format!("{}/{}", client_id, topics::INIT_2_RES);
mqtt.publish(&lss_res_2_topic, QOS, false, &res2)
.expect("could not publish LSS response 2");
Ok((root_handler, lss_signer))