Commit Graph

139 Commits

Author SHA1 Message Date
David Hill
e26e71a9a2 multi: replace godoc.org with pkg.go.dev 2020-02-18 19:35:19 -06:00
Donald Adu-Poku
6a351fa2c3 multi: define wire error types.
This updates the wire error type by clearly
defining package errors and updating call sites.
2020-02-14 13:31:58 -06:00
David Hill
4971faff25 multi: remove whitespace 2019-11-21 18:31:30 -06:00
Dave Collins
4ad3f25ca6
wire: Prepare v1.3.0.
This updates the wire module dependencies and serves as a base for
wire/v1.3.0.

The updated direct dependencies in this commit are as follows:

- github.com/decred/dcrd/chaincfg/chainhash@v1.0.2

The full list of updated direct dependencies since the previous
wire/v1.2.0 release are as follows:

- github.com/decred/dcrd/chaincfg/chainhash@v1.0.2
2019-10-14 13:19:05 -05:00
Dave Collins
4b99cc99e8
wire: Implement getcfilterv2/cfilterv2 messages.
This implements new getcfilterv2 and cfilterv2 messages which are used
to request and deliver version 2 committed gcs filters along with their
associated header commitment inclusion proof.

The getcfilterv2 message requests a version 2 gcs filter and proof for a
given block hash.  The cfilterv2 message is sent in response with the
requested filter and proof.

It should be noted that since all header commitments require consensus
changes, the proof can only be used once a consensus vote passes and the
header actually commits to the filter.

Finally, it also bumps the minor default user agent version for the wire
package to account for the updates.
2019-10-12 12:06:00 -05:00
Dave Collins
3e2208f8c1
build: Replace TravisCI with CI via Github actions. 2019-09-20 19:59:04 -05:00
Aaron Campbell
8be96a8729 multi: Correct typos.
Correct typos found by reading code, ispell, and creative grepping.
2019-08-22 10:20:03 -05:00
Aaron Campbell
8497b9843b wire: Fix a few messageError string typos. 2019-08-17 01:11:40 -05:00
Aaron Campbell
03678bb754 multi: Correct typos.
Correct typos found by reading code and creative grepping.
2019-08-16 17:37:58 -05:00
Dave Collins
8354a310bc
main: Consume latest module minors and patches.
This updates the main module to use the latest available minor and patch
versions of all modules and reverts the recent change that incorrectly
removed all of the blake256 references from the various go.sum files.

The following required direct dependencies are bumped as follows:

- github.com/decred/dcrd/blockchain/stake@v1.2.1
- github.com/decred/dcrd/blockchain/stake/v2@v2.0.1
- github.com/decred/dcrd/certgen@v1.1.0
- github.com/decred/dcrd/chaincfg@v1.5.2
- github.com/decred/dcrd/chaincfg/chainhash@v1.0.2
- github.com/decred/dcrd/chaincfg/v2@v2.2.0
- github.com/decred/dcrd/dcrutil/v2@v2.0.0
- github.com/decred/dcrd/gcs@v1.1.0
- github.com/decred/dcrd/hdkeychain/v2@v2.0.1
- github.com/decred/dcrd/txscript/v2@v2.0.0
- github.com/decred/dcrwallet/rpc/jsonrpc/types@v1.2.0
2019-08-08 10:05:35 -05:00
Nicola Larosa
1149d54cb9 multi: Use crypto/blake256.
This updates the code to make use of the new crypto/blake256 module instead of
github.com/dchest/blake256.

* change the references in the chaincfg/chainhash and gcs modules
* update chaincfg/chainhash to use the new Sum256 API
* remove references to dchest/blake256 from all go.sum files
2019-08-07 18:54:55 -05:00
Donald Adu-Poku
3c6ff2852d wire: assert MaxMessagePayload limit in tests.
This adds an additional check to Msg tests ensuring their max
payload lengths do not exceed MaxMessagePayload.
2019-06-20 12:28:41 -05:00
David Hill
893aa30dce multi: Use https links where available. 2019-06-18 14:20:06 -05:00
Hamid
31c9417b39 wire: Add tests for MsgCFilter.
This adds standard tests for MsgCFilter to make sure the API
works correctly.
2019-06-08 01:10:40 -05:00
Hamid
9f0530837e wire: Rename extended errors to malformed errors.
This changes a test's name from ExtendedErrors to MalformedErrors
to makes it naming convention consistent with the other tests of
this type.
2019-06-07 13:51:46 -05:00
Hamid
6dd986f694 wire: Add tests for MsgCFHeaders.
This adds standard wire's tests for MsgCFHeaders to make sure the api
works correctly.
2019-05-22 04:06:06 -05:00
Hamid
cad4038d78 wire: Add tests for MsgGetCFHeaders.
This adds standard wire tests for MsgGetCFHeaders to make sure the API
works correctly.
2019-05-21 20:15:04 -05:00
David Hill
70c14042d8 multi: fix recent govet findings
add govet to linter tests.
2019-04-29 17:58:06 -05:00
Hamid
8e24235d7a wire: Add tests for MsgGetCFTypes.
This adds standard tests for MsgGetCFTypes to make sure the API
works correctly.
2019-03-28 11:09:24 -05:00
Hamid
bf2ae11be8 wire: Fix MsgCFTypes maximum payload length.
This commit fixes and improves MsgCFTypes maximum payload length.
The counter of FilterType in MsgCFTypes is varInt which for 256
FilterType it has 3 bytes size.
2019-03-25 17:01:20 -05:00
Hamid
9c6dfab8da wire: Accurate calculations of maximum length.
This makes messages maximum payload length calculations accurate.
In wire messages which contain arrays, the array items counter is
variable integer (varInt). Since we limit items count in the
arrays, the maximum size of these counters is limited, this causes
these counters encoded size in all cases be lower than maximum
integer encoded size (MaxVarIntPayload). This commit makes this
calculations accurate and makes them consistent with the rest of
the codebase.
2019-03-25 16:36:32 -05:00
Hamid
9ae4670a7e wire: Add tests for MsgGetCFilter.
This adds standard wire tests for MsgGetCFilter. Summery of all
changes:
- Add standard wire test for MsgGetCFilter.
- Add an extended error checking for checking malformed encoded data
	returns correct errors. For this Message type what has been done
	is similar to what WireErrors is doing but it has been added in a
	different test to be explicit and for documentation purpose.
2019-03-21 15:43:23 -05:00
Hamid
f41b9faeda wire: Add tests for BlockHeader (From)Bytes.
Checking Bytes() and FromBytes() of BlockHeader works correctly.
2019-03-18 11:42:42 -05:00
Dave Collins
0f50fd5f8c
multi: Add go 1.11 directive to all modules.
This adds the go 1.11 directive to all of the modules in order to
clearly mark they build and work with that version.  Go 1.12 modified
the tools such that tidy will automatically add the new version to
modules that do not already have a directive and that would prevent
builds on Go 1.11 through Go 1.11.3 which is not desirable.
2019-03-18 02:02:35 -05:00
Hamid
bbada7521a wire: Fix maximum payload length of MsgAddr.
This fixes the calculation of the maximum payload size of MsgAddr.
The number of address in encoded MsgAddr is VarInt which its size for
the maximum size of allowed address is lower than MaxVarIntPayload.
2019-03-10 12:41:28 -05:00
Hamid
adc41abf59 wire: Add tests for MsgCFTypes
This adds standard wire tests for MsgCFTypes. Things done in these
commit:
- Add standard wire test for MsgCFTypes
- Fix a potential bug at BtcEncode: return an error if the number
	of filter types exceed the maximum number of supported filter
	types (256)
- Add an extended error checking for checking malformed encoded
	data return correct errors.
2019-02-16 19:07:08 -06:00
David Hill
85443cafa9 multi: cleanup linter warnings 2019-02-13 08:38:25 -05:00
Dave Collins
e052b9cbf2
multi: Remove non-root module replacements.
This modifies all of the modules, with the exception of the root module,
to remove all replacement directives from their go.mod files and update
the requirements and module sums accordingly.

