Skip to content

Commit

Permalink
Add an example config files, add volumes for pre/post, small improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
zale144 committed Jul 7, 2022
1 parent b1440fb commit 5e2a8e2
Show file tree
Hide file tree
Showing 5 changed files with 253 additions and 37 deletions.
56 changes: 48 additions & 8 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@ type PStartConfig struct {
Docker []DockerConfig `hcl:"docker_service,block"`
}

func (p *PStartConfig) absPaths(configDir string) error {
for i := range p.Docker {
if err := p.Docker[i].absPaths(configDir); err != nil {
return fmt.Errorf("failed to set pstart abs paths: %w", err)
}
}

return nil
}

type StaticPort struct {
To int `hcl:"to,optional"`
Value int `hcl:"value"`
Expand All @@ -78,6 +88,22 @@ type DockerConfig struct {
Env map[string]string `hcl:"env,optional"`
StaticPort *StaticPort `hcl:"static_port,block"`
AuthSoftFail bool `hcl:"auth_soft_fail,optional"`
Volumes []string `hcl:"volumes,optional"`
}

func (d *DockerConfig) absPaths(configDir string) error {
for i := range d.Volumes {
if !filepath.IsAbs(d.Volumes[i]) {
configFile, err := utils.AbsPathWithPrefix(configDir, d.Volumes[i])
if err != nil {
return fmt.Errorf("failed to get absolute file path: %w", err)
}

d.Volumes[i] = configFile
}
}

return nil
}

type WalletConfig struct {
Expand Down Expand Up @@ -189,6 +215,20 @@ func (c *Config) setAbsolutePaths() error {
c.Network.Nodes[idx].DataNodeBinary = dataNodeBinPath
}

// Pre start
if c.Network.PreStart != nil {
if err := c.Network.PreStart.absPaths(c.configDir); err != nil {
return fmt.Errorf("failed to set pre start abs paths: %w", err)
}
}

// Post start
if c.Network.PostStart != nil {
if err := c.Network.PostStart.absPaths(c.configDir); err != nil {
return fmt.Errorf("failed to set post start abs paths: %w", err)
}
}

return nil
}

Expand Down Expand Up @@ -440,14 +480,14 @@ func DefaultConfig() (*Config, error) {

return &Config{
OutputDir: &outputDir,
Prefix: utils.StrPoint("st-local"),
NodeDirPrefix: utils.StrPoint("node"),
TendermintNodePrefix: utils.StrPoint("tendermint"),
VegaNodePrefix: utils.StrPoint("vega"),
DataNodePrefix: utils.StrPoint("data"),
WalletPrefix: utils.StrPoint("wallet"),
FaucetPrefix: utils.StrPoint("faucet"),
VegaBinary: utils.StrPoint("vega"),
Prefix: utils.ToPointer("st-local"),
NodeDirPrefix: utils.ToPointer("node"),
TendermintNodePrefix: utils.ToPointer("tendermint"),
VegaNodePrefix: utils.ToPointer("vega"),
DataNodePrefix: utils.ToPointer("data"),
WalletPrefix: utils.ToPointer("wallet"),
FaucetPrefix: utils.ToPointer("faucet"),
VegaBinary: utils.ToPointer("vega"),
}, nil
}

Expand Down
102 changes: 102 additions & 0 deletions net_confs/config_bot.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
vega_binary_path = "vega"

network "testnet" {
ethereum {
chain_id = "1440"
network_id = "1441"
endpoint = "http://127.0.0.1:8545/"
}

faucet "faucet-1" {
wallet_pass = "f4uc3tw4ll3t-v3g4-p4ssphr4e3"

template = <<-EOT
[Node]
Port = 3002
IP = "127.0.0.1"
EOT
}

wallet "wallet-1" {
binary = "vegawallet"

template = <<-EOT
Name = "DV"
Level = "debug"
TokenExpiry = "168h0m0s"
Port = 1789
Host = "0.0.0.0"
[API]
[API.GRPC]
Hosts = [{{range $i, $v := .Validators}}{{if ne $i 0}},{{end}}"127.0.0.1:30{{$i}}2"{{end}}]
Retries = 5
EOT
}

pre_start {
docker_service "ganache-1" {
image = "vegaprotocol/ganache:latest"
cmd = "ganache-cli"
args = [
"--blockTime", "1",
"--chainId", "1440",
"--networkId", "1441",
"-h", "0.0.0.0",
"-p", "8545",
"-m", "ozone access unlock valid olympic save include omit supply green clown session",
"--db", "/app/ganache-db",
]
static_port {
value = 8545
to = 8545
}
auth_soft_fail = true
volumes = [
"./net_confs/docker:/config"
]
}
}

post_start {
docker_service "liqbot" {
image = "vegaprotocol/liqbot:local"
cmd = "./liqbot"
args = [
"--config=/config/liqbot_config.yaml"
]
auth_soft_fail = true
volumes = [
"./net_confs/docker:/config"
]
}
}

genesis_template_file = "./genesis.tmpl"
smart_contracts_addresses_file = "./public_smart_contracts_addresses.json"

node_set "validators" {
count = 2
mode = "validator"
node_wallet_pass = "n0d3w4ll3t-p4ssphr4e3"
vega_wallet_pass = "w4ll3t-p4ssphr4e3"
ethereum_wallet_pass = "ch41nw4ll3t-3th3r3um-p4ssphr4e3"

config_templates {
vega_file = "./node_set_templates/default/vega_validators.tmpl"
tendermint_file = "./node_set_templates/default/tendermint_validators.tmpl"
}
}

node_set "full" {
count = 1
mode = "full"
data_node_binary = "data-node"

config_templates {
vega_file = "./node_set_templates/default/vega_full.tmpl"
tendermint_file = "./node_set_templates/default/tendermint_full.tmpl"
data_node_file = "./node_set_templates/default/data_node_full.tmpl"
}
}
}
77 changes: 77 additions & 0 deletions net_confs/docker/liqbot_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
---

server:
env: prod # dev, prod
listen: ":7800"
logformat: text # json, text
loglevel: debug # debug, info, warning, error
pricing:
address:
scheme: https
host: prices.ops.vega.xyz
path: /prices
wallet:
url: http://host.docker.internal:1789
tokenExpiry: 31536000 # seconds
seed:
ethereumAddress: https://host.docker.internal:8545
erc20BridgeAddress: 0x9708FF7510D4A7B9541e1699d15b53Ecb1AFDc54
stakingBridgeAddress: 0x9135f5afd6F055e731bca2348429482eE614CFfA
tUSDCTokenAddress: 0x1b8a1B6CBE5c93609b46D1829Cc7f3Cb8eeE23a0
vegaTokenAddress: 0x67175Da1D5e966e40D11c4B2519392B2058373de
contractOwnerAddress: 0xEe7D375bcB50C26d52E1A4a472D8822A2A22d94F
contractOwnerPrivateKey: a37f4c2a678aefb5037bf415a826df1540b330b7e471aa54184877ba901b9ef0
amount: 1000000000000000000
bots:
- name: w00
location: host.docker.internal:3027
connectTimeout: 30000 # milliseconds
callTimeout: 10000 # milliseconds
marketID: b07e975907e117d7b82f767771f1983ba2023f7d2a61a88f3206d8a7c43b69d5 # BTC/USD
instrumentBase: BTC
instrumentQuote: USD
strategy: normal
strategyDetails:
expectedMarkPrice: 0
auctionVolume: 100
maxLong: 100
maxShort: 100
posManagementFraction: 0.25
stakeFraction: 0.1
ordersFraction: 0.25
commitmentFraction: 0.10
fee: 0.01

shorteningShape:
sells:
- {reference: Ask, proportion: 10, offset: 8}
- {reference: Ask, proportion: 20, offset: 4}
- {reference: Ask, proportion: 30, offset: 2}
- {reference: Ask, proportion: 40, offset: 1}
buys:
- {reference: Bid, proportion: 40, offset: 2}
- {reference: Bid, proportion: 30, offset: 4}
- {reference: Bid, proportion: 20, offset: 8}
- {reference: Bid, proportion: 10, offset: 16}
longeningShape:
sells:
- {reference: Ask, proportion: 10, offset: 16}
- {reference: Ask, proportion: 20, offset: 8}
- {reference: Ask, proportion: 30, offset: 4}
- {reference: Ask, proportion: 40, offset: 2}
buys:
- {reference: Bid, proportion: 40, offset: 1}
- {reference: Bid, proportion: 30, offset: 2}
- {reference: Bid, proportion: 20, offset: 4}
- {reference: Bid, proportion: 10, offset: 8}
posManagementSleepMilliseconds: 5050
marketPriceSteeringRatePerSecond: 0.25
minPriceSteerFraction: 0.00001
priceSteerOrderScale: 20.5
limitOrderDistributionParams:
method: "discreteThreeLevel"
gttLengthSeconds: 60
tgtTimeHorizonHours: 1.0
numTicksFromMid: 5
numIdenticalBots: 1
targetLNVol: 0.25
47 changes: 24 additions & 23 deletions nomad/job_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ func (r *JobRunner) runDockerJob(ctx context.Context, conf config.DockerConfig)
},
},
RestartPolicy: &api.RestartPolicy{
Attempts: utils.IntPoint(0),
Mode: utils.StrPoint("fail"),
Attempts: utils.ToPointer(0),
Mode: utils.ToPointer("fail"),
},
Name: &conf.Name,
Tasks: []*api.Task{
Expand All @@ -62,11 +62,12 @@ func (r *JobRunner) runDockerJob(ctx context.Context, conf config.DockerConfig)
"args": conf.Args,
"ports": portLabels,
"auth_soft_fail": conf.AuthSoftFail,
"volumes": conf.Volumes,
},
Env: conf.Env,
Resources: &api.Resources{
CPU: utils.IntPoint(500),
MemoryMB: utils.IntPoint(768),
CPU: utils.ToPointer(500),
MemoryMB: utils.ToPointer(768),
},
},
},
Expand Down Expand Up @@ -96,8 +97,8 @@ func (r *JobRunner) defaultNodeSetJob(ns types.NodeSet) *api.Job {
},
},
Resources: &api.Resources{
CPU: utils.IntPoint(500),
MemoryMB: utils.IntPoint(512),
CPU: utils.ToPointer(500),
MemoryMB: utils.ToPointer(512),
},
},
&api.Task{
Expand All @@ -112,8 +113,8 @@ func (r *JobRunner) defaultNodeSetJob(ns types.NodeSet) *api.Job {
},
},
Resources: &api.Resources{
CPU: utils.IntPoint(500),
MemoryMB: utils.IntPoint(512),
CPU: utils.ToPointer(500),
MemoryMB: utils.ToPointer(512),
},
})

