Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: bump ethers to v6.7.1 #141

Merged
merged 9 commits into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 19 additions & 10 deletions benchmark/GasCostBenchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ const getCumulativeGasUsed = async (tx) => {

if (tx.deployTransaction) {
receipt = await tx.deployTransaction.wait();
cumulativeGasUsed = receipt.cumulativeGasUsed.toNumber();
cumulativeGasUsed = Number(receipt.cumulativeGasUsed);
} else {
receipt = await tx.wait();
cumulativeGasUsed = await receipt.cumulativeGasUsed.toNumber();
cumulativeGasUsed = Number(receipt.cumulativeGasUsed);
}

return cumulativeGasUsed;
Expand All @@ -61,12 +61,20 @@ describe("Gas Cost Benchmarks", () => {
});
};

const benchmarkTransfer = async (contractName, contractInstance, accounts) => {
const tx = await contractInstance.transferOwnership(accounts[2].address);
recordGasCost(contractName, "transferOwnership", await getCumulativeGasUsed(tx));
const benchmarkGrantRole = async (contractName, contractInstance, accounts) => {
const tx = await contractInstance.grantRole(ethers.ZeroHash, accounts[2].address);
recordGasCost(contractName, "grantRole", await getCumulativeGasUsed(tx));

// Revert the owner by transferring back
await contractInstance.connect(accounts[2]).transferOwnership(accounts[0].address);
// Revert the change by revoking role
await contractInstance.connect(accounts[0]).revokeRole(ethers.ZeroHash, accounts[2].address);
};

const benchmarkRevokeRole = async (contractName, contractInstance, accounts) => {
// Setup by granting role
await contractInstance.connect(accounts[0]).grantRole(ethers.ZeroHash, accounts[2].address);

const tx = await contractInstance.revokeRole(ethers.ZeroHash, accounts[2].address);
recordGasCost(contractName, "revokeRole", await getCumulativeGasUsed(tx));
};

const benchmarkIssue = async (contractName, contractInstance) => {
Expand Down Expand Up @@ -152,7 +160,7 @@ describe("Gas Cost Benchmarks", () => {
it("runs benchmark", async () => {
// Deploy & initialize document store contract
const documentStoreInstance = await DocumentStore.deploy(contractName, Accounts[0].address);
const tx = await documentStoreInstance.deployed();
const tx = await documentStoreInstance.deploymentTransaction();
recordGasCost(contractName, "deployment", await getCumulativeGasUsed(tx));

// const documentStoreInstance = await UpgradableDocumentStore.deploy();
Expand All @@ -163,7 +171,8 @@ describe("Gas Cost Benchmarks", () => {
// (await getCumulativeGasUsed(documentStoreInstance)) + (await getCumulativeGasUsed(initializeTx))
// );

await benchmarkTransfer(contractName, documentStoreInstance, Accounts);
await benchmarkGrantRole(contractName, documentStoreInstance, Accounts);
await benchmarkRevokeRole(contractName, documentStoreInstance, Accounts);
await benchmarkIssue(contractName, documentStoreInstance);
await benchmarkBulkIssue(contractName, documentStoreInstance);
await benchmarkRevoke(contractName, documentStoreInstance);
Expand All @@ -174,7 +183,7 @@ describe("Gas Cost Benchmarks", () => {
describe("DocumentStoreCreator", () => {
it("runs benchmark", async () => {
const documentStoreCreatorInstance = await DocumentStoreCreator.deploy();
const tx = await documentStoreCreatorInstance.deployed();
const tx = await documentStoreCreatorInstance.deploymentTransaction();
recordGasCost("DocumentStoreCreator", "deployment", await getCumulativeGasUsed(tx));
});
});
Expand Down
4 changes: 2 additions & 2 deletions hardhat.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable import/no-extraneous-dependencies */

require("@nomiclabs/hardhat-waffle");
require("hardhat-typechain");
require("@nomicfoundation/hardhat-toolbox");
require("@typechain/hardhat");

/**
* @type import('hardhat/config').HardhatUserConfig
Expand Down
Loading