Skip to content

Commit

Permalink
Custom genesis generation for [email protected]+.
Browse files Browse the repository at this point in the history
  • Loading branch information
Frozen committed Jul 16, 2024
1 parent e662dc6 commit 8378201
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 7 deletions.
10 changes: 3 additions & 7 deletions core/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,12 @@ package core

import (
"bytes"
"crypto/ecdsa"
"encoding/hex"
"encoding/json"
"errors"
"fmt"
"math/big"
"os"
"strings"

"github.com/ethereum/go-ethereum/common"
ethCommon "github.com/ethereum/go-ethereum/common"
Expand All @@ -35,6 +33,7 @@ import (
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/rlp"
blockfactory "github.com/harmony-one/harmony/block/factory"
"github.com/harmony-one/harmony/core/genesis"
"github.com/harmony-one/harmony/internal/params"
"github.com/harmony-one/harmony/staking/slash"

Expand Down Expand Up @@ -124,11 +123,8 @@ func NewGenesisSpec(netType nodeconfig.NetworkType, shardID uint32) *Genesis {
if netType != nodeconfig.Mainnet {
gasLimit = params.TestGenesisGasLimit
// Smart contract deployer account used to deploy initial smart contract
contractDeployerKey, _ := ecdsa.GenerateKey(
crypto.S256(),
strings.NewReader("Test contract key string stream that is fixed so that generated test key are deterministic every time"),
)
contractDeployerAddress := crypto.PubkeyToAddress(contractDeployerKey.PublicKey)

contractDeployerAddress := crypto.PubkeyToAddress(genesis.ContractDeployerKey.PublicKey)
contractDeployerFunds := big.NewInt(ContractDeployerInitFund)
contractDeployerFunds = contractDeployerFunds.Mul(
contractDeployerFunds, big.NewInt(denominations.One),
Expand Down
17 changes: 17 additions & 0 deletions core/genesis/go19.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//go:build 1.19
// +build 1.19

package genesis

var ContractDeployerKey *ecdsa.PrivateKey

func init() {
var err error
ContractDeployerKey, err = ecdsa.GenerateKey(
crypto.S256(),
strings.NewReader("Test contract key string stream that is fixed so that generated test key are deterministic every time"),
)
if err != nil {
panic(err)
}
}
31 changes: 31 additions & 0 deletions core/genesis/go20.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//go:build go1.20
// +build go1.20

package genesis

import (
"crypto/ecdsa"
"math/big"

"github.com/ethereum/go-ethereum/crypto"
)

var ContractDeployerKey *ecdsa.PrivateKey

func init() {
D := &big.Int{}
D.SetString("65737420636f6e7472616374206b657920737472696e672073747265616d2074", 16)
X := &big.Int{}
X.SetString("3d4fc035410b035f72da12df457ce17e255cede9fc9e72796ac3868ceb2ed226", 16)
Y := &big.Int{}
Y.SetString("808248810e75eb32859e46cdd8e541ed9f323bde6076d2ca6fd75d6cf0ffd089", 16)

ContractDeployerKey = &ecdsa.PrivateKey{
D: D,
PublicKey: ecdsa.PublicKey{
Curve: crypto.S256(),
X: X,
Y: Y,
},
}
}

0 comments on commit 8378201

Please sign in to comment.