Skip to content

Conversation

@maflcko
Copy link
Member

@maflcko maflcko commented May 8, 2019

Unnamed arguments are confusing as to what they mean without looking up the function signature.

Since segwit is active by default in regtest, and all blocks are serialized with witness (#15664), remove the argument with_witness=True from all calls to CBlock::serialize and BlockTransactions::serialize.

Unnamed arguments are confusing as to what they mean without looking up
the function signature.

Since segwit is active by default in regtest, and all blocks are
serialized with witness (bitcoin#15664, c459c5f), remove the argument
`with_witness=True` from all calls to `CBlock::serialize` and
`BlockTransactions::serialize`.

This diff has been created with a script, but is better reviewed without
a scripted diff.

sed -i --regexp-extended -e 's/block(_?[2a-z]*)\.serialize\([a-z_]*=?True/block\1.serialize(/g' $(git grep -l serialize ./test)
@instagibbs
Copy link
Member

utACK fa31664

@maflcko maflcko force-pushed the 1905-testWitnessTrue branch 4 times, most recently from 86d1bb5 to f51ced9 Compare May 8, 2019 15:26
@jnewbery
Copy link
Contributor

jnewbery commented May 8, 2019

Please correct PR title CBlock::serialize -> CBlock.serialize so it's clear that this is a change to the Python code and not C++.

This diff has been generated with the following script, but is better
reviewed without looking at the script.

 # -BEGIN VERIFY SCRIPT-
echo "Use msg_witness_block everywhere, except for tests that require msg_block"
 # This could be a separate commit, but it is combined with the
 # following scripts to reduce the overall diff
sed -i -e 's/msg_block/msg_witness_block/g' ./test/functional/{feature_assumevalid,feature_cltv,feature_dersig,feature_versionbits_warning,p2p_fingerprint,p2p_sendheaders,p2p_unrequested_blocks,example_test,rpc_blockchain}.py

echo "Rename msg_block to msg_no_witness_block"
 # Rename msg_block to msg_no_witness_block in all tests (not the
 # framework)
sed -i -e 's/msg_block/msg_no_witness_block/g' $(git grep -l msg_block ./test/functional/*.py)
 # Derive msg_no_witness_block from msg_block
 # Make msg_block a witness block in messages.py
patch -p1 --fuzz 0 << EOF
diff --git a/test/functional/test_framework/messages.py b/test/functional/test_framework/messages.py
index 00190e4..e454ed5 100755
--- a/test/functional/test_framework/messages.py
+++ b/test/functional/test_framework/messages.py
@@ -1133 +1133 @@ class msg_block:
-        return self.block.serialize(with_witness=False)
+        return self.block.serialize()
@@ -1155 +1155 @@ class msg_generic:
-class msg_witness_block(msg_block):
+class msg_no_witness_block(msg_block):
@@ -1158,2 +1158 @@ class msg_witness_block(msg_block):
-        r = self.block.serialize()
-        return r
+        return self.block.serialize(with_witness=False)
@@ -1445 +1444 @@ class msg_blocktxn:
-        r += self.block_transactions.serialize(with_witness=False)
+        r += self.block_transactions.serialize()
@@ -1452 +1451 @@ class msg_blocktxn:
-class msg_witness_blocktxn(msg_blocktxn):
+class msg_no_witness_blocktxn(msg_blocktxn):
@@ -1456,3 +1455 @@ class msg_witness_blocktxn(msg_blocktxn):
-        r = b""
-        r += self.block_transactions.serialize()
-        return r
+        return self.block_transactions.serialize(with_witness=False)
EOF
 # Conclude rename of msg_block to msg_no_witness_block
sed -i -e 's/msg_witness_block/msg_block/g' $(git grep -l msg_witness_block)
 # -END VERIFY SCRIPT-
@maflcko maflcko force-pushed the 1905-testWitnessTrue branch from f51ced9 to fa1d766 Compare May 8, 2019 15:54
@maflcko maflcko changed the title test: Remove True argument to CBlock::serialize tests: Make msg_block a witness block May 8, 2019
@maflcko
Copy link
Member Author

maflcko commented May 8, 2019

I just went all the way to make msg_block a witness block

@laanwj
Copy link
Member

laanwj commented Jun 17, 2019

code-review ACK fa1d766

maflcko pushed a commit to maflcko/bitcoin-core that referenced this pull request Jun 17, 2019
fa1d766 tests: Make msg_block a witness block (MarcoFalke)
fa52eb5 test: Remove True argument to CBlock::serialize (MarcoFalke)

Pull request description:

  Unnamed arguments are confusing as to what they mean without looking up the function signature.

  Since segwit is active by default in regtest, and all blocks are serialized with witness (bitcoin#15664), remove the argument `with_witness=True` from all calls to `CBlock::serialize` and `BlockTransactions::serialize`.

ACKs for commit fa1d76:
  laanwj:
    code-review ACK fa1d766

Tree-SHA512: 2c550646f99c9ca86a223ca988c61a730f5e6646807adeaa7174fb2424a32cea3fef8bcd3e0b12e162e7ff192877d0c02fd0654df6ee1a9b821b065707c2dcbc
@maflcko maflcko merged commit fa1d766 into bitcoin:master Jun 17, 2019
@maflcko maflcko deleted the 1905-testWitnessTrue branch June 17, 2019 15:22
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Jun 19, 2019
fa1d766 tests: Make msg_block a witness block (MarcoFalke)
fa52eb5 test: Remove True argument to CBlock::serialize (MarcoFalke)

Pull request description:

  Unnamed arguments are confusing as to what they mean without looking up the function signature.

  Since segwit is active by default in regtest, and all blocks are serialized with witness (bitcoin#15664), remove the argument `with_witness=True` from all calls to `CBlock::serialize` and `BlockTransactions::serialize`.

ACKs for commit fa1d76:
  laanwj:
    code-review ACK fa1d766

Tree-SHA512: 2c550646f99c9ca86a223ca988c61a730f5e6646807adeaa7174fb2424a32cea3fef8bcd3e0b12e162e7ff192877d0c02fd0654df6ee1a9b821b065707c2dcbc
laanwj added a commit that referenced this pull request Jan 30, 2020
aaaae4d test: Add p2p test for forcerelay permission (MarcoFalke)
fa6b57b test: Fix whitespace in p2p_permissions.py (MarcoFalke)
faf4081 test: Make msg_tx a witness tx (MarcoFalke)

Pull request description:

  The commit `test: Make msg_tx a witness tx` is needed so that the python mininode does not strip the witness from transactions before sending them over p2p. The commit should also be done to keep symmetry with msg_block. See:

  *  tests: Make msg_block a witness block #15982

ACKs for top commit:
  laanwj:
    ACK aaaae4d

Tree-SHA512: b4b546c88f7f0576cb512f0872bc6bef9d4df65783803f226986e56175937f418aa1ed906417ac909f27f1fd521d64629621fda83250fa925c46ef9513db0e4c
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Feb 1, 2020
aaaae4d test: Add p2p test for forcerelay permission (MarcoFalke)
fa6b57b test: Fix whitespace in p2p_permissions.py (MarcoFalke)
faf4081 test: Make msg_tx a witness tx (MarcoFalke)

Pull request description:

  The commit `test: Make msg_tx a witness tx` is needed so that the python mininode does not strip the witness from transactions before sending them over p2p. The commit should also be done to keep symmetry with msg_block. See:

  *  tests: Make msg_block a witness block bitcoin#15982

ACKs for top commit:
  laanwj:
    ACK aaaae4d

Tree-SHA512: b4b546c88f7f0576cb512f0872bc6bef9d4df65783803f226986e56175937f418aa1ed906417ac909f27f1fd521d64629621fda83250fa925c46ef9513db0e4c
sidhujag pushed a commit to syscoin-core/syscoin that referenced this pull request Nov 10, 2020
aaaae4d test: Add p2p test for forcerelay permission (MarcoFalke)
fa6b57b test: Fix whitespace in p2p_permissions.py (MarcoFalke)
faf4081 test: Make msg_tx a witness tx (MarcoFalke)

Pull request description:

  The commit `test: Make msg_tx a witness tx` is needed so that the python mininode does not strip the witness from transactions before sending them over p2p. The commit should also be done to keep symmetry with msg_block. See:

  *  tests: Make msg_block a witness block bitcoin#15982

ACKs for top commit:
  laanwj:
    ACK aaaae4d

Tree-SHA512: b4b546c88f7f0576cb512f0872bc6bef9d4df65783803f226986e56175937f418aa1ed906417ac909f27f1fd521d64629621fda83250fa925c46ef9513db0e4c
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Dec 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants