The official Bitcoin-ABC guide to backporting code from Bitcoin Core. When searching for items to backport, especially be on the lookout for bug fixes, code cleanup, and important refactors, as these help improve Bitcoin ABC despite consensus-level differences between Bitcoin Cash and Bitcoin Core.
- Check out a copy of a Satoshi Bitcoin client somewhere on your machine.
- Identify the subsystem you'd like to work on.
- Tag the fork commit as
fork-commit
. Bitcoin-ABC was forked from Bitcoin Core at commit964a185cc83af34587194a6ecda3ed9cf6b49263
.> git tag -a fork-commit 964a185 -m 'Where the fun started'
git log --topo-order --graph fork-commit..HEAD -- <file or folder of interest>
- Find the commit, and if applicable, the associated merge commit that are worth backporting. The merge commit may indicate that there were other commits associated with this change that you will need to backport. E.g:
commit d083bd9b9c5249f21b8b7e4abd7aee48a25806b1
Merge: b3eb0d648 279fde58e
Author: Wladimir J. van der Laan <laanwj@gmail.com>
Date: Wed Jun 21 14:26:10 2017 +0200
Merge #10533: [tests] Use cookie auth instead of rpcuser and rpcpassword
279fde5 Check for rpcuser/rpcpassword first then for cookie (Andrew Chow)
3ec5ad8 Add test for rpcuser/rpcpassword (Andrew Chow)
c53c983 Replace cookie auth in tests (Andrew Chow)
Tree-SHA512: 21efb84c87080a895cac8a7fe4766738c34eebe9686c7d10af1bf91ed4ae422e2d5dbbebffd00d34744eb6bb2d0195ea3aca86deebf085bbdeeb1d8b474241ed
If you saw that commit c53c983
was a good idea to backport, this merge
commit would indicate that there are two other commits that are associated
with this PR and likely to be needed.
When trying to find a patch worth backporting, it's generally a good idea to backport significant refactors or bugfixes. This will help clean up the code in the ABC repository, fix bugs, and make future backports significantly easier. Backports are easiest done in topological order of commits.
Before you begin backporting commits, you will need to add an additional remote to your Bitcoin-ABC repo. For Bitcoin Core, this repository would be added as:
git remote add core git@github.com:bitcoin/bitcoin.git
git fetch core
(Assuming you have github ssh auth setup. The second command is required to obtain refs for cherry-picking.)
Once you have identified your commit, or commits on question to backport you have two choices:
- Backport each diff individually
- Squash the commits together for backporting.
In either case, you will find there are likely merge conflicts.
git checkout -b <name-of-branch>
git cherry-pick <commit-of-interest>
- Run
git status
and fix conflicts. git add -u && git cherry-pick --continue
- Run
git show
side-by-side withgit show <commit-of-interest>
and verify that the changes are reasonable. If there are additional changes caused by the merge conflict - Run the build, and the rpc test suite and verify completion.
arc diff
and at the bottom of the summary note: "Backport of Bitcoin Core PR# ". the PR# can be obtained by searching on github for the commit you are backporting. If you are backporting a commit which depends on another commit from the same PR, note that you are backportingPart 1 of X
. Additionally, if it is the second or more of a series of commits in a backport, note which other phabricator revision this diff depends on by typingDepends on DXXXX
at the bottom of the summary.
git checkout -b PRXXXXX
- Perform steps 2 through 6 from "Backporting each diff individually" in repetition for each diff in a Bitcoin Core pull request.
git rebase -i origin/master
and squash the commits together.arc diff
and at the bottom of the summary note: "Backport of Bitcoin Core PR# ". The title of the diff should be:[Backport] <Description of the included changes>