{{ range (until (.Values.chain.numberOfNodes | int)) }}
{{- $nodeNumber := printf "%03d" . }}
---
kind: ConfigMap
apiVersion: v1
metadata:
  labels:
    app: {{ template "burrow.name" $ }}
    chart: "{{ $.Chart.Name }}-{{ $.Chart.Version }}"
    heritage: {{ $.Release.Service }}
    release: {{ $.Release.Name }}
  name: {{ template "burrow.fullname" $ }}-config-{{ $nodeNumber }}
data:
  config.toml: |-
    [chain]
    assert_chain_id = {{ $.Values.chain.id | quote }}
    major_version = 0
    minor_version = 17
    genesis_file = "genesis.json"
      [chain.consensus]
      name = "tendermint"
      major_version = 0
      minor_version = 8
      relative_root = "tendermint"
      [chain.manager]
      name = "burrowmint"
      major_version = 0
      minor_version = 17
      relative_root = "burrowmint"
    [servers]
      [servers.bind]
      address = ""
      port = {{ $.Values.service.api.port }}
      [servers.tls]
      tls = false
      cert_path = ""
      key_path = ""
      [servers.cors]
      enable = false
      allow_origins = []
      allow_credentials = false
      allow_methods = []
      allow_headers = []
      expose_headers = []
      max_age = 0
      [servers.http]
      json_rpc_endpoint = "/rpc"
      [servers.websocket]
      endpoint = "/socketrpc"
      max_sessions = 50
      read_buffer_size = 4096
      write_buffer_size = 4096
      [servers.tendermint]
      rpc_local_address = "0.0.0.0:{{ $.Values.service.rpc.port }}"
      endpoint = "/websocket"
      [servers.logging]
      console_log_level = {{ $.Values.chain.logLevel | quote }}
      file_log_level = "warn"
      log_file = "burrow-logs.log"
    [tendermint]
    private_validator_file = "priv_validator.json"
      [tendermint.configuration]
      moniker = {{ printf "%s-%s-validator-%s" $.Values.organization $.Values.chain.id $nodeNumber | quote }}
      seeds = "{{ range (until (sub $.Values.chain.numberOfNodes 1 | int)) }}{{ template "burrow.fullname" $ }}-peer-{{ printf "%03d" . }}:{{ $.Values.service.peer.port }},{{ end }}{{ template "burrow.fullname" $ }}-peer-{{ sub $.Values.chain.numberOfNodes 1 | printf "%03d" }}:{{ $.Values.service.peer.port }}{{ if not (eq (len $.Values.chain.extraSeeds) 0) }}{{ range $.Values.chain.extraSeeds }},{{ . }}{{ end }}{{ end }}"
      fast_sync = true
      db_backend = "leveldb"
      log_level = {{ $.Values.chain.logLevel | quote }}
      node_laddr = "tcp://0.0.0.0:{{ $.Values.service.peer.port }}"
      rpc_laddr = "tcp://0.0.0.0:{{ $.Values.service.rpc.port }}"
      proxy_app = "tcp://127.0.0.1:46658"
        [tendermint.configuration.p2p]
        dial_timeout_seconds = 1
        handshake_timeout_seconds = 5
        max_num_peers = 20
        authenticated_encryption = true
        send_rate = 512000
        recv_rate = 512000
        fuzz_enable = false # use the fuzz wrapped conn
        fuzz_active = false # toggle fuzzing
        fuzz_mode = "drop"  # eg. drop, delay
        fuzz_max_delay_milliseconds = 3000
        fuzz_prob_drop_rw = 0.2
        fuzz_prob_drop_conn = 0.00
        fuzz_prob_sleep = 0.00
    [burrowmint]
    db_backend = "leveldb"
    tendermint_host = "0.0.0.0:{{ $.Values.service.rpc.port }}"
    [logging]
      [logging.root_sink]
        [logging.root_sink.transform]
          transform_type = "filter"
          filter_mode = "exclude_when_all_match"
          [[logging.root_sink.transform.predicates]]
            key_regex = "log_channel"
            value_regex = "Trace"
        [[logging.root_sink.sinks]]
          [logging.root_sink.sinks.output]
            output_type = "stderr"
            format = "json"
{{- end }}