mirror of
https://github.com/dashpay/dash.git
synced 2024-12-27 13:03:17 +01:00
Merge #9619: Bugfix: RPC/Mining: GBT should return 1 MB sizelimit before segwit activates
279f944
QA: Test GBT size/weight limit values (Luke Dashjr)9fc7f0b
Bugfix: RPC/Mining: GBT should return 1 MB sizelimit before segwit activates (Luke Dashjr)
This commit is contained in:
commit
aa791e2911
@ -130,10 +130,14 @@ class SegWitTest(BitcoinTestFramework):
|
|||||||
print("Verify sigops are counted in GBT with pre-BIP141 rules before the fork")
|
print("Verify sigops are counted in GBT with pre-BIP141 rules before the fork")
|
||||||
txid = self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), 1)
|
txid = self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), 1)
|
||||||
tmpl = self.nodes[0].getblocktemplate({})
|
tmpl = self.nodes[0].getblocktemplate({})
|
||||||
|
assert(tmpl['sizelimit'] == 1000000)
|
||||||
|
assert('weightlimit' not in tmpl)
|
||||||
assert(tmpl['sigoplimit'] == 20000)
|
assert(tmpl['sigoplimit'] == 20000)
|
||||||
assert(tmpl['transactions'][0]['hash'] == txid)
|
assert(tmpl['transactions'][0]['hash'] == txid)
|
||||||
assert(tmpl['transactions'][0]['sigops'] == 2)
|
assert(tmpl['transactions'][0]['sigops'] == 2)
|
||||||
tmpl = self.nodes[0].getblocktemplate({'rules':['segwit']})
|
tmpl = self.nodes[0].getblocktemplate({'rules':['segwit']})
|
||||||
|
assert(tmpl['sizelimit'] == 1000000)
|
||||||
|
assert('weightlimit' not in tmpl)
|
||||||
assert(tmpl['sigoplimit'] == 20000)
|
assert(tmpl['sigoplimit'] == 20000)
|
||||||
assert(tmpl['transactions'][0]['hash'] == txid)
|
assert(tmpl['transactions'][0]['hash'] == txid)
|
||||||
assert(tmpl['transactions'][0]['sigops'] == 2)
|
assert(tmpl['transactions'][0]['sigops'] == 2)
|
||||||
@ -241,6 +245,8 @@ class SegWitTest(BitcoinTestFramework):
|
|||||||
print("Verify sigops are counted in GBT with BIP141 rules after the fork")
|
print("Verify sigops are counted in GBT with BIP141 rules after the fork")
|
||||||
txid = self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), 1)
|
txid = self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), 1)
|
||||||
tmpl = self.nodes[0].getblocktemplate({'rules':['segwit']})
|
tmpl = self.nodes[0].getblocktemplate({'rules':['segwit']})
|
||||||
|
assert(tmpl['sizelimit'] >= 3999577) # actual maximum size is lower due to minimum mandatory non-witness data
|
||||||
|
assert(tmpl['weightlimit'] == 4000000)
|
||||||
assert(tmpl['sigoplimit'] == 80000)
|
assert(tmpl['sigoplimit'] == 80000)
|
||||||
assert(tmpl['transactions'][0]['txid'] == txid)
|
assert(tmpl['transactions'][0]['txid'] == txid)
|
||||||
assert(tmpl['transactions'][0]['sigops'] == 8)
|
assert(tmpl['transactions'][0]['sigops'] == 8)
|
||||||
@ -250,6 +256,8 @@ class SegWitTest(BitcoinTestFramework):
|
|||||||
try:
|
try:
|
||||||
tmpl = self.nodes[0].getblocktemplate({})
|
tmpl = self.nodes[0].getblocktemplate({})
|
||||||
assert(len(tmpl['transactions']) == 1) # Doesn't include witness tx
|
assert(len(tmpl['transactions']) == 1) # Doesn't include witness tx
|
||||||
|
assert(tmpl['sizelimit'] == 1000000)
|
||||||
|
assert('weightlimit' not in tmpl)
|
||||||
assert(tmpl['sigoplimit'] == 20000)
|
assert(tmpl['sigoplimit'] == 20000)
|
||||||
assert(tmpl['transactions'][0]['hash'] == txid)
|
assert(tmpl['transactions'][0]['hash'] == txid)
|
||||||
assert(tmpl['transactions'][0]['sigops'] == 2)
|
assert(tmpl['transactions'][0]['sigops'] == 2)
|
||||||
|
@ -676,8 +676,12 @@ UniValue getblocktemplate(const JSONRPCRequest& request)
|
|||||||
nSigOpLimit /= WITNESS_SCALE_FACTOR;
|
nSigOpLimit /= WITNESS_SCALE_FACTOR;
|
||||||
}
|
}
|
||||||
result.push_back(Pair("sigoplimit", nSigOpLimit));
|
result.push_back(Pair("sigoplimit", nSigOpLimit));
|
||||||
result.push_back(Pair("sizelimit", (int64_t)MAX_BLOCK_SERIALIZED_SIZE));
|
if (fPreSegWit) {
|
||||||
result.push_back(Pair("weightlimit", (int64_t)MAX_BLOCK_WEIGHT));
|
result.push_back(Pair("sizelimit", (int64_t)MAX_BLOCK_BASE_SIZE));
|
||||||
|
} else {
|
||||||
|
result.push_back(Pair("sizelimit", (int64_t)MAX_BLOCK_SERIALIZED_SIZE));
|
||||||
|
result.push_back(Pair("weightlimit", (int64_t)MAX_BLOCK_WEIGHT));
|
||||||
|
}
|
||||||
result.push_back(Pair("curtime", pblock->GetBlockTime()));
|
result.push_back(Pair("curtime", pblock->GetBlockTime()));
|
||||||
result.push_back(Pair("bits", strprintf("%08x", pblock->nBits)));
|
result.push_back(Pair("bits", strprintf("%08x", pblock->nBits)));
|
||||||
result.push_back(Pair("height", (int64_t)(pindexPrev->nHeight+1)));
|
result.push_back(Pair("height", (int64_t)(pindexPrev->nHeight+1)));
|
||||||
|
Loading…
Reference in New Issue
Block a user