git.delta.rocks / unique-network / refs/commits / bcf103b2e619

difftreelog

Merge pull request #286 from UniqueNetwork/release/opal-v916000

kozyrevdev2022-02-11parents: #5bd4b32 #f13427c.patch.diff
in: master
Release Opal Runtime v916001

13 files changed

modifiedCargo.lockdiffbeforeafterboth
382382
383[[package]]383[[package]]
384name = "autocfg"384name = "autocfg"
385version = "1.0.1"385version = "1.1.0"
386source = "registry+https://github.com/rust-lang/crates.io-index"386source = "registry+https://github.com/rust-lang/crates.io-index"
387checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"387checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
388388
389[[package]]389[[package]]
390name = "backtrace"390name = "backtrace"
634634
635[[package]]635[[package]]
636name = "block-buffer"636name = "block-buffer"
637version = "0.10.1"637version = "0.10.2"
638source = "registry+https://github.com/rust-lang/crates.io-index"638source = "registry+https://github.com/rust-lang/crates.io-index"
639checksum = "03588e54c62ae6d763e2a80090d50353b785795361b4ff5b3bf0a5097fc31c0b"639checksum = "0bf7fe51849ea569fd452f37822f606a5cabb684dc918707a0193fd4664ff324"
640dependencies = [640dependencies = [
641 "generic-array 0.14.5",641 "generic-array 0.14.5",
642]642]
10971097
1098[[package]]1098[[package]]
1099name = "core-foundation"1099name = "core-foundation"
1100version = "0.9.2"1100version = "0.9.3"
1101source = "registry+https://github.com/rust-lang/crates.io-index"1101source = "registry+https://github.com/rust-lang/crates.io-index"
1102checksum = "6888e10551bb93e424d8df1d07f1a8b4fceb0001a3a4b048bfc47554946f47b3"1102checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146"
1103dependencies = [1103dependencies = [
1104 "core-foundation-sys",1104 "core-foundation-sys",
1105 "libc",1105 "libc",
12291229
1230[[package]]1230[[package]]
1231name = "crc32fast"1231name = "crc32fast"
1232version = "1.3.1"1232version = "1.3.2"
1233source = "registry+https://github.com/rust-lang/crates.io-index"1233source = "registry+https://github.com/rust-lang/crates.io-index"
1234checksum = "a2209c310e29876f7f0b2721e7e26b84aff178aa3da5d091f9bfbf47669e60e3"1234checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d"
1235dependencies = [1235dependencies = [
1236 "cfg-if 1.0.0",1236 "cfg-if 1.0.0",
1237]1237]
12881288
1289[[package]]1289[[package]]
1290name = "crypto-common"1290name = "crypto-common"
1291version = "0.1.1"1291version = "0.1.2"
1292source = "registry+https://github.com/rust-lang/crates.io-index"1292source = "registry+https://github.com/rust-lang/crates.io-index"
1293checksum = "683d6b536309245c849479fba3da410962a43ed8e51c26b729208ec0ac2798d0"1293checksum = "a4600d695eb3f6ce1cd44e6e291adceb2cc3ab12f20a33777ecd0bf6eba34e06"
1294dependencies = [1294dependencies = [
1295 "generic-array 0.14.5",1295 "generic-array 0.14.5",
1296]1296]
18981898
1899[[package]]1899[[package]]
1900name = "digest"1900name = "digest"
1901version = "0.10.1"1901version = "0.10.2"
1902source = "registry+https://github.com/rust-lang/crates.io-index"1902source = "registry+https://github.com/rust-lang/crates.io-index"
1903checksum = "b697d66081d42af4fba142d56918a3cb21dc8eb63372c6b85d14f44fb9c5979b"1903checksum = "8cb780dce4f9a8f5c087362b3a4595936b2019e7c8b30f2c3e9a7e94e6ae9837"
1904dependencies = [1904dependencies = [
1905 "block-buffer 0.10.1",1905 "block-buffer 0.10.2",
1906 "crypto-common",1906 "crypto-common",
1907 "generic-array 0.14.5",
1908]1907]
19091908
1910[[package]]1909[[package]]
32413240
3242[[package]]3241[[package]]
3243name = "httparse"3242name = "httparse"
3244version = "1.5.1"3243version = "1.6.0"
3245source = "registry+https://github.com/rust-lang/crates.io-index"3244source = "registry+https://github.com/rust-lang/crates.io-index"
3246checksum = "acd94fdbe1d4ff688b67b04eee2e17bd50995534a61539e45adfefb45e5e5503"3245checksum = "9100414882e15fb7feccb4897e5f0ff0ff1ca7d1a86a23208ada4d7a18e6c6c4"
32473246
3248[[package]]3247[[package]]
3249name = "httpdate"3248name = "httpdate"
46644663
4665[[package]]4664[[package]]
4666name = "memmap2"4665name = "memmap2"
4667version = "0.5.2"4666version = "0.5.3"
4668source = "registry+https://github.com/rust-lang/crates.io-index"4667source = "registry+https://github.com/rust-lang/crates.io-index"
4669checksum = "fe3179b85e1fd8b14447cbebadb75e45a1002f541b925f0bfec366d56a81c56d"4668checksum = "057a3db23999c867821a7a59feb06a578fcb03685e983dff90daf9e7d24ac08f"
4670dependencies = [4669dependencies = [
4671 "libc",4670 "libc",
4672]4671]
8805source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.16#4aeb95f7f38fcd519e2628f32f79044a8fef99d5"8804source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.16#4aeb95f7f38fcd519e2628f32f79044a8fef99d5"
8806dependencies = [8805dependencies = [
8807 "impl-trait-for-tuples",8806 "impl-trait-for-tuples",
8808 "memmap2 0.5.2",8807 "memmap2 0.5.3",
8809 "parity-scale-codec",8808 "parity-scale-codec",
8810 "sc-chain-spec-derive",8809 "sc-chain-spec-derive",
8811 "sc-network",8810 "sc-network",
9912dependencies = [9911dependencies = [
9913 "cfg-if 1.0.0",9912 "cfg-if 1.0.0",
9914 "cpufeatures 0.2.1",9913 "cpufeatures 0.2.1",
9915 "digest 0.10.1",9914 "digest 0.10.2",
9916]9915]
99179916
9918[[package]]9917[[package]]
1164411643
11645[[package]]11644[[package]]
11646name = "unique-node"11645name = "unique-node"
11647version = "0.9.14"11646version = "0.9.16"
11648dependencies = [11647dependencies = [
11649 "cumulus-client-cli",11648 "cumulus-client-cli",
11650 "cumulus-client-collator",11649 "cumulus-client-collator",
modifiedDockerfile-parachaindiffbeforeafterboth
90 nvm install v15.5.0 && \90 nvm install v15.5.0 && \
91 nvm use v15.5.091 nvm use v15.5.0
9292
93RUN git clone https://github.com/PureStake/polkadot-launch -b jlm-use-para-id-in-specs93RUN git clone https://github.com/paritytech/polkadot-launch
9494
95RUN export NVM_DIR="$HOME/.nvm" && \95RUN export NVM_DIR="$HOME/.nvm" && \
96 [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" && \96 [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" && \
modifiedREADME.mddiffbeforeafterboth
2929
30Please see our [walk-thorugh instructions](doc/hackusama_walk_through.md) to try everything out!30Please see our [walk-thorugh instructions](doc/hackusama_walk_through.md) to try everything out!
3131
32## Hackusama Update
33
34During the Kusama Hackaphon the following changes were made:
35
36- Enabled Smart Contracts Pallet
37- Enabled integration between Smart Contracts and Unique Pallet (required special edition of RC4 Substrate version)
38- Fixed misc. bugs in Unique Pallet
39- Deployed Unique TestNet. Public node available at wss://unique.usetech.com, custom UI types - see below in this README.
40- New Features:
41 - Re-Fungible Token Mode
42 - Off-Chain Schema to store token image URLs
43 - Alternative economic model
44 - Allow Lists and Public Mint Permission
45- Use example: [SubstraPunks Game](https://github.com/usetech-llc/substrapunks), fully hosted on IPFS and Unique Testnet
46 Blockchain.
47
48## Application Development32## Application Development
4933
50If you are building an application that operates NFT tokens, use [this document](doc/application_development.md).34If you are building an application that operates NFT tokens, use [this document](doc/application_development.md).
5135
36
52## Building37## Building
5338
54Building Unique chain requires special versions of Rust and toolchain. We don't use the most recent versions of everything39Building Unique chain requires special versions of Rust and toolchain. We don't use the most recent versions of everything
571. Install Rust:421. Install Rust:
5843
59```bash44```bash
45sudo apt-get install git curl libssl-dev llvm pkg-config libclang-dev clang
60curl https://sh.rustup.rs -sSf | sh46curl https://sh.rustup.rs -sSf | sh
61sudo apt-get install libssl-dev pkg-config libclang-dev clang
62```47```
6348
642. Remove all installed toolchains with `rustup toolchain list` and `rustup toolchain uninstall <toolchain>`.492. Remove all installed toolchains with `rustup toolchain list` and `rustup toolchain uninstall <toolchain>`.
86cargo build --release71cargo build --release
87```72```
8873
89## Run74## Building as Parachain locally
9075
91You can start a development chain with:76Note: checkout this project and all related projects (see below) in the sibling folders (both under the same folder)
9277
93```bash
94cargo run -- --dev78### Polkadot launch utility
95```
9679
97Detailed logs may be shown by running the node with the following environment variables set:
98`RUST_LOG=debug RUST_BACKTRACE=1 cargo run -- --dev`.
99
100If you want to see the multi-node consensus algorithm in action locally, then you can create a local testnet with two
101validator nodes for Alice and Bob, who are the initial authorities of the genesis chain that have been endowed with
102testnet units. Give each node a name and expose them so they are listed on the Polkadot
103[telemetry site](https://telemetry.polkadot.io/#/Local%20Testnet). You'll need two terminal windows open.
104
105We'll start Alice's substrate node first on default TCP port 30333 with her chain database stored locally at
106`/tmp/alice`. The bootnode ID of her node is `QmQZ8TjTqeDj3ciwr93EJ95hxfDsb9pEYDizUAbWpigtQN`, which is generated from
107the `--node-key` value that we specify below:
108
109```bash
110cargo run -- \
111 --base-path /tmp/alice \
112 --chain=local \
113 --alice \
114 --node-key 0000000000000000000000000000000000000000000000000000000000000001 \
115 --telemetry-url ws://telemetry.polkadot.io:1024 \
116 --validator
117```80```
118
119In the second terminal, we'll start Bob's substrate node on a different TCP port of 30334, and with his chain database81git clone https://github.com/paritytech/polkadot-launch
120stored locally at `/tmp/bob`. We'll specify a value for the `--bootnodes` option that will connect his node to Alice's
121bootnode ID on TCP port 30333:
122
123```bash
124cargo run -- \
125 --base-path /tmp/bob \
126 --bootnodes /ip4/127.0.0.1/tcp/30333/p2p/QmQZ8TjTqeDj3ciwr93EJ95hxfDsb9pEYDizUAbWpigtQN \
127 --chain=local \
128 --bob \
129 --port 30334 \
130 --telemetry-url ws://telemetry.polkadot.io:1024 \
131 --validator
132```82```
13383
134Additional CLI usage options are available and may be shown by running `cargo run -- --help`.
135
136## Building and Running as Parachain locally
137
138Rust toolchain: nightly-2021-11-11
139Note: checkout this project and polkadot project (see below) in the sibling folders (both under the same folder)
140
141### Build relay84### Build relay
14285
143```86```
144git clone https://github.com/paritytech/polkadot.git87git clone https://github.com/paritytech/polkadot.git
145cd polkadot88cd polkadot
146git checkout release-v0.9.989git checkout release-v0.9.16
147cargo build --release90cargo build --release
148```91```
14992
150### Build parachain93### Build Unique parachain
15194
152Run in the root of this project:95Run in the root of this project:
153```96```
154cargo --build97cargo build --release
155```98```
15699
157### Run 4-node Relay100### Build Acala parachain (optional, full config only)
158101
1591. Download `rococo-custom-4.json` chain spec here: https://substrate.dev/cumulus-workshop/shared/chainspecs/rococo-custom-4.json
1602. Use these instructions to launch 4 nodes: https://substrate.dev/cumulus-workshop/#/en/2-relay-chain/1-launch
161
162Example (Run in polkadot folder. Replace `12D3KooWNLAmKcyee3oqSgTMthaQVXaAcXeo8RrGCzMfMVA3B5on` with output from Alice node):
163```102```
164./target/release/polkadot --alice --validator --base-path ./cumulus_relay0 --chain rococo-custom-4.json --port 50555 --ws-port 9944103git clone https://github.com/AcalaNetwork/Acala
165./target/release/polkadot --bob --validator --base-path ./cumulus_relay1 --chain rococo-custom-4.json --bootnodes /ip4/127.0.0.1/tcp/30333/p2p/12D3KooWNLAmKcyee3oqSgTMthaQVXaAcXeo8RrGCzMfMVA3B5on --port 50556 --ws-port 9945104cd Acala
166./target/release/polkadot --charlie --validator --base-path ./cumulus_relay1 --chain rococo-custom-4.json --bootnodes /ip4/127.0.0.1/tcp/30333/p2p/12D3KooWNLAmKcyee3oqSgTMthaQVXaAcXeo8RrGCzMfMVA3B5on --port 50557 --ws-port 9946105git checkout 54db3acd409a0b787f116f20e163a3b24101ce38
167./target/release/polkadot --dave --validator --base-path ./cumulus_relay1 --chain rococo-custom-4.json --bootnodes /ip4/127.0.0.1/tcp/30333/p2p/12D3KooWNLAmKcyee3oqSgTMthaQVXaAcXeo8RrGCzMfMVA3B5on --port 50558 --ws-port 9947106make build-release
168
169```107```
170108
1713. Export genesis state and runtime wasm from Unique parachain:109## Running as Parachain locally
172110
173Run from this project root:
174```111```
175./target/release/unique-collator export-genesis-state --parachain-id 2000 > ./resources/para-2000-genesis112./launch-testnet.sh
176./target/release/unique-collator export-genesis-wasm > ./resources/para-2000-wasm
177```113```
178114
1794. Run two parachain nodes:115Optional, full setup with Acala and Statemint
180
181Replace `12D3KooWN1ah2bFQSysEFnwZqcmcVpDDR8UedXyo6xfzV1zDNMNg` with Alice or Bob relay ID
182
183Run from this project root:
184```116```
185./target/release/unique-collator --alice --collator --force-authoring --base-path ./tmp/parachain-alice --parachain-id 2000 --port 40333 --ws-port 9844 -- --execution wasm --chain ../polkadot/rococo-custom-4.json --port 30343 --ws-port 9977117./launch-testnet-full.sh
186./target/release/unique-collator --bob --collator --force-authoring --parachain-id 2000 --base-path ./tmp/parachain/bob --port 40334 --ws-port 9845 -- --execution wasm --chain ../polkadot/rococo-custom-4.json --port 30344 --ws-port 9978 --bootnodes /ip4/127.0.0.1/tcp/50556/p2p/12D3KooWN1ah2bFQSysEFnwZqcmcVpDDR8UedXyo6xfzV1zDNMNg
187```118```
188119
1894. Reserve parachain ID as described here: https://substrate.dev/cumulus-workshop/#/en/2-relay-chain/2-reserve
190
1915. Register parachain in relay as described here: https://substrate.dev/cumulus-workshop/#/en/3-parachains/2-register
192
193
194## Run Integration Tests120## Run Integration Tests
195121
1961. Install all needed dependecies1221. Install all needed dependecies
204yarn test130yarn test
205```131```
206132
207## Benchmarks
208133
209First of all, add rust toolchain and make it default.
210```bash
211rustup target add wasm32-unknown-unknown --toolchain nightly-2021-11-11
212```
213
214Then in "/node/src" run build command below
215```bash
216cargo +nightly-2021-11-11 build --release --features runtime-benchmarks
217```
218
219Run benchmark
220```bash
221target/release/unique-collator benchmark --chain dev --pallet "pallet_unique" --extrinsic "*" --repeat 1
222```
223
224## UI custom types
225
226Moved to [runtime_types.json](./runtime_types.json).
227
228## Running Integration Tests
229
230See [tests/README.md](./tests/README.md).
231
232## Code Formatting134## Code Formatting
233135
234### Get formatter and linter settings into your branch (if you forked before they were introduced)
235```bash
236git cherry-pick -n 8ff77c21b0d30b2a4648fa35dbf61dfa9d3948a7
237```
238
239### Apply formatting and clippy fixes136### Apply formatting and clippy fixes
240```bash137```bash
241cargo clippy138cargo clippy
252cd tests && yarn eslint --ext .ts,.js src/149cd tests && yarn eslint --ext .ts,.js src/
253```150```
254151
255## Re-Enabling Ink! Contracts
256152
257Uncomment following lies:
2581. In node/rpc/Cargo.toml
259```
260# pallet-contracts-rpc = { version = "3.0", git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.9' }
261```
262
2632. In node/rpc/src/lib.rs
264```
265// C::Api: pallet_contracts_rpc::ContractsRuntimeApi<Block, AccountId, Balance, BlockNumber, Hash>,
266...
267// use pallet_contracts_rpc::{Contracts, ContractsApi};
268...
269// io.extend_with(ContractsApi::to_delegate(Contracts::new(client.clone())));
270
271```
272
2733. In runtime/Cargo.toml
274```
275 # 'pallet-contracts/std',
276 # 'pallet-contracts-primitives/std',
277 # 'pallet-contracts-rpc-runtime-api/std',
278 # 'pallet-contract-helpers/std',
279...
280 # [dependencies.pallet-contracts]
281 # git = 'https://github.com/paritytech/substrate.git'
282 # default-features = false
283 # branch = 'polkadot-v0.9.9'
284 # version = '3.0.0'
285
286 # [dependencies.pallet-contracts-primitives]
287 # git = 'https://github.com/paritytech/substrate.git'
288 # default-features = false
289 # branch = 'polkadot-v0.9.9'
290 # version = '3.0.0'
291
292 # [dependencies.pallet-contracts-rpc-runtime-api]
293 # git = 'https://github.com/paritytech/substrate.git'
294 # default-features = false
295 # branch = 'polkadot-v0.9.9'
296 # version = '3.0.0'
297...
298 # pallet-contract-helpers = { path = '../pallets/contract-helpers', default-features = false, version = '0.1.0' }
299```
300
3014. runtime/src/lib.rs
302```
303// use pallet_contracts::weights::WeightInfo;
304...
305// pub use pallet_timestamp::Call as TimestampCall;
306...
307// mod chain_extension;
308// use crate::chain_extension::{NFTExtension, Imbalance};
309...
310/*
311parameter_types! {
312 pub TombstoneDeposit: Balance = deposit(
313 ...
314}
315*/
316...
317//pallet_contract_helpers::ContractSponsorshipHandler<Runtime>,
318...
319// impl pallet_contract_helpers::Config for Runtime {}
320...
321// Contracts: pallet_contracts::{Pallet, Call, Storage, Event<T>},
322...
323// ContractHelpers: pallet_contract_helpers::{Pallet, Call, Storage},
324...
325//pallet_contract_helpers::ContractHelpersExtension<Runtime>,
326...
327/*
328 impl pallet_contracts_rpc_runtime_api::ContractsApi<Block, AccountId, Balance, BlockNumber, Hash>
329 for Runtime
330 {
331 ...
332 }
333*/
334
335```
336
337
338## Karura token transfer153## Karura token transfer
339154
340To get started, you need to open inbound and outbound hrmp channels.155To get started, you need to open inbound and outbound hrmp channels.
341Next, we need to register our asset at Karura.
342156
157### Next, we need to register our asset at Karura.
343```158```
344assetRegistry -> registerForeignAsset(location, metadata)159assetRegistry -> registerForeignAsset(location, metadata)
345location:160location:
351minimalBalance 1166minimalBalance 1
352```167```
353168
354Next, we can send tokens from Opal to Karura:169### Next, we can send tokens from Opal to Karura:
355```170```
356polkadotXcm -> reserveTransferAssets171polkadotXcm -> reserveTransferAssets
357dest:172dest:
369The result will be displayed in ChainState 184The result will be displayed in ChainState
370tokens -> accounts 185tokens -> accounts
371186
372
373To send tokens from Karura to Opal:187### To send tokens from Karura to Opal:
374
375```188```
376xtokens -> transfer189xtokens -> transfer
389 )202 )
390destWeight:203destWeight:
391 <WEIGHT>204 <WEIGHT>
392
393
394```205```
addeddoc/hackusama_update.mddiffbeforeafterboth

no changes

addeddoc/re-enable_ink_contracts.mddiffbeforeafterboth

no changes

addedlaunch-config-full.jsondiffbeforeafterboth

no changes

deletedlaunch-config-westend.jsondiffbeforeafterboth

no changes

modifiedlaunch-config.jsondiffbeforeafterboth
95 ]95 ]
96 }96 }
97 ]97 ]
98 },98 }
99 {
100 "bin": "../Acala/target/release/acala",
101 "id": "2000",
102 "chain": "karura-dev",
103 "balance": "1000000000000000000000",
104 "nodes": [
105 {
106 "wsPort": 9946,
107 "port": 31202,
108 "name": "alice",
109 "flags": [
110 "--rpc-cors=all",
111 "--unsafe-rpc-external",
112 "--unsafe-ws-external",
113 "-lxcm=trace"
114 ]
115 }
116 ]
117 }
118 ],99 ],
119 "simpleParachains": [],100 "simpleParachains": [],
120 "hrmpChannels": [101 "hrmpChannels": [],
121 {
122 "sender": 2000,
123 "recipient": 1000,
124 "maxCapacity": 8,
125 "maxMessageSize": 512
126 },
127 {
128 "sender": 1000,
129 "recipient": 2000,
130 "maxCapacity": 8,
131 "maxMessageSize": 512
132 }
133 ],
134 "finalization": false102 "finalization": false
135}103}
deletedlaunch-test-env.shdiffbeforeafterboth

