From 7a5b571c671e70e0e4807cf971c15e2d1e09d33d Mon Sep 17 00:00:00 2001 From: Jeffrey Wilcke Date: Sat, 18 Jun 2016 11:17:57 +0200 Subject: test, cmd/evm, core, core/vm: illegal code hash implementation This implements a generic approach to enabling soft forks by allowing anyone to put in hashes of contracts that should not be interacted from. This will help "The DAO" in their endevour to stop any whithdrawals from any DAO contract by convincing the mining community to accept their code hash. --- cmd/evm/main.go | 1 + cmd/utils/flags.go | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) (limited to 'cmd') diff --git a/cmd/evm/main.go b/cmd/evm/main.go index aa48f6ede..ba7d8d8a8 100644 --- a/cmd/evm/main.go +++ b/cmd/evm/main.go @@ -220,6 +220,7 @@ type ruleSet struct{} func (ruleSet) IsHomestead(*big.Int) bool { return true } +func (self *VMEnv) MarkCodeHash(common.Hash) {} func (self *VMEnv) RuleSet() vm.RuleSet { return ruleSet{} } func (self *VMEnv) Vm() vm.Vm { return self.evm } func (self *VMEnv) Db() vm.Database { return self.state } diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 14898b987..802e54c73 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -163,6 +163,10 @@ var ( } // Miner settings // TODO: refactor CPU vs GPU mining flags + IllegalCodeHashesFlag = cli.StringFlag{ + Name: "illegal-code-hashes", + Usage: "Comma separated list of code-hashes to ignore any interaction from", + } MiningEnabledFlag = cli.BoolFlag{ Name: "mine", Usage: "Enable mining", @@ -640,6 +644,16 @@ func MakePasswordList(ctx *cli.Context) []string { return lines } +// ParseIllegalCodeHashes parses a comma separated list of hashes. +func ParseIllegalCodeHashes(ctx *cli.Context) map[common.Hash]struct{} { + splittedHexHashes := strings.Split(ctx.GlobalString(IllegalCodeHashesFlag.Name), ",") + illegalCodeHashes := make(map[common.Hash]struct{}) + for _, hexHash := range splittedHexHashes { + illegalCodeHashes[common.HexToHash(strings.TrimSpace(hexHash))] = struct{}{} + } + return illegalCodeHashes +} + // MakeSystemNode sets up a local node, configures the services to launch and // assembles the P2P protocol stack. func MakeSystemNode(name, version string, relconf release.Config, extra []byte, ctx *cli.Context) *node.Node { @@ -676,6 +690,8 @@ func MakeSystemNode(name, version string, relconf release.Config, extra []byte, } // Configure the Ethereum service accman := MakeAccountManager(ctx) + // parse the illegal code hashes and set them to the core package. + core.IllegalCodeHashes = ParseIllegalCodeHashes(ctx) // initialise new random number generator rand := rand.New(rand.NewSource(time.Now().UnixNano())) -- cgit v1.2.3 From c4de28938ff8c688c4444c8b3e8e28a52cbc62ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Wed, 22 Jun 2016 11:59:28 +0300 Subject: core: add voting and result tracking for the dao soft-fork --- cmd/utils/flags.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'cmd') diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 802e54c73..c732a6635 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -163,8 +163,8 @@ var ( } // Miner settings // TODO: refactor CPU vs GPU mining flags - IllegalCodeHashesFlag = cli.StringFlag{ - Name: "illegal-code-hashes", + BlockedCodeHashesFlag = cli.StringFlag{ + Name: "blocked-code-hashes", Usage: "Comma separated list of code-hashes to ignore any interaction from", } MiningEnabledFlag = cli.BoolFlag{ @@ -644,9 +644,9 @@ func MakePasswordList(ctx *cli.Context) []string { return lines } -// ParseIllegalCodeHashes parses a comma separated list of hashes. -func ParseIllegalCodeHashes(ctx *cli.Context) map[common.Hash]struct{} { - splittedHexHashes := strings.Split(ctx.GlobalString(IllegalCodeHashesFlag.Name), ",") +// MakeBlockedCodeHashes parses a comma separated list of hashes. +func MakeBlockedCodeHashes(ctx *cli.Context) map[common.Hash]struct{} { + splittedHexHashes := strings.Split(ctx.GlobalString(BlockedCodeHashesFlag.Name), ",") illegalCodeHashes := make(map[common.Hash]struct{}) for _, hexHash := range splittedHexHashes { illegalCodeHashes[common.HexToHash(strings.TrimSpace(hexHash))] = struct{}{} @@ -690,8 +690,8 @@ func MakeSystemNode(name, version string, relconf release.Config, extra []byte, } // Configure the Ethereum service accman := MakeAccountManager(ctx) - // parse the illegal code hashes and set them to the core package. - core.IllegalCodeHashes = ParseIllegalCodeHashes(ctx) + // parse the blocked code hashes and set them to the core package. + core.BlockedCodeHashes = MakeBlockedCodeHashes(ctx) // initialise new random number generator rand := rand.New(rand.NewSource(time.Now().UnixNano())) -- cgit v1.2.3 From ba784bdf36f2daf7827ec1ec864f3393ba8d86a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Thu, 23 Jun 2016 12:47:15 +0300 Subject: core: update DAO soft-fork number, clean up the code --- cmd/geth/main.go | 1 + cmd/geth/usage.go | 1 + cmd/utils/flags.go | 23 +++++++---------------- 3 files changed, 9 insertions(+), 16 deletions(-) (limited to 'cmd') diff --git a/cmd/geth/main.go b/cmd/geth/main.go index c372430f1..95aad3bea 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -169,6 +169,7 @@ participating. utils.MiningGPUFlag, utils.AutoDAGFlag, utils.TargetGasLimitFlag, + utils.DAOSoftForkFlag, utils.NATFlag, utils.NatspecEnabledFlag, utils.NoDiscoverFlag, diff --git a/cmd/geth/usage.go b/cmd/geth/usage.go index e7ef9e2c7..10bc56b97 100644 --- a/cmd/geth/usage.go +++ b/cmd/geth/usage.go @@ -128,6 +128,7 @@ var AppHelpFlagGroups = []flagGroup{ utils.TargetGasLimitFlag, utils.GasPriceFlag, utils.ExtraDataFlag, + utils.DAOSoftForkFlag, }, }, { diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index c732a6635..d8001e348 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -163,10 +163,6 @@ var ( } // Miner settings // TODO: refactor CPU vs GPU mining flags - BlockedCodeHashesFlag = cli.StringFlag{ - Name: "blocked-code-hashes", - Usage: "Comma separated list of code-hashes to ignore any interaction from", - } MiningEnabledFlag = cli.BoolFlag{ Name: "mine", Usage: "Enable mining", @@ -185,6 +181,10 @@ var ( Usage: "Target gas limit sets the artificial target gas floor for the blocks to mine", Value: params.GenesisGasLimit.String(), } + DAOSoftForkFlag = cli.BoolFlag{ + Name: "dao-soft-fork", + Usage: "Vote for the DAO soft-fork, temporarilly decreasing the gas limits", + } AutoDAGFlag = cli.BoolFlag{ Name: "autodag", Usage: "Enable automatic DAG pregeneration", @@ -644,16 +644,6 @@ func MakePasswordList(ctx *cli.Context) []string { return lines } -// MakeBlockedCodeHashes parses a comma separated list of hashes. -func MakeBlockedCodeHashes(ctx *cli.Context) map[common.Hash]struct{} { - splittedHexHashes := strings.Split(ctx.GlobalString(BlockedCodeHashesFlag.Name), ",") - illegalCodeHashes := make(map[common.Hash]struct{}) - for _, hexHash := range splittedHexHashes { - illegalCodeHashes[common.HexToHash(strings.TrimSpace(hexHash))] = struct{}{} - } - return illegalCodeHashes -} - // MakeSystemNode sets up a local node, configures the services to launch and // assembles the P2P protocol stack. func MakeSystemNode(name, version string, relconf release.Config, extra []byte, ctx *cli.Context) *node.Node { @@ -690,8 +680,9 @@ func MakeSystemNode(name, version string, relconf release.Config, extra []byte, } // Configure the Ethereum service accman := MakeAccountManager(ctx) - // parse the blocked code hashes and set them to the core package. - core.BlockedCodeHashes = MakeBlockedCodeHashes(ctx) + + // Handle some miner strategies arrising from the DAO fiasco + core.DAOSoftFork = ctx.GlobalBool(DAOSoftForkFlag.Name) // initialise new random number generator rand := rand.New(rand.NewSource(time.Now().UnixNano())) -- cgit v1.2.3