|
|
|
@ -12,7 +12,9 @@ import ( |
|
|
|
|
"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" |
|
|
|
|
) |
|
|
|
|
|
|
|
|
@ -27,6 +29,9 @@ 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
|
|
|
|
|
|
|
|
|
@ -53,11 +58,25 @@ 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: core.GetInitShardState().Hash(), |
|
|
|
|
ShardStateHash: localShardStateHash, |
|
|
|
|
ShardState: localShardState, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Store genesis block into db.
|
|
|
|
|