-
Notifications
You must be signed in to change notification settings - Fork 721
/
genesis.jq
98 lines (87 loc) · 2.78 KB
/
genesis.jq
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
## WARNING: keep in sync with 'profile-cache-key-input' below this one: vvv
##
def fmt_decimal_10_5($x):
($x / 100000 | tostring) + "00000";
def profile_cli_args($p):
{ common:
{ createSpec:
[ "--supply", fmt_decimal_10_5($p.derived.supply_total)
, "--testnet-magic", $p.genesis.network_magic
, "--gen-genesis-keys", $p.composition.n_bft_hosts
, "--gen-utxo-keys", 1
]
, createFinalIncremental:
([ "--supply", $p.genesis.funds_balance
, "--gen-utxo-keys", 1
] +
if $p.composition.dense_pool_density != 1
then
[ ]
else [] end)
, createFinalBulk:
([ "--supply", fmt_decimal_10_5($p.genesis.funds_balance)
, "--gen-utxo-keys", 1
, "--gen-genesis-keys", $p.composition.n_bft_hosts
, "--supply-delegated", fmt_decimal_10_5($p.derived.supply_delegated)
, "--gen-pools", $p.composition.n_pools
, "--gen-stake-delegs", $p.derived.delegators_effective
, "--testnet-magic", $p.genesis.network_magic
, "--num-stuffed-utxo", fmt_decimal_10_5($p.derived.utxo_stuffed)
] +
if $p.composition.dense_pool_density != 1
then
[ "--bulk-pool-cred-files", $p.composition.n_dense_hosts
, "--bulk-pools-per-file", $p.composition.dense_pool_density ]
else [] end)
, pools:
[ "--argjson"
, "initialPoolCoin", fmt_decimal_10_5($p.genesis.pool_coin)
]
}
}
| .common * (.[$p.era] // {})
;
## Remove parts of profile that don't invalidate
## the cryptographic material in genesis. Note the opportunistic approach.
##
## Note also, that the genesis cache entry itself must still be updated
## to match these parameters, hence the distinction between parameters:
##
## WARNING: keep in sync with 'profile_cli_args' above ^^^
##
def profile_genesis_cache_key($p; $profile_file):
($p.genesis * $p.composition * $p.derived)
|
{ network_magic
, funds_balance
, per_pool_balance
, pool_coin
, n_pools
, n_bft_hosts
, n_dense_hosts
, dense_pool_density
, delegators
, utxo_stuffed
} as $genesis_crypto_affecting_data
| $genesis_crypto_affecting_data | to_entries
| map(if .value == null
then error("FATAL: undefined key \(.key) in profile \(.profile_file)")
else null end)
| $genesis_crypto_affecting_data
;
def profile_genesis_cache_entry_name($p; $params_hash):
if $p.preset == null
then [ "k\(.composition.n_pools)" ]
+
if .composition.dense_pool_density == 1 then []
else
[ "d\(.composition.dense_pool_density)" ] end
+
[ "\(.genesis.delegators / 1000)kD"
, "\(.derived.utxo_stuffed / 1000)kU"
, "\($params_hash)" ]
else [ "preset"
, $profile[0].preset ]
end
| join("-")
;