no changes

addedlaunch-testnet-full.shdiffbeforeafterboth

no changes

addedlaunch-testnet.shdiffbeforeafterboth

no changes

modifiednode/cli/Cargo.tomldiffbeforeafterboth
257license = 'All Rights Reserved'257license = 'All Rights Reserved'
258name = 'unique-node'258name = 'unique-node'
259repository = 'https://github.com/UniqueNetwork/unique-chain'259repository = 'https://github.com/UniqueNetwork/unique-chain'
260version = '0.9.14'260version = '0.9.16'
261261
262[[bin]]262[[bin]]
263name = 'unique-collator'263name = 'unique-collator'
modifiedruntime/src/lib.rsdiffbeforeafterboth
160 spec_name: create_runtime_str!("opal"),160 spec_name: create_runtime_str!("opal"),
161 impl_name: create_runtime_str!("opal"),161 impl_name: create_runtime_str!("opal"),
162 authoring_version: 1,162 authoring_version: 1,
163 spec_version: 914000,163 spec_version: 916001,
164 impl_version: 1,164 impl_version: 0,
165 apis: RUNTIME_API_VERSIONS,165 apis: RUNTIME_API_VERSIONS,
166 transaction_version: 0,166 transaction_version: 1,
167 state_version: 0,167 state_version: 0,
168};168};
169169