Remove ShardState and ShardStateHash from genesis

They now belong to epoch-last blocks.
pull/839/head
Eugene Kim 6 years ago
parent cca34560b0
commit c4338ad890
  1. 2
      core/genesis.go
  2. 21
      node/node_genesis.go

@ -253,7 +253,7 @@ func (g *Genesis) ToBlock(db ethdb.Database) *types.Block {
Coinbase: g.Coinbase,
Root: root,
ShardStateHash: g.ShardStateHash,
ShardState: g.ShardState,
// ShardState is absent in epoch block; genesis shard state is implied
}
if g.GasLimit == 0 {
head.GasLimit = 10000000000 // TODO(RJ): figure out better solution. // params.GenesisGasLimit

@ -11,10 +11,9 @@ import (
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/params"
"github.com/harmony-one/harmony/core"
"github.com/harmony-one/harmony/core/types"
"github.com/harmony-one/harmony/core/vm"
"github.com/harmony-one/harmony/internal/utils"
"github.com/harmony-one/harmony/internal/utils/contract"
)
@ -29,9 +28,6 @@ const (
// GenesisBlockSetup setups a genesis blockchain.
func (node *Node) GenesisBlockSetup(db ethdb.Database, shardID uint32, isArchival bool) (*core.BlockChain, error) {
logger := utils.GetLogInstance().New(
"shardID", shardID,
"isArchival", isArchival)
// Initialize genesis block and blockchain
// Tests account for txgen to use
@ -58,25 +54,10 @@ func (node *Node) GenesisBlockSetup(db ethdb.Database, shardID uint32, isArchiva
// TODO: create separate chain config instead of using the same pointer reference
chainConfig := *params.TestChainConfig
chainConfig.ChainID = big.NewInt(int64(shardID)) // Use ChainID as piggybacked ShardID
shardState := core.GetInitShardState()
var localShardState types.ShardState
var localShardStateHash common.Hash
for idx, oneShardState := range shardState {
if oneShardState.ShardID == shardID {
localShardState = shardState[idx : idx+1]
localShardStateHash = localShardState.Hash()
break
}
}
if localShardState == nil {
logger.Warn("initial shard state did not contain our shard")
}
gspec := core.Genesis{
Config: &chainConfig,
Alloc: genesisAlloc,
ShardID: shardID,
ShardStateHash: localShardStateHash,
ShardState: localShardState,
}
// Store genesis block into db.

Loading…
Cancel
Save