From 322f34c6c6029c705b4129d6f3fc240a214972e5 Mon Sep 17 00:00:00 2001 From: Aayush Rajasekaran Date: Wed, 18 Nov 2020 01:52:46 -0500 Subject: [PATCH] Tweak handling of bad beneficaries in DeleteActor --- chain/vm/runtime.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/chain/vm/runtime.go b/chain/vm/runtime.go index ef69ca103..a7e666d2f 100644 --- a/chain/vm/runtime.go +++ b/chain/vm/runtime.go @@ -281,9 +281,19 @@ func (rt *Runtime) DeleteActor(beneficiary address.Address) { panic(aerrors.Fatalf("failed to get actor: %s", err)) } if !act.Balance.IsZero() { - if beneficiary == rt.Receiver() && rt.NetworkVersion() >= network.Version7 { - rt.Abortf(exitcode.SysErrorIllegalArgument, "benefactor cannot be beneficiary") + // TODO: Should be safe to drop the version-check, + // since only the paych actor called this pre-version 7, but let's leave it for now + if rt.NetworkVersion() >= network.Version7 { + beneficiaryId, found := rt.ResolveAddress(beneficiary) + if !found { + rt.Abortf(exitcode.SysErrorIllegalArgument, "beneficiary doesn't exist") + } + + if beneficiaryId == rt.Receiver() { + rt.Abortf(exitcode.SysErrorIllegalArgument, "benefactor cannot be beneficiary") + } } + // Transfer the executing actor's balance to the beneficiary if err := rt.vm.transfer(rt.Receiver(), beneficiary, act.Balance); err != nil { panic(aerrors.Fatalf("failed to transfer balance to beneficiary actor: %s", err))