Skip to content

Commit

Permalink
Merge branch 'feature-dan' into merge-feature-dan
Browse files Browse the repository at this point in the history
* feature-dan: (21 commits)
  fix(core)!: remove unused get_committees call from base node (tari-project#4880)
  fix: correct value for validator_node_timeout consensus constant in localnet (tari-project#4879)
  feat: add block height to input request to get network consensus constants (tari-project#4856)
  fix: remove unused config for validator node (tari-project#4849)
  feat: add missing fields to grpc consensus constants interface (tari-project#4845)
  chore: merge development into feature-dan (tari-project#4815)
  refactor: split tari_base_node and tari_console_wallet into a lib component (tari-project#4818)
  fix(core)!: adds utxo and block info to get_template_registrations request (tari-project#4789)
  fix: computation of vn mmr (tari-project#4772)
  fix(wallet/grpc): add transaction id and template_address to template_reg response (tari-project#4788)
  fix: fix get shard key (tari-project#4744)
  feat(core): store and fetch templates from lmdb (tari-project#4726)
  fix: fix validator node registration logic (tari-project#4718)
  feat(base_node_grpc_client): add getActiveValidatorNodes method (tari-project#4719)
  fix after merge
  fix(core): bring validator node MR inline with other merkle root code (tari-project#4692)
  feat(core): add validator registration sidechain feature (tari-project#4690)
  fix merge issues
  feat: add grpc to get shard key for public key (tari-project#4654)
  feat: add validator node registration (tari-project#4507)
  ...
  • Loading branch information
sdbondi committed Nov 14, 2022
2 parents bd72d03 + 1c3eff1 commit 62e3256
Show file tree
Hide file tree
Showing 94 changed files with 3,523 additions and 735 deletions.
55 changes: 53 additions & 2 deletions applications/tari_app_grpc/proto/base_node.proto
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import "types.proto";
import "transaction.proto";
import "block.proto";
import "network.proto";
import "sidechain_types.proto";

package tari.rpc;

Expand All @@ -39,7 +40,7 @@ service BaseNode {
// Returns the block timing for the chain heights
rpc GetBlockTiming(HeightRequest) returns (BlockTimingResponse);
// Returns the network Constants
rpc GetConstants(Empty) returns (ConsensusConstants);
rpc GetConstants(BlockHeight) returns (ConsensusConstants);
// Returns Block Sizes
rpc GetBlockSize (BlockGroupRequest) returns (BlockGroupResponse);
// Returns Block Fees
Expand Down Expand Up @@ -88,7 +89,12 @@ service BaseNode {
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);
}

message GetAssetMetadataRequest {
Expand Down Expand Up @@ -435,3 +441,48 @@ message MempoolStatsResponse {
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;
}

2 changes: 2 additions & 0 deletions applications/tari_app_grpc/proto/block.proto
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ message BlockHeader {
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;
}

// Metadata required for validating the Proof of Work calculation
Expand Down
39 changes: 38 additions & 1 deletion applications/tari_app_grpc/proto/sidechain_types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,42 @@ syntax = "proto3";

package tari.rpc;

message SideChainFeatures {
import "types.proto";

message SideChainFeature {
oneof side_chain_feature {
ValidatorNodeRegistration validator_node_registration = 1;
TemplateRegistration template_registration = 2;
}
}

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 TemplateType {
oneof template_type {
WasmInfo wasm = 1;
}
}

message WasmInfo {
uint32 abi_version = 1;
}

message BuildInfo {
string repo_url = 1;
bytes commit_hash = 2;
}
2 changes: 1 addition & 1 deletion applications/tari_app_grpc/proto/transaction.proto
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ message OutputFeatures {
// require a min maturity of the Coinbase_lock_height, this should be checked on receiving new blocks.
uint64 maturity = 3;
bytes metadata = 4;
SideChainFeatures sidechain_features = 5;
SideChainFeature sidechain_feature = 5;
}


Expand Down
65 changes: 65 additions & 0 deletions applications/tari_app_grpc/proto/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,20 @@ 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 Tari base layer. A different signature scheme can be
// employed by redefining this type.
message Signature {
Expand All @@ -41,6 +52,36 @@ message ComSignature {
bytes signature_v = 3;
}

/// PoW Algorithm constants
message PowAlgorithmConstants {
uint64 max_target_time = 1;
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 metadata_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;
}

/// Consensus Constants response
message ConsensusConstants {
Expand Down Expand Up @@ -76,4 +117,28 @@ message ConsensusConstants {
uint64 block_weight_outputs = 15;
/// Block weight for kernels
uint64 block_weight_kernels = 16;
/// This is to keep track of the value inside of the genesis block
uint64 faucet_value = 17;
/// Maximum byte size of TariScript
uint64 max_script_byte_size = 18;
/// How long does it take to timeout validator node registration
uint64 validator_node_timeout = 19;
/// The height at which these constants become effective
uint64 effective_from_height = 20;
/// Current version of the blockchain
Range valid_blockchain_version_range = 21;
/// This is the maximum age a monero merge mined seed can be reused
uint64 max_randomx_seed_height = 22;
/// This keeps track of the block split targets and which algo is accepted
map<uint32, PowAlgorithmConstants> proof_of_work = 23;
/// Transaction Weight params
WeightParams transaction_weight = 24;
/// Range of valid transaction input versions
Range input_version_range = 26;
/// Range of valid transaction output (and features) versions
OutputsVersion output_version_range = 27;
/// Range of valid transaction kernel versions
Range kernel_version_range = 28;
/// An allowlist of output types
repeated OutputType permitted_output_types = 29;
}
2 changes: 1 addition & 1 deletion applications/tari_app_grpc/proto/validator_node.proto
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ message Authority {
bytes proxied_by = 3;
}

message InvokeMethodRequest{
message InvokeMethodRequest {
bytes contract_id = 1;
uint32 template_id = 2;
string method = 3;
Expand Down
28 changes: 28 additions & 0 deletions applications/tari_app_grpc/proto/wallet.proto
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,13 @@ service Wallet {
rpc ClaimShaAtomicSwapTransaction(ClaimShaAtomicSwapRequest) returns (ClaimShaAtomicSwapResponse);
// This will claim a HTLC refund transaction
rpc ClaimHtlcRefundTransaction(ClaimHtlcRefundRequest) returns (ClaimHtlcRefundResponse);
// Creates a transaction with a template registration output
rpc CreateTemplateRegistration(CreateTemplateRegistrationRequest) returns (CreateTemplateRegistrationResponse);
rpc SetBaseNode(SetBaseNodeRequest) returns (SetBaseNodeResponse);

rpc StreamTransactionEvents(TransactionEventRequest) returns (stream TransactionEventResponse);

rpc RegisterValidatorNode(RegisterValidatorNodeRequest) returns (RegisterValidatorNodeResponse);
}

message GetVersionRequest { }
Expand All @@ -97,6 +101,7 @@ message CreateBurnTransactionRequest{
string message = 3;
}


message PaymentRecipient {
string address = 1;
uint64 amount = 2;
Expand Down Expand Up @@ -257,6 +262,16 @@ message ImportUtxosResponse {
repeated uint64 tx_ids = 1;
}

message CreateTemplateRegistrationRequest {
TemplateRegistration template_registration = 1;
uint64 fee_per_gram = 2;
}

message CreateTemplateRegistrationResponse {
uint64 tx_id = 1;
bytes template_address = 2;
}

message CancelTransactionRequest {
uint64 tx_id = 1;
}
Expand Down Expand Up @@ -307,3 +322,16 @@ message TransactionEvent {
message TransactionEventResponse {
TransactionEvent transaction = 1;
}

message RegisterValidatorNodeRequest {
bytes validator_node_public_key = 1;
Signature validator_node_signature = 2;
uint64 fee_per_gram = 3;
string message = 4;
}

message RegisterValidatorNodeResponse {
uint64 transaction_id = 1;
bool is_success = 2;
string failure_message = 3;
}
2 changes: 2 additions & 0 deletions applications/tari_app_grpc/src/conversions/block_header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ impl From<BlockHeader> for grpc::BlockHeader {
pow_algo: pow_algo.as_u64(),
pow_data: h.pow.pow_data,
}),
validator_node_mr: h.validator_node_mr.to_vec(),
}
}
}
Expand Down Expand Up @@ -91,6 +92,7 @@ impl TryFrom<grpc::BlockHeader> for BlockHeader {
total_script_offset,
nonce: header.nonce,
pow,
validator_node_mr: FixedHash::try_from(header.validator_node_mr).map_err(|err| err.to_string())?,
})
}
}
Loading

0 comments on commit 62e3256

Please sign in to comment.