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

fix: runtime upgrades in unstable backend #1348

Merged
merged 2 commits into from
Jan 16, 2024

Conversation

niklasad1
Copy link
Member

@niklasad1 niklasad1 commented Jan 9, 2024

Close #1345

This commit changes the following:

  1. FollowEvent::Finalized: just remove the finalized and pruned blocks from runtimes
  2. FollowEvent::Initalized: just remove the finalized block from runtimes

Logs from manual testing in staking-miner.

2024-01-09T09:35:57.366496Z DEBUG polkadot-staking-miner: attempting to connect to "ws://localhost:9944"
2024-01-09T09:35:57.368298Z  INFO subxt::backend::unstable: Initialized: Initialized { finalized_block_hash: BlockRef { inner: BlockRefInner { hash: 0x1650329717f6e499f43f373b366ee4d57cacc969768d5dcc00d81ee1cbd28377, unpin_flags: Mutex { data: {}, poisoned: false, .. } } }, finalized_block_runtime: Some(Valid(RuntimeVersionEvent { spec: RuntimeSpec { spec_name: "westend", impl_name: "parity-westend", spec_version: 1005000, impl_version: 0, transaction_version: 24, apis: {"0x2a5e924655399e60": 1, "0xab3c0572291feb8b": 1, "0xd2bc9897eed08f15": 3, "0xfbc577b9d747efd6": 1, "0xdf6acb689907609b": 4, "0x37c8bb1350a9a2a8": 4, "0x91d5df18b0d2cf58": 2, "0x40fe3ad401f8959a": 6, "0x18ef58a3b67ba770": 1, "0xaf2c0297a23e6d3d": 10, "0xf78b278be53f454c": 2, "0x37e397fc7c91f5e4": 2, "0xf3ff14d5ab527059": 3, "0xbc9d89904f5b923f": 1, "0x49eaaf1b548a0cb0": 3, "0x17a6bc0d0062aeb3": 1, "0xcbca25e39f142387": 2, "0x687ad44ad37f03c2": 1, "0xed99c5acb25eedf5": 3} } })) }
2024-01-09T09:35:57.408200Z  INFO polkadot-staking-miner: Started prometheus endpoint on http://0.0.0.0:9999
2024-01-09T09:35:57.408238Z  INFO polkadot-staking-miner: Connected to chain: westend
2024-01-09T09:35:57.408297Z TRACE polkadot-staking-miner: updating metadata constant `ElectionProviderMultiPhase::SignedMaxWeight`: Weight(ref_time: 1479424380000, proof_size: 13650590614545068195)
2024-01-09T09:35:57.408305Z TRACE polkadot-staking-miner: updating metadata constant `ElectionProviderMultiPhase::MinerMaxLength`: 3538944
2024-01-09T09:35:57.408310Z TRACE polkadot-staking-miner: updating metadata constant `ElectionProviderMultiPhase::MinerMaxVotesPerVoter`: 16
2024-01-09T09:35:57.408315Z TRACE polkadot-staking-miner: updating metadata constant `ElectionProviderMultiPhase::MaxWinners`: 1000
2024-01-09T09:35:57.408362Z  INFO subxt::backend::unstable: Initialized: Initialized { finalized_block_hash: BlockRef { inner: BlockRefInner { hash: 0x1650329717f6e499f43f373b366ee4d57cacc969768d5dcc00d81ee1cbd28377, unpin_flags: Mutex { data: {}, poisoned: false, .. } } }, finalized_block_runtime: Some(Valid(RuntimeVersionEvent { spec: RuntimeSpec { spec_name: "westend", impl_name: "parity-westend", spec_version: 1005000, impl_version: 0, transaction_version: 24, apis: {"0x2a5e924655399e60": 1, "0xab3c0572291feb8b": 1, "0xd2bc9897eed08f15": 3, "0xfbc577b9d747efd6": 1, "0xdf6acb689907609b": 4, "0x37c8bb1350a9a2a8": 4, "0x91d5df18b0d2cf58": 2, "0x40fe3ad401f8959a": 6, "0x18ef58a3b67ba770": 1, "0xaf2c0297a23e6d3d": 10, "0xf78b278be53f454c": 2, "0x37e397fc7c91f5e4": 2, "0xf3ff14d5ab527059": 3, "0xbc9d89904f5b923f": 1, "0x49eaaf1b548a0cb0": 3, "0x17a6bc0d0062aeb3": 1, "0xcbca25e39f142387": 2, "0x687ad44ad37f03c2": 1, "0xed99c5acb25eedf5": 3} } })) }
2024-01-09T09:35:57.450875Z DEBUG polkadot-staking-miner: upgrade to version: 1005000 failed: SameVersion

