aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorWei-Ning Huang <w@dexon.org>2019-03-17 10:43:10 +0800
committerWei-Ning Huang <w@byzantine-lab.io>2019-06-12 17:27:23 +0800
commit5f64e1d10d620a8a299ff3a40695f26107f157c5 (patch)
treee28e2bf073ac7da8417e5b0789d2d0713e240ae7 /core
parent9493109f2be4507605e6b17e406bf8fd147ab3c8 (diff)
downloadgo-tangerine-5f64e1d10d620a8a299ff3a40695f26107f157c5.tar
go-tangerine-5f64e1d10d620a8a299ff3a40695f26107f157c5.tar.gz
go-tangerine-5f64e1d10d620a8a299ff3a40695f26107f157c5.tar.bz2
go-tangerine-5f64e1d10d620a8a299ff3a40695f26107f157c5.tar.lz
go-tangerine-5f64e1d10d620a8a299ff3a40695f26107f157c5.tar.xz
go-tangerine-5f64e1d10d620a8a299ff3a40695f26107f157c5.tar.zst
go-tangerine-5f64e1d10d620a8a299ff3a40695f26107f157c5.zip
core: fill in genesis timstamp and remove dMoment from protocol handshake (#263)
Fill in dmoment as genesis block timestamp. This allow us to remove dMoment check from protocol handshake since genesis block hash itself will protect us against different dMoment.
Diffstat (limited to 'core')
-rw-r--r--core/genesis.go5
-rw-r--r--core/genesis_test.go10
2 files changed, 14 insertions, 1 deletions
diff --git a/core/genesis.go b/core/genesis.go
index f2df4f62f..10585bab4 100644
--- a/core/genesis.go
+++ b/core/genesis.go
@@ -384,7 +384,7 @@ func GenesisBlockForTesting(db ethdb.Database, addr common.Address, balance *big
func DefaultGenesisBlock() *Genesis {
return &Genesis{
Config: params.MainnetChainConfig,
- Timestamp: 1540024964,
+ Timestamp: params.MainnetChainConfig.DMoment,
Nonce: 0x42,
ExtraData: hexutil.MustDecode("0x5765692d4e696e6720536f6e696320426f6a696520323031382d31302d32302e"),
GasLimit: 40000000,
@@ -397,6 +397,7 @@ func DefaultGenesisBlock() *Genesis {
func DefaultTestnetGenesisBlock() *Genesis {
return &Genesis{
Config: params.TestnetChainConfig,
+ Timestamp: params.TestnetChainConfig.DMoment,
Nonce: 0x42,
ExtraData: hexutil.MustDecode("0x3535353535353535353535353535353535353535353535353535353535353535"),
GasLimit: 40000000,
@@ -409,6 +410,7 @@ func DefaultTestnetGenesisBlock() *Genesis {
func DefaultTaipeiGenesisBlock() *Genesis {
return &Genesis{
Config: params.TaipeiChainConfig,
+ Timestamp: params.TaipeiChainConfig.DMoment,
Nonce: 0x42,
ExtraData: hexutil.MustDecode("0x3535353535353535353535353535353535353535353535353535353535353535"),
GasLimit: 40000000,
@@ -421,6 +423,7 @@ func DefaultTaipeiGenesisBlock() *Genesis {
func DefaultYilanGenesisBlock() *Genesis {
return &Genesis{
Config: params.YilanChainConfig,
+ Timestamp: params.YilanChainConfig.DMoment,
Nonce: 0x42,
ExtraData: hexutil.MustDecode("0x3535353535353535353535353535353535353535353535353535353535353535"),
GasLimit: 40000000,
diff --git a/core/genesis_test.go b/core/genesis_test.go
index de843e05a..16958eac3 100644
--- a/core/genesis_test.go
+++ b/core/genesis_test.go
@@ -105,6 +105,16 @@ func TestSetupGenesis(t *testing.T) {
wantConfig: params.TestnetChainConfig,
},
{
+ name: "custom block in DB, genesis == taipei",
+ fn: func(db ethdb.Database) (*params.ChainConfig, common.Hash, error) {
+ customg.MustCommit(db)
+ return SetupGenesisBlock(db, DefaultTaipeiGenesisBlock())
+ },
+ wantErr: &GenesisMismatchError{Stored: customghash, New: params.TaipeiGenesisHash},
+ wantHash: params.TaipeiGenesisHash,
+ wantConfig: params.TaipeiChainConfig,
+ },
+ {
name: "custom block in DB, genesis == yilan",
fn: func(db ethdb.Database) (*params.ChainConfig, common.Hash, error) {
customg.MustCommit(db)