Skip to content

Commit

Permalink
Merge #6302: feat: remove DIP0020 requirement for OP_ since it is act…
Browse files Browse the repository at this point in the history
…ivated long time ago

c8fd37d docs: added a comment about removed SCRIPT_ENABLE_DIP0020_OPCODES (Konstantin Akimov)
61bc300 feat: drop SCRIPT_ENABLE_DIP0020_OPCODES, make opcodes available from genesis block (Konstantin Akimov)
0e55abd feat: remove feature_dip0020_activationl.py functional test and related code (Konstantin Akimov)

Pull request description:

  ## Issue being fixed or feature implemented
  it's alternate solution for #6299 to fix a crash reported #6256

  ## What was done?
  Removed code related to DIP0020 activation for various OP codes. DIP0020 is activated long time ago and no any historical blocks are violating rules, removing it's backwards compatible.

  ## How Has This Been Tested?
  Run unit and functional tests. See also changes in data for unit tests and removed functional test.
  It also re-index mainnet and testnet successfully
  ```
  src/qt/dash-qt  -reindex -assumevalid=0
  src/qt/dash-qt -testnet -reindex -assumevalid=0
  ```

  Also extra test is done with bitcoin#23590 - no crash with it in `feature_dip0020_activation.py` [modified assuming it is always activated]

  ## Breaking Changes
  N/A

  ## Checklist:
  - [x] I have performed a self-review of my own code
  - [x] I have commented my code, particularly in hard-to-understand areas
  - [x] I have added or updated relevant unit/integration/functional/e2e tests
  - [x] I have made corresponding changes to the documentation
  - [x] I have assigned this pull request to a milestone

ACKs for top commit:
  UdjinM6:
    utACK c8fd37d
  PastaPastaPasta:
    utACK c8fd37d

Tree-SHA512: 05ddda4e8fb66305995e91c8a04fbda690aef8fb82acb23b7d62f302da60b5ec7e7a97bd988efd2523dbd9cafde9f4b65cae2db9e4b5257464ce1c8fcca6a40f
  • Loading branch information
