Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: MMD-1309 / Update from Substrate 3 to commit dated 10th Feb 2022 (common branch 'polkadot-v0.9.17' for use with substrate-parachain-template) #215

Open
wants to merge 116 commits into
base: master
Choose a base branch
from

Conversation

ltfschoen
Copy link
Collaborator

@ltfschoen ltfschoen commented Aug 1, 2021

A client is trying update new blocks on their local server of DataHighway mainnet at http://xxx:8585/blocks/head https://datahighway-dhx.github.io/substrate-api-sidecar/, but they are reporting the dhx.api HTTP status code is not 200-299 so they are experiencing delay and timeout like in this similar issue polkadot-js/api#3365 every few mins, so as a result users are not able to topup or withdraw in time. The said their node has both http and ws connections. This PR is an attempt to update to the latest version of Substrate (since it was last updated to an old Substrate 3 commit dated 10th Feb 2021) incase that helps resolve the issue. Then we'll do a forkless runtime upgrade on Harbour testnet and then DataHighway Westlake mainnet

Note: To debug this branch run the following:

git fetch origin luke/MMD-1309/update-substrate-3:luke/MMD-1309/update-substrate-3
git checkout luke/MMD-1309/update-substrate-3
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
./scripts/init.sh
cargo build --release
rm -rf /tmp/polkadot-chains
./target/release/datahighway \                                                            
  --base-path /tmp/polkadot-chains/alice \
  --name "Data Highway Development Chain" \
  --dev \
  --telemetry-url "wss://telemetry.polkadot.io/submit/ 0" \
  -lruntime=debug

Checklist

error: no matching package found
searched package name: `frame-benchmarking`
prerelease package needs to be specified explicitly
frame-benchmarking = { version = "4.0.0-dev" }
location searched: https://github.com/paritytech/substrate?rev=efd54879ecbf8aac41fe809d31c7215ea3101241#efd54879
required by package `datahighway v3.0.5 (/Users/me/code/DataHighway-DHX/node/node)`

and if i replace the rev value with any more recent Substrate commit and try building it gives the same error.
if i specify the dependencies the way it wants me to like <DEPENDENCY_NAME> = { version = '4.0.0-dev' } as shown here paritytech/substrate@efd5487#diff-8b507853b325d5137f0252305eeef561aaddec506b75027217df634a243d8875R23, then i can't target specific commits between Substrate commit efd54879ecbf8aac41fe809d31c7215ea3101241 (dated 11th July 2021) and the latest Substrate commit 3478e0f6b80bd43803d7b821d887527d86104a41 (dated 29th July 2021).
how can i specify the Git commit number that i want it to build so I can target these most recent Substrate commits since 9th July 2021?

i tried updating all the dependencies to pre-release versions 4.0.0-dev, 5.0.0-dev, and 0.10.0-dev in this commit 23c6941, but when i run cargo build --release i get error:

    Updating crates.io index
error: failed to select a version for the requirement `frame-benchmarking = "^4.0.0-dev"`
candidate versions found which didn't match: 3.1.0, 3.0.0, 2.0.1, ...
location searched: crates.io index
required by package `datahighway v3.0.5 (/Users/ls2/code/DataHighway-DHX/node/node)`

how do i locally test the prerelease versions (i.e. 4.0.0-dev, 5.0.0-dev, and 0.10.0-dev) of the dependencies?
is it possible to publish this pre-release at crates.io?
otherwise it doesn't seem possible to update to to a more recent version of Substrate than its commit deac6324a16fc4128b94a7b4c3826eebcb86917f (dated 9th July 2021)
See latest commit with the changes in branch 'luke/MMD-1309/update-substrate-3-4.0.0-dev'
Note: This is resolved, I think it just needed a cargo clean. If encounter similar problem consider https://doc.rust-lang.org/cargo/reference/overriding-dependencies.html?highlight=patch.#the-patch-section

./target/release/datahighway build-spec \
  --chain=<CHAIN> > ./res/chain_spec_<CHAIN>.json &&
./target/release/datahighway build-spec \
  --chain ./res/chain_spec_<CHAIN>.json \
  --raw > ./res/chain_def_<CHAIN>.json

./target/release/datahighway build-spec \
  --chain=brickable > ./res/chain_spec_brickable.json &&
./target/release/datahighway build-spec \
  --chain ./res/chain_spec_brickable.json \
  --raw > ./res/chain_def_brickable.json

./target/release/datahighway build-spec \
  --chain=harbour > ./res/chain_spec_harbour.json &&
