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

Test Runtime upgrade #1905

Closed
Tracked by #1902
mclyk opened this issue Nov 28, 2022 · 4 comments
Closed
Tracked by #1902

Test Runtime upgrade #1905

mclyk opened this issue Nov 28, 2022 · 4 comments
Assignees

Comments

@mclyk
Copy link
Contributor

mclyk commented Nov 28, 2022

related #1904

relaychain:
  image: parallelfinance/polkadot:v0.9.28
  chain: polkadot-local
  runtimeGenesisConfig:
    hrmp:
      preopenHrmpChannels:
        - sender: 2012
          recipient: 1000
          maxCapacity: 8
          maxMessageSize: 102400
        - sender: 1000
          recipient: 2012
          maxCapacity: 8
          maxMessageSize: 102400
  env:
    RUST_LOG: xcm=trace
  flags:
    - --rpc-methods=unsafe
    - --wasm-execution=compiled
    - --execution=wasm
    - --state-cache-size=0
  nodes:
    - name: alice
    - name: bob
    - name: charlie
    - name: dave
parachains:
  - image: parallelfinance/parallel:v1.9.3
    chain:
      base: parallel-dev
      collators:
        - alice
      sudo: dave
    id: 2012
    parachain: true
    flags:
      - --rpc-methods=unsafe
      - --unsafe-rpc-external
      - --force-authoring
      - --wasm-execution=compiled
      - --execution=wasm
      - --pruning=archive
      - --state-cache-size=0
    relaychainFlags:
      - --wasm-execution=compiled
      - --execution=wasm
      - --state-cache-size=0
    env:
      RUST_LOG: eth=trace,xcm=trace,loans=trace,liquidStaking=trace,crowdloans=trace,amm=trace,stableswap=trace,router=trace,bridge=trace,prices=trace
    nodes:
      - flags:
          - --alice
@mclyk mclyk self-assigned this Nov 28, 2022
@mclyk
Copy link
Contributor Author

mclyk commented Nov 28, 2022

Test runtime upgrade

1 build wasm

command refer link

./target/release/parallel export-genesis-wasm --chain=parallel-dev >> ./output/parallel_194.wasm

codehash: 0xa320d5179d1049a672fdc6f7ced3014a4cfe87d09d1cf67cdd7af27f87a0e5f5

2 submit preimage

image
preimage hash & proposalHash:
0xc939fa5c0452796ab7d398aec30bddd061dac4cba6e1dcbfc39c979d94e29ca3

3 proposal external

image

proposalHash: 0x000b7ea8c8d0cc85855055fd5cbd2be65d57a995bdfdcaf26d3de9ee1b29a560

3.1 Bob coucil vote

image

3.2 Alice coucil vote

image

3.3 close

image
image

4 Tech. fast track

must approved >= 2/3
image

proposalHash: 0x37732af909847fd3a42d25d966a1cde86c815e87ec81a2369add6ab03f8f4a2f

4.1 Eve vote true

image

4.2 Dave vote true

image

4.3 Fredie vote true

image

4.4 close

image
image

5 vote in referenda

waiting a moment, and then vote aye
image

image

image

scheduled

image

executed

image

6 parachainSystem.enactAuthorizedUpgrade

image
image

@mclyk
Copy link
Contributor Author

mclyk commented Nov 29, 2022

Test try runtime

heiko

