Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Marek <mail@marek.onl>
  • Loading branch information
arya2 and upbqdn authored Dec 19, 2024
1 parent c489d2f commit 1b69b49
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 19 deletions.
8 changes: 4 additions & 4 deletions zebra-chain/src/parameters/network/testnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ pub struct ParametersBuilder {
target_difficulty_limit: ExpandedDifficulty,
/// A flag for disabling proof-of-work checks when Zebra is validating blocks
disable_pow: bool,
/// Whether to allow transactions with transparent outputs that spend coinbase inputs,
/// Whether to allow transactions with transparent outputs to spend coinbase outputs,
/// similar to `fCoinbaseMustBeShielded` in zcashd.
should_allow_unshielded_coinbase_spends: bool,
/// The pre-Blossom halving interval for this network
Expand Down Expand Up @@ -578,7 +578,7 @@ pub struct Parameters {
target_difficulty_limit: ExpandedDifficulty,
/// A flag for disabling proof-of-work checks when Zebra is validating blocks
disable_pow: bool,
/// Whether to allow transactions with transparent outputs that spend coinbase inputs,
/// Whether to allow transactions with transparent outputs to spend coinbase outputs,
/// similar to `fCoinbaseMustBeShielded` in zcashd.
should_allow_unshielded_coinbase_spends: bool,
/// Pre-Blossom halving interval for this network
Expand Down Expand Up @@ -737,7 +737,7 @@ impl Parameters {
}

/// Returns true if this network should allow transactions with transparent outputs
/// that spend coinbase inputs
/// that spend coinbase outputs.
pub fn should_allow_unshielded_coinbase_spends(&self) -> bool {
self.should_allow_unshielded_coinbase_spends
}
Expand Down Expand Up @@ -819,7 +819,7 @@ impl Network {
}

/// Returns true if this network should allow transactions with transparent outputs
/// that spend coinbase inputs
/// that spend coinbase outputs.
pub fn should_allow_unshielded_coinbase_spends(&self) -> bool {
if let Self::Testnet(params) = self {
params.should_allow_unshielded_coinbase_spends()
Expand Down
1 change: 0 additions & 1 deletion zebra-chain/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,6 @@ impl Transaction {
network: &Network,
spend_height: block::Height,
) -> CoinbaseSpendRestriction {
// TODO: Replace `is_regtest()` with a check for a field.
if self.outputs().is_empty() || network.should_allow_unshielded_coinbase_spends() {
// we know this transaction must have shielded outputs,
// because of other consensus rules
Expand Down
18 changes: 4 additions & 14 deletions zebra-consensus/src/transaction/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -814,12 +814,12 @@ async fn mempool_request_with_transparent_coinbase_spend_is_accepted_on_regtest(
let _init_guard = zebra_test::init();

let network = Network::new_regtest(None, Some(1_000));
let mut state: MockService<_, _, _, _> = MockService::build().for_prop_tests();
let mut state: MockService<_, _, _, _> = MockService::build().for_unit_tests();
let verifier = Verifier::new_for_tests(&network, state.clone());

let height = NetworkUpgrade::Nu6
.activation_height(&network)
.expect("Canopy activation height is specified");
.expect("NU6 activation height is specified");
let fund_height = (height - 1).expect("fake source fund block height is too small");
let (input, output, known_utxos) = mock_transparent_transfer(
fund_height,
Expand All @@ -828,7 +828,7 @@ async fn mempool_request_with_transparent_coinbase_spend_is_accepted_on_regtest(
Amount::try_from(10001).expect("invalid value"),
);

// Create a non-coinbase V4 tx with the last valid expiry height.
// Create a non-coinbase V5 tx with the last valid expiry height.
let tx = Transaction::V5 {
network_upgrade: NetworkUpgrade::Nu6,
inputs: vec![input],
Expand Down Expand Up @@ -872,23 +872,14 @@ async fn mempool_request_with_transparent_coinbase_spend_is_accepted_on_regtest(
state
.expect_request(zebra_state::Request::BestChainNextMedianTimePast)
.await
.expect("verifier should call mock state service with correct request")
.respond(zebra_state::Response::BestChainNextMedianTimePast(
DateTime32::MAX,
));

state
.expect_request(zebra_state::Request::UnspentBestChainUtxo(input_outpoint))
.await
.expect("verifier should call mock state service with correct request")
.respond(zebra_state::Response::UnspentBestChainUtxo(
known_utxos.get(&input_outpoint).map(|utxo| {
let mut utxo = utxo.utxo.clone();
utxo.height = coinbase_spend_height;
utxo.from_coinbase = true;
utxo
}),
));
.respond(zebra_state::Response::UnspentBestChainUtxo(Some(utxo)));

state
.expect_request_that(|req| {
Expand All @@ -898,7 +889,6 @@ async fn mempool_request_with_transparent_coinbase_spend_is_accepted_on_regtest(
)
})
.await
.expect("verifier should call mock state service with correct request")
.respond(zebra_state::Response::ValidBestChainTipNullifiersAndAnchors);
});

Expand Down

0 comments on commit 1b69b49

Please sign in to comment.