git.delta.rocks / unique-network / refs/commits / 6f9bef9c71c9

difftreelog

fix max create multiple items

Daniel Shiposha2023-10-16parent: #71be677.patch.diff
in: master

2 files changed

modifiedprimitives/data-structs/src/lib.rsdiffbeforeafterboth
--- a/primitives/data-structs/src/lib.rs
+++ b/primitives/data-structs/src/lib.rs
@@ -135,7 +135,7 @@
 
 /// How much items can be created per single
 /// create_many call.
-pub const MAX_ITEMS_PER_BATCH: u32 = 200;
+pub const MAX_ITEMS_PER_BATCH: u32 = 120;
 
 /// Used for limit bounded types of token custom data.
 pub type CustomDataLimit = ConstU32<CUSTOM_DATA_LIMIT>;
modifiedtests/src/performance.seq.test.tsdiffbeforeafterboth
2222
23describe('Performace tests', () => {23describe('Performace tests', () => {
24 let alice: IKeyringPair;24 let alice: IKeyringPair;
25 const MAX_TOKENS_TO_MINT = 200;25 const MAX_TOKENS_TO_MINT = 120;
2626
27 before(async () => {27 before(async () => {
28 await usingPlaygrounds(async (helper, privateKey) => {28 await usingPlaygrounds(async (helper, privateKey) => {
43 });43 });
4444
45
46 const results = [];
47 const step = 1_000;45 const step = 1_000;
48 const sizeOfKey = sizeOfEncodedStr(propertyKey);46 const sizeOfKey = sizeOfEncodedStr(propertyKey);
49 let currentSize = step;47 let currentSize = step;
57 minterFunc = tryMintExplicit;55 minterFunc = tryMintExplicit;
58 }56 }
57
59 results.push({propertySize: 0, tokens: startCount});58 expect(startCount).to.be.equal(MAX_TOKENS_TO_MINT);
6059
61 while(currentSize <= 32_000) {60 while(currentSize <= 32_000) {
62 const property = {key: propertyKey, value: 'A'.repeat(currentSize - sizeOfKey - sizeOfInt(currentSize))};61 const property = {key: propertyKey, value: 'A'.repeat(currentSize - sizeOfKey - sizeOfInt(currentSize))};
63 const maxTokens = Math.ceil(results.map(x => x.tokens).reduce((a, b) => a + b) / results.length);
64 const tokens = await minterFunc(helper, alice, maxTokens, collection.collectionId, {Substrate: alice.address}, property);62 const tokens = await minterFunc(helper, alice, MAX_TOKENS_TO_MINT, collection.collectionId, {Substrate: alice.address}, property);
65 results.push({propertySize: sizeOfProperty(property), tokens});63 expect(tokens).to.be.equal(MAX_TOKENS_TO_MINT);
64
66 currentSize += step;65 currentSize += step;
67 await helper.wait.newBlocks(2);66 await helper.wait.newBlocks(2);
68 }67 }
69
70 expect(results).to.be.deep.equal([
71 {propertySize: 0, tokens: 200},
72 {propertySize: 1000, tokens: 149},
73 {propertySize: 2000, tokens: 149},
74 {propertySize: 3000, tokens: 149},
75 {propertySize: 4000, tokens: 149},
76 {propertySize: 5000, tokens: 149},
77 {propertySize: 6000, tokens: 149},
78 {propertySize: 7000, tokens: 149},
79 {propertySize: 8000, tokens: 149},
80 {propertySize: 9000, tokens: 149},
81 {propertySize: 10000, tokens: 149},
82 {propertySize: 11000, tokens: 149},
83 {propertySize: 12000, tokens: 149},
84 {propertySize: 13000, tokens: 149},
85 {propertySize: 14000, tokens: 149},
86 {propertySize: 15000, tokens: 149},
87 {propertySize: 16000, tokens: 149},
88 {propertySize: 17000, tokens: 149},
89 {propertySize: 18000, tokens: 149},
90 {propertySize: 19000, tokens: 149},
91 {propertySize: 20000, tokens: 149},
92 {propertySize: 21000, tokens: 149},
93 {propertySize: 22000, tokens: 149},
94 {propertySize: 23000, tokens: 149},
95 {propertySize: 24000, tokens: 149},
96 {propertySize: 25000, tokens: 149},
97 {propertySize: 26000, tokens: 149},
98 {propertySize: 27000, tokens: 145},
99 {propertySize: 28000, tokens: 140},
100 {propertySize: 29000, tokens: 135},
101 {propertySize: 30000, tokens: 130},
102 {propertySize: 31000, tokens: 126},
103 {propertySize: 32000, tokens: 122},
104 ]);
105 });68 });
106});69});
10770