# New block with runtime upgrade
2024-01-09T09:37:18.772467Z  INFO subxt::backend::unstable: NewBlock: Valid(RuntimeVersionEvent { spec: RuntimeSpec { spec_name: "westend", impl_name: "parity-westend", spec_version: 1009000, impl_version: 0, transaction_version: 24, apis: {"0x17a6bc0d0062aeb3": 1, "0xf3ff14d5ab527059": 3, "0x40fe3ad401f8959a": 6, "0x91d5df18b0d2cf58": 2, "0xd2bc9897eed08f15": 3, "0xdf6acb689907609b": 4, "0xfbc577b9d747efd6": 1, "0xbc9d89904f5b923f": 1, "0xaf2c0297a23e6d3d": 10, "0xf78b278be53f454c": 2, "0x18ef58a3b67ba770": 1, "0x49eaaf1b548a0cb0": 3, "0x2a5e924655399e60": 1, "0x687ad44ad37f03c2": 1, "0x37e397fc7c91f5e4": 2, "0xed99c5acb25eedf5": 3, "0xab3c0572291feb8b": 1, "0xcbca25e39f142387": 2, "0x37c8bb1350a9a2a8": 4} } })

# wait for the block to be finalized i.e without "clearing all runtimes as before" 
2024-01-09T09:37:22.328892Z  INFO subxt::backend::unstable: runtimes before applying latest blocks : {0x97752b173a423cc15d267bdfc47f20ac013903591cad1959414af30d061d8091: Valid(RuntimeVersionEvent { spec: RuntimeSpec { spec_name: "westend", impl_name: "parity-westend", spec_version: 1009000, impl_version: 0, transaction_version: 24, apis: {"0x17a6bc0d0062aeb3": 1, "0xf3ff14d5ab527059": 3, "0x40fe3ad401f8959a": 6, "0x91d5df18b0d2cf58": 2, "0xd2bc9897eed08f15": 3, "0xdf6acb689907609b": 4, "0xfbc577b9d747efd6": 1, "0xbc9d89904f5b923f": 1, "0xaf2c0297a23e6d3d": 10, "0xf78b278be53f454c": 2, "0x18ef58a3b67ba770": 1, "0x49eaaf1b548a0cb0": 3, "0x2a5e924655399e60": 1, "0x687ad44ad37f03c2": 1, "0x37e397fc7c91f5e4": 2, "0xed99c5acb25eedf5": 3, "0xab3c0572291feb8b": 1, "0xcbca25e39f142387": 2, "0x37c8bb1350a9a2a8": 4} } })}
2024-01-09T09:37:22.328955Z  INFO subxt::backend::unstable: runtimes after applying latest blocks : {0x97752b173a423cc15d267bdfc47f20ac013903591cad1959414af30d061d8091: Valid(RuntimeVersionEvent { spec: RuntimeSpec { spec_name: "westend", impl_name: "parity-westend", spec_version: 1009000, impl_version: 0, transaction_version: 24, apis: {"0x17a6bc0d0062aeb3": 1, "0xf3ff14d5ab527059": 3, "0x40fe3ad401f8959a": 6, "0x91d5df18b0d2cf58": 2, "0xd2bc9897eed08f15": 3, "0xdf6acb689907609b": 4, "0xfbc577b9d747efd6": 1, "0xbc9d89904f5b923f": 1, "0xaf2c0297a23e6d3d": 10, "0xf78b278be53f454c": 2, "0x18ef58a3b67ba770": 1, "0x49eaaf1b548a0cb0": 3, "0x2a5e924655399e60": 1, "0x687ad44ad37f03c2": 1, "0x37e397fc7c91f5e4": 2, "0xed99c5acb25eedf5": 3, "0xab3c0572291feb8b": 1, "0xcbca25e39f142387": 2, "0x37c8bb1350a9a2a8": 4} } })}
2024-01-09T09:37:26.330472Z  INFO subxt::backend::unstable: runtimes before applying latest blocks : {0x97752b173a423cc15d267bdfc47f20ac013903591cad1959414af30d061d8091: Valid(RuntimeVersionEvent { spec: RuntimeSpec { spec_name: "westend", impl_name: "parity-westend", spec_version: 1009000, impl_version: 0, transaction_version: 24, apis: {"0x17a6bc0d0062aeb3": 1, "0xf3ff14d5ab527059": 3, "0x40fe3ad401f8959a": 6, "0x91d5df18b0d2cf58": 2, "0xd2bc9897eed08f15": 3, "0xdf6acb689907609b": 4, "0xfbc577b9d747efd6": 1, "0xbc9d89904f5b923f": 1, "0xaf2c0297a23e6d3d": 10, "0xf78b278be53f454c": 2, "0x18ef58a3b67ba770": 1, "0x49eaaf1b548a0cb0": 3, "0x2a5e924655399e60": 1, "0x687ad44ad37f03c2": 1, "0x37e397fc7c91f5e4": 2, "0xed99c5acb25eedf5": 3, "0xab3c0572291feb8b": 1, "0xcbca25e39f142387": 2, "0x37c8bb1350a9a2a8": 4} } })}
2024-01-09T09:37:26.330543Z  INFO subxt::backend::unstable: runtimes after applying latest blocks : {0x97752b173a423cc15d267bdfc47f20ac013903591cad1959414af30d061d8091: Valid(RuntimeVersionEvent { spec: RuntimeSpec { spec_name: "westend", impl_name: "parity-westend", spec_version: 1009000, impl_version: 0, transaction_version: 24, apis: {"0x17a6bc0d0062aeb3": 1, "0xf3ff14d5ab527059": 3, "0x40fe3ad401f8959a": 6, "0x91d5df18b0d2cf58": 2, "0xd2bc9897eed08f15": 3, "0xdf6acb689907609b": 4, "0xfbc577b9d747efd6": 1, "0xbc9d89904f5b923f": 1, "0xaf2c0297a23e6d3d": 10, "0xf78b278be53f454c": 2, "0x18ef58a3b67ba770": 1, "0x49eaaf1b548a0cb0": 3, "0x2a5e924655399e60": 1, "0x687ad44ad37f03c2": 1, "0x37e397fc7c91f5e4": 2, "0xed99c5acb25eedf5": 3, "0xab3c0572291feb8b": 1, "0xcbca25e39f142387": 2, "0x37c8bb1350a9a2a8": 4} } })}
2024-01-09T09:37:34.341850Z  INFO subxt::backend::unstable: runtimes before applying latest blocks : {0x97752b173a423cc15d267bdfc47f20ac013903591cad1959414af30d061d8091: Valid(RuntimeVersionEvent { spec: RuntimeSpec { spec_name: "westend", impl_name: "parity-westend", spec_version: 1009000, impl_version: 0, transaction_version: 24, apis: {"0x17a6bc0d0062aeb3": 1, "0xf3ff14d5ab527059": 3, "0x40fe3ad401f8959a": 6, "0x91d5df18b0d2cf58": 2, "0xd2bc9897eed08f15": 3, "0xdf6acb689907609b": 4, "0xfbc577b9d747efd6": 1, "0xbc9d89904f5b923f": 1, "0xaf2c0297a23e6d3d": 10, "0xf78b278be53f454c": 2, "0x18ef58a3b67ba770": 1, "0x49eaaf1b548a0cb0": 3, "0x2a5e924655399e60": 1, "0x687ad44ad37f03c2": 1, "0x37e397fc7c91f5e4": 2, "0xed99c5acb25eedf5": 3, "0xab3c0572291feb8b": 1, "0xcbca25e39f142387": 2, "0x37c8bb1350a9a2a8": 4} } })}

