diff --git a/cmd/lotus-sim/simulation/block.go b/cmd/lotus-sim/simulation/block.go index 3a1181c1c..b3d0288b8 100644 --- a/cmd/lotus-sim/simulation/block.go +++ b/cmd/lotus-sim/simulation/block.go @@ -47,7 +47,7 @@ func (sim *Simulation) nextTicket() *types.Ticket { // This method does _not_ mutate local state (although it does add blocks to the datastore). func (sim *Simulation) makeTipSet(ctx context.Context, messages []*types.Message) (*types.TipSet, error) { parentTs := sim.head - parentState, parentRec, err := sim.sm.TipSetState(ctx, parentTs) + parentState, parentRec, err := sim.StateManager.TipSetState(ctx, parentTs) if err != nil { return nil, xerrors.Errorf("failed to compute parent tipset: %w", err) } @@ -80,7 +80,7 @@ func (sim *Simulation) makeTipSet(ctx context.Context, messages []*types.Message return nil, xerrors.Errorf("failed to create new tipset: %w", err) } now := time.Now() - _, _, err = sim.sm.TipSetState(ctx, newTipSet) + _, _, err = sim.StateManager.TipSetState(ctx, newTipSet) if err != nil { return nil, xerrors.Errorf("failed to compute new tipset: %w", err) } diff --git a/cmd/lotus-sim/simulation/node.go b/cmd/lotus-sim/simulation/node.go index 5046222f3..105c4c490 100644 --- a/cmd/lotus-sim/simulation/node.go +++ b/cmd/lotus-sim/simulation/node.go @@ -98,7 +98,7 @@ func (nd *Node) LoadSim(ctx context.Context, name string) (*Simulation, error) { if err != nil { return nil, xerrors.Errorf("failed to create upgrade schedule for simulation %s: %w", name, err) } - sim.sm, err = stmgr.NewStateManagerWithUpgradeSchedule(nd.Chainstore, us) + sim.StateManager, err = stmgr.NewStateManagerWithUpgradeSchedule(nd.Chainstore, us) if err != nil { return nil, xerrors.Errorf("failed to create state manager for simulation %s: %w", name, err) } @@ -114,9 +114,9 @@ func (nd *Node) CreateSim(ctx context.Context, name string, head *types.TipSet) return nil, xerrors.Errorf("simulation name %q cannot contain a '/'", name) } sim := &Simulation{ - name: name, - Node: nd, - sm: stmgr.NewStateManager(nd.Chainstore), + name: name, + Node: nd, + StateManager: stmgr.NewStateManager(nd.Chainstore), } if has, err := nd.MetadataDS.Has(sim.key("head")); err != nil { return nil, err diff --git a/cmd/lotus-sim/simulation/power.go b/cmd/lotus-sim/simulation/power.go index a86b691f3..f05dadf19 100644 --- a/cmd/lotus-sim/simulation/power.go +++ b/cmd/lotus-sim/simulation/power.go @@ -22,7 +22,7 @@ func (sim *Simulation) loadClaims(ctx context.Context, height abi.ChainEpoch) (m return nil, xerrors.Errorf("when projecting growth, failed to lookup lookback epoch: %w", err) } - powerActor, err := sim.sm.LoadActor(ctx, power.Address, ts) + powerActor, err := sim.StateManager.LoadActor(ctx, power.Address, ts) if err != nil { return nil, err } diff --git a/cmd/lotus-sim/simulation/precommit.go b/cmd/lotus-sim/simulation/precommit.go index 619ba467d..38b745a52 100644 --- a/cmd/lotus-sim/simulation/precommit.go +++ b/cmd/lotus-sim/simulation/precommit.go @@ -93,7 +93,7 @@ func (ss *simulationState) packPreCommits(ctx context.Context, cb packFunc) (ful func (ss *simulationState) packPreCommitsMiner(ctx context.Context, cb packFunc, minerAddr address.Address, count int) (int, bool, error) { // Load everything. epoch := ss.nextEpoch() - nv := ss.sm.GetNtwkVersion(ctx, epoch) + nv := ss.StateManager.GetNtwkVersion(ctx, epoch) actor, minerState, err := ss.getMinerState(ctx, minerAddr) if err != nil { return 0, false, err diff --git a/cmd/lotus-sim/simulation/provecommit.go b/cmd/lotus-sim/simulation/provecommit.go index 3bcc3a720..208af38a7 100644 --- a/cmd/lotus-sim/simulation/provecommit.go +++ b/cmd/lotus-sim/simulation/provecommit.go @@ -111,7 +111,7 @@ func (ss *simulationState) packProveCommitsMiner( return res, false, err } - nv := ss.sm.GetNtwkVersion(ctx, ss.nextEpoch()) + nv := ss.StateManager.GetNtwkVersion(ctx, ss.nextEpoch()) for sealType, snos := range pending { if nv >= network.Version13 { for len(snos) > minProveCommitBatchSize { @@ -260,7 +260,7 @@ func (ss *simulationState) loadProveCommitsMiner(ctx context.Context, addr addre // Find all pending prove commits and group by proof type. Really, there should never // (except during upgrades be more than one type. nextEpoch := ss.nextEpoch() - nv := ss.sm.GetNtwkVersion(ctx, nextEpoch) + nv := ss.StateManager.GetNtwkVersion(ctx, nextEpoch) av := actors.VersionForNetwork(nv) var total, dropped int @@ -294,7 +294,7 @@ func (ss *simulationState) filterProveCommits(ctx context.Context, minerAddr add } nextEpoch := ss.nextEpoch() - nv := ss.sm.GetNtwkVersion(ctx, nextEpoch) + nv := ss.StateManager.GetNtwkVersion(ctx, nextEpoch) av := actors.VersionForNetwork(nv) good := make([]abi.SectorNumber, 0, len(snos)) diff --git a/cmd/lotus-sim/simulation/simulation.go b/cmd/lotus-sim/simulation/simulation.go index 4b13f52f7..d33f3e94f 100644 --- a/cmd/lotus-sim/simulation/simulation.go +++ b/cmd/lotus-sim/simulation/simulation.go @@ -79,11 +79,11 @@ func (c *config) upgradeSchedule() (stmgr.UpgradeSchedule, error) { // Simulation specifies a lotus-sim simulation. type Simulation struct { *Node + StateManager *stmgr.StateManager name string config config start *types.TipSet - sm *stmgr.StateManager // head st *state.StateTree @@ -125,11 +125,11 @@ func (sim *Simulation) saveConfig() error { // The state-tree is cached until the head is changed. func (sim *Simulation) stateTree(ctx context.Context) (*state.StateTree, error) { if sim.st == nil { - st, _, err := sim.sm.TipSetState(ctx, sim.head) + st, _, err := sim.StateManager.TipSetState(ctx, sim.head) if err != nil { return nil, err } - sim.st, err = sim.sm.StateTree(st) + sim.st, err = sim.StateManager.StateTree(st) if err != nil { return nil, err } @@ -204,7 +204,7 @@ func (sim *Simulation) GetStart() *types.TipSet { // GetNetworkVersion returns the current network version for the simulation. func (sim *Simulation) GetNetworkVersion() network.Version { - return sim.sm.GetNtwkVersion(context.TODO(), sim.head.Height()) + return sim.StateManager.GetNtwkVersion(context.TODO(), sim.head.Height()) } // SetHead updates the current head of the simulation and stores it in the metadata store. This is @@ -256,7 +256,7 @@ func (sim *Simulation) SetUpgradeHeight(nv network.Version, epoch abi.ChainEpoch return err } - sim.sm = sm + sim.StateManager = sm return nil } diff --git a/cmd/lotus-sim/simulation/step.go b/cmd/lotus-sim/simulation/step.go index 0b92ed13e..9eddd039b 100644 --- a/cmd/lotus-sim/simulation/step.go +++ b/cmd/lotus-sim/simulation/step.go @@ -78,8 +78,8 @@ func (ss *simulationState) popNextMessages(ctx context.Context) ([]*types.Messag // This isn't what the network does, but it makes things easier. Otherwise, we'd need to run // migrations before this epoch and I'd rather not deal with that. nextHeight := parentTs.Height() + 1 - prevVer := ss.sm.GetNtwkVersion(ctx, nextHeight-1) - nextVer := ss.sm.GetNtwkVersion(ctx, nextHeight) + prevVer := ss.StateManager.GetNtwkVersion(ctx, nextHeight-1) + nextVer := ss.StateManager.GetNtwkVersion(ctx, nextHeight) if nextVer != prevVer { log.Warnw("packing no messages for version upgrade block", "old", prevVer, @@ -91,7 +91,7 @@ func (ss *simulationState) popNextMessages(ctx context.Context) ([]*types.Messag // Next, we compute the state for the parent tipset. In practice, this will likely be // cached. - parentState, _, err := ss.sm.TipSetState(ctx, parentTs) + parentState, _, err := ss.StateManager.TipSetState(ctx, parentTs) if err != nil { return nil, err } @@ -102,17 +102,17 @@ func (ss *simulationState) popNextMessages(ctx context.Context) ([]*types.Messag // 1. We don't charge a fee. // 2. The runtime has "fake" proof logic. // 3. We don't actually save any of the results. - r := store.NewChainRand(ss.sm.ChainStore(), parentTs.Cids()) + r := store.NewChainRand(ss.StateManager.ChainStore(), parentTs.Cids()) vmopt := &vm.VMOpts{ StateBase: parentState, Epoch: nextHeight, Rand: r, - Bstore: ss.sm.ChainStore().StateBlockstore(), - Syscalls: ss.sm.ChainStore().VMSys(), - CircSupplyCalc: ss.sm.GetVMCirculatingSupply, - NtwkVersion: ss.sm.GetNtwkVersion, + Bstore: ss.StateManager.ChainStore().StateBlockstore(), + Syscalls: ss.StateManager.ChainStore().VMSys(), + CircSupplyCalc: ss.StateManager.GetVMCirculatingSupply, + NtwkVersion: ss.StateManager.GetNtwkVersion, BaseFee: abi.NewTokenAmount(0), // FREE! - LookbackState: stmgr.LookbackStateGetterForTipset(ss.sm, parentTs), + LookbackState: stmgr.LookbackStateGetterForTipset(ss.StateManager, parentTs), } vmi, err := vm.NewVM(ctx, vmopt) if err != nil {