Skip to main content

修改代码建立私网

修改epoch持续时间

pos/posconfig/config.go:64

**********************!!!PROTECTION POLICY!!!**********************
Waiting For The Next Deployment, Maybe It Will Be Displayed After That.

此处填入准备产生的EOA账号地址

pos/posconfig/whiteAccountsMainnet.go:6

var PosOwnerAddrMainnet = common.HexToAddress("0xc45f2ec2ff75d2f28ac26973224e73ac866b22ee")

将主网genesis hash写入到源码中

params/config.go:28

MainnetGenesisHash = common.HexToHash("0x67fdc748f527b404d7a968d0888d2a24a24726af07ced977e5d5677c7fd55607") // Mainnet genesis hash to enforce below configs on, use block number zero's hash, you can check this block by using console to have this hash.

修改pow2pos的切换块高

params/config.go:35

const MainnetPow2PosUpgradeBlockNumber = 10

给预设的账号分配原生币

core/genesis_alloc.go:64

const tesramainchainAllocJson = `{
"0xc45f2ec2ff75d2f28ac26973224e73ac866b22ee": {
"balance": "21000000000000000000000000",
"staking": {
"amount":"4000000000000000000000000",
"s256pk":"0x047b2de4fa89934d05cd8a414ee2d3f4fe1d5b0ff281b07d4776f81a05d6367a8432731b3be8b94e8f62566809fdd84dc89a3646b9c265858f2e11f663c7a86e25",
"bn256pk":"0x2132cbf0c683683e4d07b628291b0567af15f2a103f03ca2b23f7824f5a7a6051fe6b7b1a28eb1632db5fb8aaa7327b62fda3e779b80d607b7b20c0ded53b65e"
}
},
"0xeffdb9112c9a413e0b8217a9987f5ebc03dbd2f8": {
"balance": "12600000000000000000000000",
"staking": {
"amount":"4000000000000000000000000",
"s256pk":"0x0458e7eaaf0ecfb31ca15e4b3eccdb2f48d9863da176c59f65914e76badd59bdca9bce57d4ec96d2d47bc33c56398411379ad645b63a07577c5eea869046fa288d",
"bn256pk":"0x19ddd7b90d59b0773f5763f20224e5e459508888ed3b839dd82c08aaa7c2ca112281c63a82d925fd12c63df3cba2527f5e705ca4c7cae7a4840314edd2b1617b"
}
},
"0x46616dc728f84eFDA02eBa6542362e74bC4A03A4": {
"balance": "12600000000000000000000000",
"staking": {
"amount":"4000000000000000000000000",
"s256pk":"0x0489907330798daedafa13b5aa49e0e96534c7ea52a2c410114ed805ad48a632f2f5fac9ddaed5a0bcb4bfdb774138f9d57a7801ca1e7f5b78a493273a7a67d3d3",
"bn256pk":"0x27c17579e1b798bceb028618d8a7844e9441fb88544fb4e99ae3f44c87ecd869045625db735652053418b552e43ecd8f4eff2e3227c2fdde5bc1fc4d51334377"
}
},
"0x588410e29AAF15ad40F8b2d765C937A24E2aC88f": {
"balance": "12600000000000000000000000",
"staking": {
"amount":"4000000000000000000000000",
"s256pk":"0x04b2341932cc27c93487141254a33ee3156ef17e6389e03772229111eda533ae3e642d59018fb8dad7219655951665c7d0cf6b62d36912d28b7bcac32ab923459f",
"bn256pk":"0x0e70496649d551da0c29fd31fd0dd9b249030b2fc6d4894f545265a015630c3d20742f52d34f0372cb1ed2b09169d3f0dbe495b977d115a0659c26db99dba498"
}
},
"0xf57639E8D9E018AF05676f0917ddbE92086077F1": {
"balance": "12600000000000000000000000",
"staking": {
"amount":"4000000000000000000000000",
"s256pk":"0x04c004d28655b84620a803caccce0c505f170eb2a6817e6da0be367fc55918b3c21f2eb2662bcc6c3c86fa5d3984560dbacd38f33bd24991eab574d2b4c645018e",
"bn256pk":"0x252a979ed24122507d6aa414146fb36efdf21a35a9dabdf5d6fa2e37e53d6b3919cc7acfb6a975a1ed02b4bcd8961845dd9fe163d9a9bd12bbbfbe0c0317d9fe"
}
},
"0xdb96f73e302C4E031901E230363aD72efa3df2AB": {
"balance": "12600000000000000000000000",
"staking": {
"amount":"4000000000000000000000000",
"s256pk":"0x04f7f9310a29f6a617c5cdc5ea49e137db45ce12a3b729a8a7102d9077099856b76ec2f6301cd62c0c83b741f86a046a3da22840a3dfc96bbd6bed8f52983fa623",
"bn256pk":"0x086917166f9184737292503bce7eaa0a193b19aa0a825f1d93de5b6bcabb2d2f1b23d05dcdf050b61b5257e58e17ded046943f8567af862baeae287964695cef"
}
},
"0x115d53A7Ea2C372349F5a78e2A9ba31b84F01b42": {
"balance": "12600000000000000000000000",
"staking": {
"amount":"4000000000000000000000000",
"s256pk":"0x04405ce5b62589b4f47e77a90fa96b9a70a04d3c94eea4ef8253f0708ffa9dc1a5d9860f88822904c0820c11a8e9568fe4aa7fe51888ec1c22622d0e98f86abc31",
"bn256pk":"0x0f3f1a2261df8f70a325ecefb68707532f85258de003a8181bb60f32c56329f1002fcdc6ca59502d9e449248ee2f006d68b44db194ab41e536706010877871f4"
}
}
}`

修改主网白名单列表,现在我们使用预设的账号公钥,重复填入,满足总数要求

pos/posconfig/whiteAccountsMainnet.go:8

**********************!!!PROTECTION POLICY!!!**********************
Waiting For The Next Deployment, Maybe It Will Be Displayed After That.

也可使用geth启动时的genesis配置文件,这样就不用修改代码了

tesramain --etherbase 0 --ethash.dagdir ~/tesramainchain/dag/0 --nodiscover --ipcpath ~/tesramainchain/ipc/0 --keystore ~/tesramainchain/keystore --unlock 0 --password ~/tesramainchain/password init core/genesis.json

genesis.json中extraData项来自于终端日志,代码在此处.

core/genesis_ppw_signers.go:25

fmt.Print(buf.String())

core/genesis.json

{
"config": {
"chainId": 1,
"byzantiumBlock": 0,
"pluto": {
"period": 10,
"epoch": 100
},
"ethash": {},
"posFirstBlock": 10,
"isPosActive": true
},
"alloc" : {
"0xc45f2ec2ff75d2f28ac26973224e73ac866b22ee": {
"balance": "21000000000000000000000000",
"staking":{
"amount":"4000000000000000000000000",
"s256pk":"0x047b2de4fa89934d05cd8a414ee2d3f4fe1d5b0ff281b07d4776f81a05d6367a8432731b3be8b94e8f62566809fdd84dc89a3646b9c265858f2e11f663c7a86e25",
"bn256pk":"0x2132cbf0c683683e4d07b628291b0567af15f2a103f03ca2b23f7824f5a7a6051fe6b7b1a28eb1632db5fb8aaa7327b62fda3e779b80d607b7b20c0ded53b65e"
}
},
"0xeffdb9112c9a413e0b8217a9987f5ebc03dbd2f8": {
"balance": "12600000000000000000000000",
"staking":{
"amount":"4000000000000000000000000",
"s256pk":"0x0458e7eaaf0ecfb31ca15e4b3eccdb2f48d9863da176c59f65914e76badd59bdca9bce57d4ec96d2d47bc33c56398411379ad645b63a07577c5eea869046fa288d",
"bn256pk":"0x19ddd7b90d59b0773f5763f20224e5e459508888ed3b839dd82c08aaa7c2ca112281c63a82d925fd12c63df3cba2527f5e705ca4c7cae7a4840314edd2b1617b"
}
},
"0x46616dc728f84eFDA02eBa6542362e74bC4A03A4": {
"balance": "12600000000000000000000000",
"staking":{
"amount":"4000000000000000000000000",
"s256pk":"0x0489907330798daedafa13b5aa49e0e96534c7ea52a2c410114ed805ad48a632f2f5fac9ddaed5a0bcb4bfdb774138f9d57a7801ca1e7f5b78a493273a7a67d3d3",
"bn256pk":"0x27c17579e1b798bceb028618d8a7844e9441fb88544fb4e99ae3f44c87ecd869045625db735652053418b552e43ecd8f4eff2e3227c2fdde5bc1fc4d51334377"
}
},
"0x588410e29AAF15ad40F8b2d765C937A24E2aC88f": {
"balance": "12600000000000000000000000",
"staking":{
"amount":"4000000000000000000000000",
"s256pk":"0x04b2341932cc27c93487141254a33ee3156ef17e6389e03772229111eda533ae3e642d59018fb8dad7219655951665c7d0cf6b62d36912d28b7bcac32ab923459f",
"bn256pk":"0x0e70496649d551da0c29fd31fd0dd9b249030b2fc6d4894f545265a015630c3d20742f52d34f0372cb1ed2b09169d3f0dbe495b977d115a0659c26db99dba498"
}
},
"0xf57639E8D9E018AF05676f0917ddbE92086077F1": {
"balance": "12600000000000000000000000",
"staking":{
"amount":"4000000000000000000000000",
"s256pk":"0x04c004d28655b84620a803caccce0c505f170eb2a6817e6da0be367fc55918b3c21f2eb2662bcc6c3c86fa5d3984560dbacd38f33bd24991eab574d2b4c645018e",
"bn256pk":"0x252a979ed24122507d6aa414146fb36efdf21a35a9dabdf5d6fa2e37e53d6b3919cc7acfb6a975a1ed02b4bcd8961845dd9fe163d9a9bd12bbbfbe0c0317d9fe"
}
},
"0xdb96f73e302C4E031901E230363aD72efa3df2AB": {
"balance": "12600000000000000000000000",
"staking":{
"amount":"4000000000000000000000000",
"s256pk":"0x04f7f9310a29f6a617c5cdc5ea49e137db45ce12a3b729a8a7102d9077099856b76ec2f6301cd62c0c83b741f86a046a3da22840a3dfc96bbd6bed8f52983fa623",
"bn256pk":"0x086917166f9184737292503bce7eaa0a193b19aa0a825f1d93de5b6bcabb2d2f1b23d05dcdf050b61b5257e58e17ded046943f8567af862baeae287964695cef"
}
},
"0x115d53A7Ea2C372349F5a78e2A9ba31b84F01b42": {
"balance": "12600000000000000000000000",
"staking":{
"amount":"4000000000000000000000000",
"s256pk":"0x04405ce5b62589b4f47e77a90fa96b9a70a04d3c94eea4ef8253f0708ffa9dc1a5d9860f88822904c0820c11a8e9568fe4aa7fe51888ec1c22622d0e98f86abc31",
"bn256pk":"0x0f3f1a2261df8f70a325ecefb68707532f85258de003a8181bb60f32c56329f1002fcdc6ca59502d9e449248ee2f006d68b44db194ab41e536706010877871f4"
}
}
},
"difficulty" : "0x100000",
"extraData" : "0xc45f2ec2ff75d2f28ac26973224e73ac866b22eeeffdb9112c9a413e0b8217a9987f5ebc03dbd2f846616dc728f84efda02eba6542362e74bc4a03a4588410e29aaf15ad40f8b2d765c937a24e2ac88ff57639e8d9e018af05676f0917ddbe92086077f1db96f73e302c4e031901e230363ad72efa3df2ab115d53a7ea2c372349f5a78e2a9ba31b84f01b42",
"gasLimit" : "0x2fefd8",
"nonce" : "0x0000000000000062",
"mixhash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
"parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
"timestamp" : "0x00"
}