Commit Graph

5730 Commits

Author SHA1 Message Date
Ryan Staudt
d4d7daa07c stake: Fix CheckSSRtx function comment.
This updates the CheckSSRtx function comment to refer to the correct
output indexes from the input ticket transaction.  It also updates the
comment to refer to SSRtx outputs rather than SSGen outputs.
2021-06-14 12:04:55 -05:00
Ryan Staudt
a89f1847bc stake: Fix CheckSSGenVotes function comment.
This updates the CheckSSGenVotes function comment to refer to the
correct output indexes from the input ticket transaction.
2021-06-14 12:04:55 -05:00
Ryan Staudt
ca67a293f4 stake: Fix MaxOutputsPerSSRtx comment. 2021-06-14 12:04:55 -05:00
Ryan Staudt
d8b7bb0cb0 blockchain: Fix comment formatting in generator. 2021-06-14 12:04:55 -05:00
Ryan Staudt
81ec47f2a2 rpcserver: Fix createrawssrtx comments.
This updates a couple of comments within createrawssrtx to properly
refer to SSRtx outputs/transactions rather than SSGen.
2021-06-14 12:04:55 -05:00
Ryan Staudt
79b6fbc427 stake: Comment on max SSGen outputs with treasury.
This adds a comment to MaxOutputsPerSSGen indicating that if the
treasury agenda is active, an OP_RETURN TV (treasury vote) output is
additionally included in the last position when voting on a treasury
spend.

The MaxOutputsPerSSGen value does NOT account for this output, and
should technically be increased by 1, but since the treasury agenda is
already active this cannot be updated without a consensus vote.
2021-06-14 12:04:38 -05:00
Dave Collins
d4084ec0e0
gcs: No standardness code in consensus.
This modifies the version 2 block filters in gcs to avoid using
standardness code since they are part of consensus code through header
commitments and therefore must not change even though the policy
regarding standardness can change.

It accomplishes the change by making use of the consensus-specific
script identification methods available via the stake package.
2021-06-14 11:58:11 -05:00
Dave Collins
87c9ccfb5d
blockchain: No standardness code in consensus.
This modifies the treasury code in blockchain which enforces the
treasury generation spending maturity to avoid using standardness code
since it is consensus level code which means it must not change even
though the policy regarding standardness can change.
2021-06-12 08:56:50 -05:00
Dave Collins
c69eb0a58e
stake: Add is treasury gen script.
This adds a method to stake which allow treasury generation scripts that
are enforced by consensus to be identified via a consensus-specific
method versus relying on the policy-based variant that is subject to
change.

This is consistent with the other consensus-enforced stake-related
scripts exported from the package.
2021-06-10 15:26:01 -05:00
Dave Collins
35a99aff86
blockchain: Remove unneeded OP_TADD maturity check.
This removes the unnecessary OP_TADD coinbase maturity check because
OP_TADD is not a spendable utxo and therefore it can never have a
maturity applied to it.  Recall that treasurybase and treasury add stake
transactions are the only place an OP_TADD is valid and in both cases
they result in increasing the balance of the treasury account and are
never directly spendable.
2021-06-10 15:21:16 -05:00
Dave Collins
2e3d5309c8
stake: Do not use standardness code in consensus.
This modifies the treasury code in stake to avoid using standardness
code since it is consensus level code which mean it must not change even
though the policy regarding standardness can change.

The consensus-specific methods are all already available in the stake
package, so the code is merely updated to use them instead.

An overview of the changes follows:

- Introduce an exported constant for the max data carrier size allowed
  in stake transactions set to match the current standardness value
  since that is now part of consensus for them
- Modify the calls to txscript.GetScriptClass used for determining null
  data scripts to use consensus-specific IsNullDataScript method
- Use the consensus-specific methods for the following:
  - IsStakeChangeScript
  - isPubKeyHashScript
  - isScriptHashScript
