From fa877503a4388756dca9d632952c2f302e995786 Mon Sep 17 00:00:00 2001 From: Braydon Fuller Date: Thu, 31 Jan 2019 13:02:40 -0800 Subject: [PATCH] blockchain: enable segwit for regtest --- lib/blockchain/chain.js | 3 +++ lib/blockchain/chaindb.js | 6 +++--- lib/protocol/networks.js | 2 +- test/http-test.js | 16 +++++++++++----- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/lib/blockchain/chain.js b/lib/blockchain/chain.js index 51329083..2c44b11d 100644 --- a/lib/blockchain/chain.js +++ b/lib/blockchain/chain.js @@ -2389,6 +2389,9 @@ class Chain extends AsyncEmitter { async getState(prev, deployment) { const bit = deployment.bit; + if (deployment.startTime === -1) + return thresholdStates.ACTIVE; + let window = this.network.minerWindow; let threshold = this.network.activationThreshold; diff --git a/lib/blockchain/chaindb.js b/lib/blockchain/chaindb.js index c0d09122..ec69b134 100644 --- a/lib/blockchain/chaindb.js +++ b/lib/blockchain/chaindb.js @@ -639,13 +639,13 @@ class ChainDB { */ writeDeployments(b) { - const bw = bio.write(1 + 17 * this.network.deploys.length); + const bw = bio.write(1 + 21 * this.network.deploys.length); bw.writeU8(this.network.deploys.length); for (const deployment of this.network.deploys) { bw.writeU8(deployment.bit); - bw.writeU32(deployment.startTime); + bw.writeI64(deployment.startTime); bw.writeU32(deployment.timeout); bw.writeI32(deployment.threshold); bw.writeI32(deployment.window); @@ -671,7 +671,7 @@ class ChainDB { for (let i = 0; i < count; i++) { const bit = br.readU8(); - const start = br.readU32(); + const start = br.readI64(); const timeout = br.readU32(); const threshold = br.readI32(); const window = br.readI32(); diff --git a/lib/protocol/networks.js b/lib/protocol/networks.js index 1072a1ad..0d440054 100644 --- a/lib/protocol/networks.js +++ b/lib/protocol/networks.js @@ -801,7 +801,7 @@ regtest.deployments = { segwit: { name: 'segwit', bit: 1, - startTime: 0, + startTime: -1, timeout: 0xffffffff, threshold: -1, window: -1, diff --git a/test/http-test.js b/test/http-test.js index 810cb6d6..9803ae9d 100644 --- a/test/http-test.js +++ b/test/http-test.js @@ -203,12 +203,14 @@ describe('HTTP', function() { }); it('should get a block template', async () => { - const json = await nclient.execute('getblocktemplate', []); + const json = await nclient.execute('getblocktemplate', [{ + rules: ['segwit'] + }]); assert.deepStrictEqual(json, { capabilities: ['proposal'], mutable: ['time', 'transactions', 'prevblock'], version: 536870912, - rules: [], + rules: ['!segwit'], vbavailable: {}, vbrequired: 0, height: 1, @@ -222,15 +224,19 @@ describe('HTTP', function() { mintime: 1296688603, maxtime: json.maxtime, expires: json.expires, - sigoplimit: 20000, - sizelimit: 1000000, + sigoplimit: 80000, + sizelimit: 4000000, + weightlimit: 4000000, longpollid: '0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206' + '00000000', submitold: false, coinbaseaux: { flags: '6d696e65642062792062636f696e' }, coinbasevalue: 5000000000, - transactions: [] + transactions: [], + default_witness_commitment: + '6a24aa21a9ede2f61c3f71d1defd3fa999dfa36953755c690689799962b48beb' + + 'd836974e8cf9' }); });