Running `target/release/parallel try-runtime --chain heiko-dev --wasm-execution=compiled --no-spec-check-panic on-runtime-upgrade live '--uri=wss://heiko-rpc.parallel.fi:443'`
2022-11-29 14:49:23 assembling new collators for new session 0 at #0    
2022-11-29 14:49:23 assembling new collators for new session 1 at #0    
2022-11-29 14:49:25 Connection established to target: Target { sockaddrs: [], host: "heiko-rpc.parallel.fi", host_header: "heiko-rpc.parallel.fi:443", _mode: Tls, path_and_query: "/" }
2022-11-29 14:49:26 scraping key-pairs from remote @ 0x27d4f4d34466464f9db3dbcb70c4ab3a42f8f6c88ef930a1011f3af5767e09f4    
2022-11-29 14:49:26 downloading data for all pallets.    
2022-11-29 14:53:30 adding data for hashed key: 26aa394eea5630e07c48ae0c9558cef7f9cce9c888469bb1a0dceaa129672ef8    
2022-11-29 14:53:31 extending externalities with 1 manually injected key-values    
2022-11-29 14:53:31 👩‍👦 scraping child-tree data from 6 top keys    
2022-11-29 14:53:38 Custom("[backend]: frontend dropped; terminate client")
2022-11-29 14:53:38 injecting a total of 97289 top keys    
2022-11-29 14:53:40 injecting a total of 592 child keys    
2022-11-29 14:53:41 initialized state externalities with storage root 0xdbb1ab606eb3d3d2356da6f6be5cbd449ea43c4194c83332bbd4590c381ff663    
2022-11-29 14:53:46 Connection established to target: Target { sockaddrs: [], host: "heiko-rpc.parallel.fi", host_header: "heiko-rpc.parallel.fi:443", _mode: Tls, path_and_query: "/" }
2022-11-29 14:53:46 found matching spec name: "heiko"    
2022-11-29 14:53:46 spec version mismatch (local 194 != remote 193). This could cause some issues.    
2022-11-29 14:53:46 Custom("[backend]: frontend dropped; terminate client")
2022-11-29 14:53:46 try-runtime::on_runtime_upgrade.    
2022-11-29 14:53:46 Migrating 0 images    
2022-11-29 14:53:46 Trying to migrate 0 agendas...    
2022-11-29 14:53:46 Migrated 0 agendas.    
2022-11-29 14:53:46 0 public proposals will be migrated.    
2022-11-29 14:53:46 11 referenda will be migrated.    
2022-11-29 14:53:46 migrating referendum #7    
2022-11-29 14:53:46 migrating referendum #5    
2022-11-29 14:53:46 migrating referendum #8    
2022-11-29 14:53:46 migrating referendum #1    
2022-11-29 14:53:46 migrating referendum #9    
2022-11-29 14:53:46 migrating referendum #2    
2022-11-29 14:53:46 migrating referendum #10    
2022-11-29 14:53:46 migrating referendum #0    
2022-11-29 14:53:46 migrating referendum #6    
2022-11-29 14:53:46 migrating referendum #3    
2022-11-29 14:53:46 migrating referendum #4    
2022-11-29 14:53:46 0 public proposals migrated, 11 referenda migrated    
2022-11-29 14:53:46 [2448844] ✍️ Number of calls to refund and delete: 0    
2022-11-29 14:53:46 ✅ no migration for System    
2022-11-29 14:53:46 ✅ no migration for Timestamp    
2022-11-29 14:53:46 ✅ no migration for Utility    
2022-11-29 14:53:46 ✅ no migration for Multisig    
2022-11-29 14:53:46 ✅ no migration for Balances    
2022-11-29 14:53:46 ✅ no migration for TransactionPayment    
2022-11-29 14:53:46 ✅ no migration for Assets    
2022-11-29 14:53:46 ✅ no migration for Proxy    
2022-11-29 14:53:46 ✅ no migration for Identity    
2022-11-29 14:53:46 ✅ no migration for Democracy    
2022-11-29 14:53:46 ✅ no migration for GeneralCouncil    
2022-11-29 14:53:46 ✅ no migration for TechnicalCommittee    
2022-11-29 14:53:46 ✅ no migration for Treasury    
2022-11-29 14:53:46 ✅ no migration for Scheduler    
2022-11-29 14:53:46 ✅ no migration for Preimage    
2022-11-29 14:53:46 ✅ no migration for ParachainInfo    
2022-11-29 14:53:46 ⚠️ XcmpQueue declares internal migrations (which *might* execute). On-chain `StorageVersion(1)` vs current storage version `StorageVersion(2)`    
2022-11-29 14:53:46 ⚠️ DmpQueue declares internal migrations (which *might* execute). On-chain `StorageVersion(0)` vs current storage version `StorageVersion(1)`    
2022-11-29 14:53:46 ⚠️ PolkadotXcm declares internal migrations (which *might* execute). On-chain `StorageVersion(0)` vs current storage version `StorageVersion(0)`    
2022-11-29 14:53:46 ✅ no migration for CumulusXcm    
2022-11-29 14:53:46 ✅ no migration for Authorship    
2022-11-29 14:53:46 ✅ no migration for CollatorSelection    
2022-11-29 14:53:46 ✅ no migration for Session    
2022-11-29 14:53:46 ✅ no migration for Aura    
2022-11-29 14:53:46 ✅ no migration for AuraExt    
2022-11-29 14:53:46 ✅ no migration for Oracle    
2022-11-29 14:53:46 ✅ no migration for XTokens    
2022-11-29 14:53:46 ✅ no migration for OrmlXcm    
2022-11-29 14:53:46 ✅ no migration for Vesting    
2022-11-29 14:53:46 ✅ no migration for Loans    
2022-11-29 14:53:46 ✅ no migration for Prices    
2022-11-29 14:53:46 ✅ no migration for Crowdloans    
2022-11-29 14:53:46 ✅ no migration for LiquidStaking    
2022-11-29 14:53:46 ✅ no migration for GeneralCouncilMembership    
2022-11-29 14:53:46 ✅ no migration for TechnicalCommitteeMembership    
2022-11-29 14:53:46 ✅ no migration for OracleMembership    
2022-11-29 14:53:46 ✅ no migration for LiquidStakingAgentsMembership    
2022-11-29 14:53:46 ✅ no migration for BridgeMembership    
2022-11-29 14:53:46 ✅ no migration for CrowdloansAutomatorsMembership    
2022-11-29 14:53:46 ✅ no migration for AMM    
2022-11-29 14:53:46 ✅ no migration for AMMRoute    
2022-11-29 14:53:46 ✅ no migration for CurrencyAdapter    
2022-11-29 14:53:46 ✅ no migration for Bridge    
2022-11-29 14:53:46 ✅ no migration for EmergencyShutdown    
2022-11-29 14:53:46 ✅ no migration for Farming    
2022-11-29 14:53:46 ✅ no migration for XcmHelper    
2022-11-29 14:53:46 ✅ no migration for Streaming    
2022-11-29 14:53:46 ✅ no migration for AssetRegistry    
2022-11-29 14:53:46 ⚠️ ParachainSystem declares internal migrations (which *might* execute). On-chain `StorageVersion(1)` vs current storage version `StorageVersion(1)`    
2022-11-29 14:53:46 TryRuntime_on_runtime_upgrade executed without errors. Consumed weight = (502625000000 ps, 5242880 byte), total weight = (500000000000 ps, 5242880 byte) (100.52 %, 100.00 %). 

