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

Update Regtest Specific Params #676

Closed
wants to merge 5 commits into from

Conversation

tynes
Copy link
Member

@tynes tynes commented Jan 25, 2019

This pull request updates the key prefixes and address prefixes to match bitcoind and btcd.
Addresses this issue: #579
See https://github.com/satoshilabs/slips/blob/master/slip-0173.md for a list of human readable prefixes

It build on #580 and reverts the change that sets the segwitstartTime to -1
https://github.com/bcoin-org/bcoin/pull/580/files#diff-44d3bcd9142fb799b54cb36cac72561eR804.

startTime is written and read from leveldb as a uint, as seen here:
https://github.com/bcoin-org/bcoin/blob/master/lib/blockchain/chaindb.js#L648
so setting it to -1 will cause an underflow and breaks some tests

@codecov-io
Copy link

codecov-io commented Jan 28, 2019

Codecov Report

Merging #676 into master will increase coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #676      +/-   ##
==========================================
+ Coverage   53.38%   53.39%   +0.01%     
==========================================
  Files         104      104              
  Lines       27709    27711       +2     
  Branches     4746     4747       +1     
==========================================
+ Hits        14792    14797       +5     
+ Misses      12917    12914       -3
Impacted Files Coverage Δ
lib/protocol/networks.js 100% <ø> (ø) ⬆️
lib/blockchain/chain.js 60.62% <100%> (+0.07%) ⬆️
lib/blockchain/chaindb.js 56.88% <100%> (+0.09%) ⬆️
lib/mining/template.js 87.32% <0%> (-0.85%) ⬇️
lib/node/rpc.js 23.58% <0%> (+0.19%) ⬆️
lib/coins/compress.js 56.32% <0%> (+1.26%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7f736db...b016cb0. Read the comment docs.

@pinheadmz
Copy link
Member

Confirmed these match bitcoin core regtest params: https://github.com/bitcoin/bitcoin/blob/master/src/chainparams.cpp#L342-L348
...even though they're base58 prefixes are encoded in... decimal?!

Also compiled Bitcoin Core from source, ran it in regtest and networked it with bcoin in regtest running locally. Ran my txmess script to generate 100s of blocks and txs, and the nodes synced fine. Randomly picked a block and printed all the txs | grep address from both nodes JUST to make extra double hella sure Core generates the same addresses as bcoin in regtest after this PR

Copy link
Member

@tuxcanfly tuxcanfly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

@pinheadmz
Copy link
Member

pinheadmz
pinheadmz previously approved these changes Jan 31, 2019
@braydonf
Copy link
Contributor

So I'm still getting an issue with connecting a Bitcoin Core regtest node and Bcoin regtest node here because of the activation time.

[debug] (peer) Rejecting block 5803d64a9bd67fc914c7b05db3beae3e2308b819578629beaeea12764bd890c1 (127.0.0.1:18444): code=invalid reason=unexpected-witness.

The change here 53a09b0 with the activation was necessary for that.

@pinheadmz
Copy link
Member

@braydonf What's your process? I networked bcoin and Bitcoin Core in regtest, and in bcoin:

bcoin-cli --http-port=8888 rpc generatetoaddress 1 bcrt1qa2v6v49gftjekdkulwz8zj7vj6ln26j0te9ldw

Bitcoin Core shows the block in the chain just fine (even though coinbase address was segwit)

./bitcoin-cli -regtest getblock `./bitcoin-cli -regtest getblockhash 1`
{
  "hash": "43c169241d289eda42cc1388a1576b089111c5a3e1a821c97ca9400f208608fe",
  "confirmations": 1,
  "strippedsize": 193,
  "size": 193,
  "weight": 772,
  "height": 1,
  "version": 536870912,
  "versionHex": "20000000",
  "merkleroot": "d866f842b06ac48cf84d794fb5ef2dc4d216e286f46929c6c5e3cdf74d9a7a22",
  "tx": [
    "d866f842b06ac48cf84d794fb5ef2dc4d216e286f46929c6c5e3cdf74d9a7a22"
  ],
  "time": 1548959281,
  "mediantime": 1548959281,
  "nonce": 1,
  "bits": "207fffff",
  "difficulty": 4.656542373906925e-10,
  "chainwork": "0000000000000000000000000000000000000000000000000000000000000004",
  "nTx": 1,
  "previousblockhash": "0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206"
}

@pinheadmz
Copy link
Member

Oh weird - ok, however bcoin rejected a segwit block from Core:

[warning] (chain) Tried to connect invalid block: 3665d2bd2df0f13b3a2fbced0f384c85328cddf5883986b30da551cee195e459 (2).
[debug] (peer) Rejecting block 3665d2bd2df0f13b3a2fbced0f384c85328cddf5883986b30da551cee195e459 (127.0.0.1:62908): code=invalid reason=unexpected-witness.
[debug] (peer) Sending reject packet to peer (127.0.0.1:62908).
[debug] (peer) Ban threshold exceeded (127.0.0.1:62908).
[debug] (net) Banning peer (127.0.0.1:62908).
[warning] (net) Error: Verification failure: unexpected-witness (code=invalid score=100 hash=3665d2bd2df0f13b3a2fbced0f384c85328cddf5883986b30da551cee195e459)

@braydonf
Copy link
Contributor

Here are my steps for testing:

Start and connect Bitcoin Core and Bcoin nodes:

./bitcoin/src/bitcoind -regtest -printtoconsole
./bin/bcoin --network=regtest --nodes=127.0.0.1:18444

Make sure that the regtest chain data is clear for each for a fresh chain and that the nodes connect. Your port configurations may vary.

Getting blockchain information from Bitcoin Core:

./bitcoin/src/bitcoin-cli -regtest getblockchaininfo

Getting blockchain information from Bcoin:

./bitcoin/src/bitcoin-cli -regtest -rpcport=48332 getblockchaininfo

Generating blocks:

./bitcoin/src/bitcoin-cli -regtest getnewaddress
./bitcoin/src/bitcoin-cli -regtest generatetoaddress 1 <address>

And then verifying that both chains have the block using the above commands.

@pinheadmz
Copy link
Member

Actually I can confirm with rpc getblockchaininfo

Bitcoin Core:

    "segwit": {
      "status": "active",
      "startTime": -1,
      "timeout": 9223372036854775807,
      "since": 0
    }

bcoin:

    "segwit": {
      "status": "defined",
      "bit": 1,
      "startTime": 0,
      "timeout": 4294967295
    },

@pinheadmz pinheadmz dismissed their stale review January 31, 2019 18:36

oops wont sync w core

@pinheadmz
Copy link
Member

Gonna revert b10aea8 and test more

@braydonf
Copy link
Contributor

braydonf commented Jan 31, 2019

Tested, and is syncing and the deployments cache will be refreshed.

Copy link
Contributor

@braydonf braydonf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM after rebase on master.

tuxcanfly and others added 5 commits January 31, 2019 14:06
The deployments are written to and read
from a database and the start time is
a U32. Changing the value to -1 will cause
the value to be read incorrectly and cause
the tests to fail.
@tynes
Copy link
Member Author

tynes commented Jan 31, 2019

Rebased

@aquaflamingo
Copy link

possible to get this merged?

braydonf added a commit to braydonf/bcoin that referenced this pull request Feb 5, 2019
@braydonf
Copy link
Contributor

braydonf commented Feb 6, 2019

Merged at 39684df

@braydonf braydonf closed this Feb 6, 2019
@braydonf braydonf mentioned this pull request Feb 6, 2019
@tynes tynes deleted the tynes/update-regtest branch February 6, 2019 21:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants