1234567891011function(rawSpec, forkFrom)12local sourceChainState = cql.chain(forkFrom).latest;1314local raw = local sourceRaw = sourceChainState._raw._preloadKeys; {15 [key]: cql.toHex(sourceRaw[key])16 for key in std.objectFields(sourceRaw)17 if sourceRaw[key] != null18};1920local21auraKeys = [22 sourceChainState.AuraExt._key.Authorities,23 sourceChainState.Aura._key.Authorities,24] + (if 'CollatorSelection' in sourceChainState then [25 sourceChainState.CollatorSelection._key.Candidates,26 sourceChainState.CollatorSelection._key.Invulnerables,27] else []),282930wantedKeys = [31 sourceChainState.ParachainInfo._key.ParachainId,32 sourceChainState.Sudo._key.Key,33 sourceChainState.System.BlockHash._key['0'],34 35 sourceChainState.System._key.ParentHash,36] + auraKeys,3738unwantedPrefixes = [39 sourceChainState.Aura._key.CurrentSlot,40 41 sourceChainState.ParachainSystem._key.ValidationData,42 sourceChainState.ParachainSystem._key.RelayStateProof,43 sourceChainState.ParachainSystem._key.HostConfiguration,44 sourceChainState.ParachainSystem._key.LastRelayChainBlockNumber,45 sourceChainState.ParachainSystem._key.LastDmqMqcHead,46 47 sourceChainState.System._key.BlockHash,48 sourceChainState.System._key.Number,49 sourceChainState.System._key.Digest,50] + auraKeys,5152cleanupRaw(raw) = {53 [key]: raw[key]54 for key in std.objectFields(raw)55 if std.all(std.map(function(prefix) !std.startsWith(key, prefix), unwantedPrefixes))56};575859local originalRaw = rawSpec.genesis.raw.top;60local outSpec = rawSpec {61 genesis+: {62 raw+: {63 top: cleanupRaw(raw) {64 [key]: originalRaw[key]65 for key in wantedKeys66 if std.objectHas(originalRaw, key)67 },68 },69 },70};7172local pow10(n) = std.foldl(function(a, _) a * std.bigint('10'), std.range(0, n), std.bigint('1'));7374local75 aliceAccount = sourceChainState.System._encodeKey.Account(['0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d']),76 totalIssuance = sourceChainState.Balances._encodeKey.TotalIssuance([]),77 Munique = pow10(6 + 18),78;7980outSpec {81 genesis+: {82 raw+: {83 top+: {84 [totalIssuance]: sourceChainState.Balances._encodeValue.TotalIssuance(85 if std.objectHas(super, totalIssuance)86 then sourceChainState.Balances._decodeValue.TotalIssuance(super[totalIssuance])87 else std.bigint(0)88 - if std.objectHas(super, aliceAccount)89 then sourceChainState.System._decodeValue.Account(super[aliceAccount]).data.free90 else std.bigint(0)91 + Munique92 ),93 [aliceAccount]: sourceChainState.System._encodeValue.Account({94 nonce: 0,95 consumers: 3,96 providers: 1,97 sufficients: 0,98 data: {99 free: Munique,100 reserved: std.bigint('0'),101 misc_frozen: std.bigint('0'),102 fee_frozen: std.bigint('0'),103 },104 },)105 },106 },107 },108}