Merge pull request #4885 from filecoin-project/asr/worker-key
Speed up worker key retrieval
This commit is contained in:
commit
c8d985b5c7
@ -7,6 +7,10 @@ import (
|
|||||||
goruntime "runtime"
|
goruntime "runtime"
|
||||||
"sync"
|
"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/filecoin-project/go-address"
|
||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
cbor "github.com/ipfs/go-ipld-cbor"
|
cbor "github.com/ipfs/go-ipld-cbor"
|
||||||
@ -40,7 +44,9 @@ func Syscalls(verifier ffiwrapper.Verifier) SyscallBuilder {
|
|||||||
return func(ctx context.Context, rt *Runtime) runtime2.Syscalls {
|
return func(ctx context.Context, rt *Runtime) runtime2.Syscalls {
|
||||||
|
|
||||||
return &syscallShim{
|
return &syscallShim{
|
||||||
ctx: ctx,
|
ctx: ctx,
|
||||||
|
epoch: rt.CurrEpoch(),
|
||||||
|
networkVersion: rt.NetworkVersion(),
|
||||||
|
|
||||||
actor: rt.Receiver(),
|
actor: rt.Receiver(),
|
||||||
cstate: rt.state,
|
cstate: rt.state,
|
||||||
@ -55,11 +61,13 @@ func Syscalls(verifier ffiwrapper.Verifier) SyscallBuilder {
|
|||||||
type syscallShim struct {
|
type syscallShim struct {
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
|
|
||||||
lbState LookbackStateGetter
|
epoch abi.ChainEpoch
|
||||||
actor address.Address
|
networkVersion network.Version
|
||||||
cstate *state.StateTree
|
lbState LookbackStateGetter
|
||||||
cst cbor.IpldStore
|
actor address.Address
|
||||||
verifier ffiwrapper.Verifier
|
cstate *state.StateTree
|
||||||
|
cst cbor.IpldStore
|
||||||
|
verifier ffiwrapper.Verifier
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ss *syscallShim) ComputeUnsealedSectorCID(st abi.RegisteredSealProof, pieces []abi.PieceInfo) (cid.Cid, error) {
|
func (ss *syscallShim) ComputeUnsealedSectorCID(st abi.RegisteredSealProof, pieces []abi.PieceInfo) (cid.Cid, error) {
|
||||||
@ -202,6 +210,10 @@ func (ss *syscallShim) VerifyBlockSig(blk *types.BlockHeader) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ss *syscallShim) workerKeyAtLookback(height abi.ChainEpoch) (address.Address, 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)
|
lbState, err := ss.lbState(ss.ctx, height)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return address.Undef, err
|
return address.Undef, err
|
||||||
|
Loading…
Reference in New Issue
Block a user