Skip to content

Commit fe32d17

Browse files
committed
chore(upgrade): v1.6.0 to v1.7.0
- Upgrade Polkadot-sdk to v.1.7.0. - Update weights to reflect the new version. Notable Changes: - [Allow custom error types in Jsonrpsee](paritytech/polkadot-sdk#1313) For more details, please refer to: [Release Notes](https://github.com/paritytech/polkadot-sdk/releases/tag/polkadot-v1.7.0) issue-1870
1 parent 3ebbb71 commit fe32d17

File tree

25 files changed

+1079
-1034
lines changed

25 files changed

+1079
-1034
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 99 additions & 99 deletions
Large diffs are not rendered by default.

common/helpers/src/rpc.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
use core::result::Result as CoreResult;
22
use jsonrpsee::{
3-
core::{Error as RpcError, RpcResult},
4-
types::error::{CallError, ErrorCode, ErrorObject},
3+
core::RpcResult,
4+
types::error::{ErrorCode, ErrorObject},
55
};
66
use sp_api::ApiError;
77

88
/// Converts CoreResult to Result for RPC calls
99
pub fn map_rpc_result<T>(response: CoreResult<T, ApiError>) -> RpcResult<T> {
1010
match response {
1111
Ok(res) => Ok(res),
12-
Err(e) => Err(RpcError::Call(CallError::Custom(ErrorObject::owned(
12+
Err(e) => Err(ErrorObject::owned(
1313
ErrorCode::ServerError(300).code(), // No real reason for this value
1414
"Api Error",
1515
Some(format!("{:?}", e)),
16-
)))),
16+
)),
1717
}
1818
}
1919

node/service/src/block_sealing.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ pub fn frequency_dev_sealing(
187187
false => None,
188188
};
189189

190-
move |deny_unsafe, _| {
190+
Box::new(move |deny_unsafe, _| {
191191
let deps = crate::rpc::FullDeps {
192192
client: client.clone(),
193193
pool: transaction_pool.clone(),
@@ -196,11 +196,11 @@ pub fn frequency_dev_sealing(
196196
};
197197

198198
crate::rpc::create_full(deps, backend.clone()).map_err(Into::into)
199-
}
199+
})
200200
};
201201

202202
sc_service::spawn_tasks(sc_service::SpawnTasksParams {
203-
rpc_builder: Box::new(rpc_extensions_builder),
203+
rpc_builder: rpc_extensions_builder,
204204
client: client.clone(),
205205
transaction_pool: transaction_pool.clone(),
206206
task_manager: &mut task_manager,

node/service/src/rpc/frequency_rpc.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use common_primitives::rpc::RpcEvent;
1111
use jsonrpsee::{
1212
core::{async_trait, RpcResult},
1313
proc_macros::rpc,
14-
types::error::{CallError, ErrorObject},
14+
types::error::ErrorObject,
1515
};
1616
use parity_scale_codec::{Codec, Decode, Encode};
1717
use sc_transaction_pool_api::{InPoolTransaction, TransactionPool};
@@ -73,9 +73,9 @@ where
7373
let api = self.client.runtime_api();
7474
let best = self.client.info().best_hash;
7575

76-
let nonce = api.account_nonce(best, account.clone()).map_err(|e| {
77-
CallError::Custom(ErrorObject::owned(1, "Unable to query nonce.", Some(e.to_string())))
78-
})?;
76+
let nonce = api
77+
.account_nonce(best, account.clone())
78+
.map_err(|e| ErrorObject::owned(1, "Unable to query nonce.", Some(e.to_string())))?;
7979
Ok(get_missing_nonces(&*self.pool, account, nonce))
8080
}
8181
}

node/service/src/service.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,7 @@ fn start_consensus(
505505
proposer,
506506
collator_service,
507507
authoring_duration: Duration::from_millis(1500),
508+
reinitialize: false,
508509
};
509510

510511
let fut =

pallets/capacity/src/tests/mock.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ impl pallet_balances::Config for Test {
6767
type WeightInfo = ();
6868
type FreezeIdentifier = RuntimeFreezeReason;
6969
type MaxFreezes = ConstU32<1>;
70-
type MaxHolds = ConstU32<0>;
7170
type RuntimeHoldReason = ();
7271
type RuntimeFreezeReason = ();
7372
}

pallets/frequency-tx-payment/src/rpc/src/lib.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,9 @@
2020
use std::{convert::TryInto, sync::Arc};
2121

2222
use jsonrpsee::{
23-
core::{async_trait, Error as JsonRpseeError, RpcResult},
23+
core::{async_trait, RpcResult},
2424
proc_macros::rpc,
25-
types::{
26-
error::{CallError, ErrorCode},
27-
ErrorObject,
28-
},
25+
types::{error::ErrorCode, ErrorObject},
2926
};
3027
use pallet_frequency_tx_payment_runtime_api::{FeeDetails, InclusionFee};
3128
use parity_scale_codec::{Codec, Decode};
@@ -102,27 +99,27 @@ where
10299

103100
let encoded_len = encoded_xt.len() as u32;
104101
let uxt: Block::Extrinsic = Decode::decode(&mut &*encoded_xt).map_err(|e| {
105-
CallError::Custom(ErrorObject::owned(
102+
ErrorObject::owned(
106103
Error::DecodeError.into(),
107104
"Unable to query capacity fee details.",
108105
Some(format!("{:?}", e)),
109-
))
106+
)
110107
})?;
111108
let fee_details = api.compute_capacity_fee(at_hash, uxt, encoded_len).map_err(|e| {
112-
CallError::Custom(ErrorObject::owned(
109+
ErrorObject::owned(
113110
Error::RuntimeError.into(),
114111
"Unable to query capacity fee details.",
115112
Some(format!("{:?}", e)),
116-
))
113+
)
117114
})?;
118115

119116
let try_into_rpc_balance = |value: Balance| {
120117
value.try_into().map_err(|_| {
121-
JsonRpseeError::Call(CallError::Custom(ErrorObject::owned(
118+
ErrorObject::owned(
122119
ErrorCode::InvalidParams.code(),
123120
format!("{} doesn't fit in NumberOrHex representation", value),
124121
None::<()>,
125-
)))
122+
)
126123
})
127124
};
128125

pallets/frequency-tx-payment/src/tests/mock.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ impl pallet_balances::Config for Test {
9595
type FreezeIdentifier = RuntimeFreezeReason;
9696
type RuntimeFreezeReason = ();
9797
type MaxFreezes = ConstU32<1>;
98-
type MaxHolds = ConstU32<0>;
9998
type RuntimeHoldReason = ();
10099
}
101100

pallets/handles/src/rpc/src/lib.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ use common_primitives::{
1717
msa::MessageSourceId,
1818
};
1919
use jsonrpsee::{
20-
core::{async_trait, Error as RpcError, RpcResult},
20+
core::{async_trait, RpcResult},
2121
proc_macros::rpc,
22+
types::{error::ErrorObjectOwned, ErrorObject},
2223
};
2324
use pallet_handles_runtime_api::HandlesRuntimeApi;
2425
use sp_api::ProvideRuntimeApi;
@@ -73,9 +74,13 @@ pub enum HandlesRpcError {
7374
InvalidHandle,
7475
}
7576

76-
impl From<HandlesRpcError> for RpcError {
77+
impl From<HandlesRpcError> for ErrorObjectOwned {
7778
fn from(e: HandlesRpcError) -> Self {
78-
RpcError::Custom(format!("{:?}", e))
79+
let msg = format!("{:?}", e);
80+
81+
match e {
82+
HandlesRpcError::InvalidHandle => ErrorObject::owned(1, msg, None::<()>),
83+
}
7984
}
8085
}
8186

pallets/handles/src/rpc/src/tests/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ sp_api::mock_impl_runtime_apis! {
4343
}
4444
}
4545

46-
type HandleResult = Result<Option<HandleResponse>, jsonrpsee::core::Error>;
46+
type HandleResult = Result<Option<HandleResponse>, jsonrpsee::types::ErrorObjectOwned>;
4747

4848
#[tokio::test]
4949
async fn get_handle_with_non_existent_msa_id_should_return_none() {

pallets/messages/src/rpc/src/lib.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ use common_helpers::rpc::map_rpc_result;
1313
use common_primitives::{messages::*, schema::*};
1414
use frame_support::{ensure, fail};
1515
use jsonrpsee::{
16-
core::{async_trait, Error as JsonRpseeError, RpcResult},
16+
core::{async_trait, RpcResult},
1717
proc_macros::rpc,
18+
types::{ErrorObject, ErrorObjectOwned},
1819
};
1920
use pallet_messages_runtime_api::MessagesRuntimeApi;
2021
use sp_api::ProvideRuntimeApi;
@@ -61,9 +62,14 @@ pub enum MessageRpcError {
6162
InvalidSchemaId,
6263
}
6364

64-
impl From<MessageRpcError> for JsonRpseeError {
65+
impl From<MessageRpcError> for ErrorObjectOwned {
6566
fn from(e: MessageRpcError) -> Self {
66-
JsonRpseeError::Custom(format!("{:?}", e))
67+
let msg = format!("{:?}", e);
68+
match e {
69+
MessageRpcError::InvalidPaginationRequest => ErrorObject::owned(1, msg, None::<()>),
70+
MessageRpcError::TypeConversionOverflow => ErrorObject::owned(2, msg, None::<()>),
71+
MessageRpcError::InvalidSchemaId => ErrorObject::owned(3, msg, None::<()>),
72+
}
6773
}
6874
}
6975

pallets/messages/src/rpc/src/tests/mod.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ type GetMessagesBySchemaResult = Result<
6363
common_primitives::messages::BlockPaginationResponse<
6464
common_primitives::messages::MessageResponse,
6565
>,
66-
jsonrpsee::core::Error,
66+
jsonrpsee::types::ErrorObjectOwned,
6767
>;
6868

6969
#[tokio::test]
@@ -77,7 +77,7 @@ async fn get_messages_by_schema_with_invalid_request_should_panic() {
7777
);
7878

7979
assert_eq!(true, result.is_err());
80-
assert_eq!("Custom error: InvalidPaginationRequest", result.unwrap_err().to_string());
80+
assert_eq!("InvalidPaginationRequest", result.unwrap_err().message());
8181
}
8282

8383
#[tokio::test]
@@ -90,9 +90,8 @@ async fn get_messages_by_schema_with_bad_schema_id_should_err() {
9090
BlockPaginationRequest { from_block: 1, to_block: 5, from_index: 0, page_size: 10 },
9191
);
9292

93-
assert_eq!(true, result.is_err());
94-
// assert_eq!("RPC call failed: ErrorObject { code: ServerError(300), message: \"Api Error\", data: Some(RawValue(\"InvalidSchemaId\")) }", result.unwrap_err().to_string());
95-
assert_eq!("Custom error: InvalidSchemaId", result.unwrap_err().to_string());
93+
assert_eq!(true, result.clone().is_err());
94+
assert_eq!("InvalidSchemaId", result.unwrap_err().message());
9695
}
9796

9897
#[tokio::test]

pallets/msa/src/rpc/src/lib.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ use common_primitives::{
1818
schema::SchemaId,
1919
};
2020
use jsonrpsee::{
21-
core::{async_trait, Error as JsonRpseeError, RpcResult},
21+
core::{async_trait, RpcResult},
2222
proc_macros::rpc,
2323
tracing::warn,
24+
types::{error::ErrorObjectOwned, ErrorObject},
2425
};
2526
use pallet_msa_runtime_api::MsaRuntimeApi;
2627
use parity_scale_codec::{Codec, Decode};
@@ -101,9 +102,16 @@ pub enum MsaOffchainRpcError {
101102
OffchainIndexingNotEnabled,
102103
}
103104

104-
impl From<MsaOffchainRpcError> for JsonRpseeError {
105+
impl From<MsaOffchainRpcError> for ErrorObjectOwned {
105106
fn from(e: MsaOffchainRpcError) -> Self {
106-
JsonRpseeError::Custom(format!("{:?}", e))
107+
let msg = format!("{:?}", e);
108+
109+
match e {
110+
MsaOffchainRpcError::ErrorAcquiringLock => ErrorObject::owned(1, msg, None::<()>),
111+
MsaOffchainRpcError::ErrorDecodingData => ErrorObject::owned(2, msg, None::<()>),
112+
MsaOffchainRpcError::OffchainIndexingNotEnabled =>
113+
ErrorObject::owned(3, msg, None::<()>),
114+
}
107115
}
108116
}
109117

pallets/msa/src/rpc/src/tests/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,8 @@ async fn get_keys_by_msa_id_with_disabled_offchain_should_fail() {
232232

233233
let result = api.get_keys_by_msa_id(NOT_EXIST_MSA);
234234

235-
assert_eq!(true, result.is_err());
236-
assert_eq!("Custom error: OffchainIndexingNotEnabled", result.unwrap_err().to_string());
235+
assert_eq!(true, result.clone().is_err());
236+
assert_eq!("OffchainIndexingNotEnabled", result.unwrap_err().message());
237237
}
238238

239239
#[tokio::test]

pallets/passkey/src/mock.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ impl pallet_balances::Config for Test {
110110
type FreezeIdentifier = RuntimeFreezeReason;
111111
type RuntimeFreezeReason = ();
112112
type MaxFreezes = ConstU32<1>;
113-
type MaxHolds = ConstU32<0>;
114113
type RuntimeHoldReason = ();
115114
}
116115

pallets/schemas/src/rpc/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
use common_helpers::{avro, rpc::map_rpc_result};
1212
use common_primitives::schema::*;
1313
use jsonrpsee::{
14-
core::{async_trait, Error as RpcError, RpcResult},
14+
core::{async_trait, RpcResult},
1515
proc_macros::rpc,
16-
types::error::{CallError, ErrorObject},
16+
types::error::ErrorObject,
1717
};
1818
use pallet_schemas_runtime_api::SchemasRuntimeApi;
1919
use sp_api::ProvideRuntimeApi;
@@ -89,11 +89,11 @@ where
8989
let validated_schema = avro::validate_raw_avro_schema(&model);
9090
match validated_schema {
9191
Ok(_) => Ok(true),
92-
Err(e) => Err(RpcError::Call(CallError::Custom(ErrorObject::owned(
92+
Err(e) => Err(ErrorObject::owned(
9393
SchemaRpcError::SchemaValidationError.into(),
9494
"Unable to validate schema",
9595
Some(format!("{:?}", e)),
96-
)))),
96+
)),
9797
}
9898
}
9999

pallets/schemas/src/rpc/src/tests/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ sp_api::mock_impl_runtime_apis! {
5050
}
5151
}
5252

53-
type SchemaResult = Result<Option<SchemaResponse>, jsonrpsee::core::Error>;
54-
type VersionResult = Result<Option<Vec<SchemaVersionResponse>>, jsonrpsee::core::Error>;
53+
type SchemaResult = Result<Option<SchemaResponse>, jsonrpsee::types::ErrorObjectOwned>;
54+
type VersionResult = Result<Option<Vec<SchemaVersionResponse>>, jsonrpsee::types::ErrorObjectOwned>;
5555

5656
#[tokio::test]
5757
async fn get_schema_with_non_existent_schema_id_should_return_none() {

pallets/schemas/src/serde.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ pub enum SerdeError {
1010

1111
pub fn validate_json_model(json_schema: Vec<u8>) -> Result<(), SerdeError> {
1212
let result: Value = from_slice(&json_schema).map_err(|_| SerdeError::DeserializationError)?;
13+
1314
match result {
1415
Value::Null => Err(SerdeError::InvalidNullSchema),
1516
Value::Object(_) => Ok(()),

pallets/schemas/src/tests/serde_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ fn serde_helper_deserialzer_error() {
4646
r#"{ 56: "number" }"#, // KeyMustBeAString
4747
r#"{ "file address": "file path" \r\n}"#, // EofWhileParsingObject
4848
r#"{ "unicode code point": "\ud83f" }"#, // InvalidUnicodeCodePoint
49-
r#"{ "v": 300e715100 }"#, // NumberOutOfRange
49+
// r#"{ "v": 300e715100 }"#, // NumberOutOfRange
5050
] {
5151
assert_noop!(
5252
validate_json_model(create_schema_vec(test_str_raw)),

pallets/stateful-storage/src/rpc/src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ use common_primitives::{
1414
stateful_storage::{ItemizedStoragePageResponse, PaginatedStorageResponse},
1515
};
1616
use jsonrpsee::{
17-
core::{async_trait, Error as RpcError, RpcResult},
17+
core::{async_trait, RpcResult},
1818
proc_macros::rpc,
19-
types::error::{CallError, ErrorCode, ErrorObject},
19+
types::error::{ErrorCode, ErrorObject},
2020
};
2121
use pallet_stateful_storage_runtime_api::StatefulStorageRuntimeApi;
2222
use sp_api::{ApiError, ProvideRuntimeApi};
@@ -95,15 +95,15 @@ where
9595
fn map_result<T>(api_result: Result<Result<T, DispatchError>, ApiError>) -> RpcResult<T> {
9696
match api_result {
9797
Ok(Ok(result)) => Ok(result),
98-
Ok(Err(e)) => Err(RpcError::Call(CallError::Custom(ErrorObject::owned(
98+
Ok(Err(e)) => Err(ErrorObject::owned(
9999
ErrorCode::ServerError(300).code(), // No real reason for this value
100100
"Runtime Error",
101101
Some(format!("{:?}", e)),
102-
)))),
103-
Err(e) => Err(RpcError::Call(CallError::Custom(ErrorObject::owned(
102+
)),
103+
Err(e) => Err(ErrorObject::owned(
104104
ErrorCode::ServerError(301).code(), // No real reason for this value
105105
"Api Error",
106106
Some(format!("{:?}", e)),
107-
)))),
107+
)),
108108
}
109109
}

pallets/stateful-storage/src/rpc/src/tests/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,9 @@ sp_api::mock_impl_runtime_apis! {
4545
}
4646
}
4747

48-
type PaginatedStateResult = Result<Vec<PaginatedStorageResponse>, jsonrpsee::core::Error>;
49-
type ItemizedStateResult = Result<ItemizedStoragePageResponse, jsonrpsee::core::Error>;
48+
type PaginatedStateResult =
49+
Result<Vec<PaginatedStorageResponse>, jsonrpsee::types::ErrorObjectOwned>;
50+
type ItemizedStateResult = Result<ItemizedStoragePageResponse, jsonrpsee::types::ErrorObjectOwned>;
5051

5152
#[tokio::test]
5253
async fn get_paginated_storage_with_non_existent_schema_id_should_return_error() {

pallets/time-release/src/mock.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ impl pallet_balances::Config for Test {
5353
type WeightInfo = ();
5454
type FreezeIdentifier = RuntimeFreezeReason;
5555
type MaxFreezes = ConstU32<1>;
56-
type MaxHolds = ConstU32<0>;
5756
type RuntimeHoldReason = ();
5857
type RuntimeFreezeReason = ();
5958
}

0 commit comments

Comments
 (0)