From d83a9a8f4429176fc6cc7974c08ce988c879a6bf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= <peterke@gmail.com>
Date: Thu, 6 Apr 2017 12:22:14 +0300
Subject: miner: don't verify our own blocks, trust the engine

---
 miner/worker.go | 10 ----------
 1 file changed, 10 deletions(-)

(limited to 'miner')

diff --git a/miner/worker.go b/miner/worker.go
index 347de4e08..b2183b77d 100644
--- a/miner/worker.go
+++ b/miner/worker.go
@@ -279,21 +279,11 @@ func (self *worker) wait() {
 				go self.mux.Post(core.NewMinedBlockEvent{Block: block})
 			} else {
 				work.state.Commit(self.config.IsEIP158(block.Number()))
-				parent := self.chain.GetBlock(block.ParentHash(), block.NumberU64()-1)
-				if parent == nil {
-					log.Error("Invalid block found during mining")
-					continue
-				}
-				if err := self.engine.VerifyHeader(self.chain, block.Header(), false); err != nil {
-					log.Error("Invalid header on mined block", "err", err)
-					continue
-				}
 				stat, err := self.chain.WriteBlock(block)
 				if err != nil {
 					log.Error("Failed writing block to chain", "err", err)
 					continue
 				}
-
 				// update block hash since it is now available and not when the receipt/log of individual transactions were created
 				for _, r := range work.receipts {
 					for _, l := range r.Logs {
-- 
cgit v1.2.3


From 158d603528d2ba36b633a8f22a2bff8329f69717 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= <peterke@gmail.com>
Date: Thu, 6 Apr 2017 14:58:03 +0300
Subject: consensus, core: drop all the legacy custom core error types

---
 miner/worker.go | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

(limited to 'miner')

diff --git a/miner/worker.go b/miner/worker.go
index b2183b77d..8a67b12a6 100644
--- a/miner/worker.go
+++ b/miner/worker.go
@@ -503,13 +503,13 @@ func (self *worker) commitNewWork() {
 func (self *worker) commitUncle(work *Work, uncle *types.Header) error {
 	hash := uncle.Hash()
 	if work.uncles.Has(hash) {
-		return core.UncleError("uncle not unique")
+		return fmt.Errorf("uncle not unique")
 	}
 	if !work.ancestors.Has(uncle.ParentHash) {
-		return core.UncleError(fmt.Sprintf("uncle's parent unknown (%x)", uncle.ParentHash[0:4]))
+		return fmt.Errorf("uncle's parent unknown (%x)", uncle.ParentHash[0:4])
 	}
 	if work.family.Has(hash) {
-		return core.UncleError(fmt.Sprintf("uncle already in family (%x)", hash))
+		return fmt.Errorf("uncle already in family (%x)", hash)
 	}
 	work.uncles.Add(uncle.Hash())
 	return nil
@@ -554,23 +554,23 @@ func (env *Work) commitTransactions(mux *event.TypeMux, txs *types.TransactionsB
 		env.state.StartRecord(tx.Hash(), common.Hash{}, env.tcount)
 
 		err, logs := env.commitTransaction(tx, bc, gp)
-		switch {
-		case core.IsGasLimitErr(err):
+		switch err {
+		case core.ErrGasLimitReached:
 			// Pop the current out-of-gas transaction without shifting in the next from the account
 			log.Trace("Gas limit exceeded for current block", "sender", from)
 			txs.Pop()
 
-		case err != nil:
-			// Pop the current failed transaction without shifting in the next from the account
-			log.Trace("Transaction failed, will be removed", "hash", tx.Hash(), "err", err)
-			env.failedTxs = append(env.failedTxs, tx)
-			txs.Pop()
-
-		default:
+		case nil:
 			// Everything ok, collect the logs and shift in the next transaction from the same account
 			coalescedLogs = append(coalescedLogs, logs...)
 			env.tcount++
 			txs.Shift()
+
+		default:
+			// Pop the current failed transaction without shifting in the next from the account
+			log.Trace("Transaction failed, will be removed", "hash", tx.Hash(), "err", err)
+			env.failedTxs = append(env.failedTxs, tx)
+			txs.Pop()
 		}
 	}
 
-- 
cgit v1.2.3