bump sphinx-rs, drop rmp_serde

This commit is contained in:
Evan Feenstra
2023-07-17 09:10:57 -07:00
parent 3f99d27766
commit bbdff4eab0
6 changed files with 53 additions and 49 deletions

39
Cargo.lock generated
View File

@@ -190,8 +190,6 @@ checksum = "29b9e657de8ff1c3488a4ab77cb51d604eab53415ce34f0bc800f2eac9b13c28"
dependencies = [
"bitcoin_hashes",
"rand_core 0.4.2",
"serde",
"unicode-normalization",
]
[[package]]
@@ -1201,14 +1199,13 @@ checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4"
[[package]]
name = "lss-connector"
version = "0.1.0"
source = "git+https://github.com/stakwork/sphinx-rs.git?rev=0843db9ff287f388653089ae95f45cac85fe7a66#0843db9ff287f388653089ae95f45cac85fe7a66"
source = "git+https://github.com/stakwork/sphinx-rs.git?rev=a5008ee18222cb6503049ea9cd9df0f3ba60495a#a5008ee18222cb6503049ea9cd9df0f3ba60495a"
dependencies = [
"anyhow",
"log",
"rmp-serde",
"rmp",
"rmp-utils",
"secp256k1",
"serde",
"serde-big-array",
"sphinx-glyph",
"vls-protocol-signer",
]
@@ -1572,6 +1569,15 @@ dependencies = [
"serde",
]
[[package]]
name = "rmp-utils"
version = "0.1.0"
source = "git+https://github.com/stakwork/sphinx-rs.git?rev=a5008ee18222cb6503049ea9cd9df0f3ba60495a#a5008ee18222cb6503049ea9cd9df0f3ba60495a"
dependencies = [
"anyhow",
"rmp",
]
[[package]]
name = "rustc-demangle"
version = "0.1.23"
@@ -1673,15 +1679,6 @@ dependencies = [
"serde_derive",
]
[[package]]
name = "serde-big-array"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "11fc7cc2c76d73e0f27ee52abbd64eec84d46f370c88371120433196934e4b7f"
dependencies = [
"serde",
]
[[package]]
name = "serde_bolt"
version = "0.2.4"
@@ -1781,7 +1778,7 @@ dependencies = [
[[package]]
name = "sphinx-auther"
version = "0.1.12"
source = "git+https://github.com/stakwork/sphinx-rs.git?rev=0843db9ff287f388653089ae95f45cac85fe7a66#0843db9ff287f388653089ae95f45cac85fe7a66"
source = "git+https://github.com/stakwork/sphinx-rs.git?rev=a5008ee18222cb6503049ea9cd9df0f3ba60495a#a5008ee18222cb6503049ea9cd9df0f3ba60495a"
dependencies = [
"anyhow",
"base64 0.21.2",
@@ -1793,7 +1790,7 @@ dependencies = [
[[package]]
name = "sphinx-crypter"
version = "0.1.0"
source = "git+https://github.com/stakwork/sphinx-rs.git?rev=0843db9ff287f388653089ae95f45cac85fe7a66#0843db9ff287f388653089ae95f45cac85fe7a66"
source = "git+https://github.com/stakwork/sphinx-rs.git?rev=a5008ee18222cb6503049ea9cd9df0f3ba60495a#a5008ee18222cb6503049ea9cd9df0f3ba60495a"
dependencies = [
"anyhow",
"chacha20poly1305",
@@ -1804,11 +1801,12 @@ dependencies = [
[[package]]
name = "sphinx-glyph"
version = "0.1.2"
source = "git+https://github.com/stakwork/sphinx-rs.git?rev=0843db9ff287f388653089ae95f45cac85fe7a66#0843db9ff287f388653089ae95f45cac85fe7a66"
source = "git+https://github.com/stakwork/sphinx-rs.git?rev=a5008ee18222cb6503049ea9cd9df0f3ba60495a#a5008ee18222cb6503049ea9cd9df0f3ba60495a"
dependencies = [
"anyhow",
"hex",
"rmp-serde",
"rmp",
"rmp-utils",
"serde",
"serde_json",
"sphinx-auther",
@@ -1829,7 +1827,6 @@ dependencies = [
"hex",
"log",
"lss-connector",
"rmp-serde",
"serde",
"serde_json",
"serde_urlencoded",
@@ -1856,7 +1853,7 @@ dependencies = [
[[package]]
name = "sphinx-signer"
version = "0.1.0"
source = "git+https://github.com/stakwork/sphinx-rs.git?rev=0843db9ff287f388653089ae95f45cac85fe7a66#0843db9ff287f388653089ae95f45cac85fe7a66"
source = "git+https://github.com/stakwork/sphinx-rs.git?rev=a5008ee18222cb6503049ea9cd9df0f3ba60495a#a5008ee18222cb6503049ea9cd9df0f3ba60495a"
dependencies = [
"anyhow",
"bip39",

View File

@@ -13,16 +13,15 @@ std = ["sphinx-signer"]
[dependencies]
hex = "0.4.3"
rmp-serde = "1.1.0"
serde = { version = "1.0.137", default-features = false }
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 = "0843db9ff287f388653089ae95f45cac85fe7a66" }
lss-connector = { git = "https://github.com/stakwork/sphinx-rs.git", default-features = false, rev = "a5008ee18222cb6503049ea9cd9df0f3ba60495a" }
# lss-connector = { path = "../../sphinx-rs/lss-connector", default-features = false }
sphinx-crypter = { git = "https://github.com/stakwork/sphinx-rs.git", rev = "0843db9ff287f388653089ae95f45cac85fe7a66" }
sphinx-signer = { git = "https://github.com/stakwork/sphinx-rs.git", optional = true, rev = "0843db9ff287f388653089ae95f45cac85fe7a66" }
sphinx-crypter = { git = "https://github.com/stakwork/sphinx-rs.git", rev = "a5008ee18222cb6503049ea9cd9df0f3ba60495a" }
sphinx-signer = { git = "https://github.com/stakwork/sphinx-rs.git", optional = true, rev = "a5008ee18222cb6503049ea9cd9df0f3ba60495a" }
# sphinx-signer = { path = "../../sphinx-rs/signer", optional = true }
anyhow.workspace = true

View File

@@ -40,7 +40,7 @@ fn main() -> anyhow::Result<()> {
let path = entry.path();
if path.is_dir() {
println!("PATH {}", path.display());
if let Err(e) = fs::remove_dir_all(path) {
if let Err(_e) = fs::remove_dir_all(path) {
println!("err removing dir");
}
}

View File

@@ -1,10 +1,10 @@
use anyhow::{anyhow, Result};
use anyhow::{anyhow, Context, Result};
use embedded_svc::storage::RawStorage;
use esp_idf_svc::nvs::{EspDefaultNvs, EspDefaultNvsPartition};
use glyph::control::{Config, ControlPersist, Controller, FlashKey, Policy, Velocity};
use glyph::ser::*;
use sphinx_signer::lightning_signer::bitcoin::Network;
use sphinx_signer::sphinx_glyph::control::{
Config, ControlPersist, Controller, FlashKey, Policy, Velocity,
};
use sphinx_signer::sphinx_glyph as glyph;
use std::convert::TryInto;
use std::sync::{Arc, Mutex};
@@ -49,11 +49,13 @@ impl ControlPersist for FlashPersister {
.0
.get_raw(FlashKey::Config.as_str(), &mut buf)?
.ok_or(anyhow!("no existing config"))?;
Ok(rmp_serde::from_slice(existing)?)
let mut bytes = Bytes::new(&existing);
Ok(deserialize_config(&mut bytes)?)
}
fn write_config(&mut self, conf: Config) -> Result<()> {
let conf1 = rmp_serde::to_vec(&conf)?;
self.0.set_raw(FlashKey::Config.as_str(), &conf1[..])?;
let mut bb = ByteBuf::new();
serialize_config(&mut bb, &conf)?;
self.0.set_raw(FlashKey::Config.as_str(), bb.as_slice())?;
Ok(())
}
fn remove_config(&mut self) -> Result<()> {
@@ -83,11 +85,13 @@ impl ControlPersist for FlashPersister {
.0
.get_raw(FlashKey::Policy.as_str(), &mut buf)?
.ok_or(anyhow!("no existing policy"))?;
Ok(rmp_serde::from_slice(existing)?)
let mut bytes = Bytes::new(&existing);
Ok(deserialize_policy(&mut bytes, None)?)
}
fn write_policy(&mut self, pol: Policy) -> Result<()> {
let pol1 = rmp_serde::to_vec(&pol)?;
self.0.set_raw(FlashKey::Policy.as_str(), &pol1[..])?;
let mut bb = ByteBuf::new();
serialize_policy(&mut bb, None, &pol)?;
self.0.set_raw(FlashKey::Policy.as_str(), bb.as_slice())?;
Ok(())
}
fn remove_policy(&mut self) -> Result<()> {
@@ -100,11 +104,14 @@ impl ControlPersist for FlashPersister {
.0
.get_raw(FlashKey::Velocity.as_str(), &mut buf)?
.ok_or(anyhow!("no existing velocity"))?;
Ok(rmp_serde::from_slice(existing)?)
let mut bytes = Bytes::new(existing);
let desvel = deserialize_velocity(&mut bytes, None)?;
Ok(desvel.context(anyhow::anyhow!("no velocity"))?)
}
fn write_velocity(&mut self, vel: Velocity) -> Result<()> {
let vel1 = rmp_serde::to_vec(&vel)?;
self.0.set_raw(FlashKey::Velocity.as_str(), &vel1[..])?;
let mut bb = ByteBuf::new();
serialize_velocity(&mut bb, None, Some(&vel))?;
self.0.set_raw(FlashKey::Velocity.as_str(), bb.as_slice())?;
Ok(())
}
}

View File

@@ -3,16 +3,16 @@ use crate::core::lss;
use crate::ota::{update_sphinx_key, validate_ota_message};
use crate::status::Status;
use glyph::control::{Config, ControlMessage, ControlResponse, Controller, Policy, Velocity};
use glyph::error::Error as GlyphError;
use glyph::ser::{serialize_controlresponse, ByteBuf};
use glyph::topics;
use lss_connector::secp256k1::PublicKey;
use sphinx_signer::approver::SphinxApprover;
use sphinx_signer::lightning_signer::bitcoin::Network;
use sphinx_signer::lightning_signer::persist::Persist;
use sphinx_signer::persist::{BackupPersister, FsPersister, ThreadMemoPersister};
use sphinx_signer::sphinx_glyph::control::{
Config, ControlMessage, ControlResponse, Controller, Policy, Velocity,
};
use sphinx_signer::sphinx_glyph::error::Error as GlyphError;
use sphinx_signer::sphinx_glyph::topics;
use sphinx_signer::sphinx_glyph as glyph;
use sphinx_signer::{self, Handler, RootHandler};
use std::sync::mpsc;
use std::sync::Arc;
@@ -135,6 +135,7 @@ pub fn make_event_loop(
Err(e) => {
log::error!("failed to init lss {:?}", e);
unsafe { esp_idf_sys::esp_restart() };
return Err(anyhow::anyhow!("nope"));
}
};
@@ -220,9 +221,9 @@ pub fn make_event_loop(
if let Some(res) =
handle_control_response(&root_handler, &approver, cres, led_tx.clone())
{
let res_data =
rmp_serde::to_vec_named(&res).expect("could not publish control response");
mqtt_pub(&mut mqtt, client_id, topics::CONTROL_RES, &res_data);
let mut bb = ByteBuf::new();
serialize_controlresponse(&mut bb, &res).expect("failed serialize_lssresponse");
mqtt_pub(&mut mqtt, client_id, topics::CONTROL_RES, bb.as_slice());
}
}
}

View File

@@ -26,7 +26,7 @@ pub fn init_lss(
}
};
let (lss_signer, res1) = LssSigner::new(&handler_builder, &server_pubkey, None, None);
let (lss_signer, res1) = LssSigner::new(&handler_builder, &server_pubkey, None);
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");
@@ -39,7 +39,7 @@ pub fn init_lss(
}
};
let (root_handler, res2) = lss_signer.build_with_lss(created, handler_builder)?;
let (root_handler, res2) = lss_signer.build_with_lss(created, handler_builder, None)?;
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");