Skip to content

Commit

Permalink
feat(p2pool-randomx-support): added pow algo to GetNewBlockRequest in…
Browse files Browse the repository at this point in the history
… p2pool proto (tari-project#6509)

Description
---
Added PoW algo to p2pool client request, so clients can get a SHA-3 or
Random-X block to mine on.

Breaking Changes
---

- [x] None
- [ ] Requires data directory on base node to be deleted
- [ ] Requires hard fork
- [ ] Other - Please specify
  • Loading branch information
ksrichard authored Sep 3, 2024
1 parent a569644 commit 125b49c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 22 deletions.
4 changes: 3 additions & 1 deletion applications/minotari_app_grpc/proto/p2pool.proto
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ service ShaP2Pool {
rpc SubmitBlock(SubmitBlockRequest) returns(tari.rpc.SubmitBlockResponse);
}

message GetNewBlockRequest {}
message GetNewBlockRequest {
tari.rpc.PowAlgo pow = 1;
}

message GetNewBlockResponse {
tari.rpc.GetNewBlockResult block = 1;
Expand Down
40 changes: 20 additions & 20 deletions applications/minotari_app_grpc/src/conversions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,26 @@
// 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.

mod aggregate_body;
mod base_node_state;
mod block;
mod block_header;
mod chain_metadata;
mod com_and_pub_signature;
mod commitment_signature;
mod consensus_constants;
mod historical_block;
mod new_block_template;
mod output_features;
mod peer;
mod proof_of_work;
mod sidechain_feature;
mod signature;
mod transaction;
mod transaction_input;
mod transaction_kernel;
mod transaction_output;
mod unblinded_output;
pub mod aggregate_body;
pub mod base_node_state;
pub mod block;
pub mod block_header;
pub mod chain_metadata;
pub mod com_and_pub_signature;
pub mod commitment_signature;
pub mod consensus_constants;
pub mod historical_block;
pub mod new_block_template;
pub mod output_features;
pub mod peer;
pub mod proof_of_work;
pub mod sidechain_feature;
pub mod signature;
pub mod transaction;
pub mod transaction_input;
pub mod transaction_kernel;
pub mod transaction_output;
pub mod unblinded_output;

use prost_types::Timestamp;

Expand Down
6 changes: 5 additions & 1 deletion applications/minotari_miner/src/run_miner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ use minotari_app_grpc::{
authentication::ClientAuthenticationInterceptor,
tari_rpc::{
base_node_client::BaseNodeClient,
pow_algo::PowAlgos,
sha_p2_pool_client::ShaP2PoolClient,
Block,
GetNewBlockRequest,
PowAlgo,
SubmitBlockRequest,
SubmitBlockResponse,
TransactionOutput as GrpcTransactionOutput,
Expand Down Expand Up @@ -455,8 +457,10 @@ async fn get_new_block_base_node(
async fn get_new_block_p2pool_node(
sha_p2pool_client: &mut ShaP2PoolGrpcClient,
) -> Result<GetNewBlockResponse, MinerError> {
let mut pow_algo = PowAlgo::default();
pow_algo.set_pow_algo(PowAlgos::Sha3x);
let block_result = sha_p2pool_client
.get_new_block(GetNewBlockRequest::default())
.get_new_block(GetNewBlockRequest { pow: Some(pow_algo) })
.await?
.into_inner();
let new_block_result = block_result.block.ok_or_else(|| err_empty("block result"))?;
Expand Down

0 comments on commit 125b49c

Please sign in to comment.