From e08d6340827ab0b27510bc5be93d38407f8e17bb Mon Sep 17 00:00:00 2001 From: Leo Chen Date: Thu, 25 Jul 2019 14:45:26 -0700 Subject: [PATCH 1/2] [test] fix the local test Signed-off-by: Leo Chen --- test/configs/local-resharding.txt | 14 ++++---------- test/deploy.sh | 2 +- test/kill_node.sh | 2 ++ 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/test/configs/local-resharding.txt b/test/configs/local-resharding.txt index d62ddfabb..1539105f5 100644 --- a/test/configs/local-resharding.txt +++ b/test/configs/local-resharding.txt @@ -15,17 +15,11 @@ 127.0.0.1 9100 newnode one1ghkz3frhske7emk79p7v2afmj4a5t0kmjyt4s5 eca09c1808b729ca56f1b5a6a287c6e1c3ae09e29ccf7efa35453471fcab07d9f73cee249e2b91f5ee44eb9618be3904 127.0.0.1 9101 newnode one1d7jfnr6yraxnrycgaemyktkmhmajhp8kl0yahv f47238daef97d60deedbde5302d05dea5de67608f11f406576e363661f7dcbc4a1385948549b31a6c70f6fde8a391486 - 127.0.0.1 9102 newnode one1r4zyyjqrulf935a479sgqlpa78kz7zlcg2jfen fc4b9c535ee91f015efff3f32fbb9d32cdd9bfc8a837bb3eee89b8fff653c7af2050a4e147ebe5c7233dc2d5df06ee0a - 127.0.0.1 9103 newnode one1p7ht2d4kl8ve7a8jxw746yfnx4wnfxtp8jqxwe ca86e551ee42adaaa6477322d7db869d3e203c00d7b86c82ebee629ad79cb6d57b8f3db28336778ec2180e56a8e07296 127.0.0.1 9104 newnode one1z05g55zamqzfw9qs432n33gycdmyvs38xjemyl 95117937cd8c09acd2dfae847d74041a67834ea88662a7cbed1e170350bc329e53db151e5a0ef3e712e35287ae954818 127.0.0.1 9105 newnode one1ljznytjyn269azvszjlcqvpcj6hjm822yrcp2e 68ae289d73332872ec8d04ac256ca0f5453c88ad392730c5741b6055bc3ec3d086ab03637713a29f459177aaa8340615 - -127.0.0.1 9107 one1uyshu2jgv8w465yc8kkny36thlt2wvel89tcmg 1c1fb28d2de96e82c3d9b4917eb54412517e2763112a3164862a6ed627ac62e87ce274bb4ea36e6a61fb66a15c263a06 - -127.0.0.1 9108 one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7 b179c4fdc0bee7bd0b6698b792837dd13404d3f985b59d4a9b1cd0641a76651e271518b61abbb6fbebd4acf963358604 - -127.0.0.1 9110 one1d2rngmem4x2c6zxsjjz29dlah0jzkr0k2n88wc 16513c487a6bb76f37219f3c2927a4f281f9dd3fd6ed2e3a64e500de6545cf391dd973cc228d24f9bd01efe94912e714 - -127.0.0.1 9109 one1658znfwf40epvy7e46cqrmzyy54h4n0qa73nep 576d3c48294e00d6be4a22b07b66a870ddee03052fe48a5abbd180222e5d5a1f8946a78d55b025de21635fd743bbad90 +127.0.0.1 9107 newnode one1uyshu2jgv8w465yc8kkny36thlt2wvel89tcmg 1c1fb28d2de96e82c3d9b4917eb54412517e2763112a3164862a6ed627ac62e87ce274bb4ea36e6a61fb66a15c263a06 +127.0.0.1 9108 newnode one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7 b179c4fdc0bee7bd0b6698b792837dd13404d3f985b59d4a9b1cd0641a76651e271518b61abbb6fbebd4acf963358604 +127.0.0.1 9109 newnode one1658znfwf40epvy7e46cqrmzyy54h4n0qa73nep 576d3c48294e00d6be4a22b07b66a870ddee03052fe48a5abbd180222e5d5a1f8946a78d55b025de21635fd743bbad90 +127.0.0.1 9110 newnode one1d2rngmem4x2c6zxsjjz29dlah0jzkr0k2n88wc 16513c487a6bb76f37219f3c2927a4f281f9dd3fd6ed2e3a64e500de6545cf391dd973cc228d24f9bd01efe94912e714 diff --git a/test/deploy.sh b/test/deploy.sh index 891b280fe..c915fc14b 100755 --- a/test/deploy.sh +++ b/test/deploy.sh @@ -36,7 +36,7 @@ function cleanup() { $DRYRUN kill -9 $pid 2> /dev/null done rm -rf ./db/harmony_* - rm -rf ./db* + rm -rf ./db-127.0.0.1-* } function killnode() { diff --git a/test/kill_node.sh b/test/kill_node.sh index 7891e3138..c173ade25 100755 --- a/test/kill_node.sh +++ b/test/kill_node.sh @@ -5,3 +5,5 @@ do echo 'Killed process: '$pid kill -9 $pid done + +rm -rf db-127.0.0.1-* From 38cd570c0dd5bbbf9a39ddbf4afe2a0c9ad05065 Mon Sep 17 00:00:00 2001 From: Leo Chen Date: Thu, 25 Jul 2019 16:36:24 -0700 Subject: [PATCH 2/2] [epoch] fix IsLastBlock if block is less than epoch block Signed-off-by: Leo Chen --- core/blockchain.go | 1 + internal/configs/sharding/localnet.go | 2 ++ internal/configs/sharding/mainnet.go | 2 ++ internal/configs/sharding/testnet.go | 2 ++ 4 files changed, 7 insertions(+) diff --git a/core/blockchain.go b/core/blockchain.go index 69a0f6a3d..ced94a2ba 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -224,6 +224,7 @@ func (bc *BlockChain) ValidateNewBlock(block *types.Block) error { } // IsEpochBlock returns whether this block is the first block of an epoch. +// TODO: lc this is not used func IsEpochBlock(block *types.Block) bool { return block.NumberU64()%ShardingSchedule.BlocksPerEpoch() == 0 } diff --git a/internal/configs/sharding/localnet.go b/internal/configs/sharding/localnet.go index 6705a9555..e4008bb8b 100644 --- a/internal/configs/sharding/localnet.go +++ b/internal/configs/sharding/localnet.go @@ -48,6 +48,8 @@ func (ls localnetSchedule) CalcEpochNumber(blockNum uint64) *big.Int { func (ls localnetSchedule) IsLastBlock(blockNum uint64) bool { blocks := ls.BlocksPerEpoch() switch { + case blockNum < localnetEpochBlock1-1: + return false case blockNum == localnetEpochBlock1-1: return true default: diff --git a/internal/configs/sharding/mainnet.go b/internal/configs/sharding/mainnet.go index 4069dd4d5..f87e09795 100644 --- a/internal/configs/sharding/mainnet.go +++ b/internal/configs/sharding/mainnet.go @@ -44,6 +44,8 @@ func (ms mainnetSchedule) CalcEpochNumber(blockNum uint64) *big.Int { func (ms mainnetSchedule) IsLastBlock(blockNum uint64) bool { blocks := ms.BlocksPerEpoch() switch { + case blockNum < mainnetEpochBlock1-1: + return false case blockNum == mainnetEpochBlock1-1: return true default: diff --git a/internal/configs/sharding/testnet.go b/internal/configs/sharding/testnet.go index 017fd4e85..c30027122 100644 --- a/internal/configs/sharding/testnet.go +++ b/internal/configs/sharding/testnet.go @@ -49,6 +49,8 @@ func (ts testnetSchedule) CalcEpochNumber(blockNum uint64) *big.Int { func (ts testnetSchedule) IsLastBlock(blockNum uint64) bool { blocks := ts.BlocksPerEpoch() switch { + case blockNum < testnetEpochBlock1-1: + return false case blockNum == testnetEpochBlock1-1: return true default: