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

make StateCompute not write the output state to the blockstore. #10453

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion api/api_full.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"github.com/google/uuid"
"github.com/ipfs/go-cid"
blocks "github.com/ipfs/go-libipfs/blocks"
"github.com/ipfs/go-libipfs/blocks"
"github.com/libp2p/go-libp2p/core/peer"

"github.com/filecoin-project/go-address"
Expand Down Expand Up @@ -606,6 +606,9 @@ type FullNode interface {
//
// Messages in the `apply` parameter must have the correct nonces, and gas
// values set.
//
// This method does not write the resulting state to the blockstore. Usually
// that state will already exist.
StateCompute(context.Context, abi.ChainEpoch, []*types.Message, types.TipSetKey) (*ComputeStateOutput, error) //perm:read
// StateVerifierStatus returns the data cap for the given address.
// Returns nil if there is no entry in the data cap table for the
Expand Down
4 changes: 3 additions & 1 deletion chain/stmgr/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
gstStore "github.com/filecoin-project/go-state-types/store"

"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/blockstore"
init_ "github.com/filecoin-project/lotus/chain/actors/builtin/init"
"github.com/filecoin-project/lotus/chain/actors/builtin/system"
"github.com/filecoin-project/lotus/chain/actors/policy"
Expand Down Expand Up @@ -86,13 +87,14 @@ func ComputeState(ctx context.Context, sm *StateManager, height abi.ChainEpoch,
// future. It's not guaranteed to be accurate... but that's fine.
}

buf := blockstore.NewBuffered(sm.cs.StateBlockstore())
r := rand.NewStateRand(sm.cs, ts.Cids(), sm.beacon, sm.GetNetworkVersion)
vmopt := &vm.VMOpts{
StateBase: base,
Epoch: height,
Timestamp: ts.MinTimestamp(),
Rand: r,
Bstore: sm.cs.StateBlockstore(),
Bstore: buf,
Actors: sm.tsExec.NewActorRegistry(),
Syscalls: sm.Syscalls,
CircSupplyCalc: sm.GetVMCirculatingSupply,
Expand Down
4 changes: 4 additions & 0 deletions cmd/lotus-shed/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ var computeStateRangeCmd = &cli.Command{
return err
}

// StateCompute doesn't write the resulting state to the blockstore,
// hence state write overheads that would otherwise apply during block
// validation will not be observed here.

fmt.Printf("computing tipset at height %d (start)\n", startTs.Height())
if _, err := api.StateCompute(ctx, startTs.Height(), nil, startTs.Key()); err != nil {
return err
Expand Down