Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove BLS activation fork logic + fixes #322

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,6 @@ class CMainParams : public CChainParams {
consensus.defaultAssumeValid = uint256S(
"000000000000000003aadeae9dee37b8cb4838a866dae19b54854a0f039b03e0");

// Date and time (GMT): Saturday, October 10, 2020 4:00:00 PM
consensus.blsActivationTime = 1602345600;

/**
* The message start string is designed to be unlikely to occur in
* normal data. The characters are rarely used upper ASCII, not valid as
Expand Down Expand Up @@ -201,9 +198,7 @@ class CTestNetParams : public CChainParams {
consensus.defaultAssumeValid = uint256S(
"000000000000030bee568d677b6b99ee7d2d00b25d1fe95df5e73b484f00c322");

// Date July 11, 2020, 4:00:00 pm GMT
//consensus.blsActivationTime = 1594483200;
consensus.blsActivationTime = 1595895427;

diskMagic[0] = 0x0d;
diskMagic[1] = 0x08;
diskMagic[2] = 0x13;
Expand Down Expand Up @@ -281,9 +276,6 @@ class CRegTestParams : public CChainParams {
// valid.
consensus.defaultAssumeValid = uint256S("0x00");

// TBD
consensus.blsActivationTime = 1999999999;

diskMagic[0] = 0xfa;
diskMagic[1] = 0xbf;
diskMagic[2] = 0xb5;
Expand Down
1 change: 0 additions & 1 deletion src/combine_transactions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ CMutableTransaction combine_transactions(const std::vector<CMutableTransaction>
combined_sigs.push_back(uint8_t(sigHashType.getRawSigHashType()));

cfinal << combined_sigs;
cfinal << OP_CHECKSIG; // do we need this?, check later

// Push back vin now with new script
vin.scriptSig = cfinal;
Expand Down
6 changes: 1 addition & 5 deletions src/consensus/activation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,5 @@ bool IsBLSEnabled(const Config &config, const CBlockIndex *pindexPrev) {
if (pindexPrev == nullptr) {
return false;
}

return pindexPrev->GetMedianTimePast() >=
gArgs.GetArg(
"-blsactivationtime",
config.GetChainParams().GetConsensus().blsActivationTime);
return true;
}
2 changes: 0 additions & 2 deletions src/primitives/create_bls_transaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ auto CreatePrivateTxWithSig(const std::vector<CKey>& keys,
c << ToByteVector(pub); // Add random pubkeys to the last input

c << aggSig;
c << OP_CHECKSIG; // since we have custom extraction not sure we actually
// need this, check later

// Put Agg Sig + Random Public Keys into the vin of the last input of the
// tx.
Expand Down
2 changes: 1 addition & 1 deletion src/script/standard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ bool IsValidBLSScriptSize(const CScript &script) {
auto script_size = script.size();
//std::cout << "Script size = << " << script_size << "\n";
if (script_size > CPubKey::BLS_PUBLIC_KEY_SIZE+2) {
script_size -= (CPubKey::BLS_SIGNATURE_SIZE + 4);
script_size -= (CPubKey::BLS_SIGNATURE_SIZE + 3);
return ((script_size % (CPubKey::BLS_PUBLIC_KEY_SIZE+1) == 0));
} else {
return ((script.size() == CPubKey::BLS_PUBLIC_KEY_SIZE+1) ||
Expand Down
23 changes: 6 additions & 17 deletions src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,11 +342,6 @@ std::string FormatStateMessage(const CValidationState &state) {
state.GetRejectCode());
}

static bool IsBLSEnabledForCurrentBlock(const Config &config) EXCLUSIVE_LOCKS_REQUIRED(cs_main) {
AssertLockHeld(cs_main);
return IsBLSEnabled(config, chainActive.Tip());
}

// Used to avoid mempool polluting consensus critical paths if CCoinsViewMempool
// were somehow broken and returning the wrong scriptPubKeys
static bool CheckInputsFromMempoolAndCache(
Expand Down Expand Up @@ -642,10 +637,8 @@ static bool AcceptToMemoryPoolWorker(
// Set extraFlags as a set of flags that needs to be activated.
uint32_t extraFlags = SCRIPT_VERIFY_NONE;

if (IsBLSEnabledForCurrentBlock(config)) {
extraFlags |= SCRIPT_ENABLE_BLS;
extraFlags |= SCRIPT_VERIFY_CHECKDATASIG_SIGOPS;
}
extraFlags |= SCRIPT_ENABLE_BLS;
extraFlags |= SCRIPT_VERIFY_CHECKDATASIG_SIGOPS;

// Make sure whatever we need to activate is actually activated.
const uint32_t scriptVerifyFlags =
Expand Down Expand Up @@ -1622,18 +1615,14 @@ static uint32_t GetBlockScriptFlags(const Config &config,
// transactions using the OP_CHECKDATASIG opcode and it's verify
// alternative. We also start enforcing push only signatures and
// clean stack.
if (IsBLSEnabled(config, pChainTip)) {
flags |= SCRIPT_VERIFY_CHECKDATASIG_SIGOPS;
flags |= SCRIPT_VERIFY_SIGPUSHONLY;
flags |= SCRIPT_VERIFY_CLEANSTACK;
}
flags |= SCRIPT_VERIFY_CHECKDATASIG_SIGOPS;
flags |= SCRIPT_VERIFY_SIGPUSHONLY;
flags |= SCRIPT_VERIFY_CLEANSTACK;

// If the Great Wall fork is enabled, we start accepting transactions
// recovering coins sent to BLS addresses. We also stop accepting 65 byte signatures in
// CHECKMULTISIG and its verify variant.
if (IsBLSEnabledForCurrentBlock(config)) {
flags |= SCRIPT_ENABLE_BLS;
}
flags |= SCRIPT_ENABLE_BLS;

return flags;
}
Expand Down
2 changes: 0 additions & 2 deletions src/wallet/bls_tx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,6 @@ auto CreatePrivateTxWithSig(const CWallet *pwallet,
c << ToByteVector(pub); // Add random pubkeys to the last input

c << aggSig;
c << OP_CHECKSIG; // since we have custom extraction not sure we actually
// need this, check later

// Put Agg Sig + Random Public Keys into the vin of the last input of the
// tx.
Expand Down