Skip to content

Commit

Permalink
feat: new template with coinbase call (#6226)
Browse files Browse the repository at this point in the history
Description
---
This adds a new grpc call to take a block template and add coinbases to
it as desired. The callee is required to ensure that the coinbases
amounts provided are correct and per consensus.

Motivation and Context
---
This is to allow external miners to create a block with 1 sided coinbase
utxo's to be added without having to create them as this necessitates
the inclusion of all Tari crypto libraries.

How Has This Been Tested?
---
New unit and cucumber tests
  • Loading branch information
SWvheerden committed Mar 27, 2024
1 parent 0290204 commit 148e398
Show file tree
Hide file tree
Showing 12 changed files with 819 additions and 8 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

27 changes: 27 additions & 0 deletions applications/minotari_app_grpc/proto/base_node.proto
Expand Up @@ -57,6 +57,10 @@ service BaseNode {
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
Expand Down Expand Up @@ -182,6 +186,28 @@ message NewBlockTemplateRequest{
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;
Expand Down Expand Up @@ -348,6 +374,7 @@ message GetNewBlockResult{
Block block = 2;
bytes merge_mining_hash =3;
bytes tari_unique_id =4;
MinerData miner_data = 5;
}

// This is the message that is returned for a miner after it asks for a new block.
Expand Down
3 changes: 3 additions & 0 deletions applications/minotari_node/Cargo.toml
Expand Up @@ -22,6 +22,9 @@ tari_storage = {path="../../infrastructure/storage"}
tari_service_framework = { path = "../../base_layer/service_framework" }
tari_shutdown = { path = "../../infrastructure/shutdown" }
tari_utilities = { version = "0.7" }
tari_key_manager = { path = "../../base_layer/key_manager", features = [
"key_manager_service",
], version = "1.0.0-pre.11a" }

anyhow = "1.0.53"
async-trait = "0.1.52"
Expand Down
2 changes: 2 additions & 0 deletions applications/minotari_node/src/config.rs
Expand Up @@ -235,6 +235,8 @@ pub enum GrpcMethod {
GetNetworkDifficulty,
GetNewBlockTemplate,
GetNewBlock,
GetNewBlockWithCoinbases,
GetNewBlockTemplateWithCoinbases,
GetNewBlockBlob,
SubmitBlock,
SubmitBlockBlob,
Expand Down

0 comments on commit 148e398

Please sign in to comment.