2021-06-10 15:16:23 -05:00
Dave Collins
742ba9ad1b
blockchain: Use scripts in tickets address query.
This modifies the TicketsWithAddress query method in blockchain to
accept the more specific stdaddr.StakeAddress since only stake-capable
addresses can be used in tickets and modifies the logic to compare the
expected voting rights script and associated script version directly
instead of extracting and comparing encoded addresses.  It also updates
the callers and plumbing in rpcserver accordingly as well as adds a test
for the new non-stake address error in the RPC handler.

Not only is this approach more efficient, it also removes the reliance
on address extraction which in turn removes the need for the flag which
specifies whether or not the treasury is active.
2021-06-09 00:29:08 -05:00
Dave Collins
62950c2b8b
stdscript: Add README.md. 2021-06-08 12:20:55 -05:00
Dave Collins
ad89f3d26d
stdscript: Add example of script hash extract.
This adds an example for extracting the script hash from a
pay-to-script-hash script.

This part of a series of commits to fully implement the stdscript
package.
2021-06-08 12:20:55 -05:00
Dave Collins
0e468b838d
stdscript: Add example for p2pkh extract.
This adds an example for extracting the public key hash from a
p2pkh-ecdsa-secp256k1 script.

This part of a series of commits to fully implement the stdscript
package.
2021-06-08 12:20:54 -05:00
Dave Collins
7b0e48e250
stdscript: Add example for determining script type.
This adds an example for determining the script type of a public key
script in terms of standardness.

This part of a series of commits to fully implement the stdscript
package.
2021-06-08 12:20:54 -05:00
Dave Collins
5da74863ff
stdscript: Add v0 atomic swap redeem benchmark.
BenchmarkExtractAtomicSwapDataPushes
------------------------------------
v0_complex_not_atomic_swap    15944958   76.34 ns/op   0 B/op    0 allocs/op
v0_normal_valid_atomic_swap    3660967   335.9 ns/op   96 B/op   1 allocs/op

This part of a series of commits to fully implement the stdscript
package.
2021-06-08 12:20:54 -05:00
Dave Collins
a52b5aec90
stdscript: Add v0 atomic swap redeem support.
This adds support for identifying if a redeem script is a version 0
atomic swap redeem script for an original pay-to-script-hash script as a
convenience method for consumers of the package.

Note that this is different than most other methods in the package in
that it applies to the redeem script as opposed to the public key script
and consequently there is no new script type introduced nor does the
overall script determination detect it.  This is the case because a
redeem script is the final push of a signature script that is itself a
redemption of a pay-to-script-hash script.

Full test coverage is included.

This is part of a series of commits to fully implement the stdscript
package.
2021-06-08 12:20:53 -05:00
Dave Collins
bf5e5b4040
stdscript: Add ecdsa multisig creation script.
This adds a convenience method to create a standard version 0 ecdsa
multisignature redemption script that requires a threshold of signatures
from a set of public keys.

Full test coverage is included.

This is part of a series of commits to fully implement the stdscript
package.
2021-06-08 12:20:53 -05:00
Dave Collins
2b099ba339
stdscript: Add determine script type benchmark.
BenchmarkDetermineScriptType
----------------------------
v0_complex_non_standard                  23581336   49.37 ns/op   0 allocs/op
v0_p2pk-ecdsa-secp256k1_uncomp          168650203   7.077 ns/op   0 allocs/op
v0_p2pk-ed25519                          85811743   14.22 ns/op   0 allocs/op
v0_p2pk-schnorr-secp256k1_comp_even      66687412   17.95 ns/op   0 allocs/op
v0_p2pkh-ecdsa-secp256k1                 79932855   15.51 ns/op   0 allocs/op
v0_p2pkh-ed25519                         49981048   24.53 ns/op   0 allocs/op
v0_p2pkh-schnorr-secp256k1               37498006   32.34 ns/op   0 allocs/op
v0_p2sh                                  52141040   23.39 ns/op   0 allocs/op
v0_multisig_1-of-1_compressed_pubkey     13393005   88.78 ns/op   0 allocs/op
v0_nulldata_no_data_push                 40623846   30.05 ns/op   0 allocs/op
v0_stake_sub_p2pkh-ecdsa-secp256k1       35731618   35.09 ns/op   0 allocs/op
v0_stake_sub_p2sh                        32320881   37.48 ns/op   0 allocs/op
v0_stake_gen_p2pkh-ecdsa-secp256k1       31518481   37.78 ns/op   0 allocs/op
v0_stake_gen_p2sh                        29044929   41.45 ns/op   0 allocs/op
v0_stake_revoke_p2pkh-ecdsa-secp256k1    26891238   40.93 ns/op   0 allocs/op
v0_stake_revoke_p2sh                     25999124   46.65 ns/op   0 allocs/op
v0_stake_change_p2pkh-ecdsa-secp256k1    27856704   44.25 ns/op   0 allocs/op
v0_stake_change_p2sh                     25236273   47.53 ns/op   0 allocs/op
v0_treasury_add                          28225464   42.33 ns/op   0 allocs/op
v0_treasury_gen_p2pkh-ecdsa-secp256k1    22417670   53.44 ns/op   0 allocs/op
v0_treasury_gen_p2sh                     23529964   52.03 ns/op   0 allocs/op

