Skip to content

Commit

Permalink
Merge pull request #945 from UniqueNetwork/release-v942057
Browse files Browse the repository at this point in the history
Release v942057
  • Loading branch information
gregzaitsev authored Jun 15, 2023
2 parents 0a1a3b4 + b8d1b18 commit e2ce643
Show file tree
Hide file tree
Showing 199 changed files with 7,981 additions and 4,465 deletions.
43 changes: 26 additions & 17 deletions .docker/Dockerfile-parachain-upgrade-data.j2
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ ARG PROFILE=release
WORKDIR /unique_parachain

RUN git clone https://github.com/UniqueNetwork/unique-chain.git -b {{ MAINNET_BRANCH }} . && \
cargo build --features={{ NETWORK }}-runtime --$PROFILE
cargo build --features={{ NETWORK }}-runtime --$PROFILE

# ===== BUILD target version ======
FROM rust-builder as builder-unique-target
Expand All @@ -35,43 +35,52 @@ ARG PROFILE=release
COPY . /unique_parachain
WORKDIR /unique_parachain

RUN cargo build --features={{ NETWORK }}-runtime --$PROFILE
RUN cargo build --features={{ NETWORK }}-runtime{{ EXTRA_FEATURES }} --$PROFILE

# ===== RUN ======
FROM ubuntu:22.04

ENV RELAY_CHAIN_TYPE={{ RELAY_CHAIN_TYPE }}
ENV REPLICA_FROM={{ REPLICA_FROM }}
ENV DESTINATION_SPEC_VERSION={{ DESTINATION_SPEC_VERSION }}
ENV NEW_PARA_BIN=/unique-chain/target/release/unique-collator
ENV NEW_PARA_WASM=/unique-chain/target/release/wbuild/{{ WASM_NAME }}-runtime/{{ WASM_NAME }}_runtime.compact.compressed.wasm

RUN apt-get -y update && \
apt-get -y install curl git && \
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash && \
export NVM_DIR="$HOME/.nvm" && \
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" && \
nvm install v16.16.0 && \
nvm use v16.16.0
nvm install v18.16.0 && \
nvm use v18.16.0

RUN git clone https://github.com/uniquenetwork/polkadot-launch.git -b {{ POLKADOT_LAUNCH_BRANCH }}

RUN export NVM_DIR="$HOME/.nvm" && \
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" && \
cd /polkadot-launch && \
npm install --global yarn && \
yarn install
RUN env

COPY --from=builder-unique-current /unique_parachain/target/release/unique-collator /unique-chain/current/release/
COPY --from=builder-unique-target /unique_parachain/target/release/unique-collator /unique-chain/target/release/
COPY --from=builder-unique-target /unique_parachain/target/release/wbuild/{{ WASM_NAME }}-runtime/{{ WASM_NAME }}_runtime.compact.compressed.wasm /unique-chain/target/release/wbuild/{{ WASM_NAME }}-runtime/{{ WASM_NAME }}_runtime.compact.compressed.wasm

COPY --from=builder-unique-target /unique_parachain/.docker/forkless-config/launch-config-forkless-data.json /polkadot-launch/launch-config.json
COPY --from=builder-unique-target /unique_parachain/.docker/forkless-config/fork.jsonnet /polkadot-launch/fork.jsonnet
COPY --from=builder-unique-target /unique_parachain/.docker/forkless-config/typeNames.jsonnet /polkadot-launch/typeNames.jsonnet
COPY --from=builder-unique-target /unique_parachain/.docker/forkless-config/zombienet-forkless-data.toml /unique-chain/tests/zombienet-forkless.toml
COPY --from=builder-unique-target /unique_parachain/.docker/forkless-config/fork.jsonnet /unique-chain/tests/fork.jsonnet
COPY --from=builder-unique-target /unique_parachain/tests/ /unique-chain/tests/

COPY --from=uniquenetwork/builder-chainql:{{ CHAINQL }} /chainql/target/release/chainql /chainql/target/release/

COPY --from=polkadot /unique_parachain/polkadot/target/release/polkadot /polkadot/target/release/
COPY --from=polkadot /unique_parachain/polkadot/target/release/wbuild/westend-runtime/westend_runtime.compact.compressed.wasm /polkadot/target/release/wbuild/westend-runtime/westend_runtime.compact.compressed.wasm
COPY --from=polkadot /unique_parachain/polkadot/target/release/wbuild/rococo-runtime/rococo_runtime.compact.compressed.wasm /polkadot/target/release/wbuild/rococo-runtime/rococo_runtime.compact.compressed.wasm

CMD export NVM_DIR="$HOME/.nvm" PATH="$PATH:/chainql/target/release" REPLICA_FROM && \
EXPOSE 33044
EXPOSE 33055
EXPOSE 33066
EXPOSE 33077
EXPOSE 33088
EXPOSE 33144
EXPOSE 33155

CMD export NVM_DIR="$HOME/.nvm" PATH="$PATH:/chainql/target/release" REPLICA_FROM NEW_PARA_BIN NEW_PARA_WASM RELAY_CHAIN_TYPE DESTINATION_SPEC_VERSION && \
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" && \
cd /polkadot-launch && \
yarn start launch-config.json --test-upgrade-parachains
cd /unique-chain/tests && \
npm install --global yarn && \
yarn install && \
export DEBUG=zombie::metrics && yarn frankenstein zombienet-forkless.toml
16 changes: 15 additions & 1 deletion .docker/docker-compose.forkless-data.j2
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,24 @@ version: "3.5"
services:
forkless-data:
image: uniquenetwork/ci-forkless-data-local:{{ NETWORK }}-{{ BUILD_TAG }}
container_name: forkless-data
container_name: forkless-data-{{ NETWORK }}
expose:
- 9944
- 9933
- 33044
- 33055
- 33066
- 33077
- 33088
- 33144
- 33155
ports:
- 127.0.0.1:9944:9944
- 127.0.0.1:9933:9933
- 127.0.0.1:33044:33044
- 127.0.0.1:33055:33055
- 127.0.0.1:33066:33066
- 127.0.0.1:33077:33077
- 127.0.0.1:33088:33088
- 127.0.0.1:33144:33144
- 127.0.0.1:33155:33155
86 changes: 49 additions & 37 deletions .docker/forkless-config/fork.jsonnet
Original file line number Diff line number Diff line change
@@ -1,44 +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 = [
// AuraExt.Authorities, we don't have aura pallet enabled for some reason, to refer using cql api
'0x3c311d57d4daf52904616cf69648081e5e0621c4869aa60c02be9adcc98a0d1d',
// Aura.Authorities
'0x57f8dc2f5ab09467896f47300f0424385e0621c4869aa60c02be9adcc98a0d1d',
],
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'],
sourceChain.System._key.ParentHash,
sourceChainState.ParachainInfo._key.ParachainId,
sourceChainState.Sudo._key.Key,
sourceChainState.System.BlockHash._key['0'],
// Always [69, 69, 69, ..., 69, 69, 69]
sourceChainState.System._key.ParentHash,
] + auraKeys,

// Keys to remove from original chain
unwantedPrefixes = [
// Aura.CurrentSlot
'0x57f8dc2f5ab09467896f47300f04243806155b3cd9a8c9e5e9a23fd5dc13a5ed',
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.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) = {
Expand All @@ -61,33 +69,37 @@ local outSpec = rawSpec {
},
};

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]: 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'),
},
},)
},
Expand Down
135 changes: 0 additions & 135 deletions .docker/forkless-config/launch-config-forkless-data.j2

This file was deleted.

Loading

0 comments on commit e2ce643

Please sign in to comment.