2019-07-12 10:43:15 +00:00
|
|
|
package types
|
|
|
|
|
|
|
|
import (
|
2019-10-13 09:08:34 +00:00
|
|
|
"context"
|
2020-01-22 21:29:19 +00:00
|
|
|
|
2020-01-13 20:47:27 +00:00
|
|
|
"github.com/filecoin-project/go-sectorbuilder"
|
2020-02-08 02:18:32 +00:00
|
|
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
2019-10-13 09:08:34 +00:00
|
|
|
|
2019-12-19 20:13:17 +00:00
|
|
|
"github.com/filecoin-project/go-address"
|
2019-10-18 04:47:41 +00:00
|
|
|
"github.com/filecoin-project/lotus/chain/actors/aerrors"
|
2019-09-12 04:12:35 +00:00
|
|
|
cid "github.com/ipfs/go-cid"
|
2020-02-04 22:19:05 +00:00
|
|
|
cbor "github.com/ipfs/go-ipld-cbor"
|
2019-09-10 19:58:45 +00:00
|
|
|
cbg "github.com/whyrusleeping/cbor-gen"
|
2019-07-12 10:43:15 +00:00
|
|
|
)
|
|
|
|
|
2019-07-12 03:59:55 +00:00
|
|
|
type Storage interface {
|
2019-09-10 19:58:45 +00:00
|
|
|
Put(cbg.CBORMarshaler) (cid.Cid, aerrors.ActorError)
|
|
|
|
Get(cid.Cid, cbg.CBORUnmarshaler) aerrors.ActorError
|
2019-07-12 03:59:55 +00:00
|
|
|
|
|
|
|
GetHead() cid.Cid
|
|
|
|
|
|
|
|
// Commit sets the new head of the actors state as long as the current
|
|
|
|
// state matches 'oldh'
|
2019-07-22 16:08:54 +00:00
|
|
|
Commit(oldh cid.Cid, newh cid.Cid) aerrors.ActorError
|
2019-07-12 03:59:55 +00:00
|
|
|
}
|
|
|
|
|
2019-07-12 16:40:58 +00:00
|
|
|
type StateTree interface {
|
2019-07-22 18:17:42 +00:00
|
|
|
SetActor(addr address.Address, act *Actor) error
|
|
|
|
GetActor(addr address.Address) (*Actor, error)
|
2019-07-12 16:40:58 +00:00
|
|
|
}
|
|
|
|
|
2019-07-12 10:43:15 +00:00
|
|
|
type VMContext interface {
|
|
|
|
Message() *Message
|
2019-07-16 16:40:25 +00:00
|
|
|
Origin() address.Address
|
2020-02-04 22:19:05 +00:00
|
|
|
Ipld() cbor.IpldStore
|
2020-02-11 01:43:26 +00:00
|
|
|
Send(to address.Address, method abi.MethodNum, value BigInt, params []byte) ([]byte, aerrors.ActorError)
|
2020-02-08 02:18:32 +00:00
|
|
|
BlockHeight() abi.ChainEpoch
|
2019-07-12 10:43:15 +00:00
|
|
|
GasUsed() BigInt
|
2019-07-12 03:59:55 +00:00
|
|
|
Storage() Storage
|
2019-07-22 16:08:54 +00:00
|
|
|
StateTree() (StateTree, aerrors.ActorError)
|
2019-08-09 21:41:50 +00:00
|
|
|
VerifySignature(sig *Signature, from address.Address, data []byte) aerrors.ActorError
|
2019-08-15 16:23:28 +00:00
|
|
|
ChargeGas(uint64) aerrors.ActorError
|
2020-02-08 02:18:32 +00:00
|
|
|
GetRandomness(height abi.ChainEpoch) ([]byte, aerrors.ActorError)
|
2019-09-12 04:12:35 +00:00
|
|
|
GetBalance(address.Address) (BigInt, aerrors.ActorError)
|
2019-12-06 14:06:42 +00:00
|
|
|
Sys() *VMSyscalls
|
2019-10-13 09:08:34 +00:00
|
|
|
|
|
|
|
Context() context.Context
|
2019-07-12 10:43:15 +00:00
|
|
|
}
|
2019-08-29 00:01:46 +00:00
|
|
|
|
2019-12-06 14:06:42 +00:00
|
|
|
type VMSyscalls struct {
|
2020-02-08 02:18:32 +00:00
|
|
|
ValidatePoRep func(context.Context, address.Address, abi.SectorSize, []byte, []byte, []byte, []byte, []byte, abi.SectorNumber) (bool, aerrors.ActorError)
|
2020-01-13 20:47:27 +00:00
|
|
|
VerifyFallbackPost func(ctx context.Context,
|
2020-02-08 02:18:32 +00:00
|
|
|
sectorSize abi.SectorSize,
|
2020-01-13 20:47:27 +00:00
|
|
|
sectorInfo sectorbuilder.SortedPublicSectorInfo,
|
|
|
|
challengeSeed []byte,
|
|
|
|
proof []byte,
|
|
|
|
candidates []sectorbuilder.EPostCandidate,
|
|
|
|
proverID address.Address,
|
|
|
|
faults uint64) (bool, error)
|
2019-12-06 14:06:42 +00:00
|
|
|
}
|
|
|
|
|
2019-08-29 00:01:46 +00:00
|
|
|
type storageWrapper struct {
|
|
|
|
s Storage
|
|
|
|
}
|
|
|
|
|
2019-11-22 16:41:09 +00:00
|
|
|
func (sw *storageWrapper) Put(i cbg.CBORMarshaler) (cid.Cid, error) {
|
|
|
|
c, err := sw.s.Put(i)
|
2019-08-29 00:01:46 +00:00
|
|
|
if err != nil {
|
|
|
|
return cid.Undef, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return c, nil
|
|
|
|
}
|
|
|
|
|
2019-11-22 16:41:09 +00:00
|
|
|
func (sw *storageWrapper) Get(c cid.Cid, out cbg.CBORUnmarshaler) error {
|
|
|
|
if err := sw.s.Get(c, out); err != nil {
|
2019-08-29 00:01:46 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|