Changeset View
Changeset View
Standalone View
Standalone View
test/functional/abc-schnorrmultisig-activation.py
Show First 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | |||||
# If we don't do this, autoreplay protection will activate before graviton and | # If we don't do this, autoreplay protection will activate before graviton and | ||||
# all our sigs will mysteriously fail. | # all our sigs will mysteriously fail. | ||||
REPLAY_PROTECTION_START_TIME = GRAVITON_START_TIME * 2 | REPLAY_PROTECTION_START_TIME = GRAVITON_START_TIME * 2 | ||||
# Before the upgrade, Schnorr checkmultisig is rejected but forgiven if it | # Before the upgrade, Schnorr checkmultisig is rejected but forgiven if it | ||||
# would have been valid after the upgrade. | # would have been valid after the upgrade. | ||||
PREUPGRADE_SCHNORR_MULTISIG_ERROR = 'upgrade-conditional-script-failure (Signature cannot be 65 bytes in CHECKMULTISIG)' | PREUPGRADE_SCHNORR_MULTISIG_ERROR = 'mandatory-script-verify-flag-failed (Signature cannot be 65 bytes in CHECKMULTISIG)' | ||||
# Before the upgrade, ECDSA checkmultisig with non-null dummy are rejected with | # Before the upgrade, ECDSA checkmultisig with non-null dummy are rejected with | ||||
# a non-mandatory error. | # a non-mandatory error. | ||||
PREUPGRADE_ECDSA_NULLDUMMY_ERROR = 'non-mandatory-script-verify-flag (Dummy CHECKMULTISIG argument must be zero)' | PREUPGRADE_ECDSA_NULLDUMMY_ERROR = 'non-mandatory-script-verify-flag (Dummy CHECKMULTISIG argument must be zero)' | ||||
# After the upgrade, ECDSA checkmultisig with non-null dummy are invalid since | # After the upgrade, ECDSA checkmultisig with non-null dummy are invalid since | ||||
# the new mode refuses ECDSA, but still do not result in ban. | # the new mode refuses ECDSA, but still do not result in ban. | ||||
POSTUPGRADE_ECDSA_NULLDUMMY_ERROR = 'upgrade-conditional-script-failure (Only Schnorr signatures allowed in this operation)' | POSTUPGRADE_ECDSA_NULLDUMMY_ERROR = 'mandatory-script-verify-flag-failed (Only Schnorr signatures allowed in this operation)' | ||||
# A mandatory (bannable) error occurs when people pass Schnorr signatures into | # A mandatory (bannable) error occurs when people pass Schnorr signatures into | ||||
# legacy OP_CHECKMULTISIG; this is the case on both sides of the upgrade. | # legacy OP_CHECKMULTISIG; this is the case on both sides of the upgrade. | ||||
SCHNORR_LEGACY_MULTISIG_ERROR = 'mandatory-script-verify-flag-failed (Signature cannot be 65 bytes in CHECKMULTISIG)' | SCHNORR_LEGACY_MULTISIG_ERROR = 'mandatory-script-verify-flag-failed (Signature cannot be 65 bytes in CHECKMULTISIG)' | ||||
# Blocks with invalid scripts give this error: | # Blocks with invalid scripts give this error: | ||||
BADINPUTS_ERROR = 'blk-bad-inputs' | BADINPUTS_ERROR = 'blk-bad-inputs' | ||||
▲ Show 20 Lines • Show All 167 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
node.sendrawtransaction, ToHex(schnorr1tx)) | node.sendrawtransaction, ToHex(schnorr1tx)) | ||||
self.log.info( | self.log.info( | ||||
"Sending rejected transactions via net (banning depending on situation)") | "Sending rejected transactions via net (banning depending on situation)") | ||||
self.check_for_no_ban_on_rejected_tx( | self.check_for_no_ban_on_rejected_tx( | ||||
ecdsa1tx, PREUPGRADE_ECDSA_NULLDUMMY_ERROR) | ecdsa1tx, PREUPGRADE_ECDSA_NULLDUMMY_ERROR) | ||||
self.check_for_ban_on_rejected_tx( | self.check_for_ban_on_rejected_tx( | ||||
schnorr0tx, SCHNORR_LEGACY_MULTISIG_ERROR) | schnorr0tx, SCHNORR_LEGACY_MULTISIG_ERROR) | ||||
self.check_for_no_ban_on_rejected_tx( | self.check_for_ban_on_rejected_tx( | ||||
schnorr1tx, PREUPGRADE_SCHNORR_MULTISIG_ERROR) | schnorr1tx, PREUPGRADE_SCHNORR_MULTISIG_ERROR) | ||||
self.log.info( | self.log.info( | ||||
"Sending invalid transactions in blocks (and get banned!)") | "Sending invalid transactions in blocks (and get banned!)") | ||||
self.check_for_ban_on_rejected_block( | self.check_for_ban_on_rejected_block( | ||||
self.build_block(tip, [schnorr0tx]), BADINPUTS_ERROR) | self.build_block(tip, [schnorr0tx]), BADINPUTS_ERROR) | ||||
self.check_for_ban_on_rejected_block( | self.check_for_ban_on_rejected_block( | ||||
self.build_block(tip, [schnorr1tx]), BADINPUTS_ERROR) | self.build_block(tip, [schnorr1tx]), BADINPUTS_ERROR) | ||||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
# save this tip for later | # save this tip for later | ||||
upgrade_block = tip | upgrade_block = tip | ||||
self.log.info( | self.log.info( | ||||
"Trying to mine a legacy nulldummy violation, but we are just barely too late") | "Trying to mine a legacy nulldummy violation, but we are just barely too late") | ||||
self.check_for_ban_on_rejected_block( | self.check_for_ban_on_rejected_block( | ||||
self.build_block(tip, [ecdsa1tx_2]), BADINPUTS_ERROR) | self.build_block(tip, [ecdsa1tx_2]), BADINPUTS_ERROR) | ||||
self.log.info( | self.log.info( | ||||
"If we try to submit it by mempool or RPC, the error code has changed but we still aren't banned") | "If we try to submit it by mempool or RPC, the error code has changed and we are banned") | ||||
assert_raises_rpc_error(-26, POSTUPGRADE_ECDSA_NULLDUMMY_ERROR, | assert_raises_rpc_error(-26, POSTUPGRADE_ECDSA_NULLDUMMY_ERROR, | ||||
node.sendrawtransaction, ToHex(ecdsa1tx_2)) | node.sendrawtransaction, ToHex(ecdsa1tx_2)) | ||||
self.check_for_no_ban_on_rejected_tx( | self.check_for_ban_on_rejected_tx( | ||||
ecdsa1tx_2, POSTUPGRADE_ECDSA_NULLDUMMY_ERROR) | ecdsa1tx_2, POSTUPGRADE_ECDSA_NULLDUMMY_ERROR) | ||||
self.log.info( | self.log.info( | ||||
"Submitting a new Schnorr-multisig via net, and mining it in a block") | "Submitting a new Schnorr-multisig via net, and mining it in a block") | ||||
node.p2p.send_txs_and_test([schnorr1tx], node) | node.p2p.send_txs_and_test([schnorr1tx], node) | ||||
assert_equal(set(node.getrawmempool()), { | assert_equal(set(node.getrawmempool()), { | ||||
ecdsa0tx_2.hash, schnorr1tx.hash}) | ecdsa0tx_2.hash, schnorr1tx.hash}) | ||||
tip = self.build_block(tip, [schnorr1tx]) | tip = self.build_block(tip, [schnorr1tx]) | ||||
▲ Show 20 Lines • Show All 57 Lines • Show Last 20 Lines |