This is part of a series of commits to fully implement the stdscript
package.
2021-06-08 12:20:52 -05:00
Dave Collins
e31b426a2d
stdscript: Add v0 treasury gen p2sh benchmark.
BenchmarkIsTreasuryGenScriptHashScript
--------------------------------------
v0_complex_non_standard       814816624   1.310 ns/op   0 allocs/op
v0_treasury_generation_p2sh   520297904   2.274 ns/op   0 allocs/op

This is part of a series of commits to fully implement the stdscript
package.
2021-06-08 12:20:52 -05:00
Dave Collins
b058f88437
stdscript: Add v0 treasury gen p2sh support.
This adds support for detecting version 0 treasury generation
pay-to-script-hash scripts as standard and extracting the associated
script hash.

Full test coverage is included.

This is part of a series of commits to fully implement the stdscript
package.
2021-06-08 12:20:52 -05:00
Dave Collins
136f5590e7
stdscript: Add v0 treasury gen p2pkh benchmark.
BenchmarkIsTreasuryGenPubKeyHashScript
--------------------------------------
v0_complex_non_standard                 317927872   3.843 ns/op   0 allocs/op
v0_treasury_gen_p2pkh-ecdsa-secp256k1   225968358   5.261 ns/op   0 allocs/op

This is part of a series of commits to fully implement the stdscript
package.
2021-06-08 12:20:51 -05:00
Dave Collins
6f37107af4
stdscript: Add v0 treasury gen p2pkh support.
This adds support for detecting version 0 treasury generation
pay-to-pubkey-hash scripts as standard and extracting the associated
public key hash.

Full test coverage is included.

This is part of a series of commits to fully implement the stdscript
package.
2021-06-08 12:20:51 -05:00
Dave Collins
9ba1fc6bd4
stdscript: Add v0 treasury add benchmark.
BenchmarkIsTreasuryAddScript
----------------------------
v0_complex_non_standard   905938653     1.328 ns/op   0 allocs/op
v0_treasury_add           1000000000   0.9594 ns/op   0 allocs/op

This is part of a series of commits to fully implement the stdscript
package.
2021-06-08 12:20:50 -05:00
Dave Collins
73f13e20e8
stdscript: Add v0 treasury add support.
This adds support for detecting version 0 treasury add scripts as
standard.

Full test coverage is included.

This is part of a series of commits to fully implement the stdscript
package.
2021-06-08 12:20:50 -05:00
Dave Collins
96a2bc60f6
stdscript: Add v0 stake change p2sh benchmark.
BenchmarkIsStakeChangeScriptHash
--------------------------------
v0_complex_non_standard   688796947   1.626 ns/op   0 allocs/op
v0_stake_change_p2sh      503956689   2.282 ns/op   0 allocs/op

