Commit 5dc2a303 authored by mdj33's avatar mdj33 Committed by vipwzw

modify toml file

parent d82063da
...@@ -102,10 +102,14 @@ writeBlockSeconds=2 ...@@ -102,10 +102,14 @@ writeBlockSeconds=2
authAccount="" authAccount=""
#创世地址额度 #创世地址额度
genesisAmount=100000000 genesisAmount=100000000
#主链计算blockhash forkheight,需要和主链保持严格一致,不可修改,209186是bityuan主链对应高度, ycc或其他按实际修改
mainBlockHashForkHeight=209186
#主链支持平行链共识tx分叉高度,需要和主链保持严格一致,不可修改,2270000是bityuan主链对应高度, ycc或其他按实际修改 #主链支持平行链共识tx分叉高度,需要和主链保持严格一致,不可修改,2270000是bityuan主链对应高度, ycc或其他按实际修改
MainForkParacrossCommitTx=2270000 mainForkParacrossCommitTx=2270000
#主链开启循环检查共识交易done的fork高度,需要和主链保持严格一致,不可修改,4320000是bityuan主链对应高度, ycc或其他按实际修改 #主链开启循环检查共识交易done的fork高度,需要和主链保持严格一致,不可修改,4320000是bityuan主链对应高度, ycc或其他按实际修改
MainLoopCheckCommitTxDoneForkHeight=4320000 mainLoopCheckCommitTxDoneForkHeight=4320000
#精简commitMsg,删除多余的hash参数,缺省mainLoopCheckCommitTxDoneForkHeight一致,一些特殊的链如game需定制
rmCommitMsgHashParamMainHeight=4320000
#主链每隔几个没有相关平行链交易的区块,平行链上打包空区块,缺省从平行链blockHeight=0开始,依次增长,空块间隔不能为0 #主链每隔几个没有相关平行链交易的区块,平行链上打包空区块,缺省从平行链blockHeight=0开始,依次增长,空块间隔不能为0
[[consensus.sub.para.emptyBlockInterval]] [[consensus.sub.para.emptyBlockInterval]]
blockHeight=0 blockHeight=0
......
...@@ -38,7 +38,6 @@ const ( ...@@ -38,7 +38,6 @@ const (
poolMainBlockSec int64 = 5 poolMainBlockSec int64 = 5
defaultEmptyBlockInterval int64 = 50 //write empty block every interval blocks in mainchain defaultEmptyBlockInterval int64 = 50 //write empty block every interval blocks in mainchain
defaultSearchMatchedBlockDepth int32 = 10000 defaultSearchMatchedBlockDepth int32 = 10000
defaultMainBlockHashForkHeight int64 = 209186 //calc block hash fork height in main chain
) )
var ( var (
...@@ -78,26 +77,27 @@ type paraSelfConsEnable struct { ...@@ -78,26 +77,27 @@ type paraSelfConsEnable struct {
} }
type subConfig struct { type subConfig struct {
WriteBlockSeconds int64 `json:"writeBlockSeconds,omitempty"` WriteBlockSeconds int64 `json:"writeBlockSeconds,omitempty"`
ParaRemoteGrpcClient string `json:"paraRemoteGrpcClient,omitempty"` ParaRemoteGrpcClient string `json:"paraRemoteGrpcClient,omitempty"`
StartHeight int64 `json:"startHeight,omitempty"` StartHeight int64 `json:"startHeight,omitempty"`
GenesisStartHeightSame bool `json:"genesisStartHeightSame,omitempty"` GenesisStartHeightSame bool `json:"genesisStartHeightSame,omitempty"`
EmptyBlockInterval []*emptyBlockInterval `json:"emptyBlockInterval,omitempty"` EmptyBlockInterval []*emptyBlockInterval `json:"emptyBlockInterval,omitempty"`
AuthAccount string `json:"authAccount,omitempty"` AuthAccount string `json:"authAccount,omitempty"`
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"`
FetchFilterParaTxsClose bool `json:"fetchFilterParaTxsClose,omitempty"` FetchFilterParaTxsClose bool `json:"fetchFilterParaTxsClose,omitempty"`
BatchFetchBlockCount int64 `json:"batchFetchBlockCount,omitempty"` BatchFetchBlockCount int64 `json:"batchFetchBlockCount,omitempty"`
ParaConsensStartHeight int64 `json:"paraConsensStartHeight,omitempty"` ParaConsensStartHeight int64 `json:"paraConsensStartHeight,omitempty"`
MultiDownloadOpen bool `json:"multiDownloadOpen,omitempty"` MultiDownloadOpen bool `json:"multiDownloadOpen,omitempty"`
MultiDownInvNumPerJob int64 `json:"multiDownInvNumPerJob,omitempty"` MultiDownInvNumPerJob int64 `json:"multiDownInvNumPerJob,omitempty"`
MultiDownJobBuffNum uint32 `json:"multiDownJobBuffNum,omitempty"` MultiDownJobBuffNum uint32 `json:"multiDownJobBuffNum,omitempty"`
MultiDownServerRspTime uint32 `json:"multiDownServerRspTime,omitempty"` MultiDownServerRspTime uint32 `json:"multiDownServerRspTime,omitempty"`
RmCommitMsgHashParamMainHeight int64 `json:"rmCommitMsgHashParamMainHeight,omitempty"`
} }
// New function to init paracross env // New function to init paracross env
...@@ -123,10 +123,6 @@ func New(cfg *types.Consensus, sub []byte) queue.Module { ...@@ -123,10 +123,6 @@ func New(cfg *types.Consensus, sub []byte) queue.Module {
panic("para EmptyBlockInterval config not correct") panic("para EmptyBlockInterval config not correct")
} }
if subcfg.MainBlockHashForkHeight <= 0 {
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)
......
...@@ -175,6 +175,7 @@ func TestAddMinerTx(t *testing.T) { ...@@ -175,6 +175,7 @@ func TestAddMinerTx(t *testing.T) {
para := &client{BaseClient: &drivers.BaseClient{}} para := &client{BaseClient: &drivers.BaseClient{}}
para.SetAPI(api) para.SetAPI(api)
para.subCfg = new(subConfig) para.subCfg = new(subConfig)
para.subCfg.SelfConsensusEnable = append(para.subCfg.SelfConsensusEnable, &paraSelfConsEnable{Enable: false})
para.privateKey = priKey para.privateKey = priKey
para.commitMsgClient = new(commitMsgClient) para.commitMsgClient = new(commitMsgClient)
para.commitMsgClient.paraClient = para para.commitMsgClient.paraClient = para
...@@ -284,3 +285,38 @@ func TestCheckEmptyInterval(t *testing.T) { ...@@ -284,3 +285,38 @@ func TestCheckEmptyInterval(t *testing.T) {
assert.Equal(t, nil, err) assert.Equal(t, nil, err)
} }
func TestCheckSelfConsensEnable(t *testing.T) {
int1 := &paraSelfConsEnable{BlockHeight: 0, Enable: false}
int2 := &paraSelfConsEnable{BlockHeight: 10, Enable: true}
int3 := &paraSelfConsEnable{BlockHeight: 5, Enable: false}
ints := []*paraSelfConsEnable{int1, int2, int3}
err := checkSelfConsensEnable(ints)
assert.Equal(t, types.ErrInvalidParam, err)
int3.BlockHeight = 15
err = checkSelfConsensEnable(ints)
assert.Nil(t, err)
}
func TestGetSelfConsEnableStatus(t *testing.T) {
int1 := &paraSelfConsEnable{BlockHeight: 0, Enable: false}
int2 := &paraSelfConsEnable{BlockHeight: 10, Enable: true}
int3 := &paraSelfConsEnable{BlockHeight: 15, Enable: false}
para := new(client)
para.subCfg = new(subConfig)
para.subCfg.SelfConsensusEnable = []*paraSelfConsEnable{int1, int2, int3}
selfConf := para.getSelfConsEnableStatus(5)
assert.Equal(t, int64(0), selfConf.BlockHeight)
assert.Equal(t, false, selfConf.Enable)
selfConf = para.getSelfConsEnableStatus(10)
assert.Equal(t, int64(10), selfConf.BlockHeight)
assert.Equal(t, true, selfConf.Enable)
selfConf = para.getSelfConsEnableStatus(16)
assert.Equal(t, int64(15), selfConf.BlockHeight)
assert.Equal(t, false, selfConf.Enable)
}
...@@ -365,7 +365,7 @@ func (client *blockSyncClient) addMinerTx(preStateHash []byte, block *types.Bloc ...@@ -365,7 +365,7 @@ func (client *blockSyncClient) addMinerTx(preStateHash []byte, block *types.Bloc
MainBlockHash: localBlock.MainHash, MainBlockHash: localBlock.MainHash,
MainBlockHeight: localBlock.MainHeight, MainBlockHeight: localBlock.MainHeight,
} }
if !pt.IsParaForkHeight(cfg, status.MainBlockHeight, pt.ForkLoopCheckCommitTxDone) { if status.MainBlockHeight < client.paraClient.subCfg.RmCommitMsgHashParamMainHeight {
status.PreBlockHash = block.ParentHash status.PreBlockHash = block.ParentHash
status.PreStateHash = preStateHash status.PreStateHash = preStateHash
} }
......
...@@ -49,6 +49,7 @@ func initTestSyncBlock() { ...@@ -49,6 +49,7 @@ func initTestSyncBlock() {
func createParaTestInstance(t *testing.T, q queue.Queue) *client { func createParaTestInstance(t *testing.T, q queue.Queue) *client {
para := new(client) para := new(client)
para.subCfg = new(subConfig) para.subCfg = new(subConfig)
para.subCfg.SelfConsensusEnable = append(para.subCfg.SelfConsensusEnable, &paraSelfConsEnable{Enable: false})
baseCli := drivers.NewBaseClient(&types.Consensus{Name: "name"}) baseCli := drivers.NewBaseClient(&types.Consensus{Name: "name"})
para.BaseClient = baseCli para.BaseClient = baseCli
......
...@@ -49,6 +49,7 @@ func TestCalcCommitMsgTxs(t *testing.T) { ...@@ -49,6 +49,7 @@ func TestCalcCommitMsgTxs(t *testing.T) {
para.SetAPI(api) para.SetAPI(api)
para.subCfg = new(subConfig) para.subCfg = new(subConfig)
para.subCfg.SelfConsensusEnable = append(para.subCfg.SelfConsensusEnable, &paraSelfConsEnable{Enable: true})
priKey := getPrivKey(t) priKey := getPrivKey(t)
client := &commitMsgClient{ client := &commitMsgClient{
...@@ -90,6 +91,7 @@ func TestGetConsensusStatus(t *testing.T) { ...@@ -90,6 +91,7 @@ func TestGetConsensusStatus(t *testing.T) {
para := &client{BaseClient: &drivers.BaseClient{}} para := &client{BaseClient: &drivers.BaseClient{}}
para.subCfg = new(subConfig) para.subCfg = new(subConfig)
para.subCfg.SelfConsensusEnable = append(para.subCfg.SelfConsensusEnable, &paraSelfConsEnable{Enable: true})
grpcClient := &typesmocks.Chain33Client{} grpcClient := &typesmocks.Chain33Client{}
//grpcClient.On("GetFork", mock.Anything, &types.ReqKey{Key: []byte("ForkBlockHash")}).Return(&types.Int64{Data: 1}, errors.New("err")).Once() //grpcClient.On("GetFork", mock.Anything, &types.ReqKey{Key: []byte("ForkBlockHash")}).Return(&types.Int64{Data: 1}, errors.New("err")).Once()
para.grpcClient = grpcClient para.grpcClient = grpcClient
......
...@@ -92,9 +92,9 @@ startHeight=20 ...@@ -92,9 +92,9 @@ startHeight=20
#打包时间间隔,单位秒 #打包时间间隔,单位秒
writeBlockSeconds=2 writeBlockSeconds=2
MainBlockHashForkHeight=1 mainBlockHashForkHeight=1
MainForkParacrossCommitTx=5 mainForkParacrossCommitTx=5
MainParaSelfConsensusForkHeight=300 mainParaSelfConsensusForkHeight=300
SearchHashMatchedBlockDepth=100 SearchHashMatchedBlockDepth=100
#验证账户,验证节点需要配置自己的账户,并且钱包导入对应种子,非验证节点留空 #验证账户,验证节点需要配置自己的账户,并且钱包导入对应种子,非验证节点留空
authAccount="1KSBd17H7ZK8iT37aJztFB22XGwsPTdwE4" authAccount="1KSBd17H7ZK8iT37aJztFB22XGwsPTdwE4"
...@@ -106,6 +106,15 @@ genesisAmount=100000000 ...@@ -106,6 +106,15 @@ genesisAmount=100000000
[[consensus.sub.para.emptyBlockInterval]] [[consensus.sub.para.emptyBlockInterval]]
blockHeight=0 blockHeight=0
interval=4 interval=4
[[consensus.sub.para.selfConsensusEnable]]
blockHeight=0
enable=true
[[consensus.sub.para.selfConsensusEnable]]
blockHeight=20
enable=false
[[consensus.sub.para.selfConsensusEnable]]
blockHeight=40
enable=true
[store] [store]
name="mavl" name="mavl"
......
...@@ -38,10 +38,14 @@ function para_set_toml() { ...@@ -38,10 +38,14 @@ function para_set_toml() {
sed -i $xsedfix 's/^startHeight=.*/startHeight=1/g' "${1}" sed -i $xsedfix 's/^startHeight=.*/startHeight=1/g' "${1}"
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/^MainLoopCheckCommitTxDoneForkHeight=.*/MainLoopCheckCommitTxDoneForkHeight='''$MainLoopCheckForkHeight'''/g' "${1}" sed -i $xsedfix 's/^mainLoopCheckCommitTxDoneForkHeight=.*/mainLoopCheckCommitTxDoneForkHeight='''$MainLoopCheckForkHeight'''/g' "${1}"
sed -i $xsedfix 's/^rmCommitMsgHashParamMainHeight=.*/rmCommitMsgHashParamMainHeight='''$MainLoopCheckForkHeight'''/g' "${1}"
sed -i $xsedfix '/^MainForkParacrossCommitTx=.*/a MainBlockHashForkHeight=1' "${1}" sed -i $xsedfix 's/^mainBlockHashForkHeight=.*/mainBlockHashForkHeight=1/g' "${1}"
#sed -i $xsedfix '/\[\[consensus.sub.para.selfConsensusEnable\]\]/{n;n;s/enable=false/enable=true/}' "${1}"
sed -i $xsedfix '/\[\[consensus.sub.para.selfConsensusEnable\]\]/!b;n;n;cenable=true' "${1}"
# rpc # rpc
sed -i $xsedfix 's/^jrpcBindAddr=.*/jrpcBindAddr="0.0.0.0:8901"/g' "${1}" sed -i $xsedfix 's/^jrpcBindAddr=.*/jrpcBindAddr="0.0.0.0:8901"/g' "${1}"
......
...@@ -218,9 +218,9 @@ function paracross_ListTitles() { ...@@ -218,9 +218,9 @@ function paracross_ListTitles() {
local resp local resp
local ok local ok
local main_ip=${UNIT_HTTP//8901/8801}
resp=$(curl -ksd '{"method":"paracross.ListTitles","params":[]}' ${UNIT_HTTP}) resp=$(curl -ksd '{"method":"paracross.ListTitles","params":[]}' ${main_ip})
#echo $resp echo $resp
ok=$(jq '(.error|not) and (.result| [has("titles"),true])' <<<"$resp") ok=$(jq '(.error|not) and (.result| [has("titles"),true])' <<<"$resp")
[ "$ok" == true ] [ "$ok" == true ]
local rst=$? local rst=$?
......
...@@ -120,12 +120,21 @@ waitBlocks4CommitMsg=2 ...@@ -120,12 +120,21 @@ waitBlocks4CommitMsg=2
searchHashMatchedBlockDepth=10000 searchHashMatchedBlockDepth=10000
#创世地址额度 #创世地址额度
genesisAmount=100000000 genesisAmount=100000000
MainBlockHashForkHeight=1 mainBlockHashForkHeight=1
MainForkParacrossCommitTx=1 mainForkParacrossCommitTx=1
MainLoopCheckCommitTxDoneForkHeight=11 mainLoopCheckCommitTxDoneForkHeight=11
[[consensus.sub.para.emptyBlockInterval]] [[consensus.sub.para.emptyBlockInterval]]
blockHeight=0 blockHeight=0
interval=2 interval=2
[[consensus.sub.para.selfConsensusEnable]]
blockHeight=0
enable=true
[[consensus.sub.para.selfConsensusEnable]]
blockHeight=20
enable=false
[[consensus.sub.para.selfConsensusEnable]]
blockHeight=40
enable=true
[store] [store]
name="mavl" name="mavl"
......
...@@ -339,6 +339,8 @@ func GetDappForkHeight(cfg *types.Chain33Config, forkKey string) int64 { ...@@ -339,6 +339,8 @@ func GetDappForkHeight(cfg *types.Chain33Config, forkKey string) int64 {
forkHeight = 10 forkHeight = 10
case ForkLoopCheckCommitTxDone: case ForkLoopCheckCommitTxDone:
forkHeight = 60 forkHeight = 60
case ForkConsensSupportJump:
forkHeight = 100
} }
} }
} }
......
...@@ -19,13 +19,11 @@ var ( ...@@ -19,13 +19,11 @@ var (
// ForkCommitTx main chain support paracross commit tx // ForkCommitTx main chain support paracross commit tx
ForkCommitTx = "ForkParacrossCommitTx" ForkCommitTx = "ForkParacrossCommitTx"
// MainForkParacrossCommitTx 平行链配置项对应主链的ForkCommitTx 高度 // MainForkParacrossCommitTx 平行链配置项对应主链的ForkCommitTx 高度
MainForkParacrossCommitTx = "MainForkParacrossCommitTx" MainForkParacrossCommitTx = "mainForkParacrossCommitTx"
// ParaSelfConsensForkHeight para self consens height string
ParaSelfConsensForkHeight = "MainParaSelfConsensusForkHeight"
// ForkLoopCheckCommitTxDone 循环检查共识交易done的fork // ForkLoopCheckCommitTxDone 循环检查共识交易done的fork
ForkLoopCheckCommitTxDone = "ForkLoopCheckCommitTxDone" ForkLoopCheckCommitTxDone = "ForkLoopCheckCommitTxDone"
// MainLoopCheckCommitTxDoneForkHeight 平行链的配置项,对应主链的ForkLoopCheckCommitTxDone高度 // MainLoopCheckCommitTxDoneForkHeight 平行链的配置项,对应主链的ForkLoopCheckCommitTxDone高度
MainLoopCheckCommitTxDoneForkHeight = "MainLoopCheckCommitTxDoneForkHeight" MainLoopCheckCommitTxDoneForkHeight = "mainLoopCheckCommitTxDoneForkHeight"
// ForkConsensSupportJump 支持主链共识从-1开始跳跃一次 // ForkConsensSupportJump 支持主链共识从-1开始跳跃一次
ForkConsensSupportJump = "ForkConsensSupportJump" ForkConsensSupportJump = "ForkConsensSupportJump"
) )
......
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