Skip to content

Commit b73d4e0

Browse files
authored
docs:Building_a_network_skeleton.md cleanups (#12079)
* Building_a_network_skeleton.md cleanups Go-State-Types Checklist updates * Updated Lotus PR to the one that was merged for nv23 * Made network version substitute variable to consistently be "xx" instead of 3 or more "x"'s in some cases. Adjusted ToC. * Leaving ToC untouched * Building_a_network_skeleton.md cleanups Go-State-Types Checklist updates * Made network version substitute variable to consistently be "xx" instead of 3 or more "x"'s in some cases. Adjusted ToC. * Leaving ToC untouched * Building_a_network_skeleton.md cleanups Go-State-Types Checklist updates * Made network version substitute variable to consistently be "xx" instead of 3 or more "x"'s in some cases. Adjusted ToC.
1 parent 8cd233b commit b73d4e0

File tree

1 file changed

+42
-25
lines changed

1 file changed

+42
-25
lines changed

documentation/misc/Building_a_network_skeleton.md

Lines changed: 42 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
This guide will walk you through the process of creating a skeleton for a network upgrade in Lotus. The process involves making changes in multiple repositories in the following order:
44

5-
1. [`ref-fvm`](#ref-fvm-checklist)
6-
2. [`filecoin-ffi`](#filecoin-ffi-checklist)
7-
3. [`go-state-types`](#go-state-types-checklist)
8-
4. [`lotus`](#lotus-checklist)
5+
- [Setup](#setup)
6+
- [Ref-FVM Checklist](#ref-fvm-checklist)
7+
- [Filecoin-FFI Checklist](#filecoin-ffi-checklist)
8+
- [Go-State-Types Checklist](#go-state-types-checklist)
9+
- [Lotus Checklist](#lotus-checklist)
910

1011
Each repository has its own set of steps that need to be followed. This guide will provide detailed instructions for each repository.
1112

@@ -60,8 +61,24 @@ You can take a look at this [Filecoin-FFI PR as a reference](https://github.com/
6061

6162
1. Follow the [go-state-types actor version checklist](https://github.com/filecoin-project/go-state-types/blob/master/actors_version_checklist.md):
6263

63-
- Copy `go-state-types/builtin/vX` to `go-state-types/builtin/v(X+1)`.
64-
- Change all references from vX to v(X+1) in the new files.
64+
- Setup
65+
```bash
66+
# export these environment variables so they can read in the commands below
67+
export CURRENT_VERSION=vXX # e.g., v14
68+
export NEW_VERSION=vXX+1 # e.g., v15
69+
```
70+
- Copy `go-state-types/builtin/vXX` to `go-state-types/builtin/v(XX+1)`.
71+
```bash
72+
cp -r builtin/$CURRENT_VERSION builtin/$NEW_VERSION
73+
```
74+
- Make a commit with this change. That way the followup commit(s) will be separated out from the copy/paste change for easier reviewing.
75+
- Change all references from vXX to v(XX+1) in the new files.
76+
```bash
77+
# Find all the files that have a reference to vXX
78+
# Update them to vXX+1
79+
# "sed -i=''" is done for macOS compatibility per https://stackoverflow.com/questions/12272065/sed-undefined-label-on-macos
80+
find builtin/$NEW_VERSION -type f -exec sh -c 'grep -q "builtin/$CURRENT_VERSION" "$1" && sed -i='' "s/builtin\/$CURRENT_VERSION/builtin\/$NEW_VERSION/g" "$1" && echo "$1"' _ {} \;
81+
```
6582
- Add new network version to `network/version.go`.
6683
- Add new actors version to `actors/version.go`.
6784
- Add `Version(XX+1) Version = XX+1` as a constant.
@@ -73,14 +90,14 @@ You can take a look at this [Filecoin-FFI PR as a reference](https://github.com/
7390
- Commit the above changes with a `Delete migration specific for nvXX` message so its easier to review.
7491
- Check your `/builtin/vXX+1/check.go` file, and see if there is any Invariant TODOs that stems from the previous migration that needs to be cleaned up.
7592

76-
You can take a look at this [Go-State-Types PR as a reference](https://github.com/filecoin-project/go-state-types/pull/257), which added the skeleton for network version 23.
93+
👉 You can take a look at this [Go-State-Types PR as a reference](https://github.com/filecoin-project/go-state-types/pull/257), which added the skeleton for network version 23.
7794

78-
2. In a second PR based off your first PR, add a simple migration for the network upgrade:
95+
1. In a second PR based off your first PR, add a simple migration for the network upgrade:
7996

8097
- Copy the system.go template [^1], and add it to your `/builtin/vXX+1/migration` folder.
8198
- Copy the top.go template [^2], and add it to your `/builtin/vXX+1/migration` folder.
8299

83-
You can take a look at this [Go-State-Types PR as a reference](https://github.com/filecoin-project/go-state-types/pull/258), which added added a simple migration for network version 23.
100+
👉 You can take a look at this [Go-State-Types PR as a reference](https://github.com/filecoin-project/go-state-types/pull/258), which added added a simple migration for network version 23.
84101

85102
## Lotus Checklist
86103

@@ -96,27 +113,27 @@ You can take a look at this [Go-State-Types PR as a reference](https://github.co
96113

97114
- Update the following files:
98115
- `params_2k.go`
99-
- Set previous `UpgradeXxxxxHeight = abi.ChainEpoch(-xx-1)`
100-
- Add `var UpgradeXxxxxHeight = abi.ChainEpoch(200)`
101-
- Add `UpgradeXxxxxHeight = getUpgradeHeight("LOTUS_XXXXX_HEIGHT", UpgradeXXXXHeight)`
116+
- Set previous `UpgradeXxHeight = abi.ChainEpoch(-xx-1)`
117+
- Add `var UpgradeXxHeight = abi.ChainEpoch(200)`
118+
- Add `UpgradeXxHeight = getUpgradeHeight("LOTUS_XX_HEIGHT", UpgradeXXHeight)`
102119
- Set `const GenesisNetworkVersion = network.VersionXX` where XX is the network version you are upgrading from.
103120
- `params_butterfly.go`
104-
- set previous upgrade to `var UpgradeXxxxxHeigh = abi.ChainEpoch(-xx-1)`
121+
- set previous upgrade to `var UpgradeXxHeigh = abi.ChainEpoch(-xx-1)`
105122
- Add comment with ?????? signaling that the new upgrade date is unkown
106-
- Add `const UpgradeXxxxxHeight = 999999999999999`
123+
- Add `const UpgradeXxHeight = 999999999999999`
107124
- `params_calibnet.go`
108125
- Add comment with `??????` signaling that the new upgrade date is unkown
109-
- Add `const UpgradeXxxxxHeight = 999999999999999`
126+
- Add `const UpgradeXxHeight = 999999999999999`
110127
- `params_interop.go`
111-
- set previous upgrade to `var UpgradeXxxxxHeigh = abi.ChainEpoch(-xx-1)`
112-
- Add `const UpgradeXxxxxHeight = 50`
128+
- set previous upgrade to `var UpgradeXxHeigh = abi.ChainEpoch(-xx-1)`
129+
- Add `const UpgradeXxHeight = 50`
113130
- `params_mainnet.go`
114-
- Set previous upgrade to `const UpgradeXxxxxHeight = XX`
131+
- Set previous upgrade to `const UpgradeXxHeight = XX`
115132
- Add comment with ???? signaling that the new upgrade date is unkown
116-
- Add `var UpgradeXxxxxxHeight = abi.ChainEpoch(9999999999)`
117-
- Change the `LOTUS_DISABLE_XXXX` env variable to the new network name
133+
- Add `var UpgradeXxHeight = abi.ChainEpoch(9999999999)`
134+
- Change the `LOTUS_DISABLE_XX` env variable to the new network name
118135
- `params_testground.go`
119-
- Add `UpgradeXxxxxHeight abi.ChainEpoch = (-xx-1)`
136+
- Add `UpgradeXxHeight abi.ChainEpoch = (-xx-1)`
120137

121138
3. Generate adapters:
122139

@@ -135,10 +152,10 @@ You can take a look at this [Go-State-Types PR as a reference](https://github.co
135152
- Add `inv.Register(actorstypes.Version(XX+1), vm.ActorsVersionPredicate(actorstypes.Version(XX+1)), builtin.MakeRegistry(actorstypes.Version(XX+1))`.
136153
137154
6. Add upgrade field to `api/types.go/ForkUpgradeParams`.
138-
- Add `UpgradeXxxxxHeight abi.ChainEpoch` to `ForkUpgradeParams` struct.
155+
- Add `UpgradeXxHeight abi.ChainEpoch` to `ForkUpgradeParams` struct.
139156
140157
7. Add upgrade to `node/impl/full/state.go`.
141-
- Add `UpgradeXxxxxHeight: build.UpgradeXxxxxHeight,`.
158+
- Add `UpgradeXxHeight: build.UpgradeXxHeight,`.
142159
143160
8. Add network version to `chain/state/statetree.go`.
144161
- Add `network.VersionXX+1` to `VersionForNetwork` function.
@@ -155,7 +172,7 @@ And you're done! These are all the steps necessary to create a network upgrade s
155172
- Complete the migration at upgrade epoch, with a succesful upgrade.
156173
- Sync the new network version with the mock actor bundle, and be able to see that you are on a new network version with `lotus state network-version`
157174
158-
You can take a look at this [Lotus PR as a reference](https://github.com/filecoin-project/lotus/pull/11897), which added the skeleton for network version 23.
175+
You can take a look at this [Lotus PR as a reference](https://github.com/filecoin-project/lotus/pull/11964), which added the skeleton for network version 23.
159176
160177
[^1]: Here is system.go template for a simple migration:
161178
@@ -315,7 +332,7 @@ You can take a look at this [Lotus PR as a reference](https://github.com/filecoi
315332
316333
```go
317334
{
318-
Height: build.UpgradeXxxxHeight,
335+
Height: build.UpgradeXxHeight,
319336
Network: network.Version(XX+1),
320337
Migration: UpgradeActorsV(XX+1),
321338
PreMigrations: []stmgr.PreMigration{{

0 commit comments

Comments
 (0)