This is part of a series of commits to fully implement the stdscript
package.
2021-06-08 12:20:50 -05:00
Dave Collins
3e10162c52
stdscript: Add v0 stake change p2sh support.
This adds support for detecting version 0 stake change
pay-to-script-hash scripts as standard and extracting the associated
script hash.

Full test coverage is included.

This is part of a series of commits to fully implement the stdscript
package.
2021-06-08 12:20:49 -05:00
Dave Collins
2a81da3a2f
stdscript: Add v0 stake change p2pkh benchmark.
BenchmarkIsStakeChangePubKeyHash
--------------------------------
v0_complex_non_standard                 311063840   3.794 ns/op   0 allocs/op
v0_stake_change_p2pkh-ecdsa-secp256k1   228116065   5.355 ns/op   0 allocs/op

This is part of a series of commits to fully implement the stdscript
package.
2021-06-08 12:20:49 -05:00
Dave Collins
124f50469e
stdscript: Add v0 stake change p2pkh support.
This adds support for detecting version 0 stake change
pay-to-pubkey-hash scripts as standard and extracting the associated
public key hash.

Full test coverage is included.

This is part of a series of commits to fully implement the stdscript
package.
2021-06-08 12:20:48 -05:00
Dave Collins
ff69455469
stdscript: Add v0 stake revoke p2sh benchmark.
BenchmarkIsStakeRevocationScriptHashScript
------------------------------------------
v0_complex_non_standard   725635868   1.631 ns/op   0 allocs/op
v0_stake_revoke_p2sh      522431919   2.571 ns/op   0 allocs/op

This is part of a series of commits to fully implement the stdscript
package.
2021-06-08 12:20:48 -05:00
Dave Collins
6710289098
stdscript: Add v0 stake revoke p2sh support.
This adds support for detecting version 0 stake revocation
pay-to-script-hash scripts as standard and extracting the associated
script hash.

Full test coverage is included.

This is part of a series of commits to fully implement the stdscript
package.
2021-06-08 12:20:48 -05:00
Dave Collins
8c31132393
stdscript: Add v0 stake revoke p2pkh benchmark.
BenchmarkIsStakeRevocationPubKeyHashScript
------------------------------------------
v0_complex_non_standard                 311770504   3.842 ns/op   0 allocs/op
v0_stake_revoke_p2pkh-ecdsa-secp256k1   228088618   5.316 ns/op   0 allocs/op

This is part of a series of commits to fully implement the stdscript
package.
2021-06-08 12:20:47 -05:00
Dave Collins
6232d0c888
stdscript: Add v0 stake revoke p2pkh support.
This adds support for detecting version 0 stake revocation
pay-to-pubkey-hash scripts as standard and extracting the associated
public key hash.

Full test coverage is included.

This is part of a series of commits to fully implement the stdscript
package.
2021-06-08 12:20:47 -05:00
Dave Collins
783234e288
stdscript: Add v0 stake gen p2sh benchmark.
BenchmarkIsStakeGenScriptHashScript
-----------------------------------
v0_complex_non_standard   748967828   1.612 ns/op   0 allocs/op
v0_stake_gen_p2sh         536599674   2.234 ns/op   0 allocs/op

This is part of a series of commits to fully implement the stdscript
package.
2021-06-08 12:20:46 -05:00
Dave Collins
436b5c4991
stdscript: Add v0 stake gen p2sh support.
This adds support for detecting version 0 stake generation
pay-to-script-hash scripts as standard and extracting the associated
script hash.

Full test coverage is included.

This is part of a series of commits to fully implement the stdscript
package.
2021-06-08 12:20:46 -05:00
Dave Collins
c3239bcaaf
stdscript: Add v0 stake gen p2pkh benchmark.
BenchmarkIsStakeGenPubKeyHashScript
-----------------------------------
v0_complex_non_standard              311106744   3.842 ns/op   0 allocs/op
v0_stake_gen_p2pkh-ecdsa-secp256k1   217513142   5.305 ns/op   0 allocs/op

