mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-18 10:50:44 +00:00
Condition added self.config.XDPoS != nil
This commit is contained in:
parent
e2beaa0fba
commit
d5101dc3ed
5 changed files with 31 additions and 80 deletions
28
internal/jsre/deps/bindata.go
Normal file → Executable file
28
internal/jsre/deps/bindata.go
Normal file → Executable file
File diff suppressed because one or more lines are too long
0
internal/jsre/deps/deps.go
Normal file → Executable file
0
internal/jsre/deps/deps.go
Normal file → Executable file
|
|
@ -18,10 +18,8 @@ package les
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"github.com/ethereum/go-ethereum/consensus/XDPoS"
|
||||||
"io/ioutil"
|
|
||||||
"math/big"
|
"math/big"
|
||||||
"path/filepath"
|
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/accounts"
|
"github.com/ethereum/go-ethereum/accounts"
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
|
|
@ -204,25 +202,11 @@ func (b *LesApiBackend) GetEngine() consensus.Engine {
|
||||||
return b.eth.engine
|
return b.eth.engine
|
||||||
}
|
}
|
||||||
func (s *LesApiBackend) GetRewardByHash(hash common.Hash) map[string]interface{} {
|
func (s *LesApiBackend) GetRewardByHash(hash common.Hash) map[string]interface{} {
|
||||||
header := s.eth.blockchain.GetHeaderByHash(hash)
|
if c, ok := s.eth.Engine().(*XDPoS.XDPoS); ok {
|
||||||
if header != nil {
|
rewards := c.GetRewards(hash)
|
||||||
data, err := ioutil.ReadFile(filepath.Join(common.StoreRewardFolder, header.Number.String()+"."+header.Hash().Hex()))
|
if rewards != nil {
|
||||||
if err == nil {
|
|
||||||
rewards := make(map[string]interface{})
|
|
||||||
err = json.Unmarshal(data, &rewards)
|
|
||||||
if err == nil {
|
|
||||||
return rewards
|
return rewards
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
data, err = ioutil.ReadFile(filepath.Join(common.StoreRewardFolder, header.Number.String()+"."+header.HashNoValidator().Hex()))
|
|
||||||
if err == nil {
|
|
||||||
rewards := make(map[string]interface{})
|
|
||||||
err = json.Unmarshal(data, &rewards)
|
|
||||||
if err == nil {
|
|
||||||
return rewards
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return make(map[string]interface{})
|
return make(map[string]interface{})
|
||||||
}
|
}
|
||||||
|
|
@ -18,7 +18,6 @@ package miner
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/binary"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/big"
|
"math/big"
|
||||||
"os"
|
"os"
|
||||||
|
|
@ -411,7 +410,6 @@ func (self *worker) wait() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Send tx sign to smart contract blockSigners.
|
// Send tx sign to smart contract blockSigners.
|
||||||
if block.NumberU64()%common.MergeSignRange == 0 || !self.config.IsTIP2019(block.Number()) {
|
|
||||||
if err := contracts.CreateTransactionSign(self.config, self.eth.TxPool(), self.eth.AccountManager(), block, self.chainDb); err != nil {
|
if err := contracts.CreateTransactionSign(self.config, self.eth.TxPool(), self.eth.AccountManager(), block, self.chainDb); err != nil {
|
||||||
log.Error("Fail to create tx sign for signer", "error", "err")
|
log.Error("Fail to create tx sign for signer", "error", "err")
|
||||||
}
|
}
|
||||||
|
|
@ -419,7 +417,6 @@ func (self *worker) wait() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// push sends a new work task to currently live miner agents.
|
// push sends a new work task to currently live miner agents.
|
||||||
func (self *worker) push(work *Work) {
|
func (self *worker) push(work *Work) {
|
||||||
|
|
@ -555,7 +552,6 @@ func (self *worker) commitNewWork() {
|
||||||
if atomic.LoadInt32(&self.mining) == 1 {
|
if atomic.LoadInt32(&self.mining) == 1 {
|
||||||
header.Coinbase = self.coinbase
|
header.Coinbase = self.coinbase
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := self.engine.Prepare(self.chain, header); err != nil {
|
if err := self.engine.Prepare(self.chain, header); err != nil {
|
||||||
log.Error("Failed to prepare header for new block", "err", err)
|
log.Error("Failed to prepare header for new block", "err", err)
|
||||||
return
|
return
|
||||||
|
|
@ -584,22 +580,12 @@ func (self *worker) commitNewWork() {
|
||||||
if self.config.DAOForkSupport && self.config.DAOForkBlock != nil && self.config.DAOForkBlock.Cmp(header.Number) == 0 {
|
if self.config.DAOForkSupport && self.config.DAOForkBlock != nil && self.config.DAOForkBlock.Cmp(header.Number) == 0 {
|
||||||
misc.ApplyDAOHardFork(work.state)
|
misc.ApplyDAOHardFork(work.state)
|
||||||
}
|
}
|
||||||
if self.config.IsTIPEVMSigner(header.Number) {
|
|
||||||
work.state.DeleteAddress(common.HexToAddress(common.BlockSigners))
|
|
||||||
}
|
|
||||||
// won't grasp txs at checkpoint
|
|
||||||
var (
|
|
||||||
txs *types.TransactionsByPriceAndNonce
|
|
||||||
specialTxs types.Transactions
|
|
||||||
)
|
|
||||||
if self.config.XDPoS != nil && header.Number.Uint64()%self.config.XDPoS.Epoch != 0 {
|
|
||||||
pending, err := self.eth.TxPool().Pending()
|
pending, err := self.eth.TxPool().Pending()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Failed to fetch pending transactions", "err", err)
|
log.Error("Failed to fetch pending transactions", "err", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
txs, specialTxs = types.NewTransactionsByPriceAndNonce(self.current.signer, pending, signers)
|
txs, specialTxs := types.NewTransactionsByPriceAndNonce(self.current.signer, pending, signers)
|
||||||
}
|
|
||||||
work.commitTransactions(self.mux, txs, specialTxs, self.chain, self.coinbase)
|
work.commitTransactions(self.mux, txs, specialTxs, self.chain, self.coinbase)
|
||||||
|
|
||||||
// compute uncles for the new block.
|
// compute uncles for the new block.
|
||||||
|
|
@ -632,7 +618,7 @@ func (self *worker) commitNewWork() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if atomic.LoadInt32(&self.mining) == 1 {
|
if atomic.LoadInt32(&self.mining) == 1 {
|
||||||
log.Info("Committing new block", "number", work.Block.Number(), "txs", work.tcount, "special-txs", len(specialTxs), "uncles", len(uncles), "elapsed", common.PrettyDuration(time.Since(tstart)))
|
log.Info("Committing new block", "number", work.Block.Number(), "txs", work.tcount, "special txs", len(specialTxs), "uncles", len(uncles), "elapsed", common.PrettyDuration(time.Since(tstart)))
|
||||||
self.unconfirmed.Shift(work.Block.NumberU64() - 1)
|
self.unconfirmed.Shift(work.Block.NumberU64() - 1)
|
||||||
self.lastParentBlockCommit = parent.Hash().Hex()
|
self.lastParentBlockCommit = parent.Hash().Hex()
|
||||||
}
|
}
|
||||||
|
|
@ -675,17 +661,6 @@ func (env *Work) commitTransactions(mux *event.TypeMux, txs *types.TransactionsB
|
||||||
log.Trace("Ignoring reply protected special transaction", "hash", tx.Hash(), "eip155", env.config.EIP155Block)
|
log.Trace("Ignoring reply protected special transaction", "hash", tx.Hash(), "eip155", env.config.EIP155Block)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if tx.To().Hex() == common.BlockSigners {
|
|
||||||
if len(tx.Data()) < 68 {
|
|
||||||
log.Trace("Data special transaction invalid lenght", "hash", tx.Hash(), "data", len(tx.Data()))
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
blkNumber := binary.BigEndian.Uint64(tx.Data()[8:40])
|
|
||||||
if blkNumber >= env.header.Number.Uint64() || blkNumber <= env.header.Number.Uint64()-env.config.XDPoS.Epoch*2 {
|
|
||||||
log.Trace("Data special transaction invalid number", "hash", tx.Hash(), "blkNumber", blkNumber, "miner", env.header.Number)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Start executing the transaction
|
// Start executing the transaction
|
||||||
env.state.Prepare(tx.Hash(), common.Hash{}, env.tcount)
|
env.state.Prepare(tx.Hash(), common.Hash{}, env.tcount)
|
||||||
nonce := env.state.GetNonce(from)
|
nonce := env.state.GetNonce(from)
|
||||||
|
|
@ -719,10 +694,6 @@ func (env *Work) commitTransactions(mux *event.TypeMux, txs *types.TransactionsB
|
||||||
log.Trace("Not enough gas for further transactions", "gp", gp)
|
log.Trace("Not enough gas for further transactions", "gp", gp)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if txs == nil {
|
|
||||||
log.Info("this block has no transaction")
|
|
||||||
break
|
|
||||||
}
|
|
||||||
// Retrieve the next transaction and abort if all done
|
// Retrieve the next transaction and abort if all done
|
||||||
tx := txs.Peek()
|
tx := txs.Peek()
|
||||||
if tx == nil {
|
if tx == nil {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue