-
Notifications
You must be signed in to change notification settings - Fork 37.7k
rpc: Add script verification flags to getdeploymentinfo #28806
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
Conversation
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code CoverageFor detailed information about the code coverage, see the test coverage report. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
This patch has been included in bitcoin-inquisition for a few releases (bitcoin-inquisition#5, bitcoin-inquisition#15 and bitcoin-inquisition#31). I used the same technique when in #23536 (review) and found it helpful. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
left some nits/questions. Feel free to ignore.
src/deploymentinfo.cpp
Outdated
|
||
std::string FormatScriptFlags(uint32_t flags) | ||
{ | ||
if (flags == 0) return ""; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this ever hit? If not, maybe it can be removed, as the remaining code should reach the same conclusion anyway in the rare case that this is hit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @aureleoules for the coverage report
No coverage data available for this pull request and commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the ping, I re-ran the job. AWS preempted the job and I haven't figured out how to rerun them automatically yet.
Anyone in this org can re-run corecheck jobs by signing in as well!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this ever hit? If not, maybe it can be removed, as the remaining code should reach the same conclusion anyway in the rare case that this is hit?
It's hit for block 170060. I think it's worth having it be explicit, as it would also be reasonable to return "NONE" (as in SCRIPT_VERIFY_NONE
) for that case.
c8ea84c
to
02d8461
Compare
Concept ACK |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Getting some deja vu here - is there another PR for this already?
|
||
#define FLAG_NAME(flag) {std::string(#flag), SCRIPT_VERIFY_##flag} | ||
const std::map<std::string, uint32_t> g_verify_flag_names{ | ||
FLAG_NAME(P2SH), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're exposing this, probably better to call it "BIP16" since p2wsh and p2tr(sometimes) are also p2sh.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Pay to script hash" is the title of BIP16, and we use both "pay-to-script-hash" and "P2SH" as descriptions of the sh()
descriptor in doc/descriptors.md, so I don't think this is confusing or needs any changes.
src/rpc/blockchain.cpp
Outdated
@@ -1359,6 +1360,7 @@ RPCHelpMan getdeploymentinfo() | |||
UniValue deploymentinfo(UniValue::VOBJ); | |||
deploymentinfo.pushKV("hash", blockindex->GetBlockHash().ToString()); | |||
deploymentinfo.pushKV("height", blockindex->nHeight); | |||
deploymentinfo.pushKV("script_flags", FormatScriptFlags(GetBlockScriptFlags(*blockindex, chainman))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe number form should also be available for users of libbitcoinconsensus?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Numbers aren't a standard (they'll readily change between releases; also true of the names) but they also aren't particularly useful as documentation, so don't think it's sensible to export them here.
Ah, #10730 |
"When we last discussed making scripts debuggable" -- this and #28802 are prereqs for "bitcoin-util evalscript" which I'm poking at on https://github.com/ajtowns/bitcoin/commits/202309-evalscript . Real debugging seems better done with smarter external tools like https://github.com/dgpv/bsst though. |
02d8461
to
7f3ee40
Compare
Moves FormatScriptFlags logic into GetScriptFlagNames which returns a vector of strings. For completeness, also has GetScriptFlagNames report on any bits that do not match a known script flag.
7f3ee40
to
b295371
Compare
The PR didn't seem to attract much attention in the past. Also, the issue seems not important enough right now to keep it sitting around idle in the list of open PRs. Closing due to lack of interest. |
Adds a
script_flags
field to the output of thegetdeploymentinfo
RPC that lists the flags selected byGetBlockScriptFlags()
. This can be useful for seeing the detailed consequences of soft-fork activation behaviour, eg:This allows you to see that P2SH, WITNESS and TAPROOT are enforced since genesis; that the p2sh exception block (170060) has none of these extra rules enforced, that the taproot exception block (692261) is exempted from taproot enforcement, and exactly which rules were activated by each soft fork (eg, NULLDUMMY as part of the segwit soft fork).