Commit e9e133c1 authored by mdj33's avatar mdj33 Committed by 33cn

para genesis start height same

parent 93f909b6
......@@ -36,7 +36,8 @@ dbCache=64
isStrongConsistency=true
singleMode=true
batchsync=false
isRecordBlockSequence=false
#平行链钱包通过平行链区块seqence索引高度,缺省是true
isRecordBlockSequence=true
isParaChain = true
enableTxQuickIndex=true
# 升级storedb是否重新执行localdb,bityuan主链升级不需要开启,平行链升级需要开启
......@@ -99,8 +100,6 @@ startHeight=345850
writeBlockSeconds=2
#验证账户,验证节点需要配置自己的账户,并且钱包导入对应种子,非验证节点留空
authAccount=""
#云端主链节点切换后,平行链适配新主链节点block,回溯查找和自己记录的相同blockhash的深度
searchHashMatchedBlockDepth=10000
#创世地址额度
genesisAmount=100000000
#主链支持平行链共识tx分叉高度,需要和主链保持严格一致,不可修改,2270000是bityuan主链对应高度, ycc或其他按实际修改
......
......@@ -21,6 +21,8 @@ require (
github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3
github.com/golang/protobuf v1.3.2
github.com/hashicorp/golang-lru v0.5.0
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/pkg/errors v0.8.0
github.com/prometheus/client_golang v1.1.0 // indirect
github.com/robertkrimen/otto v0.0.0-20180617131154-15f95af6e78d
......
......@@ -40,7 +40,6 @@ const (
defaultSearchMatchedBlockDepth int32 = 10000
defaultMainBlockHashForkHeight int64 = 209186 //calc block hash fork height in main chain
mainParaSelfConsensusForkHeight int64 = types.MaxHeight //para chain self consensus height switch, must >= ForkParacrossCommitTx of main
mainForkParacrossCommitTx int64 = types.MaxHeight //support paracross commit tx fork height in main chain: ForkParacrossCommitTx
)
var (
......@@ -78,14 +77,13 @@ type subConfig struct {
WriteBlockSeconds int64 `json:"writeBlockSeconds,omitempty"`
ParaRemoteGrpcClient string `json:"paraRemoteGrpcClient,omitempty"`
StartHeight int64 `json:"startHeight,omitempty"`
GenesisStartHeightSame bool `json:"genesisStartHeightSame,omitempty"`
EmptyBlockInterval []*emptyBlockInterval `json:"emptyBlockInterval,omitempty"`
AuthAccount string `json:"authAccount,omitempty"`
WaitBlocks4CommitMsg int32 `json:"waitBlocks4CommitMsg,omitempty"`
SearchHashMatchedBlockDepth int32 `json:"searchHashMatchedBlockDepth,omitempty"`
GenesisAmount int64 `json:"genesisAmount,omitempty"`
MainBlockHashForkHeight int64 `json:"mainBlockHashForkHeight,omitempty"`
MainParaSelfConsensusForkHeight int64 `json:"mainParaSelfConsensusForkHeight,omitempty"`
MainForkParacrossCommitTx int64 `json:"mainForkParacrossCommitTx,omitempty"`
WaitConsensStopTimes uint32 `json:"waitConsensStopTimes,omitempty"`
MaxCacheCount int64 `json:"maxCacheCount,omitempty"`
MaxSyncErrCount int32 `json:"maxSyncErrCount,omitempty"`
......@@ -121,9 +119,6 @@ func New(cfg *types.Consensus, sub []byte) queue.Module {
panic("para EmptyBlockInterval config not correct")
}
if subcfg.SearchHashMatchedBlockDepth <= 0 {
subcfg.SearchHashMatchedBlockDepth = defaultSearchMatchedBlockDepth
}
if subcfg.MainBlockHashForkHeight <= 0 {
subcfg.MainBlockHashForkHeight = defaultMainBlockHashForkHeight
}
......@@ -132,10 +127,6 @@ func New(cfg *types.Consensus, sub []byte) queue.Module {
subcfg.MainParaSelfConsensusForkHeight = mainParaSelfConsensusForkHeight
}
if subcfg.MainForkParacrossCommitTx <= 0 {
subcfg.MainForkParacrossCommitTx = mainForkParacrossCommitTx
}
if subcfg.BatchFetchBlockCount <= 0 {
subcfg.BatchFetchBlockCount = types.MaxBlockCountPerTime
}
......@@ -304,7 +295,12 @@ func (client *client) InitBlock() {
newblock.BlockTime = genesisBlockTime
newblock.ParentHash = zeroHash[:]
newblock.MainHash = mainHash
//缺省是减1,但有些特殊项目方6.2.0版本升级上来要求blockhash不变,则需与6.2.0保持一致,不减一
newblock.MainHeight = client.subCfg.StartHeight - 1
if client.subCfg.GenesisStartHeightSame {
newblock.MainHeight = client.subCfg.StartHeight
}
tx := client.CreateGenesisTx()
newblock.Txs = tx
newblock.TxHash = merkle.CalcMerkleRoot(newblock.Txs)
......@@ -322,7 +318,6 @@ func (client *client) InitBlock() {
}
plog.Debug("para consensus init parameter", "mainBlockHashForkHeight", client.subCfg.MainBlockHashForkHeight)
plog.Debug("para consensus init parameter", "mainParaSelfConsensusForkHeight", client.subCfg.MainParaSelfConsensusForkHeight)
}
......
......@@ -213,7 +213,7 @@ func (client *client) getMatchedBlockOnChain(startHeight int64) (int64, *types.B
startHeight = lastBlock.Height
}
depth := client.subCfg.SearchHashMatchedBlockDepth
depth := defaultSearchMatchedBlockDepth
for height := startHeight; height > 0 && depth > 0; height-- {
block, err := client.GetBlockByHeight(height)
if err != nil {
......@@ -228,7 +228,7 @@ func (client *client) getMatchedBlockOnChain(startHeight int64) (int64, *types.B
if depth == 0 {
plog.Error("switchHashMatchedBlock depth overflow", "last info:mainHeight", block.MainHeight,
"mainHash", hex.EncodeToString(block.MainHash), "search startHeight", lastBlock.Height, "curHeight", height,
"search depth", client.subCfg.SearchHashMatchedBlockDepth)
"search depth", defaultSearchMatchedBlockDepth)
panic("search HashMatchedBlock overflow, re-setting search depth and restart to try")
}
if height == 1 {
......
......@@ -47,7 +47,7 @@ func checkReceiptExecOk(receipt *types.ReceiptData) bool {
// 1, 主链+平行链 user.p.xx.paracross 交易组 混合跨链资产转移 paracross主链执行成功
// 2, 平行链 user.p.xx.paracross + user.p.xx.other 混合平行链组合 paracross主链执行成功
// 3, 平行链 user.p.xx.other 交易组 混合平行链组合 other主链pack
func filterParaTxGroup(tx *types.Transaction, allTxs []*types.TxDetail, index int, blockHeight, forkHeight int64) ([]*types.Transaction, int) {
func filterParaTxGroup(tx *types.Transaction, allTxs []*types.TxDetail, index int, mainBlockHeight, forkHeight int64) ([]*types.Transaction, int) {
var headIdx int
for i := index; i >= 0; i-- {
......@@ -59,7 +59,8 @@ func filterParaTxGroup(tx *types.Transaction, allTxs []*types.TxDetail, index in
endIdx := headIdx + int(tx.GroupCount)
for i := headIdx; i < endIdx; i++ {
if types.IsPara() && blockHeight < forkHeight {
//缺省是在forkHeight之前与更老版本一致,不检查平行链交易,但有些特殊平行链6.2.0版本升级上来无更老版本且要求blockhash不变,则需与6.2.0保持一致,不检查
if types.IsPara() && mainBlockHeight < forkHeight && !types.Conf("config.consensus.sub.para").IsEnable("FilterIgnoreParaTxGroup") {
if types.IsParaExecName(string(allTxs[i].Tx.Execer)) {
continue
}
......
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