From 17e9feb633e655edbd36cfccd544856d3b31d1fb Mon Sep 17 00:00:00 2001 From: Aayush Rajasekaran Date: Wed, 8 Apr 2020 18:27:31 -0400 Subject: [PATCH] Sever the API's dependency on VM --- api/api_full.go | 3 +-- chain/types/execresult.go | 9 +++++++++ chain/types/invokeret.go | 6 ------ chain/vm/runtime.go | 4 ++-- chain/vm/vm.go | 32 +------------------------------- cli/state.go | 3 +-- 6 files changed, 14 insertions(+), 43 deletions(-) create mode 100644 chain/types/execresult.go delete mode 100644 chain/types/invokeret.go diff --git a/api/api_full.go b/api/api_full.go index 3127e0915..0556c2fe0 100644 --- a/api/api_full.go +++ b/api/api_full.go @@ -20,7 +20,6 @@ import ( "github.com/filecoin-project/lotus/chain/store" "github.com/filecoin-project/lotus/chain/types" - "github.com/filecoin-project/lotus/chain/vm" "github.com/filecoin-project/lotus/node/modules/dtypes" ) @@ -313,7 +312,7 @@ type RetrievalOrder struct { type InvocResult struct { Msg *types.Message MsgRct *types.MessageReceipt - InternalExecutions []*vm.ExecutionResult + InternalExecutions []*types.ExecutionResult Error string Duration time.Duration } diff --git a/chain/types/execresult.go b/chain/types/execresult.go new file mode 100644 index 000000000..e8765f796 --- /dev/null +++ b/chain/types/execresult.go @@ -0,0 +1,9 @@ +package types + +type ExecutionResult struct { + Msg *Message + MsgRct *MessageReceipt + Error string + + Subcalls []*ExecutionResult +} diff --git a/chain/types/invokeret.go b/chain/types/invokeret.go deleted file mode 100644 index 030b728ae..000000000 --- a/chain/types/invokeret.go +++ /dev/null @@ -1,6 +0,0 @@ -package types - -type InvokeRet struct { - Result []byte - ReturnCode byte -} diff --git a/chain/vm/runtime.go b/chain/vm/runtime.go index fcb8877e4..14309d3ea 100644 --- a/chain/vm/runtime.go +++ b/chain/vm/runtime.go @@ -48,7 +48,7 @@ type Runtime struct { origin address.Address originNonce uint64 - internalExecutions []*ExecutionResult + internalExecutions []*types.ExecutionResult numActorsCreated uint64 } @@ -337,7 +337,7 @@ func (rt *Runtime) internalSend(from, to address.Address, method abi.MethodNum, GasUsed: 0, } - er := ExecutionResult{ + er := types.ExecutionResult{ Msg: msg, MsgRct: &mr, } diff --git a/chain/vm/vm.go b/chain/vm/vm.go index 90a89ba28..c862e40b9 100644 --- a/chain/vm/vm.go +++ b/chain/vm/vm.go @@ -36,36 +36,6 @@ import ( var log = logging.Logger("vm") -const ( - gasFundTransfer = 10 - gasInvoke = 5 - - gasGetObj = 10 - gasGetPerByte = 1 - gasPutObj = 20 - gasPutPerByte = 2 - gasCommit = 50 - gasPerMessageByte = 2 -) - -const ( - outOfGasErrCode = 200 -) - -type ExecutionResult struct { - Msg *types.Message - MsgRct *types.MessageReceipt - Error string - - Subcalls []*ExecutionResult -} - -// Storage interface - -// End of storage interface - -// Send allows the current execution context to invoke methods on other actors in the system - // ResolveToKeyAddr returns the public key type of address (`BLS`/`SECP256K1`) of an account actor identified by `addr`. func ResolveToKeyAddr(state types.StateTree, cst cbor.IpldStore, addr address.Address) (address.Address, aerrors.ActorError) { if addr.Protocol() == address.BLS || addr.Protocol() == address.SECP256K1 { @@ -195,7 +165,7 @@ type ApplyRet struct { types.MessageReceipt ActorErr aerrors.ActorError Penalty types.BigInt - InternalExecutions []*ExecutionResult + InternalExecutions []*types.ExecutionResult Duration time.Duration } diff --git a/cli/state.go b/cli/state.go index 344d3687d..da5cb8c09 100644 --- a/cli/state.go +++ b/cli/state.go @@ -23,7 +23,6 @@ import ( "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/chain/types" - "github.com/filecoin-project/lotus/chain/vm" "github.com/filecoin-project/lotus/miner" "github.com/docker/go-units" @@ -808,7 +807,7 @@ var stateComputeStateCmd = &cli.Command{ }, } -func printInternalExecutions(prefix string, trace []*vm.ExecutionResult) { +func printInternalExecutions(prefix string, trace []*types.ExecutionResult) { for _, im := range trace { fmt.Printf("%s%s\t%s\t%s\t%d\t%x\t%d\t%x\n", prefix, im.Msg.From, im.Msg.To, im.Msg.Value, im.Msg.Method, im.Msg.Params, im.MsgRct.ExitCode, im.MsgRct.Return) printInternalExecutions(prefix+"\t", im.Subcalls)