Skip to content
This repository has been archived by the owner on Jun 6, 2023. It is now read-only.

Commit

Permalink
compute the hash of the proposal iff the proposal hash is present
Browse files Browse the repository at this point in the history
Previously, we'd always compute the hash but only _compare_ it if it
was specified. This simply increased the cost of messages that didn't
specify the hash for no good reason.

fixes #1364
  • Loading branch information
Stebalien committed Jan 24, 2021
1 parent c7ea991 commit 0167588
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions actors/builtin/multisig/multisig_actor.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ func (a Actor) Approve(rt runtime.Runtime, params *TxnIDParams) *ApproveReturn {
ptx, err := adt.AsMap(adt.AsStore(rt), st.PendingTxns, builtin.DefaultHamtBitwidth)
builtin.RequireNoErr(rt, err, exitcode.ErrIllegalState, "failed to load pending transactions")

txn = getTransaction(rt, ptx, params.ID, params.ProposalHash, true)
txn = getTransaction(rt, ptx, params.ID, params.ProposalHash)
})

// if the transaction already has enough approvers, execute it without "processing" this approval.
Expand Down Expand Up @@ -500,7 +500,7 @@ func (a Actor) approveTransaction(rt runtime.Runtime, txnID TxnID, txn *Transact
return executeTransactionIfApproved(rt, st, txnID, txn)
}

func getTransaction(rt runtime.Runtime, ptx *adt.Map, txnID TxnID, proposalHash []byte, checkHash bool) *Transaction {
func getTransaction(rt runtime.Runtime, ptx *adt.Map, txnID TxnID, proposalHash []byte) *Transaction {
// get transaction from the state trie
var txn Transaction
found, err := ptx.Get(txnID, &txn)
Expand All @@ -509,11 +509,11 @@ func getTransaction(rt runtime.Runtime, ptx *adt.Map, txnID TxnID, proposalHash
rt.Abortf(exitcode.ErrNotFound, "no such transaction %v for approval", txnID)
}

// confirm the hashes match
if checkHash {
// confirm the hashes match, if present.
if proposalHash != nil {
calculatedHash, err := ComputeProposalHash(&txn, rt.HashBlake2b)
builtin.RequireNoErr(rt, err, exitcode.ErrIllegalState, "failed to compute proposal hash for %v", txnID)
if proposalHash != nil && !bytes.Equal(proposalHash, calculatedHash[:]) {
if !bytes.Equal(proposalHash, calculatedHash[:]) {
rt.Abortf(exitcode.ErrIllegalArgument, "hash does not match proposal params (ensure requester is an ID address)")
}
}
Expand Down

0 comments on commit 0167588

Please sign in to comment.