Parallel

Running `target/release/parallel try-runtime --chain parallel-dev --wasm-execution=compiled --no-spec-check-panic on-runtime-upgrade live '--uri=wss://rpc.parallel.fi:443'`
2022-11-29 14:55:34 assembling new collators for new session 0 at #0    
2022-11-29 14:55:34 assembling new collators for new session 1 at #0    
2022-11-29 14:55:36 Connection established to target: Target { sockaddrs: [], host: "rpc.parallel.fi", host_header: "rpc.parallel.fi:443", _mode: Tls, path_and_query: "/" }
2022-11-29 14:55:37 scraping key-pairs from remote @ 0xefc4aac2ade3e4b291e927dc934d9f602358bfb945a9588f94e9df89393b0dea    
2022-11-29 14:55:37 downloading data for all pallets.    
2022-11-29 15:16:37 adding data for hashed key: 26aa394eea5630e07c48ae0c9558cef7f9cce9c888469bb1a0dceaa129672ef8    
2022-11-29 15:16:37 extending externalities with 1 manually injected key-values    
2022-11-29 15:16:37 👩‍👦 scraping child-tree data from 8 top keys    
2022-11-29 15:16:43 Custom("[backend]: frontend dropped; terminate client")
2022-11-29 15:16:43 injecting a total of 375236 top keys    
2022-11-29 15:16:54 injecting a total of 259 child keys    
2022-11-29 15:16:55 initialized state externalities with storage root 0x57331c3f9276794d4ac3d52b7d947e595bb6f449eea6524f1ed166b1b3186b08    
2022-11-29 15:17:06 Connection established to target: Target { sockaddrs: [], host: "rpc.parallel.fi", host_header: "rpc.parallel.fi:443", _mode: Tls, path_and_query: "/" }
2022-11-29 15:17:14 found matching spec name: "parallel"    
2022-11-29 15:17:14 spec version mismatch (local 194 != remote 193). This could cause some issues.    
2022-11-29 15:17:14 Custom("[backend]: frontend dropped; terminate client")
2022-11-29 15:17:15 try-runtime::on_runtime_upgrade.    
2022-11-29 15:17:15 Migrating 0 images    
2022-11-29 15:17:15 Trying to migrate 0 agendas...    
2022-11-29 15:17:15 Migrated 0 agendas.    
2022-11-29 15:17:15 0 public proposals will be migrated.    
2022-11-29 15:17:15 9 referenda will be migrated.    
2022-11-29 15:17:15 migrating referendum #7    
2022-11-29 15:17:15 migrating referendum #5    
2022-11-29 15:17:15 migrating referendum #8    
2022-11-29 15:17:15 migrating referendum #1    
2022-11-29 15:17:15 migrating referendum #2    
2022-11-29 15:17:15 migrating referendum #0    
2022-11-29 15:17:15 migrating referendum #6    
2022-11-29 15:17:15 migrating referendum #3    
2022-11-29 15:17:15 migrating referendum #4    
2022-11-29 15:17:15 0 public proposals migrated, 9 referenda migrated    
2022-11-29 15:17:15 [2345583] ✍️ Number of calls to refund and delete: 0    
2022-11-29 15:17:15 ✅ no migration for System    
2022-11-29 15:17:15 ✅ no migration for Timestamp    
2022-11-29 15:17:15 ✅ no migration for Utility    
2022-11-29 15:17:15 ✅ no migration for Multisig    
2022-11-29 15:17:15 ✅ no migration for Balances    
2022-11-29 15:17:15 ✅ no migration for TransactionPayment    
2022-11-29 15:17:15 ✅ no migration for Assets    
2022-11-29 15:17:15 ✅ no migration for Proxy    
2022-11-29 15:17:15 ✅ no migration for Identity    
2022-11-29 15:17:15 ✅ no migration for Democracy    
2022-11-29 15:17:15 ✅ no migration for GeneralCouncil    
2022-11-29 15:17:15 ✅ no migration for TechnicalCommittee    
2022-11-29 15:17:15 ✅ no migration for Treasury    
2022-11-29 15:17:15 ✅ no migration for Scheduler    
2022-11-29 15:17:15 ✅ no migration for Preimage    
2022-11-29 15:17:15 ✅ no migration for ParachainInfo    
2022-11-29 15:17:15 ⚠️ XcmpQueue declares internal migrations (which *might* execute). On-chain `StorageVersion(1)` vs current storage version `StorageVersion(2)`    
2022-11-29 15:17:15 ⚠️ DmpQueue declares internal migrations (which *might* execute). On-chain `StorageVersion(0)` vs current storage version `StorageVersion(1)`    
2022-11-29 15:17:15 ⚠️ PolkadotXcm declares internal migrations (which *might* execute). On-chain `StorageVersion(0)` vs current storage version `StorageVersion(0)`    
2022-11-29 15:17:15 ✅ no migration for CumulusXcm    
2022-11-29 15:17:15 ✅ no migration for Authorship    
2022-11-29 15:17:15 ✅ no migration for CollatorSelection    
2022-11-29 15:17:15 ✅ no migration for Session    
2022-11-29 15:17:15 ✅ no migration for Aura    
2022-11-29 15:17:15 ✅ no migration for AuraExt    
2022-11-29 15:17:15 ✅ no migration for Oracle    
2022-11-29 15:17:15 ✅ no migration for XTokens    
2022-11-29 15:17:15 ✅ no migration for OrmlXcm    
2022-11-29 15:17:15 ✅ no migration for Vesting    
2022-11-29 15:17:15 ✅ no migration for Loans    
2022-11-29 15:17:15 ✅ no migration for Prices    
2022-11-29 15:17:15 ✅ no migration for Crowdloans    
2022-11-29 15:17:15 ✅ no migration for LiquidStaking    
2022-11-29 15:17:15 ✅ no migration for GeneralCouncilMembership    
2022-11-29 15:17:15 ✅ no migration for TechnicalCommitteeMembership    
2022-11-29 15:17:15 ✅ no migration for OracleMembership    
2022-11-29 15:17:15 ✅ no migration for LiquidStakingAgentsMembership    
2022-11-29 15:17:15 ✅ no migration for BridgeMembership    
2022-11-29 15:17:15 ✅ no migration for CrowdloansAutomatorsMembership    
2022-11-29 15:17:15 ✅ no migration for AMM    
2022-11-29 15:17:15 ✅ no migration for AMMRoute    
2022-11-29 15:17:15 ✅ no migration for CurrencyAdapter    
2022-11-29 15:17:15 ✅ no migration for Bridge    
2022-11-29 15:17:15 ✅ no migration for EmergencyShutdown    
2022-11-29 15:17:15 ✅ no migration for Farming    
2022-11-29 15:17:15 ✅ no migration for XcmHelper    
2022-11-29 15:17:15 ✅ no migration for Streaming    
2022-11-29 15:17:15 ✅ no migration for AssetRegistry    
2022-11-29 15:17:15 ⚠️ ParachainSystem declares internal migrations (which *might* execute). On-chain `StorageVersion(1)` vs current storage version `StorageVersion(1)`    
2022-11-29 15:17:15 TryRuntime_on_runtime_upgrade executed without errors. Consumed weight = (502375000000 ps, 5242880 byte), total weight = (500000000000 ps, 5242880 byte) (100.48 %, 100.00 %). 

