Commit 29118e1d authored by mdj33's avatar mdj33 Committed by vipwzw

modify selfConsensEnable

parent b92aa4fd
...@@ -254,6 +254,7 @@ Enable=0 ...@@ -254,6 +254,7 @@ Enable=0
ForkParacrossWithdrawFromParachain=0 ForkParacrossWithdrawFromParachain=0
ForkParacrossCommitTx=0 ForkParacrossCommitTx=0
ForkLoopCheckCommitTxDone=0 ForkLoopCheckCommitTxDone=0
ForkConsensSupportJump=0
[fork.sub.evm] [fork.sub.evm]
Enable=0 Enable=0
......
...@@ -88,7 +88,7 @@ type subConfig struct { ...@@ -88,7 +88,7 @@ type subConfig struct {
WaitBlocks4CommitMsg int32 `json:"waitBlocks4CommitMsg,omitempty"` WaitBlocks4CommitMsg int32 `json:"waitBlocks4CommitMsg,omitempty"`
GenesisAmount int64 `json:"genesisAmount,omitempty"` GenesisAmount int64 `json:"genesisAmount,omitempty"`
MainBlockHashForkHeight int64 `json:"mainBlockHashForkHeight,omitempty"` MainBlockHashForkHeight int64 `json:"mainBlockHashForkHeight,omitempty"`
selfConsensusEnable []*paraSelfConsEnable `json:"selfConsensusEnable,omitempty"` SelfConsensusEnable []*paraSelfConsEnable `json:"selfConsensusEnable,omitempty"`
WaitConsensStopTimes uint32 `json:"waitConsensStopTimes,omitempty"` WaitConsensStopTimes uint32 `json:"waitConsensStopTimes,omitempty"`
MaxCacheCount int64 `json:"maxCacheCount,omitempty"` MaxCacheCount int64 `json:"maxCacheCount,omitempty"`
MaxSyncErrCount int32 `json:"maxSyncErrCount,omitempty"` MaxSyncErrCount int32 `json:"maxSyncErrCount,omitempty"`
...@@ -128,16 +128,16 @@ func New(cfg *types.Consensus, sub []byte) queue.Module { ...@@ -128,16 +128,16 @@ func New(cfg *types.Consensus, sub []byte) queue.Module {
subcfg.MainBlockHashForkHeight = defaultMainBlockHashForkHeight subcfg.MainBlockHashForkHeight = defaultMainBlockHashForkHeight
} }
if len(subcfg.selfConsensusEnable) == 0 { if len(subcfg.SelfConsensusEnable) == 0 {
selfEnable := &paraSelfConsEnable{Enable: false} selfEnable := &paraSelfConsEnable{Enable: false}
subcfg.selfConsensusEnable = append(subcfg.selfConsensusEnable, selfEnable) subcfg.SelfConsensusEnable = append(subcfg.SelfConsensusEnable, selfEnable)
} }
if subcfg.selfConsensusEnable[0].BlockHeight != 0 { if subcfg.SelfConsensusEnable[0].BlockHeight != 0 {
selfEnable := &paraSelfConsEnable{Enable: false} selfEnable := &paraSelfConsEnable{Enable: false}
subcfg.selfConsensusEnable = append([]*paraSelfConsEnable{selfEnable}, subcfg.selfConsensusEnable...) subcfg.SelfConsensusEnable = append([]*paraSelfConsEnable{selfEnable}, subcfg.SelfConsensusEnable...)
} }
err = checkSelfConsensEnable(subcfg.selfConsensusEnable) err = checkSelfConsensEnable(subcfg.SelfConsensusEnable)
if err != nil { if err != nil {
panic("para selfConsensusEnable config not correct") panic("para selfConsensusEnable config not correct")
} }
...@@ -189,7 +189,7 @@ func New(cfg *types.Consensus, sub []byte) queue.Module { ...@@ -189,7 +189,7 @@ func New(cfg *types.Consensus, sub []byte) queue.Module {
para.commitMsgClient.waitConsensStopTimes = subcfg.WaitConsensStopTimes para.commitMsgClient.waitConsensStopTimes = subcfg.WaitConsensStopTimes
} }
para.commitMsgClient.setSelfConsensMap(subcfg.selfConsensusEnable) para.commitMsgClient.setSelfConsensMap(subcfg.SelfConsensusEnable)
// 设置平行链共识起始高度,在共识高度为-1也就是从未共识过的环境中允许从设置的非0起始高度开始共识 // 设置平行链共识起始高度,在共识高度为-1也就是从未共识过的环境中允许从设置的非0起始高度开始共识
//note:只有在主链LoopCheckCommitTxDoneForkHeight之后才支持设置ParaConsensStartHeight //note:只有在主链LoopCheckCommitTxDoneForkHeight之后才支持设置ParaConsensStartHeight
...@@ -401,9 +401,9 @@ func (client *client) CreateGenesisTx() (ret []*types.Transaction) { ...@@ -401,9 +401,9 @@ func (client *client) CreateGenesisTx() (ret []*types.Transaction) {
} }
func (client *client) getSelfConsEnableStatus(height int64) *paraSelfConsEnable { func (client *client) getSelfConsEnableStatus(height int64) *paraSelfConsEnable {
for i := len(client.subCfg.selfConsensusEnable) - 1; i >= 0; i-- { for i := len(client.subCfg.SelfConsensusEnable) - 1; i >= 0; i-- {
if height >= client.subCfg.selfConsensusEnable[i].BlockHeight { if height >= client.subCfg.SelfConsensusEnable[i].BlockHeight {
return client.subCfg.selfConsensusEnable[i] return client.subCfg.SelfConsensusEnable[i]
} }
} }
panic(fmt.Sprintf("para selfConsensusEnable not set for height=%d", height)) panic(fmt.Sprintf("para selfConsensusEnable not set for height=%d", height))
......
...@@ -39,7 +39,6 @@ function para_set_toml() { ...@@ -39,7 +39,6 @@ function para_set_toml() {
sed -i $xsedfix 's/^interval=.*/interval=4/g' "${1}" sed -i $xsedfix 's/^interval=.*/interval=4/g' "${1}"
sed -i $xsedfix 's/^MainForkParacrossCommitTx=.*/MainForkParacrossCommitTx=10/g' "${1}" sed -i $xsedfix 's/^MainForkParacrossCommitTx=.*/MainForkParacrossCommitTx=10/g' "${1}"
sed -i $xsedfix 's/^MainParaSelfConsensusForkHeight=.*/MainParaSelfConsensusForkHeight=50/g' "${1}"
sed -i $xsedfix 's/^MainLoopCheckCommitTxDoneForkHeight=.*/MainLoopCheckCommitTxDoneForkHeight='''$MainLoopCheckForkHeight'''/g' "${1}" sed -i $xsedfix 's/^MainLoopCheckCommitTxDoneForkHeight=.*/MainLoopCheckCommitTxDoneForkHeight='''$MainLoopCheckForkHeight'''/g' "${1}"
sed -i $xsedfix '/^MainForkParacrossCommitTx=.*/a MainBlockHashForkHeight=1' "${1}" sed -i $xsedfix '/^MainForkParacrossCommitTx=.*/a MainBlockHashForkHeight=1' "${1}"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment