vm: Fix getActorCode
This commit is contained in:
parent
d0c158b019
commit
038582ba44
@ -39,6 +39,7 @@ type VMContext interface {
|
||||
GasUsed() BigInt
|
||||
Storage() Storage
|
||||
StateTree() (StateTree, aerrors.ActorError)
|
||||
ActorCodeCID(address.Address) (cid.Cid, error)
|
||||
VerifySignature(sig *crypto.Signature, from address.Address, data []byte) aerrors.ActorError
|
||||
ChargeGas(uint64) aerrors.ActorError
|
||||
GetRandomness(height abi.ChainEpoch) ([]byte, aerrors.ActorError)
|
||||
|
@ -91,18 +91,13 @@ func (rs *runtimeShim) CurrentBalance() abi.TokenAmount {
|
||||
}
|
||||
|
||||
func (rs *runtimeShim) GetActorCodeCID(addr address.Address) (ret cid.Cid, ok bool) {
|
||||
var err error
|
||||
st, err := rs.vmctx.StateTree()
|
||||
if err != nil {
|
||||
rs.Abortf(exitcode.ErrPlaceholder, "%v", err)
|
||||
}
|
||||
|
||||
act, err := st.GetActor(addr)
|
||||
ret, err := rs.vmctx.ActorCodeCID(addr)
|
||||
if err != nil {
|
||||
// todo: notfound
|
||||
rs.Abortf(exitcode.ErrPlaceholder, "%v", err)
|
||||
}
|
||||
return act.Code, true
|
||||
|
||||
return ret, true
|
||||
}
|
||||
|
||||
func (rs *runtimeShim) GetRandomness(personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte) abi.Randomness {
|
||||
|
@ -20,6 +20,7 @@ import (
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
"github.com/filecoin-project/go-address"
|
||||
|
||||
"github.com/filecoin-project/lotus/build"
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
"github.com/filecoin-project/lotus/chain/actors/aerrors"
|
||||
@ -186,6 +187,14 @@ func (vmc *VMContext) StateTree() (types.StateTree, aerrors.ActorError) {
|
||||
return vmc.state, nil
|
||||
}
|
||||
|
||||
func (vmc *VMContext) ActorCodeCID(addr address.Address) (ret cid.Cid, err error) {
|
||||
act, err := vmc.state.GetActor(addr)
|
||||
if err != nil {
|
||||
return cid.Undef, err
|
||||
}
|
||||
return act.Code, nil
|
||||
}
|
||||
|
||||
const GasVerifySignature = 50
|
||||
|
||||
func (vmctx *VMContext) VerifySignature(sig *crypto.Signature, act address.Address, data []byte) aerrors.ActorError {
|
||||
|
Loading…
Reference in New Issue
Block a user