Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: split up app grpc proto files #4466

Merged
merged 1 commit into from
Aug 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions applications/tari_app_grpc/proto/base_node.proto
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
syntax = "proto3";

import "types.proto";
import "transaction.proto";
import "block.proto";
import "network.proto";

package tari.rpc;

Expand Down
127 changes: 127 additions & 0 deletions applications/tari_app_grpc/proto/block.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
// 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 "transaction.proto";
import "google/protobuf/timestamp.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.
google.protobuf.Timestamp timestamp = 5;
// This is the UTXO merkle root of the outputs
// This is calculated as Hash (txo MMR root || roaring bitmap hash of UTXO indices)
bytes output_mr = 6;
// This is the MMR root of the the output witness data
bytes witness_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;
}

// Metadata required for validating the Proof of Work calculation
message ProofOfWork {
// 0 = Monero
// 1 = Blake
uint64 pow_algo = 1;
// uint64 accumulated_monero_difficulty = 2;
// uint64 accumulated_sha_difficulty = 3;
bytes pow_data = 4;
// uint64 target_difficulty = 5;
}

//This is used to request the which pow algo should be used with the block template
message PowAlgo {
enum PowAlgos {
POW_ALGOS_MONERO = 0;
POW_ALGOS_SHA3 = 1;
}
PowAlgos pow_algo = 1;
}


// A Tari block. Blocks are linked together into a blockchain.
message Block {
BlockHeader header = 1;
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 = 3;
}


// 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;
// uint64 target_difficulty = 6;
// Sum of script offsets for all kernels in this block.
bytes total_script_offset = 7;
}

// 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 {
NewBlockHeaderTemplate header = 1;
AggregateBody body = 2;
}

101 changes: 101 additions & 0 deletions applications/tari_app_grpc/proto/network.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
// 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;
string public_address = 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
google.protobuf.Timestamp last_connection = 4;
/// Flags for the peer.
uint32 flags = 5;
google.protobuf.Timestamp banned_until= 6;
string banned_reason= 7;
google.protobuf.Timestamp offline_at = 8;
/// Features supported by the peer
uint64 features = 9;
/// Connection statics for the peer
google.protobuf.Timestamp last_connected_at = 10; /// Protocols supported by the peer. This should not be considered a definitive list of supported protocols and is
/// 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;
// TODO: Implement these
// uint32 incoming_bps = 4;
// uint32 outgoing_bps = 5;
// uint64 total_bytes_read = 6;
// uint64 total_bytes_written = 7;
}

message Address{
bytes address =1;
string last_seen = 2;
uint32 connection_attempts = 3;
uint32 rejected_message_count = 4;
uint64 avg_latency = 5;
}

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;
}
27 changes: 27 additions & 0 deletions applications/tari_app_grpc/proto/sidechain_types.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// 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;

message SideChainFeatures {
}
Loading