While it is nice to be able to build and test directly from each module
directory and have it pull in the latest untagged changes when
developing, having all of the overrides in each module makes it
infeasible to use the module tools to help maintain the modules and thus
makes it quite difficult to ensure they are all independently accurate
for external consumers.

By maintaining all of the overrides in the root module and invoking all
builds and tests from it, the overrides will apply to ensure the latest
code is being built and tested.

This also modifies the tests script used with in CI to run all of the
tests from the root module accordingly.
2019-02-08 18:01:43 -06:00
Dave Collins
47ade78c1a
multi: Resurrect regression network.
This resurrects the regression test network that was removed before
initial launch although it really should not have been.  The simulation
test network and the regression test network do not serve the same
purpose.  Specifically, the regression test network is intended for unit
tests, RPC server tests, and consensus tests.  On the other hand, the
simulation test network is intended for private use within a group of
individuals doing simulation testing and full integration tests between
different applications such as wallets, voting service providers, mining
pools, block explorers, and other services that build on Decred.

Keeping the concerns separate will allow the simulation test network to
be modified in ways such as activating consensus changes that have been
successfully voted into mainnet without also needing to vote them in on
the simulation test network while still preserving the ability for the
unit tests to properly test the voting semantics and handling to help
prevent regressions.

In addition to resurrecting the regression test network, this also fully
fleshes out new values for the various addresses prefixes (Rk, Rs, Re,
etc), HD key prefixes (rprv, rpub), and treasury multisig details.

As a part of resurrecting the network, a new CLI flag `--regnet` is
added to allow the RPC test harness connect to a running instance, the
areas of the code which involve votes have been modified to allow the
votes to apply to the new network, and tests have been added to the
relevant modules.

This bumps the affected module versions as follows:

- github.com/decred/dcrd/wire@v1.2.0
- github.com/decred/dcrd/chaincfg@v1.2.0
- github.com/decred/dcrd/dcrutil@v1.2.0
- github.com/decred/dcrd/hdkeychain@v1.1.1

The blockchain module is also affected, but since its version has
already been bumped since the last release tag, it is not bumped again.

Finally, this does not include switching unit tests or the RPC test
harness over the new network since that will be done in a separate
commit.
2018-10-09 18:52:13 -05:00
Dave Collins
ca3f5bd39b multi: Make changes suggested by Go 1.11 gofmt -s. 2018-08-23 12:52:07 -05:00
Dave Collins
8fda21512f
multi: Remove testnet version 2 defs and refs.
This removes all definitions and references to the no longer available
testnet2 network.
2018-08-08 08:10:22 -05:00
Dave Collins
9e1579771b
multi: Reset testnet and bump to version 3.
This adds a new testnet3 network with new genesis block, block one
ledger, treasury address, and network magic.

All consensus rules that were voted in by testnet2 are automatically
active on the new testnet3 without having to vote them in again.
Consequently, there are no consensus vote agendas defined for it.
2018-08-08 08:09:32 -05:00
Dave Collins
295179fc0d
build: Refine build module support.
This further refines the modules to add the following new modules
instead of depending on the entire dcrd module:

- github.com/decred/dcrd/dcrjson@v1.0.0
- github.com/decred/dcrd/blockchain@v1.0.0
- github.com/decred/dcrd/blockchain/stake@v1.0.0
- github.com/decred/dcrd/gcs@v1.0.0
- github.com/decred/dcrd/mining@v1.0.0
- github.com/decred/dcrd/mempool@v1.0.0
- github.com/decred/dcrd/peer@v1.0.0
- github.com/decred/dcrd/rpcclient@v1.0.0

Also, it ensures modules that rely on other modules within the repo are
provided replacements to the latest repo code to ensure builds against
master and continuous integration use the latest code.

