From 0c3cf63773370d9c44eb1b47944c951ca0749d5d Mon Sep 17 00:00:00 2001 From: Javed Khan Date: Thu, 12 Nov 2015 23:22:58 +0530 Subject: [PATCH 1/5] Use new connections for peers in TestOutboundPeer Fixes a rare hang during peer tests due to the same connection being used for different outbound peers. Also fixed passing a chan to QueueMessage(..) which was not being waited on, so was not being used. --- peer/peer_test.go | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/peer/peer_test.go b/peer/peer_test.go index ddf1d282..11bb4090 100644 --- a/peer/peer_test.go +++ b/peer/peer_test.go @@ -569,7 +569,7 @@ func TestOutboundPeer(t *testing.T) { // Test Queue Message fakeMsg := wire.NewMsgVerAck() p.QueueMessage(fakeMsg, nil) - done := make(chan struct{}, 5) + done := make(chan struct{}) p.QueueMessage(fakeMsg, done) <-done p.Shutdown() @@ -584,12 +584,14 @@ func TestOutboundPeer(t *testing.T) { return hash, 234439, nil } peerCfg.NewestBlock = newestBlock + r1, w1 := io.Pipe() + c1 := &conn{raddr: "10.0.0.1:8333", Writer: w1, Reader: r1} p1, err := peer.NewOutboundPeer(peerCfg, "10.0.0.1:8333") if err != nil { t.Errorf("NewOutboundPeer: unexpected err - %v\n", err) return } - if err := p1.Connect(c); err != nil { + if err := p1.Connect(c1); err != nil { t.Errorf("Connect: unexpected err %v\n", err) return } @@ -615,12 +617,14 @@ func TestOutboundPeer(t *testing.T) { // Test regression peerCfg.ChainParams = &chaincfg.RegressionNetParams peerCfg.Services = wire.SFNodeBloom + r2, w2 := io.Pipe() + c2 := &conn{raddr: "10.0.0.1:8333", Writer: w2, Reader: r2} p2, err := peer.NewOutboundPeer(peerCfg, "10.0.0.1:8333") if err != nil { t.Errorf("NewOutboundPeer: unexpected err - %v\n", err) return } - if err := p2.Connect(c); err != nil { + if err := p2.Connect(c2); err != nil { t.Errorf("Connect: unexpected err %v\n", err) return } @@ -647,11 +651,11 @@ func TestOutboundPeer(t *testing.T) { p2.PushRejectMsg("block", wire.RejectInvalid, "invalid", nil, false) // Test Queue Messages - p2.QueueMessage(wire.NewMsgGetAddr(), done) - p2.QueueMessage(wire.NewMsgPing(1), done) - p2.QueueMessage(wire.NewMsgMemPool(), done) - p2.QueueMessage(wire.NewMsgGetData(), done) - p2.QueueMessage(wire.NewMsgGetHeaders(), done) + p2.QueueMessage(wire.NewMsgGetAddr(), nil) + p2.QueueMessage(wire.NewMsgPing(1), nil) + p2.QueueMessage(wire.NewMsgMemPool(), nil) + p2.QueueMessage(wire.NewMsgGetData(), nil) + p2.QueueMessage(wire.NewMsgGetHeaders(), nil) p2.Shutdown() } From ee8601ecacf43b625eb17e0d801139e83b7d0c04 Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Fri, 20 Nov 2015 13:04:04 -0600 Subject: [PATCH 2/5] Add checkpoint at block height 382320. --- chaincfg/params.go | 1 + 1 file changed, 1 insertion(+) diff --git a/chaincfg/params.go b/chaincfg/params.go index 8ef1989c..e9412459 100644 --- a/chaincfg/params.go +++ b/chaincfg/params.go @@ -140,6 +140,7 @@ var MainNetParams = Params{ {319400, newShaHashFromStr("000000000000000021c6052e9becade189495d1c539aa37c58917305fd15f13b")}, {343185, newShaHashFromStr("0000000000000000072b8bf361d01a6ba7d445dd024203fafc78768ed4368554")}, {352940, newShaHashFromStr("000000000000000010755df42dba556bb72be6a32f3ce0b6941ce4430152c9ff")}, + {382320, newShaHashFromStr("00000000000000000a8dc6ed5b133d0eb2fd6af56203e4159789b092defd8ab2")}, }, // Enforce current block version once majority of the network has From 23df5ed2fc06b96b90ae2d8c4ef0eb44182ecc7d Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Fri, 20 Nov 2015 10:10:49 -0600 Subject: [PATCH 3/5] Add 0.12.0 deps to deps.txt. --- deps.txt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/deps.txt b/deps.txt index 9d270ac7..9284bf98 100644 --- a/deps.txt +++ b/deps.txt @@ -204,3 +204,17 @@ goleveldb d87ae1f5189b9ece9ed9b661e490a668e9a1d0df seelog 313961b101eb55f65ae0f03ddd4e322731763b6c websocket 31079b6807923eb23992c421b114992b95131b55 winsvc f8fb11f83f7e860e3769a08e6811d1b399a43722 + +btcd 0.12.0 Beta +---------------- +btclog 5005b7240f310ae8f01c7664a3954d280241eb2b +btcutil ff82dacded1c76d101bce55c394c03c0bbff69e8 +fastsha256 302ad4db268b46f9ebda3078f6f7397f96047735 +go-flags 6c288d648c1cc1befcb90cb5511dcacf64ae8e61 +go-socks cfe8b59e565c1a5bd4e2005d77cd9aa8b2e14524 +golangcrypto 53f62d9b43e87a6c56975cf862af7edf33a8d0df +goleveldb d87ae1f5189b9ece9ed9b661e490a668e9a1d0df +seelog 313961b101eb55f65ae0f03ddd4e322731763b6c +snappy-go fff4c573c694b1e2d5c7a9b2b72dbe947b6a4c8e +websocket 31079b6807923eb23992c421b114992b95131b55 +winsvc f8fb11f83f7e860e3769a08e6811d1b399a43722 From cea5d3c1cc16eb07a1686c557db23004655ae11b Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Fri, 20 Nov 2015 19:33:17 -0600 Subject: [PATCH 4/5] Prepare for release 0.12.0. --- CHANGES | 120 ++++++++++++++++++++++++++++++++++++++++++ cmd/btcctl/version.go | 4 +- version.go | 4 +- 3 files changed, 124 insertions(+), 4 deletions(-) diff --git a/CHANGES b/CHANGES index ba3be7c3..f72956db 100644 --- a/CHANGES +++ b/CHANGES @@ -3,6 +3,126 @@ User visible changes for btcd A full-node bitcoin implementation written in Go ============================================================================ +Changes in 0.12.0 (Fri Nov 20 2015) + - Protocol and network related changes: + - Add a new checkpoint at block height 382320 (#555) + - Implement BIP0065 which includes support for version 4 blocks, a new + consensus opcode (OP_CHECKLOCKTIMEVERIFY) that enforces transaction + lock times, and a double-threshold switchover mechanism (#535, #459, + #455) + - Implement BIP0111 which provides a new bloom filter service flag and + hence provides support for protocol version 70011 (#499) + - Add a new parameter --nopeerbloomfilters to allow disabling bloom + filter support (#499) + - Reject non-canonically encoded variable length integers (#507) + - Add mainnet peer discovery DNS seed (seed.bitcoin.jonasschnelli.ch) + (#496) + - Correct reconnect handling for persistent peers (#463, #464) + - Ignore requests for block headers if not fully synced (#444) + - Add CLI support for specifying the zone id on IPv6 addresses (#538) + - Fix a couple of issue where the initial block sync could stall (#518, + #229, #486) + - Fix an issue which prevented the --onion option from working as + intended (#446) + - Transaction relay (memory pool) changes: + - Require transactions to only include signatures encoded with the + canonical 'low-s' encoding (#512) + - Add a new parameter --minrelaytxfee to allow the minimum transaction + fee in BTC/kB to be overridden (#520) + - Retain memory pool transactions when they redeem another one that is + removed when a block is accepted (#539) + - Do not send reject messages for a transaction if it is valid but + causes an orphan transaction which depends on it to be determined + as invalid (#546) + - Refrain from attempting to add orphans to the memory pool multiple + times when the transaction they redeem is added (#551) + - Modify minimum transaction fee calculations to scale based on bytes + instead of full kilobyte boundaries (#521, #537) + - Implement signature cache: + - Provides a limited memory cache of validated signatures which is a + huge optimization when verifying blocks for transactions that are + already in the memory pool (#506) + - Add a new parameter '--sigcachemaxsize' which allows the size of the + new cache to be manually changed if desired (#506) + - Mining support changes: + - Notify getblocktemplate long polling clients when a block is pushed + via submitblock (#488) + - Speed up getblocktemplate by making use of the new signature cache + (#506) + - RPC changes: + - Implement getmempoolinfo command (#453) + - Implement getblockheader command (#461) + - Modify createrawtransaction command to accept a new optional parameter + 'locktime' (#529) + - Modify listunspent result to include the 'spendable' field (#440) + - Modify getinfo command to include 'errors' field (#511) + - Add timestamps to blockconnected and blockdisconnected notifications + (#450) + - Several modifications to searchrawtranscations command: + - Accept a new optional parameter 'vinextra' which causes the results + to include information about the outputs referenced by a transaction + inputs (#485, #487) + - Skip entries in the mempool too (#495) + - Accept a new optional parameter 'reverse' to return the results in + reverse order (most recent to oldest) (#497) + - Accept a new optional parameter 'filteraddrs' which causes the + results to only include inputs and outputs which involve the + provided addresses (#516) + - Change the notification order to notify clients about mined + transactions (recvtx, redeemingtx) before the blockconnected + notification (#449) + - Update verifymessage RPC to use the standard algorithm so it is + compatible with other implementations (#515) + - Improve ping statistics by pinging on an interval (#517) + - Websocket changes: + - Implement session command which returns a per-session unique id (#500, + #503) + - btcctl utility changes: + - Add getmempoolinfo command (#453) + - Add getblockheader command (#461) + - Add getwalletinfo command (#471) + - Notable developer-related package changes: + - Introduce a new peer package which acts a common base for creating and + concurrently managing bitcoin network peers (#445) + - Various cleanup of the new peer package (#528, #531, #524, #534, + #549) + - Blocks heights now consistently use int32 everywhere (#481) + - The BlockHeader type in the wire package now provides the BtcDecode + and BtcEncode methods (#467) + - Update wire package to recognize BIP0064 (getutxo) service bit (#489) + - Export LockTimeThreshold constant from txscript package (#454) + - Export MaxDataCarrierSize constant from txscript package (#466) + - Provide new IsUnspendable function from the txscript package (#478) + - Export variable length string functions from the wire package (#514) + - Export DNS Seeds for each network from the chaincfg package (#544) + - Preliminary work towards separating the memory pool into a separate + package (#525, #548) + - Misc changes: + - Various documentation updates (#442, #462, #465, #460, #470, #473, + #505, #530, #545) + - Add installation instructions for gentoo (#542) + - Ensure an error is shown if OS limits can't be set at startup (#498) + - Tighten the standardness checks for multisig scripts (#526) + - Test coverage improvement (#468, #494, #527, #543, #550) + - Several optimizations (#457, #474, #475, #476, #508, #509) + - Minor code cleanup and refactoring (#472, #479, #482, #519, #540) + - Contributors (alphabetical order): + - Ben Echols + - Bruno Clermont + - danda + - Daniel Krawisz + - Dario Nieuwenhuis + - Dave Collins + - David Hill + - Javed Khan + - Jonathan Gillham + - Joseph Becher + - Josh Rickmar + - Justus Ranvier + - Mawuli Adzoe + - Olaoluwa Osuntokun + - Rune T. Aune + Changes in 0.11.1 (Wed May 27 2015) - Protocol and network related changes: - Use correct sub-command in reject message for rejected transactions diff --git a/cmd/btcctl/version.go b/cmd/btcctl/version.go index 12a27ab5..fb147bcd 100644 --- a/cmd/btcctl/version.go +++ b/cmd/btcctl/version.go @@ -17,8 +17,8 @@ const semanticAlphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqr // versioning 2.0.0 spec (http://semver.org/). const ( appMajor uint = 0 - appMinor uint = 11 - appPatch uint = 1 + appMinor uint = 12 + appPatch uint = 0 // appPreRelease MUST only contain characters from semanticAlphabet // per the semantic versioning spec. diff --git a/version.go b/version.go index c9a7a3d3..192f4a7f 100644 --- a/version.go +++ b/version.go @@ -17,8 +17,8 @@ const semanticAlphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqr // versioning 2.0.0 spec (http://semver.org/). const ( appMajor uint = 0 - appMinor uint = 11 - appPatch uint = 1 + appMinor uint = 12 + appPatch uint = 0 // appPreRelease MUST only contain characters from semanticAlphabet // per the semantic versioning spec. From 6c00d079106efe16ec825c4fd6de9a87ba51b415 Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Fri, 20 Nov 2015 21:13:08 -0600 Subject: [PATCH 5/5] peer: Combine stats struct into peer struct. This defines the peer stat fields directly in the Peer struct instead of defining them in a separate struct and embedding them. It is slightly more efficient this way and there is really no reason to have them defined separately anyways since they are not passed around or otherwise used independently. --- peer/peer.go | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/peer/peer.go b/peer/peer.go index 3d4c2baa..43939f0e 100644 --- a/peer/peer.go +++ b/peer/peer.go @@ -322,23 +322,6 @@ type stallControlMsg struct { message wire.Message } -// stats is the collection of stats related to a peer. -type stats struct { - statsMtx sync.RWMutex // protects all statistics below here. - timeOffset int64 - timeConnected time.Time - lastSend time.Time - lastRecv time.Time - bytesReceived uint64 - bytesSent uint64 - startingHeight int32 - lastBlock int32 - lastAnnouncedBlock *wire.ShaHash - lastPingNonce uint64 // Set to nonce if we have a pending ping. - lastPingTime time.Time // Time we sent last ping. - lastPingMicros int64 // Time for last ping to return. -} - // StatsSnap is a snapshot of peer stats at a point in time. type StatsSnap struct { ID int32 @@ -428,6 +411,22 @@ type Peer struct { prevGetHdrsBegin *wire.ShaHash prevGetHdrsStop *wire.ShaHash + // These fields keep track of statistics for the peer and are protected + // by the statsMtx mutex. + statsMtx sync.RWMutex + timeOffset int64 + timeConnected time.Time + lastSend time.Time + lastRecv time.Time + bytesReceived uint64 + bytesSent uint64 + startingHeight int32 + lastBlock int32 + lastAnnouncedBlock *wire.ShaHash + lastPingNonce uint64 // Set to nonce if we have a pending ping. + lastPingTime time.Time // Time we sent last ping. + lastPingMicros int64 // Time for last ping to return. + stallControl chan stallControlMsg outputQueue chan outMsg sendQueue chan outMsg @@ -437,8 +436,6 @@ type Peer struct { queueQuit chan struct{} outQuit chan struct{} quit chan struct{} - - stats } // String returns the peer's address and directionality as a human-readable @@ -2058,7 +2055,6 @@ func newPeerBase(cfg *Config, inbound bool) *Peer { queueQuit: make(chan struct{}), outQuit: make(chan struct{}), quit: make(chan struct{}), - stats: stats{}, cfg: *cfg, // Copy so caller can't mutate. services: cfg.Services, protocolVersion: protocolVersion,