From bd1ac4d91b57029c2c37747587261a23bb47eb36 Mon Sep 17 00:00:00 2001 From: Aayush Rajasekaran Date: Wed, 29 Apr 2020 23:21:19 -0400 Subject: [PATCH] Only charge for actor creation after making a meaningful state change --- chain/vm/mkactor.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/chain/vm/mkactor.go b/chain/vm/mkactor.go index 5433682eb..44d9610cd 100644 --- a/chain/vm/mkactor.go +++ b/chain/vm/mkactor.go @@ -2,7 +2,6 @@ package vm import ( "context" - "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/specs-actors/actors/abi/big" "github.com/filecoin-project/specs-actors/actors/builtin" @@ -35,10 +34,6 @@ func TryCreateAccountActor(rt *Runtime, addr address.Address) (*types.Actor, aer return nil, aerrors.Escalate(err, "registering actor address") } - if err := rt.chargeGasSafe(PricelistByEpoch(rt.height).OnCreateActor()); err != nil { - return nil, err - } - act, aerr := makeActor(addr) if aerr != nil { return nil, aerr @@ -55,6 +50,10 @@ func TryCreateAccountActor(rt *Runtime, addr address.Address) (*types.Actor, aer } // call constructor on account + if err := rt.chargeGasSafe(PricelistByEpoch(rt.height).OnCreateActor()); err != nil { + return nil, err + } + _, aerr = rt.internalSend(builtin.SystemActorAddr, addrID, builtin.MethodsAccount.Constructor, big.Zero(), p) if aerr != nil { return nil, aerrors.Wrap(aerr, "failed to invoke account constructor")