- github.com/decred/dcrd/addrmgr
- github.com/decred/dcrd/blockchain
- github.com/decred/dcrd/blockchain/stake
- github.com/decred/dcrd/chaincfg
- github.com/decred/dcrd/connmgr
- github.com/decred/dcrd/database
- github.com/decred/dcrd/dcrec/secp256k1
- github.com/decred/dcrd/dcrjson
- github.com/decred/dcrd/dcrutil
- github.com/decred/dcrd/gcs
- github.com/decred/dcrd/hdkeychain
- github.com/decred/dcrd/mempool
- github.com/decred/dcrd/mining
- github.com/decred/dcrd/peer
- github.com/decred/dcrd/rpcclient
- github.com/decred/dcrd/txscript
- github.com/decred/dcrd/wire
2018-08-05 20:45:45 -05:00
Dave Collins
95f450aa13
wire: Update go build module support.
This updates the wire build module for the changes in the upcoming
go1.11 release and to depend on the latest chainhash module version.
2018-07-20 17:49:56 -05:00
Donald Adu-Poku
b105a9ef49 multi: add valueIn parameter to wire.NewTxIn.
This adds the valueIn parameter to wire.NewTxIn. Call sites and associated tests have also been updated.
2018-06-15 19:13:41 -05:00
Dave Collins
4ee21d807a
wire: Refine vgo deps.
Now that chainhash has been defined, update the wire module to only
depend on it instead of the entire dcrd module.
2018-05-25 17:06:49 -05:00
Dave Collins
45e313e6d2
multi: Define vgo modules.
This adds module support for the versioned go toolchain.  In particular,
the following packages are defined as modules:

* addrmgr
* blockchain
* certgen
* chaincfg
* connmgr
* database
* dcrjson
* dcrutil
* gcs
* hdkeychain
* mempool
* mining
* peer
* rpcclient
* txscript
* wire

It does not update the travis build environment or README since it is
experimental at this point.
2018-05-25 15:38:16 -05:00
David Hill
5a4f367b66 multi: Remove everything to do about bloom filters. 2018-05-01 11:43:32 -05:00
Dave Collins
b3ce2ad2ad
wire: Remove TxSerializeWitnessSigning.
This removes the TxSerializeWitnessSigning serialization type since
it is no longer required due to implementing it directly in the
signature hash calculation function.  It also removes all related tests.

Although this is technically a change to the wire protocol, the protocol
version is not being bumped because nothing ever sends messages using
this serialization type as it only applied for calculating signature
hashes and really should not have ever been in the wire package to begin
with.
2018-05-01 08:52:18 -05:00
Dave Collins
467b154b41
wire: Remove TxSerializeWitnessValueSigning.
This removes the TxSerializeWitnessValueSigning serialization type since
it is no longer required due to the removal of the SigHashAllValue
signature hash type.  It also removes all related tests.

Although this is technically a change to the wire protocol, the protocol
version is not being bumped because nothing ever sends messages using
this serialization type as it only applied for calculating signature
hashes and really should not have ever been in the wire package to begin
with.
2018-04-30 10:21:19 -05:00
Josh Rickmar
71500c80f2 multi: Add initial committed filter (CF) support
This change begins the work of bringing committed filters to the
network consensus daemon.  Committed filters are designed to enable
light wallets without many of the privacy issues associated with
server-side bloom filtering.

The new gcs package provides the primitives for creating and matching
against Golomb-coded sets (GCS) filters while the blockcf package
provides creation of filters and filter entries for data structures
found in blocks.

The wire package has been updated to define a new protocol version and
service flag for advertising CF support and includes types for the
following new messages: cfheaders, cfilter, cftypes, getcfheaders,
getcfilter, getcftypes.  The peer package and server implementation
have been updated to include support for the new protocol version and
messages.

Filters are created using a collision probability of 2^-20 and are
saved to a new optional database index when running with committed
filter support enabled (the default).  At first startup, if support is
not disabled, the index will be created and populated with filters and
filter headers for all preexisting blocks, and new filters will be
recorded for processed blocks.

