git.delta.rocks / unique-network / refs/commits / 32b37d3d84ce

difftreelog

NFTPAR-288. Limit schema size

str-mv2021-01-12parent: #5743a92.patch.diff
in: master

2 files changed

modifiednode/src/chain_spec.rsdiffbeforeafterboth
--- a/node/src/chain_spec.rs
+++ b/node/src/chain_spec.rs
@@ -209,7 +209,10 @@
                 custom_data_limit: 2048,
                 nft_sponsor_transfer_timeout: 15,
                 fungible_sponsor_transfer_timeout: 15,
-                refungible_sponsor_transfer_timeout: 15,
+				refungible_sponsor_transfer_timeout: 15,
+				offchain_schema_limit: 1024,
+				variable_on_chain_schema_limit: 1024,
+				const_on_chain_schema_limit: 1024,
             },
         }),
         pallet_contracts: Some(ContractsConfig {
modifiedpallets/nft/src/lib.rsdiffbeforeafterboth
74 ReFungible(DecimalPoints),74 ReFungible(DecimalPoints),
75}75}
76
77impl Default for CollectionMode {
78 fn default() -> Self {
79 Self::Invalid
80 }
81}
7682
77impl Into<u8> for CollectionMode {83impl Into<u8> for CollectionMode {
78 fn into(self) -> u8 {84 fn into(self) -> u8 {
97 }103 }
98}104}
99
100impl Default for CollectionMode {
101 fn default() -> Self {
102 Self::Invalid
103 }
104}
105105
106#[derive(Encode, Decode, Eq, Debug, Clone, PartialEq)]106#[derive(Encode, Decode, Eq, Debug, Clone, PartialEq)]
107#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]107#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
209 pub fungible_sponsor_transfer_timeout: u32,209 pub fungible_sponsor_transfer_timeout: u32,
210 pub refungible_sponsor_transfer_timeout: u32,210 pub refungible_sponsor_transfer_timeout: u32,
211
212 // Schema limits
213 pub offchain_schema_limit: u32,
214 pub variable_on_chain_schema_limit: u32,
215 pub const_on_chain_schema_limit: u32,
211}216}
212217
213pub trait WeightInfo {218pub trait WeightInfo {
367 /// Account token limit exceeded per collection372 /// Account token limit exceeded per collection
368 AccountTokenLimitExceeded,373 AccountTokenLimitExceeded,
369 /// Collection limit bounds per collection exceeded374 /// Collection limit bounds per collection exceeded
370 CollectionLimitBoundsExceeded375 CollectionLimitBoundsExceeded,
376 /// Schema data size limit bound exceeded
377 SchemaDataLimitExceeded
371 }378 }
372}379}
373380
1281 let sender = ensure_signed(origin)?;1288 let sender = ensure_signed(origin)?;
1282 Self::check_owner_or_admin_permissions(collection_id, sender.clone())?;1289 Self::check_owner_or_admin_permissions(collection_id, sender.clone())?;
1290
1291 // check schema limit
1292 ensure!(schema.len() as u32 > ChainLimit::get().offchain_schema_limit, "");
12831293
1284 let mut target_collection = <Collection<T>>::get(collection_id);1294 let mut target_collection = <Collection<T>>::get(collection_id);
1285 target_collection.offchain_schema = schema;1295 target_collection.offchain_schema = schema;
1309 let sender = ensure_signed(origin)?;1319 let sender = ensure_signed(origin)?;
1310 Self::check_owner_or_admin_permissions(collection_id, sender.clone())?;1320 Self::check_owner_or_admin_permissions(collection_id, sender.clone())?;
1321
1322 // check schema limit
1323 ensure!(schema.len() as u32 > ChainLimit::get().const_on_chain_schema_limit, "");
13111324
1312 let mut target_collection = <Collection<T>>::get(collection_id);1325 let mut target_collection = <Collection<T>>::get(collection_id);
1313 target_collection.const_on_chain_schema = schema;1326 target_collection.const_on_chain_schema = schema;
1337 let sender = ensure_signed(origin)?;1350 let sender = ensure_signed(origin)?;
1338 Self::check_owner_or_admin_permissions(collection_id, sender.clone())?;1351 Self::check_owner_or_admin_permissions(collection_id, sender.clone())?;
1352
1353 // check schema limit
1354 ensure!(schema.len() as u32 > ChainLimit::get().variable_on_chain_schema_limit, "");
13391355
1340 let mut target_collection = <Collection<T>>::get(collection_id);1356 let mut target_collection = <Collection<T>>::get(collection_id);
1341 target_collection.variable_on_chain_schema = schema;1357 target_collection.variable_on_chain_schema = schema;