mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-17 10:20:44 +00:00
Merge pull request #716 from XinFinOrg/merge-master-back-to-dev-upgrade
Merge master back to dev upgrade
This commit is contained in:
commit
6b6cf4b988
14 changed files with 111 additions and 42 deletions
|
|
@ -1242,6 +1242,9 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
|
||||||
if ctx.GlobalIsSet(DocRootFlag.Name) {
|
if ctx.GlobalIsSet(DocRootFlag.Name) {
|
||||||
cfg.DocRoot = ctx.GlobalString(DocRootFlag.Name)
|
cfg.DocRoot = ctx.GlobalString(DocRootFlag.Name)
|
||||||
}
|
}
|
||||||
|
if ctx.GlobalIsSet(RPCGlobalGasCapFlag.Name) {
|
||||||
|
cfg.RPCGasCap = ctx.GlobalUint64(RPCGlobalGasCapFlag.Name)
|
||||||
|
}
|
||||||
if ctx.GlobalIsSet(RPCGlobalTxFeeCap.Name) {
|
if ctx.GlobalIsSet(RPCGlobalTxFeeCap.Name) {
|
||||||
cfg.RPCTxFeeCap = ctx.GlobalFloat64(RPCGlobalTxFeeCap.Name)
|
cfg.RPCTxFeeCap = ctx.GlobalFloat64(RPCGlobalTxFeeCap.Name)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -350,13 +350,19 @@ An API exclusively for V2 consensus, designed to assist in getting rewards of th
|
||||||
Given the epoch number, search the epoch switch block.
|
Given the epoch number, search the epoch switch block.
|
||||||
*/
|
*/
|
||||||
func (api *API) GetBlockInfoByEpochNum(epochNumber uint64) (*utils.EpochNumInfo, error) {
|
func (api *API) GetBlockInfoByEpochNum(epochNumber uint64) (*utils.EpochNumInfo, error) {
|
||||||
result, err := api.XDPoS.EngineV2.GetBlockByEpochNumber(api.chain, epochNumber)
|
thisEpoch, err := api.XDPoS.EngineV2.GetBlockByEpochNumber(api.chain, epochNumber)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &utils.EpochNumInfo{
|
info := &utils.EpochNumInfo{
|
||||||
EpochBlockHash: result.Hash,
|
EpochBlockHash: thisEpoch.Hash,
|
||||||
EpochRound: result.Round,
|
EpochRound: thisEpoch.Round,
|
||||||
EpochBlockNumber: result.Number,
|
EpochFirstBlockNumber: thisEpoch.Number,
|
||||||
}, nil
|
}
|
||||||
|
nextEpoch, err := api.XDPoS.EngineV2.GetBlockByEpochNumber(api.chain, epochNumber+1)
|
||||||
|
|
||||||
|
if err == nil {
|
||||||
|
info.EpochLastBlockNumber = new(big.Int).Sub(nextEpoch.Number, big.NewInt(1))
|
||||||
|
}
|
||||||
|
return info, nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -661,6 +661,10 @@ func (x *XDPoS_v2) VoteHandler(chain consensus.ChainReader, voteMsg *types.Vote)
|
||||||
3. Broadcast(Not part of consensus)
|
3. Broadcast(Not part of consensus)
|
||||||
*/
|
*/
|
||||||
func (x *XDPoS_v2) VerifyTimeoutMessage(chain consensus.ChainReader, timeoutMsg *types.Timeout) (bool, error) {
|
func (x *XDPoS_v2) VerifyTimeoutMessage(chain consensus.ChainReader, timeoutMsg *types.Timeout) (bool, error) {
|
||||||
|
if timeoutMsg.Round < x.currentRound {
|
||||||
|
log.Debug("[VerifyTimeoutMessage] Disqualified timeout message as the proposed round does not match currentRound", "timeoutHash", timeoutMsg.Hash(), "timeoutRound", timeoutMsg.Round, "currentRound", x.currentRound)
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
snap, err := x.getSnapshot(chain, timeoutMsg.GapNumber, true)
|
snap, err := x.getSnapshot(chain, timeoutMsg.GapNumber, true)
|
||||||
if err != nil || snap == nil {
|
if err != nil || snap == nil {
|
||||||
log.Error("[VerifyTimeoutMessage] Fail to get snapshot when verifying timeout message!", "messageGapNumber", timeoutMsg.GapNumber, "err", err)
|
log.Error("[VerifyTimeoutMessage] Fail to get snapshot when verifying timeout message!", "messageGapNumber", timeoutMsg.GapNumber, "err", err)
|
||||||
|
|
|
||||||
|
|
@ -87,6 +87,7 @@ Forensics runs in a seperate go routine as its no system critical
|
||||||
Link to the flow diagram: https://hashlabs.atlassian.net/wiki/spaces/HASHLABS/pages/97878029/Forensics+Diagram+flow
|
Link to the flow diagram: https://hashlabs.atlassian.net/wiki/spaces/HASHLABS/pages/97878029/Forensics+Diagram+flow
|
||||||
*/
|
*/
|
||||||
func (f *Forensics) ProcessForensics(chain consensus.ChainReader, engine *XDPoS_v2, incomingQC types.QuorumCert) error {
|
func (f *Forensics) ProcessForensics(chain consensus.ChainReader, engine *XDPoS_v2, incomingQC types.QuorumCert) error {
|
||||||
|
return nil
|
||||||
log.Debug("Received a QC in forensics", "QC", incomingQC)
|
log.Debug("Received a QC in forensics", "QC", incomingQC)
|
||||||
// Clone the values to a temporary variable
|
// Clone the values to a temporary variable
|
||||||
highestCommittedQCs := f.HighestCommittedQCs
|
highestCommittedQCs := f.HighestCommittedQCs
|
||||||
|
|
@ -394,6 +395,7 @@ Forensics runs in a seperate go routine as its no system critical
|
||||||
Link to the flow diagram: https://hashlabs.atlassian.net/wiki/spaces/HASHLABS/pages/99516417/Vote+Equivocation+detection+specification
|
Link to the flow diagram: https://hashlabs.atlassian.net/wiki/spaces/HASHLABS/pages/99516417/Vote+Equivocation+detection+specification
|
||||||
*/
|
*/
|
||||||
func (f *Forensics) ProcessVoteEquivocation(chain consensus.ChainReader, engine *XDPoS_v2, incomingVote *types.Vote) error {
|
func (f *Forensics) ProcessVoteEquivocation(chain consensus.ChainReader, engine *XDPoS_v2, incomingVote *types.Vote) error {
|
||||||
|
return nil
|
||||||
log.Debug("Received a vote in forensics", "vote", incomingVote)
|
log.Debug("Received a vote in forensics", "vote", incomingVote)
|
||||||
// Clone the values to a temporary variable
|
// Clone the values to a temporary variable
|
||||||
highestCommittedQCs := f.HighestCommittedQCs
|
highestCommittedQCs := f.HighestCommittedQCs
|
||||||
|
|
@ -484,6 +486,7 @@ func (f *Forensics) isVoteBlamed(chain consensus.ChainReader, highestCommittedQC
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Forensics) DetectEquivocationInVotePool(vote *types.Vote, votePool *utils.Pool) {
|
func (f *Forensics) DetectEquivocationInVotePool(vote *types.Vote, votePool *utils.Pool) {
|
||||||
|
return
|
||||||
poolKey := vote.PoolKey()
|
poolKey := vote.PoolKey()
|
||||||
votePoolKeys := votePool.PoolObjKeysList()
|
votePoolKeys := votePool.PoolObjKeysList()
|
||||||
signer, err := GetVoteSignerAddresses(vote)
|
signer, err := GetVoteSignerAddresses(vote)
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,8 @@ type PublicApiMissedRoundsMetadata struct {
|
||||||
|
|
||||||
// Given an epoch number, this struct records the epoch switch block (first block in epoch) infos such as block number
|
// Given an epoch number, this struct records the epoch switch block (first block in epoch) infos such as block number
|
||||||
type EpochNumInfo struct {
|
type EpochNumInfo struct {
|
||||||
EpochBlockHash common.Hash `json:"hash"`
|
EpochBlockHash common.Hash `json:"hash"`
|
||||||
EpochRound types.Round `json:"round"`
|
EpochRound types.Round `json:"round"`
|
||||||
EpochBlockNumber *big.Int `json:"number"`
|
EpochFirstBlockNumber *big.Int `json:"firstBlock"`
|
||||||
|
EpochLastBlockNumber *big.Int `json:"lastBlock"`
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,8 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestProcessQcShallSetForensicsCommittedQc(t *testing.T) {
|
func TestProcessQcShallSetForensicsCommittedQc(t *testing.T) {
|
||||||
|
t.Skip("Skipping this test for now as we disable forensics")
|
||||||
|
|
||||||
blockchain, _, currentBlock, signer, signFn, _ := PrepareXDCTestBlockChainForV2Engine(t, 905, params.TestXDPoSMockChainConfig, nil)
|
blockchain, _, currentBlock, signer, signFn, _ := PrepareXDCTestBlockChainForV2Engine(t, 905, params.TestXDPoSMockChainConfig, nil)
|
||||||
engineV2 := blockchain.Engine().(*XDPoS.XDPoS).EngineV2
|
engineV2 := blockchain.Engine().(*XDPoS.XDPoS).EngineV2
|
||||||
|
|
||||||
|
|
@ -92,6 +94,8 @@ func TestProcessQcShallSetForensicsCommittedQc(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSetCommittedQCsInOrder(t *testing.T) {
|
func TestSetCommittedQCsInOrder(t *testing.T) {
|
||||||
|
t.Skip("Skipping this test for now as we disable forensics")
|
||||||
|
|
||||||
blockchain, _, currentBlock, _, _, _ := PrepareXDCTestBlockChainForV2Engine(t, 905, params.TestXDPoSMockChainConfig, nil)
|
blockchain, _, currentBlock, _, _, _ := PrepareXDCTestBlockChainForV2Engine(t, 905, params.TestXDPoSMockChainConfig, nil)
|
||||||
forensics := blockchain.Engine().(*XDPoS.XDPoS).EngineV2.GetForensicsFaker()
|
forensics := blockchain.Engine().(*XDPoS.XDPoS).EngineV2.GetForensicsFaker()
|
||||||
|
|
||||||
|
|
@ -118,6 +122,8 @@ func TestSetCommittedQCsInOrder(t *testing.T) {
|
||||||
|
|
||||||
// Happty path
|
// Happty path
|
||||||
func TestForensicsMonitoring(t *testing.T) {
|
func TestForensicsMonitoring(t *testing.T) {
|
||||||
|
t.Skip("Skipping this test for now as we disable forensics")
|
||||||
|
|
||||||
blockchain, _, currentBlock, _, _, _ := PrepareXDCTestBlockChainForV2Engine(t, 915, params.TestXDPoSMockChainConfig, nil)
|
blockchain, _, currentBlock, _, _, _ := PrepareXDCTestBlockChainForV2Engine(t, 915, params.TestXDPoSMockChainConfig, nil)
|
||||||
forensics := blockchain.Engine().(*XDPoS.XDPoS).EngineV2.GetForensicsFaker()
|
forensics := blockchain.Engine().(*XDPoS.XDPoS).EngineV2.GetForensicsFaker()
|
||||||
var decodedCurrentblockExtraField types.ExtraFields_v2
|
var decodedCurrentblockExtraField types.ExtraFields_v2
|
||||||
|
|
@ -140,6 +146,7 @@ func TestForensicsMonitoring(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestForensicsMonitoringNotOnSameChainButHaveSameRoundQC(t *testing.T) {
|
func TestForensicsMonitoringNotOnSameChainButHaveSameRoundQC(t *testing.T) {
|
||||||
|
t.Skip("Skipping this test for now as we disable forensics")
|
||||||
var numOfForks = new(int)
|
var numOfForks = new(int)
|
||||||
*numOfForks = 10
|
*numOfForks = 10
|
||||||
var forkRoundDifference = new(int)
|
var forkRoundDifference = new(int)
|
||||||
|
|
@ -199,6 +206,8 @@ func TestForensicsMonitoringNotOnSameChainButHaveSameRoundQC(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestForensicsMonitoringNotOnSameChainDoNotHaveSameRoundQC(t *testing.T) {
|
func TestForensicsMonitoringNotOnSameChainDoNotHaveSameRoundQC(t *testing.T) {
|
||||||
|
t.Skip("Skipping this test for now as we disable forensics")
|
||||||
|
|
||||||
var numOfForks = new(int)
|
var numOfForks = new(int)
|
||||||
*numOfForks = 10
|
*numOfForks = 10
|
||||||
var forkRoundDifference = new(int)
|
var forkRoundDifference = new(int)
|
||||||
|
|
@ -260,6 +269,8 @@ func TestForensicsMonitoringNotOnSameChainDoNotHaveSameRoundQC(t *testing.T) {
|
||||||
|
|
||||||
// "prone to attack" test where the "across epoch" field is true
|
// "prone to attack" test where the "across epoch" field is true
|
||||||
func TestForensicsAcrossEpoch(t *testing.T) {
|
func TestForensicsAcrossEpoch(t *testing.T) {
|
||||||
|
t.Skip("Skipping this test for now as we disable forensics")
|
||||||
|
|
||||||
var numOfForks = new(int)
|
var numOfForks = new(int)
|
||||||
*numOfForks = 10
|
*numOfForks = 10
|
||||||
var forkRoundDifference = new(int)
|
var forkRoundDifference = new(int)
|
||||||
|
|
@ -322,6 +333,8 @@ func TestForensicsAcrossEpoch(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestVoteEquivocationSameRound(t *testing.T) {
|
func TestVoteEquivocationSameRound(t *testing.T) {
|
||||||
|
t.Skip("Skipping this test for now as we disable forensics")
|
||||||
|
|
||||||
var numOfForks = new(int)
|
var numOfForks = new(int)
|
||||||
*numOfForks = 1
|
*numOfForks = 1
|
||||||
blockchain, _, currentBlock, signer, signFn, currentForkBlock := PrepareXDCTestBlockChainForV2Engine(t, 901, params.TestXDPoSMockChainConfig, &ForkedBlockOptions{numOfForkedBlocks: numOfForks})
|
blockchain, _, currentBlock, signer, signFn, currentForkBlock := PrepareXDCTestBlockChainForV2Engine(t, 901, params.TestXDPoSMockChainConfig, &ForkedBlockOptions{numOfForkedBlocks: numOfForks})
|
||||||
|
|
@ -388,6 +401,8 @@ func TestVoteEquivocationSameRound(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestVoteEquivocationDifferentRound(t *testing.T) {
|
func TestVoteEquivocationDifferentRound(t *testing.T) {
|
||||||
|
t.Skip("Skipping this test for now as we disable forensics")
|
||||||
|
|
||||||
var numOfForks = new(int)
|
var numOfForks = new(int)
|
||||||
*numOfForks = 10
|
*numOfForks = 10
|
||||||
var forkRoundDifference = new(int)
|
var forkRoundDifference = new(int)
|
||||||
|
|
|
||||||
|
|
@ -439,11 +439,11 @@ func (b *EthApiBackend) GetVotersRewards(masternodeAddr common.Address) map[comm
|
||||||
// calculate for 2 epochs ago
|
// calculate for 2 epochs ago
|
||||||
currentCheckpointNumber, _, err := engine.GetCurrentEpochSwitchBlock(chain, block.Number())
|
currentCheckpointNumber, _, err := engine.GetCurrentEpochSwitchBlock(chain, block.Number())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("[GetVotersRewards] Fail to get GetCurrentEpochSwitchBlock for current checkpoint block", "block", block)
|
log.Error("[GetVotersRewards] Fail to get GetCurrentEpochSwitchBlock for current checkpoint block", "block", block.Number(), "err", err)
|
||||||
}
|
}
|
||||||
lastCheckpointNumber, _, err := engine.GetCurrentEpochSwitchBlock(chain, big.NewInt(int64(currentCheckpointNumber-1)))
|
lastCheckpointNumber, _, err := engine.GetCurrentEpochSwitchBlock(chain, big.NewInt(int64(currentCheckpointNumber-1)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("[GetVotersRewards] Fail to get GetCurrentEpochSwitchBlock for last checkpoint block", "block", block)
|
log.Error("[GetVotersRewards] Fail to get GetCurrentEpochSwitchBlock for last checkpoint block", "block", block.Number(), "err", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
lastCheckpointBlock := chain.GetBlockByNumber(lastCheckpointNumber)
|
lastCheckpointBlock := chain.GetBlockByNumber(lastCheckpointNumber)
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ import (
|
||||||
|
|
||||||
const maxBlockDist = 7 // Maximum allowed backward distance from the chain head, 7 is just a magic number indicate very close block
|
const maxBlockDist = 7 // Maximum allowed backward distance from the chain head, 7 is just a magic number indicate very close block
|
||||||
|
|
||||||
//Define Boradcast Group functions
|
// Define Boradcast Group functions
|
||||||
type broadcastVoteFn func(*types.Vote)
|
type broadcastVoteFn func(*types.Vote)
|
||||||
type broadcastTimeoutFn func(*types.Timeout)
|
type broadcastTimeoutFn func(*types.Timeout)
|
||||||
type broadcastSyncInfoFn func(*types.SyncInfo)
|
type broadcastSyncInfoFn func(*types.SyncInfo)
|
||||||
|
|
@ -93,9 +93,8 @@ func (b *Bfter) Vote(peer string, vote *types.Vote) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
b.broadcastCh <- vote
|
|
||||||
|
|
||||||
if verified {
|
if verified {
|
||||||
|
b.broadcastCh <- vote
|
||||||
err = b.consensus.voteHandler(b.blockChainReader, vote)
|
err = b.consensus.voteHandler(b.blockChainReader, vote)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if _, ok := err.(*utils.ErrIncomingMessageRoundTooFarFromCurrentRound); ok {
|
if _, ok := err.(*utils.ErrIncomingMessageRoundTooFarFromCurrentRound); ok {
|
||||||
|
|
@ -126,8 +125,8 @@ func (b *Bfter) Timeout(peer string, timeout *types.Timeout) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
b.broadcastCh <- timeout
|
|
||||||
if verified {
|
if verified {
|
||||||
|
b.broadcastCh <- timeout
|
||||||
err = b.consensus.timeoutHandler(b.blockChainReader, timeout)
|
err = b.consensus.timeoutHandler(b.blockChainReader, timeout)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if _, ok := err.(*utils.ErrIncomingMessageRoundNotEqualCurrentRound); ok {
|
if _, ok := err.(*utils.ErrIncomingMessageRoundNotEqualCurrentRound); ok {
|
||||||
|
|
@ -156,9 +155,9 @@ func (b *Bfter) SyncInfo(peer string, syncInfo *types.SyncInfo) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
b.broadcastCh <- syncInfo
|
|
||||||
// Process only if verified and qualified
|
// Process only if verified and qualified
|
||||||
if verified {
|
if verified {
|
||||||
|
b.broadcastCh <- syncInfo
|
||||||
err = b.consensus.syncInfoHandler(b.blockChainReader, syncInfo)
|
err = b.consensus.syncInfoHandler(b.blockChainReader, syncInfo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("handle BFT SyncInfo", "error", err)
|
log.Error("handle BFT SyncInfo", "error", err)
|
||||||
|
|
|
||||||
|
|
@ -144,7 +144,7 @@ func TestBoardcastButNotProcessDisqualifiedVotes(t *testing.T) {
|
||||||
tester.bfter.Vote(peerID, &vote)
|
tester.bfter.Vote(peerID, &vote)
|
||||||
|
|
||||||
time.Sleep(50 * time.Millisecond)
|
time.Sleep(50 * time.Millisecond)
|
||||||
if int(handlerCounter) != targetVotes || int(broadcastCounter) != 1 {
|
if int(handlerCounter) != targetVotes || int(broadcastCounter) != 0 {
|
||||||
t.Fatalf("count mismatch: have %v on handler, %v on broadcast, want %v", handlerCounter, broadcastCounter, targetVotes)
|
t.Fatalf("count mismatch: have %v on handler, %v on broadcast, want %v", handlerCounter, broadcastCounter, targetVotes)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -171,7 +171,7 @@ func TestBoardcastButNotProcessDisqualifiedTimeout(t *testing.T) {
|
||||||
tester.bfter.Timeout(peerID, &timeout)
|
tester.bfter.Timeout(peerID, &timeout)
|
||||||
|
|
||||||
time.Sleep(50 * time.Millisecond)
|
time.Sleep(50 * time.Millisecond)
|
||||||
if int(handlerCounter) != targetTimeout || int(broadcastCounter) != 1 {
|
if int(handlerCounter) != targetTimeout || int(broadcastCounter) != 0 {
|
||||||
t.Fatalf("count mismatch: have %v on handler, %v on broadcast, want %v", handlerCounter, broadcastCounter, targetTimeout)
|
t.Fatalf("count mismatch: have %v on handler, %v on broadcast, want %v", handlerCounter, broadcastCounter, targetTimeout)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -198,7 +198,7 @@ func TestBoardcastButNotProcessDisqualifiedSyncInfo(t *testing.T) {
|
||||||
tester.bfter.SyncInfo(peerID, &syncInfo)
|
tester.bfter.SyncInfo(peerID, &syncInfo)
|
||||||
|
|
||||||
time.Sleep(50 * time.Millisecond)
|
time.Sleep(50 * time.Millisecond)
|
||||||
if int(handlerCounter) != targetSyncInfo || int(broadcastCounter) != 1 {
|
if int(handlerCounter) != targetSyncInfo || int(broadcastCounter) != 0 {
|
||||||
t.Fatalf("count mismatch: have %v on handler, %v on broadcast, want %v", handlerCounter, broadcastCounter, targetSyncInfo)
|
t.Fatalf("count mismatch: have %v on handler, %v on broadcast, want %v", handlerCounter, broadcastCounter, targetSyncInfo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
14
eth/peer.go
14
eth/peer.go
|
|
@ -37,13 +37,13 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
maxKnownTxs = 32768 // Maximum transactions hashes to keep in the known list (prevent DOS)
|
maxKnownTxs = 32768 // Maximum transactions hashes to keep in the known list (prevent DOS)
|
||||||
maxKnownOrderTxs = 32768 // Maximum transactions hashes to keep in the known list (prevent DOS)
|
maxKnownOrderTxs = 32768 // Maximum transactions hashes to keep in the known list (prevent DOS)
|
||||||
maxKnownLendingTxs = 32768 // Maximum transactions hashes to keep in the known list (prevent DOS)
|
maxKnownLendingTxs = 32768 // Maximum transactions hashes to keep in the known list (prevent DOS)
|
||||||
maxKnownBlocks = 1024 // Maximum block hashes to keep in the known list (prevent DOS)
|
maxKnownBlocks = 1024 // Maximum block hashes to keep in the known list (prevent DOS)
|
||||||
maxKnownVote = 1024 // Maximum transactions hashes to keep in the known list (prevent DOS)
|
maxKnownVote = 131072 // Maximum transactions hashes to keep in the known list (prevent DOS)
|
||||||
maxKnownTimeout = 1024 // Maximum transactions hashes to keep in the known list (prevent DOS)
|
maxKnownTimeout = 131072 // Maximum transactions hashes to keep in the known list (prevent DOS)
|
||||||
maxKnownSyncInfo = 1024 // Maximum transactions hashes to keep in the known list (prevent DOS)
|
maxKnownSyncInfo = 131072 // Maximum transactions hashes to keep in the known list (prevent DOS)
|
||||||
handshakeTimeout = 5 * time.Second
|
handshakeTimeout = 5 * time.Second
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -106,7 +106,7 @@ var Flags = []cli.Flag{
|
||||||
//blockprofilerateFlag,
|
//blockprofilerateFlag,
|
||||||
cpuprofileFlag,
|
cpuprofileFlag,
|
||||||
//traceFlag,
|
//traceFlag,
|
||||||
//periodicProfilingFlag,
|
periodicProfilingFlag,
|
||||||
debugDataDirFlag,
|
debugDataDirFlag,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -877,7 +877,7 @@ func (s *PublicBlockChainAPI) GetCandidateStatus(ctx context.Context, coinbaseAd
|
||||||
epochConfig := s.b.ChainConfig().XDPoS.Epoch
|
epochConfig := s.b.ChainConfig().XDPoS.Epoch
|
||||||
|
|
||||||
// checkpoint block
|
// checkpoint block
|
||||||
checkpointNumber, epochNumber = s.GetPreviousCheckpointFromEpoch(ctx, epoch)
|
checkpointNumber, epochNumber = s.GetCheckpointFromEpoch(ctx, epoch)
|
||||||
result[fieldEpoch] = epochNumber.Int64()
|
result[fieldEpoch] = epochNumber.Int64()
|
||||||
|
|
||||||
block, err = s.b.BlockByNumber(ctx, checkpointNumber)
|
block, err = s.b.BlockByNumber(ctx, checkpointNumber)
|
||||||
|
|
@ -1036,7 +1036,7 @@ func (s *PublicBlockChainAPI) GetCandidates(ctx context.Context, epoch rpc.Epoch
|
||||||
}
|
}
|
||||||
epochConfig := s.b.ChainConfig().XDPoS.Epoch
|
epochConfig := s.b.ChainConfig().XDPoS.Epoch
|
||||||
|
|
||||||
checkpointNumber, epochNumber = s.GetPreviousCheckpointFromEpoch(ctx, epoch)
|
checkpointNumber, epochNumber = s.GetCheckpointFromEpoch(ctx, epoch)
|
||||||
result[fieldEpoch] = epochNumber.Int64()
|
result[fieldEpoch] = epochNumber.Int64()
|
||||||
|
|
||||||
block, err = s.b.BlockByNumber(ctx, checkpointNumber)
|
block, err = s.b.BlockByNumber(ctx, checkpointNumber)
|
||||||
|
|
@ -1184,25 +1184,31 @@ func (s *PublicBlockChainAPI) GetCandidates(ctx context.Context, epoch rpc.Epoch
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetPreviousCheckpointFromEpoch returns header of the previous checkpoint
|
// GetCheckpointFromEpoch returns header of the previous checkpoint
|
||||||
func (s *PublicBlockChainAPI) GetPreviousCheckpointFromEpoch(ctx context.Context, epochNum rpc.EpochNumber) (rpc.BlockNumber, rpc.EpochNumber) {
|
func (s *PublicBlockChainAPI) GetCheckpointFromEpoch(ctx context.Context, epochNum rpc.EpochNumber) (rpc.BlockNumber, rpc.EpochNumber) {
|
||||||
var checkpointNumber uint64
|
var checkpointNumber uint64
|
||||||
epoch := s.b.ChainConfig().XDPoS.Epoch
|
epoch := s.b.ChainConfig().XDPoS.Epoch
|
||||||
|
|
||||||
if epochNum == rpc.LatestEpochNumber {
|
if epochNum == rpc.LatestEpochNumber {
|
||||||
blockNumer := s.b.CurrentBlock().Number().Uint64()
|
blockNumer := s.b.CurrentBlock().Number()
|
||||||
diff := blockNumer % epoch
|
if engine, ok := s.b.GetEngine().(*XDPoS.XDPoS); ok {
|
||||||
// checkpoint number
|
var err error
|
||||||
checkpointNumber = blockNumer - diff
|
var currentEpoch uint64
|
||||||
epochNum = rpc.EpochNumber(checkpointNumber / epoch)
|
checkpointNumber, currentEpoch, err = engine.GetCurrentEpochSwitchBlock(s.chainReader, blockNumer)
|
||||||
if diff > 0 {
|
if err != nil {
|
||||||
epochNum += 1
|
log.Error("[GetCheckpointFromEpoch] Fail to get GetCurrentEpochSwitchBlock for current checkpoint block", "block", blockNumer, "err", err)
|
||||||
|
return 0, epochNum
|
||||||
|
}
|
||||||
|
|
||||||
|
epochNum = rpc.EpochNumber(currentEpoch)
|
||||||
}
|
}
|
||||||
} else if epochNum < 2 {
|
} else if epochNum < 2 {
|
||||||
checkpointNumber = 0
|
checkpointNumber = 0
|
||||||
} else {
|
} else {
|
||||||
|
// TODO this checkpointNumber needs to be recalculated for v2 blocks
|
||||||
checkpointNumber = epoch * (uint64(epochNum) - 1)
|
checkpointNumber = epoch * (uint64(epochNum) - 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
return rpc.BlockNumber(checkpointNumber), epochNum
|
return rpc.BlockNumber(checkpointNumber), epochNum
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,38 @@ var (
|
||||||
TimeoutPeriod: 30,
|
TimeoutPeriod: 30,
|
||||||
MinePeriod: 2,
|
MinePeriod: 2,
|
||||||
},
|
},
|
||||||
|
2000: {
|
||||||
|
MaxMasternodes: 108,
|
||||||
|
SwitchRound: 2000,
|
||||||
|
CertThreshold: 0.667,
|
||||||
|
TimeoutSyncThreshold: 2,
|
||||||
|
TimeoutPeriod: 600,
|
||||||
|
MinePeriod: 2,
|
||||||
|
},
|
||||||
|
8000: {
|
||||||
|
MaxMasternodes: 108,
|
||||||
|
SwitchRound: 8000,
|
||||||
|
CertThreshold: 0.667,
|
||||||
|
TimeoutSyncThreshold: 2,
|
||||||
|
TimeoutPeriod: 60,
|
||||||
|
MinePeriod: 2,
|
||||||
|
},
|
||||||
|
220000: {
|
||||||
|
MaxMasternodes: 108,
|
||||||
|
SwitchRound: 220000,
|
||||||
|
CertThreshold: 0.667,
|
||||||
|
TimeoutSyncThreshold: 2,
|
||||||
|
TimeoutPeriod: 30,
|
||||||
|
MinePeriod: 2,
|
||||||
|
},
|
||||||
|
460000: {
|
||||||
|
MaxMasternodes: 108,
|
||||||
|
SwitchRound: 460000,
|
||||||
|
CertThreshold: 0.667,
|
||||||
|
TimeoutSyncThreshold: 2,
|
||||||
|
TimeoutPeriod: 20,
|
||||||
|
MinePeriod: 2,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
TestnetV2Configs = map[uint64]*V2Config{
|
TestnetV2Configs = map[uint64]*V2Config{
|
||||||
|
|
|
||||||
|
|
@ -21,10 +21,10 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
VersionMajor = 2 // Major version component of the current release
|
VersionMajor = 2 // Major version component of the current release
|
||||||
VersionMinor = 3 // Minor version component of the current release
|
VersionMinor = 3 // Minor version component of the current release
|
||||||
VersionPatch = 1 // Patch version component of the current release
|
VersionPatch = 0 // Patch version component of the current release
|
||||||
VersionMeta = "beta1" // Version metadata to append to the version string
|
VersionMeta = "stable" // Version metadata to append to the version string
|
||||||
)
|
)
|
||||||
|
|
||||||
// Version holds the textual version string.
|
// Version holds the textual version string.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue