Skip to content

Commit

Permalink
make StateCompute not write the output state to the blockstore.
Browse files Browse the repository at this point in the history
  • Loading branch information
raulk committed Mar 11, 2023
1 parent 9d994da commit 5494d73
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
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

0 comments on commit 5494d73

Please sign in to comment.