add support tari-randomx

This commit is contained in:
lzx 2025-09-09 14:54:04 +08:00
parent 8cc56a489e
commit 917d7118e6
26 changed files with 14297 additions and 111 deletions

3
go.mod
View File

@ -6,15 +6,16 @@ toolchain go1.23.1
require (
github.com/btcsuite/btcd v0.24.2
github.com/golang/protobuf v1.5.4
github.com/zeromq/goczmq v4.1.0+incompatible
go.uber.org/zap v1.27.0
google.golang.org/protobuf v1.36.6
)
require (
golang.org/x/net v0.41.0 // indirect
golang.org/x/text v0.26.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250707201910-8d1bb00bc6a7 // indirect
google.golang.org/protobuf v1.36.6 // indirect
)
require (

View File

@ -41,10 +41,15 @@ pub struct Cli {
pub non_interactive_mode: bool,
#[clap(long, alias = "zmq-pub-port", default_value = "11113")]
zmq_pub_port: u16,
#[clap(long, alias = "zmq-sub-port", default_value = "11112")]
zmq_sub_port: u16,
/// Select ZMQ job algorithm: sha3x | randomxt. If omitted, defaults from config pow algo.
#[clap(long)]
pub zmq_algo: Option<String>,
/// Optional override for ZMQ publisher port (otherwise defaults by algorithm)
#[clap(long, alias = "zmq-pub-port")]
pub zmq_pub_port: Option<u16>,
/// Optional override for ZMQ subscriber port (otherwise defaults by algorithm)
#[clap(long, alias = "zmq-sub-port")]
pub zmq_sub_port: Option<u16>,
}
impl ConfigOverrideProvider for Cli {

View File

@ -27,7 +27,7 @@ use std::{
time::{Duration, Instant},
};
use chrono::Utc;
// use chrono::Utc;
use crossbeam::channel::{bounded, Select, Sender, TrySendError};
use futures::Stream;
use log::*;
@ -37,6 +37,7 @@ use tari_core::proof_of_work::randomx_factory::RandomXFactory;
use thread::JoinHandle;
use super::difficulty::BlockHeaderSha3;
use tari_utilities::hex::Hex;
use zmq::{Socket};
@ -87,6 +88,7 @@ pub struct Miner {
publisher_socket: Arc<Mutex<Socket>>,
subscriber_socket: Arc<Mutex<Socket>>,
base_node_client: BaseNodeGrpcClient,
zmq_algorithm: String,
}
impl Miner {
@ -100,6 +102,7 @@ impl Miner {
rx_factory: Option<RandomXFactory>,
publisher_socket: Arc<Mutex<Socket>>,
subscriber_socket: Arc<Mutex<Socket>>,
zmq_algorithm: String,
) -> Self {
Self {
threads: vec![],
@ -113,6 +116,7 @@ impl Miner {
publisher_socket,
subscriber_socket,
base_node_client,
zmq_algorithm,
}
}
@ -144,8 +148,9 @@ impl Miner {
let pub_socket = Arc::clone(&self.publisher_socket);
let sub_socket = Arc::clone(&self.subscriber_socket);
let base_node_client_clone = self.base_node_client.clone();
let zmq_algo = self.zmq_algorithm.clone();
let handle = thread
.spawn(move || mining_task(base_node_client_clone, header, difficulty, tx, waker, i, share_mode, vm_key, rx_factory, pub_socket, sub_socket))
.spawn(move || mining_task(base_node_client_clone, header, difficulty, tx, waker, i, share_mode, vm_key, rx_factory, pub_socket, sub_socket, zmq_algo))
.expect("Failed to create mining thread");
(handle, rx)
});
@ -214,6 +219,8 @@ pub struct GbtMsg {
pub height: u64,
pub header: String,
pub u64target: u64,
/// RandomXT需要的vm_keyhex字符串Sha3X可为空字符串
pub vmkey: String,
}
#[derive(Debug, Serialize, Deserialize)]
@ -230,18 +237,26 @@ pub struct SubmitRequest {
pub submitidx: u64,
}
fn send_gbt_message(socket: &Arc<Mutex<Socket>>, msg: &GbtMsg) -> Result<(), Box<dyn std::error::Error>> {
fn send_gbt_message(
socket: &Arc<Mutex<Socket>>,
msg: &GbtMsg,
algorithm: &str,
) -> Result<(), Box<dyn std::error::Error>> {
let msg_json = serde_json::to_string(msg)?;
let topic = match algorithm {
"randomxt" | "TariRandomXT" => "jobrandomxt",
_ => "jobsha3x",
};
if let Ok(pub_socket) = socket.try_lock() {
pub_socket.send_multipart(&["jobsha3x".as_bytes(), msg_json.as_bytes()], 0)?;
println!("send_gbt_message");
pub_socket.send_multipart(&[topic.as_bytes(), msg_json.as_bytes()], 0)?;
println!("send_gbt_message for {}", algorithm);
Ok(())
} else {
Err("Socket lock busy".into())
}
}
fn try_receive_nonce(socket: &Arc<Mutex<Socket>>) -> Option<u64> {
fn try_receive_nonce(socket: &Arc<Mutex<Socket>>, algorithm: &str) -> Option<u64> {
let sub_socket = match socket.try_lock() {
Ok(sub_socket) => sub_socket,
Err(_) => return None,
@ -267,7 +282,11 @@ fn try_receive_nonce(socket: &Arc<Mutex<Socket>>) -> Option<u64> {
//println!("First frame: {:?}", frames.first().unwrap().as_slice());
//println!("Nonce frame: {:?}", &frames[1]);
if frames.first().map(Vec::as_slice) != Some(b"blksha3x") {
let expected_topic = match algorithm {
"randomxt" | "TariRandomXT" => b"blkrandomxt".as_slice(),
_ => b"blksha3x".as_slice(),
};
if frames.first().map(Vec::as_slice) != Some(expected_topic) {
return None;
}
@ -296,6 +315,7 @@ pub fn mining_task(
rx_factory: Option<RandomXFactory>,
publisher_socket: Arc<Mutex<Socket>>,
subscriber_socket: Arc<Mutex<Socket>>,
zmq_algorithm: String,
) {
let mining_algorithm = if rx_factory.is_some() { "RandomXT" } else { "Sha3X" };
let start = Instant::now();
@ -316,10 +336,15 @@ pub fn mining_task(
height: hasher.header.height,
header: hasher.header.mining_hash().to_string(),
u64target: target_difficulty,
vmkey: if zmq_algorithm == "randomxt" || zmq_algorithm == "TariRandomXT" {
hasher.vm_key.to_hex()
} else {
String::new()
},
};
if let Err(e) = send_gbt_message(&publisher_socket, &gbt_msg) {
if let Err(e) = send_gbt_message(&publisher_socket, &gbt_msg, &zmq_algorithm) {
error!(
target: LOG_TARGET,
"Miner {} failed to send GBT message: {}", miner, e
@ -334,7 +359,7 @@ pub fn mining_task(
let mut check_count:u64 = 0;
// Mining work
loop {
if let Some(nonce) = try_receive_nonce(&subscriber_socket) {
if let Some(nonce) = try_receive_nonce(&subscriber_socket, &zmq_algorithm) {
check_count = 0;
hasher.header.nonce = nonce;
println!("nonce {} {}", nonce, hasher.header.nonce);

View File

@ -185,15 +185,28 @@ pub async fn start_miner(cli: Cli) -> Result<(), ExitError> {
return Err(ExitError::new(ExitCode::GrpcError, e.to_string()));
}
}
config.zmq_publisher_port = 11113;
config.zmq_subscriber_port = 11112;
println!("pub port:{}, sub port {}", config.zmq_publisher_port, config.zmq_subscriber_port);
// Decide ZMQ algorithm from CLI flag or pow algo
let zmq_algo = cli
.zmq_algo
.as_ref()
.map(|s| s.as_str())
.unwrap_or_else(|| if config.proof_of_work_algo == PowAlgorithm::RandomXT { "randomxt" } else { "sha3x" });
// Default ports per algorithm, allow CLI override (do not rely on config fields)
let (default_pub, default_sub) = if zmq_algo == "randomxt" {
(11114u16, 11115u16)
} else {
(11112u16, 11113u16)
};
let publisher_port = cli.zmq_pub_port.unwrap_or(default_pub);
let subscriber_port = cli.zmq_sub_port.unwrap_or(default_sub);
println!("Using ZMQ ({}) ports: pub port:{}, sub port {}", zmq_algo, publisher_port, subscriber_port);
let zmq_context = ZmqContext::new();
let publisher_socket = zmq_context
.socket(zmq::PUB)
.map_err(|e| anyhow!("ZMQ publisher error: {}", e))?;
let publisher_addr = format!("tcp://0.0.0.0:{}", config.zmq_publisher_port);
let publisher_addr = format!("tcp://0.0.0.0:{}", publisher_port);
println!("publisher_addr:{}",publisher_addr);
publisher_socket
.bind(&publisher_addr)
@ -202,7 +215,7 @@ pub async fn start_miner(cli: Cli) -> Result<(), ExitError> {
let subscriber_socket = zmq_context
.socket(SUB)
.context("Failed to create SUB socket")?;
let subscriber_addr = format!("tcp://172.17.0.1:{}", config.zmq_subscriber_port);
let subscriber_addr = format!("tcp://127.0.0.1:{}", subscriber_port);
println!("subscriber_addr:{}",subscriber_addr);
subscriber_socket
.connect(&subscriber_addr)
@ -602,6 +615,13 @@ async fn mining_cycle(
debug!(target: LOG_TARGET, "Initializing miner");
// Determine ZMQ algorithm for miner streams (sha3x | randomxt)
let zmq_algo = cli
.zmq_algo
.as_ref()
.map(|s| s.as_str())
.unwrap_or_else(|| if config.proof_of_work_algo == PowAlgorithm::RandomXT { "randomxt" } else { "sha3x" });
let rx_factory = if config.proof_of_work_algo == PowAlgorithm::RandomXT {
Some(RandomXFactory::new(config.num_mining_threads))
} else {
@ -618,6 +638,7 @@ async fn mining_cycle(
rx_factory,
publisher_socket,
subscriber_socket,
zmq_algo.to_string(),
);
let mut reporting_timeout = Instant::now();
let mut block_submitted = false;

View File

@ -75,6 +75,22 @@ type Sha3xStratumJob struct {
U64target uint64 `json:"u64target, omitempty"`
}
type RandomxTStratumJob struct {
Header string `json:"header, omitempty"`
NBits string `json:"nBits, omitempty"`
Id uint64 `json:"id, omitempty"`
CurTime uint64 `json:"timestamp, omitempty"`
Target string `json:"target, omitempty"`
Height uint32 `json:"height, omitempty"`
Nonce string `json:"nonce, omitempty"`
Extranonce1 string `json:"extranonce1, omitempty"`
Extranonce2_size uint64 `json:"extranonce2_size, omitempty"`
Extranonce2 string `json:"extranonce2, omitempty"`
JobDifficulty float64 `json:"diff, omitempty"`
U64target uint64 `json:"u64target, omitempty"`
SeedHash string `json:"seedhash, omitempty"`
}
type BlockSha3xMsg struct {
Id uint64 `json:"id"`
User string `json:"user"`

View File

@ -178,11 +178,11 @@ type ServerContext struct {
ExitDbPoolStats chan bool
NexaJob msg.NexaStratumJob
Sha3xJob msg.Sha3xStratumJob
MoneroJob msg.MoneroStratumJob
Tari_Sha3xJob msg.GbtSendMsg
ExitDiffVar chan bool
NexaJob msg.NexaStratumJob
Sha3xJob msg.Sha3xStratumJob
MoneroJob msg.MoneroStratumJob
RandomxTJob msg.RandomxTStratumJob
ExitDiffVar chan bool
RedisClient *redis.Client
@ -387,10 +387,10 @@ type MinerObj struct {
PongFailCnt int
PingCnt int
NexaJob msg.NexaStratumJob
Sha3xJob msg.Sha3xStratumJob
MoneroJob msg.MoneroStratumJob
Tari_Sha3xJob msg.GbtSendMsg
NexaJob msg.NexaStratumJob
Sha3xJob msg.Sha3xStratumJob
MoneroJob msg.MoneroStratumJob
RandomxTJob msg.RandomxTStratumJob
FromIP string

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,600 @@
// Copyright 2020. The Tari Project
//
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
// following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
// disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
// following disclaimer in the documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote
// products derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// 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.
syntax = "proto3";
import "types.proto";
import "transaction.proto";
import "block.proto";
import "network.proto";
import "sidechain_types.proto";
package tari.rpc;
// The gRPC interface for interacting with the base node.
service BaseNode {
// Lists headers in the current best chain
rpc ListHeaders(ListHeadersRequest) returns (stream BlockHeaderResponse);
// Get header by hash
rpc GetHeaderByHash(GetHeaderByHashRequest) returns (BlockHeaderResponse);
// Returns blocks in the current best chain. Currently only supports querying by height
rpc GetBlocks(GetBlocksRequest) returns (stream HistoricalBlock);
// Returns the block timing for the chain heights
rpc GetBlockTiming(HeightRequest) returns (BlockTimingResponse);
// Returns the network Constants
rpc GetConstants(BlockHeight) returns (ConsensusConstants);
// Returns Block Sizes
rpc GetBlockSize (BlockGroupRequest) returns (BlockGroupResponse);
// Returns Block Fees
rpc GetBlockFees (BlockGroupRequest) returns (BlockGroupResponse);
// Get Version
rpc GetVersion(Empty) returns (StringValue);
// Check for new updates
rpc CheckForUpdates(Empty) returns (SoftwareUpdate);
// Get coins in circulation
rpc GetTokensInCirculation(GetBlocksRequest) returns (stream ValueAtHeightResponse);
// Get network difficulties
rpc GetNetworkDifficulty(HeightRequest) returns (stream NetworkDifficultyResponse);
// Get the block template
rpc GetNewBlockTemplate(NewBlockTemplateRequest) returns (NewBlockTemplateResponse);
// Construct a new block from a provided template
rpc GetNewBlock(NewBlockTemplate) returns (GetNewBlockResult);
// Construct a new block from a provided template
rpc GetNewBlockWithCoinbases(GetNewBlockWithCoinbasesRequest) returns (GetNewBlockResult);
// Construct a new block from a provided template
rpc GetNewBlockTemplateWithCoinbases(GetNewBlockTemplateWithCoinbasesRequest) returns (GetNewBlockResult);
// Construct a new block and header blob from a provided template
rpc GetNewBlockBlob(NewBlockTemplate) returns (GetNewBlockBlobResult);
// Submit a new block for propagation
rpc SubmitBlock(Block) returns (SubmitBlockResponse);
// Submit a new mined block blob for propagation
rpc SubmitBlockBlob(BlockBlobRequest) returns (SubmitBlockResponse);
// Submit a transaction for propagation
rpc SubmitTransaction(SubmitTransactionRequest) returns (SubmitTransactionResponse);
// Get the base node sync information
rpc GetSyncInfo(Empty) returns (SyncInfoResponse);
// Get the base node sync information
rpc GetSyncProgress(Empty) returns (SyncProgressResponse);
// Get the base node tip information
rpc GetTipInfo(Empty) returns (TipInfoResponse);
// Search for blocks containing the specified kernels
rpc SearchKernels(SearchKernelsRequest) returns (stream HistoricalBlock);
// Search for blocks containing the specified commitments
rpc SearchUtxos(SearchUtxosRequest) returns (stream HistoricalBlock);
// Fetch any utxos that exist in the main chain
rpc FetchMatchingUtxos(FetchMatchingUtxosRequest) returns (stream FetchMatchingUtxosResponse);
// get all peers from the base node
rpc GetPeers(GetPeersRequest) returns (stream GetPeersResponse);
rpc GetMempoolTransactions(GetMempoolTransactionsRequest) returns (stream GetMempoolTransactionsResponse);
rpc TransactionState(TransactionStateRequest) returns (TransactionStateResponse);
// This returns the node's network identity
rpc Identify (Empty) returns (NodeIdentity);
// Get Base Node network connectivity status
rpc GetNetworkStatus(Empty) returns (NetworkStatusResponse);
// List currently connected peers
rpc ListConnectedPeers(Empty) returns (ListConnectedPeersResponse);
// Get mempool stats
rpc GetMempoolStats(Empty) returns (MempoolStatsResponse);
// Get VNs
rpc GetActiveValidatorNodes(GetActiveValidatorNodesRequest) returns (stream GetActiveValidatorNodesResponse);
rpc GetShardKey(GetShardKeyRequest) returns (GetShardKeyResponse);
// Get templates
rpc GetTemplateRegistrations(GetTemplateRegistrationsRequest) returns (stream GetTemplateRegistrationResponse);
rpc GetSideChainUtxos(GetSideChainUtxosRequest) returns (stream GetSideChainUtxosResponse);
rpc GetNetworkState(GetNetworkStateRequest) returns (GetNetworkStateResponse);
// PayRef (Payment Reference) lookup for block explorers and external services
rpc SearchPaymentReferences(SearchPaymentReferencesRequest) returns (stream PaymentReferenceResponse);
}
message GetAssetMetadataRequest {
bytes asset_public_key = 1;
}
message GetAssetMetadataResponse {
string name = 2;
string description =3;
string image = 4;
bytes owner_commitment = 5;
OutputFeatures features = 6;
uint64 mined_height = 7;
bytes mined_in_block = 8;
}
message ListAssetRegistrationsRequest {
uint64 offset = 2;
uint64 count = 3;
}
message ListAssetRegistrationsResponse {
bytes asset_public_key = 1;
bytes unique_id = 2;
bytes owner_commitment = 3;
uint64 mined_height = 4;
bytes mined_in_block = 5;
OutputFeatures features = 6;
bytes script = 7;
}
message GetTokensRequest {
bytes asset_public_key = 1;
// Optionally get a set of specific unique_ids
repeated bytes unique_ids = 2;
}
message GetTokensResponse {
bytes unique_id = 1;
bytes asset_public_key = 2;
bytes owner_commitment = 3;
bytes mined_in_block = 4;
uint64 mined_height = 5;
OutputFeatures features = 6;
bytes script = 7;
}
message SubmitBlockResponse {
bytes block_hash = 1;
}
message BlockBlobRequest{
bytes header_blob = 1;
bytes body_blob = 2;
}
/// return type of GetTipInfo
message TipInfoResponse {
MetaData metadata = 1;
bool initial_sync_achieved = 2;
BaseNodeState base_node_state = 3;
bool failed_checkpoints = 4;
}
enum BaseNodeState{
START_UP = 0;
HEADER_SYNC = 1;
HORIZON_SYNC = 2;
CONNECTING = 3;
BLOCK_SYNC = 4;
LISTENING = 5;
SYNC_FAILED = 6;
}
/// return type of GetNewBlockTemplate
message NewBlockTemplateResponse {
NewBlockTemplate new_block_template = 1;
bool initial_sync_achieved = 3;
MinerData miner_data = 4;
}
/// return type of NewBlockTemplateRequest
message NewBlockTemplateRequest{
PowAlgo algo = 1;
//This field should be moved to optional once optional keyword is standard
uint64 max_weight = 2;
}
/// return type of NewBlockTemplateRequest
message GetNewBlockTemplateWithCoinbasesRequest{
PowAlgo algo = 1;
//This field should be moved to optional once optional keyword is standard
uint64 max_weight = 2;
repeated NewBlockCoinbase coinbases = 3;
}
/// request type of GetNewBlockWithCoinbasesRequest
message GetNewBlockWithCoinbasesRequest{
NewBlockTemplate new_template = 1;
repeated NewBlockCoinbase coinbases = 2;
}
message NewBlockCoinbase{
string address = 1;
uint64 value = 2;
bool stealth_payment= 3;
bool revealed_value_proof= 4;
bytes coinbase_extra =5;
}
// Network difficulty response
message NetworkDifficultyResponse {
uint64 difficulty = 1;
uint64 estimated_hash_rate = 2;
uint64 height = 3;
uint64 timestamp = 4;
uint64 pow_algo = 5;
uint64 sha3x_estimated_hash_rate = 6;
uint64 monero_randomx_estimated_hash_rate = 7;
uint64 tari_randomx_estimated_hash_rate = 10;
uint64 num_coinbases = 8;
repeated bytes coinbase_extras = 9;
}
// A generic single value response for a specific height
message ValueAtHeightResponse {
// uint64 circulating_supply = 1; // No longer used
// uint64 spendable_supply = 2; // No longer used
uint64 height = 3;
uint64 mined_rewards = 4;
uint64 spendable_rewards = 5;
uint64 spendable_pre_mine = 6;
uint64 total_spendable = 7;
}
// A generic uint value
message IntegerValue {
uint64 value = 1;
}
// A generic String value
message StringValue {
string value = 1;
}
/// GetBlockSize / GetBlockFees Request
/// Either the starting and ending heights OR the from_tip param must be specified
message BlockGroupRequest {
// The height from the chain tip (optional)
uint64 from_tip = 1;
// The starting height (optional)
uint64 start_height = 2;
// The ending height (optional)
uint64 end_height = 3;
/// The type of calculation required (optional)
/// Defaults to median
/// median, mean, quartile, quantile
CalcType calc_type = 4;
}
/// GetBlockSize / GetBlockFees Response
message BlockGroupResponse {
repeated double value = 1;
CalcType calc_type = 2;
}
enum CalcType {
MEAN = 0;
MEDIAN = 1;
QUANTILE = 2;
QUARTILE = 3;
}
// The request used for querying a function that requires a height, either between 2 points or from the chain tip
// If start_height and end_height are set and > 0, they take precedence, otherwise from_tip is used
message HeightRequest {
// The height from the chain tip (optional)
uint64 from_tip = 1;
// The starting height (optional)
uint64 start_height = 2;
// The ending height (optional)
uint64 end_height = 3;
}
// The return type of the rpc GetBlockTiming
message BlockTimingResponse {
uint64 max = 1;
uint64 min = 2;
double avg = 3;
}
// Request that returns a header based by hash
message GetHeaderByHashRequest {
// The hash of the block header
bytes hash = 1;
}
message BlockHeaderResponse {
// The block header
BlockHeader header = 1;
// The number of blocks from the tip of this block (a.k.a depth)
uint64 confirmations = 2;
// The block reward i.e mining reward + fees
uint64 reward = 3;
// Achieved difficulty
uint64 difficulty = 4;
// The number of transactions contained in the block
uint32 num_transactions = 5;
}
// The request used for querying headers from the base node. The parameters `from_height` and `num_headers` can be used
// to page through the current best chain.
message ListHeadersRequest {
// The height to start at. Depending on sorting, will either default to use the tip or genesis block, for `SORTING_DESC`
// and `SORTING_ASC` respectively, if a value is not provided. The first header returned will be at this height
// followed by `num_headers` - 1 headers in the direction specified by `sorting`. If greater than the current tip,
// the current tip will be used.
uint64 from_height = 1;
// The number of headers to return. If not specified, it will default to 10
uint64 num_headers = 2;
// The ordering to return the headers in. If not specified will default to SORTING_DESC. Note that if `from_height`
// is not specified or is 0, if `sorting` is SORTING_DESC, the tip will be used as `from_height`, otherwise the
// block at height 0 will be used.
Sorting sorting = 3;
}
// The request used for querying blocks in the base node's current best chain. Currently only querying by height is
// available. Multiple blocks may be queried.e.g. [189092,100023,122424]. The order in which they are returned is not
// guaranteed.
message GetBlocksRequest {
repeated uint64 heights = 1;
}
// The return type of the rpc GetBlocks. Blocks are not guaranteed to be returned in the order requested.
message GetBlocksResponse {
repeated HistoricalBlock blocks = 1;
}
enum Sorting {
SORTING_DESC = 0;
SORTING_ASC = 1;
}
message MetaData {
// The current chain height, or the block number of the longest valid chain, or `None` if there is no chain
uint64 best_block_height = 1;
// The block hash of the current tip of the longest valid chain, or `None` for an empty chain
bytes best_block_hash = 2;
// The current geometric mean of the pow of the chain tip, or `None` if there is no chain
bytes accumulated_difficulty = 5;
// This is the min height this node can provide complete blocks for. A 0 here means this node is archival and can provide complete blocks for every height.
uint64 pruned_height = 6;
uint64 timestamp = 7;
}
message SyncInfoResponse {
uint64 tip_height = 1;
uint64 local_height = 2;
repeated bytes peer_node_id = 3;
}
message SyncProgressResponse {
uint64 tip_height = 1;
uint64 local_height = 2;
SyncState state = 3;
string short_desc = 4;
uint64 initial_connected_peers = 5;
}
enum SyncState {
STARTUP = 0;
HEADER_STARTING = 1;
HEADER = 2;
BLOCK_STARTING = 3;
BLOCK = 4;
DONE = 5;
}
// This is the message that is returned for a miner after it asks for a new block.
message GetNewBlockResult{
// This is the header hash of the completed block
bytes block_hash = 1;
// This is the completed block
Block block = 2;
bytes merge_mining_hash =3;
bytes tari_unique_id =4;
MinerData miner_data = 5;
bytes vm_key = 6;
}
// This is the message that is returned for a miner after it asks for a new block.
message GetNewBlockBlobResult{
// This is the header hash of the completed block
bytes block_hash = 1;
// This is the completed block's header
bytes header = 2;
// This is the completed block's body
bytes block_body = 3;
bytes merge_mining_hash =4;
bytes utxo_mr = 5;
bytes tari_unique_id =6;
}
// This is mining data for the miner asking for a new block
message MinerData{
PowAlgo algo = 1;
uint64 target_difficulty = 2;
uint64 reward = 3;
// bytes merge_mining_hash =4;
uint64 total_fees = 5;
}
// This is the request type for the Search Kernels rpc
message SearchKernelsRequest{
repeated Signature signatures = 1;
}
// This is the request type for the Search Utxo rpc
message SearchUtxosRequest{
repeated bytes commitments = 1;
}
message FetchMatchingUtxosRequest {
repeated bytes hashes = 1;
}
message FetchMatchingUtxosResponse {
TransactionOutput output = 1;
}
// This is the request type of the get all peers rpc call
message GetPeersResponse{
Peer peer = 1;
}
message GetPeersRequest{}
message SubmitTransactionRequest {
Transaction transaction = 1;
}
message SubmitTransactionResponse {
SubmitTransactionResult result =1;
}
enum SubmitTransactionResult {
NONE = 0;
ACCEPTED = 1;
NOT_PROCESSABLE_AT_THIS_TIME = 2;
ALREADY_MINED = 3;
REJECTED = 4;
}
message GetMempoolTransactionsRequest {
}
message GetMempoolTransactionsResponse {
Transaction transaction = 1;
}
message TransactionStateRequest {
Signature excess_sig = 1;
}
message TransactionStateResponse {
TransactionLocation result =1;
}
enum TransactionLocation {
UNKNOWN = 0;
MEMPOOL = 1;
MINED = 2;
NOT_STORED = 3;
}
message MempoolStatsResponse {
uint64 unconfirmed_txs = 2;
uint64 reorg_txs = 3;
uint64 unconfirmed_weight = 4;
}
message GetActiveValidatorNodesRequest {
uint64 height = 1;
}
message GetActiveValidatorNodesResponse {
bytes shard_key = 1;
bytes public_key = 2;
}
message GetShardKeyRequest {
uint64 height = 1;
bytes public_key = 2;
}
message GetShardKeyResponse {
bytes shard_key = 1;
bool found = 2;
}
message GetTemplateRegistrationsRequest {
bytes start_hash = 1;
uint64 count = 2;
}
message GetTemplateRegistrationResponse {
bytes utxo_hash = 1;
TemplateRegistration registration = 2;
}
message BlockInfo {
uint64 height = 1;
bytes hash = 2;
bytes next_block_hash = 3;
}
message GetSideChainUtxosRequest {
bytes start_hash = 1;
uint64 count = 2;
}
message GetSideChainUtxosResponse {
BlockInfo block_info = 1;
repeated TransactionOutput outputs = 2;
}
message GetNetworkStateRequest {
}
message GetNetworkStateResponse {
// metadata
MetaData metadata = 1;
// has the base node synced
bool initial_sync_achieved = 2;
//current state of the base node
BaseNodeState base_node_state = 3;
// do we have failed checkpoints
bool failed_checkpoints = 4;
// The block reward of the next tip
uint64 reward = 5;
// estimate sha3x hash rate
uint64 sha3x_estimated_hash_rate = 6;
// estimate randomx hash rate
uint64 monero_randomx_estimated_hash_rate = 7;
uint64 tari_randomx_estimated_hash_rate = 10;
// number of connections
uint64 num_connections = 8;
//liveness results
repeated LivenessResult liveness_results = 9;
}
message LivenessResult{
// node id
bytes peer_node_id = 1;
// time to discover
uint64 discover_latency = 2;
// Dial latency
uint64 ping_latency = 3;
}
// PayRef (Payment Reference) search and lookup messages
// Request to search for outputs by payment reference
message SearchPaymentReferencesRequest {
// Payment reference as hex string (64 characters)
repeated string payment_reference_hex = 1;
repeated bytes payment_reference_bytes = 2;
// Optional: include spent outputs in results
bool include_spent = 3;
}
// Response containing payment reference match
message PaymentReferenceResponse {
// The payment reference that was found
string payment_reference_hex = 1;
// Block height where the output was mined
uint64 block_height = 2;
// Block hash where the output was mined
bytes block_hash = 3;
// Timestamp when the output was mined
uint64 mined_timestamp = 4;
// Output commitment (32 bytes)
bytes commitment = 5;
// Whether this output has been spent
bool is_spent = 6;
// Height where output was spent (if spent)
uint64 spent_height = 7;
// Block hash where output was spent (if spent)
bytes spent_block_hash = 8;
// Transaction output amount will be 0 for non set a
uint64 min_value_promise = 9;
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,143 @@
// Copyright 2020. The Tari Project
//
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
// following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
// disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
// following disclaimer in the documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote
// products derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// 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.
syntax = "proto3";
package tari.rpc;
option go_package = "./pool";
import "transaction.proto";
// The BlockHeader contains all the metadata for the block, including proof of work, a link to the previous block
// and the transaction kernels.
message BlockHeader {
// The hash of the block
bytes hash = 1;
// Version of the block
uint32 version = 2;
// Height of this block since the genesis block (height 0)
uint64 height = 3;
// Hash of the block previous to this in the chain.
bytes prev_hash = 4;
// Timestamp at which the block was built.
uint64 timestamp = 5;
// This is the UTXO merkle root of the outputs in the blockchain
bytes output_mr = 6;
// This is the merkle root of all outputs in this block
bytes block_output_mr = 7;
// This is the MMR root of the kernels
bytes kernel_mr = 8;
// This is the Merkle root of the inputs in this block
bytes input_mr = 9;
// Total accumulated sum of kernel offsets since genesis block. We can derive the kernel offset sum for *this*
// block from the total kernel offset of the previous block header.
bytes total_kernel_offset = 10;
// Nonce increment used to mine this block.
uint64 nonce = 11;
// Proof of work metadata
ProofOfWork pow = 12;
// Kernel MMR size
uint64 kernel_mmr_size = 13;
// Output MMR size
uint64 output_mmr_size = 14;
// Sum of script offsets for all kernels in this block.
bytes total_script_offset = 15;
// Merkle root of validator nodes
bytes validator_node_mr = 16;
// Validator size
uint64 validator_node_size = 17;
}
// The proof of work data structure that is included in the block header.
message ProofOfWork {
// The algorithm used to mine this block
// 0 = Monero
// 1 = Sha3X
uint64 pow_algo = 1;
// Supplemental proof of work data. For example for Sha3x, this would be empty (only the block header is
// required), but for Monero merge mining we need the Monero block header and RandomX seed hash.
bytes pow_data = 4;
}
//This is used to request the which pow algo should be used with the block template
message PowAlgo {
// The permitted pow algorithms
enum PowAlgos {
POW_ALGOS_RANDOMXM = 0; // Accessible as `grpc::pow_algo::PowAlgos::RandomxM`
POW_ALGOS_SHA3X = 1; // Accessible as `grpc::pow_algo::PowAlgos::Sha3x`
POW_ALGOS_RANDOMXT = 2; // Accessible as `grpc::pow_algo::PowAlgos::RandomxT`
}
// The pow algo to use
PowAlgos pow_algo = 1;
}
// A Minotari block. Blocks are linked together into a blockchain.
message Block {
// The BlockHeader contains all the metadata for the block, including proof of work, a link to the previous block
// and the transaction kernels.
BlockHeader header = 1;
// The components of the block or transaction. The same struct can be used for either, since in Mimblewimble,
// blocks consist of inputs, outputs and kernels, rather than transactions.
AggregateBody body = 2;
}
// The representation of a historical block in the blockchain. It is essentially identical to a protocol-defined
// block but contains some extra metadata that clients such as Block Explorers will find interesting.
message HistoricalBlock {
// The number of blocks that have been mined since this block, including this one. The current tip will have one
// confirmation.
uint64 confirmations = 1;
// The underlying block
Block block = 2;
}
// The NewBlockHeaderTemplate is used for the construction of a new mine-able block. It contains all the metadata for the block that the Base Node is able to complete on behalf of a Miner.
message NewBlockHeaderTemplate {
// Version of the block
uint32 version = 1;
// Height of this block since the genesis block (height 0)
uint64 height = 2;
// Hash of the block previous to this in the chain.
bytes prev_hash = 3;
// Total accumulated sum of kernel offsets since genesis block. We can derive the kernel offset sum for *this*
// block from the total kernel offset of the previous block header.
bytes total_kernel_offset = 4;
// Proof of work metadata
ProofOfWork pow = 5;
// Sum of script offsets for all kernels in this block.
bytes total_script_offset = 7;
BlockHeader block_header = 8;
}
// The new block template is used constructing a new partial block, allowing a miner to added the coinbase utxo and as a final step the Base node to add the MMR roots to the header.
message NewBlockTemplate {
// The NewBlockHeaderTemplate is used for the construction of a new mineable block. It contains all the metadata for
// the block that the Base Node is able to complete on behalf of a Miner.
NewBlockHeaderTemplate header = 1;
// This flag indicates if the inputs, outputs and kernels have been sorted internally, that is, the sort() method
// has been called. This may be false even if all components are sorted.
AggregateBody body = 2;
// Sometimes the mempool has not synced to the latest tip, this flag indicates if the mempool is out of sync.
// In most cases the next call to get_new_block_template will return a block with the mempool in sync.
bool is_mempool_in_sync = 3;
}

View File

@ -0,0 +1,784 @@
// Copyright 2020. The Tari Project
//
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
// following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
// disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
// following disclaimer in the documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote
// products derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// 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.
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.6
// protoc v3.6.1
// source: block.proto
package block
import (
transaction "pool/internal/server/proxy/proto/transaction"
reflect "reflect"
sync "sync"
unsafe "unsafe"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// The permitted pow algorithms
type PowAlgo_PowAlgos int32
const (
PowAlgo_POW_ALGOS_RANDOMXM PowAlgo_PowAlgos = 0 // Accessible as `grpc::pow_algo::PowAlgos::RandomxM`
PowAlgo_POW_ALGOS_SHA3X PowAlgo_PowAlgos = 1 // Accessible as `grpc::pow_algo::PowAlgos::Sha3x`
PowAlgo_POW_ALGOS_RANDOMXT PowAlgo_PowAlgos = 2 // Accessible as `grpc::pow_algo::PowAlgos::RandomxT`
)
// Enum value maps for PowAlgo_PowAlgos.
var (
PowAlgo_PowAlgos_name = map[int32]string{
0: "POW_ALGOS_RANDOMXM",
1: "POW_ALGOS_SHA3X",
2: "POW_ALGOS_RANDOMXT",
}
PowAlgo_PowAlgos_value = map[string]int32{
"POW_ALGOS_RANDOMXM": 0,
"POW_ALGOS_SHA3X": 1,
"POW_ALGOS_RANDOMXT": 2,
}
)
func (x PowAlgo_PowAlgos) Enum() *PowAlgo_PowAlgos {
p := new(PowAlgo_PowAlgos)
*p = x
return p
}
func (x PowAlgo_PowAlgos) String() string {
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
}
func (PowAlgo_PowAlgos) Descriptor() protoreflect.EnumDescriptor {
return file_block_proto_enumTypes[0].Descriptor()
}
func (PowAlgo_PowAlgos) Type() protoreflect.EnumType {
return &file_block_proto_enumTypes[0]
}
func (x PowAlgo_PowAlgos) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(x)
}
// Deprecated: Use PowAlgo_PowAlgos.Descriptor instead.
func (PowAlgo_PowAlgos) EnumDescriptor() ([]byte, []int) {
return file_block_proto_rawDescGZIP(), []int{2, 0}
}
// The BlockHeader contains all the metadata for the block, including proof of work, a link to the previous block
// and the transaction kernels.
type BlockHeader struct {
state protoimpl.MessageState `protogen:"open.v1"`
// The hash of the block
Hash []byte `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"`
// Version of the block
Version uint32 `protobuf:"varint,2,opt,name=version,proto3" json:"version,omitempty"`
// Height of this block since the genesis block (height 0)
Height uint64 `protobuf:"varint,3,opt,name=height,proto3" json:"height,omitempty"`
// Hash of the block previous to this in the chain.
PrevHash []byte `protobuf:"bytes,4,opt,name=prev_hash,json=prevHash,proto3" json:"prev_hash,omitempty"`
// Timestamp at which the block was built.
Timestamp uint64 `protobuf:"varint,5,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
// This is the UTXO merkle root of the outputs in the blockchain
OutputMr []byte `protobuf:"bytes,6,opt,name=output_mr,json=outputMr,proto3" json:"output_mr,omitempty"`
// This is the merkle root of all outputs in this block
BlockOutputMr []byte `protobuf:"bytes,7,opt,name=block_output_mr,json=blockOutputMr,proto3" json:"block_output_mr,omitempty"`
// This is the MMR root of the kernels
KernelMr []byte `protobuf:"bytes,8,opt,name=kernel_mr,json=kernelMr,proto3" json:"kernel_mr,omitempty"`
// This is the Merkle root of the inputs in this block
InputMr []byte `protobuf:"bytes,9,opt,name=input_mr,json=inputMr,proto3" json:"input_mr,omitempty"`
// Total accumulated sum of kernel offsets since genesis block. We can derive the kernel offset sum for *this*
// block from the total kernel offset of the previous block header.
TotalKernelOffset []byte `protobuf:"bytes,10,opt,name=total_kernel_offset,json=totalKernelOffset,proto3" json:"total_kernel_offset,omitempty"`
// Nonce increment used to mine this block.
Nonce uint64 `protobuf:"varint,11,opt,name=nonce,proto3" json:"nonce,omitempty"`
// Proof of work metadata
Pow *ProofOfWork `protobuf:"bytes,12,opt,name=pow,proto3" json:"pow,omitempty"`
// Kernel MMR size
KernelMmrSize uint64 `protobuf:"varint,13,opt,name=kernel_mmr_size,json=kernelMmrSize,proto3" json:"kernel_mmr_size,omitempty"`
// Output MMR size
OutputMmrSize uint64 `protobuf:"varint,14,opt,name=output_mmr_size,json=outputMmrSize,proto3" json:"output_mmr_size,omitempty"`
// Sum of script offsets for all kernels in this block.
TotalScriptOffset []byte `protobuf:"bytes,15,opt,name=total_script_offset,json=totalScriptOffset,proto3" json:"total_script_offset,omitempty"`
// Merkle root of validator nodes
ValidatorNodeMr []byte `protobuf:"bytes,16,opt,name=validator_node_mr,json=validatorNodeMr,proto3" json:"validator_node_mr,omitempty"`
// Validator size
ValidatorNodeSize uint64 `protobuf:"varint,17,opt,name=validator_node_size,json=validatorNodeSize,proto3" json:"validator_node_size,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *BlockHeader) Reset() {
*x = BlockHeader{}
mi := &file_block_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *BlockHeader) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*BlockHeader) ProtoMessage() {}
func (x *BlockHeader) ProtoReflect() protoreflect.Message {
mi := &file_block_proto_msgTypes[0]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use BlockHeader.ProtoReflect.Descriptor instead.
func (*BlockHeader) Descriptor() ([]byte, []int) {
return file_block_proto_rawDescGZIP(), []int{0}
}
func (x *BlockHeader) GetHash() []byte {
if x != nil {
return x.Hash
}
return nil
}
func (x *BlockHeader) GetVersion() uint32 {
if x != nil {
return x.Version
}
return 0
}
func (x *BlockHeader) GetHeight() uint64 {
if x != nil {
return x.Height
}
return 0
}
func (x *BlockHeader) GetPrevHash() []byte {
if x != nil {
return x.PrevHash
}
return nil
}
func (x *BlockHeader) GetTimestamp() uint64 {
if x != nil {
return x.Timestamp
}
return 0
}
func (x *BlockHeader) GetOutputMr() []byte {
if x != nil {
return x.OutputMr
}
return nil
}
func (x *BlockHeader) GetBlockOutputMr() []byte {
if x != nil {
return x.BlockOutputMr
}
return nil
}
func (x *BlockHeader) GetKernelMr() []byte {
if x != nil {
return x.KernelMr
}
return nil
}
func (x *BlockHeader) GetInputMr() []byte {
if x != nil {
return x.InputMr
}
return nil
}
func (x *BlockHeader) GetTotalKernelOffset() []byte {
if x != nil {
return x.TotalKernelOffset
}
return nil
}
func (x *BlockHeader) GetNonce() uint64 {
if x != nil {
return x.Nonce
}
return 0
}
func (x *BlockHeader) GetPow() *ProofOfWork {
if x != nil {
return x.Pow
}
return nil
}
func (x *BlockHeader) GetKernelMmrSize() uint64 {
if x != nil {
return x.KernelMmrSize
}
return 0
}
func (x *BlockHeader) GetOutputMmrSize() uint64 {
if x != nil {
return x.OutputMmrSize
}
return 0
}
func (x *BlockHeader) GetTotalScriptOffset() []byte {
if x != nil {
return x.TotalScriptOffset
}
return nil
}
func (x *BlockHeader) GetValidatorNodeMr() []byte {
if x != nil {
return x.ValidatorNodeMr
}
return nil
}
func (x *BlockHeader) GetValidatorNodeSize() uint64 {
if x != nil {
return x.ValidatorNodeSize
}
return 0
}
// The proof of work data structure that is included in the block header.
type ProofOfWork struct {
state protoimpl.MessageState `protogen:"open.v1"`
// The algorithm used to mine this block
//
// 0 = Monero
// 1 = Sha3X
PowAlgo uint64 `protobuf:"varint,1,opt,name=pow_algo,json=powAlgo,proto3" json:"pow_algo,omitempty"`
// Supplemental proof of work data. For example for Sha3x, this would be empty (only the block header is
// required), but for Monero merge mining we need the Monero block header and RandomX seed hash.
PowData []byte `protobuf:"bytes,4,opt,name=pow_data,json=powData,proto3" json:"pow_data,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *ProofOfWork) Reset() {
*x = ProofOfWork{}
mi := &file_block_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *ProofOfWork) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ProofOfWork) ProtoMessage() {}
func (x *ProofOfWork) ProtoReflect() protoreflect.Message {
mi := &file_block_proto_msgTypes[1]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ProofOfWork.ProtoReflect.Descriptor instead.
func (*ProofOfWork) Descriptor() ([]byte, []int) {
return file_block_proto_rawDescGZIP(), []int{1}
}
func (x *ProofOfWork) GetPowAlgo() uint64 {
if x != nil {
return x.PowAlgo
}
return 0
}
func (x *ProofOfWork) GetPowData() []byte {
if x != nil {
return x.PowData
}
return nil
}
// This is used to request the which pow algo should be used with the block template
type PowAlgo struct {
state protoimpl.MessageState `protogen:"open.v1"`
// The pow algo to use
PowAlgo PowAlgo_PowAlgos `protobuf:"varint,1,opt,name=pow_algo,json=powAlgo,proto3,enum=tari.rpc.PowAlgo_PowAlgos" json:"pow_algo,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *PowAlgo) Reset() {
*x = PowAlgo{}
mi := &file_block_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *PowAlgo) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*PowAlgo) ProtoMessage() {}
func (x *PowAlgo) ProtoReflect() protoreflect.Message {
mi := &file_block_proto_msgTypes[2]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use PowAlgo.ProtoReflect.Descriptor instead.
func (*PowAlgo) Descriptor() ([]byte, []int) {
return file_block_proto_rawDescGZIP(), []int{2}
}
func (x *PowAlgo) GetPowAlgo() PowAlgo_PowAlgos {
if x != nil {
return x.PowAlgo
}
return PowAlgo_POW_ALGOS_RANDOMXM
}
// A Minotari block. Blocks are linked together into a blockchain.
type Block struct {
state protoimpl.MessageState `protogen:"open.v1"`
// The BlockHeader contains all the metadata for the block, including proof of work, a link to the previous block
// and the transaction kernels.
Header *BlockHeader `protobuf:"bytes,1,opt,name=header,proto3" json:"header,omitempty"`
// The components of the block or transaction. The same struct can be used for either, since in Mimblewimble,
// blocks consist of inputs, outputs and kernels, rather than transactions.
Body *transaction.AggregateBody `protobuf:"bytes,2,opt,name=body,proto3" json:"body,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *Block) Reset() {
*x = Block{}
mi := &file_block_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *Block) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Block) ProtoMessage() {}
func (x *Block) ProtoReflect() protoreflect.Message {
mi := &file_block_proto_msgTypes[3]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Block.ProtoReflect.Descriptor instead.
func (*Block) Descriptor() ([]byte, []int) {
return file_block_proto_rawDescGZIP(), []int{3}
}
func (x *Block) GetHeader() *BlockHeader {
if x != nil {
return x.Header
}
return nil
}
func (x *Block) GetBody() *transaction.AggregateBody {
if x != nil {
return x.Body
}
return nil
}
// The representation of a historical block in the blockchain. It is essentially identical to a protocol-defined
// block but contains some extra metadata that clients such as Block Explorers will find interesting.
type HistoricalBlock struct {
state protoimpl.MessageState `protogen:"open.v1"`
// The number of blocks that have been mined since this block, including this one. The current tip will have one
// confirmation.
Confirmations uint64 `protobuf:"varint,1,opt,name=confirmations,proto3" json:"confirmations,omitempty"`
// The underlying block
Block *Block `protobuf:"bytes,2,opt,name=block,proto3" json:"block,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *HistoricalBlock) Reset() {
*x = HistoricalBlock{}
mi := &file_block_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *HistoricalBlock) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*HistoricalBlock) ProtoMessage() {}
func (x *HistoricalBlock) ProtoReflect() protoreflect.Message {
mi := &file_block_proto_msgTypes[4]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use HistoricalBlock.ProtoReflect.Descriptor instead.
func (*HistoricalBlock) Descriptor() ([]byte, []int) {
return file_block_proto_rawDescGZIP(), []int{4}
}
func (x *HistoricalBlock) GetConfirmations() uint64 {
if x != nil {
return x.Confirmations
}
return 0
}
func (x *HistoricalBlock) GetBlock() *Block {
if x != nil {
return x.Block
}
return nil
}
// The NewBlockHeaderTemplate is used for the construction of a new mine-able block. It contains all the metadata for the block that the Base Node is able to complete on behalf of a Miner.
type NewBlockHeaderTemplate struct {
state protoimpl.MessageState `protogen:"open.v1"`
// Version of the block
Version uint32 `protobuf:"varint,1,opt,name=version,proto3" json:"version,omitempty"`
// Height of this block since the genesis block (height 0)
Height uint64 `protobuf:"varint,2,opt,name=height,proto3" json:"height,omitempty"`
// Hash of the block previous to this in the chain.
PrevHash []byte `protobuf:"bytes,3,opt,name=prev_hash,json=prevHash,proto3" json:"prev_hash,omitempty"`
// Total accumulated sum of kernel offsets since genesis block. We can derive the kernel offset sum for *this*
// block from the total kernel offset of the previous block header.
TotalKernelOffset []byte `protobuf:"bytes,4,opt,name=total_kernel_offset,json=totalKernelOffset,proto3" json:"total_kernel_offset,omitempty"`
// Proof of work metadata
Pow *ProofOfWork `protobuf:"bytes,5,opt,name=pow,proto3" json:"pow,omitempty"`
// Sum of script offsets for all kernels in this block.
TotalScriptOffset []byte `protobuf:"bytes,7,opt,name=total_script_offset,json=totalScriptOffset,proto3" json:"total_script_offset,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
BlockHeader *BlockHeader `protobuf:"bytes,8,opt,name=block_header,json=blockHeader,proto3" json:"block_header,omitempty"`
}
func (x *NewBlockHeaderTemplate) Reset() {
*x = NewBlockHeaderTemplate{}
mi := &file_block_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *NewBlockHeaderTemplate) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*NewBlockHeaderTemplate) ProtoMessage() {}
func (x *NewBlockHeaderTemplate) ProtoReflect() protoreflect.Message {
mi := &file_block_proto_msgTypes[5]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use NewBlockHeaderTemplate.ProtoReflect.Descriptor instead.
func (*NewBlockHeaderTemplate) Descriptor() ([]byte, []int) {
return file_block_proto_rawDescGZIP(), []int{5}
}
func (x *NewBlockHeaderTemplate) GetVersion() uint32 {
if x != nil {
return x.Version
}
return 0
}
func (x *NewBlockHeaderTemplate) GetHeight() uint64 {
if x != nil {
return x.Height
}
return 0
}
func (x *NewBlockHeaderTemplate) GetPrevHash() []byte {
if x != nil {
return x.PrevHash
}
return nil
}
func (x *NewBlockHeaderTemplate) GetTotalKernelOffset() []byte {
if x != nil {
return x.TotalKernelOffset
}
return nil
}
func (x *NewBlockHeaderTemplate) GetPow() *ProofOfWork {
if x != nil {
return x.Pow
}
return nil
}
func (x *NewBlockHeaderTemplate) GetTotalScriptOffset() []byte {
if x != nil {
return x.TotalScriptOffset
}
return nil
}
// The new block template is used constructing a new partial block, allowing a miner to added the coinbase utxo and as a final step the Base node to add the MMR roots to the header.
type NewBlockTemplate struct {
state protoimpl.MessageState `protogen:"open.v1"`
// The NewBlockHeaderTemplate is used for the construction of a new mineable block. It contains all the metadata for
// the block that the Base Node is able to complete on behalf of a Miner.
Header *NewBlockHeaderTemplate `protobuf:"bytes,1,opt,name=header,proto3" json:"header,omitempty"`
// This flag indicates if the inputs, outputs and kernels have been sorted internally, that is, the sort() method
// has been called. This may be false even if all components are sorted.
Body *transaction.AggregateBody `protobuf:"bytes,2,opt,name=body,proto3" json:"body,omitempty"`
// Sometimes the mempool has not synced to the latest tip, this flag indicates if the mempool is out of sync.
// In most cases the next call to get_new_block_template will return a block with the mempool in sync.
IsMempoolInSync bool `protobuf:"varint,3,opt,name=is_mempool_in_sync,json=isMempoolInSync,proto3" json:"is_mempool_in_sync,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *NewBlockTemplate) Reset() {
*x = NewBlockTemplate{}
mi := &file_block_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *NewBlockTemplate) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*NewBlockTemplate) ProtoMessage() {}
func (x *NewBlockTemplate) ProtoReflect() protoreflect.Message {
mi := &file_block_proto_msgTypes[6]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use NewBlockTemplate.ProtoReflect.Descriptor instead.
func (*NewBlockTemplate) Descriptor() ([]byte, []int) {
return file_block_proto_rawDescGZIP(), []int{6}
}
func (x *NewBlockTemplate) GetHeader() *NewBlockHeaderTemplate {
if x != nil {
return x.Header
}
return nil
}
func (x *NewBlockTemplate) GetBody() *transaction.AggregateBody {
if x != nil {
return x.Body
}
return nil
}
func (x *NewBlockTemplate) GetIsMempoolInSync() bool {
if x != nil {
return x.IsMempoolInSync
}
return false
}
var File_block_proto protoreflect.FileDescriptor
const file_block_proto_rawDesc = "" +
"\n" +
"\vblock.proto\x12\btari.rpc\x1a\x11transaction.proto\"\xd6\x04\n" +
"\vBlockHeader\x12\x12\n" +
"\x04hash\x18\x01 \x01(\fR\x04hash\x12\x18\n" +
"\aversion\x18\x02 \x01(\rR\aversion\x12\x16\n" +
"\x06height\x18\x03 \x01(\x04R\x06height\x12\x1b\n" +
"\tprev_hash\x18\x04 \x01(\fR\bprevHash\x12\x1c\n" +
"\ttimestamp\x18\x05 \x01(\x04R\ttimestamp\x12\x1b\n" +
"\toutput_mr\x18\x06 \x01(\fR\boutputMr\x12&\n" +
"\x0fblock_output_mr\x18\a \x01(\fR\rblockOutputMr\x12\x1b\n" +
"\tkernel_mr\x18\b \x01(\fR\bkernelMr\x12\x19\n" +
"\binput_mr\x18\t \x01(\fR\ainputMr\x12.\n" +
"\x13total_kernel_offset\x18\n" +
" \x01(\fR\x11totalKernelOffset\x12\x14\n" +
"\x05nonce\x18\v \x01(\x04R\x05nonce\x12'\n" +
"\x03pow\x18\f \x01(\v2\x15.tari.rpc.ProofOfWorkR\x03pow\x12&\n" +
"\x0fkernel_mmr_size\x18\r \x01(\x04R\rkernelMmrSize\x12&\n" +
"\x0foutput_mmr_size\x18\x0e \x01(\x04R\routputMmrSize\x12.\n" +
"\x13total_script_offset\x18\x0f \x01(\fR\x11totalScriptOffset\x12*\n" +
"\x11validator_node_mr\x18\x10 \x01(\fR\x0fvalidatorNodeMr\x12.\n" +
"\x13validator_node_size\x18\x11 \x01(\x04R\x11validatorNodeSize\"C\n" +
"\vProofOfWork\x12\x19\n" +
"\bpow_algo\x18\x01 \x01(\x04R\apowAlgo\x12\x19\n" +
"\bpow_data\x18\x04 \x01(\fR\apowData\"\x91\x01\n" +
"\aPowAlgo\x125\n" +
"\bpow_algo\x18\x01 \x01(\x0e2\x1a.tari.rpc.PowAlgo.PowAlgosR\apowAlgo\"O\n" +
"\bPowAlgos\x12\x16\n" +
"\x12POW_ALGOS_RANDOMXM\x10\x00\x12\x13\n" +
"\x0fPOW_ALGOS_SHA3X\x10\x01\x12\x16\n" +
"\x12POW_ALGOS_RANDOMXT\x10\x02\"c\n" +
"\x05Block\x12-\n" +
"\x06header\x18\x01 \x01(\v2\x15.tari.rpc.BlockHeaderR\x06header\x12+\n" +
"\x04body\x18\x02 \x01(\v2\x17.tari.rpc.AggregateBodyR\x04body\"^\n" +
"\x0fHistoricalBlock\x12$\n" +
"\rconfirmations\x18\x01 \x01(\x04R\rconfirmations\x12%\n" +
"\x05block\x18\x02 \x01(\v2\x0f.tari.rpc.BlockR\x05block\"\xf0\x01\n" +
"\x16NewBlockHeaderTemplate\x12\x18\n" +
"\aversion\x18\x01 \x01(\rR\aversion\x12\x16\n" +
"\x06height\x18\x02 \x01(\x04R\x06height\x12\x1b\n" +
"\tprev_hash\x18\x03 \x01(\fR\bprevHash\x12.\n" +
"\x13total_kernel_offset\x18\x04 \x01(\fR\x11totalKernelOffset\x12'\n" +
"\x03pow\x18\x05 \x01(\v2\x15.tari.rpc.ProofOfWorkR\x03pow\x12.\n" +
"\x13total_script_offset\x18\a \x01(\fR\x11totalScriptOffset\"\xa6\x01\n" +
"\x10NewBlockTemplate\x128\n" +
"\x06header\x18\x01 \x01(\v2 .tari.rpc.NewBlockHeaderTemplateR\x06header\x12+\n" +
"\x04body\x18\x02 \x01(\v2\x17.tari.rpc.AggregateBodyR\x04body\x12+\n" +
"\x12is_mempool_in_sync\x18\x03 \x01(\bR\x0fisMempoolInSyncB$Z\"pool/internal/gbt/tari/block;blockb\x06proto3"
var (
file_block_proto_rawDescOnce sync.Once
file_block_proto_rawDescData []byte
)
func file_block_proto_rawDescGZIP() []byte {
file_block_proto_rawDescOnce.Do(func() {
file_block_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_block_proto_rawDesc), len(file_block_proto_rawDesc)))
})
return file_block_proto_rawDescData
}
var file_block_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
var file_block_proto_msgTypes = make([]protoimpl.MessageInfo, 7)
var file_block_proto_goTypes = []any{
(PowAlgo_PowAlgos)(0), // 0: tari.rpc.PowAlgo.PowAlgos
(*BlockHeader)(nil), // 1: tari.rpc.BlockHeader
(*ProofOfWork)(nil), // 2: tari.rpc.ProofOfWork
(*PowAlgo)(nil), // 3: tari.rpc.PowAlgo
(*Block)(nil), // 4: tari.rpc.Block
(*HistoricalBlock)(nil), // 5: tari.rpc.HistoricalBlock
(*NewBlockHeaderTemplate)(nil), // 6: tari.rpc.NewBlockHeaderTemplate
(*NewBlockTemplate)(nil), // 7: tari.rpc.NewBlockTemplate
(*transaction.AggregateBody)(nil), // 8: tari.rpc.AggregateBody
}
var file_block_proto_depIdxs = []int32{
2, // 0: tari.rpc.BlockHeader.pow:type_name -> tari.rpc.ProofOfWork
0, // 1: tari.rpc.PowAlgo.pow_algo:type_name -> tari.rpc.PowAlgo.PowAlgos
1, // 2: tari.rpc.Block.header:type_name -> tari.rpc.BlockHeader
8, // 3: tari.rpc.Block.body:type_name -> tari.rpc.AggregateBody
4, // 4: tari.rpc.HistoricalBlock.block:type_name -> tari.rpc.Block
2, // 5: tari.rpc.NewBlockHeaderTemplate.pow:type_name -> tari.rpc.ProofOfWork
6, // 6: tari.rpc.NewBlockTemplate.header:type_name -> tari.rpc.NewBlockHeaderTemplate
8, // 7: tari.rpc.NewBlockTemplate.body:type_name -> tari.rpc.AggregateBody
8, // [8:8] is the sub-list for method output_type
8, // [8:8] is the sub-list for method input_type
8, // [8:8] is the sub-list for extension type_name
8, // [8:8] is the sub-list for extension extendee
0, // [0:8] is the sub-list for field type_name
}
func init() { file_block_proto_init() }
func file_block_proto_init() {
if File_block_proto != nil {
return
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_block_proto_rawDesc), len(file_block_proto_rawDesc)),
NumEnums: 1,
NumMessages: 7,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_block_proto_goTypes,
DependencyIndexes: file_block_proto_depIdxs,
EnumInfos: file_block_proto_enumTypes,
MessageInfos: file_block_proto_msgTypes,
}.Build()
File_block_proto = out.File
file_block_proto_goTypes = nil
file_block_proto_depIdxs = nil
}

View File

@ -0,0 +1,790 @@
// Copyright 2020. The Tari Project
//
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
// following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
// disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
// following disclaimer in the documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote
// products derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// 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.
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.6
// protoc v3.6.1
// source: network.proto
package net_work
import (
_ "github.com/golang/protobuf/ptypes/timestamp"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
unsafe "unsafe"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type ConnectivityStatus int32
const (
ConnectivityStatus_Initializing ConnectivityStatus = 0
ConnectivityStatus_Online ConnectivityStatus = 1
ConnectivityStatus_Degraded ConnectivityStatus = 2
ConnectivityStatus_Offline ConnectivityStatus = 3
)
// Enum value maps for ConnectivityStatus.
var (
ConnectivityStatus_name = map[int32]string{
0: "Initializing",
1: "Online",
2: "Degraded",
3: "Offline",
}
ConnectivityStatus_value = map[string]int32{
"Initializing": 0,
"Online": 1,
"Degraded": 2,
"Offline": 3,
}
)
func (x ConnectivityStatus) Enum() *ConnectivityStatus {
p := new(ConnectivityStatus)
*p = x
return p
}
func (x ConnectivityStatus) String() string {
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
}
func (ConnectivityStatus) Descriptor() protoreflect.EnumDescriptor {
return file_network_proto_enumTypes[0].Descriptor()
}
func (ConnectivityStatus) Type() protoreflect.EnumType {
return &file_network_proto_enumTypes[0]
}
func (x ConnectivityStatus) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(x)
}
// Deprecated: Use ConnectivityStatus.Descriptor instead.
func (ConnectivityStatus) EnumDescriptor() ([]byte, []int) {
return file_network_proto_rawDescGZIP(), []int{0}
}
type NodeIdentity struct {
state protoimpl.MessageState `protogen:"open.v1"`
PublicKey []byte `protobuf:"bytes,1,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"`
PublicAddresses []string `protobuf:"bytes,2,rep,name=public_addresses,json=publicAddresses,proto3" json:"public_addresses,omitempty"`
NodeId []byte `protobuf:"bytes,3,opt,name=node_id,json=nodeId,proto3" json:"node_id,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *NodeIdentity) Reset() {
*x = NodeIdentity{}
mi := &file_network_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *NodeIdentity) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*NodeIdentity) ProtoMessage() {}
func (x *NodeIdentity) ProtoReflect() protoreflect.Message {
mi := &file_network_proto_msgTypes[0]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use NodeIdentity.ProtoReflect.Descriptor instead.
func (*NodeIdentity) Descriptor() ([]byte, []int) {
return file_network_proto_rawDescGZIP(), []int{0}
}
func (x *NodeIdentity) GetPublicKey() []byte {
if x != nil {
return x.PublicKey
}
return nil
}
func (x *NodeIdentity) GetPublicAddresses() []string {
if x != nil {
return x.PublicAddresses
}
return nil
}
func (x *NodeIdentity) GetNodeId() []byte {
if x != nil {
return x.NodeId
}
return nil
}
type Peer struct {
state protoimpl.MessageState `protogen:"open.v1"`
// / Public key of the peer
PublicKey []byte `protobuf:"bytes,1,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"`
// / NodeId of the peer
NodeId []byte `protobuf:"bytes,2,opt,name=node_id,json=nodeId,proto3" json:"node_id,omitempty"`
// / Peer's addresses
Addresses []*Address `protobuf:"bytes,3,rep,name=addresses,proto3" json:"addresses,omitempty"`
// / Last connection attempt to peer
LastConnection uint64 `protobuf:"varint,4,opt,name=last_connection,json=lastConnection,proto3" json:"last_connection,omitempty"`
// / Flags for the peer.
Flags uint32 `protobuf:"varint,5,opt,name=flags,proto3" json:"flags,omitempty"`
BannedUntil uint64 `protobuf:"varint,6,opt,name=banned_until,json=bannedUntil,proto3" json:"banned_until,omitempty"`
BannedReason string `protobuf:"bytes,7,opt,name=banned_reason,json=bannedReason,proto3" json:"banned_reason,omitempty"`
OfflineAt uint64 `protobuf:"varint,8,opt,name=offline_at,json=offlineAt,proto3" json:"offline_at,omitempty"`
// / Features supported by the peer
Features uint32 `protobuf:"varint,9,opt,name=features,proto3" json:"features,omitempty"`
// / used as information for more efficient protocol negotiation.
SupportedProtocols [][]byte `protobuf:"bytes,11,rep,name=supported_protocols,json=supportedProtocols,proto3" json:"supported_protocols,omitempty"`
// / User agent advertised by the peer
UserAgent string `protobuf:"bytes,12,opt,name=user_agent,json=userAgent,proto3" json:"user_agent,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *Peer) Reset() {
*x = Peer{}
mi := &file_network_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *Peer) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Peer) ProtoMessage() {}
func (x *Peer) ProtoReflect() protoreflect.Message {
mi := &file_network_proto_msgTypes[1]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Peer.ProtoReflect.Descriptor instead.
func (*Peer) Descriptor() ([]byte, []int) {
return file_network_proto_rawDescGZIP(), []int{1}
}
func (x *Peer) GetPublicKey() []byte {
if x != nil {
return x.PublicKey
}
return nil
}
func (x *Peer) GetNodeId() []byte {
if x != nil {
return x.NodeId
}
return nil
}
func (x *Peer) GetAddresses() []*Address {
if x != nil {
return x.Addresses
}
return nil
}
func (x *Peer) GetLastConnection() uint64 {
if x != nil {
return x.LastConnection
}
return 0
}
func (x *Peer) GetFlags() uint32 {
if x != nil {
return x.Flags
}
return 0
}
func (x *Peer) GetBannedUntil() uint64 {
if x != nil {
return x.BannedUntil
}
return 0
}
func (x *Peer) GetBannedReason() string {
if x != nil {
return x.BannedReason
}
return ""
}
func (x *Peer) GetOfflineAt() uint64 {
if x != nil {
return x.OfflineAt
}
return 0
}
func (x *Peer) GetFeatures() uint32 {
if x != nil {
return x.Features
}
return 0
}
func (x *Peer) GetSupportedProtocols() [][]byte {
if x != nil {
return x.SupportedProtocols
}
return nil
}
func (x *Peer) GetUserAgent() string {
if x != nil {
return x.UserAgent
}
return ""
}
type NetworkStatusResponse struct {
state protoimpl.MessageState `protogen:"open.v1"`
Status ConnectivityStatus `protobuf:"varint,1,opt,name=status,proto3,enum=tari.rpc.ConnectivityStatus" json:"status,omitempty"`
AvgLatencyMs uint32 `protobuf:"varint,2,opt,name=avg_latency_ms,json=avgLatencyMs,proto3" json:"avg_latency_ms,omitempty"`
NumNodeConnections uint32 `protobuf:"varint,3,opt,name=num_node_connections,json=numNodeConnections,proto3" json:"num_node_connections,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *NetworkStatusResponse) Reset() {
*x = NetworkStatusResponse{}
mi := &file_network_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *NetworkStatusResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*NetworkStatusResponse) ProtoMessage() {}
func (x *NetworkStatusResponse) ProtoReflect() protoreflect.Message {
mi := &file_network_proto_msgTypes[2]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use NetworkStatusResponse.ProtoReflect.Descriptor instead.
func (*NetworkStatusResponse) Descriptor() ([]byte, []int) {
return file_network_proto_rawDescGZIP(), []int{2}
}
func (x *NetworkStatusResponse) GetStatus() ConnectivityStatus {
if x != nil {
return x.Status
}
return ConnectivityStatus_Initializing
}
func (x *NetworkStatusResponse) GetAvgLatencyMs() uint32 {
if x != nil {
return x.AvgLatencyMs
}
return 0
}
func (x *NetworkStatusResponse) GetNumNodeConnections() uint32 {
if x != nil {
return x.NumNodeConnections
}
return 0
}
type Address struct {
state protoimpl.MessageState `protogen:"open.v1"`
Address []byte `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"`
LastSeen string `protobuf:"bytes,2,opt,name=last_seen,json=lastSeen,proto3" json:"last_seen,omitempty"`
ConnectionAttempts uint32 `protobuf:"varint,3,opt,name=connection_attempts,json=connectionAttempts,proto3" json:"connection_attempts,omitempty"`
AvgLatency *AverageLatency `protobuf:"bytes,5,opt,name=avg_latency,json=avgLatency,proto3" json:"avg_latency,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *Address) Reset() {
*x = Address{}
mi := &file_network_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *Address) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Address) ProtoMessage() {}
func (x *Address) ProtoReflect() protoreflect.Message {
mi := &file_network_proto_msgTypes[3]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Address.ProtoReflect.Descriptor instead.
func (*Address) Descriptor() ([]byte, []int) {
return file_network_proto_rawDescGZIP(), []int{3}
}
func (x *Address) GetAddress() []byte {
if x != nil {
return x.Address
}
return nil
}
func (x *Address) GetLastSeen() string {
if x != nil {
return x.LastSeen
}
return ""
}
func (x *Address) GetConnectionAttempts() uint32 {
if x != nil {
return x.ConnectionAttempts
}
return 0
}
func (x *Address) GetAvgLatency() *AverageLatency {
if x != nil {
return x.AvgLatency
}
return nil
}
type AverageLatency struct {
state protoimpl.MessageState `protogen:"open.v1"`
Latency uint64 `protobuf:"varint,1,opt,name=latency,proto3" json:"latency,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *AverageLatency) Reset() {
*x = AverageLatency{}
mi := &file_network_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *AverageLatency) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*AverageLatency) ProtoMessage() {}
func (x *AverageLatency) ProtoReflect() protoreflect.Message {
mi := &file_network_proto_msgTypes[4]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use AverageLatency.ProtoReflect.Descriptor instead.
func (*AverageLatency) Descriptor() ([]byte, []int) {
return file_network_proto_rawDescGZIP(), []int{4}
}
func (x *AverageLatency) GetLatency() uint64 {
if x != nil {
return x.Latency
}
return 0
}
type ListConnectedPeersResponse struct {
state protoimpl.MessageState `protogen:"open.v1"`
ConnectedPeers []*Peer `protobuf:"bytes,1,rep,name=connected_peers,json=connectedPeers,proto3" json:"connected_peers,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *ListConnectedPeersResponse) Reset() {
*x = ListConnectedPeersResponse{}
mi := &file_network_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *ListConnectedPeersResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ListConnectedPeersResponse) ProtoMessage() {}
func (x *ListConnectedPeersResponse) ProtoReflect() protoreflect.Message {
mi := &file_network_proto_msgTypes[5]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ListConnectedPeersResponse.ProtoReflect.Descriptor instead.
func (*ListConnectedPeersResponse) Descriptor() ([]byte, []int) {
return file_network_proto_rawDescGZIP(), []int{5}
}
func (x *ListConnectedPeersResponse) GetConnectedPeers() []*Peer {
if x != nil {
return x.ConnectedPeers
}
return nil
}
type SoftwareUpdate struct {
state protoimpl.MessageState `protogen:"open.v1"`
HasUpdate bool `protobuf:"varint,1,opt,name=has_update,json=hasUpdate,proto3" json:"has_update,omitempty"`
Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"`
Sha string `protobuf:"bytes,3,opt,name=sha,proto3" json:"sha,omitempty"`
DownloadUrl string `protobuf:"bytes,4,opt,name=download_url,json=downloadUrl,proto3" json:"download_url,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *SoftwareUpdate) Reset() {
*x = SoftwareUpdate{}
mi := &file_network_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *SoftwareUpdate) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*SoftwareUpdate) ProtoMessage() {}
func (x *SoftwareUpdate) ProtoReflect() protoreflect.Message {
mi := &file_network_proto_msgTypes[6]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use SoftwareUpdate.ProtoReflect.Descriptor instead.
func (*SoftwareUpdate) Descriptor() ([]byte, []int) {
return file_network_proto_rawDescGZIP(), []int{6}
}
func (x *SoftwareUpdate) GetHasUpdate() bool {
if x != nil {
return x.HasUpdate
}
return false
}
func (x *SoftwareUpdate) GetVersion() string {
if x != nil {
return x.Version
}
return ""
}
func (x *SoftwareUpdate) GetSha() string {
if x != nil {
return x.Sha
}
return ""
}
func (x *SoftwareUpdate) GetDownloadUrl() string {
if x != nil {
return x.DownloadUrl
}
return ""
}
type GetIdentityRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *GetIdentityRequest) Reset() {
*x = GetIdentityRequest{}
mi := &file_network_proto_msgTypes[7]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *GetIdentityRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetIdentityRequest) ProtoMessage() {}
func (x *GetIdentityRequest) ProtoReflect() protoreflect.Message {
mi := &file_network_proto_msgTypes[7]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use GetIdentityRequest.ProtoReflect.Descriptor instead.
func (*GetIdentityRequest) Descriptor() ([]byte, []int) {
return file_network_proto_rawDescGZIP(), []int{7}
}
type GetIdentityResponse struct {
state protoimpl.MessageState `protogen:"open.v1"`
PublicKey []byte `protobuf:"bytes,1,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"`
PublicAddress string `protobuf:"bytes,2,opt,name=public_address,json=publicAddress,proto3" json:"public_address,omitempty"`
NodeId []byte `protobuf:"bytes,3,opt,name=node_id,json=nodeId,proto3" json:"node_id,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *GetIdentityResponse) Reset() {
*x = GetIdentityResponse{}
mi := &file_network_proto_msgTypes[8]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *GetIdentityResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetIdentityResponse) ProtoMessage() {}
func (x *GetIdentityResponse) ProtoReflect() protoreflect.Message {
mi := &file_network_proto_msgTypes[8]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use GetIdentityResponse.ProtoReflect.Descriptor instead.
func (*GetIdentityResponse) Descriptor() ([]byte, []int) {
return file_network_proto_rawDescGZIP(), []int{8}
}
func (x *GetIdentityResponse) GetPublicKey() []byte {
if x != nil {
return x.PublicKey
}
return nil
}
func (x *GetIdentityResponse) GetPublicAddress() string {
if x != nil {
return x.PublicAddress
}
return ""
}
func (x *GetIdentityResponse) GetNodeId() []byte {
if x != nil {
return x.NodeId
}
return nil
}
var File_network_proto protoreflect.FileDescriptor
const file_network_proto_rawDesc = "" +
"\n" +
"\rnetwork.proto\x12\btari.rpc\x1a\x1fgoogle/protobuf/timestamp.proto\"q\n" +
"\fNodeIdentity\x12\x1d\n" +
"\n" +
"public_key\x18\x01 \x01(\fR\tpublicKey\x12)\n" +
"\x10public_addresses\x18\x02 \x03(\tR\x0fpublicAddresses\x12\x17\n" +
"\anode_id\x18\x03 \x01(\fR\x06nodeId\"\x81\x03\n" +
"\x04Peer\x12\x1d\n" +
"\n" +
"public_key\x18\x01 \x01(\fR\tpublicKey\x12\x17\n" +
"\anode_id\x18\x02 \x01(\fR\x06nodeId\x12/\n" +
"\taddresses\x18\x03 \x03(\v2\x11.tari.rpc.AddressR\taddresses\x12'\n" +
"\x0flast_connection\x18\x04 \x01(\x04R\x0elastConnection\x12\x14\n" +
"\x05flags\x18\x05 \x01(\rR\x05flags\x12!\n" +
"\fbanned_until\x18\x06 \x01(\x04R\vbannedUntil\x12#\n" +
"\rbanned_reason\x18\a \x01(\tR\fbannedReason\x12\x1d\n" +
"\n" +
"offline_at\x18\b \x01(\x04R\tofflineAt\x12\x1a\n" +
"\bfeatures\x18\t \x01(\rR\bfeatures\x12/\n" +
"\x13supported_protocols\x18\v \x03(\fR\x12supportedProtocols\x12\x1d\n" +
"\n" +
"user_agent\x18\f \x01(\tR\tuserAgent\"\xa5\x01\n" +
"\x15NetworkStatusResponse\x124\n" +
"\x06status\x18\x01 \x01(\x0e2\x1c.tari.rpc.ConnectivityStatusR\x06status\x12$\n" +
"\x0eavg_latency_ms\x18\x02 \x01(\rR\favgLatencyMs\x120\n" +
"\x14num_node_connections\x18\x03 \x01(\rR\x12numNodeConnections\"\xac\x01\n" +
"\aAddress\x12\x18\n" +
"\aaddress\x18\x01 \x01(\fR\aaddress\x12\x1b\n" +
"\tlast_seen\x18\x02 \x01(\tR\blastSeen\x12/\n" +
"\x13connection_attempts\x18\x03 \x01(\rR\x12connectionAttempts\x129\n" +
"\vavg_latency\x18\x05 \x01(\v2\x18.tari.rpc.AverageLatencyR\n" +
"avgLatency\"*\n" +
"\x0eAverageLatency\x12\x18\n" +
"\alatency\x18\x01 \x01(\x04R\alatency\"U\n" +
"\x1aListConnectedPeersResponse\x127\n" +
"\x0fconnected_peers\x18\x01 \x03(\v2\x0e.tari.rpc.PeerR\x0econnectedPeers\"~\n" +
"\x0eSoftwareUpdate\x12\x1d\n" +
"\n" +
"has_update\x18\x01 \x01(\bR\thasUpdate\x12\x18\n" +
"\aversion\x18\x02 \x01(\tR\aversion\x12\x10\n" +
"\x03sha\x18\x03 \x01(\tR\x03sha\x12!\n" +
"\fdownload_url\x18\x04 \x01(\tR\vdownloadUrl\"\x14\n" +
"\x12GetIdentityRequest\"t\n" +
"\x13GetIdentityResponse\x12\x1d\n" +
"\n" +
"public_key\x18\x01 \x01(\fR\tpublicKey\x12%\n" +
"\x0epublic_address\x18\x02 \x01(\tR\rpublicAddress\x12\x17\n" +
"\anode_id\x18\x03 \x01(\fR\x06nodeId*M\n" +
"\x12ConnectivityStatus\x12\x10\n" +
"\fInitializing\x10\x00\x12\n" +
"\n" +
"\x06Online\x10\x01\x12\f\n" +
"\bDegraded\x10\x02\x12\v\n" +
"\aOffline\x10\x03B*Z(pool/internal/gbt/tari/net_work;net_workb\x06proto3"
var (
file_network_proto_rawDescOnce sync.Once
file_network_proto_rawDescData []byte
)
func file_network_proto_rawDescGZIP() []byte {
file_network_proto_rawDescOnce.Do(func() {
file_network_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_network_proto_rawDesc), len(file_network_proto_rawDesc)))
})
return file_network_proto_rawDescData
}
var file_network_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
var file_network_proto_msgTypes = make([]protoimpl.MessageInfo, 9)
var file_network_proto_goTypes = []any{
(ConnectivityStatus)(0), // 0: tari.rpc.ConnectivityStatus
(*NodeIdentity)(nil), // 1: tari.rpc.NodeIdentity
(*Peer)(nil), // 2: tari.rpc.Peer
(*NetworkStatusResponse)(nil), // 3: tari.rpc.NetworkStatusResponse
(*Address)(nil), // 4: tari.rpc.Address
(*AverageLatency)(nil), // 5: tari.rpc.AverageLatency
(*ListConnectedPeersResponse)(nil), // 6: tari.rpc.ListConnectedPeersResponse
(*SoftwareUpdate)(nil), // 7: tari.rpc.SoftwareUpdate
(*GetIdentityRequest)(nil), // 8: tari.rpc.GetIdentityRequest
(*GetIdentityResponse)(nil), // 9: tari.rpc.GetIdentityResponse
}
var file_network_proto_depIdxs = []int32{
4, // 0: tari.rpc.Peer.addresses:type_name -> tari.rpc.Address
0, // 1: tari.rpc.NetworkStatusResponse.status:type_name -> tari.rpc.ConnectivityStatus
5, // 2: tari.rpc.Address.avg_latency:type_name -> tari.rpc.AverageLatency
2, // 3: tari.rpc.ListConnectedPeersResponse.connected_peers:type_name -> tari.rpc.Peer
4, // [4:4] is the sub-list for method output_type
4, // [4:4] is the sub-list for method input_type
4, // [4:4] is the sub-list for extension type_name
4, // [4:4] is the sub-list for extension extendee
0, // [0:4] is the sub-list for field type_name
}
func init() { file_network_proto_init() }
func file_network_proto_init() {
if File_network_proto != nil {
return
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_network_proto_rawDesc), len(file_network_proto_rawDesc)),
NumEnums: 1,
NumMessages: 9,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_network_proto_goTypes,
DependencyIndexes: file_network_proto_depIdxs,
EnumInfos: file_network_proto_enumTypes,
MessageInfos: file_network_proto_msgTypes,
}.Build()
File_network_proto = out.File
file_network_proto_goTypes = nil
file_network_proto_depIdxs = nil
}

View File

@ -0,0 +1,97 @@
// Copyright 2020. The Tari Project
//
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
// following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
// disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
// following disclaimer in the documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote
// products derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// 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.
syntax = "proto3";
package tari.rpc;
import "google/protobuf/timestamp.proto";
message NodeIdentity {
bytes public_key = 1;
repeated string public_addresses = 2;
bytes node_id = 3;
}
message Peer {
/// Public key of the peer
bytes public_key =1;
/// NodeId of the peer
bytes node_id =2;
/// Peer's addresses
repeated Address addresses = 3;
/// Last connection attempt to peer
uint64 last_connection = 4;
/// Flags for the peer.
uint32 flags = 5;
uint64 banned_until= 6;
string banned_reason= 7;
uint64 offline_at = 8;
/// Features supported by the peer
uint32 features = 9;
/// used as information for more efficient protocol negotiation.
repeated bytes supported_protocols = 11;
/// User agent advertised by the peer
string user_agent = 12;
}
enum ConnectivityStatus {
Initializing = 0;
Online = 1;
Degraded = 2;
Offline = 3;
}
message NetworkStatusResponse {
ConnectivityStatus status = 1;
uint32 avg_latency_ms = 2;
uint32 num_node_connections = 3;
}
message Address{
bytes address =1;
string last_seen = 2;
uint32 connection_attempts = 3;
AverageLatency avg_latency = 5;
}
message AverageLatency {
uint64 latency = 1;
}
message ListConnectedPeersResponse {
repeated Peer connected_peers = 1;
}
message SoftwareUpdate {
bool has_update = 1;
string version = 2;
string sha = 3;
string download_url = 4;
}
message GetIdentityRequest { }
message GetIdentityResponse {
bytes public_key = 1;
string public_address = 2;
bytes node_id = 3;
}

View File

@ -0,0 +1,61 @@
// Copyright 2024. The Tari Project
//
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
// following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
// disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
// following disclaimer in the documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote
// products derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// 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.
syntax = "proto3";
package tari.rpc;
import "base_node.proto";
import "block.proto";
service ShaP2Pool {
rpc GetTipInfo(GetTipInfoRequest) returns(GetTipInfoResponse);
rpc GetNewBlock(GetNewBlockRequest) returns(GetNewBlockResponse);
rpc SubmitBlock(SubmitBlockRequest) returns(tari.rpc.SubmitBlockResponse);
}
message GetTipInfoRequest {
}
message GetTipInfoResponse {
uint64 node_height = 1;
bytes node_tip_hash = 2;
uint64 p2pool_rx_height = 3;
bytes p2pool_rx_tip_hash = 4;
uint64 p2pool_sha_height = 5;
bytes p2pool_sha_tip_hash = 6;
}
message GetNewBlockRequest {
tari.rpc.PowAlgo pow = 1;
string coinbase_extra = 2;
string wallet_payment_address = 3;
}
message GetNewBlockResponse {
tari.rpc.GetNewBlockResult block = 1;
uint64 target_difficulty = 2;
}
message SubmitBlockRequest {
tari.rpc.Block block = 1;
string wallet_payment_address = 2;
}

View File

@ -0,0 +1,77 @@
// Copyright 2020. The Tari Project
//
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
// following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
// disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
// following disclaimer in the documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote
// products derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// 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.
syntax = "proto3";
package tari.rpc;
import "types.proto";
message SideChainFeature {
oneof side_chain_feature {
ValidatorNodeRegistration validator_node_registration = 1;
TemplateRegistration template_registration = 2;
ConfidentialOutputData confidential_output = 3;
}
}
message ValidatorNodeRegistration {
bytes public_key = 1;
Signature signature = 2;
}
message TemplateRegistration {
bytes author_public_key = 1;
Signature author_signature = 2;
string template_name = 3;
uint32 template_version = 4;
TemplateType template_type = 5;
BuildInfo build_info = 6;
bytes binary_sha = 7;
string binary_url = 8;
}
message ConfidentialOutputData {
bytes claim_public_key = 1;
}
message TemplateType {
oneof template_type {
WasmInfo wasm = 1;
FlowInfo flow = 2;
ManifestInfo manifest = 3;
}
}
message WasmInfo {
uint32 abi_version = 1;
}
message FlowInfo {
}
message ManifestInfo {
}
message BuildInfo {
string repo_url = 1;
bytes commit_hash = 2;
}

View File

@ -0,0 +1,727 @@
// Copyright 2020. The Tari Project
//
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
// following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
// disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
// following disclaimer in the documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote
// products derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// 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.
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.6
// protoc v3.6.1
// source: sidechain_types.proto
package sidechain_types
import (
types "pool/internal/server/proxy/proto/types"
reflect "reflect"
sync "sync"
unsafe "unsafe"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type SideChainFeature struct {
state protoimpl.MessageState `protogen:"open.v1"`
// Types that are valid to be assigned to SideChainFeature:
//
// *SideChainFeature_ValidatorNodeRegistration
// *SideChainFeature_TemplateRegistration
// *SideChainFeature_ConfidentialOutput
SideChainFeature isSideChainFeature_SideChainFeature `protobuf_oneof:"side_chain_feature"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *SideChainFeature) Reset() {
*x = SideChainFeature{}
mi := &file_sidechain_types_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *SideChainFeature) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*SideChainFeature) ProtoMessage() {}
func (x *SideChainFeature) ProtoReflect() protoreflect.Message {
mi := &file_sidechain_types_proto_msgTypes[0]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use SideChainFeature.ProtoReflect.Descriptor instead.
func (*SideChainFeature) Descriptor() ([]byte, []int) {
return file_sidechain_types_proto_rawDescGZIP(), []int{0}
}
func (x *SideChainFeature) GetSideChainFeature() isSideChainFeature_SideChainFeature {
if x != nil {
return x.SideChainFeature
}
return nil
}
func (x *SideChainFeature) GetValidatorNodeRegistration() *ValidatorNodeRegistration {
if x != nil {
if x, ok := x.SideChainFeature.(*SideChainFeature_ValidatorNodeRegistration); ok {
return x.ValidatorNodeRegistration
}
}
return nil
}
func (x *SideChainFeature) GetTemplateRegistration() *TemplateRegistration {
if x != nil {
if x, ok := x.SideChainFeature.(*SideChainFeature_TemplateRegistration); ok {
return x.TemplateRegistration
}
}
return nil
}
func (x *SideChainFeature) GetConfidentialOutput() *ConfidentialOutputData {
if x != nil {
if x, ok := x.SideChainFeature.(*SideChainFeature_ConfidentialOutput); ok {
return x.ConfidentialOutput
}
}
return nil
}
type isSideChainFeature_SideChainFeature interface {
isSideChainFeature_SideChainFeature()
}
type SideChainFeature_ValidatorNodeRegistration struct {
ValidatorNodeRegistration *ValidatorNodeRegistration `protobuf:"bytes,1,opt,name=validator_node_registration,json=validatorNodeRegistration,proto3,oneof"`
}
type SideChainFeature_TemplateRegistration struct {
TemplateRegistration *TemplateRegistration `protobuf:"bytes,2,opt,name=template_registration,json=templateRegistration,proto3,oneof"`
}
type SideChainFeature_ConfidentialOutput struct {
ConfidentialOutput *ConfidentialOutputData `protobuf:"bytes,3,opt,name=confidential_output,json=confidentialOutput,proto3,oneof"`
}
func (*SideChainFeature_ValidatorNodeRegistration) isSideChainFeature_SideChainFeature() {}
func (*SideChainFeature_TemplateRegistration) isSideChainFeature_SideChainFeature() {}
func (*SideChainFeature_ConfidentialOutput) isSideChainFeature_SideChainFeature() {}
type ValidatorNodeRegistration struct {
state protoimpl.MessageState `protogen:"open.v1"`
PublicKey []byte `protobuf:"bytes,1,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"`
Signature *types.Signature `protobuf:"bytes,2,opt,name=signature,proto3" json:"signature,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *ValidatorNodeRegistration) Reset() {
*x = ValidatorNodeRegistration{}
mi := &file_sidechain_types_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *ValidatorNodeRegistration) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ValidatorNodeRegistration) ProtoMessage() {}
func (x *ValidatorNodeRegistration) ProtoReflect() protoreflect.Message {
mi := &file_sidechain_types_proto_msgTypes[1]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ValidatorNodeRegistration.ProtoReflect.Descriptor instead.
func (*ValidatorNodeRegistration) Descriptor() ([]byte, []int) {
return file_sidechain_types_proto_rawDescGZIP(), []int{1}
}
func (x *ValidatorNodeRegistration) GetPublicKey() []byte {
if x != nil {
return x.PublicKey
}
return nil
}
func (x *ValidatorNodeRegistration) GetSignature() *types.Signature {
if x != nil {
return x.Signature
}
return nil
}
type TemplateRegistration struct {
state protoimpl.MessageState `protogen:"open.v1"`
AuthorPublicKey []byte `protobuf:"bytes,1,opt,name=author_public_key,json=authorPublicKey,proto3" json:"author_public_key,omitempty"`
AuthorSignature *types.Signature `protobuf:"bytes,2,opt,name=author_signature,json=authorSignature,proto3" json:"author_signature,omitempty"`
TemplateName string `protobuf:"bytes,3,opt,name=template_name,json=templateName,proto3" json:"template_name,omitempty"`
TemplateVersion uint32 `protobuf:"varint,4,opt,name=template_version,json=templateVersion,proto3" json:"template_version,omitempty"`
TemplateType *TemplateType `protobuf:"bytes,5,opt,name=template_type,json=templateType,proto3" json:"template_type,omitempty"`
BuildInfo *BuildInfo `protobuf:"bytes,6,opt,name=build_info,json=buildInfo,proto3" json:"build_info,omitempty"`
BinarySha []byte `protobuf:"bytes,7,opt,name=binary_sha,json=binarySha,proto3" json:"binary_sha,omitempty"`
BinaryUrl string `protobuf:"bytes,8,opt,name=binary_url,json=binaryUrl,proto3" json:"binary_url,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *TemplateRegistration) Reset() {
*x = TemplateRegistration{}
mi := &file_sidechain_types_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *TemplateRegistration) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*TemplateRegistration) ProtoMessage() {}
func (x *TemplateRegistration) ProtoReflect() protoreflect.Message {
mi := &file_sidechain_types_proto_msgTypes[2]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use TemplateRegistration.ProtoReflect.Descriptor instead.
func (*TemplateRegistration) Descriptor() ([]byte, []int) {
return file_sidechain_types_proto_rawDescGZIP(), []int{2}
}
func (x *TemplateRegistration) GetAuthorPublicKey() []byte {
if x != nil {
return x.AuthorPublicKey
}
return nil
}
func (x *TemplateRegistration) GetAuthorSignature() *types.Signature {
if x != nil {
return x.AuthorSignature
}
return nil
}
func (x *TemplateRegistration) GetTemplateName() string {
if x != nil {
return x.TemplateName
}
return ""
}
func (x *TemplateRegistration) GetTemplateVersion() uint32 {
if x != nil {
return x.TemplateVersion
}
return 0
}
func (x *TemplateRegistration) GetTemplateType() *TemplateType {
if x != nil {
return x.TemplateType
}
return nil
}
func (x *TemplateRegistration) GetBuildInfo() *BuildInfo {
if x != nil {
return x.BuildInfo
}
return nil
}
func (x *TemplateRegistration) GetBinarySha() []byte {
if x != nil {
return x.BinarySha
}
return nil
}
func (x *TemplateRegistration) GetBinaryUrl() string {
if x != nil {
return x.BinaryUrl
}
return ""
}
type ConfidentialOutputData struct {
state protoimpl.MessageState `protogen:"open.v1"`
ClaimPublicKey []byte `protobuf:"bytes,1,opt,name=claim_public_key,json=claimPublicKey,proto3" json:"claim_public_key,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *ConfidentialOutputData) Reset() {
*x = ConfidentialOutputData{}
mi := &file_sidechain_types_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *ConfidentialOutputData) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ConfidentialOutputData) ProtoMessage() {}
func (x *ConfidentialOutputData) ProtoReflect() protoreflect.Message {
mi := &file_sidechain_types_proto_msgTypes[3]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ConfidentialOutputData.ProtoReflect.Descriptor instead.
func (*ConfidentialOutputData) Descriptor() ([]byte, []int) {
return file_sidechain_types_proto_rawDescGZIP(), []int{3}
}
func (x *ConfidentialOutputData) GetClaimPublicKey() []byte {
if x != nil {
return x.ClaimPublicKey
}
return nil
}
type TemplateType struct {
state protoimpl.MessageState `protogen:"open.v1"`
// Types that are valid to be assigned to TemplateType:
//
// *TemplateType_Wasm
// *TemplateType_Flow
// *TemplateType_Manifest
TemplateType isTemplateType_TemplateType `protobuf_oneof:"template_type"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *TemplateType) Reset() {
*x = TemplateType{}
mi := &file_sidechain_types_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *TemplateType) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*TemplateType) ProtoMessage() {}
func (x *TemplateType) ProtoReflect() protoreflect.Message {
mi := &file_sidechain_types_proto_msgTypes[4]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use TemplateType.ProtoReflect.Descriptor instead.
func (*TemplateType) Descriptor() ([]byte, []int) {
return file_sidechain_types_proto_rawDescGZIP(), []int{4}
}
func (x *TemplateType) GetTemplateType() isTemplateType_TemplateType {
if x != nil {
return x.TemplateType
}
return nil
}
func (x *TemplateType) GetWasm() *WasmInfo {
if x != nil {
if x, ok := x.TemplateType.(*TemplateType_Wasm); ok {
return x.Wasm
}
}
return nil
}
func (x *TemplateType) GetFlow() *FlowInfo {
if x != nil {
if x, ok := x.TemplateType.(*TemplateType_Flow); ok {
return x.Flow
}
}
return nil
}
func (x *TemplateType) GetManifest() *ManifestInfo {
if x != nil {
if x, ok := x.TemplateType.(*TemplateType_Manifest); ok {
return x.Manifest
}
}
return nil
}
type isTemplateType_TemplateType interface {
isTemplateType_TemplateType()
}
type TemplateType_Wasm struct {
Wasm *WasmInfo `protobuf:"bytes,1,opt,name=wasm,proto3,oneof"`
}
type TemplateType_Flow struct {
Flow *FlowInfo `protobuf:"bytes,2,opt,name=flow,proto3,oneof"`
}
type TemplateType_Manifest struct {
Manifest *ManifestInfo `protobuf:"bytes,3,opt,name=manifest,proto3,oneof"`
}
func (*TemplateType_Wasm) isTemplateType_TemplateType() {}
func (*TemplateType_Flow) isTemplateType_TemplateType() {}
func (*TemplateType_Manifest) isTemplateType_TemplateType() {}
type WasmInfo struct {
state protoimpl.MessageState `protogen:"open.v1"`
AbiVersion uint32 `protobuf:"varint,1,opt,name=abi_version,json=abiVersion,proto3" json:"abi_version,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *WasmInfo) Reset() {
*x = WasmInfo{}
mi := &file_sidechain_types_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *WasmInfo) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*WasmInfo) ProtoMessage() {}
func (x *WasmInfo) ProtoReflect() protoreflect.Message {
mi := &file_sidechain_types_proto_msgTypes[5]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use WasmInfo.ProtoReflect.Descriptor instead.
func (*WasmInfo) Descriptor() ([]byte, []int) {
return file_sidechain_types_proto_rawDescGZIP(), []int{5}
}
func (x *WasmInfo) GetAbiVersion() uint32 {
if x != nil {
return x.AbiVersion
}
return 0
}
type FlowInfo struct {
state protoimpl.MessageState `protogen:"open.v1"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *FlowInfo) Reset() {
*x = FlowInfo{}
mi := &file_sidechain_types_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *FlowInfo) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*FlowInfo) ProtoMessage() {}
func (x *FlowInfo) ProtoReflect() protoreflect.Message {
mi := &file_sidechain_types_proto_msgTypes[6]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use FlowInfo.ProtoReflect.Descriptor instead.
func (*FlowInfo) Descriptor() ([]byte, []int) {
return file_sidechain_types_proto_rawDescGZIP(), []int{6}
}
type ManifestInfo struct {
state protoimpl.MessageState `protogen:"open.v1"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *ManifestInfo) Reset() {
*x = ManifestInfo{}
mi := &file_sidechain_types_proto_msgTypes[7]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *ManifestInfo) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ManifestInfo) ProtoMessage() {}
func (x *ManifestInfo) ProtoReflect() protoreflect.Message {
mi := &file_sidechain_types_proto_msgTypes[7]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ManifestInfo.ProtoReflect.Descriptor instead.
func (*ManifestInfo) Descriptor() ([]byte, []int) {
return file_sidechain_types_proto_rawDescGZIP(), []int{7}
}
type BuildInfo struct {
state protoimpl.MessageState `protogen:"open.v1"`
RepoUrl string `protobuf:"bytes,1,opt,name=repo_url,json=repoUrl,proto3" json:"repo_url,omitempty"`
CommitHash []byte `protobuf:"bytes,2,opt,name=commit_hash,json=commitHash,proto3" json:"commit_hash,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *BuildInfo) Reset() {
*x = BuildInfo{}
mi := &file_sidechain_types_proto_msgTypes[8]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *BuildInfo) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*BuildInfo) ProtoMessage() {}
func (x *BuildInfo) ProtoReflect() protoreflect.Message {
mi := &file_sidechain_types_proto_msgTypes[8]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use BuildInfo.ProtoReflect.Descriptor instead.
func (*BuildInfo) Descriptor() ([]byte, []int) {
return file_sidechain_types_proto_rawDescGZIP(), []int{8}
}
func (x *BuildInfo) GetRepoUrl() string {
if x != nil {
return x.RepoUrl
}
return ""
}
func (x *BuildInfo) GetCommitHash() []byte {
if x != nil {
return x.CommitHash
}
return nil
}
var File_sidechain_types_proto protoreflect.FileDescriptor
const file_sidechain_types_proto_rawDesc = "" +
"\n" +
"\x15sidechain_types.proto\x12\btari.rpc\x1a\vtypes.proto\"\xbb\x02\n" +
"\x10SideChainFeature\x12e\n" +
"\x1bvalidator_node_registration\x18\x01 \x01(\v2#.tari.rpc.ValidatorNodeRegistrationH\x00R\x19validatorNodeRegistration\x12U\n" +
"\x15template_registration\x18\x02 \x01(\v2\x1e.tari.rpc.TemplateRegistrationH\x00R\x14templateRegistration\x12S\n" +
"\x13confidential_output\x18\x03 \x01(\v2 .tari.rpc.ConfidentialOutputDataH\x00R\x12confidentialOutputB\x14\n" +
"\x12side_chain_feature\"m\n" +
"\x19ValidatorNodeRegistration\x12\x1d\n" +
"\n" +
"public_key\x18\x01 \x01(\fR\tpublicKey\x121\n" +
"\tsignature\x18\x02 \x01(\v2\x13.tari.rpc.SignatureR\tsignature\"\x81\x03\n" +
"\x14TemplateRegistration\x12*\n" +
"\x11author_public_key\x18\x01 \x01(\fR\x0fauthorPublicKey\x12>\n" +
"\x10author_signature\x18\x02 \x01(\v2\x13.tari.rpc.SignatureR\x0fauthorSignature\x12#\n" +
"\rtemplate_name\x18\x03 \x01(\tR\ftemplateName\x12)\n" +
"\x10template_version\x18\x04 \x01(\rR\x0ftemplateVersion\x12;\n" +
"\rtemplate_type\x18\x05 \x01(\v2\x16.tari.rpc.TemplateTypeR\ftemplateType\x122\n" +
"\n" +
"build_info\x18\x06 \x01(\v2\x13.tari.rpc.BuildInfoR\tbuildInfo\x12\x1d\n" +
"\n" +
"binary_sha\x18\a \x01(\fR\tbinarySha\x12\x1d\n" +
"\n" +
"binary_url\x18\b \x01(\tR\tbinaryUrl\"B\n" +
"\x16ConfidentialOutputData\x12(\n" +
"\x10claim_public_key\x18\x01 \x01(\fR\x0eclaimPublicKey\"\xa9\x01\n" +
"\fTemplateType\x12(\n" +
"\x04wasm\x18\x01 \x01(\v2\x12.tari.rpc.WasmInfoH\x00R\x04wasm\x12(\n" +
"\x04flow\x18\x02 \x01(\v2\x12.tari.rpc.FlowInfoH\x00R\x04flow\x124\n" +
"\bmanifest\x18\x03 \x01(\v2\x16.tari.rpc.ManifestInfoH\x00R\bmanifestB\x0f\n" +
"\rtemplate_type\"+\n" +
"\bWasmInfo\x12\x1f\n" +
"\vabi_version\x18\x01 \x01(\rR\n" +
"abiVersion\"\n" +
"\n" +
"\bFlowInfo\"\x0e\n" +
"\fManifestInfo\"G\n" +
"\tBuildInfo\x12\x19\n" +
"\brepo_url\x18\x01 \x01(\tR\arepoUrl\x12\x1f\n" +
"\vcommit_hash\x18\x02 \x01(\fR\n" +
"commitHashB8Z6pool/internal/gbt/tari/sidechain_types;sidechain_typesb\x06proto3"
var (
file_sidechain_types_proto_rawDescOnce sync.Once
file_sidechain_types_proto_rawDescData []byte
)
func file_sidechain_types_proto_rawDescGZIP() []byte {
file_sidechain_types_proto_rawDescOnce.Do(func() {
file_sidechain_types_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_sidechain_types_proto_rawDesc), len(file_sidechain_types_proto_rawDesc)))
})
return file_sidechain_types_proto_rawDescData
}
var file_sidechain_types_proto_msgTypes = make([]protoimpl.MessageInfo, 9)
var file_sidechain_types_proto_goTypes = []any{
(*SideChainFeature)(nil), // 0: tari.rpc.SideChainFeature
(*ValidatorNodeRegistration)(nil), // 1: tari.rpc.ValidatorNodeRegistration
(*TemplateRegistration)(nil), // 2: tari.rpc.TemplateRegistration
(*ConfidentialOutputData)(nil), // 3: tari.rpc.ConfidentialOutputData
(*TemplateType)(nil), // 4: tari.rpc.TemplateType
(*WasmInfo)(nil), // 5: tari.rpc.WasmInfo
(*FlowInfo)(nil), // 6: tari.rpc.FlowInfo
(*ManifestInfo)(nil), // 7: tari.rpc.ManifestInfo
(*BuildInfo)(nil), // 8: tari.rpc.BuildInfo
(*types.Signature)(nil), // 9: tari.rpc.Signature
}
var file_sidechain_types_proto_depIdxs = []int32{
1, // 0: tari.rpc.SideChainFeature.validator_node_registration:type_name -> tari.rpc.ValidatorNodeRegistration
2, // 1: tari.rpc.SideChainFeature.template_registration:type_name -> tari.rpc.TemplateRegistration
3, // 2: tari.rpc.SideChainFeature.confidential_output:type_name -> tari.rpc.ConfidentialOutputData
9, // 3: tari.rpc.ValidatorNodeRegistration.signature:type_name -> tari.rpc.Signature
9, // 4: tari.rpc.TemplateRegistration.author_signature:type_name -> tari.rpc.Signature
4, // 5: tari.rpc.TemplateRegistration.template_type:type_name -> tari.rpc.TemplateType
8, // 6: tari.rpc.TemplateRegistration.build_info:type_name -> tari.rpc.BuildInfo
5, // 7: tari.rpc.TemplateType.wasm:type_name -> tari.rpc.WasmInfo
6, // 8: tari.rpc.TemplateType.flow:type_name -> tari.rpc.FlowInfo
7, // 9: tari.rpc.TemplateType.manifest:type_name -> tari.rpc.ManifestInfo
10, // [10:10] is the sub-list for method output_type
10, // [10:10] is the sub-list for method input_type
10, // [10:10] is the sub-list for extension type_name
10, // [10:10] is the sub-list for extension extendee
0, // [0:10] is the sub-list for field type_name
}
func init() { file_sidechain_types_proto_init() }
func file_sidechain_types_proto_init() {
if File_sidechain_types_proto != nil {
return
}
file_sidechain_types_proto_msgTypes[0].OneofWrappers = []any{
(*SideChainFeature_ValidatorNodeRegistration)(nil),
(*SideChainFeature_TemplateRegistration)(nil),
(*SideChainFeature_ConfidentialOutput)(nil),
}
file_sidechain_types_proto_msgTypes[4].OneofWrappers = []any{
(*TemplateType_Wasm)(nil),
(*TemplateType_Flow)(nil),
(*TemplateType_Manifest)(nil),
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_sidechain_types_proto_rawDesc), len(file_sidechain_types_proto_rawDesc)),
NumEnums: 0,
NumMessages: 9,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_sidechain_types_proto_goTypes,
DependencyIndexes: file_sidechain_types_proto_depIdxs,
MessageInfos: file_sidechain_types_proto_msgTypes,
}.Build()
File_sidechain_types_proto = out.File
file_sidechain_types_proto_goTypes = nil
file_sidechain_types_proto_depIdxs = nil
}

View File

@ -0,0 +1,188 @@
// Copyright 2020. The Tari Project
//
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
// following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
// disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
// following disclaimer in the documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote
// products derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// 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.
syntax = "proto3";
package tari.rpc;
import "types.proto";
import "sidechain_types.proto";
// The transaction kernel tracks the excess for a given transaction. For an explanation of what the excess is, and
// why it is necessary, refer to the
// [Mimblewimble TLU post](https://tlu.tarilabs.com/protocols/mimblewimble-1/sources/PITCHME.link.html?highlight=mimblewimble#mimblewimble).
// The kernel also tracks other transaction metadata, such as the lock height for the transaction (i.e. the earliest
// this transaction can be mined) and the transaction fee, in cleartext.
message TransactionKernel {
// Options for a kernel's structure or use
uint32 features = 1;
/// Fee originally included in the transaction this proof is for (in MicroMinotari)
uint64 fee = 2;
// This kernel is not valid earlier than lock_height blocks
// The max lock_height of all *inputs* to this transaction
uint64 lock_height = 3;
// Remainder of the sum of all transaction commitments. If the transaction
// is well formed, amounts components should sum to zero and the excess
// is hence a valid public key.
bytes excess = 6;
// The signature proving the excess is a valid public key, which signs
// the transaction fee.
Signature excess_sig = 7;
// The hash of the kernel, as it appears in the MMR
bytes hash = 8;
// Version
uint32 version = 9;
// Optional burned commitment
bytes burn_commitment = 10;
}
// A transaction input.
//
// Primarily a reference to an output being spent by the transaction.
message TransactionInput {
// The features of the output being spent. We will check maturity for all outputs.
OutputFeatures features = 1;
// The commitment referencing the output being spent.
bytes commitment = 2;
// Hash of the input, as it appears in the MMR
bytes hash = 3;
// The serialised script
bytes script = 4;
// The script input data, if any
bytes input_data = 5;
// A signature with k_s, signing the script, input data, and mined height
ComAndPubSignature script_signature = 7;
// The offset public key, K_O
bytes sender_offset_public_key = 8;
// The hash of the output this input is spending
bytes output_hash = 9;
// Covenant
bytes covenant = 10;
// Version
uint32 version = 11;
// The encrypted data
bytes encrypted_data = 12;
// The minimum value of the commitment that is proven by the range proof (in MicroMinotari)
uint64 minimum_value_promise = 13;
// The metadata signature for output this input is spending
ComAndPubSignature metadata_signature = 14;
// The rangeproof hash for output this input is spending
bytes rangeproof_hash = 15;
}
// Output for a transaction, defining the new ownership of coins that are being transferred. The commitment is a
// blinded value for the output while the range proof guarantees the commitment includes a positive value without
// overflow and the ownership of the private key.
message TransactionOutput {
// Options for an output's structure or use
OutputFeatures features = 1;
// The homomorphic commitment representing the output amount
bytes commitment = 2;
// A proof that the commitment is in the right range
RangeProof range_proof = 3;
// The hash of the output, as it appears in the MMR
bytes hash = 4;
// Tari script serialised script
bytes script = 5;
// Tari script offset public key, K_O
bytes sender_offset_public_key = 6;
// Metadata signature with the homomorphic commitment private values (amount and blinding factor) and the sender
// offset private key
ComAndPubSignature metadata_signature = 7;
// Covenant
bytes covenant = 8;
// Version
uint32 version = 9;
// Encrypted Pedersen commitment openings (value and mask) for the output
bytes encrypted_data = 10;
// The minimum value of the commitment that is proven by the range proof (in MicroMinotari)
uint64 minimum_value_promise = 11;
// Payment reference (PayRef) - 32-byte Blake2b hash of (block_hash || output_hash)
// This provides a unique, deterministic reference for the output that can be used
// for payment verification without revealing wallet ownership
bytes payment_reference = 12;
}
// Options for UTXOs
message OutputFeatures {
// Version
uint32 version = 1;
// The type of output, eg Coinbase, all of which have different consensus rules
uint32 output_type = 2;
// The maturity of the specific UTXO. This is the min lock height at which an UTXO can be spend. Coinbase UTXO
// require a min maturity of the Coinbase_lock_height, this should be checked on receiving new blocks.
uint64 maturity = 3;
// Additional arbitrary info in coinbase transactions supplied by miners
bytes coinbase_extra = 4;
// Features that are specific to a side chain
SideChainFeature sidechain_feature = 5;
// The type of range proof used in the output
uint32 range_proof_type = 6;
}
// The components of the block or transaction. The same struct can be used for either, since in Mimblewimble,
// cut-through means that blocks and transactions have the same structure. The inputs, outputs and kernels should
// be sorted by their Blake2b-256bit digest hash
message AggregateBody {
// List of inputs spent by the transaction.
repeated TransactionInput inputs = 1;
// List of outputs the transaction produces.
repeated TransactionOutput outputs = 2;
// Kernels contain the excesses and their signatures for transaction
repeated TransactionKernel kernels = 3;
}
// A transaction which consists of a kernel offset and an aggregate body made up of inputs, outputs and kernels.
message Transaction {
bytes offset = 1;
AggregateBody body = 2;
bytes script_offset = 3;
}
message UnblindedOutput {
// Value of the output
uint64 value = 1;
// Spending key of the output
bytes spending_key = 2;
// Options for an output's structure or use
OutputFeatures features = 3;
// Tari script serialised script
bytes script = 4;
// Tari script input data for spending
bytes input_data = 5;
// Tari script private key
bytes script_private_key = 7;
// Tari script offset pubkey, K_O
bytes sender_offset_public_key = 8;
// UTXO signature with the script offset private key, k_O
ComAndPubSignature metadata_signature = 9;
// The minimum height the script allows this output to be spent
uint64 script_lock_height = 10;
// Covenant
bytes covenant = 11;
// Encrypted data
bytes encrypted_data = 12;
// The minimum value of the commitment that is proven by the range proof (in MicroMinotari)
uint64 minimum_value_promise = 13;
// The range proof
RangeProof range_proof = 14;
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,147 @@
// Copyright 2020. The Tari Project
//
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
// following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
// disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
// following disclaimer in the documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote
// products derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// 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.
syntax = "proto3";
package tari.rpc;
/// An unsigned range interface to more accurately represent Rust native Range's
message Range {
uint64 min = 1;
uint64 max = 2;
}
/// An Empty placeholder for endpoints without request parameters
message Empty {}
/// Define an interface for block height
message BlockHeight {
uint64 block_height = 1;
}
// Define the explicit Signature implementation for the Minotari base layer. A different signature scheme can be
// employed by redefining this type.
message Signature {
bytes public_nonce = 1;
bytes signature = 2;
}
// Define the explicit ComAndPubSignature implementation for the Minotari base layer. A different signature scheme can be
// employed by redefining this type.
message ComAndPubSignature {
bytes ephemeral_commitment = 1;
bytes ephemeral_pubkey = 2;
bytes u_a = 3;
bytes u_x = 4;
bytes u_y = 5;
}
// Define the explicit CommitmentSignature implementation for the Minotari base layer. A different signature scheme can be
// employed by redefining this type
message CommitmentSignature {
bytes public_nonce = 1;
bytes u = 2;
bytes v = 3;
}
/// PoW Algorithm constants
message PowAlgorithmConstants {
uint64 min_difficulty = 2;
uint64 max_difficulty = 3;
uint64 target_time = 4;
}
/// Weight params
message WeightParams {
uint64 kernel_weight = 1;
uint64 input_weight = 2;
uint64 output_weight = 3;
uint64 features_and_scripts_bytes_per_gram = 4;
}
/// Output version
message OutputsVersion {
Range outputs = 1;
Range features = 2;
}
/// Output types
enum OutputType {
STANDARD = 0;
COINBASE = 1;
BURN = 2;
VALIDATOR_NODE_REGISTRATION = 3;
CODE_TEMPLATE_REGISTRATION = 4;
}
/// Range proof types
enum RangeProofType {
BULLETPROOF_PLUS = 0;
REVEALED_VALUE = 1;
}
message PermittedRangeProofs {
OutputType output_type = 1;
repeated RangeProofType range_proof_types = 2;
}
/// Range proof
message RangeProof {
bytes proof_bytes = 1;
}
/// Consensus Constants response
message ConsensusConstants {
uint64 coinbase_min_maturity = 1;
uint32 blockchain_version = 2;
uint64 future_time_limit = 3;
uint64 difficulty_block_window = 5;
uint64 max_block_transaction_weight = 7;
uint64 pow_algo_count = 8;
uint64 median_timestamp_count = 9;
uint64 emission_initial = 10;
repeated uint64 emission_decay = 11;
uint64 emission_tail = 12 [deprecated=true];
uint64 min_sha3x_pow_difficulty = 13;
uint64 block_weight_inputs = 14;
uint64 block_weight_outputs = 15;
uint64 block_weight_kernels = 16;
uint64 pre_mine_value = 17;
uint64 max_script_byte_size = 18;
uint64 validator_node_validity_period = 19;
uint64 effective_from_height = 20;
Range valid_blockchain_version_range = 21;
uint64 max_randomx_seed_height = 22;
map<uint32, PowAlgorithmConstants> proof_of_work = 23;
WeightParams transaction_weight = 24;
Range input_version_range = 26;
OutputsVersion output_version_range = 27;
Range kernel_version_range = 28;
repeated OutputType permitted_output_types = 29;
uint64 epoch_length = 30;
uint64 validator_node_registration_min_deposit_amount = 31;
uint64 validator_node_registration_min_lock_height = 32;
uint64 validator_node_registration_shuffle_interval_epoch = 33;
repeated PermittedRangeProofs permitted_range_proof_types = 34;
uint64 inflation_bips = 35;
uint64 tail_epoch_length = 36;
uint64 max_block_coinbase_count = 37;
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,132 @@
// Copyright 2021. The Tari Project
//
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
// following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
// disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
// following disclaimer in the documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote
// products derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// 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.
syntax = "proto3";
import "types.proto";
import "network.proto";
import "transaction.proto";
package tari.rpc;
service ValidatorNode {
rpc GetIdentity(GetIdentityRequest) returns (GetIdentityResponse);
rpc GetMetadata(GetMetadataRequest) returns (GetMetadataResponse);
rpc GetTokenData(GetTokenDataRequest) returns (GetTokenDataResponse);
// rpc ExecuteInstruction(ExecuteInstructionRequest) returns (ExecuteInstructionResponse);
rpc InvokeReadMethod(InvokeReadMethodRequest) returns (InvokeReadMethodResponse);
rpc InvokeMethod(InvokeMethodRequest) returns (InvokeMethodResponse);
rpc GetConstitutionRequests(GetConstitutionRequestsRequest) returns (stream TransactionOutput);
rpc PublishContractAcceptance(PublishContractAcceptanceRequest) returns (PublishContractAcceptanceResponse);
rpc PublishContractUpdateProposalAcceptance(PublishContractUpdateProposalAcceptanceRequest) returns (PublishContractUpdateProposalAcceptanceResponse);
}
message GetConstitutionRequestsRequest {
// empty
}
message GetMetadataRequest {
// empty
}
message PublishContractAcceptanceRequest {
bytes contract_id = 1;
}
message PublishContractAcceptanceResponse {
string status = 1;
uint64 tx_id = 2;
}
message PublishContractUpdateProposalAcceptanceRequest {
bytes contract_id = 1;
uint64 proposal_id = 2;
}
message PublishContractUpdateProposalAcceptanceResponse {
string status = 1;
uint64 tx_id = 2;
}
message GetMetadataResponse {
repeated SidechainMetadata sidechains = 1;
}
message SidechainMetadata {
bytes asset_public_key =1;
uint64 committed_height = 2;
bytes committed_hash = 3;
}
message GetTokenDataRequest {
bytes asset_pub_key = 1;
bytes unique_id = 2;
}
message GetTokenDataResponse {
}
//message ExecuteInstructionRequest{
// bytes asset_public_key = 1;
// uint32 template_id = 2;
// string method = 3;
// bytes args = 4;
//// bytes token_id = 5;
//// bytes signature = 6;
//}
//
//message ExecuteInstructionResponse {
// string status = 1;
// optional bytes result = 2;
//}
message InvokeReadMethodRequest{
bytes contract_id = 1;
uint32 template_id = 2;
string method = 3;
bytes args = 4;
bytes sender = 5;
}
message InvokeReadMethodResponse {
bytes result = 1;
Authority authority = 2;
}
message Authority {
bytes node_public_key =1;
bytes signature = 2;
bytes proxied_by = 3;
}
message InvokeMethodRequest {
bytes contract_id = 1;
uint32 template_id = 2;
string method = 3;
bytes args = 4;
bytes sender = 5;
}
message InvokeMethodResponse {
string status = 1;
bytes result = 2;
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,165 @@
package proxy
import (
"context"
"crypto/rand"
"encoding/hex"
"fmt"
pb "pool/internal/server/proxy/proto"
block "pool/internal/server/proxy/proto/block"
transaction "pool/internal/server/proxy/proto/transaction"
"sync"
"google.golang.org/grpc"
)
// BaseNode客户端示例
type BaseNodeClient struct {
conn *grpc.ClientConn
client pb.BaseNodeClient
ctx context.Context
}
type NewBlockTemplateResponse struct {
NewBlockTemplate *block.NewBlockTemplate `json:"new_block_template"`
InitialSyncAchieved bool `json:"initial_sync_achieved"`
MinerData *pb.MinerData `json:"miner_data"`
}
type NewBlockTemplate struct {
Header *block.BlockHeader `json:"header"`
Body *transaction.AggregateBody `json:"body"`
}
// 创建BaseNode客户端
func NewBaseNodeClient(address string) (*BaseNodeClient, error) {
conn, err := grpc.Dial(address, grpc.WithInsecure())
if err != nil {
return nil, fmt.Errorf("failed to connect to base node: %v", err)
}
ctx := context.Background()
return &BaseNodeClient{
conn: conn,
client: pb.NewBaseNodeClient(conn),
ctx: ctx,
}, nil
}
type RandomxTJob struct {
JobID string `json:"job_id"`
SeedHash string `json:"seed_hash"`
Height uint64 `json:"height"`
MiningHash string `json:"mining_hash"`
Blob string `json:"blob"` // hash_blob
Difficulty uint64 `json:"diffculty"`
Header string `json:"header"`
Body string `json:"body"`
}
type MoneroNotify_params_msg struct {
Id string `json:"id"`
JobId string `json:"job_id"`
SeedHash string `json:"seed_hash"`
Blob string `json:"blob"`
Height uint32 `json:"height"`
Target string `json:"target"`
NextSeedHash string `json:"next_seed_hash"`
Algo string `json:"algo"`
}
type Monero_msg struct {
Jsonrpc string `json:"jsonrpc"`
Method string `json:"method"`
Params MoneroNotify_params_msg `json:"params"`
}
type MoneroAuthorize_reply struct {
ID float64 `json:"id"`
Jsonrpc string `json:"jsonrpc"`
Error interface{} `json:"error"`
Result MoneroJob `json:"result"`
}
type MoneroJob struct {
Id string `json:"id"`
Job MoneroNotify_params_msg `json:"job"`
Status string `json:"status"`
}
func randomxJobId() string {
// 生成4个字节
bytes := make([]byte, 4)
_, err := rand.Read(bytes)
if err != nil {
panic(err)
}
// 转成 hex 字符串
hexStr := hex.EncodeToString(bytes)
return hexStr
}
var jobs sync.Map
func (c *BaseNodeClient) get_randomxt_data() {
getblocktemplateReq := &pb.NewBlockTemplateRequest{
Algo: &block.PowAlgo{
PowAlgo: block.PowAlgo_POW_ALGOS_RANDOMXT, // 使用 SHA3X 算法
},
MaxWeight: 0x00ff, // 设置最大权重
}
blocktemplate, err := c.client.GetNewBlockTemplate(c.ctx, getblocktemplateReq)
if err != nil {
fmt.Println("get block template failed:", err)
return
}
synced := blocktemplate.InitialSyncAchieved
if !synced {
fmt.Println("chain doesn`t synced!")
return
}
diff := blocktemplate.MinerData.TargetDifficulty
template := blocktemplate.NewBlockTemplate
newblock, err := c.client.GetNewBlock(c.ctx, template)
if err != nil {
fmt.Println("get new block failed:", err)
return
}
height := newblock.Block.Header.Height
newblockblob, err := c.client.GetNewBlockBlob(c.ctx, template)
if err != nil {
fmt.Println("get new block blob failed:", err)
return
}
mining_hash_byte, vm_key_byte := newblock.BlockHash, newblock.VmKey
header_byte, body_byte := newblockblob.Header, newblockblob.BlockBody
// 构造tari-ranomdxt hashing_blob
// 3字节前导0 + 32字节mining_hash + 8字节nonce + 1字节pow_algo + 32字节pow_data
pilotZero := make([]byte, 3)
pow_algo := []byte{0x20}
pow_data := make([]byte, 32)
initNonce := make([]byte, 8)
hashing_blob := make([]byte, 76)
copy(hashing_blob[0:3], pilotZero) // 3字节
copy(hashing_blob[3:35], mining_hash_byte) // 32字节
copy(hashing_blob[35:43], initNonce) // 8字节
copy(hashing_blob[43:44], pow_algo) // 1字节
copy(hashing_blob[44:76], pow_data) // 32字节
jobId := randomxJobId()
var job RandomxTJob
job.MiningHash = hex.EncodeToString(mining_hash_byte)
job.Blob = hex.EncodeToString(hashing_blob)
job.Header = hex.EncodeToString(header_byte)
job.Body = hex.EncodeToString(body_byte)
job.Height = height
job.Difficulty = diff
job.SeedHash = hex.EncodeToString(vm_key_byte)
job.JobID = jobId
jobs.LoadOrStore(jobId, job)
}

View File

@ -26,49 +26,56 @@ import (
"go.uber.org/zap"
)
const SERVER_SHA3X_VERSION string = "sha3x v0.1a"
const SERVER_RANDOMXT_VERSION string = "randomxt v0.1a"
type Sha3xBlockHeader struct {
Nonce [8]byte
Header [32]byte
Algo byte
type RandomxTBlockHeader struct {
Zero [3]byte
Nonce [8]byte
Header [32]byte
Algo byte
PowData [32]byte
}
func Sha3xBlockHeaderToBytes(h Sha3xBlockHeader) []byte {
out := make([]byte, 8+32+1)
for i := 0; i < 8; i++ {
out[i] = h.Nonce[i]
func RandomxTBlockHeaderToBytes(miningHash string) []byte {
miningHashBytes, err := hex.DecodeString(miningHash)
if err != nil || len(miningHashBytes) != 32 {
return nil
}
for i := 0; i < 32; i++ {
out[8+i] = h.Header[i]
}
out[8+32] = h.Algo
out := make([]byte, 76)
copy(out[0:3], []byte{0x00, 0x00, 0x00})
copy(out[3:35], miningHashBytes)
// nonce 8 字节默认全 0无需手动赋值
out[43] = 0x02
// 最后 32 字节也默认全 0无需赋值
return out
}
type ServerSha3xContext struct {
type ServerRandomxContext struct {
ServerCtx *coin.ServerContext
logg *zap.Logger
Sha3xJob msg.Sha3xStratumJob
RandomxTJob msg.RandomxTStratumJob
}
var logg *zap.Logger
var ServerSha3xCtx ServerSha3xContext
var ServerSha3xCtx ServerRandomxContext
var vm *RandomXValidator
type Sha3xNotify_params_msg struct {
Algo string `json:"algo"`
Blob string `json:"blob"`
Height uint32 `json:"height"`
Job_id string `json:"job_id"`
Target string `json:"target"`
type RandomxTNotify_params_msg struct {
Algo string `json:"algo"` // "rx/0"
Blob string `json:"blob"`
Height uint32 `json:"height"`
Job_id string `json:"job_id"`
Target string `json:"target"`
SeedHash string `json:"seed_hash"`
Variant string `json:"variant"` // "rx/0"
}
type Sha3xNotify_msg struct {
Jsonrpc string `json:"jsonrpc"`
Method string `json:"method"`
Params Sha3xNotify_params_msg `json:"params"`
type RandomxTNotify_msg struct {
Jsonrpc string `json:"jsonrpc"`
Method string `json:"method"`
Params RandomxTNotify_params_msg `json:"params"`
}
func handle_submit(miner *coin.MinerObj, id float64, miner_user string, job_id string, nonce2 string, ntime string, nonce string) (bool, bool, bool) {
@ -98,7 +105,7 @@ func handle_submit(miner *coin.MinerObj, id float64, miner_user string, job_id s
//stratum.UpdateJobs(miner)
v, ok := miner.Jobs.Load(job_id)
if ok {
job := v.(msg.Sha3xStratumJob)
job := v.(msg.RandomxTStratumJob)
if job.Height < miner.CurHeight-1 {
ack.Result = false
@ -129,19 +136,25 @@ func handle_submit(miner *coin.MinerObj, id float64, miner_user string, job_id s
nb, _ := hex.DecodeString(nonce)
var calc_hash []byte
// var calc_hash []byte
var header Sha3xBlockHeader
for i := 0; i < 8; i++ {
header.Nonce[i] = nb[i]
// var header RandomxTBlockHeader
// for i := 0; i < 8; i++ {
// header.Nonce[i] = nb[i]
// }
// for i := 0; i < 32; i++ {
// header.Header[i] = phb[i]
// }
// header.Algo = 1
// header := miner.Server.RandomxTJob.Header
submit_item.Header = hex.EncodeToString(phb)
calc_hash, _, err := vm.BuildPowHash(phb, nb)
if err != nil {
ack.Result = false
stratum.Handle_exception(miner, id, stratum.MINER_ERR_UNKNOWN)
miner.ErrOthers = miner.ErrOthers + 1
return false, false, false
}
for i := 0; i < 32; i++ {
header.Header[i] = phb[i]
}
header.Algo = 1
submit_item.Header = hex.EncodeToString(Sha3xBlockHeaderToBytes(header))
calc_hash = BuildPowHash(header)
//logg.Debug("[server]", zap.String("hash in", submit_item.Header))
//calc_hash, header := util.BuildBlockHash(&(job), true, Build_PowHash)
//logg.Debug("[server]", zap.String("calc_hash", hex.EncodeToString(calc_hash)) /*, zap.String("merkle root", hex.EncodeToString(merkle_root))*/)
@ -455,7 +468,8 @@ func handle_submit(miner *coin.MinerObj, id float64, miner_user string, job_id s
return false, false, true
}
func Produce_block_submit(miner *coin.MinerObj /*header Sha3xBlockHeader,*/, job *msg.Sha3xStratumJob, PowHash string, SubIdx int64) {
func Produce_block_submit(miner *coin.MinerObj /*header Sha3xBlockHeader,*/, job *msg.RandomxTStratumJob, PowHash string, SubIdx int64) {
var nm msg.BlockSha3xMsg
nm.Id = job.Id
nm.Header = job.Header
@ -497,7 +511,7 @@ func Produce_block_submit(miner *coin.MinerObj /*header Sha3xBlockHeader,*/, job
}
if miner.Server.PubCh != nil {
//miner.Server.PubCh.SendChan <- [][]byte{[]byte("blksha3x"), []byte(blk)}
err := miner.Server.PubCh.SendMessage([][]byte{[]byte("blksha3x"), []byte(blk)})
err := miner.Server.PubCh.SendMessage([][]byte{[]byte("blkrandomxt"), []byte(blk)})
if err != nil {
miner.Server.PubCh.Destroy()
miner.Server.PubCh = nil
@ -509,12 +523,12 @@ func Produce_block_submit(miner *coin.MinerObj /*header Sha3xBlockHeader,*/, job
}
// server-->miner
func sha3x_parse_miner_notify(miner *coin.MinerObj, msg msg.Sha3xStratumJob) int {
func randomxT_parse_miner_notify(miner *coin.MinerObj, msg msg.RandomxTStratumJob) int {
if miner.Sha3xJob.Height != msg.Height {
miner.Job.IsClean = true
}
miner.Sha3xJob = msg
miner.Sha3xJob.Extranonce1 = miner.Job.Extranonce1
miner.RandomxTJob = msg
miner.RandomxTJob.Extranonce1 = miner.Job.Extranonce1
miner.Job.Extranonce2_size = msg.Extranonce2_size
//miner.Server.Logg.Info("[server]", zap.Int32("miner.Version", miner.Version), zap.Int32("msg.Version", msg.Version))
@ -524,7 +538,7 @@ func sha3x_parse_miner_notify(miner *coin.MinerObj, msg msg.Sha3xStratumJob) int
func Init(server *coin.ServerContext) {
ServerSha3xCtx.ServerCtx = server
logg = server.Logg
logg.Info("[server]", zap.String("server_sha3x_version", SERVER_SHA3X_VERSION))
logg.Info("[server]", zap.String("server_version", SERVER_RANDOMXT_VERSION))
coin.Init_diff_db()
}
@ -537,8 +551,8 @@ func Stop() {
}
func InitMiner(miner *coin.MinerObj) {
miner.Sha3xJob = miner.Server.Sha3xJob
miner.Sha3xJob.Extranonce1 = miner.Job.Extranonce1
miner.RandomxTJob = miner.Server.RandomxTJob
miner.RandomxTJob.Extranonce1 = miner.Job.Extranonce1
server_target := new(big.Int)
t_bytes, err := hex.DecodeString(miner.NexaJob.Target)
@ -596,18 +610,18 @@ func Sha3xNotify(miner *coin.MinerObj) {
miner.TxLock.Lock()
//log.Println("[server]extra1, id", miner.Job.Extranonce1, miner.Job.Job_id, miner.MinerId)
var msg Sha3xNotify_msg
var msg RandomxTNotify_msg
idb := make([]byte, 4)
binary.BigEndian.PutUint32(idb, miner.JobId)
miner.Job.Job_id = hex.EncodeToString(idb)
msg.Params.Algo = "sha3x"
msg.Params.Algo = "rx/0"
msg.Params.Variant = "rx/0"
msg.Params.SeedHash = miner.Server.RandomxTJob.SeedHash
msg.Params.Job_id = miner.Job.Job_id
msg.Params.Blob = miner.Sha3xJob.Header
msg.Params.Height = miner.Sha3xJob.Height
//target_s, _ := stratum.ReverseHexStringByByte(miner.Sha3xJob.Target)
//msg.Params.Target = target_s[48:]
msg.Params.Blob = miner.RandomxTJob.Header
msg.Params.Height = miner.RandomxTJob.Height
target_new, _ := utility.DiffToTarget(miner.Difficulty)
target_str := fmt.Sprintf("%064x", target_new.Bytes())
target_strr, strerr := stratum.ReverseHexStringByByte(target_str)
@ -617,11 +631,11 @@ func Sha3xNotify(miner *coin.MinerObj) {
//println("target=", target_str, "r=", target_strr)
msg.Params.Target = target_strr[48:]
miner.CurHeight = miner.Sha3xJob.Height
miner.CurHeight = miner.RandomxTJob.Height
miner.Sha3xJob.JobDifficulty = miner.Difficulty
miner.RandomxTJob.JobDifficulty = miner.Difficulty
miner.Jobs.LoadOrStore(miner.Job.Job_id, miner.Sha3xJob)
miner.Jobs.LoadOrStore(miner.Job.Job_id, miner.RandomxTJob)
/*var entry coin.JobListEntry
entry.Job_id = miner.Job.Job_id
@ -691,8 +705,11 @@ func formatUint64ToHexWithPadding(val uint64) string {
return hexStr
}
var last_seed_hash string = ""
func HandleJobMsg(server *coin.ServerContext, Msg []byte) {
var result msg.Sha3xStratumJob
vm = &RandomXValidator{} // 初始化vm虚拟机指针防止出现空指针报错
var result msg.RandomxTStratumJob
server.Logg.Warn("[server]", zap.String("receive", "job"))
if err := json.Unmarshal(Msg, &result); err != nil {
@ -701,21 +718,36 @@ func HandleJobMsg(server *coin.ServerContext, Msg []byte) {
}
result.Target = formatUint64ToHexWithPadding(result.U64target)
if last_seed_hash != result.SeedHash {
seed_hash_byte, err := hex.DecodeString(result.SeedHash)
if err != nil {
server.Logg.Error("[server]", zap.String("DecodeString", err.Error()))
return
}
vm, err = NewRandomXValidator(seed_hash_byte)
if err != nil {
server.Logg.Error("[server]", zap.String("NewRandomXValidator", err.Error()))
return
}
last_seed_hash = result.SeedHash
}
//target_new, _ := utility.DiffToTarget((float64)(result.U64target))
//target_str := fmt.Sprintf("%064x", target_new.Bytes())
//result.Target = target_str
server.Sha3xJob = msg.Sha3xStratumJob(result)
logg.Debug("[gbt]", zap.String("Target", server.Sha3xJob.Target))
server.RandomxTJob = msg.RandomxTStratumJob(result)
blobByte := RandomxTBlockHeaderToBytes(server.RandomxTJob.Header)
server.RandomxTJob.Header = hex.EncodeToString(blobByte)
logg.Debug("[gbt]", zap.String("Target", server.RandomxTJob.Target))
server.Sha3xJob.Extranonce2_size = 8
server.RandomxTJob.Extranonce2_size = 8
server.SJob.Extranonce2_size = 8
logg.Debug("[gbt]", zap.Uint32("Height", server.Sha3xJob.Height), zap.String("Target", server.Sha3xJob.Target), zap.String("Header", server.Sha3xJob.Header) /*, zap.Uint64("Timastamp", server.Sha3xJob.CurTime)*/)
targetb, _ := hex.DecodeString(server.Sha3xJob.Target)
logg.Debug("[gbt]", zap.Uint64("Id", server.Sha3xJob.Id), zap.Float64("network diff", utility.Target2Diff(utility.Reverse(targetb))))
logg.Debug("[gbt]", zap.Uint32("Height", server.RandomxTJob.Height), zap.String("Target", server.RandomxTJob.Target), zap.String("Header", server.RandomxTJob.Header) /*, zap.Uint64("Timastamp", server.Sha3xJob.CurTime)*/)
targetb, _ := hex.DecodeString(server.RandomxTJob.Target)
logg.Debug("[gbt]", zap.Uint64("Id", server.RandomxTJob.Id), zap.Float64("network diff", utility.Target2Diff(utility.Reverse(targetb))))
server.NetHight = uint64(server.Sha3xJob.Height)
server.NetTarget = server.Sha3xJob.Target
server.NetHight = uint64(server.RandomxTJob.Height)
server.NetTarget = server.RandomxTJob.Target
server.Miners.Range(func(k, v interface{}) bool {
if v != nil {
m, ok := v.(*(coin.MinerObj))
@ -724,7 +756,7 @@ func HandleJobMsg(server *coin.ServerContext, Msg []byte) {
server.Logg.Info("[server]", zap.String("lock", "start"))
m.TxLock.Lock()
status := m.Status
cmd := sha3x_parse_miner_notify(m, server.Sha3xJob)
cmd := randomxT_parse_miner_notify(m, server.RandomxTJob)
m.TxLock.Unlock()
server.Logg.Info("[server]", zap.String("lock", "end"))
var need_notify bool = true

View File

@ -15,16 +15,15 @@ import (
"log"
//"math/big"
"math/rand"
"net"
"os"
"os/signal"
"pool/internal/cache"
"pool/internal/db"
"pool/internal/server/coin"
"pool/internal/server/dbif"
"pool/internal/server/sha3x"
"math/rand"
"pool/internal/cache"
"pool/internal/server/randomxT"
"pool/internal/stratum"
"pool/internal/utility"
@ -129,20 +128,35 @@ var coinobjs = []coin.CoinObj{
// IsMhsLow: nexa.IsMhsLow,
// GetBlockInterval: nexa.GetBlockInterval,
// },
// {
// Coin: "sha3x",
// Init: sha3x.Init,
// Start: sha3x.Start,
// Stop: sha3x.Stop,
// InitMiner: sha3x.InitMiner,
// HandleMinerSubscribe: sha3x.HandleMinerSubscribe,
// HandleMinerAuth: sha3x.HandleMinerAuth,
// HandleMinerSubmit: sha3x.HandleMinerSubmit,
// SetDifficulty: sha3x.SetDifficulty,
// Notify: sha3x.Notify,
// HandleJobMsg: sha3x.HandleJobMsg,
// IsMhsLow: sha3x.IsMhsLow,
// GetBlockInterval: sha3x.GetBlockInterval,
// },
{
Coin: "sha3x",
Init: sha3x.Init,
Start: sha3x.Start,
Stop: sha3x.Stop,
InitMiner: sha3x.InitMiner,
HandleMinerSubscribe: sha3x.HandleMinerSubscribe,
HandleMinerAuth: sha3x.HandleMinerAuth,
HandleMinerSubmit: sha3x.HandleMinerSubmit,
SetDifficulty: sha3x.SetDifficulty,
Notify: sha3x.Notify,
HandleJobMsg: sha3x.HandleJobMsg,
IsMhsLow: sha3x.IsMhsLow,
GetBlockInterval: sha3x.GetBlockInterval,
Coin: "randomxt",
Init: randomxT.Init,
Start: randomxT.Start,
Stop: randomxT.Stop,
InitMiner: randomxT.InitMiner,
HandleMinerSubscribe: randomxT.HandleMinerSubscribe,
HandleMinerAuth: randomxT.HandleMinerAuth,
HandleMinerSubmit: randomxT.HandleMinerSubmit,
SetDifficulty: randomxT.SetDifficulty,
Notify: randomxT.Notify,
HandleJobMsg: randomxT.HandleJobMsg,
IsMhsLow: randomxT.IsMhsLow,
GetBlockInterval: randomxT.GetBlockInterval,
},
// {
// Coin: "monero",

View File

@ -225,6 +225,27 @@ type MoneroJob struct {
Status string `json:"status"`
}
type RandomxTAuthorize_reply struct {
ID float64 `json:"id"`
Jsonrpc string `json:"jsonrpc"`
Result RandomxTAuthorize_job_msg `json:"job"`
Error interface{} `json:"error"`
}
type RandomxTAuthorize_job_msg struct {
ID string `json:"id"`
Job struct {
Algo string `json:"algo"` // "rx/0"
JobId string `json:"job_id"`
Blob string `json:"blob"`
SeedHash string `json:"seed_hash"`
Target string `json:"target"`
Height uint32 `json:"height"`
Variant string `json:"variant"` // "rx/0"
} `json:"job"`
Status string `json:"status"`
}
type KeepAlived_resp struct {
ID int `json:"id"`
Jsonrpc string `json:"jsonrpc"`
@ -581,7 +602,7 @@ func Handle_authorize(miner *coin.MinerObj, id float64, auth_msg string, DbCtx *
if e = json.Unmarshal([]byte(auth_msg), &s); e != nil {
miner.Server.Logg.Error("[server]", zap.String("Unmarshal", e.Error()))
}
} else if miner.Name == "sha3x" || miner.Name == "monero" {
} else if miner.Name == "sha3x" || miner.Name == "monero" || miner.Name == "randomxt" {
if e = json.Unmarshal([]byte(auth_msg), &s_sha3x); e != nil {
miner.Server.Logg.Error("[server]", zap.String("Unmarshal", e.Error()))
}
@ -753,6 +774,41 @@ func Handle_authorize(miner *coin.MinerObj, id float64, auth_msg string, DbCtx *
body_string = string(body) + "\n"
// fmt.Println(body_string)
err = Conn_tx(miner.Conn, []byte(body_string))
} else if miner.Name == "randomxt" {
var randomxt_ack RandomxTAuthorize_reply
randomxt_ack.Result.Status = "OK"
idb := make([]byte, 4)
binary.BigEndian.PutUint32(idb, miner.JobId)
miner.Job.Job_id = hex.EncodeToString(idb)
randomxt_ack.ID = id
randomxt_ack.Result.Status = "OK"
randomxt_ack.Result.ID = "1"
randomxt_ack.Result.Job.JobId = miner.Job.Job_id
randomxt_ack.Result.Job.Algo = "rx/0"
randomxt_ack.Result.Job.Blob = miner.RandomxTJob.Header
randomxt_ack.Result.Job.Height = miner.RandomxTJob.Height
randomxt_ack.Result.Job.Variant = "rx/0"
randomxt_ack.Result.Job.SeedHash = miner.RandomxTJob.SeedHash
target_new, _ := utility.MoneroDiffToTarget(miner.Difficulty)
target_str := fmt.Sprintf("%064x", target_new.Bytes())
target_strr, strerr := ReverseHexStringByByte(target_str)
if strerr != nil {
println("ReverseHexStringByByte", strerr.Error())
}
randomxt_ack.Result.Job.Target = target_strr[48:]
body, err := json.Marshal(randomxt_ack)
if err != nil {
miner.Server.Logg.Error("[server]", zap.String("Marshal", err.Error()))
miner.TxLock.Unlock()
return false
}
body_string = string(body) + "\n"
err = Conn_tx(miner.Conn, []byte(body_string))
if err != nil {
//delete(miner.Server.Miners, miner.MinerId)
//miner.Server.Miners.Delete(miner.MinerId)
}
} else {
}