This updates all remaining cases of unwrapped errors in fmt.Errorf calls
to wrap the underlying errors with the %w format verb to ensure they
work nicely with errors.Is and errors.As.
Go 1.22 is introducing a change to the way the range statement works
that is not entirely backward compatible. In particular, the loop
variable is changing from one instance per loop to one instance per
iteration.
The existing semantics are well known and in order to ensure correct
behavior and avoid potential races that would otherwise result, the
current code typically opts for using ranges with an index and creating
a local that points into the array when the range variable needs to be
used as a pointer.
In addition, there are a few remaining cases that use the common
alternative approach of capturing the range variable through self
assignment.
Both approaches will work correctly when compiled with Go 1.22 as well
as older version of Go so long as the module versions are not bumped.
However, once the modules are updated to allow support of all features
introduced by go 1.22, the second approach of capturing the range
variable would no longer be needed and as a result would very likely
need to be removed to avoid vet/linter issues. Unfortunately, the
consequence of that change would mean building the code with older
versions of Go would start to produce incorrect code.
The first approach of using a range index that is predominantly used
throughout the code does not have that potential pitfall as it works
equally well for all of the aforementioned cases.
Thus, in order to avoid any potential issues before they ever even have
a chance to arise, this updates the few remaining instances of the
second approach to the first one or to otherwise rework the code to
avoid the need altogether.
This makes use of the github actions cache to save and restore the Go
test and module caches. This should result in faster CI runs since most
changes only affect a small number of tests.
It also updates the RPC integration tests to ensure the logs directory
is not in the source code dir so the go testing cache can be used.
Next, it renames the txscript module's data dir to testdata so go does
not treat it like a package.
Finally, it adds a script that stabilizes the timestamps on all files in
testdata directories when running the github action. This is necessary
because the go testing cache logic uses the timestamps of all input
files when determining whether or not a test needs to be rerun and
github clones a fresh repo on every run which causes the timestamps of
the test data to change.
This updates the txscript module dependencies, the copyright year in the
files modified since the previous release, and serves as a base for
txscript/v4.1.0.
The updated direct dependencies in this commit are as follows:
- github.com/dchest/siphash@v1.2.3
- github.com/decred/base58@v1.0.5
- github.com/decred/dcrd/chaincfg/chainhash@v1.0.4
- github.com/decred/dcrd/chaincfg@3.2.0
- github.com/decred/dcrd/crypto/blake256@v1.0.1
- github.com/decred/dcrd/crypto/ripemd160@v1.0.2
- github.com/decred/dcrd/dcrec@v1.0.1
- github.com/decred/dcrd/dcrec/edwards/v2@v2.0.3
- github.com/decred/dcrd/dcrec/secp256k1/v4@v4.2.0
- github.com/decred/dcrd/wire@v1.6.0
The updated indirect dependencies in this commit are as follows:
- github.com/agl/ed25519@v0.0.0-20170116200512-5312a6153412
- github.com/klauspost/cpuid/v2@v2.0.9
- lukechampine.com/blake3@v1.2.1
The full list of updated dependencies since the previous txscript/v4.0.0
release are the same as above.
Finally, all modules in the repository are tidied to ensure they are
updated to use the latest versions hoisted forward as a result.
The requireMinimal flag for MakeScriptNum was removed in
84b65d049b but the description was left
in the comment for MakeScriptNum. This removes that part of the docs.
Also expand on range error and fix code reference. In
d8306ee602, the error for out-of-range
changed from ErrNumberTooBig to ErrNumOutOfRange.
This modifies the entire repository to use the new formatting of doc
comments in the upcoming Go 1.19 release.
The primary motivating factors for this are:
- Builds check that files are formatted per gofmt and that will no
longer be true as of Go 1.19 without these changes
- Separating all the updates into a single commit ensures these
documentation only formatting changes do not clutter up diffs that
actually change code
For the most part, the changes are just the automated changes suggested
by the Go 1.19 version of gofmt, but there are also a few cases where
the comments were reworded a bit to play nicely with the new formatting
requirements.
For example, the new version of gofmt reformats and collapses nested
lists where as the existing version does not. Thus, instances of nested
lists have been changed to either eliminate them or use mixed markers
which produce expect results.
This bumps the go directive for all of the modules provided by the
repository to 1.17 which will allow the new module graph pruning and
lazy loading capabilities introduced in Go 1.17 to be used once the
updated modules are released.
This means that, as described by the documentation, the go.mod files for
each module now include a separate require block that includes all of
the indirect dependencies
Profiling allocations during an initial chain sync shows that a large
portion of the allocations due to the CHECKMULTISIG opcode are the
result of generating the list of public keys and signatures.
This eliminates those allocations as follows:
- Use slices into fixed-size stack-based backing arrays for the typical
number of public keys and signatures
- Make the slice of signature info contiguous instead of pointers which
not only eliminates the associated allocations, but also provides
better cache locality
This modifies the encoding logic for script numbers to support encoding
min int64s. This was previously not supported since the type was not
public and it is not possible to achieve a min int64 within the context
of the script system itself due to the strict limits it imposes.
However, now that script numbers are exported for external use and
callers are not bound by the aforementioned strictness, it should be
possible to encode the entire range for completeness.
In practice, callers should never realistically need to encode the value
since the purpose of the type is to create encoded numbers for scripts
and the value in question will be rejected upon any attempt to use it as
a number when verifying scripts given it is out of range.
This modifies DecodeAddressV0 to reject any attempts to decode strings
that are larger than the max possible size early since there is no
reason to waste time and memory doing the base 58 decode when it is
guaranteed to be invalid anyway.
It also adds an associated test to ensure proper functionality.
This modifies the MultiSigScriptV0 convenience func for creating a
multisig script to return an error if the caller improperly calls it
with a negative threshold.
This updates the txscript module dependencies, the copyright year in the
files modified since the previous release, and serves as a base for
txscript/v4.0.0.
The updated direct dependencies in this commit are as follows:
- github.com/decred/dcrd/chaincfg/chainhash@v1.0.3
- github.com/decred/dcrd/chaincfg/v3@v3.1.0
- github.com/decred/dcrd/dcrec/edwards/v2@v2.0.2
- github.com/decred/dcrd/dcrec/secp256k1/v4@v4.0.1
- github.com/decred/dcrd/wire@v1.5.0
- github.com/decred/slog@v1.2.0
The full list of updated direct dependencies since the previous
txscript/v3.0.0 release are as follows:
- github.com/dchest/siphash@v1.2.2
- github.com/decred/base58@v1.0.3
- github.com/decred/dcrd/chaincfg/chainhash@v1.0.3
- github.com/decred/dcrd/chaincfg/v3@v3.1.0
- github.com/decred/dcrd/crypto/blake256@v1.0.0
- github.com/decred/dcrd/dcrec/edwards/v2@v2.0.2
- github.com/decred/dcrd/dcrec/secp256k1/v4@v4.0.1
- github.com/decred/dcrd/wire@v1.5.0
- github.com/decred/slog@v1.2.0
The following direct dependencies are no longer required as compared to
the previous txscript/v3.0.0 release:
- github.com/decred/dcrd/dcrutil/v3
Finally, all modules in the repository that depend on txscript are
tidied to ensure they are updated to use the latest versions hoisted
forward as a result.
This adds support for directly extracting the script hash from standard
version 0 stake-tagged pay-to-script-hash scripts along with full test
coverage.
While all of this data can be extracted from each individual type, it
can be more convenient for callers who treat all script hashes as the
same entity which is the case for many applications.
This adds support for directly extracting the public key hash from
standard version 0 stake-tagged pay-to-pubkey-hash scripts along with
full test coverage.
While all of this data can be extracted from each individual type, it
can be more convenient for callers who treat all public key hashes as
the same entity which is the case for many applications.
This modifies the code to use the opcode definitions in txscript now
that the previous cyclic dependency no longer applies since txscript no
longer depends on stdaddr.
This removes ErrTooMuchNullData and its associated stringer test since
it is no longer used by anything in the repository.
This is part of a series of commits to remove all code related to
standard scripts from txscript.
This removes ErrTooManyRequiredSigs and its associated stringer test
since it is no longer used by anything in the repository.
This is part of a series of commits to remove all code related to
standard scripts from txscript.
This removes ErrNotMultisigScript and its associated stringer test since
it is no longer used by anything in the repository.
This is part of a series of commits to remove all code related to
standard scripts from txscript.
This removes ScriptClass and its associated tests since it is no longer
used by anything in the repository and is now available via
stdscript.ScriptType.
This is part of a series of commits to remove all code related to
standard scripts from txscript.
This removes MaxDataCarrierSize since it is no longer used by anything
in the repository and is now available via
stdscript.MaxDataCarrierSizeV0.
This is part of a series of commits to remove all code related to
standard scripts from txscript.
This removes isStandardAltSignatureType since it is no longer used by
anything in the package.
This is part of a series of commits to remove all code related to
standard scripts from txscript.
This removes extractPubKeyHashAltDetails since it is no longer used by
anything in the package.
This is part of a series of commits to remove all code related to
standard scripts from txscript.
This removes isPubKeyHashAltScript along with its benchmark since it is
no longer used by anything in the package.
This is part of a series of commits to remove all code related to
standard scripts from txscript.
This removes extractCompressedPubKey since it is no longer used by
anything in the package.
This is part of a series of commits to remove all code related to
standard scripts from txscript.
This removes extractUncompressedPubKey since it is no longer used by
anything in the package.
This is part of a series of commits to remove all code related to
standard scripts from txscript.
This removes extractPubKey since it is no longer used by anything in the
package.
This is part of a series of commits to remove all code related to
standard scripts from txscript.
This removes isPubKeyScript along with its benchmark since it is no
longer used by anything in the package.
This is part of a series of commits to remove all code related to
standard scripts from txscript.
This removes extractPubKeyAltDetails since it is no longer used by
anything in the package.
This is part of a series of commits to remove all code related to
standard scripts from txscript.
This removes isPubKeyAltScript along with its benchmark since it is no
longer used by anything in the package.
This is part of a series of commits to remove all code related to
standard scripts from txscript.
This removes extractPubKeyHash since it is no longer used by anything in
the package.
This is part of a series of commits to remove all code related to
standard scripts from txscript.
This removes isNullDataScript along with its benchmark since it is no
longer used by anything in the package.
This is part of a series of commits to remove all code related to
standard scripts from txscript.
This removes extractStakePubKeyHash since it is no longer used by
anything in the package.
This is part of a series of commits to remove all code related to
standard scripts from txscript.
This removes extractStakeScriptHash since it is no longer used by
anything in the package.
This is part of a series of commits to remove all code related to
standard scripts from txscript.
This removes isStakeSubmissionScript along with its benchmark since it
is no longer used by anything in the package.
This is part of a series of commits to remove all code related to
standard scripts from txscript.
This removes isStakeGenScript along with its benchmark since it is no
longer used by anything in the package.
This is part of a series of commits to remove all code related to
standard scripts from txscript.
This removes isStakeRevocationScript along with its benchmark since it
is no longer used by anything in the package.
This is part of a series of commits to remove all code related to
standard scripts from txscript.
This removes isPubKeyHashScript along with its benchmark since it is no
longer used by anything in the package.
This is part of a series of commits to remove all code related to
standard scripts from txscript.
This removes isStakeChangeScript along with its benchmark since it is no
longer used by anything in the package.
This is part of a series of commits to remove all code related to
standard scripts from txscript.
This removes extractMultisigScriptDetails since it is no longer used by
anything in the package.
This is part of a series of commits to remove all code related to
standard scripts from txscript.
This removes isTreasuryAddScript since it is no longer used by anything
in the package.
This is part of a series of commits to remove all code related to
standard scripts from txscript.
This removes pubKeyHashToAddrs since it is no longer used by anything in
the package.
This is part of a series of commits to remove all code related to
standard scripts from txscript.
This removes scriptHashToAddrs since it is no longer used by anything in
the package.
This is part of a series of commits to remove all code related to
standard scripts from txscript.
This removes ExtractPkScriptAddrs and its associated tests, benchmarks,
and example since it is no longer used by anything in the repository
and is now available via stdscript.ExtractAddrs.
This is part of a series of commits to remove all code related to
standard scripts from txscript.
This removes isMultisigScript since it is no longer used by anything in
the package.
This is part of a series of commits to remove all code related to
standard scripts from txscript.
This removes isTreasurySpendScript since it is no longer used by
anything in the package.
This is part of a series of commits to remove all code related to
standard scripts from txscript.