Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stdscript: Add consolidated stake extracts. #2816

Merged
merged 4 commits into from
Nov 19, 2021

Conversation

davecgh
Copy link
Member

@davecgh davecgh commented Nov 19, 2021

This adds support for extracting the public key and script hashes from version 0 scripts that are any of of the standard types usable in the staking system along with associated tests and benchmarks.

Namely, it adds

  • ExtractStakePubKeyHashV0
  • ExtractStakeScriptHashV0

While all of the data can be extracted from each individual type, it can be more convenient for callers who treat all types of script hashes and/or public key hashes as the same entity which is the case for many applications.

BenchmarkExtractStakeScriptHashV0
---------------------------------
v0_complex_non_standard       226793582   5.253 ns/op
v0_stake_submission_p2sh      372232682   3.233 ns/op
v0_stake_gen_p2sh             305602378   3.979 ns/op
v0_stake_revoke_p2sh          201691552   5.064 ns/op
v0_stake_change_p2sh          209401243   5.687 ns/op
v0_treasury_generation_p2sh   221794405   5.419 ns/op

BenchmarkExtractStakePubKeyHashV0
---------------------------------
v0_complex_non_standard-16                        229676676   5.139 ns/op
v0_stake_submission_p2pkh-ecdsa-secp256k1-16      335241789   3.531 ns/op
v0_stake_gen_p2pkh-ecdsa-secp256k1-16             268142942   4.517 ns/op
v0_stake_revoke_p2pkh-ecdsa-secp256k1-16          244045095   4.908 ns/op
v0_stake_change_p2pkh-ecdsa-secp256k1-16          220275314   5.441 ns/op
v0_treasury_generation_p2pkh-ecdsa-secp256k1-16   197104339   6.086 ns/op

@davecgh davecgh added this to the 1.7.0 milestone Nov 19, 2021
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.
BenchmarkExtractStakePubKeyHashV0
---------------------------------
v0_complex_non_standard-16                        229676676   5.139 ns/op
v0_stake_submission_p2pkh-ecdsa-secp256k1-16      335241789   3.531 ns/op
v0_stake_gen_p2pkh-ecdsa-secp256k1-16             268142942   4.517 ns/op
v0_stake_revoke_p2pkh-ecdsa-secp256k1-16          244045095   4.908 ns/op
v0_stake_change_p2pkh-ecdsa-secp256k1-16          220275314   5.441 ns/op
v0_treasury_generation_p2pkh-ecdsa-secp256k1-16   197104339   6.086 ns/op
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.
BenchmarkExtractStakeScriptHashV0
---------------------------------
v0_complex_non_standard       226793582   5.253 ns/op
v0_stake_submission_p2sh      372232682   3.233 ns/op
v0_stake_gen_p2sh             305602378   3.979 ns/op
v0_stake_revoke_p2sh          201691552   5.064 ns/op
v0_stake_change_p2sh          209401243   5.687 ns/op
v0_treasury_generation_p2sh   221794405   5.419 ns/op
@davecgh davecgh force-pushed the stdscript_consolidated_stake_extracts branch from cfdada9 to b1b9a86 Compare November 19, 2021 05:03
@davecgh davecgh merged commit b1b9a86 into decred:master Nov 19, 2021
@davecgh davecgh deleted the stdscript_consolidated_stake_extracts branch November 19, 2021 05:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants