From 91721de2ff3b4ed0de6de4e82dcf6f9fffdac3fb Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Fri, 22 Jan 2021 18:47:10 +0100 Subject: [PATCH] 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 --- node/impl/full/gas.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/node/impl/full/gas.go b/node/impl/full/gas.go index 1e5dcfd0524..cfd8bc6f4cf 100644 --- a/node/impl/full/gas.go +++ b/node/impl/full/gas.go @@ -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) }