[committee] Remove debug code

pull/1850/head
Edgar Aroutiounian 5 years ago
parent eab52d1d37
commit f348e10a5c
  1. 2
      cmd/client/wallet/main.go
  2. 5
      cmd/harmony/main.go
  3. 43
      consensus/consensus_v2.go
  4. 1
      consensus/quorum/one-node-one-vote.go
  5. 10
      consensus/quorum/one-node-staked-vote.go
  6. 4
      consensus/quorum/quorum.go
  7. 1
      internal/chain/engine.go
  8. 6
      node/node.go
  9. 2
      node/node_genesis.go
  10. 9
      node/node_newblock.go
  11. 2
      shard/committee/assignment.go

@ -304,7 +304,7 @@ func createWalletNode() *node.Node {
panic(err)
}
chainDBFactory := &shardchain.MemDBFactory{}
w := node.New(host, nil, chainDBFactory, false, "")
w := node.New(host, nil, chainDBFactory, false)
w.Client = client.NewClient(w.GetHost(), uint32(shardID))
w.NodeConfig.SetRole(nodeconfig.ClientNode)

@ -309,9 +309,7 @@ func setupConsensusAndNode(nodeConfig *nodeconfig.ConfigType) *node.Node {
// Current node.
chainDBFactory := &shardchain.LDBFactory{RootDir: nodeConfig.DBDir}
currentNode := node.New(
myHost, currentConsensus, chainDBFactory, *isArchival, *port,
)
currentNode := node.New(myHost, currentConsensus, chainDBFactory, *isArchival)
switch {
case *networkType == nodeconfig.Localnet:
@ -496,7 +494,6 @@ func main() {
currentNode.ServiceManagerSetup()
currentNode.RunServices()
// fmt.Println("CurrentRPC-port", *port)
// RPC for SDK not supported for mainnet.
if err := currentNode.StartRPC(*port); err != nil {

@ -4,7 +4,6 @@ import (
"bytes"
"encoding/binary"
"encoding/hex"
"fmt"
"time"
"github.com/ethereum/go-ethereum/common"
@ -316,54 +315,12 @@ func (consensus *Consensus) onPrepare(msg *msg_pb.Message) {
}
senderKey, err := consensus.verifySenderKey(msg)
// fmt.Println("prepare-sender-key", senderKey.SerializeToHexStr())
// for _, v := range consensus.Decider.DumpParticipants() {
// fmt.Println("in-committee-", consensus.ShardID, v)
// }
type t struct {
Participants []string `json:"committee-members"`
ShardID uint32 `json:"shard-id"`
MissingID string `json"missing-key"`
CurrentEpoch uint64 `json:"current-epoch"`
CurrentObject uint64 `json:"current-epoch-from-obj"`
PossibleError string `json:"possible-error"`
}
// e := ""
// if err != nil {
// e = err.Error()
// }
// b, _ := json.Marshal(t{
// consensus.Decider.DumpParticipants(),
// consensus.ShardID,
// senderKey.SerializeToHexStr(),
// consensus.ChainReader.CurrentHeader().Epoch().Uint64(),
// consensus.epoch,
// e,
// })
// fmt.Println(string(b))
if err != nil {
// fmt.Println("On Prepare is busted =/", err, "on shard-", consensus.ShardID)
utils.Logger().Error().Err(err).Msg("[OnPrepare] VerifySenderKey failed")
return
}
if err = verifyMessageSig(senderKey, msg); err != nil {
fmt.Println("unable to verify message sig")
// p := consensus.Decider.DumpParticipants()
// for _, k := range p {
// if senderKey.SerializeToHexStr() == k {
// fmt.Println("Sender is in my committee quorum", consensus.PubKey.SerializeToHexStr())
// break
// }
// }
// fmt.Println("Bad sender?", senderKey.SerializeToHexStr())
utils.Logger().Error().Err(err).Msg("[OnPrepare] Failed to verify sender's signature")
return
}

@ -77,7 +77,6 @@ func (v *uniformVoteWeight) Award(
func (v *uniformVoteWeight) ShouldSlash(k shard.BlsPublicKey) bool {
// No-op, no semantic meaning in one-slot-one-vote
// fmt.Println("Called here for key:", k.Hex())
return false
}

@ -2,7 +2,6 @@ package quorum
import (
"encoding/json"
"fmt"
"math/big"
"github.com/ethereum/go-ethereum/common"
@ -40,8 +39,7 @@ func (v *stakedVoteWeight) Policy() Policy {
// IsQuorumAchieved ..
func (v *stakedVoteWeight) IsQuorumAchieved(p Phase) bool {
// TODO Implement this logic
// fmt.Println("is quorum achieved")
// TODO Implement this logic w/Chao
// soFar := numeric.ZeroDec()
w := shard.BlsPublicKey{}
members := v.Participants()
@ -59,14 +57,12 @@ func (v *stakedVoteWeight) IsQuorumAchieved(p Phase) bool {
// QuorumThreshold ..
func (v *stakedVoteWeight) QuorumThreshold() *big.Int {
// fmt.Println("check quorum threshold")
return v.total.Mul(twoThirds).Int
}
// RewardThreshold ..
func (v *stakedVoteWeight) IsRewardThresholdAchieved() bool {
// TODO Implement
// fmt.Println("check threshold")
return true
}
@ -77,9 +73,7 @@ func (v *stakedVoteWeight) Award(
payout := big.NewInt(0)
last := big.NewInt(0)
count := big.NewInt(int64(len(earners)))
s, _ := v.ShardIDProvider()()
fmt.Println("Award called on shard as staked vote", s)
// TODO Finish implementing this logic
proportional := map[common.Address]numeric.Dec{}
for _, details := range v.validatorStakes {

@ -156,7 +156,7 @@ func (s *cIdentities) Participants() []*bls.PublicKey {
}
func (s *cIdentities) UpdateParticipants(pubKeys []*bls.PublicKey) {
// TODO - might need to put this in separate method
// TODO - might need to put reset of seen counter in separate method
s.seenCounter = make(map[[shard.PublicKeySizeInBytes]byte]int, len(pubKeys))
for i := range pubKeys {
k := shard.BlsPublicKey{}
@ -168,9 +168,7 @@ func (s *cIdentities) UpdateParticipants(pubKeys []*bls.PublicKey) {
func (s *cIdentities) SlashThresholdMet(key shard.BlsPublicKey) bool {
s.seenCounter[key]++
fmt.Println("Slash Map", s.seenCounter)
return s.seenCounter[key] == slash.UnavailabilityInConsecutiveBlockSigning
}
func (s *cIdentities) DumpParticipants() []string {

@ -200,7 +200,6 @@ func (e *engineImpl) Finalize(
}
for _, validator := range validators {
wrapper := state.GetStakingInfo(validator)
// fmt.Println("In finalize", validator.String(), "wrapper:", wrapper, "on-epoch", header.Epoch(), "on-shard", header.ShardID())
if wrapper != nil {
for i := range wrapper.Delegations {
delegation := wrapper.Delegations[i]

@ -103,7 +103,6 @@ type syncConfig struct {
// Node represents a protocol-participating node in the network
type Node struct {
myPort string
Consensus *consensus.Consensus // Consensus object containing all Consensus related data (e.g. committee members, signatures, commits)
BlockChannel chan *types.Block // The channel to send newly proposed blocks
ConfirmedBlockChannel chan *types.Block // The channel to send confirmed blocks
@ -375,12 +374,9 @@ func (node *Node) GetSyncID() [SyncIDLength]byte {
// New creates a new node.
func New(host p2p.Host, consensusObj *consensus.Consensus,
chainDBFactory shardchain.DBFactory, isArchival bool, port string) *Node {
chainDBFactory shardchain.DBFactory, isArchival bool) *Node {
node := Node{}
node.myPort = port
// fmt.Println("as node, my port is", node.myPort)
node.syncFreq = SyncFrequency
node.beaconSyncFreq = SyncFrequency

@ -44,8 +44,6 @@ func (gi *genesisInitializer) InitChainDB(db ethdb.Database, shardID uint32) err
big.NewInt(core.GenesisEpoch), gi.node.chainConfig, nil,
)
// fmt.Println("initial-shard-state", shardState.JSON())
if shardID != shard.BeaconChainShardID {
// store only the local shard for shard chains
c := shardState.FindCommitteeByID(shardID)

@ -1,7 +1,6 @@
package node
import (
"math/big"
"sort"
"time"
@ -124,14 +123,6 @@ func (node *Node) proposeNewBlock() (*types.Block, error) {
node.Consensus.ShardID, node.Beaconchain(),
)
// fmt.Println("Update my keys, right", "on port", node.NodeConfig.Port)
if node.Beaconchain().CurrentHeader().Epoch().Cmp(big.NewInt(1)) == 0 {
// fmt.Println("Update my keys, right", "on port", node.NodeConfig.Port)
// node.NodeConfig.ConsensusPriKey
// node.NodeConfig.ConsensusPubKey
}
// fmt.Println("super-comm", shardState.JSON())
if err != nil {
return nil, err

@ -128,7 +128,6 @@ func eposStakedCommittee(
if err != nil {
return nil, err
}
essentials[validator.Address] = effective.SlotOrder{
validator.Stake,
validator.SlotPubKeys,
@ -173,6 +172,7 @@ func eposStakedCommittee(
&slot.Dec,
})
}
return superComm, nil
}

Loading…
Cancel
Save