Skip to content

Commit

Permalink
fix(gas): when estimating GasLimit only apply priors up to the nonce
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jakub Sztandera committed Jan 22, 2021
1 parent 29b076a commit 8c7fda4
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions node/impl/full/gas.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down

0 comments on commit 8c7fda4

Please sign in to comment.