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

chore: upgrade stable2409 #412

Open
wants to merge 18 commits into
base: chungquantin/chore-polkadot-stable2407
Choose a base branch
from

Conversation

Daanvdplas
Copy link
Collaborator

@Daanvdplas Daanvdplas commented Dec 18, 2024

Uplifts pop to 2409. Some noteworthy changes had to be made for ismp (upstream changes) and the sdk. I left comments at the relevant places to have a discussion.

Notes:

  • Pallet revive will be added in a separate PR.
  • In some Cargo.toml files dependencies were added to the features. This was done while trying to find the cause of the compilation error (pop common). I left them in as they might cause issues in the future.

@Daanvdplas Daanvdplas force-pushed the chungquantin/chore-polkadot-stable2407 branch from 45b2cf6 to e7abcd9 Compare December 19, 2024 14:08
@Daanvdplas Daanvdplas force-pushed the daan/chore-stable2409 branch from 39144ac to 5a52b05 Compare December 19, 2024 14:59
@@ -341,7 +341,7 @@ fn start_destroy_works() {
// Check that the token is not live after starting the destroy process.
assert_noop!(
Assets::mint(signed(ALICE), token, ALICE, 10 * UNIT),
AssetsError::AssetNotLive
TokenError::UnknownAsset
Copy link
Collaborator Author

@Daanvdplas Daanvdplas Dec 19, 2024

Choose a reason for hiding this comment

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

Test was failing due to the following paritytech/polkadot-sdk#3286

Concerning to me is that this would have broken a smart contract. Presumably contracts won't often match on a specific error but if so, the contract could behave unexpected.

Curious to hear what others think about this.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Good to see that the test worked. If someone were using this, we would need to map the error AssetNotLive to UnknownAsset as to not break the contract.

Only a problem if we don't catch it before a runtime upgrade.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This error only changed for the mint function.

The reason why it is concerning to me is that I don't have the feeling parity is seeing this as a breaking change, meaning that they'll make such changes more often, meaning that we have to create more versions.

@codecov-commenter
Copy link

codecov-commenter commented Dec 20, 2024

Codecov Report

Attention: Patch coverage is 13.63636% with 19 lines in your changes missing coverage. Please review.

Please upload report for BASE (chungquantin/chore-polkadot-stable2407@ab0bb49). Learn more about missing BASE report.

Files with missing lines Patch % Lines
node/src/command.rs 0.00% 7 Missing ⚠️
node/src/service.rs 0.00% 5 Missing ⚠️
node/src/rpc.rs 0.00% 2 Missing ⚠️
runtime/devnet/src/config/ismp.rs 0.00% 2 Missing ⚠️
runtime/common/src/lib.rs 0.00% 1 Missing ⚠️
runtime/devnet/src/lib.rs 0.00% 1 Missing ⚠️
runtime/testnet/src/lib.rs 0.00% 1 Missing ⚠️
@@                            Coverage Diff                            @@
##             chungquantin/chore-polkadot-stable2407     #412   +/-   ##
=========================================================================
  Coverage                                          ?   68.24%           
=========================================================================
  Files                                             ?       70           
  Lines                                             ?    11841           
  Branches                                          ?    11841           
=========================================================================
  Hits                                              ?     8081           
  Misses                                            ?     3503           
  Partials                                          ?      257           
Files with missing lines Coverage Δ
pallets/api/src/fungibles/tests.rs 99.69% <100.00%> (ø)
runtime/devnet/src/config/contracts.rs 66.66% <ø> (ø)
runtime/mainnet/src/config/xcm.rs 0.00% <ø> (ø)
runtime/mainnet/src/lib.rs 21.44% <100.00%> (ø)
runtime/testnet/src/config/contracts.rs 66.66% <ø> (ø)
runtime/common/src/lib.rs 0.00% <0.00%> (ø)
runtime/devnet/src/lib.rs 5.44% <0.00%> (ø)
runtime/testnet/src/lib.rs 6.29% <0.00%> (ø)
node/src/rpc.rs 0.00% <0.00%> (ø)
runtime/devnet/src/config/ismp.rs 0.00% <0.00%> (ø)
... and 2 more

assets::start_destroy(&addr, token);
assert_eq!(mint(&addr, token, &BOB, amount), Err(Module { index: 52, error: [16, 0] }));
assert_eq!(mint(&addr, token, &BOB, amount), Err(Token(UnknownAsset)));
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Same error that changed as above.

@@ -16,6 +16,7 @@ fn schedule<T: pallet_contracts::Config>() -> pallet_contracts::Schedule<T> {
pallet_contracts::Schedule {
limits: pallet_contracts::Limits {
runtime_memory: 1024 * 1024 * 1024,
validator_runtime_memory: 2 * 1024 * 1024 * 1024,
Copy link
Collaborator Author

@Daanvdplas Daanvdplas Dec 20, 2024

Choose a reason for hiding this comment

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

The integrity test was failing:

failures:

---- __construct_runtime_integrity_test::runtime_integrity_tests stdout ----
thread '__construct_runtime_integrity_test::runtime_integrity_tests' panicked at /Users/R0GUE/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pallet-contracts-38.0.0/src/lib.rs:707:13:
Maximal storage size 143942352 exceeds the storage limit 0
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

@peterwht do you remember why you put this in the runtimes. The SDK uses the default, yet an other error occurs when applying:

failures:

---- __construct_runtime_integrity_test::runtime_integrity_tests stdout ----
thread '__construct_runtime_integrity_test::runtime_integrity_tests' panicked at /Users/R0GUE/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pallet-contracts-38.0.0/src/lib.rs:657:13:
Given `CallStack` height 24, `MaxCodeLen` should be set less than 8995 (current value is 262144), to avoid possible runtime oom issues.
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

I see we have double the MaxCodeLen value configured as the sdk runtime linked.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't remember why, unfortunately. I guess it just gives us the flexibility to modify those as needed.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The reason the default isn't working is due to this: https://github.com/paritytech/polkadot-sdk/blob/master/substrate/frame/contracts/src/lib.rs#L649

We would need to reduce the MaxCodeLen if we want to use the default schedule.

Copy link
Collaborator

Choose a reason for hiding this comment

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

also, do you have a link for where this value is coming from: " validator_runtime_memory: 2 * 1024 * 1024 * 1024,"?

Copy link
Collaborator Author

@Daanvdplas Daanvdplas Dec 21, 2024

Choose a reason for hiding this comment

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

It had to be bigger than the other value so not much thought put towards it.

I changed the contracts configuration back to default. As we might transition to only using revive I suggest we look into this when we add revive to the runtime, and take a closer look at those configurations, in stead of now.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@@ -17,7 +17,7 @@ impl pallet_ismp::Config for Runtime {
type Coprocessor = Coprocessor;
type Currency = Balances;
type HostStateMachine = HostStateMachine;
type Mmr = pallet_ismp::NoOpMmrTree<Self>;
type OffchainDB = ();
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Confirmed with polytope labs team that this is oke to use in stead of the Mmr pallet

@@ -17,7 +17,7 @@ impl pallet_ismp::Config for Runtime {
type Coprocessor = Coprocessor;
type Currency = Balances;
type HostStateMachine = HostStateMachine;
type Mmr = pallet_ismp::NoOpMmrTree<Self>;
type OffchainDB = ();
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Confirmed with polytope labs team that this is oke to use in stead of the Mmr pallet

fn module_for_id(&self, id: Vec<u8>) -> Result<Box<dyn IsmpModule>, Error> {
Err(Error::ModuleNotFound(id))
fn module_for_id(&self, id: Vec<u8>) -> Result<Box<dyn IsmpModule>, anyhow::Error> {
Err(anyhow::anyhow!("Module not found: {:?}", id))
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed to anyhow error type

@@ -134,7 +134,7 @@ impl xcm_executor::Config for XcmConfig {
type CallDispatcher = RuntimeCall;
type FeeManager = XcmFeeManagerFromComponents<
WaivedLocations,
XcmFeeToAccount<Self::AssetTransactor, AccountId, SudoAddress>,
SendXcmFeeToAccount<Self::AssetTransactor, SudoAddress>,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

runtime/devnet/src/config/contracts.rs Outdated Show resolved Hide resolved
@@ -16,6 +16,7 @@ fn schedule<T: pallet_contracts::Config>() -> pallet_contracts::Schedule<T> {
pallet_contracts::Schedule {
limits: pallet_contracts::Limits {
runtime_memory: 1024 * 1024 * 1024,
validator_runtime_memory: 2 * 1024 * 1024 * 1024,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't remember why, unfortunately. I guess it just gives us the flexibility to modify those as needed.

@@ -16,6 +16,7 @@ fn schedule<T: pallet_contracts::Config>() -> pallet_contracts::Schedule<T> {
pallet_contracts::Schedule {
limits: pallet_contracts::Limits {
runtime_memory: 1024 * 1024 * 1024,
validator_runtime_memory: 2 * 1024 * 1024 * 1024,
Copy link
Collaborator

Choose a reason for hiding this comment

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

The reason the default isn't working is due to this: https://github.com/paritytech/polkadot-sdk/blob/master/substrate/frame/contracts/src/lib.rs#L649

We would need to reduce the MaxCodeLen if we want to use the default schedule.

@@ -341,7 +341,7 @@ fn start_destroy_works() {
// Check that the token is not live after starting the destroy process.
assert_noop!(
Assets::mint(signed(ALICE), token, ALICE, 10 * UNIT),
AssetsError::AssetNotLive
TokenError::UnknownAsset
Copy link
Collaborator

Choose a reason for hiding this comment

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

Good to see that the test worked. If someone were using this, we would need to map the error AssetNotLive to UnknownAsset as to not break the contract.

Only a problem if we don't catch it before a runtime upgrade.

runtime/common/src/lib.rs Outdated Show resolved Hide resolved
@@ -16,6 +16,7 @@ fn schedule<T: pallet_contracts::Config>() -> pallet_contracts::Schedule<T> {
pallet_contracts::Schedule {
limits: pallet_contracts::Limits {
runtime_memory: 1024 * 1024 * 1024,
validator_runtime_memory: 2 * 1024 * 1024 * 1024,
Copy link
Collaborator

Choose a reason for hiding this comment

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

also, do you have a link for where this value is coming from: " validator_runtime_memory: 2 * 1024 * 1024 * 1024,"?

@Daanvdplas Daanvdplas mentioned this pull request Dec 21, 2024
Copy link
Collaborator

@AlexD10S AlexD10S left a comment

Choose a reason for hiding this comment

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

Thank you for the comment clarifying the key changes. Great work!

@@ -45,14 +46,14 @@ futures = "0.3.30"
hex = "0.4.3"
hex-literal = "0.4.1"
impl-trait-for-tuples = "0.2.2"
jsonrpsee = { version = "0.23.2", features = [ "server" ] }
log = { version = "0.4.21", default-features = false }
jsonrpsee = { version = "0.24.3" }
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is the removal of features = [ "server" ] intentional, as mentioned in the description?

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.

5 participants