fix(gas): when estimating GasLimit only apply priors up to the nonce

The bug is applying all messages from given From address are priors
before appling the message that we are estimating.

If user tries replacing message in the middle with gas limit estimation
then message sequence is off and user will either get an execution error
or gas mis-esimation.

Resolves #5402

Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
This commit is contained in:
Jakub Sztandera 2021-01-22 18:47:10 +01:00
parent 29b076ad69
commit 8c7fda4441
No known key found for this signature in database
GPG Key ID: 9A9AF56F8B3879BA

View File

@ -229,6 +229,9 @@ func gasEstimateGasLimit(
pending, ts := mpool.PendingFor(fromA)
priorMsgs := make([]types.ChainMsg, 0, len(pending))
for _, m := range pending {
if m.Message.Nonce == msg.Nonce {
break
}
priorMsgs = append(priorMsgs, m)
}