Lower devnet's initial difficulty (#1869)

* Lower devnet's initial difficulty

* Increase simple-sync timeToPropagate to 10 seconds

* Check expectedAveragePropagationTime

Co-authored-by: Ori Newman <>
Co-authored-by: stasatdaglabs <39559713+stasatdaglabs@users.noreply.github.com>
This commit is contained in:
Ori Newman 2021-12-12 16:24:43 +02:00 committed by GitHub
parent 227ef392ba
commit 5806fef35f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 23 additions and 15 deletions

View File

@ -205,32 +205,32 @@ func TestBlockWindow(t *testing.T) {
{
parents: []string{"H", "F"},
id: "I",
expectedWindow: []string{"F", "D", "H", "C", "B", "G"},
expectedWindow: []string{"F", "D", "H", "C", "G", "B"},
},
{
parents: []string{"I"},
id: "J",
expectedWindow: []string{"I", "F", "D", "H", "C", "B", "G"},
expectedWindow: []string{"I", "F", "D", "H", "C", "G", "B"},
},
{
parents: []string{"J"},
id: "K",
expectedWindow: []string{"J", "I", "F", "D", "H", "C", "B", "G"},
expectedWindow: []string{"J", "I", "F", "D", "H", "C", "G", "B"},
},
{
parents: []string{"K"},
id: "L",
expectedWindow: []string{"K", "J", "I", "F", "D", "H", "C", "B", "G"},
expectedWindow: []string{"K", "J", "I", "F", "D", "H", "C", "G", "B"},
},
{
parents: []string{"L"},
id: "M",
expectedWindow: []string{"L", "K", "J", "I", "F", "D", "H", "C", "B", "G"},
expectedWindow: []string{"L", "K", "J", "I", "F", "D", "H", "C", "G", "B"},
},
{
parents: []string{"M"},
id: "N",
expectedWindow: []string{"M", "L", "K", "J", "I", "F", "D", "H", "C", "B"},
expectedWindow: []string{"M", "L", "K", "J", "I", "F", "D", "H", "C", "G"},
},
{
parents: []string{"N"},

View File

@ -129,8 +129,10 @@ func TestDifficulty(t *testing.T) {
var expectedBits uint32
switch consensusConfig.Name {
case dagconfig.TestnetParams.Name, dagconfig.DevnetParams.Name:
case dagconfig.TestnetParams.Name:
expectedBits = uint32(0x1e7f1441)
case dagconfig.DevnetParams.Name:
expectedBits = uint32(0x207f1441)
case dagconfig.MainnetParams.Name:
expectedBits = uint32(0x1d02c50f)
}

View File

@ -38,7 +38,7 @@ func TestPruning(t *testing.T) {
"dag-for-test-pruning.json": {
dagconfig.MainnetParams.Name: "503",
dagconfig.TestnetParams.Name: "502",
dagconfig.DevnetParams.Name: "502",
dagconfig.DevnetParams.Name: "503",
dagconfig.SimnetParams.Name: "502",
},
}

View File

@ -105,10 +105,7 @@ var devnetGenesisCoinbaseTx = transactionhelper.NewSubnetworkTransaction(0,
// devGenesisHash is the hash of the first block in the block DAG for the development
// network (genesis block).
var devnetGenesisHash = externalapi.NewDomainHashFromByteArray(&[externalapi.DomainHashSize]byte{
0x34, 0x3b, 0x53, 0xb7, 0xad, 0x82, 0x8a, 0x33,
0x4b, 0x03, 0xb1, 0xbb, 0x13, 0x15, 0xb0, 0x75,
0xf3, 0xf0, 0x40, 0xfb, 0x64, 0x0c, 0xca, 0x19,
0xc9, 0x61, 0xe7, 0x69, 0xdb, 0x98, 0x98, 0x3e,
0x4c, 0x64, 0x16, 0x35, 0xc8, 0x5d, 0xc8, 0x8d, 0x90, 0xbe, 0x2a, 0x42, 0xc1, 0xf6, 0x0f, 0xc4, 0xe9, 0xfc, 0xfc, 0xda, 0xdb, 0x53, 0x0d, 0x51, 0xe3, 0x02, 0x2b, 0x68, 0x65, 0xa6, 0x46, 0x7b,
})
// devnetGenesisMerkleRoot is the hash of the first transaction in the genesis block
@ -130,7 +127,7 @@ var devnetGenesisBlock = externalapi.DomainBlock{
&externalapi.DomainHash{},
externalapi.NewDomainHashFromByteArray(muhash.EmptyMuHashHash.AsArray()),
0x11e9db49828,
0x1e7fffff,
0x207fffff,
0x48e5e,
0,
0,

View File

@ -26,6 +26,7 @@ func mineLoop(syncerRPCClient, syncedRPCClient *rpc.Client) error {
return err
}
log.Infof("Starting to mine")
totalTime := time.Duration(0)
for i := uint64(0); i < activeConfig().NumberOfBlocks; i++ {
log.Infof("Mining block %d...", i+1)
err = mineBlock(syncerRPCClient.Address(), miningAddr)
@ -35,12 +36,14 @@ func mineLoop(syncerRPCClient, syncedRPCClient *rpc.Client) error {
log.Warnf("mineBlock returned an err: %s", err)
}
const timeToPropagate = 1 * time.Second
start := time.Now()
const timeToPropagate = 10 * time.Second
select {
case <-syncedRPCClient.OnBlockAdded:
case <-time.After(timeToPropagate):
return errors.Errorf("block %d took more than %s to propagate", i+1, timeToPropagate)
}
totalTime += time.Since(start)
syncerResult, err := syncerRPCClient.GetBlockDAGInfo()
if err != nil {
@ -57,6 +60,12 @@ func mineLoop(syncerRPCClient, syncedRPCClient *rpc.Client) error {
}
}
const expectedAveragePropagationTime = time.Second
averagePropagationTime := totalTime / time.Duration(activeConfig().NumberOfBlocks)
if averagePropagationTime > expectedAveragePropagationTime {
return errors.Errorf("average block propagation time %s is higher than expected (%s)", averagePropagationTime, expectedAveragePropagationTime)
}
log.Infof("Finished to mine")
log.Infof("Getting syncer block count")

View File

@ -16,7 +16,7 @@ func TestGetHashrateString(t *testing.T) {
var results = map[string]string{
dagconfig.MainnetParams.Name: "1.53 GH/s",
dagconfig.TestnetParams.Name: "131.07 KH/s",
dagconfig.DevnetParams.Name: "131.07 KH/s",
dagconfig.DevnetParams.Name: "2 H/s",
dagconfig.SimnetParams.Name: "2.00 KH/s",
}
testutils.ForAllNets(t, false, func(t *testing.T, consensusConfig *consensus.Config) {