Merge pull request #1995 from rlan35/staking_pangaea

add flag to revert only beacon chain; also fix a epoch calc bug
pull/1999/head
Rongjian Lan 5 years ago committed by GitHub
commit 1563318f64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      cmd/harmony/main.go
  2. 2
      internal/configs/sharding/testnet.go

@ -119,6 +119,7 @@ var (
// Bad block revert // Bad block revert
doRevertBefore = flag.Int("do_revert_before", 0, "If the current block is less than do_revert_before, revert all blocks until (including) revert_to block") doRevertBefore = flag.Int("do_revert_before", 0, "If the current block is less than do_revert_before, revert all blocks until (including) revert_to block")
revertTo = flag.Int("revert_to", 0, "The revert will rollback all blocks until and including block number revert_to") revertTo = flag.Int("revert_to", 0, "The revert will rollback all blocks until and including block number revert_to")
revertBeacon = flag.Bool("revert_beacon", false, "Whether to revert beacon chain or the chain this node is assigned to")
) )
func initSetup() { func initSetup() {
@ -505,6 +506,9 @@ func main() {
if uint64(*doRevertBefore) != 0 && uint64(*revertTo) != 0 { if uint64(*doRevertBefore) != 0 && uint64(*revertTo) != 0 {
chain := currentNode.Blockchain() chain := currentNode.Blockchain()
if *revertBeacon {
chain = currentNode.Beaconchain()
}
curNum := chain.CurrentBlock().NumberU64() curNum := chain.CurrentBlock().NumberU64()
if curNum < uint64(*doRevertBefore) && curNum >= uint64(*revertTo) { if curNum < uint64(*doRevertBefore) && curNum >= uint64(*revertTo) {
// Remove invalid blocks // Remove invalid blocks

@ -39,7 +39,7 @@ func (testnetSchedule) BlocksPerEpoch() uint64 {
} }
func (ts testnetSchedule) CalcEpochNumber(blockNum uint64) *big.Int { func (ts testnetSchedule) CalcEpochNumber(blockNum uint64) *big.Int {
epoch := blockNum % ts.BlocksPerEpoch() epoch := blockNum / ts.BlocksPerEpoch()
return big.NewInt(int64(epoch)) return big.NewInt(int64(epoch))
} }

Loading…
Cancel
Save