Expand All @@ -129,22 +130,22 @@ func (r *JobRunner) defaultNodeSetJob(ns types.NodeSet) *api.Job {
},
},
Resources: &api.Resources{
CPU: utils.IntPoint(500),
MemoryMB: utils.IntPoint(512),
CPU: utils.ToPointer(500),
MemoryMB: utils.ToPointer(512),
},
})
}

return &api.Job{
ID: utils.StrPoint(ns.Name),
ID: utils.ToPointer(ns.Name),
Datacenters: []string{"dc1"},
TaskGroups: []*api.TaskGroup{
{
RestartPolicy: &api.RestartPolicy{
Attempts: utils.IntPoint(0),
Mode: utils.StrPoint("fail"),
Attempts: utils.ToPointer(0),
Mode: utils.ToPointer("fail"),
},
Name: utils.StrPoint("vega"),
Name: utils.ToPointer("vega"),
Tasks: tasks,
},
},
Expand Down Expand Up @@ -243,10 +244,10 @@ func (r *JobRunner) runWallet(ctx context.Context, conf *config.WalletConfig, wa
TaskGroups: []*api.TaskGroup{
{
RestartPolicy: &api.RestartPolicy{
Attempts: utils.IntPoint(0),
Mode: utils.StrPoint("fail"),
Attempts: utils.ToPointer(0),
Mode: utils.ToPointer("fail"),
},
Name: utils.StrPoint("vega"),
Name: utils.ToPointer("vega"),
Tasks: []*api.Task{
{
Name: "wallet-1",
Expand All @@ -264,8 +265,8 @@ func (r *JobRunner) runWallet(ctx context.Context, conf *config.WalletConfig, wa
},
},
Resources: &api.Resources{
CPU: utils.IntPoint(500),
MemoryMB: utils.IntPoint(512),
CPU: utils.ToPointer(500),
MemoryMB: utils.ToPointer(512),
},
},
},
Expand All @@ -287,8 +288,8 @@ func (r *JobRunner) runFaucet(ctx context.Context, binary string, conf *config.F
TaskGroups: []*api.TaskGroup{
{
RestartPolicy: &api.RestartPolicy{
Attempts: utils.IntPoint(0),
Mode: utils.StrPoint("fail"),
Attempts: utils.ToPointer(0),
Mode: utils.ToPointer("fail"),
},
Name: &conf.Name,
Tasks: []*api.Task{
Expand All @@ -305,8 +306,8 @@ func (r *JobRunner) runFaucet(ctx context.Context, binary string, conf *config.F
},
},
Resources: &api.Resources{
CPU: utils.IntPoint(500),
MemoryMB: utils.IntPoint(512),
CPU: utils.ToPointer(500),
MemoryMB: utils.ToPointer(512),
},
},
},
Expand Down
Loading

0 comments on commit 5e2a8e2

Please sign in to comment.