Skip to content
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

v1.14.0 #92

Merged
merged 22 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
41a52be
misc: double space fix
Slixe Aug 23, 2024
a6b7d70
daemon: support page filter for list_assets, list_peers, list_miners
Slixe Aug 23, 2024
f9b2d37
common: impl serializer for ipaddr
Slixe Aug 23, 2024
6681da9
daemon: rework p2p peerlist, create a DB file instead of json file in…
Slixe Aug 24, 2024
6b45ad8
daemon: peerlist entry rename
Slixe Aug 24, 2024
379a472
daemon: don't keep Peer instance in chain sync
Slixe Aug 25, 2024
eaddd4e
daemon: support empty/no page
Slixe Aug 25, 2024
02b0e1b
wallet: support optional directory feature (anonymous browsing) for w…
Slixe Aug 27, 2024
b3a15cc
wallet: add clear_tx_cache cli command
Slixe Aug 28, 2024
8068d8d
wallet: fix force_stable_balance option
Slixe Aug 30, 2024
69bda6e
daemon: add get_pruned_topoheight rpc method
Slixe Aug 30, 2024
b864fac
misc: add get_pruned_topoheight in API.md
Slixe Aug 30, 2024
cb9b30c
wallet: prevent lose of history on rescan with pruned chain
Slixe Aug 30, 2024
f954b76
misc: rename incorrect rpc method name
Slixe Aug 30, 2024
74c98fa
common: network info, get_target from rpc client
Slixe Sep 2, 2024
759ad4d
wallet: rpc method network_info
Slixe Sep 2, 2024
64bf627
common: lagged i
Slixe Sep 2, 2024
756805d
wallet: improve balances debug logs
Slixe Sep 2, 2024
563922a
misc: add network_info rpc method in API.md
Slixe Sep 2, 2024
fa458b3
wallet: delete transactions at or above topoheight
Slixe Sep 2, 2024
3b6a855
all: set version to 1.14.0
Slixe Sep 2, 2024
189faa7
misc: add v1.14.0 in changelog
Slixe Sep 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ target/
mainnet/
testnet/
dev/
peerlist-*/
.vscode/
wallets/
peerlist-*.json
Expand Down
72 changes: 71 additions & 1 deletion API.md
Original file line number Diff line number Diff line change
Expand Up @@ -3158,6 +3158,33 @@ No parameters
}
```

#### Get Pruned Topo Height
Retrieve the pruned topoheight if the node has a pruned chain.
Otherwise, returns `null` as value.

##### Method `get_pruned_topoheight`

##### Parameters
No parameters

##### Request
```json
{
"jsonrpc": "2.0",
"method": "get_pruned_topoheight",
"id": 1
}
```

##### Response
```json
{
"id": 1,
"jsonrpc": "2.0",
"result": null
}
```

#### Get Stable Height
Retrieve current stable height of the chain.

Expand Down Expand Up @@ -11135,7 +11162,6 @@ Returned fees are in atomic units.
}
```


#### Is Online
Determine if the wallet is connected to a node or not (offline / online mode).

Expand All @@ -11162,6 +11188,50 @@ No parameter
}
```

#### Network Info
Fetch all information about the current node to which the wallet is connected to.

##### Method `network_info`

##### Parameters
No parameter

##### Request
```json
{
"jsonrpc": "2.0",
"method": "network_info",
"id": 1
}
```

##### Response
```json
{
"id": 1,
"jsonrpc": "2.0",
"result": {
"average_block_time": 15954,
"block_reward": 137924147,
"block_time_target": 15000,
"circulating_supply": 104512595148870,
"connected_to": "ws://127.0.0.1:8080/json_rpc",
"dev_reward": 13792414,
"difficulty": "107844053400",
"height": 725025,
"maximum_supply": 1840000000000000,
"mempool_size": 0,
"miner_reward": 124131733,
"network": "Mainnet",
"pruned_topoheight": null,
"stableheight": 725017,
"top_block_hash": "1914802b64b28386adc37927081beb6ac4677b6f85ee2149f7a143339c99d309",
"topoheight": 761761,
"version": "1.13.4-d33986a"
}
}
```

### Storage

XELIS Wallet has the ability to have a built-in encrypted DB that can be used to store / fetch entries easily.
Expand Down
25 changes: 24 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,32 @@
# Changelog

This file contains all the changelogs to ensure that changes can be tracked and to provide a summary for interested parties.
This file contains all the changelogs to ensure that changes can be tracked and to provide a summary for interested parties.

To see the full history and exact changes, please refer to the commits history directly.

## v1.14.0

Moving to 1.14.0 due to breaking changes in peerlist storage.

Common:
- add new struct for `network_info` rpc method
- clean up in ws json rpc client

Daemon:
- add `get_pruned_topoheight` rpc method
- P2P peerlist is now backed by a DB instead of a traditional JSON file. (Reduce memory usage, and better I/O operations)
- add `show_peerlist` cli command
- paginate few CLI commands
- don't keep Peer instance in chain sync task, but its priority flag & id only.

Wallet:
- `network_info` rpc method added
- fix `force-stable-balance` CLI option
- add `clear_tx_cache` cli command
- fix blockDAG reorg resync of transactions
- support anonymous browsing for web wallet (no access to directory feature)


## v1.13.4

Bug fixes for nodes with less than 2GB of ram, and for nodes having reorg issues.
Expand Down
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion xelis_common/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "xelis_common"
version = "1.13.4"
version = "1.14.0"
edition = "2021"
authors = ["Slixe <slixeprivate@gmail.com>"]
build = "build.rs"
Expand Down
10 changes: 9 additions & 1 deletion xelis_common/src/api/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ use super::{
DataValue,
query::Query,
default_false_value,
default_true_value
default_true_value,
daemon
};

#[derive(Serialize, Deserialize)]
Expand Down Expand Up @@ -116,6 +117,13 @@ pub struct SetOnlineModeParams {
pub auto_reconnect: bool,
}

#[derive(Serialize, Deserialize)]
pub struct NetworkInfoResult {
#[serde(flatten)]
pub inner: daemon::GetInfoResult,
pub connected_to: String,
}

#[derive(Serialize, Deserialize)]
pub struct GetBalanceParams {
pub asset: Option<Hash>
Expand Down
21 changes: 11 additions & 10 deletions xelis_common/src/json_rpc/websocket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ impl<T: DeserializeOwned> EventReceiver<T> {
// If we lagged behind, we need to catch up
while let Err(e) = res {
match e {
broadcast::error::RecvError::Lagged(_) => {
error!("EventReceiver lagged behind, catching up...");
broadcast::error::RecvError::Lagged(i) => {
error!("EventReceiver lagged {i} behind, catching up...");
res = self.inner.recv().await;
}
e => return Err(e.into())
Expand Down Expand Up @@ -114,15 +114,11 @@ pub struct WebSocketJsonRPCClientImpl<E: Serialize + Hash + Eq + Send + Sync + C
pub const DEFAULT_AUTO_RECONNECT: Duration = Duration::from_secs(5);

impl<E: Serialize + Hash + Eq + Send + Sync + Clone + std::fmt::Debug + 'static> WebSocketJsonRPCClientImpl<E> {
async fn connect_to(target: &String) -> Result<WebSocketStream, JsonRPCError> {
let ws = connect(target).await?;

Ok(ws)
}

// Create a new WebSocketJsonRPCClient with the target address
pub async fn new(mut target: String) -> Result<WebSocketJsonRPCClient<E>, JsonRPCError> {
target = sanitize_daemon_address(target.as_str());
let ws = Self::connect_to(&target).await?;
let ws = connect(&target).await?;

let (sender, receiver) = mpsc::channel(64);
let client = Arc::new(WebSocketJsonRPCClientImpl {
Expand All @@ -149,6 +145,11 @@ impl<E: Serialize + Hash + Eq + Send + Sync + Clone + std::fmt::Debug + 'static>
Ok(client)
}

// Get the target address
pub fn get_target(&self) -> &str {
&self.target
}

// Generate a new ID for a JSON-RPC request
fn next_id(&self) -> usize {
self.count.fetch_add(1, Ordering::SeqCst)
Expand Down Expand Up @@ -280,7 +281,7 @@ impl<E: Serialize + Hash + Eq + Send + Sync + Clone + std::fmt::Debug + 'static>
return Ok(false)
}

let ws = Self::connect_to(&self.target).await?;
let ws = connect(&self.target).await?;
{
let mut lock = self.background_task.lock().await;
if let Some(handle) = lock.take() {
Expand Down Expand Up @@ -359,7 +360,7 @@ impl<E: Serialize + Hash + Eq + Send + Sync + Clone + std::fmt::Debug + 'static>
debug!("Reconnecting to the server in {} seconds...", auto_reconnect.as_secs());
sleep(auto_reconnect).await;

match Self::connect_to(&zelf.target).await {
match connect(&zelf.target).await {
Ok(websocket) => {
ws = Some(websocket);

Expand Down
69 changes: 41 additions & 28 deletions xelis_common/src/serializer/defaults.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,39 +378,13 @@ impl<const N: usize> Serializer for [u8; N] {

impl Serializer for SocketAddr {
fn read(reader: &mut Reader) -> Result<Self, ReaderError> {
let is_v6 = reader.read_bool()?;
let ip: IpAddr = if !is_v6 {
let a = reader.read_u8()?;
let b = reader.read_u8()?;
let c = reader.read_u8()?;
let d = reader.read_u8()?;
IpAddr::V4(Ipv4Addr::new(a, b, c, d))
} else {
let a = reader.read_u16()?;
let b = reader.read_u16()?;
let c = reader.read_u16()?;
let d = reader.read_u16()?;
let e = reader.read_u16()?;
let f = reader.read_u16()?;
let g = reader.read_u16()?;
let h = reader.read_u16()?;
IpAddr::V6(Ipv6Addr::new(a, b, c, d, e, f, g, h))
};
let ip = IpAddr::read(reader)?;
let port = reader.read_u16()?;
Ok(SocketAddr::new(ip, port))
}

fn write(&self, writer: &mut Writer) {
match self.ip() {
IpAddr::V4(addr) => {
writer.write_u8(0);
writer.write_bytes(&addr.octets());
},
IpAddr::V6(addr) => {
writer.write_u8(1);
writer.write_bytes(&addr.octets());
}
};
self.ip().write(writer);
self.port().write(writer);
}

Expand All @@ -425,6 +399,45 @@ impl Serializer for SocketAddr {
}
}

impl Serializer for IpAddr {
fn read(reader: &mut Reader) -> Result<Self, ReaderError> {
match reader.read_u8()? {
0 => {
let a = reader.read_u8()?;
let b = reader.read_u8()?;
let c = reader.read_u8()?;
let d = reader.read_u8()?;
Ok(IpAddr::V4(Ipv4Addr::new(a, b, c, d)))
},
1 => {
let a = reader.read_u16()?;
let b = reader.read_u16()?;
let c = reader.read_u16()?;
let d = reader.read_u16()?;
let e = reader.read_u16()?;
let f = reader.read_u16()?;
let g = reader.read_u16()?;
let h = reader.read_u16()?;
Ok(IpAddr::V6(Ipv6Addr::new(a, b, c, d, e, f, g, h)))
},
_ => Err(ReaderError::InvalidValue)
}
}

fn write(&self, writer: &mut Writer) {
match self {
IpAddr::V4(addr) => {
writer.write_u8(0);
writer.write_bytes(&addr.octets());
},
IpAddr::V6(addr) => {
writer.write_u8(1);
writer.write_bytes(&addr.octets());
}
};
}
}

impl Serializer for () {
fn read(_reader: &mut Reader) -> Result<Self, ReaderError> {
Ok(())
Expand Down
2 changes: 1 addition & 1 deletion xelis_daemon/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "xelis_daemon"
version = "1.13.4"
version = "1.14.0"
edition = "2021"
authors = ["Slixe <slixeprivate@gmail.com>"]

Expand Down
Loading
Loading