mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-18 19:00:46 +00:00
reduce number sign transaction
This commit is contained in:
parent
590bcb448e
commit
95041650e8
4 changed files with 48 additions and 29 deletions
|
|
@ -1,22 +1,25 @@
|
||||||
package common
|
package common
|
||||||
|
|
||||||
|
import "math/big"
|
||||||
|
|
||||||
const (
|
const (
|
||||||
RewardMasterPercent = 40
|
RewardMasterPercent = 40
|
||||||
RewardVoterPercent = 30
|
RewardVoterPercent = 50
|
||||||
RewardFoundationPercent = 30
|
RewardFoundationPercent = 10
|
||||||
HexSignMethod = "e341eaa4"
|
HexSignMethod = "e341eaa4"
|
||||||
HexSetSecret = "34d38600"
|
HexSetSecret = "34d38600"
|
||||||
HexSetOpening = "e11f5ba2"
|
HexSetOpening = "e11f5ba2"
|
||||||
EpocBlockSecret = 800
|
EpocBlockSecret = 800
|
||||||
EpocBlockOpening = 850
|
EpocBlockOpening = 850
|
||||||
EpocBlockRandomize = 900
|
EpocBlockRandomize = 900
|
||||||
MaxMasternodes = 21
|
MaxMasternodes = 150
|
||||||
LimitPenaltyEpoch = 4
|
LimitPenaltyEpoch = 4
|
||||||
BlocksPerYear = uint64(15768000)
|
BlocksPerYear = uint64(15768000)
|
||||||
LimitThresholdNonceInQueue = 10
|
LimitThresholdNonceInQueue = 10
|
||||||
MinGasPrice = 2500
|
MinGasPrice = 2500
|
||||||
|
MergeSignRange = 15
|
||||||
// Maximum number of Masternodes Set to 21
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var TIP2019Block = big.NewInt(1050000)
|
||||||
var IsTestnet bool = false
|
var IsTestnet bool = false
|
||||||
|
var StoreRewardFolder string
|
||||||
|
|
@ -493,7 +493,8 @@ func (s *PublicBlockChainAPI) BlockNumber() *big.Int {
|
||||||
}
|
}
|
||||||
|
|
||||||
// BlockNumber returns the block number of the chain head.
|
// BlockNumber returns the block number of the chain head.
|
||||||
return s.b.GetRewardByHash(hash)
|
func (s *PublicBlockChainAPI) GetRewardByHash(hash common.Hash) map[string]interface{} {
|
||||||
|
return s.b.GetRewardByHash(hash)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetBalance returns the amount of wei for the given address in the state of the
|
// GetBalance returns the amount of wei for the given address in the state of the
|
||||||
|
|
@ -859,22 +860,34 @@ func (s *PublicBlockChainAPI) rpcOutputBlock(b *types.Block, inclTx bool, fullTx
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Fail to connect IPC client for block status", "error", err)
|
log.Error("Fail to connect IPC client for block status", "error", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
var signers []common.Address
|
var signers []common.Address
|
||||||
var filterSigners []common.Address
|
var filterSigners []common.Address
|
||||||
finality := int32(0)
|
finality := int32(0)
|
||||||
if b.Number().Int64() > 0 {
|
if b.Number().Int64() > 0 {
|
||||||
engine := s.b.GetEngine()
|
curBlockNumber := b.Number().Uint64()
|
||||||
|
prevBlockNumber := curBlockNumber + (common.MergeSignRange - (curBlockNumber % common.MergeSignRange))
|
||||||
|
latestBlockNumber := s.b.CurrentBlock().Number().Uint64()
|
||||||
|
if prevBlockNumber >= latestBlockNumber || !s.b.ChainConfig().IsTIP2019(b.Number()) {
|
||||||
|
prevBlockNumber = curBlockNumber
|
||||||
|
}
|
||||||
|
if engine, ok := s.b.GetEngine().(*XDPoS.XDPoS); ok {
|
||||||
|
prevBlock, _ := s.b.BlockByNumber(ctx, rpc.BlockNumber(prevBlockNumber))
|
||||||
addrBlockSigner := common.HexToAddress(common.BlockSigners)
|
addrBlockSigner := common.HexToAddress(common.BlockSigners)
|
||||||
signers, err = contracts.GetSignersFromContract(addrBlockSigner, client, b.Hash())
|
signers, err = contracts.GetSignersByExecutingEVM(addrBlockSigner, client, prevBlock.Hash())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Fail to get signers from block signer SC.", "error", err)
|
log.Error("Fail to get signers from block signer SC.", "error", err)
|
||||||
|
return nil, err
|
||||||
}
|
}
|
||||||
|
validator, _ := engine.RecoverValidator(b.Header())
|
||||||
|
creator, _ := engine.RecoverSigner(b.Header())
|
||||||
|
signers = append(signers, validator)
|
||||||
|
signers = append(signers, creator)
|
||||||
// Get block epoc latest.
|
// Get block epoc latest.
|
||||||
if s.b.ChainConfig().XDPoS != nil {
|
lastCheckpointNumber := prevBlockNumber - (prevBlockNumber % s.b.ChainConfig().XDPoS.Epoch)
|
||||||
lastCheckpointNumber := rpc.BlockNumber(b.Number().Uint64() - (b.Number().Uint64() % s.b.ChainConfig().XDPoS.Epoch))
|
prevCheckpointBlock, _ := s.b.BlockByNumber(ctx, rpc.BlockNumber(lastCheckpointNumber))
|
||||||
prevCheckpointBlock, _ := s.b.BlockByNumber(ctx, lastCheckpointNumber)
|
|
||||||
if prevCheckpointBlock != nil {
|
if prevCheckpointBlock != nil {
|
||||||
masternodes := engine.(*XDPoS.XDPoS).GetMasternodesFromCheckpointHeader(prevCheckpointBlock.Header(), b.Number().Uint64(), s.b.ChainConfig().XDPoS.Epoch)
|
masternodes := engine.GetMasternodesFromCheckpointHeader(prevCheckpointBlock.Header(), curBlockNumber, s.b.ChainConfig().XDPoS.Epoch)
|
||||||
countFinality := 0
|
countFinality := 0
|
||||||
for _, masternode := range masternodes {
|
for _, masternode := range masternodes {
|
||||||
for _, signer := range signers {
|
for _, signer := range signers {
|
||||||
|
|
|
||||||
|
|
@ -410,12 +410,14 @@ 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")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// push sends a new work task to currently live miner agents.
|
// push sends a new work task to currently live miner agents.
|
||||||
|
|
@ -552,11 +554,8 @@ func (self *worker) commitNewWork() {
|
||||||
if atomic.LoadInt32(&self.mining) == 1 {
|
if atomic.LoadInt32(&self.mining) == 1 {
|
||||||
header.Coinbase = self.coinbase
|
header.Coinbase = self.coinbase
|
||||||
}
|
}
|
||||||
state := &state.StateDB{}
|
|
||||||
if self.current != nil {
|
if err := self.engine.Prepare(self.chain, header); err != nil {
|
||||||
state = self.current.state
|
|
||||||
}
|
|
||||||
if err := self.engine.Prepare(self.chain, state, 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
|
||||||
}
|
}
|
||||||
|
|
@ -616,12 +615,12 @@ func (self *worker) commitNewWork() {
|
||||||
delete(self.possibleUncles, hash)
|
delete(self.possibleUncles, hash)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if atomic.LoadInt32(&self.mining) == 1 {
|
|
||||||
// Create the new block to seal with the consensus engine
|
// Create the new block to seal with the consensus engine
|
||||||
if work.Block, err = self.engine.Finalize(self.chain, header, work.state, work.txs, uncles, work.receipts); err != nil {
|
if work.Block, err = self.engine.Finalize(self.chain, header, work.state, work.txs, uncles, work.receipts); err != nil {
|
||||||
log.Error("Failed to finalize block for sealing", "err", err)
|
log.Error("Failed to finalize block for sealing", "err", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
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()
|
||||||
|
|
|
||||||
|
|
@ -213,6 +213,10 @@ func (c *ChainConfig) IsConstantinople(num *big.Int) bool {
|
||||||
return isForked(c.ConstantinopleBlock, num)
|
return isForked(c.ConstantinopleBlock, num)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *ChainConfig) IsTIP2019(num *big.Int) bool {
|
||||||
|
return isForked(common.TIP2019Block, num)
|
||||||
|
}
|
||||||
|
|
||||||
// GasTable returns the gas table corresponding to the current phase (homestead or homestead reprice).
|
// GasTable returns the gas table corresponding to the current phase (homestead or homestead reprice).
|
||||||
//
|
//
|
||||||
// The returned GasTable's fields shouldn't, under any circumstances, be changed.
|
// The returned GasTable's fields shouldn't, under any circumstances, be changed.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue