Skip to content

Commit 42e3392

Browse files
committed
Merge branch 'main' into feature/upgrade-polkadot-sdk-to-stable2407
2 parents 43737f3 + 791ea42 commit 42e3392

File tree

11 files changed

+96
-65
lines changed

11 files changed

+96
-65
lines changed

e2e-tests/tests/config.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ export const LOCAL_NODE_URL = "http://127.0.0.1:9999";
1515
// Chain config
1616
export const CHAIN_ID = 667;
1717
export const GAS_PRICE = "0x3B9ACA00";
18-
export const ETH_BLOCK_GAS_LIMIT = 15000000; // The same configuration as runtime
19-
export const GAS_LIMIT = ETH_BLOCK_GAS_LIMIT - 10000000; // TODO remove subtraction
2018

2119
// Accounts
2220
export const FAITH = "0xC0F0f4ab324C46e55D02D0033343B4Be8A55532d";

e2e-tests/tests/test-create-collection.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import Contract from "web3-eth-contract";
44
import {
55
EVOLUTION_COLLECTION_FACTORY_CONTRACT_ADDRESS,
66
EVOLUTION_COLLECTION_FACTORY_ABI,
7-
GAS_LIMIT,
87
GAS_PRICE,
98
FAITH,
109
FAITH_PRIVATE_KEY,
@@ -27,7 +26,6 @@ describeWithExistingNode("Frontier RPC (Create Collection)", (context) => {
2726
{
2827
from: FAITH,
2928
gasPrice: GAS_PRICE,
30-
gas: GAS_LIMIT,
3129
}
3230
);
3331
context.web3.eth.accounts.wallet.add(FAITH_PRIVATE_KEY);
@@ -42,9 +40,10 @@ describeWithExistingNode("Frontier RPC (Create Collection)", (context) => {
4240
});
4341

4442
step("when collection is created event is emitted", async function () {
43+
const estimatedGas = await contract.methods.createCollection(FAITH).estimateGas();
4544
const result = await contract.methods.createCollection(FAITH).send({
4645
from: FAITH,
47-
gas: GAS_LIMIT,
46+
gas: estimatedGas,
4847
gasPrice: GAS_PRICE,
4948
});
5049
expect(result.status).to.be.eq(true);

e2e-tests/tests/test-evolution.ts

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,9 @@
1+
import { createCollection, describeWithExistingNode, slotAndOwnerToTokenId } from "./util";
12
import {
2-
addressToCollectionId,
3-
createCollection,
4-
describeWithExistingNode,
5-
extractRevertReason,
6-
slotAndOwnerToTokenId,
7-
} from "./util";
8-
import {
9-
GAS_LIMIT,
103
FAITH,
114
SELECTOR_LOG_EVOLVED_WITH_EXTERNAL_TOKEN_URI,
125
SELECTOR_LOG_MINTED_WITH_EXTERNAL_TOKEN_URI,
136
SELECTOR_LOG_OWNERSHIP_TRANSFERRED,
14-
SELECTOR_LOG_PUBLIC_MINTING_ENABLED,
15-
SELECTOR_LOG_PUBLIC_MINTING_DISABLED,
16-
ALITH,
17-
ALITH_PRIVATE_KEY,
187
} from "./config";
198
import { expect } from "chai";
209
import Contract from "web3-eth-contract";
@@ -47,9 +36,10 @@ describeWithExistingNode("Frontier RPC (Mint and Evolve Assets)", (context) => {
4736
const tokenURI = "https://example.com";
4837

4938
let nonce = await context.web3.eth.getTransactionCount(FAITH);
39+
const estimatedGas = await collectionContract.methods.mintWithExternalURI(to, slot, tokenURI).estimateGas();
5040
const result = await collectionContract.methods
5141
.mintWithExternalURI(to, slot, tokenURI)
52-
.send({ from: FAITH, gas: GAS_LIMIT, nonce: nonce++ });
42+
.send({ from: FAITH, gas: estimatedGas, nonce: nonce++ });
5343
expect(result.status).to.be.eq(true);
5444

5545
const tokenId = result.events.MintedWithExternalURI.returnValues._tokenId;
@@ -72,9 +62,10 @@ describeWithExistingNode("Frontier RPC (Mint and Evolve Assets)", (context) => {
7262
const to = FAITH;
7363
const tokenURI = "https://example.com";
7464

65+
const estimatedGas = await collectionContract.methods.mintWithExternalURI(to, slot, tokenURI).estimateGas();
7566
const result = await collectionContract.methods
7667
.mintWithExternalURI(to, slot, tokenURI)
77-
.send({ from: FAITH, gas: GAS_LIMIT });
68+
.send({ from: FAITH, gas: estimatedGas });
7869
expect(result.status).to.be.eq(true);
7970

8071
expect(Object.keys(result.events).length).to.be.eq(1);
@@ -108,14 +99,18 @@ describeWithExistingNode("Frontier RPC (Mint and Evolve Assets)", (context) => {
10899
const tokenId = slotAndOwnerToTokenId(slot, to);
109100
const tokenIdDecimal = new BN(tokenId, 16, "be").toString(10);
110101

102+
var estimatedGas = await collectionContract.methods.mintWithExternalURI(to, slot, tokenURI).estimateGas();
111103
const mintingResult = await collectionContract.methods
112104
.mintWithExternalURI(to, slot, tokenURI)
113-
.send({ from: FAITH, gas: GAS_LIMIT });
105+
.send({ from: FAITH, gas: estimatedGas });
114106
expect(mintingResult.status).to.be.eq(true);
115107

108+
estimatedGas = await collectionContract.methods
109+
.evolveWithExternalURI(tokenIdDecimal, newTokenURI)
110+
.estimateGas();
116111
const evolvingResult = await collectionContract.methods
117112
.evolveWithExternalURI(tokenIdDecimal, newTokenURI)
118-
.send({ from: FAITH, gas: GAS_LIMIT });
113+
.send({ from: FAITH, gas: estimatedGas });
119114
expect(evolvingResult.status).to.be.eq(true);
120115

121116
const got = await collectionContract.methods.tokenURI(tokenIdDecimal).call();
@@ -130,14 +125,18 @@ describeWithExistingNode("Frontier RPC (Mint and Evolve Assets)", (context) => {
130125
const tokenId = slotAndOwnerToTokenId(slot, to);
131126
const tokenIdDecimal = new BN(tokenId, 16, "be").toString(10);
132127

128+
var estimatedGas = await collectionContract.methods.mintWithExternalURI(to, slot, tokenURI).estimateGas();
133129
const mintingResult = await collectionContract.methods
134130
.mintWithExternalURI(to, slot, tokenURI)
135-
.send({ from: FAITH, gas: GAS_LIMIT });
131+
.send({ from: FAITH, gas: estimatedGas });
136132
expect(mintingResult.status).to.be.eq(true);
137133

134+
estimatedGas = await collectionContract.methods
135+
.evolveWithExternalURI(tokenIdDecimal, newTokenURI)
136+
.estimateGas();
138137
const evolvingResult = await collectionContract.methods
139138
.evolveWithExternalURI(tokenIdDecimal, newTokenURI)
140-
.send({ from: FAITH, gas: GAS_LIMIT });
139+
.send({ from: FAITH, gas: estimatedGas });
141140
expect(evolvingResult.status).to.be.eq(true);
142141

143142
expect(Object.keys(evolvingResult.events).length).to.be.eq(1);
@@ -171,9 +170,10 @@ describeWithExistingNode("Frontier RPC (Transfer Ownership)", (context) => {
171170
const newOwner = "0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac";
172171

173172
expect(await collectionContract.methods.owner().call()).to.be.eq(FAITH);
173+
const estimatedGas = await collectionContract.methods.transferOwnership(newOwner).estimateGas();
174174
const tranferringResult = await collectionContract.methods
175175
.transferOwnership(newOwner)
176-
.send({ from: FAITH, gas: GAS_LIMIT });
176+
.send({ from: FAITH, gas: estimatedGas });
177177
expect(tranferringResult.status).to.be.eq(true);
178178
expect(await collectionContract.methods.owner().call()).to.be.eq(newOwner);
179179

@@ -198,10 +198,13 @@ describeWithExistingNode("Frontier RPC (Transfer Ownership)", (context) => {
198198
expect(tranferringResult.events.OwnershipTransferred.raw.data).to.be.eq("0x");
199199

200200
try {
201-
await collectionContract.methods.transferOwnership(FAITH).send({ from: FAITH, gas: GAS_LIMIT });
201+
const estimatedGas = await collectionContract.methods.transferOwnership(FAITH).estimateGas();
202+
await collectionContract.methods.transferOwnership(FAITH).send({ from: FAITH, gas: estimatedGas });
202203
expect.fail("Expected error was not thrown"); // Ensure an error is thrown
203204
} catch (error) {
204-
expect(await extractRevertReason(context, error.receipt.transactionHash)).to.eq("NoPermission");
205+
expect(error.message).to.eq(
206+
"Returned error: VM Exception while processing transaction: revert NoPermission"
207+
);
205208
}
206209
});
207210
});

e2e-tests/tests/test-staking.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import { describeWithExistingNode } from "./util";
22
import {
3-
GAS_LIMIT,
43
ALITH,
54
STAKING_ABI,
65
STAKING_CONTRACT_ADDRESS,
7-
GAS_PRICE,
86
UNIT,
97
FAITH_PRIVATE_KEY,
108
FAITH,

e2e-tests/tests/test-update-extended-token-uri.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import Contract from "web3-eth-contract";
44
import {
55
ASSET_METADATA_EXTENDER_ADDRESS,
66
ASSET_METADATA_EXTENDER_ABI,
7-
GAS_LIMIT,
87
GAS_PRICE,
98
FAITH,
109
FAITH_PRIVATE_KEY,
@@ -20,7 +19,6 @@ describeWithExistingNode("Frontier RPC (Extend Token URI)", (context) => {
2019
contract = new context.web3.eth.Contract(ASSET_METADATA_EXTENDER_ABI, ASSET_METADATA_EXTENDER_ADDRESS, {
2120
from: FAITH,
2221
gasPrice: GAS_PRICE,
23-
gas: GAS_LIMIT,
2422
});
2523
context.web3.eth.accounts.wallet.add(FAITH_PRIVATE_KEY);
2624
});
@@ -36,9 +34,10 @@ describeWithExistingNode("Frontier RPC (Extend Token URI)", (context) => {
3634

3735
step("extend should return ok", async function () {
3836
let nonce = await context.web3.eth.getTransactionCount(FAITH);
37+
const estimatedGas = await contract.methods.extendULWithExternalURI(uloc, tokenURI).estimateGas();
3938
extendResult = await contract.methods.extendULWithExternalURI(uloc, tokenURI).send({
4039
from: FAITH,
41-
gas: GAS_LIMIT,
40+
gas: estimatedGas,
4241
gasPrice: GAS_PRICE,
4342
nonce: nonce++,
4443
});
@@ -94,15 +93,15 @@ describeWithExistingNode("Frontier RPC (Update Extended Token URI)", async (cont
9493
contract = new context.web3.eth.Contract(ASSET_METADATA_EXTENDER_ABI, ASSET_METADATA_EXTENDER_ADDRESS, {
9594
from: FAITH,
9695
gasPrice: GAS_PRICE,
97-
gas: GAS_LIMIT,
9896
});
9997
context.web3.eth.accounts.wallet.add(FAITH_PRIVATE_KEY);
10098

10199
// we first create an extension to be updated later
102100
let nonce = await context.web3.eth.getTransactionCount(FAITH);
101+
const estimatedGas = await contract.methods.extendULWithExternalURI(uloc, tokenURI).estimateGas();
103102
const createResult = await contract.methods.extendULWithExternalURI(uloc, tokenURI).send({
104103
from: FAITH,
105-
gas: GAS_LIMIT,
104+
gas: estimatedGas,
106105
gasPrice: GAS_PRICE,
107106
nonce: nonce++,
108107
});
@@ -119,9 +118,10 @@ describeWithExistingNode("Frontier RPC (Update Extended Token URI)", async (cont
119118

120119
step("update extension should return ok", async function () {
121120
let nonce = await context.web3.eth.getTransactionCount(FAITH);
121+
const estimatedGas = await contract.methods.updateExtendedULWithExternalURI(uloc, newTokenURI).estimateGas();
122122
updateExtensionResult = await contract.methods.updateExtendedULWithExternalURI(uloc, newTokenURI).send({
123123
from: FAITH,
124-
gas: GAS_LIMIT,
124+
gas: estimatedGas,
125125
gasPrice: GAS_PRICE,
126126
nonce: nonce++,
127127
});

e2e-tests/tests/test-vesting.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,20 @@ import Contract from "web3-eth-contract";
44
import {
55
VESTING_CONTRACT_ADDRESS,
66
VESTING_ABI,
7-
GAS_LIMIT,
87
GAS_PRICE,
98
FAITH,
109
FAITH_PRIVATE_KEY,
1110
ALITH,
1211
ALITH_PRIVATE_KEY,
1312
} from "./config";
14-
import { describeWithExistingNode, extractRevertReason } from "./util";
15-
import Web3 from "web3";
13+
import { describeWithExistingNode } from "./util";
1614

1715
describeWithExistingNode("Frontier RPC (Vesting)", (context) => {
1816
let contract: Contract;
1917

2018
before(async function () {
2119
contract = new context.web3.eth.Contract(VESTING_ABI, VESTING_CONTRACT_ADDRESS, {
22-
from: FAITH,
2320
gasPrice: GAS_PRICE,
24-
gas: GAS_LIMIT,
2521
});
2622
context.web3.eth.accounts.wallet.add(FAITH_PRIVATE_KEY);
2723
context.web3.eth.accounts.wallet.add(ALITH_PRIVATE_KEY);
@@ -34,10 +30,12 @@ describeWithExistingNode("Frontier RPC (Vesting)", (context) => {
3430
it("when there is no vesting do vest reverts", async function () {
3531
try {
3632
let nonce = await context.web3.eth.getTransactionCount(FAITH);
37-
await contract.methods.vest().send({ from: FAITH, gas: GAS_LIMIT, nonce: nonce++ });
33+
const estimatedGas = await contract.methods.vest().estimateGas();
34+
contract.options.from = FAITH;
35+
await contract.methods.vest().send({ from: FAITH, gas: estimatedGas, nonce: nonce++ });
3836
expect.fail("Expected error was not thrown"); // Ensure an error is thrown
3937
} catch (error) {
40-
expect(await extractRevertReason(context, error.receipt.transactionHash)).to.eq("NotVesting");
38+
expect(error.message).to.eq("Returned error: VM Exception while processing transaction: revert NotVesting");
4139
}
4240
});
4341
it("when vesting exists it returns the list", async function () {
@@ -50,12 +48,15 @@ describeWithExistingNode("Frontier RPC (Vesting)", (context) => {
5048
step("when vesting exists do vest returns ok", async function () {
5149
let nonce = await context.web3.eth.getTransactionCount(ALITH);
5250
contract.options.from = ALITH;
53-
let result = await contract.methods.vest().send({ from: ALITH, gas: GAS_LIMIT, nonce: nonce++ });
51+
const estimatedGas = await contract.methods.vest().estimateGas();
52+
let result = await contract.methods.vest().send({ from: ALITH, gas: estimatedGas, nonce: nonce++ });
5453
expect(result.status).to.be.eq(true);
5554
});
5655
step("when vesting exists do vestOther returns ok", async function () {
5756
let nonce = await context.web3.eth.getTransactionCount(FAITH);
58-
let result = await contract.methods.vestOther(ALITH).send({ from: FAITH, gas: GAS_LIMIT, nonce: nonce++ });
57+
contract.options.from = FAITH;
58+
const estimatedGas = await contract.methods.vestOther(ALITH).estimateGas();
59+
let result = await contract.methods.vestOther(ALITH).send({ from: FAITH, gas: estimatedGas, nonce: nonce++ });
5960
expect(result.status).to.be.eq(true);
6061
});
6162
});

e2e-tests/tests/util.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import Web3 from "web3";
44
import { JsonRpcResponse } from "web3-core-helpers";
55
import {
66
EVOLUTION_COLLECTION_FACTORY_CONTRACT_ADDRESS,
7-
GAS_LIMIT,
87
GAS_PRICE,
98
FAITH,
109
FAITH_PRIVATE_KEY,
@@ -87,9 +86,10 @@ export async function createCollection(context: { web3: Web3 }): Promise<Contrac
8786

8887
let nonce = await context.web3.eth.getTransactionCount(FAITH);
8988
context.web3.eth.accounts.wallet.add(FAITH_PRIVATE_KEY);
89+
const estimatedGas = await contract.methods.createCollection(FAITH).estimateGas();
9090
const result = await contract.methods.createCollection(FAITH).send({
9191
from: FAITH,
92-
gas: GAS_LIMIT,
92+
gas: estimatedGas,
9393
gasPrice: GAS_PRICE,
9494
nonce: nonce++,
9595
});
@@ -101,7 +101,6 @@ export async function createCollection(context: { web3: Web3 }): Promise<Contrac
101101
result.events.NewCollection.returnValues._collectionAddress,
102102
{
103103
from: FAITH,
104-
gas: GAS_LIMIT,
105104
gasPrice: GAS_PRICE,
106105
}
107106
);

pallets/precompiles-benchmark/src/precompiles/vesting/benchmarking.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -123,15 +123,6 @@ type BalanceOf<Runtime> = <<Runtime as pallet_vesting::Config>::Currency as Curr
123123
<Runtime as frame_system::Config>::AccountId,
124124
>>::Balance;
125125

126-
/*
127-
* Allow directive added because when the macro expands, `T` has constraints in
128-
* multiple locations. This is what the expanded code looks like:
129-
* ```
130-
* fn _precompile_vest<T: Config>(verify: bool)
131-
* where
132-
* T: Config + pallet_vesting: Config,
133-
* ```
134-
*/
135126
#[benchmarks(
136127
where
137128
T: Config + pallet_vesting::Config,

0 commit comments

Comments
 (0)