@mclyk
Copy link
Contributor Author

mclyk commented Dec 5, 2022

1 research about this

[Parachain] panicked at 'Timestamp slot must match `CurrentSlot`'

1.1 calculate slot

https://github.com/parallel-finance/parallel/blob/4c87f31f91/node/parallel/src/service.rs#L352

let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client)?;

https://github.com/parallel-finance/parallel/blob/4c87f31f91/node/parallel/src/service.rs#L372-L376

let slot = sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration(
	*timestamp,
	slot_duration,
);

image

1.2 pass in on_slot

image

2.1 on_slot

https://github.com/paritytech/substrate/blob/5ea6d95309/client/consensus/slots/src/lib.rs#L246-L250

2.2 client/consensus/slots/propose

https://github.com/paritytech/substrate/blob/5ea6d95309/client/consensus/slots/src/lib.rs#L181-L200

2.3 /client/consensus/aura/pre_digest_data

https://github.com/paritytech/substrate/blob/5ea6d95309/client/consensus/aura/src/lib.rs#L374-L376

2.4 /primitives/consensus/aura/src/digests/aura_pre_digest

store in frame_system
https://github.com/paritytech/substrate/blob/5ea6d95309/primitives/consensus/aura/src/digests.rs#L56-L58

3.1 frame/aura/current_slot_from_digests

