From 586b6a7822d4d0344b82bb516f314a5a90e291d8 Mon Sep 17 00:00:00 2001 From: Rongjian Lan Date: Wed, 4 Sep 2019 16:56:28 -0700 Subject: [PATCH] Fix comments --- api/service/staking/service.go | 4 ++-- core/resharding.go | 16 +--------------- internal/keystore/keystore.go | 4 ++-- internal/params/config.go | 5 +++++ node/node_newblock.go | 2 +- 5 files changed, 11 insertions(+), 20 deletions(-) diff --git a/api/service/staking/service.go b/api/service/staking/service.go index 295e31159..3e882b5ba 100644 --- a/api/service/staking/service.go +++ b/api/service/staking/service.go @@ -222,8 +222,8 @@ func (s *Service) createRawStakingMessage() []byte { ) // This is currently not called. - hmykey.Unlock(s.account) - if signedTx, err := hmykey.SignTx(s.account, tx); err == nil { + chainID := big.NewInt(1) // TODO: wire the correct chain ID after staking flow is revamped. + if signedTx, err := hmykey.SignTx(s.account, tx, chainID); err == nil { ts := types.Transactions{signedTx} return constructStakingMessage(ts) } diff --git a/core/resharding.go b/core/resharding.go index 36556ebe6..4cd2885ba 100644 --- a/core/resharding.go +++ b/core/resharding.go @@ -133,21 +133,6 @@ func Shuffle(list []shard.NodeID) { }) } -// GetBlockNumberFromEpoch calculates the block number where epoch sharding information is stored -// TODO lc - use ShardingSchedule function -// WARNING: -//func GetBlockNumberFromEpoch(epoch uint64) uint64 { -// number := epoch * ShardingSchedule.BlocksPerEpoch() // currently we use the first block in each epoch -// return number -//} - -// GetLastBlockNumberFromEpoch calculates the last block number for the given -// epoch. TODO ek – this is a temp hack. -// TODO lc - use ShardingSchedule function -//func GetLastBlockNumberFromEpoch(epoch uint64) uint64 { -// return (epoch+1)*ShardingSchedule.BlocksPerEpoch() - 1 -//} - // GetEpochFromBlockNumber calculates the epoch number the block belongs to func GetEpochFromBlockNumber(blockNumber uint64) uint64 { return ShardingSchedule.CalcEpochNumber(blockNumber).Uint64() @@ -164,6 +149,7 @@ func GetShardingStateFromBlockChain(bc *BlockChain, epoch *big.Int) (*ShardingSt } shardState = shardState.DeepCopy() + // TODO(RJ,HB): use real randomness for resharding //blockNumber := GetBlockNumberFromEpoch(epoch.Uint64()) //rndSeedBytes := bc.GetVdfByNumber(blockNumber) rndSeed := uint64(0) diff --git a/internal/keystore/keystore.go b/internal/keystore/keystore.go index 6035bcdf1..9b142bad2 100644 --- a/internal/keystore/keystore.go +++ b/internal/keystore/keystore.go @@ -41,9 +41,9 @@ func Unlock(account accounts.Account) { } // SignTx signs transaction using account key -func SignTx(account accounts.Account, tx *types.Transaction) (*types.Transaction, error) { +func SignTx(account accounts.Account, tx *types.Transaction, chainID *big.Int) (*types.Transaction, error) { if hmyKeystore != nil { - return hmyKeystore.SignTx(account, tx, big.NewInt(1)) // TODO: use chainID from config + return hmyKeystore.SignTx(account, tx, chainID) } return tx, fmt.Errorf("un-initialized keystore") } diff --git a/internal/params/config.go b/internal/params/config.go index 34abe1c63..05ac74a60 100644 --- a/internal/params/config.go +++ b/internal/params/config.go @@ -9,6 +9,7 @@ import ( // Genesis hashes to enforce below configs on. var ( + // TODO: populate with real genesis hash (sharded) MainnetGenesisHash = common.HexToHash("0x") TestnetGenesisHash = common.HexToHash("0x") ) @@ -31,9 +32,13 @@ var ( } // AllProtocolChanges ... + // This configuration is intentionally not using keyed fields to force anyone + // adding flags to the config to also have to set these fields. AllProtocolChanges = &ChainConfig{big.NewInt(100), big.NewInt(0), big.NewInt(0), big.NewInt(0)} // TestChainConfig ... + // This configuration is intentionally not using keyed fields to force anyone + // adding flags to the config to also have to set these fields. TestChainConfig = &ChainConfig{big.NewInt(99), big.NewInt(0), big.NewInt(0), big.NewInt(0)} // TestRules ... diff --git a/node/node_newblock.go b/node/node_newblock.go index 54b8e8d45..44e5ab77f 100644 --- a/node/node_newblock.go +++ b/node/node_newblock.go @@ -50,7 +50,7 @@ func (node *Node) WaitForConsensusReadyV2(readySignal chan struct{}, stopChan ch utils.Logger().Debug(). Uint64("blockNum", node.Blockchain().CurrentBlock().NumberU64()+1). - Msg("=========Proposing New Block==========") + Msg("PROPOSING NEW BLOCK ------------------------------------------------") newBlock, err := node.proposeNewBlock()