./target/release/datahighway build-spec \
  --chain ./res/chain_spec_harbour.json \
  --raw > ./res/chain_def_harbour.json

./target/release/datahighway build-spec \
  --chain=westlake > ./res/chain_spec_westlake.json &&
./target/release/datahighway build-spec \
  --chain ./res/chain_spec_westlake.json \
  --raw > ./res/chain_def_westlake.json

the steps i taken were:

  • created a new branch called 'lukemmd1309' from branch 'luke/MMD-1309/update-substrate-3' so Docker would recognise the branch name
  • in docker-compose-dev.yml, i replaced all image: dhxdocker/datahighway:latest with image: dhxdocker/datahighway:lukemmd1309
  • created .env file cp .env.sample .env
  • in .env file i changed BOOTNODE_ENDPOINT_TESTNET=3.67.117.245 to BOOTNODE_ENDPOINT_TESTNET=127.0.0.1
  • remove old version of docker on server and install new
sudo apt-get remove docker-compose

sudo curl -L "https://github.com/docker/compose/releases/download/1.29.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

sudo chmod +x /usr/local/bin/docker-compose
the server had docker-compose version 1.24.1, but i needed 1.29.0
  • i setup rust by running ./scripts/init.sh,
rustup update stable
rustup update nightly
rustup toolchain install nightly-2021-12-01
rustup target add wasm32-unknown-unknown --toolchain nightly-2021-12-01
rustup default nightly-2021-12-01
rustup override set nightly-2021-12-01
  • i tried to build the local Docker image by running
sudo chmod -R 777 /home/luke/node/
docker-compose --env-file=./.env --file docker-compose-dev.yml --verbose build --build-arg CHAIN_VERSION="brickable"
docker login
docker tag dhxdocker/datahighway:lukemmd1309 lukemmd1309
docker push dhxdocker/datahighway:lukemmd1309
  • run the development nodes and view logs
docker-compose -f docker-compose-dev.yml up --detach
docker-compose -f docker-compose-dev.yml logs --follow
scp -J luke@<IP_ADDR_1> luke@<IP_ADDR_2>:/home/luke/node/target/release/wbuild/datahighway-runtime/datahighway_runtime.compact.wasm .
  • generate chain spec and definition.
sudo ./target/release/datahighway build-spec \
  --chain=brickable > /home/luke/node/res/chain_spec_brickable.json &&
sudo ./target/release/datahighway build-spec \
  --chain /home/luke/node/res/chain_spec_brickable.json \
  --raw > /home/luke/node/res/chain_def_brickable.json
  • copy chain spec and definition from server to local machine to share with client to connect to Brickable with a node
scp -J luke@<IP_ADDR_1> luke@<IP_ADDR_2>:/home/luke/node/res/chain_spec_brickable.json .
scp -J luke@<IP_ADDR_1> luke@<IP_ADDR_2>:/home/luke/node/res/chain_def_brickable.json .
  • note: if we do all the above in future with docker-compose-custom.yml instead we can run a Local network without dev accounts like Alice, Bob, then we'd run cURL commands to inject Grandpa and Aura keys, and finally restart each container so it finalizes blocks with docker restart <DOCKER_CONTAINER_ID>

STATUS: Requested client to check if they experience the timeout issues with the updates we've made in this PR and deployed to Brickable

IMPORTANT NOTE: Feedback from Substrate Builders was that the timeout that we're experiencing with Babe might get smaller as more and more validators are added. So in future when we have more validators or we simulate that this is true then we might choose to switch back to using Babe instead of Aura.

  • - Release new version of github.com/DataHighway-DHX/node, after client checked if they still encounter the same delays/timeouts with API requests to /block/head

ltfschoen added 30 commits July 30, 2021 08:27
replaced 10th Feb release commit '49a4103f4bfef55be20a5c6d26e18ff3003c3353' of v3.0.0 and v0.9.0 dependencies with specific commit at later date

replace

	version = '3.0.0'
	git = 'https://github.com/paritytech/substrate', rev = '3957f43912e43fd28b624bb0736141ac24b51615'

replace
	version = '0.9.0'
	git = 'https://github.com/paritytech/substrate', rev = '3957f43912e43fd28b624bb0736141ac24b51615'

replace
	= '3.0.0'
	= { git = 'https://github.com/paritytech/substrate', rev = '3957f43912e43fd28b624bb0736141ac24b51615' }

replace
	= '3.1.0'
	= { git = 'https://github.com/paritytech/substrate', rev = '3957f43912e43fd28b624bb0736141ac24b51615' }