This is part of a series of commits to fully implement the stdscript
package.
2021-06-08 12:20:45 -05:00
Dave Collins
4fbd4a5012
stdscript: Add v0 stake gen p2pkh support.
This adds support for detecting version 0 stake generation
pay-to-pubkey-hash scripts as standard and extracting the associated
public key hash.

Full test coverage is included.

This is part of a series of commits to fully implement the stdscript
package.
2021-06-08 12:20:45 -05:00
Dave Collins
b73452be36
stdscript: Add v0 stake sub p2sh benchmark.
BenchmarkIsStakeSubmissionScriptHashScript
------------------------------------------
v0_complex_non_standard    930421526   1.284 ns/op   0 allocs/op
v0_stake_submission_p2sh   529045244   2.273 ns/op   0 allocs/op

This is part of a series of commits to fully implement the stdscript
package.
2021-06-08 12:20:45 -05:00
Dave Collins
02bcf8414f
stdscript: Add v0 stake sub p2sh support.
This adds support for detecting version 0 stake submission
pay-to-script-hash scripts as standard and extracting the associated
script hash.

Full test coverage is included.

This is part of a series of commits to fully implement the stdscript
package.
2021-06-08 12:20:44 -05:00
Dave Collins
3ea8aa854b
stdscript: Add v0 stake sub p2pkh benchmark.
BenchmarkIsStakeSubmissionPubKeyHashScript
------------------------------------------
v0_complex_non_standard              312435804   3.828 ns/op   0 allocs/op
v0_stake_sub_p2pkh-ecdsa-secp256k1   220546760   5.301 ns/op   0 allocs/op

This is part of a series of commits to fully implement the stdscript
package.
2021-06-08 12:20:44 -05:00
Dave Collins
08e2d88e8a
stdscript: Add v0 stake sub p2pkh support.
This adds support for detecting version 0 stake submission
pay-to-pubkey-hash scripts as standard and extracting the associated
public key hash.

Full test coverage is included.

This is part of a series of commits to fully implement the stdscript
package.
2021-06-08 12:20:43 -05:00
Dave Collins
bbaec90366
stdscript: Add v0 nulldata benchmark.
BenchmarkIsNullDataScript
-------------------------
v0_complex_non_standard          279362058   4.306 ns/op   0 allocs/op
v0_nulldata_no_data_push         276928082   4.325 ns/op   0 allocs/op
v0_nulldata_single_zero_push     40513850    29.47 ns/op   0 allocs/op
v0_nulldata_small_int_push       39842752    29.65 ns/op   0 allocs/op
v0_nulldata_max_small_int_push   36889138    29.82 ns/op   0 allocs/op
v0_nulldata_small_data_push      40597321    28.86 ns/op   0 allocs/op
v0_nulldata_60-byte_push         41307235    28.68 ns/op   0 allocs/op
v0_nulldata_max_standard_push    36347774    32.41 ns/op   0 allocs/op

This is part of a series of commits to fully implement the stdscript
package.
2021-06-08 12:20:43 -05:00
Dave Collins
a6d266d0b9
stdscript: Add v0 nulldata support.
This adds support for detecting version 0 nulldata scripts as standard.

It should be noted that this code includes a change in the semantics as
compared to the existing code.  In particular, the existing code detects
and treats any type of data push up to the maximum allowed length,
including those that are not canonical, as standard per policy, whereas
this new code further restricts the standardness policy to only treat
nulldata scripts with canonical data pushes up to the maximum allowed
length as standard since they occupy less space on chain and there is
really no good reason for using non-canonical pushes anyway.  In
practice, all known software already only creates canonical pushes and
has since launch.

This does not affect consensus in any way since consensus enforces its
own code related to the associated opcode as required.  Further,
nulldata scripts are unspendable by consensus, so this is purely a
policy change.

Full test coverage is included.

This is part of a series of commits to fully implement the stdscript
package.
2021-06-08 12:20:43 -05:00
Dave Collins
5c01d86f38
stdscript: Add extract v0 multisig redeem benchmark.
BenchmarkMultiSigRedeemScriptFromScriptSigV0
--------------------------------------------
v0_multisig_1-of-1_redeem_script    22222550   51.36 ns/op   0 allocs/op
v0_multisig_1-of-2_redeem_script    27158536   42.95 ns/op   0 allocs/op