# The block was finalized and removed from "runtimes"
2024-01-09T09:37:34.341924Z  INFO subxt::backend::unstable: runtimes after applying latest blocks : {}
2024-01-09T09:37:34.341947Z  INFO subxt::backend::unstable: runtime upgrade found in finalized block

# staking-miner runtime upgrade was applied
2024-01-09T09:37:38.400252Z TRACE polkadot-staking-miner: updating metadata constant 
`ElectionProviderMultiPhase::SignedMaxWeight`: Weight(ref_time: 1479424380000, proof_size: 13650590614545068195)
2024-01-09T09:37:38.400277Z TRACE polkadot-staking-miner: updating metadata constant `ElectionProviderMultiPhase::MinerMaxLength`: 3538944
2024-01-09T09:37:38.400282Z TRACE polkadot-staking-miner: updating metadata constant `ElectionProviderMultiPhase::MinerMaxVotesPerVoter`: 16
2024-01-09T09:37:38.400287Z TRACE polkadot-staking-miner: updating metadata constant `ElectionProviderMultiPhase::MaxWinners`: 13
2024-01-09T09:37:38.400376Z  INFO polkadot-staking-miner: upgrade to version: 1009000 successful

This commit changes the following:

1. FollowEvent::Finalized: just remove the finalized and pruned blocks from runtimes
2. FollowEvent::Initalized: just remove the finalized block from runtimes
@niklasad1 niklasad1 requested a review from a team as a code owner January 9, 2024 09:29
@niklasad1 niklasad1 requested a review from jsdw January 9, 2024 09:29
@niklasad1 niklasad1 merged commit df85e46 into master Jan 16, 2024
10 of 11 checks passed
@niklasad1 niklasad1 deleted the na-unstable-backend-refactor-runtime-upgrades branch January 16, 2024 10:58
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.

Unstable backend: runtime upgrade stream doesn't work
4 participants