Merge pull request #2378 from obscuren/enable-jit-a-b
cmd/utils, miner: A/B testing JIT VM. Disabled for miners
This commit is contained in:
		@@ -22,11 +22,13 @@ import (
 | 
				
			|||||||
	"io/ioutil"
 | 
						"io/ioutil"
 | 
				
			||||||
	"math"
 | 
						"math"
 | 
				
			||||||
	"math/big"
 | 
						"math/big"
 | 
				
			||||||
 | 
						"math/rand"
 | 
				
			||||||
	"os"
 | 
						"os"
 | 
				
			||||||
	"path/filepath"
 | 
						"path/filepath"
 | 
				
			||||||
	"runtime"
 | 
						"runtime"
 | 
				
			||||||
	"strconv"
 | 
						"strconv"
 | 
				
			||||||
	"strings"
 | 
						"strings"
 | 
				
			||||||
 | 
						"time"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/codegangsta/cli"
 | 
						"github.com/codegangsta/cli"
 | 
				
			||||||
	"github.com/ethereum/ethash"
 | 
						"github.com/ethereum/ethash"
 | 
				
			||||||
@@ -659,6 +661,16 @@ func MakeSystemNode(name, version string, extra []byte, ctx *cli.Context) *node.
 | 
				
			|||||||
	// Configure the Ethereum service
 | 
						// Configure the Ethereum service
 | 
				
			||||||
	accman := MakeAccountManager(ctx)
 | 
						accman := MakeAccountManager(ctx)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// initialise new random number generator
 | 
				
			||||||
 | 
						rand := rand.New(rand.NewSource(time.Now().UnixNano()))
 | 
				
			||||||
 | 
						// get enabled jit flag
 | 
				
			||||||
 | 
						jitEnabled := ctx.GlobalBool(VMEnableJitFlag.Name)
 | 
				
			||||||
 | 
						// if the jit is not enabled enable it for 10 pct of the people
 | 
				
			||||||
 | 
						if !jitEnabled && rand.Float64() < 0.1 {
 | 
				
			||||||
 | 
							jitEnabled = true
 | 
				
			||||||
 | 
							glog.V(logger.Info).Infoln("You're one of the lucky few that will try out the JIT VM (random). If you get a consensus failure please be so kind to report this incident with the block hash that failed. You can switch to the regular VM by setting --jitvm=false")
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ethConf := ð.Config{
 | 
						ethConf := ð.Config{
 | 
				
			||||||
		ChainConfig:             MustMakeChainConfig(ctx),
 | 
							ChainConfig:             MustMakeChainConfig(ctx),
 | 
				
			||||||
		Genesis:                 MakeGenesisBlock(ctx),
 | 
							Genesis:                 MakeGenesisBlock(ctx),
 | 
				
			||||||
@@ -673,7 +685,7 @@ func MakeSystemNode(name, version string, extra []byte, ctx *cli.Context) *node.
 | 
				
			|||||||
		ExtraData:               MakeMinerExtra(extra, ctx),
 | 
							ExtraData:               MakeMinerExtra(extra, ctx),
 | 
				
			||||||
		NatSpec:                 ctx.GlobalBool(NatspecEnabledFlag.Name),
 | 
							NatSpec:                 ctx.GlobalBool(NatspecEnabledFlag.Name),
 | 
				
			||||||
		DocRoot:                 ctx.GlobalString(DocRootFlag.Name),
 | 
							DocRoot:                 ctx.GlobalString(DocRootFlag.Name),
 | 
				
			||||||
		EnableJit:               ctx.GlobalBool(VMEnableJitFlag.Name),
 | 
							EnableJit:               jitEnabled,
 | 
				
			||||||
		ForceJit:                ctx.GlobalBool(VMForceJitFlag.Name),
 | 
							ForceJit:                ctx.GlobalBool(VMForceJitFlag.Name),
 | 
				
			||||||
		GasPrice:                common.String2Big(ctx.GlobalString(GasPriceFlag.Name)),
 | 
							GasPrice:                common.String2Big(ctx.GlobalString(GasPriceFlag.Name)),
 | 
				
			||||||
		GpoMinGasPrice:          common.String2Big(ctx.GlobalString(GpoMinGasPriceFlag.Name)),
 | 
							GpoMinGasPrice:          common.String2Big(ctx.GlobalString(GpoMinGasPriceFlag.Name)),
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -662,7 +662,15 @@ func (env *Work) commitTransactions(mux *event.TypeMux, transactions types.Trans
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
func (env *Work) commitTransaction(tx *types.Transaction, bc *core.BlockChain, gp *core.GasPool) (error, vm.Logs) {
 | 
					func (env *Work) commitTransaction(tx *types.Transaction, bc *core.BlockChain, gp *core.GasPool) (error, vm.Logs) {
 | 
				
			||||||
	snap := env.state.Copy()
 | 
						snap := env.state.Copy()
 | 
				
			||||||
	receipt, logs, _, err := core.ApplyTransaction(env.config, bc, gp, env.state, env.header, tx, env.header.GasUsed, env.config.VmConfig)
 | 
					
 | 
				
			||||||
 | 
						// this is a bit of a hack to force jit for the miners
 | 
				
			||||||
 | 
						config := env.config.VmConfig
 | 
				
			||||||
 | 
						if !(config.EnableJit && config.ForceJit) {
 | 
				
			||||||
 | 
							config.EnableJit = false
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						config.ForceJit = false // disable forcing jit
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						receipt, logs, _, err := core.ApplyTransaction(env.config, bc, gp, env.state, env.header, tx, env.header.GasUsed, config)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		env.state.Set(snap)
 | 
							env.state.Set(snap)
 | 
				
			||||||
		return err, nil
 | 
							return err, nil
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user