Pirat
March 7, 2020, 2:37pm
1
Where the block production speed is written in the zcash code, I got confused I don’t understand at all how the calculation takes place.
1 Like
Shawn
March 7, 2020, 4:28pm
2
Hi @Pirat I assume you are referring to the Zcash difficulty adjustment? The block target time since Sapling is 75 seconds, the difficulty adjustment is defined in section 7.6.3 of the protocol spec: https://zips.z.cash/protocol/protocol.pdf#diffadjustment
[Edit for accuracy by @daira : since Blossom, not Sapling. Also changed the link to a stable URL.]
Pirat
March 7, 2020, 7:44pm
3
And where in the code it is written
* fed a fake alternate chain. We use NU activation blocks for this purpose instead of
* the checkpoint blocks, because network upgrades (should) have significantly more
* scrutiny than regular releases. nMinimumChainWork MUST be set to at least the chain
* work of this block, otherwise this detection will have false positives.
*/
boost::optional<uint256> hashActivationBlock;
};
/** ZIP208 block target interval in seconds. */
static const unsigned int PRE_BLOSSOM_POW_TARGET_SPACING = 150;
static const unsigned int POST_BLOSSOM_POW_TARGET_SPACING = 75;
static_assert(POST_BLOSSOM_POW_TARGET_SPACING < PRE_BLOSSOM_POW_TARGET_SPACING, "Blossom target spacing must be less than pre-Blossom target spacing.");
static const unsigned int PRE_BLOSSOM_HALVING_INTERVAL = 840000;
static const unsigned int PRE_BLOSSOM_REGTEST_HALVING_INTERVAL = 150;
static const int BLOSSOM_POW_TARGET_SPACING_RATIO = PRE_BLOSSOM_POW_TARGET_SPACING / POST_BLOSSOM_POW_TARGET_SPACING;
static_assert(BLOSSOM_POW_TARGET_SPACING_RATIO * POST_BLOSSOM_POW_TARGET_SPACING == PRE_BLOSSOM_POW_TARGET_SPACING, "Invalid BLOSSOM_POW_TARGET_SPACING_RATIO");
static const unsigned int POST_BLOSSOM_HALVING_INTERVAL = PRE_BLOSSOM_HALVING_INTERVAL * BLOSSOM_POW_TARGET_SPACING_RATIO;
static const unsigned int POST_BLOSSOM_REGTEST_HALVING_INTERVAL = PRE_BLOSSOM_REGTEST_HALVING_INTERVAL * BLOSSOM_POW_TARGET_SPACING_RATIO;
/**
* Parameters that influence chain consensus.
I found only Sapling time and where is the original time?
Shawn
March 7, 2020, 7:49pm
4
1 Like
str4d
March 7, 2020, 8:01pm
5
The line you’ve highlighted is the block interval in seconds from the Blossom network upgrade onwards (75 seconds). The line right above it is the block interval from the launch of Zcash through to just before the Blossom NU (150 seconds).
The canonical place to look in the code for the block interval at some block height is here:
int64_t Params::PoWTargetSpacing(int nHeight) const {
// zip208
// PoWTargetSpacing(height) :=
// PreBlossomPoWTargetSpacing, if not IsBlossomActivated(height)
// PostBlossomPoWTargetSpacing, otherwise.
bool blossomActive = NetworkUpgradeActive(nHeight, Consensus::UPGRADE_BLOSSOM);
return blossomActive ? nPostBlossomPowTargetSpacing : nPreBlossomPowTargetSpacing;
}
2 Likes