mirror of
https://github.com/sonr-io/sonr.git
synced 2026-08-04 02:11:40 +00:00
(no commit message provided)
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
import "./toml.pkl"
|
||||
|
||||
`minimum-gas-prices` = "0stake"
|
||||
`query-gas-limit` = "0"
|
||||
pruning = "default"
|
||||
`pruning-keep-recent` = "0"
|
||||
`pruning-interval` = "0"
|
||||
`halt-height` = 0
|
||||
`halt-time` = 0
|
||||
`min-retain-blocks` = 0
|
||||
`inter-block-cache` = true
|
||||
`index-events` = new Listing {}
|
||||
`iavl-cache-size` = 781250
|
||||
`iavl-disable-fastnode` = false
|
||||
`app-db-backend` = ""
|
||||
|
||||
telemetry = new {
|
||||
`service-name` = ""
|
||||
enabled = true
|
||||
`enable-hostname` = false
|
||||
`enable-hostname-label` = false
|
||||
`enable-service-label` = false
|
||||
`prometheus-retention-time` = 60
|
||||
`global-labels` = new Listing {
|
||||
new Listing {
|
||||
"chain_id"
|
||||
"chain-NKlMbx"
|
||||
}
|
||||
}
|
||||
`metrics-sink` = ""
|
||||
`statsd-addr` = ""
|
||||
`datadog-hostname` = ""
|
||||
}
|
||||
|
||||
api = new {
|
||||
enable = true
|
||||
swagger = false
|
||||
address = "tcp://0.0.0.0:1317"
|
||||
`max-open-connections` = 1000
|
||||
`rpc-read-timeout` = 10
|
||||
`rpc-write-timeout` = 0
|
||||
`rpc-max-body-bytes` = 1000000
|
||||
`enabled-unsafe-cors` = false
|
||||
}
|
||||
|
||||
grpc = new {
|
||||
enable = true
|
||||
address = "0.0.0.0:9090"
|
||||
`max-recv-msg-size` = "10485760"
|
||||
`max-send-msg-size` = "2147483647"
|
||||
}
|
||||
|
||||
`grpc-web` = new {
|
||||
enable = true
|
||||
}
|
||||
|
||||
`state-sync` = new {
|
||||
`snapshot-interval` = 0
|
||||
`snapshot-keep-recent` = 2
|
||||
}
|
||||
|
||||
streaming = new {
|
||||
abci = new {
|
||||
keys = new Listing {}
|
||||
plugin = ""
|
||||
`stop-node-on-err` = true
|
||||
}
|
||||
}
|
||||
|
||||
mempool = new {
|
||||
`max-txs` = 5000
|
||||
}
|
||||
|
||||
output {
|
||||
renderer = new toml.Renderer {}
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
import "./toml.pkl"
|
||||
|
||||
version = "0.38.5"
|
||||
|
||||
proxy_app = "tcp://127.0.0.1:26658"
|
||||
moniker = "node0"
|
||||
db_backend = "goleveldb"
|
||||
db_dir = "data"
|
||||
log_level = "info"
|
||||
log_format = "plain"
|
||||
|
||||
genesis_file = "config/genesis.json"
|
||||
priv_validator_key_file = "config/priv_validator_key.json"
|
||||
priv_validator_state_file = "data/priv_validator_state.json"
|
||||
priv_validator_laddr = ""
|
||||
node_key_file = "config/node_key.json"
|
||||
abci = "socket"
|
||||
filter_peers = false
|
||||
|
||||
rpc = new {
|
||||
laddr = "tcp://0.0.0.0:26657"
|
||||
cors_allowed_origins = new Listing {}
|
||||
cors_allowed_methods = new Listing {
|
||||
"HEAD"
|
||||
"GET"
|
||||
"POST"
|
||||
}
|
||||
cors_allowed_headers = new Listing {
|
||||
"Origin"
|
||||
"Accept"
|
||||
"Content-Type"
|
||||
"X-Requested-With"
|
||||
"X-Server-Time"
|
||||
}
|
||||
grpc_laddr = ""
|
||||
grpc_max_open_connections = 900
|
||||
unsafe = false
|
||||
max_open_connections = 900
|
||||
max_subscription_clients = 100
|
||||
max_subscriptions_per_client = 5
|
||||
experimental_subscription_buffer_size = 200
|
||||
experimental_websocket_write_buffer_size = 200
|
||||
experimental_close_on_slow_client = false
|
||||
timeout_broadcast_tx_commit = "10s"
|
||||
max_body_bytes = 1000000
|
||||
max_header_bytes = 1048576
|
||||
tls_cert_file = ""
|
||||
tls_key_file = ""
|
||||
pprof_laddr = "localhost:6060"
|
||||
}
|
||||
|
||||
p2p = new {
|
||||
laddr = "tcp://0.0.0.0:26656"
|
||||
external_address = ""
|
||||
seeds = ""
|
||||
persistent_peers = "7698b304905ac4459e8bf5fe8f8373aa46a528a5@192.168.0.2:26656,b1aee1db2ac83c57ffe561624ba169bdcd80dc1a@192.168.0.4:26656,cda55214016021246cd26f8991bd842a0c1dc3fb@192.168.0.3:26656"
|
||||
addr_book_file = "config/addrbook.json"
|
||||
addr_book_strict = true
|
||||
max_num_inbound_peers = 40
|
||||
max_num_outbound_peers = 10
|
||||
unconditional_peer_ids = ""
|
||||
persistent_peers_max_dial_period = "0s"
|
||||
flush_throttle_timeout = "100ms"
|
||||
max_packet_msg_payload_size = 1024
|
||||
send_rate = 5120000
|
||||
recv_rate = 5120000
|
||||
pex = true
|
||||
seed_mode = false
|
||||
private_peer_ids = ""
|
||||
allow_duplicate_ip = false
|
||||
handshake_timeout = "20s"
|
||||
dial_timeout = "3s"
|
||||
}
|
||||
|
||||
mempool = new {
|
||||
type = "flood"
|
||||
recheck = true
|
||||
broadcast = true
|
||||
wal_dir = ""
|
||||
size = 5000
|
||||
max_txs_bytes = 1073741824
|
||||
cache_size = 10000
|
||||
`keep-invalid-txs-in-cache` = false
|
||||
max_tx_bytes = 1048576
|
||||
max_batch_bytes = 0
|
||||
experimental_max_gossip_connections_to_persistent_peers = 0
|
||||
experimental_max_gossip_connections_to_non_persistent_peers = 0
|
||||
}
|
||||
|
||||
statesync = new {
|
||||
enable = false
|
||||
rpc_servers = ""
|
||||
trust_height = 0
|
||||
trust_hash = ""
|
||||
trust_period = "168h0m0s"
|
||||
discovery_time = "15s"
|
||||
temp_dir = ""
|
||||
chunk_request_timeout = "10s"
|
||||
chunk_fetchers = "4"
|
||||
}
|
||||
|
||||
blocksync = new {
|
||||
version = "v0"
|
||||
}
|
||||
|
||||
consensus = new {
|
||||
wal_file = "data/cs.wal/wal"
|
||||
timeout_propose = "3s"
|
||||
timeout_propose_delta = "500ms"
|
||||
timeout_prevote = "1s"
|
||||
timeout_prevote_delta = "500ms"
|
||||
timeout_precommit = "1s"
|
||||
timeout_precommit_delta = "500ms"
|
||||
timeout_commit = "5s"
|
||||
double_sign_check_height = 0
|
||||
skip_timeout_commit = false
|
||||
create_empty_blocks = true
|
||||
create_empty_blocks_interval = "0s"
|
||||
peer_gossip_sleep_duration = "100ms"
|
||||
peer_query_maj23_sleep_duration = "2s"
|
||||
}
|
||||
|
||||
storage = new {
|
||||
discard_abci_responses = false
|
||||
}
|
||||
|
||||
tx_index = new {
|
||||
indexer = "kv"
|
||||
`psql-conn` = ""
|
||||
}
|
||||
|
||||
instrumentation = new {
|
||||
prometheus = false
|
||||
prometheus_listen_addr = ":26660"
|
||||
max_open_connections = 3
|
||||
namespace = "cometbft"
|
||||
}
|
||||
|
||||
|
||||
output {
|
||||
renderer = new toml.Renderer {}
|
||||
}
|
||||
@@ -0,0 +1,217 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//===----------------------------------------------------------------------===//
|
||||
/// A renderer for [TOML](https://toml.io) configuration files.
|
||||
///
|
||||
/// Basic usage:
|
||||
/// ```
|
||||
/// import "package://pkg.pkl-lang.org/pantry/pkl.toml@1.0.0"
|
||||
///
|
||||
/// output {
|
||||
/// renderer = new toml.Renderer {}
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// To render TOML dates and times, use [Date], [Time], and [DateTime].
|
||||
@ModuleInfo { minPklVersion = "0.25.0" }
|
||||
module pkl.toml.toml
|
||||
|
||||
abstract class AbstractDateTime {
|
||||
value: String
|
||||
}
|
||||
|
||||
/// A TOML [Local Date](https://toml.io/en/v1.0.0#local-date) value.
|
||||
class Date extends AbstractDateTime {
|
||||
value: String(matches(Regex(#"(\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])"#)))
|
||||
}
|
||||
|
||||
/// A TOML [Local Time](https://toml.io/en/v1.0.0#local-time) value.
|
||||
class Time extends AbstractDateTime {
|
||||
value: String(matches(Regex(#"([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9]|60)(\.[0-9]+)?"#)))
|
||||
}
|
||||
|
||||
/// A TOML [Offset Date-Time](https://toml.io/en/v1.0.0#offset-date-time)
|
||||
/// or [Local Date-Time](https://toml.io/en/v1.0.0#local-date-time) value.
|
||||
class DateTime extends AbstractDateTime {
|
||||
value: String(matches(Regex(#"(\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])[T ]([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9]|60)(\.[0-9]+)?(Z|[+-]([01][0-9]|2[0-3]):([0-5][0-9]))?"#)))
|
||||
}
|
||||
|
||||
/// Renders values as TOML.
|
||||
class Renderer extends ValueRenderer {
|
||||
/// Value converters to apply before values are rendered.
|
||||
///
|
||||
/// For further information see [PcfRenderer.converters].
|
||||
/// For path converters, only "*" is supported.
|
||||
converters: Mapping<Class|String, (unknown) -> Any>
|
||||
|
||||
function renderValue(value: Any) =
|
||||
let (_value = getBasicValue(value, false))
|
||||
doRenderValue(_value, List()).trim()
|
||||
|
||||
function renderDocument(value: Any) =
|
||||
if (!isTableLike(value))
|
||||
throw("""
|
||||
Invalid input: TOML can only render object-types at the root level. Received: \(value)
|
||||
""")
|
||||
else
|
||||
renderValue(value)
|
||||
|
||||
local jsonRenderer = new JsonRenderer {}
|
||||
|
||||
local function getConvertersForValue(value: Any): List<(Any) -> unknown> = new Listing {
|
||||
when (convertersMap.containsKey(value.getClass())) {
|
||||
convertersMap[value.getClass()]
|
||||
}
|
||||
when (convertersMap.containsKey("*")) {
|
||||
convertersMap["*"]
|
||||
}
|
||||
}.toList()
|
||||
|
||||
local function applyConverters(value: Any) =
|
||||
let (converters = getConvertersForValue(value))
|
||||
converters.fold(value, (acc, converter) -> converter.apply(acc))
|
||||
|
||||
/// Traverses the object and casts it down to its basic type: Map, List, or the primitive value. Runs each
|
||||
/// value through the converter if there is a match.
|
||||
/// `skipConversion` is a helper flag to avoid infinite recursion in case the converter returns the same type.
|
||||
local function getBasicValue(value: Any, skipConversion: Boolean) =
|
||||
if (!skipConversion && !getConvertersForValue(value).isEmpty)
|
||||
getBasicValue(applyConverters(value), true)
|
||||
// If the value is Dynamic, and we have both elements and properties, it's ambiguous whether we should
|
||||
// render as a table or an array.
|
||||
else if (value is Dynamic && isTableLike(value) && isArrayLike(value))
|
||||
throw("""
|
||||
Cannot render object with both properties/entries and elements as TOML. Received: \(value)
|
||||
""")
|
||||
else if (isTableLike(value))
|
||||
getMap(value)
|
||||
.mapValues((_, elem) -> getBasicValue(elem, false))
|
||||
else if (isArrayLike(value)) getList(value).map((elem) -> getBasicValue(elem, false))
|
||||
else value
|
||||
|
||||
/// Underlying implementation for rendering values as toml
|
||||
local function doRenderValue(value: Any, path: List<String>): String =
|
||||
if (isTableArray(value))
|
||||
renderTableArray(value, path)
|
||||
else if (value is Map)
|
||||
renderTable(value, path)
|
||||
else
|
||||
renderInlineValue(value)
|
||||
|
||||
/// Determine whether an object is map-like. We'll consider any Dynamic that doesn't have any elements as map-like.
|
||||
local function isTableLike(obj: Any) = !(obj is AbstractDateTime) && ((obj is Dynamic && obj.toList().isEmpty) || obj is MapLike)
|
||||
|
||||
/// Determine whether an object is list-like. We'll consider any Dynamic that has elements as list-like.
|
||||
local function isArrayLike(obj: Any) = (obj is Dynamic && !obj.toList().isEmpty) || obj is ListLike
|
||||
|
||||
/// Convert an object to its Map representation. Toml doesn't include null so we should filter out null properties.
|
||||
local function getMap(obj: MapLike|Dynamic) = (if (obj is Map) obj else obj.toMap()).filter((_, elem) -> elem != null)
|
||||
|
||||
/// Convert an object to its List representation.
|
||||
local function getList(obj: ListLike|Dynamic) = if (obj is List) obj else obj.toList()
|
||||
|
||||
/// Determine if we should render this value as an array of tables or not.
|
||||
/// A value is an array of tables if all of the inhabitants are table-like.
|
||||
local function isTableArray(value: Any) =
|
||||
value is List && value.every((elem) -> elem is Map)
|
||||
|
||||
local function isTableTypeProp(value: Any) = value is Map || isTableArray(value)
|
||||
|
||||
local convertersMap = converters.toMap()
|
||||
|
||||
/// Render the value as an inline value (e.g. inline array, object, or primitive)
|
||||
local function renderInlineValue(value: Any) =
|
||||
if (value is Number && value.isNaN)
|
||||
"nan"
|
||||
else if (value == Infinity)
|
||||
"inf"
|
||||
else if (value is String)
|
||||
renderString(value)
|
||||
else if (value is Number|Boolean)
|
||||
jsonRenderer.renderValue(value)
|
||||
else if (value is AbstractDateTime)
|
||||
value.value
|
||||
else if (value is Map)
|
||||
"{ " + new Listing {
|
||||
for (k, v in value) {
|
||||
"\(makeSingleKey(k)) = \(renderInlineValue(v))"
|
||||
}
|
||||
}.toList().join(", ") + " }"
|
||||
else if (value is List)
|
||||
"[ " + value.map((elem) -> renderInlineValue(elem)).join(", ") + " ]"
|
||||
else
|
||||
throw("Not sure how to render value: \(value). Try defining a converter for this type.")
|
||||
|
||||
/// Render a string making sure multi-line use the """ multi-line syntax for better readability.
|
||||
local function renderString(value: String) =
|
||||
if (value.contains("\n"))
|
||||
("\"\"\"\n" +
|
||||
value.split("\n")
|
||||
.map((line) -> jsonRenderer.renderValue(line).drop(1).dropLast(1))
|
||||
.join("\n")
|
||||
+ "\"\"\"")
|
||||
else jsonRenderer.renderValue(value)
|
||||
|
||||
local function renderSingleTableArray(map: Map, path: List<String>) =
|
||||
let (nativeProps = map.filter((_, value) -> !isTableTypeProp(value)))
|
||||
let (tableProps = map.filter((_, value) -> isTableTypeProp(value)))
|
||||
new Listing {
|
||||
"""
|
||||
|
||||
[[\(makeKey(path))]]
|
||||
"""
|
||||
for (k, v in nativeProps) {
|
||||
"\(makeSingleKey(k)) = \(renderInlineValue(v))"
|
||||
}
|
||||
for (k, v in tableProps) {
|
||||
doRenderValue(v, path.add(k))
|
||||
}
|
||||
}.toList().join("\n")
|
||||
|
||||
local function renderTableArray(value: List, path: List<String>) =
|
||||
value.map((elem) -> renderSingleTableArray(getMap(elem), path)).join("\n")
|
||||
|
||||
local function makeSingleKey(key: String) = if (key.matches(Regex(#"[A-Za-z0-9_-]+"#)))
|
||||
key
|
||||
else
|
||||
jsonRenderer.renderValue(key)
|
||||
|
||||
local function makeKey(path: List<String>): String = path.map((k) -> makeSingleKey(k)).join(".")
|
||||
|
||||
local function renderTable(m: Map, path: List<String>): String =
|
||||
let (nativeProps = m.filter((_, value) -> !isTableTypeProp(value)))
|
||||
let (tableProps = m.filter((_, value) -> isTableTypeProp(value)))
|
||||
new Listing {
|
||||
// If we are in an object's context, render the object header. Skip if all children are also objects.
|
||||
when (!path.isEmpty && nativeProps.length > 0) {
|
||||
"""
|
||||
|
||||
[\(makeKey(path))]
|
||||
"""
|
||||
}
|
||||
for (k, v in nativeProps) {
|
||||
"\(makeSingleKey(k)) = \(renderInlineValue(v))"
|
||||
}
|
||||
for (k, v in tableProps) {
|
||||
doRenderValue(v, path.add(k))
|
||||
}
|
||||
}
|
||||
.toList()
|
||||
.join("\n")
|
||||
}
|
||||
|
||||
local typealias MapLike = Typed|Map|Mapping
|
||||
|
||||
local typealias ListLike = List|Listing
|
||||
Reference in New Issue
Block a user