fix state cid accounting after 'Transaction' calls
This commit is contained in:
parent
114cb2d2aa
commit
85e17fa5b0
@ -197,6 +197,13 @@ func (rt *Runtime) CreateActor(codeId cid.Cid, address address.Address) {
|
||||
}
|
||||
|
||||
func (rt *Runtime) DeleteActor() {
|
||||
act, err := rt.state.GetActor(rt.Message().Receiver())
|
||||
if err != nil {
|
||||
rt.Abortf(exitcode.SysErrInternal, "failed to load actor in delete actor: %s", err)
|
||||
}
|
||||
if !act.Balance.IsZero() {
|
||||
rt.Abortf(exitcode.SysErrInternal, "cannot delete actor with non-zero balance")
|
||||
}
|
||||
if err := rt.state.DeleteActor(rt.Message().Receiver()); err != nil {
|
||||
rt.Abortf(exitcode.SysErrInternal, "failed to delete actor: %s", err)
|
||||
}
|
||||
|
@ -56,6 +56,8 @@ type ExecutionResult struct {
|
||||
Msg *types.Message
|
||||
MsgRct *types.MessageReceipt
|
||||
Error string
|
||||
|
||||
Subcalls []*ExecutionResult
|
||||
}
|
||||
|
||||
// Storage interface
|
||||
@ -113,12 +115,11 @@ func (bs *gasChargingBlocks) Put(blk block.Block) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (vm *VM) makeRuntime(ctx context.Context, sroot cid.Cid, msg *types.Message, origin address.Address, usedGas types.BigInt) *Runtime {
|
||||
func (vm *VM) makeRuntime(ctx context.Context, msg *types.Message, origin address.Address, usedGas types.BigInt) *Runtime {
|
||||
rt := &Runtime{
|
||||
ctx: ctx,
|
||||
vm: vm,
|
||||
state: vm.cstate,
|
||||
sroot: sroot,
|
||||
msg: msg,
|
||||
origin: origin,
|
||||
height: vm.blockHeight,
|
||||
@ -209,7 +210,7 @@ func (vm *VM) send(ctx context.Context, msg *types.Message, parent *Runtime,
|
||||
gasUsed = types.BigAdd(parent.gasUsed, gasUsed)
|
||||
origin = parent.origin
|
||||
}
|
||||
rt := vm.makeRuntime(ctx, toActor.Head, msg, origin, gasUsed)
|
||||
rt := vm.makeRuntime(ctx, msg, origin, gasUsed)
|
||||
if parent != nil {
|
||||
defer func() {
|
||||
parent.gasUsed = rt.gasUsed
|
||||
@ -226,9 +227,6 @@ func (vm *VM) send(ctx context.Context, msg *types.Message, parent *Runtime,
|
||||
|
||||
if msg.Method != 0 {
|
||||
ret, err := vm.Invoke(toActor, rt, msg.Method, msg.Params)
|
||||
if !aerrors.IsFatal(err) {
|
||||
toActor.Head = rt.sroot
|
||||
}
|
||||
return ret, err, rt
|
||||
}
|
||||
|
||||
|
12
cli/state.go
12
cli/state.go
@ -23,6 +23,7 @@ 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"
|
||||
@ -799,15 +800,20 @@ var stateComputeStateCmd = &cli.Command{
|
||||
if cctx.Bool("show-trace") {
|
||||
for _, ir := range stout.Trace {
|
||||
fmt.Printf("%s\t%s\t%s\t%d\t%x\t%d\t%x\n", ir.Msg.From, ir.Msg.To, ir.Msg.Value, ir.Msg.Method, ir.Msg.Params, ir.MsgRct.ExitCode, ir.MsgRct.Return)
|
||||
for _, im := range ir.InternalExecutions {
|
||||
fmt.Printf("\t%s\t%s\t%s\t%d\t%x\t%d\t%x\n", im.Msg.From, im.Msg.To, im.Msg.Value, im.Msg.Method, im.Msg.Params, im.MsgRct.ExitCode, im.MsgRct.Return)
|
||||
}
|
||||
printInternalExecutions("\t", ir.InternalExecutions)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
func printInternalExecutions(prefix string, trace []*vm.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)
|
||||
}
|
||||
}
|
||||
|
||||
var stateWaitMsgCmd = &cli.Command{
|
||||
Name: "wait-msg",
|
||||
Usage: "Wait for a message to appear on chain",
|
||||
|
Loading…
Reference in New Issue
Block a user