pendulum-chain / pendulum

GNU General Public License v3.0
43 stars 14 forks source link

Polkadot v1.1.0 #489

Closed gianfra-t closed 2 months ago

gianfra-t commented 3 months ago

@pendulum-chain/product: This PR adds changes to the node client code that require a redeployment of the collator nodes to take effect. Please ensure that the collator nodes are redeployed after this PR is merged.

Closes #481 .

Notable changes and decisions.

Integration tests changes.

Now we differentiate between the xcm-simulator and xcm-emulator. See the small wiki here. Previous macros now belong to the simulator, while from the description I infer that what we actually need for integration tests is the emulator. I also tested the simulator since it required less changes but I was getting Unroutable errors for every xcm message sent. Therefore, for these two reasons I decided to move to the emulator.

Most of the code changes revolve around the new macro definitions and most importantly the genesis config of these test chains.

Asset-hub runtimes issue.

Initially it was attempted to get the runtimes from the new fellows repo. The issue is that it uses the crates.io version of the polkadot dependencies, which brought conflicts when using the unit tests, since all our dependencies are from the polkadot-sdk repo, branch release-polkadot-v1.1.0. Although they are the same to release-crates-io-v1.1.0, the version scheme changes. The solution to this issue was to implement a patch with all packages specified to normalize for this branch (attempted in this commit). Previous macros for building the externalities are now replaced by the genesis config.

Alternatively, we can use the runtimes from the polkadot-sdk repository, although they seem to be fixed at version 9.42 of the runtime, while maintaining compatibility with the dependencies. Since this is only used for unit testing I have implemented this second option to avoid the maintaining the patch. The alternative is also possible if we require so in the future.

Testing Migrations

Related ticket. Only pallet_contracts seems to define a migration for this update. In this case, from 10 to 15. Also, both pallet_bounties and parachain_staking need to be bumped to the correct version (4 and 7 respectively). According to this PR, the migration for Bounties must happen because the prefix was changed. Now, while running these migrations as defined on the companion update for Kusama/Polkadot at that time, we get that the new prefix is not empty (we get this error), hinting that the storage already lives on the new prefix.

We can test the application of this migrations with the try-runtime tool. Command to run it and docs in our notion. The output of this should tell us if the migrations will be applied correctly or not.

Bandersnatch_vfrs patch

Addition of this patch exception was required due to an error in compilation with nightly-2024-04-18, see run issue. Using a new nightly version solves the issue (nightly-2024-05-30 for instance), but the package bandersnatch_vrfs was not found. Solution found here.

Open questions

As far as I see from other chains and templates (bifrost, sdk template) it is okay to pass an empty closure since the pallet will take care of adding the inherents by default.

prayagd commented 3 months ago

redeployment of the collator nodes to take effect.

Do we have a ticket for this, so i can link here as blocked?

gianfra-t commented 3 months ago

@prayagd they have to be redeployed but after the changes on this PR are finished. Sorry it pinged you since it is still a draft.

gianfra-t commented 2 months ago

@ebma about this question:

But these patches are not contained in the most recent version anymore. Does this mean you want to rely on the current state of the Cargo.lock file? Seems a little brittle to me. Or am I missing something here?

We are not relying on the lock file, we required the patches if we were to use the assethub runtimes from the polkadot-fellows repo. But if we use the assethub runtimes from the polkadot-sdk directly, then there is no compilation issue. The difference as I put in the description is that these are fixed at 0.9.42, even though the sdk version is 1.1.0. I believe they just made them compatible but did not upgrade the logic itself. So we have the choice to use either:

When I discovered the second option was also working, I chose that one since maintaining the patch is very brittle. Especially since we cannot do cargo update without breaking our lock.

About the weights, yes I didn't think about regenerating the weights again. Do you think it can be a bit too much for a single PR?

ebma commented 2 months ago

Thanks for explaining that part again 👍 Yes I fully agree that not having to patch all dependencies is the better approach, so let's stick to the runtimes from the polkadot-sdk repository.

About the weights, yes I didn't think about regenerating the weights again. Do you think it can be a bit too much for a single PR?

I would opt for including it in the same PR as the weights are only required due to the updated dependencies and we shouldn't roll out the runtime upgrade without regenerating them first. I would hope that this is not too much overhead.

gianfra-t commented 2 months ago

I updated the weights by running the benchmarks again. Created a simple script for this that will run all the existing benchmarks on the weights folder, ignoring fails. @pendulum-chain/devs If you like this script we can keep it, I'll add it to the REAMDE.

Also added a fix for the failing orlm-tokens-management which only required to increase the balance of the tester account. I did it this way to avoid conversion errors (since in benchmarks is always hard to access values).

Only pallet redeem is not working for the pendulum runtime.

called `Result::unwrap()` on an `Err` value: Module(ModuleError { index: 53, error: [5, 0, 0, 0], message: Some("ExistentialDeposit") }) 

This is a bit surprising since also amplitude has the same existential deposit values, yet it works there.

We can either choose to investigate further, or use amplitude's weights for this pallet, depending on priorities.

EDIT: Should also add that the benchmark also fails in main.

ebma commented 2 months ago

I briefly compared the runtime definitions of pendulum and amplitude but was not able to spot the difference that could make the benchmark fail on pendulum. @gianfra-t which one of the benchmark functions fails exactly?

I'm happy to keep your shell script for the weight generation, thanks for creating it 👍

gianfra-t commented 2 months ago

When you benchmark on main is harder to see, but running on this branch there is an unwrap() panicking, this line precisely.

So clearly the issue must be closer to the VaultRegistry config. But as you said, I don't understand how if the ED is the same. Do you recall any liquidation parameter that could be different between runtimes?

ebma commented 2 months ago

I'm not 100% sure but maybe it's because of the differing values for the thresholds (e.g. this) of the vault registry in the genesis configuration of pendulum vs amplitude in chain_spec.rs. Can you try if changing all the thresholds to the same values as are used in Amplitude fixes the benchmark for Pendulum?

gianfra-t commented 2 months ago

Nope, same error 🤔.

gianfra-t commented 2 months ago

@ebma I pushed a change to increase the amount of tokens issued before liquidating and this solves the fix. I suspect this line and subsequent transfer, but I have no idea why it worked on Amplitude. In any case I executed both again with the same parameter.

Technically we should point to a new rev once the Spacewalk fix is merged.

@pendulum-chain/devs let me know if I missed an open question or remark since this PR grew a bit too much already!

ebma commented 2 months ago

Although we don't 100% know which caused the issue, the amount used was very low so the fix is fine with me. Let's point to the new Spacewalk rev then.

gianfra-t commented 2 months ago

Sorry @b-yap, but if you can re-approve again please since @ebma and I where last to commit and now the review is stale.

ebma commented 2 months ago

I'll just merge it for you @gianfra-t.