StateSearchMsg: Correct usage of the allowReplaced flag

This commit is contained in:
Aayush Rajasekaran 2021-10-05 23:58:16 -04:00
parent 26ae8bb3a7
commit 441bcdc4af

View File

@ -252,22 +252,27 @@ func (sm *StateManager) tipsetExecutedMessage(ts *types.TipSet, msg cid.Cid, vmm
if m.VMMessage().From == vmm.From { // cheaper to just check origin first if m.VMMessage().From == vmm.From { // cheaper to just check origin first
if m.VMMessage().Nonce == vmm.Nonce { if m.VMMessage().Nonce == vmm.Nonce {
if allowReplaced && m.VMMessage().EqualCall(vmm) { if !m.VMMessage().EqualCall(vmm) {
if m.Cid() != msg { // this is an entirely different message, fail
log.Warnw("found message with equal nonce and call params but different CID", return nil, cid.Undef, xerrors.Errorf("found message with equal nonce as the one we are looking for that is NOT a valid replacement message (F:%s n %d, TS: %s n%d)",
"wanted", msg, "found", m.Cid(), "nonce", vmm.Nonce, "from", vmm.From) msg, vmm.Nonce, m.Cid(), m.VMMessage().Nonce)
}
pr, err := sm.cs.GetParentReceipt(ts.Blocks()[0], i)
if err != nil {
return nil, cid.Undef, err
}
return pr, m.Cid(), nil
} }
// this should be that message if m.Cid() != msg {
return nil, cid.Undef, xerrors.Errorf("found message with equal nonce as the one we are looking for (F:%s n %d, TS: %s n%d)", if !allowReplaced {
msg, vmm.Nonce, m.Cid(), m.VMMessage().Nonce) log.Warnw("found message with equal nonce and call params but different CID",
"wanted", msg, "found", m.Cid(), "nonce", vmm.Nonce, "from", vmm.From)
return nil, cid.Undef, xerrors.Errorf("found message with equal nonce as the one we are looking for (F:%s n %d, TS: %s n%d)",
msg, vmm.Nonce, m.Cid(), m.VMMessage().Nonce)
}
}
pr, err := sm.cs.GetParentReceipt(ts.Blocks()[0], i)
if err != nil {
return nil, cid.Undef, err
}
return pr, m.Cid(), nil
} }
if m.VMMessage().Nonce < vmm.Nonce { if m.VMMessage().Nonce < vmm.Nonce {
return nil, cid.Undef, nil // don't bother looking further return nil, cid.Undef, nil // don't bother looking further