Skip to content

Commit 0340339

Browse files
committed
Return proper error
1 parent a026648 commit 0340339

4 files changed

Lines changed: 7 additions & 1 deletion

File tree

‎core/chain_manager.go‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,8 @@ func (self *ChainManager) InsertChain(chain types.Blocks) error {
449449
*/
450450

451451
self.setTransState(state.New(block.Root(), self.stateDb))
452+
self.setTxState(state.New(block.Root(), self.stateDb))
453+
452454
queue[i] = ChainEvent{block}
453455
queueEvent.canonicalCount++
454456
} else {

‎core/error.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func (err *NonceErr) Error() string {
7878
}
7979

8080
func NonceError(is, exp uint64) *NonceErr {
81-
return &NonceErr{Message: fmt.Sprintf("Nonce err. Is %d, expected %d", is, exp), Is: is, Exp: exp}
81+
return &NonceErr{Message: fmt.Sprintf("Transaction w/ invalid nonce (%d / %d)", is, exp), Is: is, Exp: exp}
8282
}
8383

8484
func IsNonceErr(err error) bool {

‎core/state_transition.go‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,9 @@ func (self *StateTransition) preCheck() (err error) {
148148

149149
// Pre-pay gas / Buy gas of the coinbase account
150150
if err = self.BuyGas(); err != nil {
151+
if state.IsGasLimitErr(err) {
152+
return err
153+
}
151154
return InvalidTxError(err)
152155
}
153156

‎miner/worker.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ gasLimit:
212212
fallthrough
213213
case core.IsInvalidTxErr(err):
214214
// Remove invalid transactions
215+
self.chain.TxState().RemoveNonce(tx.From(), tx.Nonce())
215216
remove = append(remove, tx)
216217
case state.IsGasLimitErr(err):
217218
// Break on gas limit

0 commit comments

Comments
 (0)