Skip to content

Commit f5e9080

Browse files
authored
Merge pull request #2 from crytic/dev/CONTRIBUTING-module-path-update
Update CONTRIBUTING.md to account for new module path
2 parents c1e6169 + 2a67b3d commit f5e9080

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

Diff for: CONTRIBUTING.md

+20-5
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,17 @@
1010

1111
## Updating fork branches
1212

13-
As releases of `go-ethereum` are made, forked changes will need to be migrated on top of the new release in a new branch in this repository. We provide instructions below which describe how to produce git patches from a previous fork branch, clone `go-ethereum` into this repository under a new version branch, and apply the patches to it.
13+
As releases of `go-ethereum` are made, we follow a consistent/predictable process to update our fork:
14+
- The new version will be cloned on a new branch in this repository, retaining existing commit history (see existing branches).
15+
- Our previous `medusa-geth` changes/commits are carried forward using git patches.
16+
- Any new changes are applied at this step (and will be carried forward in future fork git patches).
17+
- A final commit is made to refactor all module paths (e.g. in `go.mod`, `.go` imports, and all submodule files) from `github.com/ethereum/go-ethereum` to `github.com/crytic/medusa-geth`.
18+
- Git patches cannot account for *newly added/removed imports* in `.go` files, so this is done as a manual replace-all operation. This commit should never be included in git patches mentioned previously.
1419

1520
### Creating git patches from previous branch
1621

17-
- Look at the latest release branch of this repository, note the latest commit hash (which we will call `BBBBBBB`) and the latest _original go-ethereum_ commit hash (which we will call `AAAAAAA`).
22+
- Look at the latest release branch of this repository, obtain the last commit hash *prior to the module path refactor commit*.
23+
- Take note of that^ commit hash (which we will call `BBBBBBB`) and the latest _original go-ethereum_ commit hash (which we will call `AAAAAAA`).
1824
- Clone this repository to your local machine.
1925
- Create a patch of the changes between commit `AAAAAAA` and `BBBBBBB` by using the command: `git format-patch -k AAAAAAA..BBBBBBB -o ./patches`, where `./patches` is the directory to save the generated patches.
2026

@@ -23,7 +29,7 @@ As releases of `go-ethereum` are made, forked changes will need to be migrated o
2329

2430
- Clone the `go-ethereum` repository at the exact commit hash for the release you wish to fork.
2531
- Add this repository as a remote (tracked repository) and remove the original `go-ethereum` repository as a remote.
26-
- Create a new branch at your current position, name if `v<version number`, like the rest of `medusa-geth`'s releases (e.g. `v1.11.1`).
32+
- Create a new branch at your current position, name it `v<version number`, like the rest of `medusa-geth`'s releases (e.g. `v1.11.1`).
2733
- Delete all release tags pulled locally to your machine using `git tag -d $(git tag -l)` (we do not want to push `go-ethereum` release tags to this repository).
2834
- Your local repository should now point to this repository as a remote, have no release tags locally, and be on a branch with a name that is consistent with our release version number.
2935
- You can finally push your changes to the remote.
@@ -33,8 +39,18 @@ As releases of `go-ethereum` are made, forked changes will need to be migrated o
3339
- Your local repository from the last steps should still be on the branch which has the latest vanilla `go-ethereum` release on it.
3440
- To apply the original patches over it, which we generated earlier, run `git am -3 .\patches\<patch name>.patch` for any patches.
3541
- The changes should now be applied, resolve merge conflicts from the patch (if any), and push to remote
42+
43+
### Refactoring the module path
44+
45+
- Perform a "replace-all" operation across the entire repository, replacing `github.com/ethereum/go-ethereum` to `github.com/crytic/medusa-geth`.
46+
- **Important**: JetBrains GoLand and Visual Studio Code load find-and-replace results asynchronously, so replacing all before it is done loading may not actually replace all!
47+
- Triple check that the `go.mod` path and all `.go` import paths are replaced.
48+
- Failure to do so may result in `medusa` failing to compile later on.
49+
- Commit this refactor with the commit message `DO NOT INCLUDE IN PATCH SET: Refactor module path` or similar, for clarity.
50+
- Only commit `medusa-geth` changes, not changes to any submodules that were inadvertently refactored in the process.
3651

3752
### Linking the latest `medusa-geth` branch to `medusa`
53+
3854
Note that `medusa-geth` is linked to `medusa` through a [pseudo-version](https://go.dev/ref/mod#pseudo-versions), not
3955
through a traditional release tag. A pseudo-version is a specially formatted pre-release version that encodes
4056
information about a specific revision in a version control repository. To link the new `medusa-geth` forked branch,
@@ -48,8 +64,7 @@ go: github.com/crytic/[email protected]: invalid version: resolves to version
4864
> **NOTE**: Do not worry about the "invalid version" error in the output above
4965
5066
- Copy the pseudo-version value. In the example above, it is `v0.0.0-20240209160711-dfded09070ca`.
51-
- Open the `go.mod` file in the `medusa` repository and update the pseudo-version for `medusa-geth`. You can find this
52-
by looking for the `replace` directive at the bottom of the `go.mod` file.
67+
- Open the `go.mod` file in the `medusa` repository and update the pseudo-version for `medusa-geth`.
5368

5469
### Testing
5570

0 commit comments

Comments
 (0)