-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow Tokio Console support #517
Changes from all commits
7f65090
08ae810
191ecc5
f042087
87ad4d5
a0d233d
c6d5e25
e77d7ac
bd13f8f
a02b192
102f58c
5507a2a
6ef16b1
ff168c6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,7 @@ log = "0.4.0" | |
serde = { version = "1.0.136", features = ["derive"] } | ||
serde_json = "1.0.71" | ||
thiserror = "1.0" | ||
tokio = { version = "1.0", features = ["full"] } | ||
tokio = { version = "1.37", features = ["full"] } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The reason for this is the "lost its waker" issue in tokio, fixed in the newer versions. |
||
prometheus = { version = "0.12.0", features = ["process"] } | ||
url = "2" | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ wallet = { path = "../wallet", features = ["testing-utils"] } | |
|
||
[dependencies] | ||
hex = "0.4.3" | ||
log = {version = "0.4.14"} | ||
tracing = { version = "0.1", features = ["log"] } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. helps with tokio-console and instrumentation:
|
||
|
||
base64 = "0.13.0" | ||
rand = "0.8.5" | ||
|
@@ -34,11 +34,12 @@ substrate-stellar-sdk = {git = "https://github.com/pendulum-chain/substrate-stel | |
|
||
err-derive = "0.3.1" | ||
|
||
tokio = { version = "1.0", features = [ | ||
tokio = { version = "1.37", features = [ | ||
"macros", # allows main function to be async | ||
"rt-multi-thread", # for multi-thread runtime | ||
"sync", # to make channels available | ||
"time" # for timeouts and sleep, when reconnecting | ||
"time", # for timeouts and sleep, when reconnecting | ||
"tracing" # for tokio console | ||
] } | ||
async-std = { version = "1.12.0", features = ["attributes"] } | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ use substrate_stellar_sdk::{ | |
types::{AuthenticatedMessageV0, Curve25519Public, HmacSha256Mac, MessageType}, | ||
XdrCodec, | ||
}; | ||
use tracing::{error, trace}; | ||
|
||
use crate::{ | ||
connection::{ | ||
|
@@ -86,18 +87,12 @@ impl Connector { | |
body: &[u8], | ||
) -> Result<(), Error> { | ||
let remote_info = self.remote_info.as_ref().ok_or(Error::NoRemoteInfo)?; | ||
log::trace!( | ||
trace!( | ||
"verify_auth(): remote sequence: {}, auth message sequence: {}", | ||
remote_info.sequence(), | ||
auth_msg.sequence | ||
); | ||
|
||
let auth_msg_xdr = auth_msg.to_base64_xdr(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I decided to remove this because the xdr was huge and may not be helpful at all. |
||
let auth_msg_xdr = | ||
String::from_utf8(auth_msg_xdr.clone()).unwrap_or(format!("{:?}", auth_msg_xdr)); | ||
|
||
log::debug!("verify_auth(): received auth message from Stellar Node: {auth_msg_xdr}"); | ||
|
||
if remote_info.sequence() != auth_msg.sequence { | ||
// must be handled on main thread because workers could mix up order of messages. | ||
return Err(Error::InvalidSequenceNumber) | ||
|
@@ -169,7 +164,7 @@ impl Connector { | |
|
||
pub fn stop(&mut self) { | ||
if let Err(e) = self.tcp_stream.shutdown(Shutdown::Both) { | ||
log::error!("stop(): failed to shutdown tcp stream: {}", e); | ||
error!("stop(): failed to shutdown tcp stream: {}", e); | ||
} | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
use substrate_stellar_sdk::{ | ||
types::{ErrorCode, Hello, MessageType, StellarMessage}, | ||
XdrCodec, | ||
}; | ||
|
||
use crate::connection::{ | ||
authentication::verify_remote_auth_cert, | ||
helper::{error_to_string, time_now}, | ||
hmac::HMacKeys, | ||
xdr_converter::parse_authenticated_message, | ||
Connector, Error, Xdr, | ||
}; | ||
use substrate_stellar_sdk::{ | ||
types::{ErrorCode, Hello, MessageType, StellarMessage}, | ||
XdrCodec, | ||
}; | ||
use tracing::{error, info, trace, warn}; | ||
|
||
use crate::node::RemoteInfo; | ||
|
||
|
@@ -33,13 +33,13 @@ impl Connector { | |
|
||
MessageType::ErrorMsg => match auth_msg.message { | ||
StellarMessage::ErrorMsg(e) => { | ||
log::error!( | ||
error!( | ||
"process_raw_message(): Received ErrorMsg during authentication: {}", | ||
error_to_string(e.clone()) | ||
); | ||
return Err(Error::from(e)) | ||
}, | ||
other => log::error!( | ||
other => error!( | ||
"process_raw_message(): Received ErrorMsg during authentication: {:?}", | ||
other | ||
), | ||
|
@@ -50,9 +50,7 @@ impl Connector { | |
if self.is_handshake_created() { | ||
self.verify_auth(&auth_msg, &data[4..(data.len() - 32)])?; | ||
self.increment_remote_sequence()?; | ||
log::trace!( | ||
"process_raw_message(): Processing {msg_type:?} message: auth verified" | ||
); | ||
trace!("process_raw_message(): Processing {msg_type:?} message: auth verified"); | ||
} | ||
|
||
return self.process_stellar_message(auth_msg.message, msg_type).await | ||
|
@@ -80,29 +78,23 @@ impl Connector { | |
} else { | ||
self.send_auth_message().await?; | ||
} | ||
log::info!("process_stellar_message(): Hello message processed successfully"); | ||
info!("process_stellar_message(): Hello message processed successfully"); | ||
}, | ||
|
||
StellarMessage::Auth(_) => { | ||
self.process_auth_message().await?; | ||
}, | ||
|
||
StellarMessage::ErrorMsg(e) => { | ||
log::error!( | ||
"process_stellar_message(): Received ErrorMsg during authentication: {e:?}" | ||
); | ||
error!("process_stellar_message(): Received ErrorMsg during authentication: {e:?}"); | ||
if e.code == ErrorCode::ErrConf || e.code == ErrorCode::ErrAuth { | ||
return Err(Error::from(e)) | ||
} | ||
return Ok(Some(StellarMessage::ErrorMsg(e))) | ||
}, | ||
|
||
// we do not handle other messages. Return to caller | ||
other => { | ||
log::trace!( | ||
"process_stellar_message(): Processing {} message: received from overlay", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we are only interested on messages that will be processed by the vault. |
||
String::from_utf8(other.to_base64_xdr()) | ||
.unwrap_or(format!("{:?}", other.to_base64_xdr())) | ||
); | ||
self.check_to_send_more(msg_type).await?; | ||
return Ok(Some(other)) | ||
}, | ||
|
@@ -124,7 +116,7 @@ impl Connector { | |
remote.node().overlay_version, | ||
); | ||
} else { | ||
log::warn!("process_auth_message(): No remote overlay version after handshake."); | ||
warn!("process_auth_message(): No remote overlay version after handshake."); | ||
} | ||
|
||
self.check_to_send_more(MessageType::Auth).await | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
latest tokio vresion is 1.37.