Skip to content

Commit bbeaab7

Browse files
committed
cmd/utils, miner: A/B testing JIT VM. Disabled for miners
This PR introduces a 10% probability that you'll run the client with the JIT enabled testing the new client and helps us potentially catch errors when reported. This feature is **disabled** for miners (disabling the JIT completely). The JIT can however be force for miners if they enable both --jitvm and --forcejit.
1 parent c580794 commit bbeaab7

2 files changed

Lines changed: 22 additions & 2 deletions

File tree

‎cmd/utils/flags.go‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@ import (
2222
"io/ioutil"
2323
"math"
2424
"math/big"
25+
"math/rand"
2526
"os"
2627
"path/filepath"
2728
"runtime"
2829
"strconv"
2930
"strings"
31+
"time"
3032

3133
"github.com/codegangsta/cli"
3234
"github.com/ethereum/ethash"
@@ -659,6 +661,16 @@ func MakeSystemNode(name, version string, extra []byte, ctx *cli.Context) *node.
659661
// Configure the Ethereum service
660662
accman := MakeAccountManager(ctx)
661663

664+
// initialise new random number generator
665+
rand := rand.New(rand.NewSource(time.Now().UnixNano()))
666+
// get enabled jit flag
667+
jitEnabled := ctx.GlobalBool(VMEnableJitFlag.Name)
668+
// if the jit is not enabled enable it for 10 pct of the people
669+
if !jitEnabled && rand.Float64() < 0.1 {
670+
jitEnabled = true
671+
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")
672+
}
673+
662674
ethConf := &eth.Config{
663675
ChainConfig: MustMakeChainConfig(ctx),
664676
Genesis: MakeGenesisBlock(ctx),
@@ -673,7 +685,7 @@ func MakeSystemNode(name, version string, extra []byte, ctx *cli.Context) *node.
673685
ExtraData: MakeMinerExtra(extra, ctx),
674686
NatSpec: ctx.GlobalBool(NatspecEnabledFlag.Name),
675687
DocRoot: ctx.GlobalString(DocRootFlag.Name),
676-
EnableJit: ctx.GlobalBool(VMEnableJitFlag.Name),
688+
EnableJit: jitEnabled,
677689
ForceJit: ctx.GlobalBool(VMForceJitFlag.Name),
678690
GasPrice: common.String2Big(ctx.GlobalString(GasPriceFlag.Name)),
679691
GpoMinGasPrice: common.String2Big(ctx.GlobalString(GpoMinGasPriceFlag.Name)),

‎miner/worker.go‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,15 @@ func (env *Work) commitTransactions(mux *event.TypeMux, transactions types.Trans
662662

663663
func (env *Work) commitTransaction(tx *types.Transaction, bc *core.BlockChain, gp *core.GasPool) (error, vm.Logs) {
664664
snap := env.state.Copy()
665-
receipt, logs, _, err := core.ApplyTransaction(env.config, bc, gp, env.state, env.header, tx, env.header.GasUsed, env.config.VmConfig)
665+
666+
// this is a bit of a hack to force jit for the miners
667+
config := env.config.VmConfig
668+
if !(config.EnableJit && config.ForceJit) {
669+
config.EnableJit = false
670+
}
671+
config.ForceJit = false // disable forcing jit
672+
673+
receipt, logs, _, err := core.ApplyTransaction(env.config, bc, gp, env.state, env.header, tx, env.header.GasUsed, config)
666674
if err != nil {
667675
env.state.Set(snap)
668676
return err, nil

0 commit comments

Comments
 (0)