Multiple filter types are supported.  The regular filter commits to
output scripts and previous outpoints that any non-voting wallet will
require access to.  Scripts and previous outpoints that can only be
spent by votes and revocations are not committed to the filter.  The
extended filter is a supplementary filter which commits to all
transaction hashes and script data pushes from the input scripts of
non-coinbase regular and ticket purchase transactions.  Creating these
filters is based on the algorithm defined by BIP0158 but is modified
to only commit "regular" data in stake transactions to prevent
committed filters from being used to create SPV voting wallets.
2018-03-30 13:52:12 -04:00
David Hill
8c0d28864c multi: remove MsgAlert
It is currently unused and does not fit into decentralization.
2018-03-29 14:47:55 -04:00
Dave Collins
74d130057a
multi: Rename BIP0111Version to NodeBloomVersion.
This renames the BIP0111Version constant to NodeBloomVersion to better
describe its purpose.
2018-03-02 22:29:14 -06:00
Markus Richter
1e42b8524d multi: Properly capitalize Decred.
Decred is inconsistencly capitalized in the code base,
change all occurences of decred to Decred.
2018-03-01 17:41:35 -06:00
David Hill
5fc31ca578 multi: fix misspell linter warnings 2018-02-18 12:26:52 -06:00
David Hill
dce7e3f161 multi: various cleanups 2018-02-02 14:18:41 -06:00
David Hill
b13f5dfbda travis: add ineffassign linter 2017-12-01 09:14:04 -05:00
David Hill
20686cd775 travis: add gosimple linter 2017-11-20 18:49:55 -06:00
Dave Collins
42175088b6
blockchain: Implement enforced relative seq locks.
This repurposes the sequence number of version 2 transaction inputs to
provide consensus-enforced relative lock-time semantics so that a
transaction can require inputs to have a specified relative age before
they are allowed to be included in a block.  Each relative time lock can
either specify a relative number of seconds (with a granularity of 512
seconds and a maximum value of 33,553,920) or a specific number of
blocks (max 65535).

The number of seconds is calculated relative to the past median time of
the block before the one that contains the referenced output.  This is
done because, due to other changes that will also be included in the
same agenda vote, said time will become the earliest possible time the
block that contains the referenced output could have been (technically
it will be one second after that, but that complexity is ignored since
there is already a granularity involved anyways).

It is also possible to disable the behavior by setting bit 31 of the
sequence number (which all transactions currently do by default since
they are set to the max).

In order for the transaction to be permitted to the mempool, relayed,
considered for inclusion into block templates, and allowed into a block,
the specified relative time locks for all of its inputs must be
satisfied.

This only implements the required logic and tests to enforce the new
behavior.  Code to enforce the new behavior when considering candidate
transactions for acceptance to the mempool, relaying, and inclusion into
block templates will be added in a separate commit.

A consensus vote is required in order to reject blocks which contain
transactions that violate the new rules at a consensus level.  Code to
selectively enable consensus enforcement based on the result of an
agenda vote will be added in a separate commit.

In order to accomplish this new behavior, the concept of a sequence lock
is introduced which allows the minimum possible time and height at which
a transaction can be included into a block to be calculated from all
inputs with non-disabled relative time locks, and functions to calculate
and evaluate the sequence lock are added.

The following is an overview of the changes:

- Introduce a new struct named SequenceLock to represent the previously
  described sequence lock
- Define new constants related to sequence numbers named
  SequenceLockTimeDisabled, SequenceLockTimeIsSeconds,
  SequenceLockTimeMask, and SequenceLockTimeGranularity
- Add a new function named calcSequenceLock to calculate the sequence
  lock for a given transaction
- Add a new function named SequenceLockActive to determine if a given
  sequence lock is satisfied for a given block height and past median
  time
- Add a convenience function named LockTimeToSequence which can be used
  to convert a relative lock time to a sequence number
- Add a comprehensive set of tests for all of the new funcs
2017-09-21 15:58:36 -05:00
Dave Collins
bd78208c37
txscript: Revert upstream CSV merge.
This reverts the changes related to the CheckSequenceVerify opcode that
were merged from upstream since additional changes are needed and it's
much cleaner to implement all of code related to the sequence locks in
the same PR which will be referenced by the DCP as opposed to being
split up in multiple.
2017-09-21 11:17:58 -05:00