Page MenuHomePhabricator

validation: only check input scripts once
Changes PlannedPublic

Authored by PiRK on Fri, Nov 14, 12:22.

Details

Reviewers
None
Group Reviewers
Restricted Project
Summary

Previously, we would check failing input scripts twice when considering
a transaction for the mempool, in order to distinguish policy failures
from consensus failures. This allowed us both to provide a different
error message and to discourage peers for consensus failures. Because we
are no longer discouraging peers for consensus failures during tx relay,
and because checking a script can be expensive, only do this once.

Also renames non-mandatory-script-verify-flag error to
mempool-script-verify-flag-failed.

This is a backport of core#33050
https://github.com/bitcoin/bitcoin/pull/33050/commits/b29ae9efdfeeff774e32ee433ce67d8ed8ecd49f

Depends on D18933

Test Plan

ninja all check-all

Event Timeline

Failed tests logs:

====== AgoraPartial enforcedLockTime: AgoraPartial enforcedLockTime AgoraPartial enforcedLockTime ======
AssertionError: expected promise to be rejected with an error including 'Failed getting /broadcast-tx: 400: Br…' but got 'Failed getting /broadcast-tx: 400: Br…'

      + expected - actual

      -Failed getting /broadcast-tx: 400: Broadcast failed: Transaction rejected by mempool: mempool-script-verify-flag-failed (Script failed an OP_EQUALVERIFY operation), input 2 of f9844a277cfe190f3bc9abe30921d6b1e80f6748249e4c3cc342902f0280df23, spending f7a455f0d2cc521ce071223e7f219155f5c4029ef8a11d1c93128ac6a82bff72:1
      +Failed getting /broadcast-tx: 400: Broadcast failed: Transaction rejected by mempool: mandatory-script-verify-flag-failed (Script failed an OP_EQUALVERIFY operation)

Each failure log is accessible here:
AgoraPartial enforcedLockTime: AgoraPartial enforcedLockTime AgoraPartial enforcedLockTime

fix accidental squashing

@bot build-chronik chronik-client-integration-tests

fix an agora integration test

Failed tests logs:

====== AgoraPartial enforcedLockTime: AgoraPartial enforcedLockTime AgoraPartial enforcedLockTime ======
AssertionError: expected promise to be rejected with an error including 'Failed getting /broadcast-tx: 400: Br…' but got 'Failed getting /broadcast-tx: 400: Br…'

      + expected - actual

      -Failed getting /broadcast-tx: 400: Broadcast failed: Transaction rejected by mempool: mempool-script-verify-flag-failed (Script failed an OP_EQUALVERIFY operation), input 2 of f9844a277cfe190f3bc9abe30921d6b1e80f6748249e4c3cc342902f0280df23, spending f7a455f0d2cc521ce071223e7f219155f5c4029ef8a11d1c93128ac6a82bff72:1
      +Failed getting /broadcast-tx: 400: Broadcast failed: Transaction rejected by mempool: mandatory-script-verify-flag-failed (Script failed an OP_EQUALVERIFY operation)

Each failure log is accessible here:
AgoraPartial enforcedLockTime: AgoraPartial enforcedLockTime AgoraPartial enforcedLockTime

PiRK published this revision for review.Mon, Nov 17, 09:51

@bot ecash-agora-integration-tests chronik-client-integration-tests

PiRK planned changes to this revision.Tue, Nov 18, 13:47

The benefit / risk ratio is not clear on that one. The benefits are limited to deduplicating the script checks, and the risks involve making some CPU DoS attacks easier to perform.
This needs more consideration.