PastaPastaPasta committed Oct 15, 2024
2 parents dc02da1 + c8fd37d commit 5318d68
Show file tree
Hide file tree
Showing 13 changed files with 239 additions and 400 deletions.
4 changes: 1 addition & 3 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ class CRegTestParams : public CChainParams {
consensus.DIP0003EnforcementHash = uint256();
consensus.DIP0008Height = 1; // Always active unless overridden
consensus.BRRHeight = 1; // Always active unless overridden
consensus.DIP0020Height = 1;
consensus.DIP0020Height = 1; // Always active unless overridden
consensus.DIP0024Height = 900;
consensus.DIP0024QuorumsHeight = 900;
consensus.V19Height = 900;
Expand Down Expand Up @@ -999,8 +999,6 @@ static void MaybeUpdateHeights(const ArgsManager& args, Consensus::Params& conse
consensus.DIP0001Height = int{height};
} else if (name == "dip0008") {
consensus.DIP0008Height = int{height};
} else if (name == "dip0020") {
consensus.DIP0020Height = int{height};
} else if (name == "v20") {
consensus.V20Height = int{height};
} else if (name == "mn_rr") {
Expand Down
2 changes: 1 addition & 1 deletion src/chainparamsbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ void SetupChainParamsBaseOptions(ArgsManager& argsman)
argsman.AddArg("-dip3params=<activation>:<enforcement>", "Override DIP3 activation and enforcement heights (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS);
argsman.AddArg("-dip8params=<activation>", "Override DIP8 activation height (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS);
argsman.AddArg("-bip147height=<activation>", "Override BIP147 activation height (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS);
argsman.AddArg("-testactivationheight=name@height.", "Set the activation height of 'name' (bip147, bip34, dersig, cltv, csv, brr, dip0001, dip0008, dip0020, v20, mn_rr). (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST);
argsman.AddArg("-testactivationheight=name@height.", "Set the activation height of 'name' (bip147, bip34, dersig, cltv, csv, brr, dip0001, dip0008, v20, mn_rr). (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST);
argsman.AddArg("-highsubsidyblocks=<n>", "The number of blocks with a higher than normal subsidy to mine at the start of a chain. Block after that height will have fixed subsidy base. (default: 0, devnet-only)", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS);
argsman.AddArg("-highsubsidyfactor=<n>", "The factor to multiply the normal block subsidy by while in the highsubsidyblocks window of a chain (default: 1, devnet-only)", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS);
argsman.AddArg("-llmqchainlocks=<quorum name>", "Override the default LLMQ type used for ChainLocks. Allows using ChainLocks with smaller LLMQs. (default: llmq_devnet, devnet-only)", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS);
Expand Down
1 change: 0 additions & 1 deletion src/policy/policy.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ static constexpr unsigned int STANDARD_SCRIPT_VERIFY_FLAGS = MANDATORY_SCRIPT_VE
SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY |
SCRIPT_VERIFY_CHECKSEQUENCEVERIFY |
SCRIPT_VERIFY_LOW_S |
SCRIPT_ENABLE_DIP0020_OPCODES |
SCRIPT_VERIFY_CONST_SCRIPTCODE;

/** For convenience, standard but not mandatory verify flags. */
Expand Down
17 changes: 0 additions & 17 deletions src/script/interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,23 +409,6 @@ bool EvalScript(std::vector<std::vector<unsigned char> >& stack, const CScript&
if (opcode > OP_16 && ++nOpCount > MAX_OPS_PER_SCRIPT)
return set_error(serror, SCRIPT_ERR_OP_COUNT);

bool fDIP0020OpcodesEnabled = (flags & SCRIPT_ENABLE_DIP0020_OPCODES) != 0;
if (!fDIP0020OpcodesEnabled) {
if (opcode == OP_CAT ||
opcode == OP_SPLIT ||
opcode == OP_AND ||
opcode == OP_OR ||
opcode == OP_XOR ||
opcode == OP_DIV ||
opcode == OP_MOD ||
opcode == OP_NUM2BIN ||
opcode == OP_BIN2NUM ||
opcode == OP_CHECKDATASIG ||
opcode == OP_CHECKDATASIGVERIFY) {
return set_error(serror, SCRIPT_ERR_DISABLED_OPCODE); // Disabled opcodes.
}
}

if (opcode == OP_INVERT ||
opcode == OP_2MUL ||
opcode == OP_2DIV ||
Expand Down
7 changes: 5 additions & 2 deletions src/script/interpreter.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,11 @@ enum : uint32_t {
//
SCRIPT_VERIFY_NULLFAIL = (1U << 14),

// Enable the opcodes listed in DIP0020 (OP_CAT, OP_AND, OP_OR, OP_XOR, OP_DIV, OP_MOD, OP_SPLIT, OP_BIN2NUM, OP_NUM2BIN, OP_CHECKDATASIG, OP_CHECKDATASIGVERIFY).
SCRIPT_ENABLE_DIP0020_OPCODES = (1U << 15),
// DIP0020_OPCODES - ignored.
// Was used to enable the opcodes listed in DIP0020
// (OP_CAT, OP_AND, OP_OR, OP_XOR, OP_DIV, OP_MOD, OP_SPLIT, OP_BIN2NUM,
// OP_NUM2BIN, OP_CHECKDATASIG, OP_CHECKDATASIGVERIFY).
// SCRIPT_ENABLE_DIP0020_OPCODES = (1U << 15),

// Making OP_CODESEPARATOR and FindAndDelete fail
//
Expand Down
4 changes: 2 additions & 2 deletions src/test/checkdatasig_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ static void CheckError(uint32_t flags, const stacktype& original_stack,
BaseSignatureChecker sigchecker;
ScriptError err = ScriptError::SCRIPT_ERR_OK;
stacktype stack{original_stack};
bool r = EvalScript(stack, script, flags | SCRIPT_ENABLE_DIP0020_OPCODES, sigchecker, SigVersion::BASE, &err);
bool r = EvalScript(stack, script, flags, sigchecker, SigVersion::BASE, &err);
BOOST_CHECK(!r);
BOOST_CHECK(err == expected);
}
Expand All @@ -53,7 +53,7 @@ static void CheckPass(uint32_t flags, const stacktype& original_stack,
BaseSignatureChecker sigchecker;
ScriptError err = ScriptError::SCRIPT_ERR_OK;
stacktype stack{original_stack};
bool r = EvalScript(stack, script, flags | SCRIPT_ENABLE_DIP0020_OPCODES, sigchecker, SigVersion::BASE, &err);
bool r = EvalScript(stack, script, flags, sigchecker, SigVersion::BASE, &err);
BOOST_CHECK(r);
BOOST_CHECK(err == ScriptError::SCRIPT_ERR_OK);
BOOST_CHECK(stack == expected);
Expand Down
Loading

0 comments on commit 5318d68

Please sign in to comment.