core, core/state, trie: Hardfork EIP155, EIP161, EIP170

This commit implements EIP158 part 1, 2, 3 & 4

1. If an account is empty it's no longer written to the trie. An empty
  account is defined as (balance=0, nonce=0, storage=0, code=0).
2. Delete an empty account if it's touched
3. An empty account is redefined as either non-existent or empty.
4. Zero value calls and zero value suicides no longer consume the 25k
  reation costs.

params: moved core/config to params

Signed-off-by: Jeffrey Wilcke <jeffrey@ethereum.org>
This commit is contained in:
Jeffrey Wilcke
2016-10-20 13:36:29 +02:00
parent ef9265d0d7
commit dc2e34ddf3
936 changed files with 149218 additions and 66328 deletions

View File

@@ -769,7 +769,7 @@ func SetupNetwork(ctx *cli.Context) {
}
// MustMakeChainConfig reads the chain configuration from the database in ctx.Datadir.
func MustMakeChainConfig(ctx *cli.Context) *core.ChainConfig {
func MustMakeChainConfig(ctx *cli.Context) *params.ChainConfig {
db := MakeChainDatabase(ctx)
defer db.Close()
@@ -777,9 +777,9 @@ func MustMakeChainConfig(ctx *cli.Context) *core.ChainConfig {
}
// MustMakeChainConfigFromDb reads the chain configuration from the given database.
func MustMakeChainConfigFromDb(ctx *cli.Context, db ethdb.Database) *core.ChainConfig {
func MustMakeChainConfigFromDb(ctx *cli.Context, db ethdb.Database) *params.ChainConfig {
// If the chain is already initialized, use any existing chain configs
config := new(core.ChainConfig)
config := new(params.ChainConfig)
genesis := core.GetBlock(db, core.GetCanonicalHash(db, 0))
if genesis != nil {
@@ -793,6 +793,9 @@ func MustMakeChainConfigFromDb(ctx *cli.Context, db ethdb.Database) *core.ChainC
Fatalf("Could not make chain configuration: %v", err)
}
}
if config.ChainId == nil {
config.ChainId = new(big.Int)
}
// Set any missing fields due to them being unset or system upgrade
if config.HomesteadBlock == nil {
if ctx.GlobalBool(TestNetFlag.Name) {
@@ -809,11 +812,39 @@ func MustMakeChainConfigFromDb(ctx *cli.Context, db ethdb.Database) *core.ChainC
}
config.DAOForkSupport = true
}
if config.HomesteadGasRepriceBlock == nil {
if config.EIP150Block == nil {
if ctx.GlobalBool(TestNetFlag.Name) {
config.HomesteadGasRepriceBlock = params.TestNetHomesteadGasRepriceBlock
config.EIP150Block = params.TestNetHomesteadGasRepriceBlock
} else {
config.HomesteadGasRepriceBlock = params.MainNetHomesteadGasRepriceBlock
config.EIP150Block = params.MainNetHomesteadGasRepriceBlock
}
}
if config.EIP150Hash == (common.Hash{}) {
if ctx.GlobalBool(TestNetFlag.Name) {
config.EIP150Hash = params.TestNetHomesteadGasRepriceHash
} else {
config.EIP150Hash = params.MainNetHomesteadGasRepriceHash
}
}
if config.EIP155Block == nil {
if ctx.GlobalBool(TestNetFlag.Name) {
config.EIP150Block = params.TestNetSpuriousDragon
} else {
config.EIP155Block = params.MainNetSpuriousDragon
}
}
if config.EIP158Block == nil {
if ctx.GlobalBool(TestNetFlag.Name) {
config.EIP158Block = params.TestNetSpuriousDragon
} else {
config.EIP158Block = params.MainNetSpuriousDragon
}
}
if config.ChainId.BitLen() == 0 {
if ctx.GlobalBool(TestNetFlag.Name) {
config.ChainId = params.TestNetChainID
} else {
config.ChainId = params.MainNetChainID
}
}
// Force override any existing configs if explicitly requested