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
--- 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'),
 					},
 				},)
 			},
deleted.docker/forkless-config/typeNames.jsonnetdiffbeforeafterboth
before · .docker/forkless-config/typeNames.jsonnet
1function(chain)2local3	typeName(id) = local4		ty = chain._meta.types.types[id],5		name = if std.objectHas(ty.type, "path") then6			std.join('::', ty.type.path)7		else if std.objectHas(ty.type.def, "primitive") then ty.type.def.primitive8		else if std.objectHas(ty.type.def, "tuple") then "(" + std.join(', ', std.map(typeName, ty.type.def.tuple)) + ")"9		else if std.objectHas(ty.type.def, "sequence") then "Vec<" + typeName(ty.type.def.sequence.type) + ">"10		else if std.objectHas(ty.type.def, "array") then "[" + typeName(ty.type.def.array.type) + "; " + ty.type.def.array.len + "]"11		else if std.objectHas(ty.type.def, "compact") then "Compact<" + typeName(ty.type.def.compact.type) + ">"12		else error "Can't generate useable name for " + ty.type,13		generics = if std.objectHas(ty.type, "params") then14			'<' + std.join(', ', std.map(function(p) if p.type == null then 'Spec#'+id else typeName(p.type), ty.type.params)) + '>'15		else ''16	; name + generics,17	shortenPrefix(obj, prefix, short) = {18		[short]: obj[field]19		for field in std.objectFields(obj)20		// There should be at most one element with this prefix21		if std.startsWith(field, prefix)22	},23	makeObject(keyValues) = std.foldl(function(o, kv) if kv[0] in o then o else o + {[kv[0]]: kv[1]}, keyValues, {}),24;2526local typesRaw = makeObject([27	[typeName(id), id]28	for id in std.range(0, std.length(chain._meta.types.types)-1)29]);3031local types = typesRaw + shortenPrefix(typesRaw, 'frame_system::AccountInfo<', 'AccountInfo');3233types34// local35// ;3637// local encoded = chain._encode(types['AccountInfo'], {38// 	nonce: 0,39// 	consumers: 3,40// 	providers: 1,41// 	sufficients: 0,42// 	data: {43// 		free: Munique,44// 		reserved: "0",45// 		misc_frozen: "0",46// 		fee_frozen: "0",47// 	},48// });4950// local systemAccount = chain._decode(types['AccountInfo'], encoded);5152// 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",
+  ]