Skip to content

Commit 174d016

Browse files
committed
Merge #12798: doc: Refer to witness reserved value as spec. in the BIP
adc2586 doc: Refer to witness reserved value as spec. in the BIP (MarcoFalke) Pull request description: BIP141 refers to the coinbase's input's witness that consists of a single 32-byte array as "witness reserved value". This updates the code to follow the BIP Tree-SHA512: 49c9463519bd11b9ff322eeecd638f7627aa8efdfb869f8549f9a160ff34281e1b5a0b9d83545a692de6f5ff795055292c423403b0f3ce7597e3f32273cf1deb
2 parents 18606eb + adc2586 commit 174d016

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

src/validation.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3223,10 +3223,10 @@ static bool ContextualCheckBlock(const CBlock& block, CValidationState& state, c
32233223
// Validation for witness commitments.
32243224
// * We compute the witness hash (which is the hash including witnesses) of all the block's transactions, except the
32253225
// coinbase (where 0x0000....0000 is used instead).
3226-
// * The coinbase scriptWitness is a stack of a single 32-byte vector, containing a witness nonce (unconstrained).
3226+
// * The coinbase scriptWitness is a stack of a single 32-byte vector, containing a witness reserved value (unconstrained).
32273227
// * We build a merkle tree with all those witness hashes as leaves (similar to the hashMerkleRoot in the block header).
32283228
// * There must be at least one output whose scriptPubKey is a single 36-byte push, the first 4 bytes of which are
3229-
// {0xaa, 0x21, 0xa9, 0xed}, and the following 32 bytes are SHA256^2(witness root, witness nonce). In case there are
3229+
// {0xaa, 0x21, 0xa9, 0xed}, and the following 32 bytes are SHA256^2(witness root, witness reserved value). In case there are
32303230
// multiple, the last one is used.
32313231
bool fHaveWitness = false;
32323232
if (VersionBitsState(pindexPrev, consensusParams, Consensus::DEPLOYMENT_SEGWIT, versionbitscache) == ThresholdState::ACTIVE) {
@@ -3238,7 +3238,7 @@ static bool ContextualCheckBlock(const CBlock& block, CValidationState& state, c
32383238
// already does not permit it, it is impossible to trigger in the
32393239
// witness tree.
32403240
if (block.vtx[0]->vin[0].scriptWitness.stack.size() != 1 || block.vtx[0]->vin[0].scriptWitness.stack[0].size() != 32) {
3241-
return state.DoS(100, false, REJECT_INVALID, "bad-witness-nonce-size", true, strprintf("%s : invalid witness nonce size", __func__));
3241+
return state.DoS(100, false, REJECT_INVALID, "bad-witness-nonce-size", true, strprintf("%s : invalid witness reserved value size", __func__));
32423242
}
32433243
CHash256().Write(hashWitness.begin(), 32).Write(&block.vtx[0]->vin[0].scriptWitness.stack[0][0], 32).Finalize(hashWitness.begin());
32443244
if (memcmp(hashWitness.begin(), &block.vtx[0]->vout[commitpos].scriptPubKey[6], 32)) {
@@ -3257,7 +3257,7 @@ static bool ContextualCheckBlock(const CBlock& block, CValidationState& state, c
32573257
}
32583258
}
32593259

3260-
// After the coinbase witness nonce and commitment are verified,
3260+
// After the coinbase witness reserved value and commitment are verified,
32613261
// we can check if the block weight passes (before we've checked the
32623262
// coinbase witness, it would be possible for the weight to be too
32633263
// large by filling up the coinbase witness, which doesn't change

src/validation.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ bool IsWitnessEnabled(const CBlockIndex* pindexPrev, const Consensus::Params& pa
411411
/** When there are blocks in the active chain with missing data, rewind the chainstate and remove them from the block index */
412412
bool RewindBlockIndex(const CChainParams& params);
413413

414-
/** Update uncommitted block structures (currently: only the witness nonce). This is safe for submitted blocks. */
414+
/** Update uncommitted block structures (currently: only the witness reserved value). This is safe for submitted blocks. */
415415
void UpdateUncommittedBlockStructures(CBlock& block, const CBlockIndex* pindexPrev, const Consensus::Params& consensusParams);
416416

417417
/** Produce the necessary coinbase commitment for a block (modifies the hash, don't call for mined blocks). */

test/functional/p2p_segwit.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ def test_block_malleability(self):
425425

426426
assert(self.nodes[0].getbestblockhash() == block.hash)
427427

428-
# Now make sure that malleating the witness nonce doesn't
428+
# Now make sure that malleating the witness reserved value doesn't
429429
# result in a block permanently marked bad.
430430
block = self.build_next_block()
431431
add_witness_commitment(block)
@@ -436,7 +436,7 @@ def test_block_malleability(self):
436436
block.vtx[0].wit.vtxinwit[0].scriptWitness.stack = [ ser_uint256(1) ]
437437
test_witness_block(self.nodes[0].rpc, self.test_node, block, accepted=False)
438438

439-
# Changing the witness nonce doesn't change the block hash
439+
# Changing the witness reserved value doesn't change the block hash
440440
block.vtx[0].wit.vtxinwit[0].scriptWitness.stack = [ ser_uint256(0) ]
441441
test_witness_block(self.nodes[0].rpc, self.test_node, block, accepted=True)
442442

0 commit comments

Comments
 (0)