diff options
author | Péter Szilágyi <peterke@gmail.com> | 2017-10-24 18:40:42 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-24 18:40:42 +0800 |
commit | 6d6a5a93370371a33fb815d7ae47b60c7021c86a (patch) | |
tree | aa73dff1db3aa2566c2e74cf9ac37f13878fae80 /core/genesis.go | |
parent | ea5f2da39ad198e58107a79214419e31988c5e5a (diff) | |
download | go-tangerine-6d6a5a93370371a33fb815d7ae47b60c7021c86a.tar go-tangerine-6d6a5a93370371a33fb815d7ae47b60c7021c86a.tar.gz go-tangerine-6d6a5a93370371a33fb815d7ae47b60c7021c86a.tar.bz2 go-tangerine-6d6a5a93370371a33fb815d7ae47b60c7021c86a.tar.lz go-tangerine-6d6a5a93370371a33fb815d7ae47b60c7021c86a.tar.xz go-tangerine-6d6a5a93370371a33fb815d7ae47b60c7021c86a.tar.zst go-tangerine-6d6a5a93370371a33fb815d7ae47b60c7021c86a.zip |
cmd, consensus, core, miner: instatx clique for --dev (#15323)
* cmd, consensus, core, miner: instatx clique for --dev
* cmd, consensus, clique: support configurable --dev block times
* cmd, core: allow --dev to use persistent storage too
Diffstat (limited to 'core/genesis.go')
-rw-r--r-- | core/genesis.go | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/core/genesis.go b/core/genesis.go index fd6ed6115..26b1c9f63 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -151,7 +151,7 @@ func (e *GenesisMismatchError) Error() string { // The returned chain configuration is never nil. func SetupGenesisBlock(db ethdb.Database, genesis *Genesis) (*params.ChainConfig, common.Hash, error) { if genesis != nil && genesis.Config == nil { - return params.AllProtocolChanges, common.Hash{}, errGenesisNoConfig + return params.AllEthashProtocolChanges, common.Hash{}, errGenesisNoConfig } // Just commit the new block if there is no stored genesis block. @@ -216,7 +216,7 @@ func (g *Genesis) configOrDefault(ghash common.Hash) *params.ChainConfig { case ghash == params.TestnetGenesisHash: return params.TestnetChainConfig default: - return params.AllProtocolChanges + return params.AllEthashProtocolChanges } } @@ -285,7 +285,7 @@ func (g *Genesis) Commit(db ethdb.Database) (*types.Block, error) { } config := g.Config if config == nil { - config = params.AllProtocolChanges + config = params.AllEthashProtocolChanges } return block, WriteChainConfig(db, block.Hash(), config) } @@ -342,14 +342,30 @@ func DefaultRinkebyGenesisBlock() *Genesis { } } -// DevGenesisBlock returns the 'geth --dev' genesis block. -func DevGenesisBlock() *Genesis { +// DeveloperGenesisBlock returns the 'geth --dev' genesis block. Note, this must +// be seeded with the +func DeveloperGenesisBlock(period uint64, faucet common.Address) *Genesis { + // Override the default period to the user requested one + config := *params.AllCliqueProtocolChanges + config.Clique.Period = period + + // Assemble and return the genesis with the precompiles and faucet pre-funded return &Genesis{ - Config: params.AllProtocolChanges, - Nonce: 42, - GasLimit: 4712388, - Difficulty: big.NewInt(131072), - Alloc: decodePrealloc(devAllocData), + Config: &config, + ExtraData: append(append(make([]byte, 32), faucet[:]...), make([]byte, 65)...), + GasLimit: 6283185, + Difficulty: big.NewInt(1), + Alloc: map[common.Address]GenesisAccount{ + common.BytesToAddress([]byte{1}): GenesisAccount{Balance: big.NewInt(1)}, // ECRecover + common.BytesToAddress([]byte{2}): GenesisAccount{Balance: big.NewInt(1)}, // SHA256 + common.BytesToAddress([]byte{3}): GenesisAccount{Balance: big.NewInt(1)}, // RIPEMD + common.BytesToAddress([]byte{4}): GenesisAccount{Balance: big.NewInt(1)}, // Identity + common.BytesToAddress([]byte{5}): GenesisAccount{Balance: big.NewInt(1)}, // ModExp + common.BytesToAddress([]byte{6}): GenesisAccount{Balance: big.NewInt(1)}, // ECAdd + common.BytesToAddress([]byte{7}): GenesisAccount{Balance: big.NewInt(1)}, // ECScalarMul + common.BytesToAddress([]byte{8}): GenesisAccount{Balance: big.NewInt(1)}, // ECPairing + faucet: GenesisAccount{Balance: new(big.Int).Sub(new(big.Int).Lsh(big.NewInt(1), 256), big.NewInt(9))}, + }, } } |