The chainindexer.go file is completely commented out and has been
replaced by a new indexing infrastructure. This removes the entire file
since it is no longer required.
This corrects an issue introduced by commit
e8f63bc29550705268b533032ccc2ea24f8c86ba where a failure to lookup a
hostname could lead to a panic in certain circumstances. An error is
now returned in that case as expected.
This commit modifies the `ConnManager` to use the `net.Add` interface
through the package instead of a plain string to represent and
manipulate addresses. This change makes the package much more general as
users of the package can possibly utilize custom implementations of the
`net.Addr` interface to establish connections.
More precisely, the `ConnReq` struct has been modified to use a net.Addr
instance explicitly, and the `DialFunc` type has also been modified to
take a `net.Addr` directly. This latter change gives functions that
adhere to the `DialFunc` type more flexibility as to exactly how the
connection is established.
Additionally, the `connmgr.Config.GetNewAddress` configuration option
now directly returns a `net.Addr. This change allows the `connmgr` to be
decoupled from all DNS queries which allows callers to preferentially
select more secure methods like performing DNS lookups over a Tor proxy.
This modifies the connection manager to provide support for accepting
inbound connections on a caller-provided set of listeners and notify the
caller via a callback.
This is only the minimum work necessary to get inbound support into the
connection manager. The intention for future commits is to move more
connection-related logic such as limiting the maximum number of overall
connections and banned peer tracking into the connection manager.
This removes the type definitions for the callback functions in favor of
declaring them directly in the Config struct. This is more consistent
with the rest of the code base and is preferred since it means callers
reviewing the documentation don't have to follow another level of
indirection to figure out the signature.
The inability for a peer to negotiate is not something that should be a
warning which implies something is wrong. On the contrary, it is quite
expected that various peers will connect (or be connected to) that are
unable to properly negotiate for a variety of reasons. One example would
be a peer that is too old.
Also, while here take care of a few style nits.
This corrects a few issues introduced with the connection manager where
the server was not notifying the connection manager when a connection
request is available again.
The cases resolved are:
- Unable to initialize a server peer instance in response to the connection
- Failure to associate the connection with the server peer instance
- Disconnection of a non-persistent outbound peer
It also changes the log message to a debug in the former case because
it's not something that should be shown to the user as an error given
it's not due to anything the user has misconfigured nor is it even
unexpected if an invalid address is provided.
This adds a new field to the peer struct which stores the protocol
version advertised by the remote peer and updates the StatsSnapshot to
return the advertised version instead of the negotiated version.
Older nodes previously added the IP and port information to the address
manager which proved to be unreliable as an inbound connection from a
peer didn't necessarily mean the peer itself accepted inbound
connections.
This also fixes a bug where the peer package was incorrectly sending
the peer's services as its own.
This commit introduces package connmgr which contains connection
management related functionality.
The following is an overview of the features the package provides:
- Maintain fixed number of outbound connections
- Optional connect-only mode
- Retry persistent connections with increasing back-off
- Source peers from DNS seeds
- Use Tor to resolve DNS
- Dynamic ban scores
- Test coverage
In addition, btcd has been refactored to make use of the new package by
extending the connection manager to work with the server to source and
maintain peer connections. The following is a broad overview of the
changes to integrate the package:
- Simplify peer state by removing pending, retry peers
- Refactor to remove retries which are now handled by connmgr
- Use callback to add addresses sourced from the DNS seed
Finally the following connection-related things have been improved as a
part of this refactor:
- Fixes 100% cpu usage when network is down
- Fixes issues with max peers
- Simplify outbound peer connections management
dcrctl does not require dcrd so it should not keep complaining about
it missing. Just skip automatic configuration if dcrd's configuration
is missing, but still set it up in the future if one appears and dcrctl
is still lacking a configuration file.
Upstream commit 763f731c5c.
This updates wire to enforce a limit of 256 instead of the existing 2000
to coincide with the upstream btcd project, and consequently includes a
wire version bump to 0.2.1 in the merge commit.
This modifies the rpcserver.go file to make the function definitions
consistent with one another. Not only is this good for consistency, but
it also makes the upstream syncs easier since there are less merge
conflicts due to superfluous changes.
This adds bounds check for the RPC parameters for the getstakeversions
command to both the handler and the chain function itself which provides
the data.
Also, while here simplify the for loop in GetStakeVersions to check
prevNode in the for loops condition instead of in a separate if block,
return more appropriate error types for RPC parameter type errors, and
use a naked type cast of the command to be consistent with all of the
other handlers.
This updates the script signing test code to use a single chain params
variable instead of repeatedly referring to a specific network. This
makes it much easier to change in the future such as future testnet
resets.
The linters take quite a while to run in the TravisCI environment which
causes the deadline to be exceeded.
While here, also increase the allowed deadline for the remaining linters
to 10 minutes and also update Travis to use a new ubuntu distribution.
The test network should allow any scripts and transaction types that are
valid according to consensus rules as opposed to the more strict
standardness rules that apply to mainnet. This allows new script forms
and types to be tested before they go to mainnet.
Also, this is the same setting as the previous test network.
Agendas require some complicated and not always obvious assumptions. In
order to prevent bad agendas from making it into the code we validate
them at init time and panic if an agenda violates assumptions. This
will not adversely impact the user experience but will force developers
to properly design dcrd agendas.
These are the required tests to ensure vote integrity:
* All choices shall be consecutive and enumerated.
* Mask only contains consecutive 1 bits set.
* Ensure IsIgnore and IsNo are never both set to true.
* Ensure there is one and only one IsNo choice set to true.
* Ensure there is one and only one IsIgnore choice set to true.
* Ensure that the abstain choice is 0.
* Ensure that the number of choices does not exceed the mask bits
permissible size.
* Ensure that choice bits match the mask bits.
* Ensure there are no duplicate choice ids.
* Ensure there are no duplicate vote ids.
Add a test where the expiration time is roughly at the half of the
voting window. We do that by spoofing the ExpireTime to be half of the
required RCI window. The synthetics use a second per block time stamp
so we simply set ExpireTime to RCI/2 seconds.
Modify threshold state to use the stake version that will be used in the
next block. That removes a full interval before voting can start and it
makes all voting intervals consistent.
Fixes#595
Requires #596
Make GetBlockHeaderVerboseResult and GetBlockVerboseResult return
Confirmations as -1 when we are dealing with an orphan block.
While here fix confirmations in the createTxRawResult call as well.
Every user of GetBlockHeaderVerboseResult, GetBlockVerboseResult and
TxRawResult MUST change the Confirmations field to int64!
The RPCs that are affected are getblock, getblockheader and
getrawtransaction.
The go compiler treats the math.MaxUint32 constant as an integer in the
error print which causes a compile error. This casts the constant to
avoid that thus allows the code to compile on 32-bit architectures.
This modifies all invocations of newBlockNode in the tests to use the
already existing zeroHash instance and nil for all unused fields versus
creating an empty object for them. This is more consistent with
existing code and avoids needlessly creating objects.
The functions that are used to keep stake version and vote versions
humming along are relatively expensive due to repeated chain walks.
This commit removes the most egregious sinners by memoizing the answer.
It should be noted that we can not memoize the walk to the prior
interval because that would require one to memoize all blocks up to the
prior interval. This is in practice not a big issue because relatively
new blockNodes are in memory. The real savings happen when a block does
not need to be loaded from disk.
Here are some figures from a quad core Xeon 2.66GHz.
stakeversion_test.go:930: running: shallow no cache with 20160 nodes
stakeversion_test.go:1000: run time (setup 0) 712.273µs
stakeversion_test.go:1000: run time (run 1) 576.898µs
stakeversion_test.go:1000: run time (run 2) 571.683µs
stakeversion_test.go:1000: run time (run 3) 571.424µs
stakeversion_test.go:1000: run time (run 4) 570.918µs
stakeversion_test.go:930: running: shallow cache with 20160 nodes
stakeversion_test.go:1000: run time (setup 0) 775.044µs memory cost: 116
stakeversion_test.go:1000: run time (run 1) 74.316µs memory cost: 116
stakeversion_test.go:1000: run time (run 2) 57.283µs memory cost: 116
stakeversion_test.go:1000: run time (run 3) 57.235µs memory cost: 116
stakeversion_test.go:1000: run time (run 4) 57.068µs memory cost: 116
stakeversion_test.go:930: running: deep no cache with 201600 nodes
stakeversion_test.go:1000: run time (setup 0) 700.987µs
stakeversion_test.go:1000: run time (run 1) 571.4µs
stakeversion_test.go:1000: run time (run 2) 569.362µs
stakeversion_test.go:1000: run time (run 3) 569.154µs
stakeversion_test.go:1000: run time (run 4) 569.319µs
stakeversion_test.go:930: running: deep cache with 201600 nodes
stakeversion_test.go:1000: run time (setup 0) 723.686µs memory cost: 116
stakeversion_test.go:1000: run time (run 1) 57.565µs memory cost: 116
stakeversion_test.go:1000: run time (run 2) 55.698µs memory cost: 116
stakeversion_test.go:1000: run time (run 3) 55.478µs memory cost: 116
stakeversion_test.go:1000: run time (run 4) 56.046µs memory cost: 116
This modifies the goclean.sh script that is executed on Travis to
only run the tests once.
While it is nice to see coverage reports in the log, unfortunately it
appears that both the -race and -cover flags can't be used together, and
the tests have grown in complexity such that they are starting to get
close to TravisCI time limits.