From df13cfa52b21ef344d397f13171974f192961262 Mon Sep 17 00:00:00 2001 From: Aayush Rajasekaran Date: Tue, 24 Mar 2020 04:43:09 -0400 Subject: [PATCH] Only resolve origin to pubkey address when creating a new account actor --- chain/vm/runtime.go | 3 ++- chain/vm/vm.go | 16 +--------------- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/chain/vm/runtime.go b/chain/vm/runtime.go index f29798da9..37e04f8c0 100644 --- a/chain/vm/runtime.go +++ b/chain/vm/runtime.go @@ -159,7 +159,8 @@ func (rs *Runtime) Store() vmr.Store { func (rt *Runtime) NewActorAddress() address.Address { var b bytes.Buffer - if err := rt.origin.MarshalCBOR(&b); err != nil { // todo: spec says cbor; why not just bytes? + oa, _ := ResolveToKeyAddr(rt.vm.cstate, rt.vm.cst, rt.origin) + if err := oa.MarshalCBOR(&b); err != nil { // todo: spec says cbor; why not just bytes? rt.Abortf(exitcode.ErrSerialization, "writing caller address into a buffer: %v", err) } diff --git a/chain/vm/vm.go b/chain/vm/vm.go index 2cea8900a..eb78d2ed0 100644 --- a/chain/vm/vm.go +++ b/chain/vm/vm.go @@ -66,14 +66,6 @@ type ExecutionResult struct { // Send allows the current execution context to invoke methods on other actors in the system -func ResolveToStableAddr(state types.StateTree, cst cbor.IpldStore, addr address.Address) (address.Address, aerrors.ActorError) { - if addr == builtin.SystemActorAddr { - return addr, nil - } - - return ResolveToKeyAddr(state, cst, addr) -} - // 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 { @@ -202,7 +194,7 @@ func (vm *VM) send(ctx context.Context, msg *types.Message, parent *Runtime, st := vm.cstate gasUsed := gasCharge - var origin address.Address + origin := msg.From on := msg.Nonce var nac uint64 = 0 if parent != nil { @@ -210,12 +202,6 @@ func (vm *VM) send(ctx context.Context, msg *types.Message, parent *Runtime, origin = parent.origin on = parent.originNonce nac = parent.numActorsCreated - } else { - var aerr aerrors.ActorError - origin, aerr = ResolveToStableAddr(vm.cstate, vm.cst, msg.From) - if aerr != nil { - return nil, aerr, nil - } } rt := vm.makeRuntime(ctx, msg, origin, on, gasUsed, nac)