[committee] Remove debug code, use shardchain db instead of beaconchain

pull/1850/head
Edgar Aroutiounian 5 years ago
parent f348e10a5c
commit 5eb5e7a6b0
  1. 5
      cmd/harmony/main.go
  2. 1
      consensus/consensus_v2.go
  3. 6
      consensus/engine/consensus_engine.go
  4. 1
      core/state/statedb.go
  5. 1
      node/node_genesis.go
  6. 3
      node/node_newblock.go

@ -224,6 +224,7 @@ func setupConsensusKey(nodeConfig *nodeconfig.ConfigType) *bls.PublicKey {
os.Exit(100)
}
pubKey := consensusPriKey.GetPublicKey()
// Consensus keys are the BLS12-381 keys used to sign consensus messages
nodeConfig.ConsensusPriKey, nodeConfig.ConsensusPubKey = consensusPriKey, consensusPriKey.GetPublicKey()
if nodeConfig.ConsensusPriKey == nil || nodeConfig.ConsensusPubKey == nil {
@ -235,6 +236,7 @@ func setupConsensusKey(nodeConfig *nodeconfig.ConfigType) *bls.PublicKey {
func createGlobalConfig() *nodeconfig.ConfigType {
var err error
nodeConfig := nodeconfig.GetShardConfig(initialAccount.ShardID)
if *nodeType == "validator" {
// Set up consensus keys.
@ -308,7 +310,6 @@ func setupConsensusAndNode(nodeConfig *nodeconfig.ConfigType) *node.Node {
// Current node.
chainDBFactory := &shardchain.LDBFactory{RootDir: nodeConfig.DBDir}
currentNode := node.New(myHost, currentConsensus, chainDBFactory, *isArchival)
switch {
@ -339,6 +340,7 @@ func setupConsensusAndNode(nodeConfig *nodeconfig.ConfigType) *node.Node {
currentNode.NodeConfig.SetPushgatewayIP(nodeConfig.PushgatewayIP)
currentNode.NodeConfig.SetPushgatewayPort(nodeConfig.PushgatewayPort)
currentNode.NodeConfig.SetMetricsFlag(nodeConfig.MetricsFlag)
currentNode.NodeConfig.SetBeaconGroupID(nodeconfig.NewGroupIDByShardID(0))
switch *nodeType {
@ -494,7 +496,6 @@ func main() {
currentNode.ServiceManagerSetup()
currentNode.RunServices()
// RPC for SDK not supported for mainnet.
if err := currentNode.StartRPC(*port); err != nil {
utils.Logger().Warn().

@ -319,7 +319,6 @@ func (consensus *Consensus) onPrepare(msg *msg_pb.Message) {
utils.Logger().Error().Err(err).Msg("[OnPrepare] VerifySenderKey failed")
return
}
if err = verifyMessageSig(senderKey, msg); err != nil {
utils.Logger().Error().Err(err).Msg("[OnPrepare] Failed to verify sender's signature")
return

@ -10,6 +10,7 @@ import (
"github.com/harmony-one/harmony/core/types"
"github.com/harmony-one/harmony/internal/params"
"github.com/harmony-one/harmony/shard"
"github.com/harmony-one/harmony/shard/committee"
"github.com/harmony-one/harmony/staking/slash"
staking "github.com/harmony-one/harmony/staking/types"
)
@ -44,9 +45,8 @@ type ChainReader interface {
// ReadActiveValidatorList retrieves the list of active validators
ReadActiveValidatorList() ([]common.Address, error)
ValidatorCandidates() []common.Address
ReadValidatorData(addr common.Address) (*staking.ValidatorWrapper, error)
ValidatorStakingWithDelegation(addr common.Address) *big.Int
// Methods needed for EPoS committee assignment calculation
committee.StakingCandidatesReader
}
// Engine is an algorithm agnostic consensus engine.

@ -30,6 +30,7 @@ import (
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/trie"
"github.com/harmony-one/harmony/core/types"
"github.com/harmony-one/harmony/staking"
stk "github.com/harmony-one/harmony/staking/types"

@ -43,7 +43,6 @@ func (gi *genesisInitializer) InitChainDB(db ethdb.Database, shardID uint32) err
shardState, _ := committee.WithStakingEnabled.Compute(
big.NewInt(core.GenesisEpoch), gi.node.chainConfig, nil,
)
if shardID != shard.BeaconChainShardID {
// store only the local shard for shard chains
c := shardState.FindCommitteeByID(shardID)

@ -120,10 +120,9 @@ func (node *Node) proposeNewBlock() (*types.Block, error) {
// Prepare shard state
shardState, err := node.Worker.SuperCommitteeForNextEpoch(
node.Consensus.ShardID, node.Beaconchain(),
node.Consensus.ShardID, node.Blockchain(),
)
// fmt.Println("super-comm", shardState.JSON())
if err != nil {
return nil, err
}

Loading…
Cancel
Save