Revert "Merge pull request #1294 from coolcottontail/vdf_version_onff"

This reverts commit c3b84ab79d, reversing
changes made to 6eb83ca29e.
pull/1465/head
Eugene Kim 5 years ago
parent 30b63fc552
commit c2a2c2c3ed
  1. 9
      consensus/consensus_service.go
  2. 5
      consensus/consensus_v2.go
  3. 2
      core/blockchain.go
  4. 6
      internal/configs/sharding/fixedschedule.go
  5. 9
      internal/configs/sharding/localnet.go
  6. 9
      internal/configs/sharding/mainnet.go
  7. 6
      internal/configs/sharding/pangaea.go
  8. 4
      internal/configs/sharding/shardingconfig.go
  9. 6
      internal/configs/sharding/testnet.go

@ -744,12 +744,3 @@ func (consensus *Consensus) IsLeader() bool {
}
return false
}
// NeedsRandomNumberGeneration returns true if the current epoch needs random number generation
func (consensus *Consensus) NeedsRandomNumberGeneration(epoch *big.Int) bool {
if consensus.ShardID == 0 && epoch.Uint64() >= core.ShardingSchedule.RandomnessStartingEpoch() {
return true
}
return false
}

@ -210,7 +210,7 @@ func (consensus *Consensus) onAnnounce(msg *msg_pb.Message) {
}
//VRF/VDF is only generated in the beach chain
if consensus.NeedsRandomNumberGeneration(headerObj.Epoch) {
if consensus.ShardID == 0 {
//validate the VRF with proof if a non zero VRF is found in header
if len(headerObj.Vrf) > 0 {
if !consensus.ValidateVrfAndProof(headerObj) {
@ -1075,14 +1075,13 @@ func (consensus *Consensus) Start(blockChannel chan *types.Block, stopChan chan
Msg("[ConsensusMainLoop] Received Proposed New Block!")
//VRF/VDF is only generated in the beacon chain
if consensus.NeedsRandomNumberGeneration(newBlock.Header().Epoch) {
if consensus.ShardID == 0 {
// generate VRF if the current block has a new leader
if !consensus.ChainReader.IsSameLeaderAsPreviousBlock(newBlock) {
vrfBlockNumbers, err := consensus.ChainReader.ReadEpochVrfBlockNums(newBlock.Header().Epoch)
if err != nil {
consensus.getLogger().Info().
Uint64("MsgBlockNum", newBlock.NumberU64()).
Uint64("Epoch", newBlock.Header().Epoch.Uint64()).
Msg("[ConsensusMainLoop] no VRF block number from local db")
}

@ -1974,7 +1974,7 @@ func (bc *BlockChain) WriteEpochVdfBlockNum(epoch *big.Int, blockNum *big.Int) e
// IsSameLeaderAsPreviousBlock retrieves a block from the database by number, caching it
func (bc *BlockChain) IsSameLeaderAsPreviousBlock(block *types.Block) bool {
if IsEpochBlock(block) {
if block.NumberU64() == 0 {
return false
}

@ -44,12 +44,6 @@ func (s fixedSchedule) ConsensusRatio() float64 {
return mainnetConsensusRatio
}
// TODO: remove it after randomness feature turned on mainnet
//RandonnessStartingEpoch returns starting epoch of randonness generation
func (s fixedSchedule) RandomnessStartingEpoch() uint64 {
return mainnetRandomnessStartingEpoch
}
func (s fixedSchedule) MaxTxAmountLimit() *big.Int {
amountBigInt := big.NewInt(mainnetMaxTxAmountLimit)
amountBigInt = amountBigInt.Mul(amountBigInt, big.NewInt(denominations.One))

@ -24,9 +24,6 @@ const (
localnetVdfDifficulty = 5000 // This takes about 10s to finish the vdf
localnetConsensusRatio = float64(0.1)
// TODO: remove it after randomness feature turned on mainnet
localnetRandomnessStartingEpoch = 0
localnetMaxTxAmountLimit = 1e3 // unit is in One
localnetMaxNumRecentTxsPerAccountLimit = 1e2
localnetMaxTxPoolSizeLimit = 8000
@ -80,12 +77,6 @@ func (ls localnetSchedule) ConsensusRatio() float64 {
return localnetConsensusRatio
}
// TODO: remove it after randomness feature turned on mainnet
//RandonnessStartingEpoch returns starting epoch of randonness generation
func (ls localnetSchedule) RandomnessStartingEpoch() uint64 {
return localnetRandomnessStartingEpoch
}
func (ls localnetSchedule) MaxTxAmountLimit() *big.Int {
amountBigInt := big.NewInt(localnetMaxTxAmountLimit)
amountBigInt = amountBigInt.Mul(amountBigInt, big.NewInt(denominations.One))

@ -15,9 +15,6 @@ const (
mainnetVdfDifficulty = 50000 // This takes about 100s to finish the vdf
mainnetConsensusRatio = float64(0.66)
// TODO: remove it after randomness feature turned on mainnet
mainnetRandomnessStartingEpoch = 100000
mainnetV0_1Epoch = 1
mainnetV0_2Epoch = 5
mainnetV0_3Epoch = 8
@ -93,12 +90,6 @@ func (ms mainnetSchedule) ConsensusRatio() float64 {
return mainnetConsensusRatio
}
// TODO: remove it after randomness feature turned on mainnet
//RandonnessStartingEpoch returns starting epoch of randonness generation
func (ms mainnetSchedule) RandomnessStartingEpoch() uint64 {
return mainnetRandomnessStartingEpoch
}
func (ms mainnetSchedule) MaxTxAmountLimit() *big.Int {
amountBigInt := big.NewInt(mainnetMaxTxAmountLimit)
amountBigInt = amountBigInt.Mul(amountBigInt, big.NewInt(denominations.One))

@ -44,12 +44,6 @@ var pangaeaReshardingEpoch = []*big.Int{common.Big0}
var pangaeaV0 = MustNewInstance(
4, 250, 20, genesis.PangaeaAccounts, genesis.FoundationalPangaeaAccounts, pangaeaReshardingEpoch)
// TODO: remove it after randomness feature turned on mainnet
//RandonnessStartingEpoch returns starting epoch of randonness generation
func (pangaeaSchedule) RandomnessStartingEpoch() uint64 {
return mainnetRandomnessStartingEpoch
}
func (pangaeaSchedule) MaxTxAmountLimit() *big.Int {
amountBigInt := big.NewInt(mainnetMaxTxAmountLimit)
amountBigInt = amountBigInt.Mul(amountBigInt, big.NewInt(denominations.One))

@ -29,10 +29,6 @@ type Schedule interface {
// ConsensusRatio ratio of new nodes vs consensus total nodes
ConsensusRatio() float64
// TODO: remove it after randomness feature turned on mainnet
//RandomnessStartingEpoch returns starting epoch of randonness generation
RandomnessStartingEpoch() uint64
// Max amount limit for a valid transaction
MaxTxAmountLimit() *big.Int

@ -77,12 +77,6 @@ func (ts testnetSchedule) ConsensusRatio() float64 {
return mainnetConsensusRatio
}
// TODO: remove it after randomness feature turned on mainnet
//RandonnessStartingEpoch returns starting epoch of randonness generation
func (ts testnetSchedule) RandomnessStartingEpoch() uint64 {
return mainnetRandomnessStartingEpoch
}
func (ts testnetSchedule) MaxTxAmountLimit() *big.Int {
amountBigInt := big.NewInt(testnetMaxTxAmountLimit)
amountBigInt = amountBigInt.Mul(amountBigInt, big.NewInt(denominations.One))

Loading…
Cancel
Save