From 8c7fda44416194446b66f7cee76fdb65981b5926 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 6cf189f1265..ec7074e5bdd 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) }