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

feat: standardize output hash for unblinded output, transaction output and transaction input #3592

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 4 additions & 2 deletions applications/tari_app_grpc/src/conversions/output_features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

use crate::tari_rpc as grpc;
use std::convert::TryFrom;
use tari_core::transactions::transaction::{OutputFeatures, OutputFlags};

use tari_core::transactions::transaction_entities::{OutputFeatures, OutputFlags};

use crate::tari_rpc as grpc;

impl TryFrom<grpc::OutputFeatures> for OutputFeatures {
type Error = String;
Expand Down
6 changes: 4 additions & 2 deletions applications/tari_app_grpc/src/conversions/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

use crate::tari_rpc as grpc;
use std::convert::{TryFrom, TryInto};

use tari_common_types::transaction::{self as tx, TxId};
use tari_core::{
crypto::{ristretto::RistrettoSecretKey, tari_utilities::ByteArray},
transactions::transaction::Transaction,
transactions::transaction_entities::Transaction,
};

use crate::tari_rpc as grpc;

impl From<Transaction> for grpc::Transaction {
fn from(source: Transaction) -> Self {
Self {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
use crate::tari_rpc as grpc;
use std::convert::{TryFrom, TryInto};
use tari_common_types::types::{Commitment, PublicKey};
use tari_core::transactions::transaction::TransactionInput;
use tari_core::transactions::transaction_entities::TransactionInput;
use tari_crypto::{
script::{ExecutionStack, TariScript},
tari_utilities::{ByteArray, Hashable},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,17 @@
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

use crate::tari_rpc as grpc;
use std::convert::{TryFrom, TryInto};

use tari_crypto::tari_utilities::{ByteArray, Hashable};

use tari_common_types::types::Commitment;
use tari_core::transactions::{
tari_amount::MicroTari,
transaction::{KernelFeatures, TransactionKernel},
transaction_entities::{KernelFeatures, TransactionKernel},
};
use tari_crypto::tari_utilities::{ByteArray, Hashable};

use crate::tari_rpc as grpc;

impl TryFrom<grpc::TransactionKernel> for TransactionKernel {
type Error = String;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,19 @@
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

use crate::tari_rpc as grpc;
use std::convert::{TryFrom, TryInto};

use tari_common_types::types::{BulletRangeProof, Commitment, PublicKey};
use tari_core::{
crypto::{
script::TariScript,
tari_utilities::{ByteArray, Hashable},
},
transactions::transaction::TransactionOutput,
transactions::transaction_entities::TransactionOutput,
};

use crate::tari_rpc as grpc;

impl TryFrom<grpc::TransactionOutput> for TransactionOutput {
type Error = String;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use tari_core::{
script::{ExecutionStack, TariScript},
tari_utilities::ByteArray,
},
transactions::{tari_amount::MicroTari, transaction::UnblindedOutput},
transactions::{tari_amount::MicroTari, transaction_entities::UnblindedOutput},
};

impl From<UnblindedOutput> for grpc::UnblindedOutput {
Expand Down
69 changes: 36 additions & 33 deletions applications/tari_base_node/src/grpc/base_node_grpc_server.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,39 @@
use std::{
cmp,
convert::{TryFrom, TryInto},
};

use either::Either;
use futures::{channel::mpsc, SinkExt};
use log::*;
use tari_crypto::tari_utilities::{message_format::MessageFormat, Hashable};
use tokio::task;
use tonic::{Request, Response, Status};

use tari_app_grpc::{
tari_rpc,
tari_rpc::{CalcType, Sorting},
};
use tari_app_utilities::consts;
use tari_common_types::types::Signature;
use tari_comms::{Bytes, CommsNode};
use tari_core::{
base_node::{
comms_interface::{Broadcast, CommsInterfaceError},
LocalNodeCommsInterface,
StateMachineHandle,
},
blocks::{Block, BlockHeader, NewBlockTemplate},
chain_storage::ChainStorageError,
consensus::{emission::Emission, ConsensusManager, NetworkConsensus},
crypto::tari_utilities::{hex::Hex, ByteArray},
iterators::NonOverlappingIntegerPairIter,
mempool::{service::LocalMempoolService, TxStorageResponse},
proof_of_work::PowAlgorithm,
transactions::transaction_entities::Transaction,
};
use tari_p2p::{auto_update::SoftwareUpdaterHandle, services::liveness::LivenessHandle};

// Copyright 2019. The Tari Project
//
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
Expand Down Expand Up @@ -26,39 +62,6 @@ use crate::{
helpers::{mean, median},
},
};
use either::Either;
use futures::{channel::mpsc, SinkExt};
use log::*;
use std::{
cmp,
convert::{TryFrom, TryInto},
};
use tari_app_grpc::{
tari_rpc,
tari_rpc::{CalcType, Sorting},
};
use tari_app_utilities::consts;
use tari_common_types::types::Signature;
use tari_comms::{Bytes, CommsNode};
use tari_core::{
base_node::{
comms_interface::{Broadcast, CommsInterfaceError},
LocalNodeCommsInterface,
StateMachineHandle,
},
blocks::{Block, BlockHeader, NewBlockTemplate},
chain_storage::ChainStorageError,
consensus::{emission::Emission, ConsensusManager, NetworkConsensus},
crypto::tari_utilities::{hex::Hex, ByteArray},
iterators::NonOverlappingIntegerPairIter,
mempool::{service::LocalMempoolService, TxStorageResponse},
proof_of_work::PowAlgorithm,
transactions::transaction::Transaction,
};
use tari_crypto::tari_utilities::{message_format::MessageFormat, Hashable};
use tari_p2p::{auto_update::SoftwareUpdaterHandle, services::liveness::LivenessHandle};
use tokio::task;
use tonic::{Request, Response, Status};

const LOG_TARGET: &str = "tari::base_node::grpc";
const GET_TOKENS_IN_CIRCULATION_MAX_HEIGHTS: usize = 1_000_000;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ use tari_core::{
tari_utilities::hex::Hex,
transactions::{
tari_amount::{uT, MicroTari, Tari},
transaction::{TransactionOutput, UnblindedOutput},
transaction_entities::{TransactionOutput, UnblindedOutput},
},
};
use tari_wallet::{
Expand Down
7 changes: 4 additions & 3 deletions applications/tari_console_wallet/src/automation/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,22 @@
use std::num::{ParseFloatError, ParseIntError};

use log::*;
use thiserror::Error;
use tokio::task::JoinError;

use tari_common::exit_codes::ExitCodes;
use tari_core::{
tari_utilities::hex::HexError,
transactions::{
tari_amount::{MicroTariError, TariConversionError},
transaction::TransactionError,
transaction_entities::TransactionError,
},
};
use tari_wallet::{
error::{WalletError, WalletStorageError},
output_manager_service::error::OutputManagerError,
transaction_service::error::TransactionServiceError,
};
use thiserror::Error;
use tokio::task::JoinError;

pub const LOG_TARGET: &str = "wallet::automation::error";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ use tari_common_types::types::{BlockHash, Signature};
use tari_comms::{types::CommsPublicKey, CommsNode};
use tari_core::{
tari_utilities::{hex::Hex, ByteArray},
transactions::{tari_amount::MicroTari, transaction::UnblindedOutput},
transactions::{tari_amount::MicroTari, transaction_entities::UnblindedOutput},
};
use tari_crypto::tari_utilities::Hashable;
use tari_wallet::{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

use crate::error::MmProxyError;
use std::convert::TryFrom;

use tari_app_grpc::tari_rpc as grpc;
use tari_core::{
blocks::NewBlockTemplate,
transactions::transaction::{TransactionKernel, TransactionOutput},
transactions::transaction_entities::{TransactionKernel, TransactionOutput},
};

use crate::error::MmProxyError;

pub fn add_coinbase(
coinbase: grpc::Transaction,
block_template: grpc::NewBlockTemplate,
Expand Down
6 changes: 4 additions & 2 deletions applications/tari_stratum_transcoder/src/common/mining.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

use crate::error::StratumTranscoderProxyError;
use std::convert::TryFrom;

use tari_app_grpc::tari_rpc as grpc;
use tari_core::{
blocks::NewBlockTemplate,
transactions::transaction::{TransactionKernel, TransactionOutput},
transactions::transaction_entities::{TransactionKernel, TransactionOutput},
};

use crate::error::StratumTranscoderProxyError;

pub fn add_coinbase(
coinbase: Option<grpc::Transaction>,
mut block: NewBlockTemplate,
Expand Down
5 changes: 2 additions & 3 deletions applications/test_faucet/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,16 @@
use std::{fs::File, io::Write};

use serde::Serialize;
use tari_crypto::script;
use tari_crypto::{script, tari_utilities::hex::Hex};
use tokio::{sync::mpsc, task};

use tari_common_types::types::{Commitment, PrivateKey};
use tari_core::transactions::{
tari_amount::{MicroTari, T},
test_helpers,
transaction::{KernelFeatures, OutputFeatures, TransactionKernel, TransactionOutput},
transaction_entities::{KernelFeatures, OutputFeatures, TransactionKernel, TransactionOutput},
CryptoFactories,
};
use tari_crypto::tari_utilities::hex::Hex;

const NUM_KEYS: usize = 4000;

Expand Down
14 changes: 10 additions & 4 deletions base_layer/core/src/base_node/comms_interface/comms_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,20 @@
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

use std::fmt::{self, Display, Formatter};

use serde::{Deserialize, Serialize};

use tari_common_types::{chain_metadata::ChainMetadata, types::HashOutput};

use crate::{
blocks::{Block, BlockHeader, ChainHeader, HistoricalBlock, NewBlockTemplate},
proof_of_work::Difficulty,
transactions::transaction::{TransactionKernel, TransactionOutput},
transactions::transaction_entities::{
transaction_kernel::TransactionKernel,
transaction_output::TransactionOutput,
},
};
use serde::{Deserialize, Serialize};
use std::fmt::{self, Display, Formatter};
use tari_common_types::{chain_metadata::ChainMetadata, types::HashOutput};

/// API Response enum
#[derive(Debug, Serialize, Deserialize, Clone)]
Expand Down
25 changes: 14 additions & 11 deletions base_layer/core/src/base_node/comms_interface/inbound_handlers.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
use std::{
fmt::{Display, Error, Formatter},
sync::Arc,
};

use log::*;
use strum_macros::Display;
use tari_crypto::tari_utilities::{hash::Hashable, hex::Hex};
use tokio::sync::Semaphore;

use tari_common_types::types::{BlockHash, HashOutput};
use tari_comms::peer_manager::NodeId;

// Copyright 2019. The Tari Project
//
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
Expand Down Expand Up @@ -32,18 +45,8 @@ use crate::{
consensus::{ConsensusConstants, ConsensusManager},
mempool::{async_mempool, Mempool},
proof_of_work::{Difficulty, PowAlgorithm},
transactions::transaction::TransactionKernel,
};
use log::*;
use std::{
fmt::{Display, Error, Formatter},
sync::Arc,
transactions::transaction_entities::transaction_kernel::TransactionKernel,
};
use strum_macros::Display;
use tari_common_types::types::{BlockHash, HashOutput};
use tari_comms::peer_manager::NodeId;
use tari_crypto::tari_utilities::{hash::Hashable, hex::Hex};
use tokio::sync::Semaphore;

const LOG_TARGET: &str = "c::bn::comms_interface::inbound_handler";
const MAX_HEADERS_PER_RESPONSE: u32 = 100;
Expand Down
28 changes: 16 additions & 12 deletions base_layer/core/src/base_node/comms_interface/local_interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,35 @@
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

use std::{ops::RangeInclusive, sync::Arc};

use tokio::sync::broadcast;

use tari_common_types::{
chain_metadata::ChainMetadata,
types::{BlockHash, Commitment, HashOutput, Signature},
};
use tari_service_framework::{reply_channel::SenderService, Service};

use crate::{
base_node::comms_interface::{
comms_request::GetNewBlockTemplateRequest,
error::CommsInterfaceError,
BlockEvent,
Broadcast,
NodeCommsRequest,
NodeCommsResponse,
},
blocks::{Block, HistoricalBlock, NewBlockTemplate},
blocks::{Block, ChainHeader, HistoricalBlock, NewBlockTemplate},
proof_of_work::PowAlgorithm,
transactions::transaction::TransactionKernel,
transactions::transaction_entities::{
transaction_kernel::TransactionKernel,
transaction_output::TransactionOutput,
},
};
use std::{ops::RangeInclusive, sync::Arc};
use tari_common_types::{chain_metadata::ChainMetadata, types::BlockHash};
use tari_service_framework::{reply_channel::SenderService, Service};
use tokio::sync::broadcast;

pub type BlockEventSender = broadcast::Sender<Arc<BlockEvent>>;
pub type BlockEventReceiver = broadcast::Receiver<Arc<BlockEvent>>;
use crate::{
base_node::comms_interface::comms_request::GetNewBlockTemplateRequest,
blocks::ChainHeader,
transactions::transaction::TransactionOutput,
};
use tari_common_types::types::{Commitment, HashOutput, Signature};

/// The InboundNodeCommsInterface provides an interface to request information from the current local node by other
/// internal services.
Expand Down
Loading