mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-01-10 07:08:05 -05:00
merge last master commits
This commit is contained in:
6
Cargo.lock
generated
6
Cargo.lock
generated
@@ -1296,7 +1296,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "darkwiki"
|
||||
version = "0.3.0"
|
||||
version = "0.4.0"
|
||||
dependencies = [
|
||||
"async-channel",
|
||||
"async-std",
|
||||
@@ -1315,7 +1315,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "darkwikid"
|
||||
version = "0.3.0"
|
||||
version = "0.4.0"
|
||||
dependencies = [
|
||||
"async-channel",
|
||||
"async-executor",
|
||||
@@ -3986,7 +3986,7 @@ checksum = "c02424087780c9b71cc96799eaeddff35af2bc513278cda5c99fc1f5d026d3c1"
|
||||
|
||||
[[package]]
|
||||
name = "tau"
|
||||
version = "0.3.0"
|
||||
version = "0.4.0"
|
||||
dependencies = [
|
||||
"async-std",
|
||||
"chrono",
|
||||
|
||||
@@ -20,8 +20,6 @@ name = "darkfi"
|
||||
members = [
|
||||
"bin/zkas",
|
||||
#"bin/cashierd",
|
||||
"bin/darkwiki",
|
||||
"bin/darkwikid",
|
||||
"bin/darkfid",
|
||||
"bin/darkotc",
|
||||
"bin/drk",
|
||||
@@ -33,6 +31,8 @@ members = [
|
||||
"bin/dao-cli",
|
||||
"bin/tau/taud",
|
||||
"bin/tau/tau-cli",
|
||||
"bin/darkwiki/darkwikid",
|
||||
"bin/darkwiki/darkwiki-cli",
|
||||
"bin/vanityaddr",
|
||||
"bin/lilith",
|
||||
"src/sdk",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "darkwiki"
|
||||
description = ""
|
||||
version = "0.3.0"
|
||||
version = "0.4.0"
|
||||
edition = "2021"
|
||||
authors = ["darkfi <dev@dark.fi>"]
|
||||
license = "AGPL-3.0-only"
|
||||
@@ -15,7 +15,7 @@ categories = []
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
darkfi = {path = "../../", features = ["rpc"]}
|
||||
darkfi = {path = "../../../", features = ["rpc"]}
|
||||
|
||||
|
||||
# Async
|
||||
@@ -16,7 +16,7 @@
|
||||
#inbound = ["tls://127.0.0.1:24331"]
|
||||
|
||||
## Connection slots
|
||||
outbound_connections=5
|
||||
outbound_connections=8
|
||||
|
||||
## P2P external addresses
|
||||
#external_addr = ["tls://127.0.0.1:24331"]
|
||||
@@ -25,7 +25,7 @@ outbound_connections=5
|
||||
#peers = ["tls://127.0.0.1:24331"]
|
||||
|
||||
## Seed nodes to connect to
|
||||
seeds = ["tls://wiki0.dark.fi:24331", "tls://wiki1.dark.fi:24331"]
|
||||
seeds = ["tls://lilith0.dark.fi:24331", "tls://lilith1.dark.fi:24331"]
|
||||
|
||||
# Prefered transports for outbound connections
|
||||
#transports = ["tls", "tcp"]
|
||||
@@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "darkwikid"
|
||||
description = ""
|
||||
version = "0.3.0"
|
||||
version = "0.4.0"
|
||||
edition = "2021"
|
||||
authors = ["darkfi <dev@dark.fi>"]
|
||||
license = "AGPL-3.0-only"
|
||||
@@ -13,7 +13,7 @@ categories = []
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
darkfi = {path = "../../", features = ["raft", "net", "rpc"]}
|
||||
darkfi = {path = "../../../", features = ["raft", "net", "rpc"]}
|
||||
|
||||
|
||||
# Async
|
||||
@@ -48,7 +48,7 @@ use patch::{OpMethod, Patch};
|
||||
type Patches = (Vec<Patch>, Vec<Patch>, Vec<Patch>, Vec<Patch>);
|
||||
|
||||
pub const CONFIG_FILE: &str = "darkwiki.toml";
|
||||
pub const CONFIG_FILE_CONTENTS: &str = include_str!("../darkwiki.toml");
|
||||
pub const CONFIG_FILE_CONTENTS: &str = include_str!("../../darkwiki.toml");
|
||||
|
||||
/// darkwikid cli
|
||||
#[derive(Clone, Debug, Deserialize, StructOpt, StructOptToml)]
|
||||
@@ -225,8 +225,9 @@ impl Darkwiki {
|
||||
}
|
||||
patch = self.raft.1.recv().fuse() => {
|
||||
for (workspace, salsa_box) in self.workspaces.iter() {
|
||||
if let Ok(patch) = decrypt_patch(&patch.clone()?, &salsa_box) {
|
||||
if let Ok(mut patch) = decrypt_patch(&patch.clone()?, &salsa_box) {
|
||||
info!("[{}] Receive a {:?}", workspace, patch);
|
||||
patch.workspace = workspace.clone();
|
||||
self.on_receive_patch(&patch)?;
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
# Darkwiki
|
||||
|
||||
see [Darkfi Book](https://darkrenaissance.github.io/darkfi/misc/darkwiki.html) for the installation guide.
|
||||
@@ -309,7 +309,7 @@ impl UMsgs {
|
||||
|
||||
pub async fn insert(&self, msg: &Privmsg) -> String {
|
||||
let mut hasher = Ripemd160::new();
|
||||
hasher.update(msg.to_string() + &msg.term.to_string());
|
||||
hasher.update(msg.to_string() + &msg.term.to_string() + &msg.timestamp.to_string());
|
||||
let key = hex::encode(hasher.finalize());
|
||||
|
||||
let msgs = &mut self.msgs.lock().await;
|
||||
|
||||
@@ -83,7 +83,7 @@ impl<C: AsyncRead + AsyncWrite + Send + Unpin + 'static> IrcClient<C> {
|
||||
}
|
||||
|
||||
pub async fn process_msg(&mut self, msg: &Privmsg) -> Result<()> {
|
||||
info!("[P2P] Received: {}", msg.to_string().trim());
|
||||
info!("[P2P] Received: {:?}", msg);
|
||||
|
||||
let mut msg = msg.clone();
|
||||
let mut contact = String::new();
|
||||
@@ -484,7 +484,7 @@ impl<C: AsyncRead + AsyncWrite + Send + Unpin + 'static> IrcClient<C> {
|
||||
.notify_with_exclude(privmsg.clone(), &[self.subscription.get_id()])
|
||||
.await;
|
||||
|
||||
info!("[P2P] Broadcast: {:?}", privmsg.to_string().trim());
|
||||
info!("[P2P] Broadcast: {:?}", privmsg);
|
||||
self.p2p.broadcast(privmsg).await?;
|
||||
|
||||
Ok(())
|
||||
|
||||
@@ -36,11 +36,12 @@ impl Inv {
|
||||
#[derive(SerialDecodable, SerialEncodable, Clone, Debug)]
|
||||
struct GetData {
|
||||
invs: Vec<InvObject>,
|
||||
term: Option<u64>,
|
||||
}
|
||||
|
||||
impl GetData {
|
||||
fn new(invs: Vec<InvObject>) -> Self {
|
||||
Self { invs }
|
||||
fn new(invs: Vec<InvObject>, term: Option<u64>) -> Self {
|
||||
Self { invs, term }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,7 +119,7 @@ impl ProtocolPrivmsg {
|
||||
}
|
||||
|
||||
if !inv_requested.is_empty() {
|
||||
self.channel.send(GetData::new(inv_requested)).await?;
|
||||
self.channel.send(GetData::new(inv_requested, None)).await?;
|
||||
}
|
||||
|
||||
self.update_unread_msgs().await?;
|
||||
@@ -147,6 +148,7 @@ impl ProtocolPrivmsg {
|
||||
}
|
||||
|
||||
self.update_unread_msgs().await?;
|
||||
|
||||
self.p2p.broadcast_with_exclude(msg, &exclude_list).await?;
|
||||
}
|
||||
}
|
||||
@@ -160,12 +162,15 @@ impl ProtocolPrivmsg {
|
||||
self.update_unread_msgs().await?;
|
||||
|
||||
match self.buffers.privmsgs.last_term().await.cmp(&last_term) {
|
||||
Ordering::Less => {
|
||||
Ordering::Greater => {
|
||||
for msg in self.buffers.privmsgs.fetch_msgs(last_term).await {
|
||||
self.channel.send(msg).await?;
|
||||
}
|
||||
}
|
||||
Ordering::Greater | Ordering::Equal => continue,
|
||||
Ordering::Less => {
|
||||
self.channel.send(GetData::new(vec![], Some(last_term))).await?;
|
||||
}
|
||||
Ordering::Equal => continue,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -181,6 +186,12 @@ impl ProtocolPrivmsg {
|
||||
self.channel.send(msg.clone()).await?;
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(term) = getdata.term {
|
||||
for msg in self.buffers.privmsgs.fetch_msgs(term).await {
|
||||
self.channel.send(msg).await?;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,8 +206,9 @@ impl ProtocolPrivmsg {
|
||||
continue
|
||||
}
|
||||
if msg.read_confirms >= settings::MAX_CONFIRM {
|
||||
self.add_to_msgs(&msg).await?;
|
||||
self.buffers.unread_msgs.remove(&hash).await;
|
||||
if let Some(msg) = self.buffers.unread_msgs.remove(&hash).await {
|
||||
self.add_to_msgs(&msg).await?;
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
|
||||
@@ -15,7 +15,7 @@ pub const CONFIG_FILE_CONTENTS: &str = include_str!("../ircd_config.toml");
|
||||
|
||||
// Buffers and ordering configuration
|
||||
pub const SIZE_OF_MSGS_BUFFER: usize = 4095;
|
||||
pub const SIZE_OF_IDSS_BUFFER: usize = 16384;
|
||||
pub const SIZE_OF_IDSS_BUFFER: usize = 65536;
|
||||
pub const LIFETIME_FOR_ORPHAN: i64 = 600;
|
||||
pub const TERM_MAX_TIME_DIFFERENCE: i64 = 180;
|
||||
pub const BROADCAST_LAST_TERM_MSG: u64 = 4;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "tau"
|
||||
description = "Command-line client for taud"
|
||||
version = "0.3.0"
|
||||
version = "0.4.0"
|
||||
edition = "2021"
|
||||
authors = ["darkfi <dev@dark.fi>"]
|
||||
license = "AGPL-3.0-only"
|
||||
|
||||
@@ -210,7 +210,7 @@ async fn realmain(settings: Args, executor: Arc<Executor<'_>>) -> Result<()> {
|
||||
let workspaces = get_workspaces(&settings)?;
|
||||
|
||||
if workspaces.is_empty() {
|
||||
error!("Please add at least on workspace to the config file.");
|
||||
error!("Please add at least one workspace to the config file.");
|
||||
println!("Run `$ taud --generate` to generate new workspace.");
|
||||
return Ok(())
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#inbound = ["tcp://127.0.0.1:23331"]
|
||||
|
||||
## Connection slots
|
||||
outbound_connections=5
|
||||
outbound_connections=8
|
||||
|
||||
## P2P external addresses
|
||||
#external_addr = ["tls://127.0.0.1:23331"]
|
||||
@@ -25,7 +25,7 @@ outbound_connections=5
|
||||
#peers = ["tls://127.0.0.1:23331"]
|
||||
|
||||
## Seed nodes to connect to
|
||||
seeds=["tls://tau0.dark.fi:23331", "tls://tau1.dark.fi:23331"]
|
||||
seeds=["tls://lilith0.dark.fi:23331", "tls://lilith1.dark.fi:23331"]
|
||||
|
||||
# Prefered transports for outbound connections
|
||||
#transports = ["tls", "tcp"]
|
||||
|
||||
@@ -734,11 +734,107 @@
|
||||
"source": [
|
||||
"As observed we have a uniformizer $t$ with $k = 2$."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "a05bc126",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Valuation with Places\n",
|
||||
"\n",
|
||||
"Using sage valuation rings since local ring is a DVR"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"id": "3da404fc",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"[Place (x, y),\n",
|
||||
" Place (x + 3, y + 4),\n",
|
||||
" Place (x + 3, y + 7),\n",
|
||||
" Place (x + 5, y + 3),\n",
|
||||
" Place (x + 5, y + 8),\n",
|
||||
" Place (x + 7, y + 5),\n",
|
||||
" Place (x + 7, y + 6),\n",
|
||||
" Place (x + 9, y + 4),\n",
|
||||
" Place (x + 9, y + 7),\n",
|
||||
" Place (x + 10, y + 4),\n",
|
||||
" Place (x + 10, y + 7)]"
|
||||
]
|
||||
},
|
||||
"execution_count": 2,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"K.<x> = FunctionField(GF(11))\n",
|
||||
"_.<Y> = K[]\n",
|
||||
"L.<y> = K.extension(Y^2 - x^3 - 4*x)\n",
|
||||
"L.places_finite()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "e4719879",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"We are interested in $P = (2, 4)$ so we want the place $(x - 2, x - 4) = (x + 9, y + 7)$."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"id": "f87c8b23",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"Place (x + 9, y + 7)"
|
||||
]
|
||||
},
|
||||
"execution_count": 3,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# I don't know how to actually construct this yet\n",
|
||||
"p = L.places_finite()[-3]\n",
|
||||
"p"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"id": "3d007b0b",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"2"
|
||||
]
|
||||
},
|
||||
"execution_count": 4,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"(y - 2*x).valuation(p)"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "SageMath 9.6",
|
||||
"display_name": "SageMath 9.5",
|
||||
"language": "sage",
|
||||
"name": "sagemath"
|
||||
},
|
||||
@@ -752,7 +848,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.10.5"
|
||||
"version": "3.10.7"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::{any::Any, io, io::Cursor, sync::Arc};
|
||||
|
||||
use async_trait::async_trait;
|
||||
use fxhash::FxHashMap;
|
||||
use log::{debug, error, warn};
|
||||
use log::{debug, warn};
|
||||
use rand::Rng;
|
||||
|
||||
use crate::{
|
||||
@@ -143,7 +143,7 @@ impl<M: Message> MessageDispatcherInterface for MessageDispatcher<M> {
|
||||
self._trigger_all(message).await
|
||||
}
|
||||
Err(err) => {
|
||||
error!("Unable to decode data. Dropping...: {}", err);
|
||||
debug!("Unable to decode data. Dropping...: {}", err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ use std::fmt;
|
||||
use async_executor::Executor;
|
||||
use futures::{select, try_join, FutureExt};
|
||||
use fxhash::{FxHashMap, FxHashSet};
|
||||
use log::{debug, warn};
|
||||
use log::{debug, error, warn};
|
||||
use serde_json::json;
|
||||
use url::Url;
|
||||
|
||||
@@ -305,7 +305,13 @@ impl P2p {
|
||||
/// Broadcasts a message across all channels.
|
||||
pub async fn broadcast<M: Message + Clone>(&self, message: M) -> Result<()> {
|
||||
for channel in self.channels.lock().await.values() {
|
||||
channel.send(message.clone()).await?;
|
||||
if let Err(e) = channel.send(message.clone()).await {
|
||||
error!(
|
||||
"P2p::broadcast(): Broadcasting message to {} failed: {}",
|
||||
channel.address(),
|
||||
e
|
||||
);
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -98,12 +98,24 @@ impl ProtocolVersion {
|
||||
Some(app_version) => {
|
||||
debug!(target: "net", "ProtocolVersion::send_version() [App version: {}]", app_version);
|
||||
debug!(target: "net", "ProtocolVersion::send_version() [Recieved version: {}]", verack_msg.app);
|
||||
if app_version != &verack_msg.app {
|
||||
// Version format: MAJOR.MINOR.PATCH
|
||||
let app_versions: Vec<&str> = app_version.split('.').collect();
|
||||
let verack_msg_versions: Vec<&str> = verack_msg.app.split('.').collect();
|
||||
// Check for malformed versions
|
||||
if app_versions.len() != 3 || verack_msg_versions.len() != 3 {
|
||||
error!("ProtocolVersion::send_version() [Malformed version detected. Disconnecting from channel.]");
|
||||
self.hosts.remove(&self.channel.address()).await;
|
||||
self.channel.stop().await;
|
||||
return Err(Error::ChannelStopped)
|
||||
}
|
||||
// Ignore PATCH version
|
||||
if app_versions[0] != verack_msg_versions[0] ||
|
||||
app_versions[1] != verack_msg_versions[1]
|
||||
{
|
||||
error!(
|
||||
"Wrong app version from [{}]. Disconnecting from channel.",
|
||||
"ProtocolVersion::send_version() [Wrong app version from ({}). Disconnecting from channel.]",
|
||||
self.channel.address()
|
||||
);
|
||||
|
||||
self.hosts.remove(&self.channel.address()).await;
|
||||
self.channel.stop().await;
|
||||
return Err(Error::ChannelStopped)
|
||||
|
||||
@@ -24,7 +24,7 @@ impl Default for RaftSettings {
|
||||
heartbeat_timeout: 500,
|
||||
timeout: 6,
|
||||
id_timeout: 12,
|
||||
prun_duration: 240,
|
||||
prun_duration: 30,
|
||||
datastore_path: PathBuf::from(""),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,8 +168,13 @@ macro_rules! async_daemonize {
|
||||
let log_file_path = match std::env::var("DARKFI_LOG") {
|
||||
Ok(p) => p,
|
||||
Err(_) => {
|
||||
std::fs::create_dir_all(expand_path("~/.local")?)?;
|
||||
"~/.local/darkfi.log".into()
|
||||
let bin_name = if let Some(bin_name) = option_env!("CARGO_BIN_NAME") {
|
||||
bin_name
|
||||
} else {
|
||||
"darkfi"
|
||||
};
|
||||
std::fs::create_dir_all(expand_path("~/.local/darkfi")?)?;
|
||||
format!("~/.local/darkfi/{}.log", bin_name)
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user