Only charge for actor creation after making a meaningful state change
This commit is contained in:
parent
d7d2b12a32
commit
bd1ac4d91b
@ -2,7 +2,6 @@ package vm
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/chain/actors"
|
"github.com/filecoin-project/lotus/chain/actors"
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi/big"
|
"github.com/filecoin-project/specs-actors/actors/abi/big"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin"
|
"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")
|
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)
|
act, aerr := makeActor(addr)
|
||||||
if aerr != nil {
|
if aerr != nil {
|
||||||
return nil, aerr
|
return nil, aerr
|
||||||
@ -55,6 +50,10 @@ func TryCreateAccountActor(rt *Runtime, addr address.Address) (*types.Actor, aer
|
|||||||
}
|
}
|
||||||
// call constructor on account
|
// 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)
|
_, aerr = rt.internalSend(builtin.SystemActorAddr, addrID, builtin.MethodsAccount.Constructor, big.Zero(), p)
|
||||||
if aerr != nil {
|
if aerr != nil {
|
||||||
return nil, aerrors.Wrap(aerr, "failed to invoke account constructor")
|
return nil, aerrors.Wrap(aerr, "failed to invoke account constructor")
|
||||||
|
Loading…
Reference in New Issue
Block a user