Skip to content

Conversation

@theuni
Copy link
Member

@theuni theuni commented Apr 11, 2017

This should really be 2 PRs, but the CNode change is helpful to show the script's usefulness.

Scriptable changes verifier

We often make simple changes that produce large diffs, but are easily scriptable. A large search+replace like #9902 is the most obvious example.

It's useful both for reviewers, and for posterity, to include these transforming scripts in the commit message. And once there, we can use c-i to verify the scripted changes before merging.

A simple script checks for commits containing the line: -BEGIN VERIFY SCRIPT-, and reads until it the line: -END VERIFY SCRIPT-, or the end of the commit message.

The resulting script should exactly transform the previous commit into the current one. Any remaining diff signals an error.

Travis will check each commit for these scripts, and fail if any script fails.

Make CNode's id field private

This was useful to check the safety of #10176 (making it easier to see where the node's id is used), and is a general encapsulation improvement.

@jtimon
Copy link
Contributor

jtimon commented Apr 11, 2017

This is a great idea I plan to heavily use.
utACK 4759716 besides the script itself which I still have some doubts about. Probably instead of learning the git-fu involved now I could simply go ahead and test it by writing something based on this.

@theuni
Copy link
Member Author

theuni commented Apr 11, 2017

@jtimon You're right to doubt the script, it's quite kludgy. it works by rewinding to the previous commit, running the supplied transform script, and comparing the result to the actual commit.

Because the script needs to work on real files, I'm not sure how to avoid working on the current repo, other than maybe setting up a dummy index/workdir.

@jtimon
Copy link
Contributor

jtimon commented Apr 12, 2017

ACK 6ca7f42 conditional to 74214a2 failing on travis but the whole PR squashed as a single commit passing. See #10193

@jtimon
Copy link
Contributor

jtimon commented Apr 12, 2017

ACK 6ca7f42 Travis fails if not all the changes performed by the script are included in the commit as expected https://travis-ci.org/bitcoin/bitcoin/jobs/221211199 I will now squash #10193 so that it passes.

@TheBlueMatt
Copy link
Contributor

As discussed on IRC, making the script require some prefix in the commit title (ie first line) would help make sure people see it.

@theuni
Copy link
Member Author

theuni commented Apr 20, 2017

Added enforcement of the prefix: "scripted-diff:" in the first line.

@luke-jr
Copy link
Member

luke-jr commented Apr 20, 2017

Relying on Travis to do review is a bad thing, and as-implemented, it's not very safe for reviewers to run manually.

But more annoyingly, can the prefix be on a not-first-line where it pollutes the commit summary? :/

@theuni
Copy link
Member Author

theuni commented Apr 20, 2017

@luke-jr it's enforced in the subject line so that reviewers can't miss it. That was the resounding request during the meeting.

It can be fixed up to (optionally) require approval before running. Would that make you comfortable enough to run it locally?

@theuni
Copy link
Member Author

theuni commented Apr 20, 2017

rebased at @jtimon's request

@luke-jr
Copy link
Member

luke-jr commented Apr 20, 2017

I wouldn't be comfortable with anything less than reading the script and manually running it explicitly...

@theuni
Copy link
Member Author

theuni commented Apr 20, 2017

@luke-jr You're free to c/p the script and run it, then. I understand your hesitance, but this doesn't take away anything, only adds a check which can be ignored.

@luke-jr
Copy link
Member

luke-jr commented Apr 20, 2017

It takes away from readability of single-line summaries. And gives people a false sense of security if Travis is trusted.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe wait for user input prior to eval to give the user time to actually read the script and exit on doubt. (travis can use --force-eval)

see discussion in #10193 (comment)

@laanwj
Copy link
Member

laanwj commented Apr 26, 2017

Concept ACK

@luke-jr You're free to c/p the script and run it, then. I understand your hesitance, but this doesn't take away anything, only adds a check which can be ignored.

I agree. We already use Travis for many checks, adding one more isn't problematic. It should not take away from people manually reviewing or running tests locally.

@jtimon
Copy link
Contributor

jtimon commented Apr 26, 2017

