Skip to content
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

Refactor Actor Upgrade Functions to Reduce Code Duplication #11971

Open
rjan90 opened this issue May 7, 2024 · 0 comments
Open

Refactor Actor Upgrade Functions to Reduce Code Duplication #11971

rjan90 opened this issue May 7, 2024 · 0 comments

Comments

@rjan90
Copy link
Contributor

rjan90 commented May 7, 2024

Background

In the network upgrade logic, there is a lot of duplication of code that potentially can be extracted to a function and called for all future upgrades. Some examples that Zen found during the code-review of the nv23 skeleton:

func PreUpgradeActorsV13(ctx context.Context, sm *stmgr.StateManager, cache stmgr.MigrationCache, root cid.Cid, epoch abi.ChainEpoch, ts *types.TipSet) error {
// Use half the CPUs for pre-migration, but leave at least 3.
workerCount := MigrationMaxWorkerCount
if workerCount <= 4 {
workerCount = 1
} else {
workerCount /= 2
}
lbts, lbRoot, err := stmgr.GetLookbackTipSetForRound(ctx, sm, ts, epoch)
if err != nil {
return xerrors.Errorf("error getting lookback ts for premigration: %w", err)
}
config := migration.Config{
MaxWorkers: uint(workerCount),
ProgressLogPeriod: time.Minute * 5,
UpgradeEpoch: build.UpgradeDragonHeight,
}
_, err = upgradeActorsV13Common(ctx, sm, cache, lbRoot, epoch, lbts, config)
return err
}

func upgradeActorsV14Common(
ctx context.Context, sm *stmgr.StateManager, cache stmgr.MigrationCache,
root cid.Cid, epoch abi.ChainEpoch, ts *types.TipSet,
config migration.Config,
) (cid.Cid, error) {
writeStore := blockstore.NewAutobatch(ctx, sm.ChainStore().StateBlockstore(), units.GiB/4)
adtStore := store.ActorStore(ctx, writeStore)

We should look into if we can refactor some of this to reduce code duplication, simplify future upgrades and enhance maintainability.

@rjan90 rjan90 mentioned this issue May 7, 2024
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant