You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: node.go
    path of file: ./repos/lotus/cmd/lotus-sim/simulation
    
    the code of the file until where you have to start completion: package simulation

import (
	"context"
	"strings"

	"github.com/ipfs/go-datastore"
	"github.com/ipfs/go-datastore/query"
	"go.uber.org/multierr"
	"golang.org/x/xerrors"

	"github.com/filecoin-project/lotus/blockstore"
	"github.com/filecoin-project/lotus/chain/consensus"
	"github.com/filecoin-pro
    
func (nd *Node) CreateSim(ctx context.Context, name string, head *types.TipSet) (*Simulation, error) {
	if strings.Contains(name, "/") {
		return nil, xerrors.Errorf("simulation name %q cannot contain a '/'", name)
	}
	stages, err := stages.DefaultPipeline()
	if err != nil {
		return nil, err
	}
	sm, err := stmgr.NewStateManager(nd.Chainstore, consensus.NewTipSetExecutor(filcns.RewardFunc), vm.Syscalls(mock.Verifier), filcns.DefaultUpgradeSchedule(), nil, nd.MetadataDS, index.DummyMsgIndex)
	if err != nil {
		return nil, xerrors.Errorf("creating state manager: %w", err)
	}
	sim := &Simulation{
		name:         name,
		Node:         nd,
		StateManager: sm,
		stages:       stages,
	}
	if has, err := nd.MetadataDS.Has(ctx, sim.key("head")); err != nil {
		return nil, err
	} else if has {
		return nil, xerrors.Errorf("simulation named %s already exists", name)
	}

	if err := sim.storeNamedTipSet("start", head); err != nil {
		return nil, xerrors.Errorf("failed to set simulation start: %w", err)
	}

	if err := sim.SetHead(head); err != nil {
		return nil, err
	}

	return sim, nil
}