replace
	= '0.9.0'
	= { git = 'https://github.com/paritytech/substrate', rev = '3957f43912e43fd28b624bb0736141ac24b51615' }

additionally had to add telemetry_span code to node/src/service.rs since it is required after one of the commits
update to 22nd Feb commit 904495b and fixed error `the trait SpawnEssentialNamed is not implemented for SpawnTaskHandle` in node/src/service.rs
…7-30 from nightly-2021-03-10 to fix .clamp unstable error

fix error missing `block_proposal_slot_portion`

using nightly-2021-07-30 after updating using:

rustup install nightly-2021-07-30-x86_64-apple-darwin
rustup default nightly-2021-07-30
rustup override set nightly-2021-07-30
rustup target add wasm32-unknown-unknown --toolchain nightly-2021-07-30
rustup toolchain list
@ltfschoen ltfschoen changed the title feat: MMD-1309 / Update from Substrate 3 to commit 027368fe34e9a57ead752d4f900db6b5f85352e6 dated 15th Dec 2021 feat: MMD-1309 / Update from Substrate 3 to commit e2d1f1823796cb767b40d9003ac2ee145e0837a4 dated 17th Jan 2022 Mar 9, 2022
@ltfschoen ltfschoen changed the title feat: MMD-1309 / Update from Substrate 3 to commit e2d1f1823796cb767b40d9003ac2ee145e0837a4 dated 17th Jan 2022 feat: MMD-1309 / Update from Substrate 3 to commit dfe52f7de12a7e308c0bc3a25e211b9cc4d61871 dated 25th Feb 2022 (same date as 'polkadot-v0.9.17' in the substrate-parachain-template) Mar 10, 2022
node/Cargo.toml Outdated
@@ -12,68 +12,70 @@ name = 'datahighway'
targets = ['x86_64-unknown-linux-gnu']

[build-dependencies]
substrate-build-script-utils = '3.0.0'
substrate-build-script-utils = { git = 'https://github.com/paritytech/substrate', rev = 'dfe52f7de12a7e308c0bc3a25e211b9cc4d61871' }
Copy link
Contributor

@ayushmishra2005 ayushmishra2005 Mar 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we using this specific version? Can we use polkadotv0.9.17 or monthly-2022-03

use std::fs::File;
use std::io::Read;
use std::str::FromStr;
// use hex::{FromHex, FromHexError};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove commented code

impl pallet_utility::Config for Runtime {
type Event = Event;
type Call = Call;
type PalletsOrigin = OriginCaller;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation

type GenesisElectionProvider = onchain::OnChainSequentialPhragmen<Self>;
// Alternatively, use pallet_staking::UseNominatorsMap<Runtime> to just use the nominators map.
// Note that the aforementioned does not scale to a very large number of nominators.
type SortedListProvider = BagsList;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation

impl pallet_election_provider_multi_phase::Config for Runtime {
type Event = Event;
type Currency = Balances;
type EstimateCallFee = TransactionPayment;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation

type SolutionImprovementThreshold = SolutionImprovementThreshold;
type OffchainRepeat = OffchainRepeat;
type MinerMaxWeight = MinerMaxWeight;
type MinerMaxLength = MinerMaxLength;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation

type DataProvider = Staking;
type Solution = NposSolution16;
type Fallback = pallet_election_provider_multi_phase::NoFallback<Self>;
type GovernanceFallback =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation

>;
type WeightInfo = pallet_election_provider_multi_phase::weights::SubstrateWeight<Self>;
type ForceOrigin = EnsureRootOrHalfCouncil;
type BenchmarkingConfig = ElectionProviderBenchmarkConfig;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation

type WeightInfo = pallet_election_provider_multi_phase::weights::SubstrateWeight<Self>;
type ForceOrigin = EnsureRootOrHalfCouncil;
type BenchmarkingConfig = ElectionProviderBenchmarkConfig;
type VoterSnapshotPerBlock = ConstU32<VoterSnapshotPerBlockAsConst>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation

@ltfschoen ltfschoen changed the title feat: MMD-1309 / Update from Substrate 3 to commit dfe52f7de12a7e308c0bc3a25e211b9cc4d61871 dated 25th Feb 2022 (same date as 'polkadot-v0.9.17' in the substrate-parachain-template) feat: MMD-1309 / Update from Substrate 3 to commit dated 10th Feb 2022 (common branch 'polkadot-v0.9.17' for use with substrate-parachain-template) Mar 11, 2022
…DHX so works with polkadot-launch export-genesis-state
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants