Skip to content

Commit d250a6e

Browse files
authored
Contracts: Stabilize APIs (#3384)
Remove `#[unstable]` on `call_v2`, `instantiate_v2`, `lock_delegate_dependency` and `unlock_delegate_dependency`. See ink! integrations: - call_v2: use-ink/ink#2077 - instantiate_v2: <TODO> - lock/unlock dependency: use-ink/ink#2076
1 parent e89d0fc commit d250a6e

26 files changed

+137
-140
lines changed

prdoc/pr_3384.prdoc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0
2+
# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json
3+
4+
title: "[pallet_contracts] stabilize `call_v2`, `instantiate_v2`, `lock_dependency` and `unlock_dependency`"
5+
6+
doc:
7+
- audience: Runtime Dev
8+
description: |
9+
These APIs are currently unstable and are being stabilized in this PR.
10+
Note: `add_delegate_dependency` and `remove_delegate_dependency` have been renamed to `lock_dependency` and `unlock_dependency` respectively.
11+
12+
crates:
13+
- name: pallet-contracts-uapi
14+
- name: pallet-contracts

substrate/frame/contracts/fixtures/contracts/call.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,13 @@ pub extern "C" fn call() {
3535
);
3636

3737
// Call the callee
38-
api::call_v1(
38+
api::call_v2(
3939
uapi::CallFlags::empty(),
4040
callee_addr,
41-
0u64, // How much gas to devote for the execution. 0 = all.
42-
&0u64.to_le_bytes(), // value transferred to the contract.
41+
0u64, // How much ref_time to devote for the execution. 0 = all.
42+
0u64, // How much proof_size to devote for the execution. 0 = all.
43+
None, // No deposit limit.
44+
&0u64.to_le_bytes(), // Value transferred to the contract.
4345
callee_input,
4446
None,
4547
)

substrate/frame/contracts/fixtures/contracts/call_return_code.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,13 @@ pub extern "C" fn call() {
3838
);
3939

4040
// Call the callee
41-
let err_code = match api::call_v1(
41+
let err_code = match api::call_v2(
4242
uapi::CallFlags::empty(),
4343
callee_addr,
44-
0u64, // How much gas to devote for the execution. 0 = all.
45-
&100u64.to_le_bytes(), // value transferred to the contract.
44+
0u64, // How much ref_time to devote for the execution. 0 = all.
45+
0u64, // How much proof_size to devote for the execution. 0 = all.
46+
None, // No deposit limit.
47+
&100u64.to_le_bytes(), // Value transferred to the contract.
4648
input,
4749
None,
4850
) {

substrate/frame/contracts/fixtures/contracts/call_runtime_and_call.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,13 @@ pub extern "C" fn call() {
3939
api::call_runtime(call).unwrap();
4040

4141
// Call the callee
42-
api::call_v1(
42+
api::call_v2(
4343
uapi::CallFlags::empty(),
4444
callee_addr,
45-
0u64, // How much gas to devote for the execution. 0 = all.
46-
&0u64.to_le_bytes(), // value transferred to the contract.
45+
0u64, // How much ref_time to devote for the execution. 0 = all.
46+
0u64, // How much proof_size to devote for the execution. 0 = all.
47+
None, // No deposit limit.
48+
&0u64.to_le_bytes(), // Value transferred to the contract.
4749
callee_input,
4850
None,
4951
)

substrate/frame/contracts/fixtures/contracts/call_with_limit.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ pub extern "C" fn call() {
3838
forwarded_input: [u8],
3939
);
4040

41-
#[allow(deprecated)]
4241
api::call_v2(
4342
uapi::CallFlags::empty(),
4443
callee_addr,

substrate/frame/contracts/fixtures/contracts/caller_contract.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ pub extern "C" fn call() {
4040
let reverted_input = [1u8, 34, 51, 68, 85, 102, 119];
4141

4242
// Fail to deploy the contract since it returns a non-zero exit status.
43-
#[allow(deprecated)]
4443
let res = api::instantiate_v2(
4544
code_hash,
4645
0u64, // How much ref_time weight to devote for the execution. 0 = all.
@@ -55,7 +54,6 @@ pub extern "C" fn call() {
5554
assert!(matches!(res, Err(ReturnErrorCode::CalleeReverted)));
5655

5756
// Fail to deploy the contract due to insufficient ref_time weight.
58-
#[allow(deprecated)]
5957
let res = api::instantiate_v2(
6058
code_hash, 1u64, // too little ref_time weight
6159
0u64, // How much proof_size weight to devote for the execution. 0 = all.
@@ -65,7 +63,6 @@ pub extern "C" fn call() {
6563
assert!(matches!(res, Err(ReturnErrorCode::CalleeTrapped)));
6664

6765
// Fail to deploy the contract due to insufficient proof_size weight.
68-
#[allow(deprecated)]
6966
let res = api::instantiate_v2(
7067
code_hash, 0u64, // How much ref_time weight to devote for the execution. 0 = all.
7168
1u64, // Too little proof_size weight
@@ -78,7 +75,6 @@ pub extern "C" fn call() {
7875
let mut callee = [0u8; 32];
7976
let callee = &mut &mut callee[..];
8077

81-
#[allow(deprecated)]
8278
api::instantiate_v2(
8379
code_hash,
8480
0u64, // How much ref_time weight to devote for the execution. 0 = all.
@@ -94,7 +90,6 @@ pub extern "C" fn call() {
9490
assert_eq!(callee.len(), 32);
9591

9692
// Call the new contract and expect it to return failing exit code.
97-
#[allow(deprecated)]
9893
let res = api::call_v2(
9994
uapi::CallFlags::empty(),
10095
callee,
@@ -108,11 +103,10 @@ pub extern "C" fn call() {
108103
assert!(matches!(res, Err(ReturnErrorCode::CalleeReverted)));
109104

110105
// Fail to call the contract due to insufficient ref_time weight.
111-
#[allow(deprecated)]
112106
let res = api::call_v2(
113107
uapi::CallFlags::empty(),
114108
callee,
115-
1u64, // too little ref_time weight
109+
1u64, // Too little ref_time weight.
116110
0u64, // How much proof_size weight to devote for the execution. 0 = all.
117111
None, // No deposit limit.
118112
&value,
@@ -122,7 +116,6 @@ pub extern "C" fn call() {
122116
assert!(matches!(res, Err(ReturnErrorCode::CalleeTrapped)));
123117

124118
// Fail to call the contract due to insufficient proof_size weight.
125-
#[allow(deprecated)]
126119
let res = api::call_v2(
127120
uapi::CallFlags::empty(),
128121
callee,
@@ -137,7 +130,6 @@ pub extern "C" fn call() {
137130

138131
// Call the contract successfully.
139132
let mut output = [0u8; 4];
140-
#[allow(deprecated)]
141133
api::call_v2(
142134
uapi::CallFlags::empty(),
143135
callee,

substrate/frame/contracts/fixtures/contracts/chain_extension_temp_storage.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,13 @@ pub extern "C" fn call() {
5050
output!(addr, [0u8; 32], api::address,);
5151

5252
// call self
53-
api::call_v1(
53+
api::call_v2(
5454
uapi::CallFlags::ALLOW_REENTRY,
5555
addr,
56-
0u64, // How much gas to devote for the execution. 0 = all.
57-
&0u64.to_le_bytes(), // value transferred to the contract.
56+
0u64, // How much ref_time to devote for the execution. 0 = all.
57+
0u64, // How much proof_size to devote for the execution. 0 = all.
58+
None, // No deposit limit.
59+
&0u64.to_le_bytes(), // Value transferred to the contract.
5860
input,
5961
None,
6062
)

substrate/frame/contracts/fixtures/contracts/create_storage_and_call.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,13 @@ pub extern "C" fn call() {
4040
api::set_storage(buffer, &[1u8; 4]);
4141

4242
// Call the callee
43-
#[allow(deprecated)]
4443
api::call_v2(
4544
uapi::CallFlags::empty(),
4645
callee,
4746
0u64, // How much ref_time weight to devote for the execution. 0 = all.
4847
0u64, // How much proof_size weight to devote for the execution. 0 = all.
4948
Some(deposit_limit),
50-
&0u64.to_le_bytes(), // value transferred to the contract.
49+
&0u64.to_le_bytes(), // Value transferred to the contract.
5150
input,
5251
None,
5352
)

substrate/frame/contracts/fixtures/contracts/create_storage_and_instantiate.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ pub extern "C" fn call() {
4040
let mut address = [0u8; 32];
4141
let address = &mut &mut address[..];
4242

43-
#[allow(deprecated)]
4443
api::instantiate_v2(
4544
code_hash,
4645
0u64, // How much ref_time weight to devote for the execution. 0 = all.

substrate/frame/contracts/fixtures/contracts/destroy_and_transfer.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ pub extern "C" fn deploy() {
3434
let address = &mut &mut address[..];
3535
let salt = [71u8, 17u8];
3636

37-
#[allow(deprecated)]
3837
api::instantiate_v2(
3938
code_hash,
4039
0u64, // How much ref_time weight to devote for the execution. 0 = all.
@@ -60,7 +59,6 @@ pub extern "C" fn call() {
6059
api::get_storage(&ADDRESS_KEY, callee_addr).unwrap();
6160

6261
// Calling the destination contract with non-empty input data should fail.
63-
#[allow(deprecated)]
6462
let res = api::call_v2(
6563
uapi::CallFlags::empty(),
6664
callee_addr,
@@ -74,7 +72,6 @@ pub extern "C" fn call() {
7472
assert!(matches!(res, Err(uapi::ReturnErrorCode::CalleeTrapped)));
7573

7674
// Call the destination contract regularly, forcing it to self-destruct.
77-
#[allow(deprecated)]
7875
api::call_v2(
7976
uapi::CallFlags::empty(),
8077
callee_addr,

0 commit comments

Comments
 (0)