get from frame_system
https://github.com/paritytech/substrate/blob/5ea6d95309/frame/aura/src/lib.rs#L178-L189

3.2 primitives/runtime/src/generic/digest/as_pre_runtime

https://github.com/paritytech/substrate/blob/5ea6d95309/primitives/runtime/src/generic/digest.rs#L321-L327

4.1

https://github.com/paritytech/substrate/blob/5ea6d95309/frame/aura/src/lib.rs#L291-L304

fn on_timestamp_set(moment: T::Moment) {
		let slot_duration = Self::slot_duration();
		assert!(!slot_duration.is_zero(), "Aura slot duration cannot be zero.");

		let timestamp_slot = moment / slot_duration;
		let timestamp_slot = Slot::from(timestamp_slot.saturated_into::<u64>());

		assert!(
			CurrentSlot::<T>::get() == timestamp_slot,
			"Timestamp slot must match `CurrentSlot`"
		);
	}

4.2

https://github.com/paritytech/substrate/blob/5ea6d95309/frame/aura/src/lib.rs#L191-L196

pub fn slot_duration() -> T::Moment {
		// we double the minimum block-period so each author can always propose within
		// the majority of its slot.
		<T as pallet_timestamp::Config>::MinimumPeriod::get().saturating_mul(2u32.into())
	}

5.1

https://kusama.polkassembly.io/referenda/8

5.2

https://github.com/interlay/interbtc/blob/1.20.0/parachain/src/service.rs#L474-L478

let slot_ms = if parachain_config.chain_spec.id() == "kusama" {
        6000
    } else {
        12000
    };

5.3

image

@mclyk mclyk closed this as completed Dec 5, 2022
@mclyk
Copy link
Contributor Author

mclyk commented Dec 7, 2022

docker run -it parallelfinance/parallel:latest_evm export-genesis-wasm --chain=vanilla-dev >> ./vanilla_194.wasm

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

No branches or pull requests

1 participant