Skip to content

Commit

Permalink
Merge pull request #4903 from filecoin-project/asr/delete-fix
Browse files Browse the repository at this point in the history
Tweak handling of bad beneficaries in DeleteActor
  • Loading branch information
magik6k authored Nov 18, 2020
2 parents 8575f55 + 322f34c commit 09c996d
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions chain/vm/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 09c996d

Please sign in to comment.