This is part of a series of commits to fully implement the stdscript
package.
2021-06-08 12:20:42 -05:00
Dave Collins
aec1f34e9e
stdscript: Add v0 ecdsa multisig redeem benchmark.
BenchmarkIsMultiSigSigScript
----------------------------
v0_complex_non_standard     276108408   4.344 ns/op   0 allocs/op
v0_multisig_1-of-1_redeem    11796938   102.6 ns/op   0 allocs/op
v0_multisig_1-of-2_redeem    10727167   111.2 ns/op   0 allocs/op

This is part of a series of commits to fully implement the stdscript
package.
2021-06-08 12:20:42 -05:00
Dave Collins
9bcae49b9e
stdscript: Add v0 ecdsa multisig redeem support.
This adds support for identifying if a signature script likely consists
of a pay-to-script-hash multi-signature redeem script for an original
pay-to-script-hash script as a convenience method for consumers of the
package.

Note that this is different in that it applies to the signature script
as opposed to the public key script and consequently there is no new
script type introduced nor does the overall script determination detect
it.  This is the case because determining if a signature script is
actually a redemption of pay-to-script-hash requires the associated
public key script which is often expensive to obtain.  Therefore, this
makes a fast best effort guess that has a high probability of being
correct by checking if the signature script ends with a data push and
treating that data push as if it were a p2sh redeem script.

Also of note is that the same change in semantics regarding compressed
public keys and the required number of signatures as described in the
commit which introduced support for detecting version 0 ecdsa
multisignature scripts applies here.

Full test coverage is included.

This is part of a series of commits to fully implement the stdscript
package.
2021-06-08 12:20:41 -05:00
Dave Collins
299bdc987c
stdscript: Add v0 ecdsa multisig benchmark.
BenchmarkIsMultiSigScript
-------------------------
v0_complex_non_standard                 211282112   5.694 ns/op   0 allocs/op
v0_multisig_1-of-1_compressed_pubkey     20099121   59.14 ns/op   0 allocs/op
v0_multisig_1-of-2_compressed_pubkeys    18043728   65.97 ns/op   0 allocs/op
v0_multisig_2-of-3_compressed_pubkeys    15902906   76.20 ns/op   0 allocs/op

This is part of a series of commits to fully implement the stdscript
package.
2021-06-08 12:20:41 -05:00
Dave Collins
50e602285a
stdscript: Add v0 ecdsa multisig support.
This adds support for detecting version 0 ecdsa multisignature scripts
as standard and extracting the associated details, including the number
of required signatures, number of public keys, and the public keys
themselves.

It should be noted that this code includes a change in the semantics as
compared to the existing code.  In particular:

- The new code only multisignature scripts with compressed public keys
  as standard versus the existing code that allows both compressed and
  uncompressed public keys
- The new code requires at least one signature to be required versus the
  existing code that only requires any small integer (which includes 0)

These ensure the scripts take up considerably less space on chain and
there really isn't a reasonable justification for not using compressed
public keys or not requiring any signatures since that could be done
with a smaller script if truly desired.

In practice, all known software already conforms to these semnatics and
has since launch.

This, of course, does not affect consensus in any way and it still
technically supports both uncompressed and compressed public keys as
well as zero required signatures for the associated multisig opcode.

Full test coverage is included.

This is part of a series of commits to fully implement the stdscript
package.
2021-06-08 12:20:41 -05:00
Dave Collins
f67fc23bd1
stdscript: Add v0 p2sh benchmark.
BenchmarkIsScriptHashScript
---------------------------
v0_complex_non_standard   923756949   1.279 ns/op   0 allocs/op
v0_p2sh                   746887346   1.502 ns/op   0 allocs/op

This is part of a series of commits to fully implement the stdscript
package.
2021-06-08 12:20:40 -05:00