Skip to content

Commit

Permalink
feat: enable revealed-value proofs (#5983)
Browse files Browse the repository at this point in the history
Description
---
Enabled revealed-value proofs for all output types, which are be
controlled via the consensus constants. Range-proof types are mapped to
output types.

From the merge mining proxy/miner log, coinbase output showing
`range_proof_type: RevealedValue` and `Proof: None`:


![image](https://github.com/tari-project/tari/assets/39146854/9ca0ed86-3ba9-4c18-aeee-4cd6a933a52a)

_**Note:** The faucets changed due to `RangeProofType` now being parsed
with snake case - `"range_proof_type":"RevealedValue"` changed to
`"range_proof_type":"revealed_value"` on every output line._

Motivation and Context
---
See #5968

How Has This Been Tested?
---
Added unit tests
Unit tests pass
Cucumber tests pass
System-level tests ~~[**TO BE COMPLETED**]~~

What process can a PR reviewer use to test or verify this change?
---
Code walkthrough
Review the additional unit tests
Run system-level tests

<!-- Checklist -->
<!-- 1. Is the title of your PR in the form that would make nice release
notes? The title, excluding the conventional commit
tag, will be included exactly as is in the CHANGELOG, so please think
about it carefully. -->


Breaking Changes
---

- [x] None
- [ ] Requires data directory on base node to be deleted
- [ ] Requires hard fork
- [ ] Other - Please specify

<!-- Does this include a breaking change? If so, include this line as a
footer -->
<!-- BREAKING CHANGE: Description what the user should do, e.g. delete a
database, resync the chain -->
  • Loading branch information
hansieodendaal committed Nov 27, 2023
1 parent 89b19f6 commit f3f5879
Show file tree
Hide file tree
Showing 30 changed files with 2,023 additions and 1,710 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.

7 changes: 6 additions & 1 deletion applications/minotari_app_grpc/proto/types.proto
Expand Up @@ -98,6 +98,11 @@ enum RangeProofType {
REVEALED_VALUE = 1;
}

message PermittedRangeProofs {
OutputType output_type = 1;
repeated RangeProofType range_proof_types = 2;
}

/// Range proof
message RangeProof {
bytes proof_bytes = 1;
Expand Down Expand Up @@ -135,5 +140,5 @@ message ConsensusConstants {
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 RangeProofType permitted_range_proof_types = 34;
repeated PermittedRangeProofs permitted_range_proof_types = 34;
}
Expand Up @@ -75,11 +75,16 @@ impl From<ConsensusConstants> for grpc::ConsensusConstants {
.map(|ot| i32::from(ot.as_byte()))
.collect::<Vec<i32>>();

let permitted_range_proof_types = cc.permitted_range_proof_types();
let permitted_range_proof_types = permitted_range_proof_types
.iter()
.map(|rpt| i32::from(rpt.as_byte()))
.collect::<Vec<i32>>();
let mut permitted_range_proof_types = Vec::with_capacity(cc.permitted_range_proof_types().len());
for (output_type, range_proof_types) in cc.permitted_range_proof_types() {
permitted_range_proof_types.push(grpc::PermittedRangeProofs {
output_type: i32::from(output_type.as_byte()),
range_proof_types: range_proof_types
.iter()
.map(|rpt| i32::from(rpt.as_byte()))
.collect::<Vec<i32>>(),
});
}

let randomx_pow = grpc::PowAlgorithmConstants {
max_difficulty: cc.max_pow_difficulty(PowAlgorithm::RandomX).as_u64(),
Expand Down
Expand Up @@ -215,6 +215,7 @@ impl BlockTemplateProtocol<'_> {
&self.wallet_payment_address,
self.config.stealth_payment,
self.consensus_manager.consensus_constants(tari_height),
self.config.range_proof_type,
)
.await?;
Ok((coinbase_output, coinbase_kernel))
Expand Down
4 changes: 4 additions & 0 deletions applications/minotari_merge_mining_proxy/src/config.rs
Expand Up @@ -28,6 +28,7 @@ use tari_common::{
};
use tari_common_types::tari_address::TariAddress;
use tari_comms::multiaddr::Multiaddr;
use tari_core::transactions::transaction_components::RangeProofType;

#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
Expand Down Expand Up @@ -72,6 +73,8 @@ pub struct MergeMiningProxyConfig {
pub wallet_payment_address: String,
/// Stealth payment yes or no
pub stealth_payment: bool,
/// Range proof type - revealed_value or bullet_proof_plus: (default = revealed_value)
pub range_proof_type: RangeProofType,
}

impl Default for MergeMiningProxyConfig {
Expand All @@ -93,6 +96,7 @@ impl Default for MergeMiningProxyConfig {
network: Default::default(),
wallet_payment_address: TariAddress::default().to_hex(),
stealth_payment: true,
range_proof_type: RangeProofType::RevealedValue,
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions applications/minotari_miner/src/config.rs
Expand Up @@ -41,6 +41,7 @@ use serde::{Deserialize, Serialize};
use tari_common::{configuration::Network, SubConfigPath};
use tari_common_types::{grpc_authentication::GrpcAuthentication, tari_address::TariAddress};
use tari_comms::multiaddr::Multiaddr;
use tari_core::transactions::transaction_components::RangeProofType;

#[derive(Serialize, Deserialize, Debug)]
#[serde(deny_unknown_fields)]
Expand Down Expand Up @@ -77,6 +78,8 @@ pub struct MinerConfig {
pub wallet_payment_address: String,
/// Stealth payment yes or no
pub stealth_payment: bool,
/// Range proof type - revealed_value or bullet_proof_plus: (default = revealed_value)
pub range_proof_type: RangeProofType,
}

/// The proof of work data structure that is included in the block header. For the Minotari miner only `Sha3x` is
Expand Down Expand Up @@ -110,6 +113,7 @@ impl Default for MinerConfig {
wait_timeout_on_error: 10,
wallet_payment_address: TariAddress::default().to_hex(),
stealth_payment: true,
range_proof_type: RangeProofType::RevealedValue,
}
}
}
Expand Down
1 change: 1 addition & 0 deletions applications/minotari_miner/src/run_miner.rs
Expand Up @@ -287,6 +287,7 @@ async fn mining_cycle(
wallet_payment_address,
config.stealth_payment,
consensus_manager.consensus_constants(height),
config.range_proof_type,
)
.await
.map_err(|e| MinerError::CoinbaseError(e.to_string()))?;
Expand Down
18 changes: 10 additions & 8 deletions applications/minotari_node/src/config.rs
Expand Up @@ -273,14 +273,16 @@ mod tests {

#[test]
fn it_deserializes_enums() {
let config_str = r#"name = "blockchain champion"
inner_config.deny_methods = [
"list_headers",
"get_constants",
# "get_blocks"
"identify",
# "get_shard_key"
]"#;
let config_str = r#"
name = "blockchain champion"
inner_config.deny_methods = [
"list_headers",
"get_constants",
# "get_blocks"
"identify",
# "get_shard_key"
]
"#;
let config = toml::from_str::<TestConfig>(config_str).unwrap();

// Enums in the config
Expand Down
1 change: 1 addition & 0 deletions base_layer/core/Cargo.toml
Expand Up @@ -86,6 +86,7 @@ libsqlite3-sys = { version = "0.25.1", features = ["bundled"] }
config = { version = "0.13.0" }
env_logger = "0.7.0"
tempfile = "3.1.0"
toml = { version = "0.5" }

[build-dependencies]
tari_common = { path = "../../common", features = ["build"] }
Expand Down

0 comments on commit f3f5879

Please sign in to comment.