Skip to content

Commit

Permalink
Remove sunsetted op_return replay protection
Browse files Browse the repository at this point in the history
Summary: We now passed the sunset height, so this is not necessary anymore

Test Plan:
  make check
  ./test/functional/test_runner.py

Reviewers: #bitcoin_abc, jasonbcox

Reviewed By: #bitcoin_abc, jasonbcox

Subscribers: teamcity

Differential Revision: https://reviews.bitcoinabc.org/D1412
  • Loading branch information
deadalnix committed May 14, 2018
1 parent b987db4 commit 09ec5e9
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 192 deletions.
2 changes: 1 addition & 1 deletion src/Makefile.test.include
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ BITCOIN_TESTS =\
test/rpc_tests.cpp \
test/sanity_tests.cpp \
test/scheduler_tests.cpp \
test/script_antireplay_tests.cpp \
test/script_commitment_tests.cpp \
test/script_P2SH_tests.cpp \
test/script_tests.cpp \
test/script_sighashtype_tests.cpp \
Expand Down
15 changes: 0 additions & 15 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,6 @@

#include "chainparamsseeds.h"

// Far into the future.
static const std::string ANTI_REPLAY_COMMITMENT =
"Bitcoin: A Peer-to-Peer Electronic Cash System";

static std::vector<uint8_t> GetAntiReplayCommitment() {
return std::vector<uint8_t>(std::begin(ANTI_REPLAY_COMMITMENT),
std::end(ANTI_REPLAY_COMMITMENT));
}

static CBlock CreateGenesisBlock(const char *pszTimestamp,
const CScript &genesisOutputScript,
uint32_t nTime, uint32_t nNonce,
Expand Down Expand Up @@ -106,8 +97,6 @@ class CMainParams : public CChainParams {
consensus.BIP65Height = 388381;
// 00000000000000000379eaa19dce8c9b722d46ae6a57c2f1a988119488b50931
consensus.BIP66Height = 363725;
consensus.antiReplayOpReturnSunsetHeight = 530000;
consensus.antiReplayOpReturnCommitment = GetAntiReplayCommitment();
consensus.powLimit = uint256S(
"00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
// two weeks
Expand Down Expand Up @@ -283,8 +272,6 @@ class CTestNetParams : public CChainParams {
consensus.BIP65Height = 581885;
// 000000002104c8c45e99a8853285a3b592602a3ccde2b832481da85e9e4ba182
consensus.BIP66Height = 330776;
consensus.antiReplayOpReturnSunsetHeight = 1250000;
consensus.antiReplayOpReturnCommitment = GetAntiReplayCommitment();
consensus.powLimit = uint256S(
"00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
// two weeks
Expand Down Expand Up @@ -422,8 +409,6 @@ class CRegTestParams : public CChainParams {
consensus.BIP65Height = 1351;
// BIP66 activated on regtest (Used in rpc activation tests)
consensus.BIP66Height = 1251;
consensus.antiReplayOpReturnSunsetHeight = 530000;
consensus.antiReplayOpReturnCommitment = GetAntiReplayCommitment();
consensus.powLimit = uint256S(
"7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
// two weeks
Expand Down
4 changes: 0 additions & 4 deletions src/consensus/params.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ struct Params {
int monolithActivationTime;
/** Unix time used for MTP activation of Nov 15 2018, hardfork */
int magneticAnomalyActivationTime;
/** Block height at which OP_RETURN replay protection stops */
int antiReplayOpReturnSunsetHeight;
/** Committed OP_RETURN value for replay protection */
std::vector<uint8_t> antiReplayOpReturnCommitment;
/**
* Minimum blocks including miner confirmation of the total of 2016 blocks
* in a retargeting period, (nPowTargetTimespan / nPowTargetSpacing) which
Expand Down
2 changes: 1 addition & 1 deletion src/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ add_test_to_suite(bitcoin test_bitcoin
rpc_tests.cpp
sanity_tests.cpp
scheduler_tests.cpp
script_antireplay_tests.cpp
script_commitment_tests.cpp
script_P2SH_tests.cpp
script_tests.cpp
script_sighashtype_tests.cpp
Expand Down
157 changes: 0 additions & 157 deletions src/test/script_antireplay_tests.cpp

This file was deleted.

62 changes: 62 additions & 0 deletions src/test/script_commitment_tests.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// Copyright (c) 2017 The Bitcoin developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include "script/script.h"
#include "test/test_bitcoin.h"

#include "chainparams.h"
#include "config.h"
#include "consensus/validation.h"
#include "validation.h"

#include <boost/test/unit_test.hpp>

#include <string>
#include <vector>

BOOST_FIXTURE_TEST_SUITE(script_commitmenet_tests, BasicTestingSetup)

BOOST_AUTO_TEST_CASE(test_is_commitment) {
std::vector<uint8_t> data{};

// Empty commitment.
auto s = CScript() << OP_RETURN << data;
BOOST_CHECK(s.IsCommitment(data));

// Commitment to a value of the wrong size.
data.push_back(42);
BOOST_CHECK(!s.IsCommitment(data));

// Not a commitment.
s = CScript() << data;
BOOST_CHECK(!s.IsCommitment(data));

// Non empty commitment.
s = CScript() << OP_RETURN << data;
BOOST_CHECK(s.IsCommitment(data));

// Commitment to the wrong value.
data[0] = 0x42;
BOOST_CHECK(!s.IsCommitment(data));

// Commitment to a larger value.
std::string str = "Bitcoin: A peer-to-peer Electronic Cash System";
data = std::vector<uint8_t>(str.begin(), str.end());
BOOST_CHECK(!s.IsCommitment(data));

s = CScript() << OP_RETURN << data;
BOOST_CHECK(s.IsCommitment(data));

// 64 bytes commitment, still valid.
data.resize(64);
s = CScript() << OP_RETURN << data;
BOOST_CHECK(s.IsCommitment(data));

// Commitment is too large.
data.push_back(23);
s = CScript() << OP_RETURN << data;
BOOST_CHECK(!s.IsCommitment(data));
}

BOOST_AUTO_TEST_SUITE_END()
14 changes: 0 additions & 14 deletions src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3622,20 +3622,6 @@ bool ContextualCheckTransaction(const Config &config, const CTransaction &tx,
"non-final transaction");
}

const Consensus::Params &consensusParams =
config.GetChainParams().GetConsensus();

if (IsUAHFenabled(config, nHeight) &&
nHeight <= consensusParams.antiReplayOpReturnSunsetHeight) {
for (const CTxOut &o : tx.vout) {
if (o.scriptPubKey.IsCommitment(
consensusParams.antiReplayOpReturnCommitment)) {
return state.DoS(10, false, REJECT_INVALID, "bad-txn-replay",
false, "non playable transaction");
}
}
}

return true;
}

Expand Down

0 comments on commit 09ec5e9

Please sign in to comment.