difftreelog
ci zombienet config + updated chainql files
in: master
3 files changed
.docker/forkless-config/fork.jsonnetdiffbeforeafterboth--- a/.docker/forkless-config/fork.jsonnet
+++ b/.docker/forkless-config/fork.jsonnet
@@ -1,46 +1,52 @@
+// Get live chain data on the URL provided with `forkFrom`, and
+// insert the necessary data into a chain spec to launch a new chain with.
+//
+// ### Arguments
+// - `rawSpec`: Path to the raw chain spec to modify
+// - `forkFrom`: URL of the chain's WS port to get the data from
+//
+// ### Usage
+// `chainql --tla-code=rawSpec="import 'parachain-spec-raw.json'" --tla-str=forkFrom="wss://some-parachain.node:443" fork.jsonnet`
function(rawSpec, forkFrom)
-local sourceChain = cql.chain(forkFrom).latest;
+local sourceChainState = cql.chain(forkFrom).latest;
-local raw = local sourceRaw = sourceChain._raw._preloadKeys; {
+local raw = local sourceRaw = sourceChainState._raw._preloadKeys; {
[key]: cql.toHex(sourceRaw[key])
for key in std.objectFields(sourceRaw)
if sourceRaw[key] != null
};
-local typeNames = (import './typeNames.jsonnet')(sourceChain);
-
local
auraKeys = [
- sourceChain.AuraExt._key.Authorities,
- sourceChain.Aura._key.Authorities,
-] + (if 'CollatorSelection' in sourceChain then [
- sourceChain.CollatorSelection._key.Candidates,
- sourceChain.CollatorSelection._key.Invulnerables,
+ sourceChainState.AuraExt._key.Authorities,
+ sourceChainState.Aura._key.Authorities,
+] + (if 'CollatorSelection' in sourceChainState then [
+ sourceChainState.CollatorSelection._key.Candidates,
+ sourceChainState.CollatorSelection._key.Invulnerables,
] else []),
// Keys, which should be migrated from passed spec, rather than from forked chain
wantedKeys = [
- sourceChain.ParachainInfo._key.ParachainId,
- sourceChain.Sudo._key.Key,
- sourceChain.System.BlockHash._key['0'],
+ sourceChainState.ParachainInfo._key.ParachainId,
+ sourceChainState.Sudo._key.Key,
+ sourceChainState.System.BlockHash._key['0'],
// Always [69, 69, 69, ..., 69, 69, 69]
- sourceChain.System._key.ParentHash,
+ sourceChainState.System._key.ParentHash,
] + auraKeys,
-
// Keys to remove from original chain
unwantedPrefixes = [
- sourceChain.Aura._key.CurrentSlot,
+ sourceChainState.Aura._key.CurrentSlot,
// Ensure there will be no panics caused by unexpected kept state
- sourceChain.ParachainSystem._key.ValidationData,
- sourceChain.ParachainSystem._key.RelayStateProof,
- sourceChain.ParachainSystem._key.HostConfiguration,
- sourceChain.ParachainSystem._key.LastRelayChainBlockNumber,
- sourceChain.ParachainSystem._key.LastDmqMqcHead,
+ sourceChainState.ParachainSystem._key.ValidationData,
+ sourceChainState.ParachainSystem._key.RelayStateProof,
+ sourceChainState.ParachainSystem._key.HostConfiguration,
+ sourceChainState.ParachainSystem._key.LastRelayChainBlockNumber,
+ sourceChainState.ParachainSystem._key.LastDmqMqcHead,
// Part of head
- sourceChain.System._key.BlockHash,
- sourceChain.System._key.Number,
- sourceChain.System._key.Digest,
+ sourceChainState.System._key.BlockHash,
+ sourceChainState.System._key.Number,
+ sourceChainState.System._key.Digest,
] + auraKeys,
cleanupRaw(raw) = {
@@ -63,33 +69,37 @@
},
};
+local pow10(n) = std.foldl(function(a, _) a * std.bigint('10'), std.range(0, n), std.bigint('1'));
+
local
- aliceAccount = sourceChain.System._encodeKey.Account(['0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d']),
- totalIssuance = sourceChain.Balances._encodeKey.TotalIssuance([]),
- unique = cql.calc(["10", "18", "**"]),
- Munique = cql.calc([unique, "10", "6", "**", "*"]),
+ aliceAccount = sourceChainState.System._encodeKey.Account(['0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d']),
+ totalIssuance = sourceChainState.Balances._encodeKey.TotalIssuance([]),
+ Munique = pow10(6 + 18),
;
outSpec {
genesis+: {
raw+: {
top+: {
- [totalIssuance]: sourceChain._encode(typeNames.u128, cql.calc([
- Munique,
- if std.objectHas(super, totalIssuance) then sourceChain._decode(typeNames.u128, super[totalIssuance]) else '0',
- if std.objectHas(super, aliceAccount) then sourceChain._decode(typeNames.AccountInfo, super[aliceAccount]).data.free else '0',
- '-', '+',
- ])),
- [aliceAccount]: sourceChain._encode(typeNames.AccountInfo, {
+ [totalIssuance]: sourceChainState.Balances._encodeValue.TotalIssuance(
+ if std.objectHas(super, totalIssuance)
+ then sourceChainState.Balances._decodeValue.TotalIssuance(super[totalIssuance])
+ else std.bigint(0)
+ - if std.objectHas(super, aliceAccount)
+ then sourceChainState.System._decodeValue.Account(super[aliceAccount]).data.free
+ else std.bigint(0)
+ + Munique
+ ),
+ [aliceAccount]: sourceChainState.System._encodeValue.Account({
nonce: 0,
consumers: 3,
providers: 1,
sufficients: 0,
data: {
free: Munique,
- reserved: "0",
- misc_frozen: "0",
- fee_frozen: "0",
+ reserved: std.bigint('0'),
+ misc_frozen: std.bigint('0'),
+ fee_frozen: std.bigint('0'),
},
},)
},
.docker/forkless-config/typeNames.jsonnetdiffbeforeafterboth--- a/.docker/forkless-config/typeNames.jsonnet
+++ /dev/null
@@ -1,52 +0,0 @@
-function(chain)
-local
- typeName(id) = local
- ty = chain._meta.types.types[id],
- name = if std.objectHas(ty.type, "path") then
- std.join('::', ty.type.path)
- else if std.objectHas(ty.type.def, "primitive") then ty.type.def.primitive
- else if std.objectHas(ty.type.def, "tuple") then "(" + std.join(', ', std.map(typeName, ty.type.def.tuple)) + ")"
- else if std.objectHas(ty.type.def, "sequence") then "Vec<" + typeName(ty.type.def.sequence.type) + ">"
- else if std.objectHas(ty.type.def, "array") then "[" + typeName(ty.type.def.array.type) + "; " + ty.type.def.array.len + "]"
- else if std.objectHas(ty.type.def, "compact") then "Compact<" + typeName(ty.type.def.compact.type) + ">"
- else error "Can't generate useable name for " + ty.type,
- generics = if std.objectHas(ty.type, "params") then
- '<' + std.join(', ', std.map(function(p) if p.type == null then 'Spec#'+id else typeName(p.type), ty.type.params)) + '>'
- else ''
- ; name + generics,
- shortenPrefix(obj, prefix, short) = {
- [short]: obj[field]
- for field in std.objectFields(obj)
- // There should be at most one element with this prefix
- if std.startsWith(field, prefix)
- },
- makeObject(keyValues) = std.foldl(function(o, kv) if kv[0] in o then o else o + {[kv[0]]: kv[1]}, keyValues, {}),
-;
-
-local typesRaw = makeObject([
- [typeName(id), id]
- for id in std.range(0, std.length(chain._meta.types.types)-1)
-]);
-
-local types = typesRaw + shortenPrefix(typesRaw, 'frame_system::AccountInfo<', 'AccountInfo');
-
-types
-// local
-// ;
-
-// local encoded = chain._encode(types['AccountInfo'], {
-// nonce: 0,
-// consumers: 3,
-// providers: 1,
-// sufficients: 0,
-// data: {
-// free: Munique,
-// reserved: "0",
-// misc_frozen: "0",
-// fee_frozen: "0",
-// },
-// });
-
-// local systemAccount = chain._decode(types['AccountInfo'], encoded);
-
-// chain.System._encodeKey.Account(['0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d'])
.docker/forkless-config/zombienet-forkless-data.tomldiffbeforeafterbothno content