Skip to content

Commit 8574f19

Browse files
[pallet-revive] Version the Remaining Runtime API Functions (#12536)
# Description This PR closes #11924 and #11928 and versions the final remaining runtime API functions in pallet-revive, fully deprecating the old unversioned runtime API in favor of the new versioned runtime API functions. Additionally, this PR adds an `unversioned_runtime_api_functions_are_unchanged_by_versioning` test which is an important test which asserts that every single type which can be seen in the unversioned runtime API functions is identical to the new versioned types in terms of encoding such that if we encode an old unversioned type we can decode as a new versioned type and vice versa. This is made possible through the schema available in the metadata which allows us to check a pre-versioning schema against a post-versioning schema. This test is implemented as a very very simple walker which walks the schema in lock-step and checks that the schema of the pre-versioning types matches that of the post-versioning types. Yes, the code for this test is slightly long, but it's very simple. The moment you see that lots of the code length is due to us wanting to preserve the paths (for printing in assertion messages), you can see that the test is quite simple. Aside from the above, and as mentioned at the start, this PR also versioned the remaining runtime API functions. In the process, I combined some runtime API functions into a single versioned runtime API function. For example, `eth_transact` and `eth_transact_with_config` have been combined into a single `eth_transact_versioned` since `eth_transact_with_config` was added as way to version the `eth_transact` runtime API function. Same was done to the `trace_call` and the `trace_call_with_config` in that they've been combined into a single versioned runtime API function. --------- Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 8630d5b commit 8574f19

53 files changed

Lines changed: 3500 additions & 1096 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.lock

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

polkadot/zombienet-sdk-tests/tests/parachains/weights.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
mod ahw {}
99

1010
use ahw::runtime_types::{
11-
pallet_revive::primitives::{Code, StorageDeposit},
11+
pallet_revive_types::runtime_api::types::contract::{CodeV1, StorageDepositV1},
1212
sp_weights::weight_v2::Weight,
1313
};
1414
use anyhow::anyhow;
@@ -295,14 +295,14 @@ async fn instantiate_params(
295295
caller: &Keypair,
296296
) -> Result<(u64, u64, u128), anyhow::Error> {
297297
let account_id = caller.public_key().to_account_id();
298-
let code = Code::Upload(code);
298+
let code = CodeV1::Upload(code);
299299
let call = ahw::apis()
300300
.revive_api()
301301
.instantiate(account_id, 0, None, None, code, vec![], None);
302302
let dry_run = client.runtime_api().at_latest().await?.call(call).await?;
303303
let deposit = match dry_run.storage_deposit {
304-
StorageDeposit::Charge(c) => c,
305-
StorageDeposit::Refund(_) => 0,
304+
StorageDepositV1::Charge(c) => c,
305+
StorageDepositV1::Refund(_) => 0,
306306
};
307307

308308
// Make sure we have enough gas and multiply by 4, since without it the calls fail not enough
@@ -320,8 +320,8 @@ async fn call_params(
320320
let call = ahw::apis().revive_api().call(account_id, contract, 0, None, None, payload);
321321
let dry_run = client.runtime_api().at_latest().await?.call(call).await?;
322322
let deposit = match dry_run.storage_deposit {
323-
StorageDeposit::Charge(c) => c,
324-
StorageDeposit::Refund(_) => 0,
323+
StorageDepositV1::Charge(c) => c,
324+
StorageDepositV1::Refund(_) => 0,
325325
};
326326

327327
Ok((dry_run.weight_required.ref_time, dry_run.weight_required.proof_size, deposit))

prdoc/pr_12536.prdoc

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
title: '[pallet-revive] Version the Remaining Runtime API Functions'
2+
doc:
3+
- audience: Runtime Dev
4+
description: |-
5+
# Description
6+
7+
This PR versions the final remaining runtime API functions in pallet-revive, fully deprecating the old unversioned runtime API in favor of the new versioned runtime API functions.
8+
9+
Additionally, this PR adds an `unversioned_runtime_api_functions_are_unchanged_by_versioning` test which is an important test which asserts that every single type which can be seen in the unversioned runtime API functions is identical to the new versioned types in terms of encoding such that if we encode an old unversioned type we can decode as a new versioned type and vice versa. This is made possible through the schema available in the metadata which allows us to check a pre-versioning schema against a post-versioning schema. This test is implemented as a very very simple walker which walks the schema in lock-step and checks that the schema of the pre-versioning types matches that of the post-versioning types. Yes, the code for this test is slightly long, but it's very simple. The moment you see that lots of the code length is due to us wanting to preserve the paths (for printing in assertion messages), you can see that the test is quite simple.
10+
11+
Aside from the above, and as mentioned at the start, this PR also versioned the remaining runtime API functions. In the process, I combined some runtime API functions into a single versioned runtime API function. For example, `eth_transact` and `eth_transact_with_config` have been combined into a single `eth_transact_versioned` since `eth_transact_with_config` was added as way to version the `eth_transact` runtime API function. Same was done to the `trace_call` and the `trace_call_with_config` in that they've been combined into a single versioned runtime API function.
12+
crates:
13+
- name: pallet-revive-eth-rpc
14+
bump: major
15+
- name: pallet-revive
16+
bump: major
17+
- name: pallet-revive-types
18+
bump: major
19+
- name: revive-dev-runtime
20+
bump: major

0 commit comments

Comments
 (0)