-
Notifications
You must be signed in to change notification settings - Fork 250
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
Apply geth patches on the fly #653 #660
Conversation
@canercidam can you point |
4033589
to
337f0a6
Compare
CI passed. Important notes:
I think this PR needs an initial review before updating README.md and DEPENDENCIES.md. I'll update both with the last state it's agreed on. |
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.
Great job! That should simplify our workflow a lot.
A few questions:
- what would happen to vendor-check if we remove patches?
- what would happen to vendor-check if the patch was changed but the changes didn't apply?
_assets/patches/patcher
Outdated
done | ||
)) | ||
newPatches=( "${fromDevelop[@]}" "${uncommitted[@]}" ) | ||
# Checks new patches and exits with 1 if there are unapplied. |
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.
what would happen if we removed a patch?
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.
Nothing problematic. Looks like there's a flaw about that - ideally, it should exclude the removed ones - but it doesn't affect the result. Any patch change (addition, removal) is detected as a new patch but it's not counted if it's currently not residing as an unapplied patch in the directory.
Another question is, what happens if there's a non-new & unapplied patch in the directory (since it will get ignored) but that's not a big problem because make dep-ensure
keeps things on track.
_assets/ci/isolate-vendor-check.sh
Outdated
|
||
branchName="$(git rev-parse --abbrev-ref HEAD)" | ||
|
||
git checkout -b isolated-vendor-check |
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.
I'd add some timestamp to the temp branch name, to avoid conflicts. Maybe isolated-vendor-check/<timestamp>
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.
Just a few minor questions (and of course README.md still needs to be updated). This would have saved me probably a full day when I was recently patching our fork for Whisper v6. Looking forward to having this merged in. Great job!
"whisper/whisperv5" | ||
] | ||
revision = "5b2cc44bf2b32bb482def02d7c8fa32ba08d0bf4" | ||
source = "https://github.com/status-im/go-ethereum.git" | ||
revision = "4bb3c89d44e372e6a9ab85a8be0c9345265c763a" |
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.
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.
Can you elaborate?
We won't be able to keep the same revision SHA in this PR because we point to another repository.
In this diff I don't see anything changed in go-ethereum
, just one main file + a few test utils.
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.
Nevermind, I'm still partly asleep :-) I was assuming that the vendor folder would contain the unpatched version, which of course doesn't make sense.
# 1) Stashes all changes and checks out to a temporary branch. | ||
# 2) Reverts all patches and commits changes. | ||
# 3) Runs "dep ensure" and validate-vendor.sh. Saves exit code and message. | ||
# 4) Commits any changes. |
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.
Why do we commit the changes if the branch is going to be removed in the next step? Is that for debugging purposes in case the process fails?
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.
About first commit: Running the validation script when there are patches, it says "Oh, you've made some changes! That's not the way to work with dep
." Then it removes all our patches and complains until we commit, which is bad because now it removed all of the changes it's not possible to check any other changes. And this script is about checking those ones because ideally there should be no other changes than patches. After reversion and committing, what's left are those.
About second commit: It rarely leaves the workspace in an uncommitted state so that's useful before git checkout <previous_branch>
.
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.
Yeah, I was just wondering what was the reason to not do git reset --hard
instead.
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.
That was my first option but this looked like a cleaner approach than counting successful commits. And safer while making changes on the script.
Edit: Ah, I forgot that git reset --hard <rev>
should be possible.
_assets/patches/patcher
Outdated
git apply "$f" --directory="$basepath" > /dev/null 2>&1 | ||
done | ||
# Sorts out new patches' paths by comparing with "develop" branch. | ||
fromDevelop=($(git diff develop --stat | grep "\\.patch" | |
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.
What do you think about making develop a baseBranch
variable at the beginning of the script next to basepath
and others and rename fromDevelop
to fromBaseBranch
? That would make it easy to see all assumptions in one place at the beginning of the script and promote reuse in future script additions.
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.
Good idea! Thanks.
geth/node/node.go
Outdated
@@ -182,15 +181,6 @@ func activateShhService(stack *node.Node, config *params.NodeConfig) error { | |||
mailServer.Init(whisperService, whisperConfig.DataDir, whisperConfig.Password, whisperConfig.MinimumPoW) | |||
} | |||
|
|||
// enable notification service |
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.
@mandrigin Is this code not needed anymore?
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.
We actually should move it to the notifications patch, I think.
It isn't really dependent on anything in status-go.
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.
@adambabik @divan @JekaMas what do you think?
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.
@canercidam can you please move that removed code into 0004-whisper-notifications.patch
and just expose EnableNotifications()
method from whisperService
?
That's the last thing that is left in this PR, and we can merge it!
(PS: Looking at that it takes more time than we expected, we made it a bigger M
bounty).
Makefile
Outdated
./_assets/patches/patcher -c | ||
./_assets/ci/isolate-vendor-check.sh | ||
|
||
dep-ensure: |
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.
Any reason why we're not including these targets in the help screen of Make so people are aware of them when they type make
? We could have patches and dependencies sections. What do you think @mandrigin?
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.
I think we should definitely include them
Complains:
|
_assets/patches/patcher
Outdated
@@ -56,7 +60,7 @@ while getopts :prcv opt; do | |||
git apply "$f" --directory="$basepath" > /dev/null 2>&1 | |||
done | |||
# Sorts out new patches' paths by comparing with "develop" branch. |
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.
replace "develop" in comment
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.
Done 👍
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.
Just a tiny change requested, but other than that it is approved
@canercidam thanks. So now we just need to include the removed |
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.
I think we should make EnableNotifications()
method in whisperService
and make it a part of a patch (0004...
).
Otherwise, we will have the same problems with dep
being unable to find a correct go-ethereum
branch when upgrading this dependency.
@mandrigin Patching status-go code? Before doing that, I'm wondering if it's really necessary to have |
@canercidam this package shouldn't be in Though it would be a huge scope creep to do that in this PR, I think. I'd like to have it merged :)
if whisperConfig.EnablePushNotification {
log.Info("Register PushNotification server")
whisperService.EnableNotificationServer()
}
|
@mandrigin That sounds nice but wouldn't that cause an import cycle problem? |
@canercidam you are right.
|
Thank you, added. I think that was a clean solution. 👍 |
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.
Looks great! Thanks a lot, amazing job, @canercidam!
🎉 |
This PR adds
-c
option topatcher
, which checks for unapplied patches (see comment in script) and pointsgo-ethereum
dependency github.com/ethereum/go-ethereum
. Also, aisolate-vendor-check.sh
script is added to avoid conflicts between patching andvalidate-vendor.sh
.Changes:
make vendor-check
fails if any of the added patches were not applied in current workspace and branch.go-ethereum
points github.com/ethereum/go-ethereum
.dep-ensure
was created as described in Apply geth patches on the fly. #653.go-ethereum
is not used anywhere.Closes #653
@mandrigin @adambabik