Giter Site home page Giter Site logo

pkt-cash / pktd Goto Github PK

View Code? Open in Web Editor NEW

This project forked from btcsuite/btcd

39.0 3.0 26.0 22.67 MB

The PKT full node and wallet

Home Page: https://pkt.cash/

License: ISC License

Go 99.32% Shell 0.45% Dockerfile 0.03% C 0.09% Makefile 0.08% Ruby 0.01% Batchfile 0.01% Perl 0.02%

pktd's Introduction

pktd

ISC License Master branch build Status Develop branch build Status

pktd is the primary full node PKT Cash implementation, written in Go.

The PKT Cash project is currently under active development and considered to be beta quality software.

In particular, the development branch of pktd is highly experimental, and should generally not be used in a production environment or on the PKT Cash mainnet.

pktd is the primary mainnet node software for the PKT blockchain. It is known to correctly download, validate, and serve the chain, using rules for block acceptance based on Bitcoin Core, with the addition of PacketCrypt Proofs.

It relays newly mined blocks, and individual transactions that have not yet made it into a block, as well as maintaining a transaction pool. All individual transactions admitted to the pool follow rules defined by the network operators, which include strict checks to filter transactions based on miner requirements ("standard" vs "non-standard" transactions).

Unlike other similar software, pktd does NOT directly include wallet functionality - this was an intentional design decision. You will not be able to make or receive payments with pktd directly.

Example wallet functionality is provided in the included, separate, pktwallet package.

Requirements

  • Google Go (Golang) version 1.14 or higher.
  • A somewhat recent release of Git.

Issue Tracker

Building

Using git, clone the project from the repository:

git clone https://github.com/pkt-cash/pktd

Use the ./do shell script to build pktd, pktwallet, and pktctl.

NOTE: It is highly recommended to use only the toolchain Google distributes at the official Go homepage. Go toolchains provided by Linux distributions often use different defaults or apply non-standard patches to the official sources, usually to meet distribution-specific requirements (for example, Red Hat backports, security fixes, and provides a different default linker configuration vs. the upstream Google Go package.)

Support can only be provided for binaries compiled from unmodified sources, using the official (upstream) Google Golang toolchain. We unfortunately are unable to test and support every distribution specific combination.

The official Google Golang installer for Linux is always available for download here.

Documentation

The documentation for pktd is work-in-progress, and available in the docs folder.

License

pktd is licensed under the Copyfree ISC License.

pktd's People

Contributors

0xmichalis avatar aakselrod avatar aldebap avatar alexbosworth avatar backupbrain avatar cfromknecht avatar cjdelisle avatar dajohi avatar davecgh avatar dirbaio avatar dkoukoul avatar drahn avatar dskloetg avatar flammit avatar halseth avatar jcvernaleo avatar jimmysong avatar johnsonjh avatar jongillham avatar jrick avatar martelletto avatar owainga avatar roasbeef avatar stevenroose avatar thierrymarianne avatar tsenart avatar tuxcanfly avatar ucis avatar wallclockbuilder avatar wpaulino avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

pktd's Issues

Issue decrypting wallet seed

I was trying to use "./bin/pktwallet --create" to recover my wallet as my passphrase I set up got botched because I entered it using TeamViewer to a virtual machine on my private server over my phone. I spun up a new virtual machine to install pktd and recover the wallet but when entering my wallet seed and then enter the same password I just entered as the passphrase it says "Decrypting your seed..." and then ends up giving me the error

The seed did not decrypt properly, please try again.

It then prompts me again for the wallet password. Is there a bug here where the passphrase I enter at the beginning of the create process doesn't work to store it properly or is the password it requires actually the original passphrase I used when setting up the wallet the first time?

Test failure on Go 1.15beta1 with diff

Tests fail on 1.15b1, trimmed output:

# github.com/pkt-cash/pktd/btcutil/bech32_test
btcutil/bech32/bech32_test.go:26:12: conversion from untyped int to string yields a string of one rune
# github.com/pkt-cash/pktd/btcutil
btcutil/address.go:37:50: conversion from UnsupportedWitnessProgLenError (int) to string yields a string of one rune
# github.com/pkt-cash/pktd/btcjson_test
btcjson/cmdparse_test.go:206:10: conversion from untyped int to string yields a string of one rune
# github.com/pkt-cash/pktd
./upnp.go:236:16: conversion from int to string yields a string of one rune
FAIL    github.com/pkt-cash/pktd [build failed]
# github.com/pkt-cash/pktd/wire
wire/message.go:240:51: conversion from untyped int to string yields a string of one rune
FAIL    github.com/pkt-cash/pktd/btcjson [build failed]
FAIL    github.com/pkt-cash/pktd/btcutil [build failed]
FAIL    github.com/pkt-cash/pktd/btcutil/bech32 [build failed]
FAIL    github.com/pkt-cash/pktd/wire [build failed]
FAIL
tests failed

Still not too familiar with Go, but this patch seems to correct the issue (but only lightly tested on my node.)

Diff formatted patch attached

silently ignore onion addresses in peers.json

Should be silently skipped:

1605707594 [ERR] AMGR addrmanager.go:433: Failed to parse file /Users/user/Library/Application Support/Pktwallet/pkt/peers.json: 1.1.1-354914b8 failed to deserialize netaddress dvxyatqge3qfhd5p.onion:6476
4: 1.1.1-354914b8 lookup dvxyatqge3qfhd5p.onion: no such host                                                                                                                                               
                                                                                                                                                                                                            
  btcutil/er/er.go:359 +0x16d     btcutil/er.E()                                                                                                                                                            
  neutrino/neutrino.go:661 +0x6f          neutrino.NewChainService.func2()                                                                                                                                  
  addrmgr/addrmanager.go:733 +0xb7        addrmgr.(*AddrManager).HostToNetAddress()                                                                                                                         
  addrmgr/addrmanager.go:567 +0x10d       addrmgr.(*AddrManager).DeserializeNetAddress()
  addrmgr/addrmanager.go:485 +0x389       addrmgr.(*AddrManager).deserializePeers()                                                                                                                           addrmgr/addrmanager.go:431 +0x7d        addrmgr.(*AddrManager).loadPeers()
  addrmgr/addrmanager.go:581 +0xad        addrmgr.(*AddrManager).Start()                                                                                                                                    
  neutrino/neutrino.go:1511 +0x4b         neutrino.(*ChainService).Start()                                                                                                                                  
  pktwallet/chain/neutrino.go:45 +0x2e    pktwallet/chain.(*NeutrinoClient).Start()
  pktwallet/pktwallet.go:213 +0x96a       main.rpcClientConnectLoop()
  pktwallet/pktwallet.go:109 +0x7b2       created by main.walletMain


  btcutil/er/er.go:343 +0x8d      btcutil/er.Errorf()
  addrmgr/addrmanager.go:487 +0x704       addrmgr.(*AddrManager).deserializePeers()
  addrmgr/addrmanager.go:431 +0x7d        addrmgr.(*AddrManager).loadPeers()
  addrmgr/addrmanager.go:581 +0xad        addrmgr.(*AddrManager).Start()
  neutrino/neutrino.go:1511 +0x4b         neutrino.(*ChainService).Start()
  pktwallet/chain/neutrino.go:45 +0x2e    pktwallet/chain.(*NeutrinoClient).Start()
  pktwallet/pktwallet.go:213 +0x96a       main.rpcClientConnectLoop()
  pktwallet/pktwallet.go:109 +0x7b2       created by main.walletMain

@johnsonjh

The pprof server (and statsviz server, PR #213) listen on all interfaces

Currently, pktwallet and pktd currently provides no configuration option to enable listening on a specific address or interface (the StatsViz PR intentionally provides the same configuration as the pprof server for the sake of consistency).

Both the pprof and statsviz servers provide details which users may not want to be made publicly available, and currently would need to use an OS or container-level firewall to avoid this - if they are even aware of the situation.

I propose that the pprof (and statsviz) options be extended by an additional configuration variable such as ProfileBind (or StatsVizBind) with a corresponding command-line option, such as --profilebind= (and --statsvizbind=), for example, --profile=6660 --profilebind=127.0.0.1.

I can easily provide the PR for this, but ask your guidance as to the how the change should be implemented:

  1. It would be best, IMO, to maintain the current behavior (backwards compatibility is fully retained), but if the new options are not specified in conjunction with --profile (or --statsviz), then a prominent message should be logged at the warn level level, alerting the user about the possibly insecure configuration.

  2. One alternative would be to listen only on localhost (127.0.0.1 and/or ::1) by default, but allowing the user to use the new options to revert to the original behavior, e.g. --profilebind=0.0.0.0 or --profilebind=::1, breaking backward compatibility.

  3. Yet another alternative would be to extend the input accepted by the existing options to work with host:port syntax, but maintain backward compatibility by binding to all interfaces if the older syntax of the port only is used.

  4. Finally, if backwards compatibility is not considered important, these options could be changed to require the user explicitly specify both the host and port, where a null host string would mean to listen on all ports. This would be in alignment with other Go software, (godoc -http=:19876 or godoc -http=1.2.3.4:5678 for example).

Regardless of the different ways this could be implemented, I personally think maintaining backwards-compatibility with the current interface (--profile=portnumber) is important, as well as having the new options prominently listed in the help, making option 1 the most sensible, at least to me. Option 2 would break backwards compatibility, and options 3 and 4 may not be easily discoverable or intuitive for end-users unless they are already familiar with this specific syntax, which is rather Go-centric - I personally find the syntax (i.e. :8000) to be a bit strange, and unlike most other software.

Regardless, I'd be happy to implement the feature.

Go Lang ~/pktd

Confirmed git version 2.25.1
apt-get updates..Done

~/pktd$ ./do

--> "./do: 2: go: not found

With go-devel (a29dd1f2bd Wed Oct 21), new TestNetworkFailure in connmanager_test.go and a fix.

--- FAIL: TestNetworkFailure (0.09s)
connmanager_test.go:382: network failure: unexpected number of dials - got 114, want < 75
FAIL
FAIL github.com/pkt-cash/pktd/connmgr 0.261s

Updating to the x/net dependency to v0.0.0-20201021035429-f5854403a974 or higher results in passing tests.

I'll push a PR for this, but I've not personally done my normal regression testing to ensure that x/net 20201021035429 doesn't cause any issues with Go 1.14 through 1.15.3 - while I imagine it would not, I've been surprised before!

Edit: Verified this causes no issues with Go toolchains 1.14 through 1.15.3. Also was recommended to me that x/sys be updated when updating x/net, so that will be included. Rebased, so the PR will be against your current develop branch at the time of this writing.

Fix for CVE-2019-11840 (update crypto to 20200622213623-75b288015ac9)

Fix for CVE-2019-11840 (first noticed via Red Hat Bugzilla #BZ1691529).

An issue was discovered in supplementary Go cryptography libraries, aka golang-googlecode-go-crypto, before 2019-03-20. A flaw was found in the amd64 implementation of golang.org/x/crypto/salsa20 and golang.org/x/crypto/salsa20/salsa. If more than 256 GiB of keystream is generated, or if the counter otherwise grows greater than 32 bits, the amd64 implementation will first generate incorrect output, and then cycle back to previously generated keystream. Repeated keystream bytes can lead to loss of confidentiality in encryption applications, or to predictability in CSPRNG applications.

Details regarding complete changes to the upstream package are available at https://go.googlesource.com/net/+/4c5254603344ea4a8ae4bed7e296a9588303e14f

Fix: Upgrade crypto to 20200622213623-75b288015ac9.

Attached is patch to fix pktd in diff format: CVE-2019-11840.diff

Neutrino: TestBlockManagerInvalidInterval race detected

The very last race detector warnings from the pktd tests:

==================
WARNING: DATA RACE
Write at 0x00c000244000 by goroutine 140:
  github.com/pkt-cash/pktd/neutrino.TestBlockManagerInvalidInterval()
      pktd/neutrino/blockmanager_test.go:544 +0x30b
  testing.tRunner()
      golang/src/testing/testing.go:1123 +0x202

Previous read at 0x00c000244000 by goroutine 174:
  github.com/pkt-cash/pktd/neutrino.TestBlockManagerInvalidInterval.func4()
      pktd/neutrino/blockmanager_test.go:682 +0x5e

Goroutine 140 (running) created at:
  testing.(*T).Run()
      golang/src/testing/testing.go:1168 +0x5bb
  testing.runTests.func1()
      golang/src/testing/testing.go:1439 +0xa6
  testing.tRunner()
      golang/src/testing/testing.go:1123 +0x202
  testing.runTests()
      golang/src/testing/testing.go:1437 +0x612
  testing.(*M).Run()
      golang/src/testing/testing.go:1345 +0x3b3
  github.com/pkt-cash/pktd/neutrino.TestMain()
      pktd/neutrino/test_test.go:12 +0x1fb
  main.main()
      _testmain.go:145 +0x371

Goroutine 174 (running) created at:
  github.com/pkt-cash/pktd/neutrino.TestBlockManagerInvalidInterval()
      pktd/neutrino/blockmanager_test.go:681 +0xbce
  testing.tRunner()
      golang/src/testing/testing.go:1123 +0x202
==================

โ€  Attached is the full Neutrino TestBlockManagerInvalidInterval race detector log.

Update some dependencies with notable bugfixes

A few module dependencies can be safely updated, especially as there are quite a few important bugfixes to the grpc module. Also ran through go tidy to ensure any indirect modules that might be required for other platforms correctly resolve and would be included (no issues).

Tested here for ~24 hours under moderate conditions without incident.

Attached: Diff formatted patch file

TestRandomUint64 failures

Can trigger reliably when doing extensive regression testing on my system when low on entropy, even when using HAVEGED, and can almost always trigger when doing testing using virtual machines - hard to say what a solution is since tests should either pass or fail, but perhaps we should do some additional verification of what we get back from Rand, in the situations where it's truly warranted?

--- FAIL: TestRandomUint64 (0.00s)
    common_test.go:741: Random Uint64 iteration 195 failed - The random number generator on this system is clearly terrible since we got 6 values less than 72057594037927936 in 256 runs when only 5 was expected 6
FAIL
// TestRandomUint64 exercises the randomness of the random number generator on
// the system by ensuring the probability of the generated numbers.  If the RNG
// is evenly distributed as a proper cryptographic RNG should be, there really
// should only be 1 number < 2^56 in 2^8 tries for a 64-bit number.  However,
// use a higher number of 5 to really ensure the test doesn't fail unless the
// RNG is just horrendous.
// randomUint64 returns a cryptographically random uint64 value.  This
// unexported version takes a reader primarily to ensure the error paths
// can be properly tested by passing a fake reader in the tests.
func randomUint64(r io.Reader) (uint64, er.R) {
    rv, err := binarySerializer.Uint64(r, bigEndian) 
    if err != nil {
        return 0, err
    }
    return rv, nil
}
    
// RandomUint64 returns a cryptographically random uint64 value.
func RandomUint64() (uint64, er.R) {
    return randomUint64(rand.Reader)
}

As an aside, we should investigate current uses of "math/rand" to see if "crypto/rand" might be more appropriate.

Calculate cyclomatic complexity code quality metrics for all functions

Calculated cyclomatic complexity code quality metrics. The table is sorted by the number of linearly independent paths. "Functions with higher cyclomatic complexity need additional testing to cover all possible paths and are potentially harder to understand."

Average cyclomatic complexity metric for the full code base is 3.8.

The top 30 functions with the highest cyclomatic complexitiy metrics, (when excludingGoLevelDB and tests):

  1. 257 txscript executeOp txscript/opcode.go:35:1
  2. 127 interpret doOp blockchain/packetcrypt/randhash/interpret/simpleop_gen.go:13:1
  3. 118 main loadConfig config.go:413:1
  4. 85 main loadConfig pktwallet/config.go:277:1
  5. 84 neutrino rescan neutrino/rescan.go:218:1
  6. 73 opcodes (OpCode).String blockchain/packetcrypt/randhash/opcodes/optable_gen.go:94:1
  7. 62 peer (*Peer).inHandler peer/peer.go:1399:1
  8. 49 wire (*MsgTx).BtcDecode wire/msgtx.go:393:1
  9. 48 neutrino queryChainServiceBatch neutrino/query.go:266:1
  10. 48 mining (*BlkTmplGenerator).NewBlockTemplate mining/mining.go:487:1
  11. 45 rpcclient (*Client).handleNotification rpcclient/notify.go:206:1
  12. 43 main newServer server.go:2544:1
  13. 41 blockchain (*BlockChain).checkConnectBlock blockchain/validate.go:1093:1
  14. 41 btcjson assignField btcjson/cmdparse.go:249:1
  15. 40 mempool (*TxPool).maybeAcceptTransaction mempool/mempool.go:930:1
  16. 40 txscript opcodeCheckMultiSig txscript/opcode.go:2168:1
  17. 39 wallet (*Wallet).findEligibleOutputs pktwallet/wallet/createtx.go:370:1
  18. 39 netsync (*SyncManager).handleInvMsg netsync/manager.go:1058:1
  19. 37 main handleSearchRawTransactions rpcserver.go:3416:1
  20. 37 neutrino (*blockManager).handleProvenHeadersMsg neutrino/blockmanager.go:2454:1
  21. 35 indexers (*Manager).Init blockchain/indexers/manager.go:233:1
  22. 35 main createWallet pktwallet/walletsetup.go:117:1
  23. 34 wire readElement wire/common.go:194:1
  24. 34 wtxmgr rollbackTransaction pktwallet/wtxmgr/tx.go:431:1
  25. 33 legacyrpc signRawTransaction pktwallet/rpc/legacyrpc/methods.go:1513:1
  26. 33 blockchain (*BlockChain).reorganizeChain blockchain/chain.go:841:1
  27. 31 txscript NewEngine txscript/engine.go:832:1
  28. 30 neutrino (*blockManager).cfHandler neutrino/blockmanager.go:461:1
  29. 30 interpret interpret blockchain/packetcrypt/randhash/interpret/interpret.go:109:1
  30. 30 wire makeEmptyMessage wire/message.go:117:1

While there is likely nothing inherently wrong with these parts of the code, if we're looking for where the bugs might be hiding or where additional tests might be warranted, this is probably a good list to review.

exit code of pktctl is always zero

Ideal would be:

  • catchall error 1
  • If pktwallet is having a problem (like out of disk, corruption, etc) then it should be 128

Jeff to provide more info

Improving testing speed

While the tests complete in here in less than a minute, @cjdelisle advised they are taking close to 90s for him - on Travis, they can sometimes take 10 minutes or more, depending on the load.

Here's the runtime breakdown:

testtimes

The Neutrino test is 16s because it reliant on wall-clock time to do it's ban/unban testing, and is the low-hanging fruit. This test could be rewritten based on a range, or moved completely out into ALL_TESTS=1 (Neutrino has some slow, extra tests there already, including the tests that would require getting the full test harness working again.)

Anyway, for my 50s test runtime, the top 10 here are 45s of it.

Neutrino: Race detected at start-up

Race detector goes off immediate at startup with Neutrino:

==================                                                            
WARNING: DATA RACE                                                            
Write at 0x00c0179ac498 by goroutine 83:                                      
  github.com/pkt-cash/pktd/addrmgr.(*AddrManager).Attempt()                   
      github.com/pkt-cash/pktd/addrmgr/addrmanager.go:862 +0x1c8              
  github.com/pkt-cash/pktd/neutrino.(*ChainService).outboundPeerConnected()   
      github.com/pkt-cash/pktd/neutrino/neutrino.go:1414 +0x433               
  github.com/pkt-cash/pktd/neutrino.(*ChainService).outboundPeerConnected-fm()
      github.com/pkt-cash/pktd/neutrino/neutrino.go:1388 +0x64                
                                                                              
Previous read at 0x00c0179ac498 by goroutine 136:                             
  github.com/pkt-cash/pktd/addrmgr.(*KnownAddress).LastAttempt()              
      github.com/pkt-cash/pktd/addrmgr/knownaddress.go:34 +0x5d0              
  github.com/pkt-cash/pktd/neutrino.NewChainService.func5()                   
      github.com/pkt-cash/pktd/neutrino/neutrino.go:806 +0x3c6                
  github.com/pkt-cash/pktd/connmgr.(*ConnManager).NewConnReq()                
      github.com/pkt-cash/pktd/connmgr/connmanager.go:406 +0x401              
  github.com/pkt-cash/pktd/connmgr.(*ConnManager).handleFailedConn.func3()
      github.com/pkt-cash/pktd/connmgr/connmanager.go:225 +0x52           
                                                                          
Goroutine 83 (running) created at:                                        
  github.com/pkt-cash/pktd/connmgr.(*ConnManager).connHandler()           
      github.com/pkt-cash/pktd/connmgr/connmanager.go:281 +0x115b         
                                                                          
Goroutine 136 (running) created at:                                       
  github.com/pkt-cash/pktd/connmgr.(*ConnManager).handleFailedConn()      
      github.com/pkt-cash/pktd/connmgr/connmanager.go:223 +0x6c4          
  github.com/pkt-cash/pktd/connmgr.(*ConnManager).connHandler()           
      github.com/pkt-cash/pktd/connmgr/connmanager.go:355 +0x4c4          
==================                                                        

The future of BTC Core/Satoshi compatibility, BIP-0155, BIP-0152, ADDVR2, etc.

  • See Core commit bitcoin/bitcoin@7be6ff6
    • I see we'll have to recognize and ignore the I2P names on P2PNET to maintain full compatibility with Core mainnet, if that's going to remain a goal - I'm currently of the opinion that we should move away for that, as the effort to get "there" from "here" would be quite large and mostly, IMHO, wasted effort, and our time best spent elsewhere.

I have a list, somewhere, of the changes needed to maintain full interop with Core mainnet, and it's getting longer every day.

The changes are coming very fast from Core lately, like the entire new ban system being dropped and replaced with the new "discouragement" logic, all in a point release, and before I could even get the 0.19.x/0.20.0 behavior cloned and merged.

Even upstream BTCD, back under active development, is no longer compatible with BTC Core mainnet right now. Unsurprisingly, due to the issues we (@johnsonjh and @cjdelisle) had previously taked about privately.

In this case, you see the Satoshi/Core and BTCD get in a fight because BTCD does not (yet) implement addrv2 wire messages aka BIP-0155, and Core does not recognize the wire reject messages - they've already been purged from their network, with the result being disconnected (and now, eventual isolation from the network via the discouragement mechanism and peers won't connect to you).

I propose we start looking more to BCH/BCHN/BCHA (Bitcoin Cash), not for direct interoperability, but as a source for maintaining the "state of the art" when it comes to effectively communicating on the P2P mainnet. In fact, the aggressive changes being pushed (by only a few influential developers in many cases) seems to be in response to falling behind some of the forks, and they often offer less complex and dangerous alternatives to some of the changes being pushed in Core.

So, while they aren't actively "banning" any longer on Core P2P mainnet, it's now very easy to end up as an isolated peer unless we go along with all the rest of the Core changes like removal of reject, alterts, banning, HBCBR, compressed representation, Schnorr signatures, ADDVR2 - the list keeps getting longer. Also, just to give one example, nodes that run as HBCBR (High-Bandwidth Compact Block Relays) aka BIP-0152 will be exempted from the "discouragement"/shunning system.

Also, while not unsound, I believe that many of these new changes in Core are dangerous because they're difficult to get right, and getting them wrong would create an incident. I'd present BIP-0152 Pre-Validation Relay as just one example of many. A system essentially the same as FIBRE (Fast Internet Bitcoin Relay Extension) is in use on the BCH network, and does not change the block validation logic. Also, extensions such as XTHINNER are options we can explore without much systemic risk to the network, and always having to up to date with the, of late, relentless changes in Core.

We can also maintain connectively with Core, if necessary, by adopting a compatible Lightning implementation that offers a channel compatible with Satoshi/Core Bitcoind, or connecting PKTD directly to a BTCD node manually (thus a persistent and white-listed link) seems to be a more reasonable goal at this time. Again, my opinion only.

https://nvd.nist.gov/vuln/detail/CVE-2020-14040

Doubtful we'd be affected, pretty sure nothing uses it as a direct dependency or but it's sometimes hard to tell what embedded or vendored dependencies within dependencies are sneaking in. I'll have a few ideas for solutions, but regardless, this is a reminder that we should use some sort of sanitizer before printing any possible "user generated" data out - I think there are a few places, mostly error messages, where this could be possible.

I'm sure I can find some automated way to address it, so keep open for now as a reminder for me.

Neutrino: ConnManager race and BlockManager test race

Another Neutrino hit by the race detector, this one occurs during runtime periodically, usually right when it switches to another peer.

==================
WARNING: DATA RACE
Read at 0x00c0004be340 by goroutine 158:
  github.com/pkt-cash/pktd/connmgr.(*ConnManager).handleFailedConn()
      github.com/pkt-cash/pktd/connmgr/connmanager.go:212 +0x3f3
  github.com/pkt-cash/pktd/connmgr.(*ConnManager).connHandler()
      github.com/pkt-cash/pktd/connmgr/connmanager.go:355 +0x4c4

Previous write at 0x00c0004be340 by goroutine 196:
  ??()
      -:0 +0xffffffffffffffff
  github.com/pkt-cash/pktd/neutrino.(*ServerPeer).OnVersion()
      github.com/pkt-cash/pktd/neutrino/neutrino.go:280 +0x8f5
  github.com/pkt-cash/pktd/neutrino.(*ServerPeer).OnVersion-fm()
      github.com/pkt-cash/pktd/neutrino/neutrino.go:219 +0x55
  github.com/pkt-cash/pktd/peer.(*Peer).readRemoteVersionMsg()
      github.com/pkt-cash/pktd/peer/peer.go:2055 +0x9dc
  github.com/pkt-cash/pktd/peer.(*Peer).negotiateOutboundProtocol()
      github.com/pkt-cash/pktd/peer/peer.go:2161 +0x86
  github.com/pkt-cash/pktd/peer.(*Peer).start.func1()
      github.com/pkt-cash/pktd/peer/peer.go:2173 +0xa4

Goroutine 158 (running) created at:
  github.com/pkt-cash/pktd/connmgr.(*ConnManager).Start()
      github.com/pkt-cash/pktd/connmgr/connmanager.go:536 +0x126
==================

Recover address after corrupted wallet.db file

Hello,

I got corrupted the wallet.db file of my wallet. No way to recover it.
I'm using pktwallet version 1.4.0

Instead, I re run the pktwallet --create command.
Entered the passphrase on
Enter the private passphrase for your new wallet:

then I answered yes at:
Do you have an existing wallet seed you want to use? (n/no/y/yes) [no]: yes

Entered the wallet phrase at:
Enter existing wallet seed:

Decrypting your seed...
Creating the wallet...
1649873981 [INF] wallet.go:3254 Opened wallet
The wallet has been created successfully.

Then I run the pktwallet command.

1649873989 [INF] pktwallet.go:67 Version 1.4.0
1649873989 [INF] server.go:200 Listening on 127.0.0.1:64763
1649873989 [INF] server.go:200 Listening on [::1]:64763
1649873990 [INF] wallet.go:3254 Opened wallet
1649874040 [INF] wallet.go:399 Waiting for chain backend to sync to tip

1649874040 [INF] seed.go:58 1 addresses found from DNS seed seed.anode.co
1649874040 [INF] seed.go:58 20 addresses found from DNS seed seed.cjd.li
1649874040 [INF] wallet.go:403 Chain backend synced to tip! ๐Ÿ‘

1649874040 [INF] seed.go:58 20 addresses found from DNS seed pktdseed.pkt.world

But when I run the pktctl --wallet getaddressbalances command, I get:

[]

The miners I have, seem to be still generating at my old pkt address without problems.
Any suggerence to get the pktctl command to run or to recover the address I have in use for the pktctl command?

Thanks for any comment/suggerence ๐Ÿ˜

WIP Progress

@cjdelisle

[via GitLab] - From #254:


It's up now, the develop-johnsonjn branch, also, the same is available over at Gridfinity GitLab.

  • I'm still getting random failures on these two tests - I'll look into fixing it tomorrow, properly:
  • --- FAIL: TestLightningWallet/btcwallet/btcd:signed_with_tweaked_pubkeys
  • --- FAIL: TestWeightEstimate

Extensive changes from yours - I ran the full test suite about five or six times and only got the failures three or so times - I'm going to try to look at fixing it right - I think the second is mostly harmless? Probably has to do with BTC/PKT differences. The new tests
that I've added are working and passing, so that's a good sign, at least. I have more to add as well.

Oddly, the MORE threads and CPU's I tell it to run with, the less it seems to produce the failures. Grrr....

Still left to merge is my total revamp of GoLevelDB (with the caching working and all race conditions fixes, and it's been exercised with TB's and TB's of data without issue - so not just "all the races fixed"), but also, the all new testing framework, which includes leak detection for all tests, the new BBoltDB optimizations, etc. I still have about 4 or 5 PR's to merge with that branch. I'll also look at how difficult it would be to merge the rest of my tree local tree which has some additions ported from
BitCoin Core and Bitcoin Cash, as well as my initial implementation of the UDP fastblock transfer mode, and some other notable performance improvements and changes, but the remainder are mostly backports from mainline and decred.

I also have adjustments to the INV and ban system, which fixes that too early triggered "misbehaving peer" warning (just need to break out), and the Mage build is just about ready to merge in as well.

I hope to get it fully in-shape tomorrow, but, feel free to poke around if you like.

(FYI, PR's left to review are and decide if I want to merge are #111, #229, #231, #232, #234, #235) , and the notes in #251 - everything is in my local tree.)

Even better, I promise I'll have the automatic package builds working for macOS, Linux, and Windows tomorrow today as well as the coverage reporting analysis.


the latest release is not working

following is the error message

1629373627 [INF] seed.go:58 7 addresses found from DNS seed seed.cjd.li
1629373635 [INF] seed.go:53 DNS discovery failed on seed seed.gridfinity.com: 1.3.1 lookup seed.gridfinity.com: Temporary failure in name resolution                                                      

  btcutil/er/er.go:393 +0x192     btcutil/er.E()
  neutrino/neutrino.go:657 +0x6f          neutrino.NewChainService.func2()
  connmgr/seed.go:51 +0x168       connmgr.SeedFromDNS.func1()
  connmgr/seed.go:48 +0xd5        connmgr.SeedFromDNS

I tried yesterday, not working. try again today and the problem still exists.

Command line tool collides with btcctl

The command line tool collides with the btc version of btcctl both in the executable name and default config file path.

This makes it extraordinarily difficult to use both tools on the same machine.

pkt should follow other forks of btcd (bchd, ltcd, etc) and rename the command line tool and config file to pktctl.

Enhancement: Inclusion of "dry-run" flag

A dry-run option could be applicable to functions such as pktwallet wallet creation, and pktctl RPC calls such as sendtoaddress, sendfrom, etc, so the effect of the call can be safely evaluated before execution.

btcjsonTest/cmdparse_test.go: TestAssignField Test #14 failing on Go 1.16-pre, caused by bug in JSONiter 1.1.10

Using latest released Go 1.15.3, no errors in 5000 runs (and previously has been tested through 1M+ runs in my regression testing):

 ยป go test -count=5000 .
ok  	github.com/pkt-cash/pktd/btcjson	49.116s

Using latest unreleased Go 1.16 (devel +32f8be27f3 Sat Oct 31 17:11:37 2020 -0400), test always fails:

--- FAIL: TestAssignField (0.00s)
    cmdparse_test.go:170: Running 20 tests
    cmdparse_test.go:176: Test #14 (convertible types - string -> float32) unexpected error: 0.0.0-custom ErrInvalidType: a type was passed that is not the required type: parameter #1 'testField' must parse to a float32
        
          /home/jhj/p/btcutil/er/er.go:91 +0x99	  btcutil/er.(*ErrorCode).New()
          /home/jhj/p/btcjson/cmdparse.go:460 +0x1eb2	  btcjson.assignField()
          /home/jhj/p/btcjson/cmdparse_test.go:174 +0xaef	  btcjson_test.TestAssignField()
          /home/jhj/src/go-current/src/testing/testing.go:1173 +0xef	  testing.tRunner()
          /home/jhj/src/go-current/src/testing/testing.go:1218 +0x2b3	  created by testing.(*T).Run

Upgrading to JSONiter v1.1.11-0.20200806011408-6821bec9fa5c fixes the issue.

I have an outstanding PR already, #116, pending, that incorporates the fix, so we can close this once you merge.

Coin Folding Fee Bug?

I made Coin Folding Transactions like in the Docs with the Amount of 0 PKT. Like

./bin/pktctl --wallet sendfrom ADDRESS 0 '["ADDRESS"]'

I had many to fold so I made it in a quick manner without waiting for the block confirmation.
Somehow the Transaktion Fee was in the XXX and 1300PKT Range.

image

image

Is this a known Bug, made i something wrong on my end?

Just updated the git repo, was from early May. Still want to make sure this does not happen again :s

Thanks!
Tobias

Yet another flaky test (or a flaky function!) causing rare failures.

peer: TestPeerConnection test:

--- FAIL: TestPeerConnection (0.00s)
    peer_test.go:342: Running 2 tests
    peer_test.go:211: testPeer: wrong LastSend - got 2020-10-31 20:16:07 +0000 GMT, want 1970-01-01 00:00:00 +0000 GMT
cd peer && go test -count=10000 . | grep 'FAIL: TestPeerConnection' | wc -l`
90

So, the test passes 99.1% of the time.

Will look into it and see what the source of this failure may be.

Originally posted by @johnsonjh in #127 (comment)

Considering upgrading minimum required Golang to 1.15.3.

Propose upgrading minimum required Golang to 1.15.3.

Two major things to consideration (and we already require 1.14 now for various reasons):

  1. golang/go#40641 - (Note: I have seen in my test rig but not in production.)
  2. golang/go#40643 - (Note: I believe this could be the cause of the 0.5% failures I mentioned to in passing to you earlier. It's also sort of sad.)

This should be fixed for Go 1.14 and Go 1.15. It's a bug that was introduced in Go 1.14, and may cause random and unavoidable crashes at any point in time. There may not be enough time to fix this for 1.15 (the failure is very rare, but we've seen it internally), and if not, it should definitely go in a point release.

Golang's curve25519.ScalarMult is deprecated and will be removed soon; replaced by X25519

Golang's curve25519.ScalarMult is deprecated: when provided a low-order point, ScalarMult will set dst to all zeroes, irrespective of the scalar - it will be replaced with the X25519 function, which will return an error.

Is this something to worry about, in consensus-sensitive code?

It's would be extremely easy to maintain a fork of the "buggy" version if need be, and I see they are already looking into the possibility doing some additional checks in the current code, due to it being a potential security concern.

See:

The standard deprecation policy for Golang is to remove deprecated functions no sooner than the next major release after the deprecation. This function was deprecated on Nov 7, 2019, which makes it part of the 1.14 major release, so the function is eligible for removal with the next release, Go 1.16 (though it still remains in master today, it could be removed at any time.)

Looking at the release history, the average time between releases is 204 days, and it's been 87 days since the last release, so we should expect it to be gone by March 2021.

wallet_setup failed

Tried to follow https://pkt.cash/wallet_setup but failed:

$ go get github.com/pkt-cash/pktd/pktwallet

# github.com/coreos/bbolt
go/src/github.com/coreos/bbolt/bolt_unix_aix.go:13:6: flock redeclared in this block
        previous declaration at go/src/github.com/coreos/bbolt/bolt_unix.go:13:59
go/src/github.com/coreos/bbolt/bolt_unix_aix.go:46:6: funlock redeclared in this block
        previous declaration at go/src/github.com/coreos/bbolt/bolt_unix.go:45:22
go/src/github.com/coreos/bbolt/bolt_unix_aix.go:56:6: mmap redeclared in this block
        previous declaration at go/src/github.com/coreos/bbolt/bolt_unix.go:50:27
go/src/github.com/coreos/bbolt/bolt_unix_aix.go:76:6: munmap redeclared in this block
        previous declaration at go/src/github.com/coreos/bbolt/bolt_unix.go:72:21

Monitoring instrumentation

Roasbeef had a fully instrumented btcd a long while back, using Prometheus so it would work with Grafana - I think the code is still public in his repo... apparently the experience later led the full instrumentation which is now standard in lnd (build with tags=monitoring) and the lndmon frontend (lightninglabs/lndmon).

Ah, found it - https://github.com/Roasbeef/btcdmon - it's all 5 years or so out of date, unfortunately, but still should give me a pretty good idea of how to do similar for pktd. I've never done anything with Prometheus outside of PCP/Shell/Perl and a little C, but it's a good project to keep on the TODO list and if the interfaces for Go anything like the ones for C, it should be something I'd be able to complete.

When I get "free time" I'll do a checkout of btcd at the same commit that he instrumented and run it through nvimdiff and beyondcompare to see exactly what sort of work would be involved.

Building with newDo on w/frolvlad/alpine-gcc [PureGO example]

Not as much as issue as a HOWTO, but here are some EASY steps you can use to get a PKT suite built with newDo - in case you can't build "pure go" versions on your distro for some reason, need to avoid linking against glibc (as even static glibc binaries are not actually staticly linked) or you require the types of builds newDo can produce.

FYI - some reason, the Golang provided by Google (1.15.3) no longer works correctly on Alpine, nor via the Docker image 'frolvlad/alpine-gcc', but you can workaround this quite easily (you actually get better results with the pre-1.6 Golang toolchainas of this writing, but Go 1.15.3+ is OK too.)

The version I'm building here is essentially develop with PR#70 + 71 applied as of this writing (10-21-2020), using Alpine via the 'frolvlad/alpine-gcc' Docker image (has some of it's own issues, but none of which will affect the build):

$ docker run -it frolvlad/alpine-gcc /bin/sh
and when inside:

  1. apk update
  2. apk upgrade
  3. apk add git
  4. apk add go (You need their old Go to compile your newer Go)
  5. apk add bash (Sadly, the Go build system is written in Bash - no Bash required by any part of PKT suite or newDo.)
  6. wget and extract the Go sources from golang.org or git clone https://go.googlesource.com/go
  7. cd go/src
  8. bash ./all.bash (and wait awhile)
  9. export PATH=/root/go/bin:$PATH

Then from outside:

  1. docker ps to get the ID, then:
  2. docker cp your-pktd-source-tree.tar [IDHERE]:/root/pktd-src.tar

Back on the "inside", three steps:

  1. cd /root ; tar xvf your-pktd-source-tree.tar && cd pktd
  2. export PKT_BUILD_PUREGO=1 ; export PKT_BUILD_REPROD=1 ; export PKT_FAIL_DIRTY=0 ; export PKT_OWN_GOPATH=1 ; export PKT_OWN_GOPATH_DIR=/gopath ; export PKT_SKIP_TESTS=0 ; export PKT_FROM_SCRATCH=0
  3. GOPATH=/gopath ./contrib/newDo/newDo

Here is the "reproducible" "Pure Go" build - (yes - newDo does work just fine with BusyBox ash.)

newDo: This is PKT newDo; version 0.6-20200830-R_PRODUCTION.
newDo: POSIX compliance claim: 200809

newDo: Locating required POSIX utilities:
newDo: Looking for cat: /bin/cat
newDo: Looking for chmod: /bin/chmod
newDo: Looking for comm: /usr/bin/comm
newDo: Looking for cut: /usr/bin/cut
newDo: Looking for grep: /bin/grep
newDo: Looking for mkdir: /bin/mkdir
newDo: Looking for mktemp: /bin/mktemp
newDo: Looking for rm: /bin/rm
newDo: Looking for rmdir: /bin/rmdir
newDo: Looking for sed: /bin/sed
newDo: Looking for sort: /usr/bin/sort
newDo: Looking for tr: /usr/bin/tr
newDo: Looking for true: true
newDo: Looking for uname: /bin/uname
newDo: Looking for xargs: /usr/bin/xargs

newDo: Locating required build tools:
newDo: Looking for git: /usr/bin/git
newDo: Looking for go: /root/go/bin/go

newDo: Locating optional utilities:
newDo: Looking for ccache: not found
newDo: Looking for checksec: not found
newDo: Looking for lsb_release: not found
newDo: Looking for sw_vers: not found
newDo: Looking for tput: not found
newDo: Looking for upx: not found

newDo: Warning: Previous config "/root/.pkt-do.conf" ignored, no execute attribute.

newDo: Operating system claims to be: linux
newDo: Machine hardware claims to be: amd64

newDo: Checking basic PKT build configuration: passed
newDo: Checking Go version: Go 1.15.x
newDo: Checking PKT build configuration compatibility with Go 15: passed
newDo: Checking operating system compatibility with Go 15: passed (linux)
newDo: Checking machine hardware compatibility with Go 15: passed (amd64)
newDo: Checking overall Go configuration: passed
newDo: Notice: PKT build has been successfully configured.

newDo: Warning: Removing existing configuration at "/root/.pkt-do.conf"
newDo: Notice: Current configuration written to "/root/.pkt-do.conf"
newDo: Notice: To enable it, execute: "chmod +x /root/.pkt-do.conf"

newDo: PKT_BUILD_REPROD: Build should be reproducible when compiling same sources.
newDo: PKT_BUILD_PUREGO: Making best efforts to avoid CGo, static linking if possible.

newDo: Notice: Building pktd
go: downloading github.com/jessevdk/go-flags v1.4.1-0.20200711081900-c17162fe8fd7
go: downloading github.com/gorilla/websocket v1.4.3-0.20200912193213-c3dd95aea977
go: downloading github.com/sethgrid/pester v1.1.1-0.20200617174401-d2ad9ec9a8b6
go: downloading github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc
go: downloading github.com/decred/go-socks v1.1.0
go: downloading github.com/decred/dcrd/lru v1.1.1-0.20201017002141-c07fa09c584d
go: downloading golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897
go: downloading github.com/dchest/blake2b v1.0.0
go: downloading github.com/golang/snappy v0.0.2
go: downloading github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da
go: downloading github.com/kkdai/bstream v1.0.0
go: downloading github.com/aead/siphash v1.0.1
go: downloading golang.org/x/sys v0.0.0-20201018230417-eeed37f84f13

newDo: Notice: Building pktwallet
go: downloading google.golang.org/grpc v1.34.0-dev.0.20201019205402-ce5e36655676
go: downloading github.com/emirpasic/gods v1.12.1-0.20200630092735-7e2349589531
go: downloading go.etcd.io/bbolt v1.3.6-0.20200807205753-f6be82302843
go: downloading github.com/lightningnetwork/lnd/queue v1.0.5-0.20201016111222-d12f76fd6d48
go: downloading github.com/LK4D4/trylock v0.0.0-20191027065348-ff7e133a5c54
go: downloading github.com/lightningnetwork/lnd/ticker v1.0.0
go: downloading github.com/golang/protobuf v1.4.3
go: downloading google.golang.org/genproto v0.0.0-20201019141844-1ed22bb0c154
go: downloading golang.org/x/net v0.0.0-20201020065357-d65d470038a5
go: downloading google.golang.org/protobuf v1.25.0
go: downloading golang.org/x/text v0.3.4-0.20200826142016-a8b467125457

newDo: Notice: Building pktctl
newDo: Notice: Regenerating tests.

The following values are the computed linearly independent vectors needed to make use of the secp256k1 endomorphism:
a1: 3086d221a7d46bcde86c90e49284eb15
b1: -e4437ed6010e88286f547fa90abfe4c3
a2: 114ca50f7a8e2f3f657c1108d9d44cfd8
b2: 3086d221a7d46bcde86c90e49284eb15
Generating seed words

newDo: Notice: Running all tests.
ok  	github.com/pkt-cash/pktd	0.113s
ok  	github.com/pkt-cash/pktd/addrmgr	0.451s
ok  	github.com/pkt-cash/pktd/blockchain	11.558s
ok  	github.com/pkt-cash/pktd/blockchain/indexers	0.152s
ok  	github.com/pkt-cash/pktd/blockchain/packetcrypt	0.082s
ok  	github.com/pkt-cash/pktd/btcec	2.617s
ok  	github.com/pkt-cash/pktd/btcjson	0.136s
ok  	github.com/pkt-cash/pktd/btcutil	0.137s
ok  	github.com/pkt-cash/pktd/btcutil/base58	0.030s
ok  	github.com/pkt-cash/pktd/btcutil/bech32	0.090s
ok  	github.com/pkt-cash/pktd/btcutil/bloom	0.100s
ok  	github.com/pkt-cash/pktd/btcutil/coinset	0.041s
ok  	github.com/pkt-cash/pktd/btcutil/gcs	4.227s
ok  	github.com/pkt-cash/pktd/btcutil/gcs/builder	0.083s
ok  	github.com/pkt-cash/pktd/btcutil/hdkeychain	0.153s
ok  	github.com/pkt-cash/pktd/btcutil/txsort	0.032s
ok  	github.com/pkt-cash/pktd/chaincfg	0.017s
ok  	github.com/pkt-cash/pktd/chaincfg/chainhash	0.040s
ok  	github.com/pkt-cash/pktd/connmgr	0.149s
ok  	github.com/pkt-cash/pktd/database	0.237s
ok  	github.com/pkt-cash/pktd/database/ffldb	3.688s
ok  	github.com/pkt-cash/pktd/database/internal/treap	0.081s
ok  	github.com/pkt-cash/pktd/mempool	0.454s
ok  	github.com/pkt-cash/pktd/mining	0.061s
ok  	github.com/pkt-cash/pktd/neutrino	8.535s
ok  	github.com/pkt-cash/pktd/neutrino/banman	1.099s
ok  	github.com/pkt-cash/pktd/neutrino/blockntfns	0.016s
ok  	github.com/pkt-cash/pktd/neutrino/cache	0.007s
ok  	github.com/pkt-cash/pktd/neutrino/cache/lru	0.008s
ok  	github.com/pkt-cash/pktd/neutrino/chainsync	0.022s
ok  	github.com/pkt-cash/pktd/neutrino/filterdb	0.064s
ok  	github.com/pkt-cash/pktd/neutrino/headerfs	0.384s
ok  	github.com/pkt-cash/pktd/neutrino/headerlist	0.019s
ok  	github.com/pkt-cash/pktd/neutrino/pushtx	0.111s
ok  	github.com/pkt-cash/pktd/peer	0.113s
ok  	github.com/pkt-cash/pktd/pktwallet/chain	0.073s
ok  	github.com/pkt-cash/pktd/pktwallet/internal/legacy/keystore	6.282s
ok  	github.com/pkt-cash/pktd/pktwallet/internal/zero	0.028s
ok  	github.com/pkt-cash/pktd/pktwallet/rpc/legacyrpc	0.094s
ok  	github.com/pkt-cash/pktd/pktwallet/snacl	1.120s
ok  	github.com/pkt-cash/pktd/pktwallet/waddrmgr	2.625s
ok  	github.com/pkt-cash/pktd/pktwallet/wallet	7.296s
ok  	github.com/pkt-cash/pktd/pktwallet/wallet/internal/txsizes	0.301s
ok  	github.com/pkt-cash/pktd/pktwallet/wallet/seedwords	10.422s
ok  	github.com/pkt-cash/pktd/pktwallet/wallet/txauthor	0.096s
ok  	github.com/pkt-cash/pktd/pktwallet/walletdb	0.049s
ok  	github.com/pkt-cash/pktd/pktwallet/walletdb/bdb	0.188s
ok  	github.com/pkt-cash/pktd/pktwallet/walletdb/migration	0.005s
ok  	github.com/pkt-cash/pktd/pktwallet/wtxmgr	0.260s
ok  	github.com/pkt-cash/pktd/txscript	1.851s
ok  	github.com/pkt-cash/pktd/txscript/scriptbuilder	0.027s
ok  	github.com/pkt-cash/pktd/wire	1.053s
ok  	github.com/pkt-cash/pktd/wire/protocol	0.010s

do: [Executing pktd --version:]: pktd version 1.1.1-0993fc3c

newDo: Build complete

newDo: All build actions completed.

newDo: Running cleanup tasks.
newDo: All cleanup tasks completed.
  • The proof's in the pudding:
# cd bin ; ls -l
-rwxr-xr-x    1 root     root       9487260 Oct 21 00:20 pktctl
-rwxr-xr-x    1 root     root      18296420 Oct 21 00:20 pktd
-rwxr-xr-x    1 root     root      22211755 Oct 21 00:20 pktwallet
# ./pktd 
1603239964 [INF] BTCD config.go:740: Creating a .cookie file
1603239964 [INF] BTCD btcd.go:61: Version 1.1.1-0993fc3c
1603239964 [INF] BTCD version.go:97: This is a pre-release version
1603239964 [INF] BTCD btcd.go:272: Loading block database from '/root/.pktd/data/pkt/blocks_ffldb'
1603239964 [INF] BTCD btcd.go:292: Block database loaded
1603239964 [INF] INDX server.go:2629: Committed filter index is enabled
1603239964 [INF] INDX manager.go:400: Catching up indexes from height -1 to 0
1603239964 [INF] INDX manager.go:452: Indexes caught up to height 0
1603239964 [INF] CHAN chain.go:1867: Chain state (height 0, hash 0bdc1712a46194e552cf417ab0439c2d4f456c35cf63a0a406964c6f93432d85, totaltx 1, work 4096)
1603239964 [WRN] RPCS server.go:2532: Can't listen on [::1]:64765: listen tcp6 [::1]:64765: bind: cannot assign requested address
1603239964 [INF] CMGR connmanager.go:499: Server listening on 0.0.0.0:64764
1603239964 [INF] CMGR connmanager.go:499: Server listening on [::]:64764
1603239964 [INF] RPCS rpcserver.go:4498: RPC server listening on 127.0.0.1:64765
1603239964 [INF] CMGR seed.go:57: 1 addresses found from DNS seed seed.anode.co
1603239964 [INF] CMGR seed.go:57: 26 addresses found from DNS seed seed.gridfinity.com
1603239964 [INF] CMGR seed.go:57: 22 addresses found from DNS seed seed.cjd.li
1603239975 [INF] SYNC manager.go:426: New valid peer 198.58.101.91:64764 (outbound) (/btcwire:0.5.0/pktd:1.1.1-942bda7d/)
[SNIP]
1603239976 [INF] SYNC manager.go:979: Verified downloaded block header against checkpoint at height 8192/hash 2b6b3d2951d365f26fd5b5362ab8dd5695ea6f5bd6c19ea9b16eb63a3de95ede
1603239976 [INF] SYNC manager.go:1004: Received 8192 block headers: Fetching blocks
1603239986 [INF] SYNC blocklogger.go:69: Processed 1091 blocks in the last 10s (1091 transactions, height 1091, 2019-08-20 17:35:50 +0000 UTC)

and yer off to the races.....

[FYI apk add tmux helps here]

now the pktwallet example:

# ./pktwallet --create                                   

/root/.pktwallet/pktwallet.conf does not exist, creating it from default
Enter the private passphrase for your new wallet: ********
Confirm passphrase: ********
Do you want to add an additional layer of encryption for public data? (n/no/y/yes) [no]: no                                                                       
Do you have an existing wallet seed you want to use? (n/no/y/yes) [no]: no
Encrypting your seed...                                                         
Your wallet generation seed is:
[redacted]

# ./pktwallet --userpc
1603240137 [INF] BTCW btcwallet.go:115: Version 1.1.1-0993fc3c
1603240137 [INF] BTCW version.go:97: This is a pre-release version
1603240137 [INF] BTCW rpcserver.go:57: Generating TLS certificates...
1603240138 [INF] BTCW rpcserver.go:100: Done generating TLS certificates
1603240138 [WRN] BTCW rpcserver.go:238: Can't listen on [::1]:64763: 1.1.1-0993fc3c listen tcp6 [::1]:64763: bind: cannot assign requested address

  btcutil/er/er.go:359 +0x188     btcutil/er.E()
  pktwallet/rpcserver.go:133 +0x85        main.startRPCServers.func1()
  pktwallet/rpcserver.go:236 +0x423       main.makeListeners()
  pktwallet/rpcserver.go:160 +0x268       main.startRPCServers()
  pktwallet/btcwallet.go:135 +0x2a7       main.walletMain()
  pktwallet/btcwallet.go:41 +0xa5         main.main()

1603240138 [INF] BTCW btcwallet.go:336: Attempting RPC client connection to localhost:64765
1603240138 [INF] RPCS server.go:198: Listening on 127.0.0.1:64763
1603240138 [INF] CHNS infrastructure.go:1388: Established connection to RPC server localhost:64765
1603240139 [INF] WLLT wallet.go:3335: Opened wallet
1603240139 [INF] WLLT chainntfns.go:100: Notification chain.ClientConnected
# ./pktctl --wallet getnewaddress
pkt1[redacted]

These binaries will run anywhere - no libc linkage required - note that on Linux glibc "static" binaries are not actually static anymore, because they will dynamically dlload/dlopen stuff, etc. Linux is terrible.

bin/pktctl:    ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, not stripped
bin/pktd:      ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, not stripped
bin/pktwallet: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, not stripped

newDo is a "hermetic" build system for building for redistribution, intended to on at least Linux (as far back as 1.2 kernels!), Mac OS X, MINGW 32/64, Win WSL, Free/Net/Open/DragonFlyBSD, Solaris, and even others, and is tested with with zsh, bash, ksh93, dash, ash, mksh, lksh, and OpenKSH [and is 100% sub-POSIX shell] - thousands and thousands of eye-cancer-causing lines of it, full of crazyness and insanity and stuff to ensure you get a working build - and tries it's best to not let you use incompatible flags.

newDo supports the following options, as of this writing:

# With BE_VERBOSE enabled, the script itself and any external
# commands it calls will be configured for extra verbosity. 
#BE_VERBOSE=0                           # OFF by default   
                                                          
# When DEBUG_OUTPUT is enabled, the script itself as well    
# as some called commands will be configured to produce   
# extra output, which may be helpful for debugging issues.    
#DEBUG_OUTPUT=0                         # OFF by default  

# If PKT_FAIL_DIRTY is enabled, the build process will fail 
# if any changes have been made to the the sources or the
# build scripts, to ensure a stable and reliable build.      
#PKT_FAIL_DIRTY=1                       # ON by default     
                                                           
# If using a build that utilizes Cgo, this option will add
# "-march=native" to the compiler flags, which will produce  
# binary output that is possibly faster, but not-portable.
#PKT_BUILD_NATIVE=0                     # OFF by default      
                                                             
# When enabled, no tests are run when the build is done.    
#PKT_SKIP_TESTS=0                       # OFF by default   
                                                          
# When enabled, use a separate GOPATH for the PKT build.     
#PKT_OWN_GOPATH=1                       # ON by default   

# If PKT_OWN_GOPATH is enabled, then the PKT_OWN_GOPATH_DIR
# variable will be used to provide a specific directory to  
# be used for the GOPATH. If undefined, the default "go-pkt"
# directory will be created in the current directory.    
#PKT_OWN_GOPATH_DIR="$HOME/.go-pkt"     # SET by default     
                                                            
# When this option is enabled, special steps are taken to  
# ensure a *fully* fresh build is produced, without using 
# any previous build artifacts. At a minimum, this calls     
# use git clean and go clean -cache. Additionally, if     
# PKT_OWN_GOPATH is enabled, the entire contents of the       
# PKT_OWN_GOPATH_DIR will be cleared. If ccache is is found,
# the ccache cache directory is also completely cleared.    
# During the build, -a to rebuild all will be enabled also. 
#PKT_FROM_SCRATCH=0                     # OFF by default 
                                                             
# When enabled, builds the (unsupported) wallettool utility.
#PKT_BUILD_WALLETTOOL=0         # OFF by default           
                                                          
# When enbabld, builds the (unsupported) dropwtxmgr utility. 
#PKT_BUILD_DROPWTXMGR=0         # OFF by default          

# This option will make best efforts for a "pure Go" build, 
# avoiding any unnecessary use of Cgo functionality or Gccgo,
# and will force the selection of the pure Go DNS resolver. 
# This outputs a standalone static binary on most platforms.
#PKT_BUILD_PUREGO=1                     # ON by default      
                                                            
# This option, in combination with the required toolchain, 
# such as that which is available on Fedora 26 or higher, 
# will build PIE (Position Independent Executable) binaries  
# which use the hardened compiler and linker flags developed
# and tested by Red Hat. These options are are the defaults   
# when no overriding options are specified using the Red Hat
# distributed releases of Golang. This option could be useful
# to users of other distributions, or for Red Hat users who 
# are utilizing the mainline Google Golang distribution.    
#PKT_BUILD_HARDRH=0                     # OFF by default     
                                                            
# This option attempts to create a reproducible binary, where
# the same source will produce the the same binary each time,
# at the the expense of extended features, such as support   
# for GNU_HASH, Build-ID, and similar ELF functionality.    
#PKT_BUILD_REPROD=1             # ON by default               

# This option will make use of the "UPX" compression utiltity.
# if available, to reduce the size of the compiled binaries.
#PKT_UPX_COMPRESS=0                             # OFF by default

I have a newer alpha version that can do cross-compiling successfully as well as producing automated opmsg and/or gnupg signed releases. Again, this is most going to be ported to Go and hopefully would be able to quality for inclusion in a release.

I'll put a copy of it here in a PR, in case it might help someone build redist binaries or what not - but I recommend NOT using it unless have the specific NEED for it, such as produce a ABI/API agnostic distributable releases, etc.

Race detector hits for pktd

Two so far, doing sync from 0.

  • First one between AddrManager and ConnManager. (Not unexpected as I've probably fixed a dozen between these two so far.)
1604481610 [INF] SYNC manager.go:434: New valid peer 45.79.38.122:64764 (outbound) (/btcwire:0.5.0/pktd:1.1.1-df6dd036/)
==================
WARNING: DATA RACE
Write at 0x00c00021ca20 by goroutine 180:
  github.com/pkt-cash/pktd/addrmgr.(*AddrManager).updateAddress()
      github.com/pkt-cash/pktd/addrmgr/addrmanager.go:193 +0x3a6
  github.com/pkt-cash/pktd/addrmgr.(*AddrManager).AddAddresses()
      github.com/pkt-cash/pktd/addrmgr/addrmanager.go:610 +0xc9
  main.(*serverPeer).OnAddr()
      github.com/pkt-cash/pktd/server.go:1272 +0x450
  main.(*serverPeer).OnAddr-fm()
      github.com/pkt-cash/pktd/server.go:1229 +0x55
  github.com/pkt-cash/pktd/peer.(*Peer).inHandler()
      github.com/pkt-cash/pktd/peer/peer.go:1507 +0x1da9

Previous read at 0x00c00021ca20 by goroutine 88:
  github.com/pkt-cash/pktd/addrmgr.(*KnownAddress).NetAddress()
      github.com/pkt-cash/pktd/addrmgr/knownaddress.go:29 +0x438
  main.newServer.func5()
      github.com/pkt-cash/pktd/server.go:2812 +0x444
  github.com/pkt-cash/pktd/connmgr.(*ConnManager).NewConnReq()
      github.com/pkt-cash/pktd/connmgr/connmanager.go:406 +0x401
  github.com/pkt-cash/pktd/connmgr.(*ConnManager).handleFailedConn.func2()
      github.com/pkt-cash/pktd/connmgr/connmanager.go:220 +0x5d

Goroutine 180 (running) created at:
  github.com/pkt-cash/pktd/peer.(*Peer).start()
      github.com/pkt-cash/pktd/peer/peer.go:2193 +0x3bc
  github.com/pkt-cash/pktd/peer.(*Peer).AssociateConnection.func1()
      github.com/pkt-cash/pktd/peer/peer.go:2230 +0x3c

Goroutine 88 (running) created at:
  time.goFunc()
      time/sleep.go:167 +0x51
==================
[DBG] CMGR connmanager.go:275: Connected to [2600:3c00::f03c:92ff:fe24:730]:64764 (reqid 39)
  • Second one detected in ConnManager, no fun to see NotifyConnectionRequestActuallyCompleted() in there since I wrote that one.
==================
WARNING: DATA RACE
Read at 0x00c0002c4e80 by goroutine 165:
  github.com/pkt-cash/pktd/connmgr.(*ConnManager).handleFailedConn()
      github.com/pkt-cash/pktd/connmgr/connmanager.go:212 +0x3f3
  github.com/pkt-cash/pktd/connmgr.(*ConnManager).connHandler()
      github.com/pkt-cash/pktd/connmgr/connmanager.go:355 +0x4c4

Previous write at 0x00c0002c4e80 by goroutine 152:
  github.com/pkt-cash/pktd/connmgr.(*ConnManager).NotifyConnectionRequestActuallyCompleted()
      github.com/pkt-cash/pktd/connmgr/connmanager.go:371 +0xafb
  main.(*server).handleAddPeerMsg()
      github.com/pkt-cash/pktd/server.go:1652 +0xac4
  main.(*server).peerHandler()
      github.com/pkt-cash/pktd/server.go:2128 +0xe8f

Goroutine 165 (running) created at:
  github.com/pkt-cash/pktd/connmgr.(*ConnManager).Start()
      github.com/pkt-cash/pktd/connmgr/connmanager.go:536 +0x126

Goroutine 152 (running) created at:
  main.(*server).Start()
      github.com/pkt-cash/pktd/server.go:2329 +0x128
  main.pktdMain()
      github.com/pkt-cash/pktd/pktd.go:179 +0x121d
  fmt.Fscanf()
      fmt/scan.go:143 +0xd4
  fmt.Sscanf()
      fmt/scan.go:114 +0x191
  github.com/pkt-cash/pktd/goleveldb/leveldb/storage.fsParseName()
      github.com/pkt-cash/pktd/[email protected]/leveldb/storage/file_storage.go:643 +0xa6
  github.com/pkt-cash/pktd/goleveldb/leveldb/storage.(*fileStorage).List()
      github.com/pkt-cash/pktd/[email protected]/leveldb/storage/file_storage.go:458 +0x319
  fmt.Fscanf()
      fmt/scan.go:143 +0xd4
  fmt.Sscanf()
      fmt/scan.go:114 +0x191
  github.com/pkt-cash/pktd/goleveldb/leveldb/storage.fsParseName()
      github.com/pkt-cash/pktd/[email protected]/leveldb/storage/file_storage.go:643 +0xa6
  github.com/pkt-cash/pktd/goleveldb/leveldb/storage.(*fileStorage).List()
      github.com/pkt-cash/pktd/[email protected]/leveldb/storage/file_storage.go:458 +0x319
  github.com/pkt-cash/pktd/goleveldb/leveldb.(*DB).checkAndCleanFiles()
      github.com/pkt-cash/pktd/[email protected]/leveldb/db_util.go:52 +0x301
  github.com/pkt-cash/pktd/goleveldb/leveldb.openDB()
      github.com/pkt-cash/pktd/[email protected]/leveldb/db.go:136 +0xa3e
  fmt.(*ss).doScanf()
      fmt/scan.go:1230 +0x3c5
  fmt.Fscanf()
      fmt/scan.go:143 +0xd4
  fmt.Sscanf()
      fmt/scan.go:114 +0x191
  github.com/pkt-cash/pktd/goleveldb/leveldb/storage.fsParseName()
      github.com/pkt-cash/pktd/[email protected]/leveldb/storage/file_storage.go:643 +0xa6
  github.com/pkt-cash/pktd/goleveldb/leveldb/storage.(*fileStorage).List()
      github.com/pkt-cash/pktd/[email protected]/leveldb/storage/file_storage.go:458 +0x319
  github.com/pkt-cash/pktd/goleveldb/leveldb.(*DB).checkAndCleanFiles()
      github.com/pkt-cash/pktd/[email protected]/leveldb/db_util.go:52 +0x301
  github.com/pkt-cash/pktd/goleveldb/leveldb.openDB()
      github.com/pkt-cash/pktd/[email protected]/leveldb/db.go:136 +0xa3e
  fmt.(*ss).doScanf()
      fmt/scan.go:1230 +0x3c5
  fmt.Fscanf()
      fmt/scan.go:143 +0xd4
  fmt.Sscanf()
      fmt/scan.go:114 +0x191
  github.com/pkt-cash/pktd/goleveldb/leveldb/storage.fsParseName()
      github.com/pkt-cash/pktd/[email protected]/leveldb/storage/file_storage.go:643 +0xa6
  github.com/pkt-cash/pktd/goleveldb/leveldb/storage.(*fileStorage).List()
      github.com/pkt-cash/pktd/[email protected]/leveldb/storage/file_storage.go:458 +0x319
  fmt.Fscanf()
      fmt/scan.go:143 +0xd4
  fmt.Sscanf()
      fmt/scan.go:114 +0x191
  github.com/pkt-cash/pktd/goleveldb/leveldb/storage.fsParseName()
      github.com/pkt-cash/pktd/[email protected]/leveldb/storage/file_storage.go:643 +0xa6
  github.com/pkt-cash/pktd/goleveldb/leveldb/storage.(*fileStorage).List()
      github.com/pkt-cash/pktd/[email protected]/leveldb/storage/file_storage.go:458 +0x319
  fmt.Fscanf()
      fmt/scan.go:143 +0xd4
  fmt.Sscanf()
      fmt/scan.go:114 +0x191
  github.com/pkt-cash/pktd/goleveldb/leveldb/storage.fsParseName()
      github.com/pkt-cash/pktd/[email protected]/leveldb/storage/file_storage.go:643 +0xa6
  github.com/pkt-cash/pktd/goleveldb/leveldb/storage.(*fileStorage).List()
      github.com/pkt-cash/pktd/[email protected]/leveldb/storage/file_storage.go:458 +0x319
  fmt.Fscanf()
      fmt/scan.go:143 +0xd4
  fmt.Sscanf()
      fmt/scan.go:114 +0x191
  github.com/pkt-cash/pktd/goleveldb/leveldb/storage.fsParseName()
      github.com/pkt-cash/pktd/[email protected]/leveldb/storage/file_storage.go:643 +0xa6
  github.com/pkt-cash/pktd/goleveldb/leveldb/storage.(*fileStorage).List()
      github.com/pkt-cash/pktd/[email protected]/leveldb/storage/file_storage.go:458 +0x319
  github.com/pkt-cash/pktd/goleveldb/leveldb.(*DB).recoverJournal()
      github.com/pkt-cash/pktd/[email protected]/leveldb/db.go:482 +0xc8
  github.com/pkt-cash/pktd/goleveldb/leveldb.openDB()
      github.com/pkt-cash/pktd/[email protected]/leveldb/db.go:131 +0xa1a
  github.com/pkt-cash/pktd/goleveldb/leveldb.Open()
      github.com/pkt-cash/pktd/[email protected]/leveldb/db.go:203 +0x247
  fmt.Fscanf()
      fmt/scan.go:143 +0xd4
  fmt.Sscanf()
      fmt/scan.go:114 +0x191
  github.com/pkt-cash/pktd/goleveldb/leveldb/storage.fsParseName()
  github.com/pkt-cash/pktd/goleveldb/leveldb/storage.fsParseName()
      github.com/pkt-cash/pktd/[email protected]/leveldb/storage/file_storage.go:643 +0xa6
  github.com/pkt-cash/pktd/goleveldb/leveldb/storage.(*fileStorage).List()
      github.com/pkt-cash/pktd/[email protected]/leveldb/storage/file_storage.go:458 +0x319
  github.com/pkt-cash/pktd/goleveldb/leveldb.(*session).recover.func1()
      github.com/pkt-cash/pktd/[email protected]/leveldb/session.go:134 +0x103
  github.com/pkt-cash/pktd/goleveldb/leveldb.(*session).recover()
      github.com/pkt-cash/pktd/[email protected]/leveldb/session.go:142 +0x1952
  github.com/pkt-cash/pktd/goleveldb/leveldb.Open()
      github.com/pkt-cash/pktd/[email protected]/leveldb/db.go:189 +0x109
  github.com/pkt-cash/pktd/goleveldb/leveldb.OpenFile()
      github.com/pkt-cash/pktd/[email protected]/leveldb/db.go:225 +0xae
  github.com/pkt-cash/pktd/database/ffldb.openDB()
      github.com/pkt-cash/pktd/database/ffldb/db.go:2067 +0x184
  github.com/pkt-cash/pktd/database/ffldb.createDBDriver()
      github.com/pkt-cash/pktd/database/ffldb/driver.go:65 +0x104
  github.com/pkt-cash/pktd/database.Create()
      github.com/pkt-cash/pktd/database/driver.go:75 +0x10f
  main.loadBlockDB()
      github.com/pkt-cash/pktd/pktd.go:304 +0x979
  main.pktdMain()
      github.com/pkt-cash/pktd/pktd.go:102 +0x4f4
  main.main()
      github.com/pkt-cash/pktd/pktd.go:345 +0x1fe
==================

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.