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

Speed up worker key retrieval #4885

Merged
merged 1 commit into from
Nov 17, 2020
Merged
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
24 changes: 18 additions & 6 deletions chain/vm/syscalls.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import (
goruntime "runtime"
"sync"

"github.com/filecoin-project/go-state-types/network"

"github.com/filecoin-project/lotus/chain/actors/policy"

"github.com/filecoin-project/go-address"
"github.com/ipfs/go-cid"
cbor "github.com/ipfs/go-ipld-cbor"
Expand Down Expand Up @@ -40,7 +44,9 @@ func Syscalls(verifier ffiwrapper.Verifier) SyscallBuilder {
return func(ctx context.Context, rt *Runtime) runtime2.Syscalls {

return &syscallShim{
ctx: ctx,
ctx: ctx,
epoch: rt.CurrEpoch(),
networkVersion: rt.NetworkVersion(),

actor: rt.Receiver(),
cstate: rt.state,
Expand All @@ -55,11 +61,13 @@ func Syscalls(verifier ffiwrapper.Verifier) SyscallBuilder {
type syscallShim struct {
ctx context.Context

lbState LookbackStateGetter
actor address.Address
cstate *state.StateTree
cst cbor.IpldStore
verifier ffiwrapper.Verifier
epoch abi.ChainEpoch
networkVersion network.Version
lbState LookbackStateGetter
actor address.Address
cstate *state.StateTree
cst cbor.IpldStore
verifier ffiwrapper.Verifier
}

func (ss *syscallShim) ComputeUnsealedSectorCID(st abi.RegisteredSealProof, pieces []abi.PieceInfo) (cid.Cid, error) {
Expand Down Expand Up @@ -202,6 +210,10 @@ func (ss *syscallShim) VerifyBlockSig(blk *types.BlockHeader) error {
}

func (ss *syscallShim) workerKeyAtLookback(height abi.ChainEpoch) (address.Address, error) {
if ss.networkVersion >= network.Version7 && height < ss.epoch-policy.ChainFinality {
return address.Undef, xerrors.Errorf("cannot get worker key (currEpoch %d, height %d)", ss.epoch, height)
}

lbState, err := ss.lbState(ss.ctx, height)
if err != nil {
return address.Undef, err
Expand Down