2019-07-12 10:43:15 +00:00
|
|
|
package types
|
|
|
|
|
|
|
|
import (
|
2019-10-13 09:08:34 +00:00
|
|
|
"context"
|
2020-01-13 20:47:27 +00:00
|
|
|
"github.com/filecoin-project/go-sectorbuilder"
|
2019-10-13 09:08:34 +00:00
|
|
|
|
2019-12-19 20:13:17 +00:00
|
|
|
"github.com/filecoin-project/go-address"
|
2019-11-22 16:41:09 +00:00
|
|
|
"github.com/filecoin-project/go-amt-ipld"
|
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"
|
|
|
|
hamt "github.com/ipfs/go-hamt-ipld"
|
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
|
2019-07-12 10:43:15 +00:00
|
|
|
Ipld() *hamt.CborIpldStore
|
2019-07-22 16:08:54 +00:00
|
|
|
Send(to address.Address, method uint64, value BigInt, params []byte) ([]byte, aerrors.ActorError)
|
2019-07-12 10:43:15 +00:00
|
|
|
BlockHeight() uint64
|
|
|
|
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
|
2019-09-19 13:32:00 +00:00
|
|
|
GetRandomness(height uint64) ([]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-01-13 20:47:27 +00:00
|
|
|
ValidatePoRep func(context.Context, address.Address, uint64, []byte, []byte, []byte, []byte, []byte, uint64) (bool, aerrors.ActorError)
|
|
|
|
VerifyFallbackPost func(ctx context.Context,
|
|
|
|
sectorSize uint64,
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
func WrapStorage(s Storage) amt.Blocks {
|
|
|
|
return &storageWrapper{s}
|
|
|
|
}
|