Skip to content

Commit

Permalink
add infer uri flag
Browse files Browse the repository at this point in the history
  • Loading branch information
SiNZeRo committed Jun 5, 2018
1 parent dc59560 commit 928e360
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 5 deletions.
1 change: 1 addition & 0 deletions cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ var (
utils.GpoPercentileFlag,
utils.ExtraDataFlag,
configFileFlag,
utils.ModelCallInterfaceFlag,
}

rpcFlags = []cli.Flag{
Expand Down
10 changes: 9 additions & 1 deletion cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,11 @@ var (
Usage: "Minimum POW accepted",
Value: whisper.DefaultMinimumPoW,
}
ModelCallInterfaceFlag = cli.StringFlag{
Name: "cvm.inferuri",
Usage: "infer uri",
Value: "http://127.0.0.1:5000/infer",
}
)

// MakeDataDir retrieves the currently requested data directory, terminating
Expand Down Expand Up @@ -1247,7 +1252,10 @@ func MakeChain(ctx *cli.Context, stack *node.Node) (chain *core.BlockChain, chai
if ctx.GlobalIsSet(CacheFlag.Name) || ctx.GlobalIsSet(CacheGCFlag.Name) {
cache.TrieNodeLimit = ctx.GlobalInt(CacheFlag.Name) * ctx.GlobalInt(CacheGCFlag.Name) / 100
}
vmcfg := vm.Config{EnablePreimageRecording: ctx.GlobalBool(VMEnableDebugFlag.Name)}
vmcfg := vm.Config{
EnablePreimageRecording: ctx.GlobalBool(VMEnableDebugFlag.Name),
InferURI: ctx.GlobalString(ModelCallInterfaceFlag.Name),
}
chain, err = core.NewBlockChain(chainDb, cache, config, engine, vmcfg)
if err != nil {
Fatalf("Can't create BlockChain: %v", err)
Expand Down
2 changes: 1 addition & 1 deletion core/vm/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ func (evm *EVM) Infer(model_meta_hash []byte, input_meta_hash []byte) ([]byte, e
resp, err := resty.R().
SetHeader("Content-Type", "application/json").
SetBody(requestBody).
Post("http://127.0.0.1:5000/infer")
Post(evm.interpreter.cfg.InferURI)
if err != nil {
return []byte{}, errors.New("evm.Infer: External Call Error")
}
Expand Down
3 changes: 2 additions & 1 deletion core/vm/interpreter.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ type Config struct {
// may be left uninitialised and will be set to the default
// table.
JumpTable [256]operation
// uri for remote infer service
InferURI string
}

// Interpreter is used to run Ethereum based contracts and will utilise the
Expand Down Expand Up @@ -73,7 +75,6 @@ func NewInterpreter(evm *EVM, cfg Config) *Interpreter {
cfg.JumpTable = frontierInstructionSet
}
}

return &Interpreter{
evm: evm,
cfg: cfg,
Expand Down
5 changes: 3 additions & 2 deletions core/vm/runtime/runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ func TestRunCmd(t *testing.T) {
Value: new(big.Int),
BlockNumber: new(big.Int).SetUint64(blockNumber),
EVMConfig: vm.Config{
Tracer: tracer,
Debug: true,
Tracer: tracer,
Debug: true,
InferURI: "http://127.0.0.1:5000/infer",
},
}

Expand Down

0 comments on commit 928e360

Please sign in to comment.