Needs rebase, re-utACK except for the script itself, which I don't fully understand but I have tested using travis.
I don't plan to ever run it locally. The idea of using shell scripts for certain refactor changes and put the commands used in the commit message for easier review is awesome and I'm going to use it whether this check is done by travis or not. Even if reviewers don't run the scripts locally to make sure the changes are complete, they can point it out if the commit is doing something else than what would running the script could possibly do.

It takes away from readability of single-line summaries.

No, the single line summary can still be very clear, and the script in the detailed message just says the same thing in a more formal way.

And gives people a false sense of security if Travis is trusted.

It doesn't give me any false sense of security and from what you say it doesn't give it to you either.
Perhaps we should make clearer somewhere that travis doesn't replace review and testing and that commits prefixed with "scripted-diff" need review like any other commit.

If we're going to keep discussing it, maybe the PR should be separated in the script itself and the changes to net_processing, since the scripted-diff commits can be merged before the script itself is merged anyway (and the script itself will much more unlikely require rebase).

@theuni
Copy link
Member Author

theuni commented Apr 28, 2017

Rebased. If this ends up needing another rebase later due to another net change, I'll split it up.

I'd rather hold off on making the interactive change until this gets a little real-world testing. I'm sure some other things worth addressing will crop up.

@TheBlueMatt
Copy link
Contributor

utACK 644cb250e708b5724a0879f26449baa5544d35cf (needs squash, of course)

theuni added 3 commits May 4, 2017 01:04
-BEGIN VERIFY SCRIPT-
sed -i "s/\(node\|to\|from\)->id/\1->GetId()/" src/net.cpp src/net_processing.cpp
-END VERIFY SCRIPT-
@jtimon
Copy link
Contributor

jtimon commented May 4, 2017

As mentioned on IRC, I drafted some documentation for this, not sure where to put it, maybe contributing.md : https://0bin.net/paste/mTtIoaSoedZ3al-y#dWgD7aBKElhKofVS5nHJBvuvlDLRFmgRy8a03KroOFM

@maflcko
Copy link
Member

maflcko commented May 6, 2017

utACK e50c33e

@laanwj laanwj merged commit 0f3471f into bitcoin:master May 7, 2017
laanwj added a commit that referenced this pull request May 7, 2017
…e it to make CNode::id private.

0f3471f net: make CNode's id private (Cory Fields)
9ff0a51 scripted-diff: net: Use accessor rather than node's id directly (Cory Fields)
e50c33e devtools: add script to verify scriptable changes (Cory Fields)

Tree-SHA512: a0ff50f4e1d38a2b63109b4996546c91b3e02e00d92c0bf04f48792948f78b1f6d9227a15d25c823fd4723a0277fc6a32c2c1287c7abbb7e50fd82ffb0f8d994
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jun 19, 2019
…ges. Use it to make CNode::id private.

0f3471f net: make CNode's id private (Cory Fields)
9ff0a51 scripted-diff: net: Use accessor rather than node's id directly (Cory Fields)
e50c33e devtools: add script to verify scriptable changes (Cory Fields)

skipped travis changes

Tree-SHA512: a0ff50f4e1d38a2b63109b4996546c91b3e02e00d92c0bf04f48792948f78b1f6d9227a15d25c823fd4723a0277fc6a32c2c1287c7abbb7e50fd82ffb0f8d994

pnode->id to pnode->GetId()

Signed-off-by: Pasta <[email protected]>
zkbot added a commit to zcash/zcash that referenced this pull request Oct 27, 2020
Verifier for scriptable changes

Includes changes from the following upstream PRs:
- bitcoin/bitcoin#10189
  - Excluding the `CNode` scripted changes.
- bitcoin/bitcoin#10480
- bitcoin/bitcoin#11390
- bitcoin/bitcoin#13281
  - Only the lint scripts we already have.
- bitcoin/bitcoin#13454
  - Only changes to scripts we already have.
- bitcoin/bitcoin#14864
- bitcoin/bitcoin#16327
  - Includes some portability fixes to other shell scripts.
- bitcoin/bitcoin#20069
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants