Skip to content

Commit

Permalink
Merge branch 'development' into messaging-simplify-perf-reliability
Browse files Browse the repository at this point in the history
  • Loading branch information
sdbondi authored Jan 22, 2024
2 parents 6bf6e11 + f85608a commit d991c59
Show file tree
Hide file tree
Showing 15 changed files with 110 additions and 105 deletions.
15 changes: 3 additions & 12 deletions Cargo.lock

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

11 changes: 5 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ resolver = "2"
# specifying them in a single place and having them applied to all crates

# internal dependencies among workspace crates
libp2p-messaging = { path = "networking/libp2p-messaging"}
libp2p-peersync = { path = "networking/libp2p-peersync"}
libp2p-messaging = { path = "networking/libp2p-messaging" }
libp2p-peersync = { path = "networking/libp2p-peersync" }
libp2p-substream = { path = "networking/libp2p-substream" }
proto_builder = { path = "networking/proto_builder" }
sqlite_message_logger = { path = "networking/sqlite_message_logger" }
Expand Down Expand Up @@ -87,10 +87,10 @@ tari_rpc_framework = { path = "networking/rpc_framework" }
tari_rpc_macros = { path = "networking/rpc_macros" }
tari_state_store_sqlite = { path = "dan_layer/state_store_sqlite" }
tari_swarm = { path = "networking/swarm" }
tari_template_abi = { version="0.3.0", path = "dan_layer/template_abi" }
tari_template_abi = { version = "0.3.0", path = "dan_layer/template_abi" }
tari_template_builtin = { path = "dan_layer/template_builtin" }
tari_template_lib = { path = "dan_layer/template_lib" }
tari_template_macros = { version="0.3.0", path = "dan_layer/template_macros" }
tari_template_macros = { version = "0.3.0", path = "dan_layer/template_macros" }
tari_template_test_tooling = { path = "dan_layer/template_test_tooling" }
tari_transaction = { path = "dan_layer/transaction" }
tari_transaction_manifest = { path = "dan_layer/transaction_manifest" }
Expand Down Expand Up @@ -198,7 +198,6 @@ semver = "1.0"
serde = { version = "1.0", default-features = false }
serde_json = "1.0"
serde_with = "2.3"
serde-byte-array = "0.1.2"
sha2 = "0.10.8"
smallvec = "2.0.0-alpha.1"
std-semaphore = "0.1.0"
Expand All @@ -211,7 +210,7 @@ tokio-stream = "0.1.7"
tokio-util = "0.7.10"
tonic = "0.6.2"
tower = "0.4"
tower-http = { version = "0.3.5", default-features = false}
tower-http = { version = "0.3.5", default-features = false }
tower-layer = "0.3"
tracing = "0.1.40"
url = "2.4.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ function Committees({ committees, peerId }: { committees: CommitteeShardInfo[] |
<TableBody>
{committees.map((committee) => (
<Committee
key={committee.bucket}
begin={committee.shard_range.start}
end={committee.shard_range.end}
key={committee.shard}
begin={committee.substate_address_range.start}
end={committee.substate_address_range.end}
members={committee.validators}
peerId={peerId}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,23 @@ const MyChartComponent = ({ chartData }: MyChartComponentProps) => {

useEffect(() => {
const mappedTitles = chartData.committees.map((shardInfo) => {
return `${shardInfo.shard_range.start.slice(0, 6)}... - ${shardInfo.shard_range.end.slice(0, 6)}...`;
return `${shardInfo.substate_address_range.start.slice(0, 6)}... - ${shardInfo.substate_address_range.end.slice(
0,
6,
)}...`;
});
setTitles(mappedTitles);

const mappedContent = chartData.committees.reverse().map((shardInfo) => {
const data: any = {
value: shardInfo.validators.length,
name: `${shardInfo.shard_range.start.slice(0, 6)}... - ${shardInfo.shard_range.end.slice(0, 6)}...`,
name: `${shardInfo.substate_address_range.start.slice(0, 6)}... - ${shardInfo.substate_address_range.end.slice(
0,
6,
)}...`,
committee: shardInfo.validators,
link: `/committees/${shardInfo.shard_range.start},${shardInfo.shard_range.end}`,
range: `${shardInfo.shard_range.start}<br />${shardInfo.shard_range.end}`,
link: `/committees/${shardInfo.substate_address_range.start},${shardInfo.substate_address_range.end}`,
range: `${shardInfo.substate_address_range.start}<br />${shardInfo.substate_address_range.end}`,
};
return data;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ export default function CommitteesRadial({ committees }: { committees: GetNetwor
};

dataset.forEach((data: CommitteeShardInfo) => {
const start = fromHexString(data.shard_range.start)[0];
const end = fromHexString(data.shard_range.end)[0];
const start = fromHexString(data.substate_address_range.start)[0];
const end = fromHexString(data.substate_address_range.end)[0];

switch (true) {
case start === end:
Expand Down Expand Up @@ -86,7 +86,7 @@ export default function CommitteesRadial({ committees }: { committees: GetNetwor
}
});
setChartData(info);
const newTitles = dataset.map((info) => `Committee ${info.bucket}`);
const newTitles = dataset.map((info) => `Committee ${info.shard}`);
setTitles(newTitles);
}, [committees]);

Expand All @@ -95,7 +95,7 @@ export default function CommitteesRadial({ committees }: { committees: GetNetwor
const data = committees.committees[dataIndex];
const {
validators,
shard_range: { start, end },
substate_address_range: { start, end },
} = data;

const memberList = validators
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import { useState, useEffect } from "react";
import { fromHexString } from "../VN/Components/helpers";
import EChartsReact from "echarts-for-react";
import { ICommittees, ICommitteeChart, ICommitteeMap } from "../../utils/interfaces";
import { ICommitteeChart } from "../../utils/interfaces";
import "../../theme/echarts.css";
import { CommitteeShardInfo } from "../../utils/interfaces";

Expand Down Expand Up @@ -56,8 +56,8 @@ export default function CommitteesWaterfall({ committees }: { committees: Commit
};

committees.forEach((data) => {
const firstValue = fromHexString(data.shard_range.start)[0];
const secondValue = fromHexString(data.shard_range.end)[0];
const firstValue = fromHexString(data.substate_address_range.start)[0];
const secondValue = fromHexString(data.substate_address_range.end)[0];
switch (true) {
case firstValue === secondValue:
info.activeleft.push(0);
Expand Down Expand Up @@ -86,15 +86,15 @@ export default function CommitteesWaterfall({ committees }: { committees: Commit
});
setChartData(info);
setDivHeight(committees.length * 50);
const newTitles = committees.map((data) => `Committee ${data.bucket}`);
const newTitles = committees.map((data) => `Committee ${data.shard}`);
setTitles(newTitles);
}, [committees]);

function tooltipFormatter(params: any) {
const dataIndex = params[0].dataIndex;
const data = committees[dataIndex];
const begin = fromHexString(data.shard_range.start)[0];
const end = fromHexString(data.shard_range.end)[0];
const begin = fromHexString(data.substate_address_range.start)[0];
const end = fromHexString(data.substate_address_range.end)[0];

const memberList = data.validators
.map((member) => `<li>${member.address}</li>`)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ interface GetNetworkCommitteesResponse {
}

interface CommitteeShardInfo {
bucket: number;
shard_range: {
shard: number;
substate_address_range: {
end: string;
start: string;
};
Expand Down
13 changes: 5 additions & 8 deletions dan_layer/template_lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ tari_template_macros = { workspace = true, optional = true }
tari_bor = { workspace = true, default-features = false }

newtype-ops = { workspace = true }
serde = { workspace = true, default-features = false, features = ["derive", "alloc"] }
serde-byte-array = { workspace = true }
serde = { workspace = true, default-features = false, features = [
"derive",
"alloc",
] }
serde_with = { workspace = true }

[dev-dependencies]
serde_json = { workspace = true }
Expand All @@ -23,9 +26,3 @@ serde_json = { workspace = true }
default = ["macro", "std"]
macro = ["tari_template_macros"]
std = ["serde/std", "tari_bor/std"]

[package.metadata.cargo-machete]
ignored = [
# Used but not detectable by machete
"serde-byte-array",
]
4 changes: 3 additions & 1 deletion dan_layer/template_lib/src/crypto/balance_proof.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
// Copyright 2023 The Tari Project
// SPDX-License-Identifier: BSD-3-Clause
use serde::{Deserialize, Serialize};
use serde_with::{serde_as, Bytes};

use crate::crypto::InvalidByteLengthError;

/// The signature of a balance proof, used to validate the authorship of confidential transfers
#[serde_as]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(transparent)]
pub struct BalanceProofSignature(#[serde(with = "serde_byte_array")] [u8; BalanceProofSignature::length()]);
pub struct BalanceProofSignature(#[serde_as(as = "Bytes")] [u8; BalanceProofSignature::length()]);

impl BalanceProofSignature {
pub const fn length() -> usize {
Expand Down
4 changes: 3 additions & 1 deletion dan_layer/template_lib/src/crypto/commitment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
// SPDX-License-Identifier: BSD-3-Clause

use serde::{Deserialize, Serialize};
use serde_with::{serde_as, Bytes};
use tari_template_abi::rust::fmt::{Display, Formatter};

use crate::{crypto::InvalidByteLengthError, Hash};

/// A Pederson Commitment byte contents
#[serde_as]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Ord, PartialOrd, Hash, Default, Serialize, Deserialize)]
#[serde(transparent)]
pub struct PedersonCommitmentBytes(#[serde(with = "serde_byte_array")] [u8; PedersonCommitmentBytes::length()]);
pub struct PedersonCommitmentBytes(#[serde_as(as = "Bytes")] [u8; PedersonCommitmentBytes::length()]);

impl PedersonCommitmentBytes {
pub const fn length() -> usize {
Expand Down
4 changes: 3 additions & 1 deletion dan_layer/template_lib/src/crypto/ristretto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
// SPDX-License-Identifier: BSD-3-Clause

use serde::{Deserialize, Serialize};
use serde_with::{serde_as, Bytes};
use tari_template_abi::rust::fmt::{Display, Formatter};

use crate::{crypto::InvalidByteLengthError, models::NonFungibleAddress, Hash};

/// A Ristretto public key byte contents
#[serde_as]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)]
#[serde(transparent)]
pub struct RistrettoPublicKeyBytes(#[serde(with = "serde_byte_array")] [u8; RistrettoPublicKeyBytes::length()]);
pub struct RistrettoPublicKeyBytes(#[serde_as(as = "Bytes")] [u8; RistrettoPublicKeyBytes::length()]);

impl RistrettoPublicKeyBytes {
pub const fn length() -> usize {
Expand Down
4 changes: 3 additions & 1 deletion dan_layer/template_lib/src/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@ use std::{
};

use serde::{Deserialize, Serialize};
use serde_with::{serde_as, Bytes};

/// Representation of a 32-byte hash value
#[serde_as]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Ord, PartialOrd, Hash, Default, Serialize, Deserialize)]
#[serde(transparent)]
pub struct Hash([u8; 32]);
pub struct Hash(#[serde_as(as = "Bytes")] [u8; 32]);

impl Hash {
pub const fn from_array(bytes: [u8; 32]) -> Self {
Expand Down
7 changes: 5 additions & 2 deletions dan_layer/template_lib/src/models/confidential_proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: BSD-3-Clause

use serde::{Deserialize, Serialize};
use serde_with::{serde_as, Bytes};

use crate::{
crypto::{BalanceProofSignature, PedersonCommitmentBytes, RistrettoPublicKeyBytes},
Expand All @@ -21,9 +22,10 @@ pub struct ConfidentialOutputProof {
}

/// A zero-knowledge proof that a confidential resource amount is valid
#[serde_as]
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct ConfidentialStatement {
#[serde(with = "serde_byte_array")]
#[serde_as(as = "Bytes")]
pub commitment: [u8; 32],
/// Public nonce (R) that was used to generate the commitment mask
// #[cfg_attr(feature = "serde", serde(with = "hex::serde"))]
Expand All @@ -47,9 +49,10 @@ pub struct ConfidentialWithdrawProof {

/// Used by the receiver to determine the value component of the commitment, in both confidential transfers and Minotari
/// burns
#[serde_as]
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(transparent)]
pub struct EncryptedData(#[serde(with = "serde_byte_array")] pub [u8; EncryptedData::size()]);
pub struct EncryptedData(#[serde_as(as = "Bytes")] pub [u8; EncryptedData::size()]);

impl EncryptedData {
pub const fn size() -> usize {
Expand Down
4 changes: 3 additions & 1 deletion dan_layer/template_lib/src/models/non_fungible.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: BSD-3-Clause

use serde::{de::DeserializeOwned, Deserialize, Serialize};
use serde_with::{serde_as, Bytes};
use tari_bor::BorTag;
use tari_template_abi::{
call_engine,
Expand All @@ -22,9 +23,10 @@ use crate::{
const DELIM: char = ':';

/// The unique identification of a non-fungible token inside it's parent resource
#[serde_as]
#[derive(Debug, Clone, Ord, PartialOrd, PartialEq, Eq, Serialize, Deserialize, Hash)]
pub enum NonFungibleId {
U256(#[serde(with = "serde_byte_array")] [u8; 32]),
U256(#[serde_as(as = "Bytes")] [u8; 32]),
String(String),
Uint32(u32),
Uint64(u64),
Expand Down
Loading

0 comments on commit d991c59

Please sign in to comment.