diff --git a/cmd/puppeth/genesis.go b/cmd/puppeth/genesis.go index 0d172e5944..235f62fb39 100644 --- a/cmd/puppeth/genesis.go +++ b/cmd/puppeth/genesis.go @@ -26,11 +26,15 @@ import ( "github.com/ubiq/go-ubiq/common" "github.com/ubiq/go-ubiq/common/hexutil" math2 "github.com/ubiq/go-ubiq/common/math" - "github.com/ubiq/go-ubiq/consensus/ubqhash" + // "github.com/ubiq/go-ubiq/consensus/ubqhash" "github.com/ubiq/go-ubiq/core" "github.com/ubiq/go-ubiq/params" ) +var ( + blockReward *big.Int = big.NewInt(8e+18) // Block reward in wei for successfully mining a block +) + // alethGenesisSpec represents the genesis specification format used by the // C++ Ethereum implementation. type alethGenesisSpec struct { @@ -130,7 +134,7 @@ func newAlethGenesisSpec(network string, genesis *core.Genesis) (*alethGenesisSp spec.Params.DifficultyBoundDivisor = (*math2.HexOrDecimal256)(params.DifficultyBoundDivisor) spec.Params.GasLimitBoundDivisor = (math2.HexOrDecimal64)(params.GasLimitBoundDivisor) spec.Params.DurationLimit = (*math2.HexOrDecimal256)(params.DurationLimit) - spec.Params.BlockReward = (*hexutil.Big)(ubqhash.FrontierBlockReward) + spec.Params.BlockReward = (*hexutil.Big)(blockReward) spec.Genesis.Nonce = (hexutil.Bytes)(make([]byte, 8)) binary.LittleEndian.PutUint64(spec.Genesis.Nonce[:], genesis.Nonce) @@ -324,7 +328,7 @@ func newParityChainSpec(network string, genesis *core.Genesis, bootnodes []strin spec.Engine.Ubqhash.Params.MinimumDifficulty = (*hexutil.Big)(params.MinimumDifficulty) spec.Engine.Ubqhash.Params.DifficultyBoundDivisor = (*hexutil.Big)(params.DifficultyBoundDivisor) spec.Engine.Ubqhash.Params.DurationLimit = (*hexutil.Big)(params.DurationLimit) - spec.Engine.Ubqhash.Params.BlockReward["0x0"] = hexutil.EncodeBig(ubqhash.FrontierBlockReward) + spec.Engine.Ubqhash.Params.BlockReward["0x0"] = hexutil.EncodeBig(blockReward) // Homestead spec.Engine.Ubqhash.Params.HomesteadTransition = hexutil.Uint64(genesis.Config.HomesteadBlock.Uint64()) @@ -427,7 +431,7 @@ func (spec *parityChainSpec) setPrecompile(address byte, data *parityChainSpecBu } func (spec *parityChainSpec) setByzantium(num *big.Int) { - spec.Engine.Ubqhash.Params.BlockReward[hexutil.EncodeBig(num)] = hexutil.EncodeBig(ubqhash.ByzantiumBlockReward) + spec.Engine.Ubqhash.Params.BlockReward[hexutil.EncodeBig(num)] = hexutil.EncodeBig(blockReward) spec.Engine.Ubqhash.Params.DifficultyBombDelays[hexutil.EncodeBig(num)] = hexutil.EncodeUint64(3000000) n := hexutil.Uint64(num.Uint64()) spec.Engine.Ubqhash.Params.EIP100bTransition = n @@ -438,7 +442,7 @@ func (spec *parityChainSpec) setByzantium(num *big.Int) { } func (spec *parityChainSpec) setConstantinople(num *big.Int) { - spec.Engine.Ubqhash.Params.BlockReward[hexutil.EncodeBig(num)] = hexutil.EncodeBig(ubqhash.ConstantinopleBlockReward) + spec.Engine.Ubqhash.Params.BlockReward[hexutil.EncodeBig(num)] = hexutil.EncodeBig(blockReward) spec.Engine.Ubqhash.Params.DifficultyBombDelays[hexutil.EncodeBig(num)] = hexutil.EncodeUint64(2000000) n := hexutil.Uint64(num.Uint64()) spec.Params.EIP145Transition = n diff --git a/cmd/puppeth/wizard_genesis.go b/cmd/puppeth/wizard_genesis.go index 2a34dc33cb..f53487c442 100644 --- a/cmd/puppeth/wizard_genesis.go +++ b/cmd/puppeth/wizard_genesis.go @@ -248,28 +248,12 @@ func (w *wizard) manageGenesis() { out, _ := json.MarshalIndent(w.conf.Genesis, "", " ") // Export the native genesis spec used by puppeth and Gubiq - gethJson := filepath.Join(folder, fmt.Sprintf("%s.json", w.network)) - if err := ioutil.WriteFile((gethJson), out, 0644); err != nil { + gubiqJson := filepath.Join(folder, fmt.Sprintf("%s.json", w.network)) + if err := ioutil.WriteFile((gubiqJson), out, 0644); err != nil { log.Error("Failed to save genesis file", "err", err) return } log.Info("Saved native genesis chain spec", "path", gubiqJson) - - // Export the genesis spec used by Aleth (formerly C++ Ethereum) - if spec, err := newAlethGenesisSpec(w.network, w.conf.Genesis); err != nil { - log.Error("Failed to create Aleth chain spec", "err", err) - } else { - saveGenesis(folder, w.network, "aleth", spec) - } - // Export the genesis spec used by Parity - if spec, err := newParityChainSpec(w.network, w.conf.Genesis, []string{}); err != nil { - log.Error("Failed to create Parity chain spec", "err", err) - } else { - saveGenesis(folder, w.network, "parity", spec) - } - // Export the genesis spec used by Harmony (formerly EthereumJ - saveGenesis(folder, w.network, "harmony", w.conf.Genesis) - case "3": // Make sure we don't have any services running if len(w.conf.servers()) > 0 { diff --git a/cmd/swarm/swarm-smoke/main.go b/cmd/swarm/swarm-smoke/main.go index 6619a846dc..2cc2eeed82 100644 --- a/cmd/swarm/swarm-smoke/main.go +++ b/cmd/swarm/swarm-smoke/main.go @@ -22,7 +22,7 @@ import ( "sort" "github.com/ubiq/go-ubiq/cmd/utils" - gethmetrics "github.com/ubiq/go-ubiq/metrics" + gubiqmetrics "github.com/ubiq/go-ubiq/metrics" "github.com/ubiq/go-ubiq/metrics/influxdb" swarmmetrics "github.com/ubiq/go-ubiq/swarm/metrics" "github.com/ubiq/go-ubiq/swarm/tracing" @@ -183,7 +183,7 @@ func emitMetrics(ctx *cli.Context) error { tagsMap["version"] = gitCommit tagsMap["filesize"] = fmt.Sprintf("%v", filesize) - return influxdb.InfluxDBWithTagsOnce(gethmetrics.DefaultRegistry, endpoint, database, username, password, "swarm-smoke.", tagsMap) + return influxdb.InfluxDBWithTagsOnce(gubiqmetrics.DefaultRegistry, endpoint, database, username, password, "swarm-smoke.", tagsMap) } return nil diff --git a/swarm/metrics/flags.go b/swarm/metrics/flags.go index 5d3e30f315..92727eba0b 100644 --- a/swarm/metrics/flags.go +++ b/swarm/metrics/flags.go @@ -20,7 +20,7 @@ import ( "time" "github.com/ubiq/go-ubiq/cmd/utils" - gethmetrics "github.com/ubiq/go-ubiq/metrics" + gubiqmetrics "github.com/ubiq/go-ubiq/metrics" "github.com/ubiq/go-ubiq/metrics/influxdb" "github.com/ubiq/go-ubiq/swarm/log" cli "gopkg.in/urfave/cli.v1" @@ -97,12 +97,12 @@ func Setup(ctx *cli.Context) { if enableExport { log.Info("Enabling swarm metrics export to InfluxDB") - go influxdb.InfluxDBWithTags(gethmetrics.DefaultRegistry, 10*time.Second, endpoint, database, username, password, "swarm.", tagsMap) + go influxdb.InfluxDBWithTags(gubiqmetrics.DefaultRegistry, 10*time.Second, endpoint, database, username, password, "swarm.", tagsMap) } if enableAccountingExport { log.Info("Exporting swarm accounting metrics to InfluxDB") - go influxdb.InfluxDBWithTags(gethmetrics.AccountingRegistry, 10*time.Second, endpoint, database, username, password, "accounting.", tagsMap) + go influxdb.InfluxDBWithTags(gubiqmetrics.AccountingRegistry, 10*time.Second, endpoint, database, username, password, "accounting.", tagsMap) } } } diff --git a/tests/difficulty_test_util.go b/tests/difficulty_test_util.go index 039f7f328d..920cd5d525 100644 --- a/tests/difficulty_test_util.go +++ b/tests/difficulty_test_util.go @@ -23,6 +23,7 @@ import ( "github.com/ubiq/go-ubiq/common" "github.com/ubiq/go-ubiq/common/math" "github.com/ubiq/go-ubiq/consensus/ubqhash" + //"github.com/ubiq/go-ubiq/core/types" "github.com/ubiq/go-ubiq/params" ) @@ -49,14 +50,8 @@ type difficultyTestMarshaling struct { func (test *DifficultyTest) Run(config *params.ChainConfig) error { parentNumber := big.NewInt(int64(test.CurrentBlockNumber - 1)) - /*parent := &types.Header{ - Difficulty: test.ParentDifficulty, - Time: test.ParentTimestamp, - Number: parentNumber, - UncleHash: test.UncleHash, - }*/ - actual := ubqhash.CalcDifficulty(config, test.CurrentTimestamp, parent) + actual := ubqhash.CalcDifficultyLegacy(test.CurrentTimestamp, test.ParentTimestamp, parentNumber, test.ParentDifficulty) exp := test.CurrentDifficulty if actual.Cmp(exp) != 0 {