git.delta.rocks / unique-network / refs/commits / 6964da352da9

difftreelog

ci zombienet config + updated chainql files

Fahrrader2023-04-28parent: #379a12b.patch.diff
in: master

3 files changed

modified.docker/forkless-config/fork.jsonnetdiffbeforeafterboth
1// Get live chain data on the URL provided with `forkFrom`, and
2// insert the necessary data into a chain spec to launch a new chain with.
3//
4// ### Arguments
5// - `rawSpec`: Path to the raw chain spec to modify
6// - `forkFrom`: URL of the chain's WS port to get the data from
7//
8// ### Usage
9// `chainql --tla-code=rawSpec="import 'parachain-spec-raw.json'" --tla-str=forkFrom="wss://some-parachain.node:443" fork.jsonnet`
110
2function(rawSpec, forkFrom)11function(rawSpec, forkFrom)
3local sourceChain = cql.chain(forkFrom).latest;12local sourceChainState = cql.chain(forkFrom).latest;
413
5local raw = local sourceRaw = sourceChain._raw._preloadKeys; {14local raw = local sourceRaw = sourceChainState._raw._preloadKeys; {
6 [key]: cql.toHex(sourceRaw[key])15 [key]: cql.toHex(sourceRaw[key])
7 for key in std.objectFields(sourceRaw)16 for key in std.objectFields(sourceRaw)
8 if sourceRaw[key] != null17 if sourceRaw[key] != null
9};18};
1019
11local typeNames = (import './typeNames.jsonnet')(sourceChain);
12
13local20local
14auraKeys = [21auraKeys = [
15 sourceChain.AuraExt._key.Authorities,22 sourceChainState.AuraExt._key.Authorities,
16 sourceChain.Aura._key.Authorities,23 sourceChainState.Aura._key.Authorities,
17] + (if 'CollatorSelection' in sourceChain then [24] + (if 'CollatorSelection' in sourceChainState then [
18 sourceChain.CollatorSelection._key.Candidates,25 sourceChainState.CollatorSelection._key.Candidates,
19 sourceChain.CollatorSelection._key.Invulnerables,26 sourceChainState.CollatorSelection._key.Invulnerables,
20] else []),27] else []),
2128
22// Keys, which should be migrated from passed spec, rather than from forked chain29// Keys, which should be migrated from passed spec, rather than from forked chain
23wantedKeys = [30wantedKeys = [
24 sourceChain.ParachainInfo._key.ParachainId,31 sourceChainState.ParachainInfo._key.ParachainId,
25 sourceChain.Sudo._key.Key,32 sourceChainState.Sudo._key.Key,
26 sourceChain.System.BlockHash._key['0'],33 sourceChainState.System.BlockHash._key['0'],
27 // Always [69, 69, 69, ..., 69, 69, 69]34 // Always [69, 69, 69, ..., 69, 69, 69]
28 sourceChain.System._key.ParentHash,35 sourceChainState.System._key.ParentHash,
29] + auraKeys,36] + auraKeys,
30
31// Keys to remove from original chain37// Keys to remove from original chain
32unwantedPrefixes = [38unwantedPrefixes = [
33 sourceChain.Aura._key.CurrentSlot,39 sourceChainState.Aura._key.CurrentSlot,
34 // Ensure there will be no panics caused by unexpected kept state40 // Ensure there will be no panics caused by unexpected kept state
35 sourceChain.ParachainSystem._key.ValidationData,41 sourceChainState.ParachainSystem._key.ValidationData,
36 sourceChain.ParachainSystem._key.RelayStateProof,42 sourceChainState.ParachainSystem._key.RelayStateProof,
37 sourceChain.ParachainSystem._key.HostConfiguration,43 sourceChainState.ParachainSystem._key.HostConfiguration,
38 sourceChain.ParachainSystem._key.LastRelayChainBlockNumber,44 sourceChainState.ParachainSystem._key.LastRelayChainBlockNumber,
39 sourceChain.ParachainSystem._key.LastDmqMqcHead,45 sourceChainState.ParachainSystem._key.LastDmqMqcHead,
40 // Part of head46 // Part of head
41 sourceChain.System._key.BlockHash,47 sourceChainState.System._key.BlockHash,
42 sourceChain.System._key.Number,48 sourceChainState.System._key.Number,
43 sourceChain.System._key.Digest,49 sourceChainState.System._key.Digest,
44] + auraKeys,50] + auraKeys,
4551
46cleanupRaw(raw) = {52cleanupRaw(raw) = {
62 },68 },
63 },69 },
64};70};
71
72local pow10(n) = std.foldl(function(a, _) a * std.bigint('10'), std.range(0, n), std.bigint('1'));
6573
66local74local
67 aliceAccount = sourceChain.System._encodeKey.Account(['0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d']),75 aliceAccount = sourceChainState.System._encodeKey.Account(['0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d']),
68 totalIssuance = sourceChain.Balances._encodeKey.TotalIssuance([]),76 totalIssuance = sourceChainState.Balances._encodeKey.TotalIssuance([]),
69 unique = cql.calc(["10", "18", "**"]),77 Munique = pow10(6 + 18),
70 Munique = cql.calc([unique, "10", "6", "**", "*"]),
71;78;
7279
73outSpec {80outSpec {
74 genesis+: {81 genesis+: {
75 raw+: {82 raw+: {
76 top+: {83 top+: {
77 [totalIssuance]: sourceChain._encode(typeNames.u128, cql.calc([84 [totalIssuance]: sourceChainState.Balances._encodeValue.TotalIssuance(
78 Munique,85 if std.objectHas(super, totalIssuance)
79 if std.objectHas(super, totalIssuance) then sourceChain._decode(typeNames.u128, super[totalIssuance]) else '0',86 then sourceChainState.Balances._decodeValue.TotalIssuance(super[totalIssuance])
87 else std.bigint(0)
80 if std.objectHas(super, aliceAccount) then sourceChain._decode(typeNames.AccountInfo, super[aliceAccount]).data.free else '0',88 - if std.objectHas(super, aliceAccount)
89 then sourceChainState.System._decodeValue.Account(super[aliceAccount]).data.free
90 else std.bigint(0)
81 '-', '+',91 + Munique
82 ])),92 ),
83 [aliceAccount]: sourceChain._encode(typeNames.AccountInfo, {93 [aliceAccount]: sourceChainState.System._encodeValue.Account({
84 nonce: 0,94 nonce: 0,
85 consumers: 3,95 consumers: 3,
86 providers: 1,96 providers: 1,
87 sufficients: 0,97 sufficients: 0,
88 data: {98 data: {
89 free: Munique,99 free: Munique,
90 reserved: "0",100 reserved: std.bigint('0'),
91 misc_frozen: "0",101 misc_frozen: std.bigint('0'),
92 fee_frozen: "0",102 fee_frozen: std.bigint('0'),
93 },103 },
94 },)104 },)
95 },105 },
deleted.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'])
added.docker/forkless-config/zombienet-forkless-data.tomldiffbeforeafterboth
--- /dev/null
+++ b/.docker/forkless-config/zombienet-forkless-data.toml
@@ -0,0 +1,46 @@
+[settings]
+provider = "native"
+
+[relaychain]
+default_command = "/polkadot/target/release/polkadot"
+default_args = [ "-lparachain::candidate_validation=debug", "-lxcm=trace", ]
+chain = "{{ RELAY_CHAIN_TYPE }}-local"
+
+  [[relaychain.nodes]]
+  name = "relay-alice"
+  ws_port = 9844
+  rpc_port = 9843
+  p2p_port = 30444
+
+  [[relaychain.node_groups]]
+  name = "relay"
+  count = 4
+
+[[parachains]]
+id = 1000
+chain_spec_modifier_commands = [[
+  "chainql",
+  "--tla-code=rawSpec=import '{{'raw'|chainSpec}}'",
+  "--tla-str=forkFrom={{ REPLICA_FROM }}",
+  "fork.jsonnet",
+]]
+
+  [[parachains.collators]]
+  name = "alice"
+  command = "/unique-chain/current/release/unique-collator"
+  ws_port = 9944
+  rpc_port = 9933
+  p2p_port = 31200
+  args = [
+    "-lxcm=trace,parity_ws::handler=debug,jsonrpsee_core=trace,jsonrpsee-core=trace,jsonrpsee_ws_server=debug",
+  ]
+
+  [[parachains.collators]]
+  name = "bob"
+  command = "/unique-chain/current/release/unique-collator"
+  ws_port = 9945
+  rpc_port = 9934
+  p2p_port = 31201
+  args = [
+    "-lxcm=trace,parity_ws::handler=debug,jsonrpsee_core=trace,jsonrpsee-core=trace,jsonrpsee_ws_server=debug",
+  ]