From 0b5530db4d84bbc245c563cdcf6237cfdba5f960 Mon Sep 17 00:00:00 2001 From: dk1a Date: Tue, 11 Jul 2023 16:48:32 +0300 Subject: [PATCH 01/11] feat(gas-reporter): create package, move relevant files to it --- packages/cli/package.json | 3 +- packages/cli/src/commands/index.ts | 5 +- packages/gas-reporter/.gitignore | 11 +++ packages/gas-reporter/.npmignore | 9 +++ packages/gas-reporter/.solhint.json | 8 +++ packages/gas-reporter/CHANGELOG.md | 4 ++ packages/gas-reporter/README.md | 1 + packages/gas-reporter/foundry.toml | 11 +++ packages/gas-reporter/package.json | 49 +++++++++++++ packages/gas-reporter/remappings.txt | 2 + .../test => gas-reporter/src}/GasReporter.sol | 0 .../test/GasReporter.t.sol | 2 +- .../ts/index.ts} | 0 packages/gas-reporter/ts/mud-gas-report.ts | 31 +++++++++ packages/gas-reporter/tsconfig.json | 20 ++++++ packages/gas-reporter/tsup.config.ts | 11 +++ pnpm-lock.yaml | 68 +++++++++++++++---- 17 files changed, 215 insertions(+), 20 deletions(-) create mode 100644 packages/gas-reporter/.gitignore create mode 100644 packages/gas-reporter/.npmignore create mode 100644 packages/gas-reporter/.solhint.json create mode 100644 packages/gas-reporter/CHANGELOG.md create mode 100644 packages/gas-reporter/README.md create mode 100644 packages/gas-reporter/foundry.toml create mode 100644 packages/gas-reporter/package.json create mode 100644 packages/gas-reporter/remappings.txt rename packages/{std-contracts/src/test => gas-reporter/src}/GasReporter.sol (100%) rename packages/{std-contracts => gas-reporter}/test/GasReporter.t.sol (88%) rename packages/{cli/src/commands/gas-report.ts => gas-reporter/ts/index.ts} (100%) create mode 100755 packages/gas-reporter/ts/mud-gas-report.ts create mode 100644 packages/gas-reporter/tsconfig.json create mode 100644 packages/gas-reporter/tsup.config.ts diff --git a/packages/cli/package.json b/packages/cli/package.json index 6c94e5b3c4..a27a7be1c1 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -33,6 +33,7 @@ "@improbable-eng/grpc-web-node-http-transport": "^0.15.0", "@latticexyz/common": "workspace:*", "@latticexyz/config": "workspace:*", + "@latticexyz/gas-reporter": "workspace:*", "@latticexyz/schema-type": "workspace:*", "@latticexyz/services": "workspace:*", "@latticexyz/solecs": "workspace:*", @@ -51,8 +52,6 @@ "nice-grpc-web": "^2.0.1", "openurl": "^1.1.1", "path": "^0.12.7", - "strip-ansi": "^7.1.0", - "table": "^6.8.1", "throttle-debounce": "^5.0.0", "typechain": "^8.1.1", "typescript": "^4.9.5", diff --git a/packages/cli/src/commands/index.ts b/packages/cli/src/commands/index.ts index 69177e2863..d9c5f3f71e 100644 --- a/packages/cli/src/commands/index.ts +++ b/packages/cli/src/commands/index.ts @@ -1,8 +1,9 @@ import { CommandModule } from "yargs"; +import gasReport from "@latticexyz/gas-reporter"; + import devnode from "./devnode"; import faucet from "./faucet"; -import gasReport from "./gas-report"; import hello from "./hello"; import tablegen from "./tablegen"; import tsgen from "./tsgen"; @@ -18,7 +19,7 @@ export const commands: CommandModule[] = [ deploy, devnode, faucet, - gasReport, + gasReport as CommandModule, hello, tablegen, tsgen, diff --git a/packages/gas-reporter/.gitignore b/packages/gas-reporter/.gitignore new file mode 100644 index 0000000000..574cef0484 --- /dev/null +++ b/packages/gas-reporter/.gitignore @@ -0,0 +1,11 @@ +cache +abi +out +docs +_docs +DOCS.md +artifacts +yarn-error.log +API +dist +types/ethers-contracts diff --git a/packages/gas-reporter/.npmignore b/packages/gas-reporter/.npmignore new file mode 100644 index 0000000000..523900e14e --- /dev/null +++ b/packages/gas-reporter/.npmignore @@ -0,0 +1,9 @@ +* + +!abi/** +!src/** +!ts/** +!types/** +!package.json +!README.md +!dist/** diff --git a/packages/gas-reporter/.solhint.json b/packages/gas-reporter/.solhint.json new file mode 100644 index 0000000000..4e2baa8be7 --- /dev/null +++ b/packages/gas-reporter/.solhint.json @@ -0,0 +1,8 @@ +{ + "extends": "solhint:recommended", + "rules": { + "compiler-version": ["error", ">=0.8.0"], + "avoid-low-level-calls": "off", + "func-visibility": ["warn", { "ignoreConstructors": true }] + } +} diff --git a/packages/gas-reporter/CHANGELOG.md b/packages/gas-reporter/CHANGELOG.md new file mode 100644 index 0000000000..e4d87c4d45 --- /dev/null +++ b/packages/gas-reporter/CHANGELOG.md @@ -0,0 +1,4 @@ +# Change Log + +All notable changes to this project will be documented in this file. +See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. diff --git a/packages/gas-reporter/README.md b/packages/gas-reporter/README.md new file mode 100644 index 0000000000..2411999e66 --- /dev/null +++ b/packages/gas-reporter/README.md @@ -0,0 +1 @@ +# Gas Reporter diff --git a/packages/gas-reporter/foundry.toml b/packages/gas-reporter/foundry.toml new file mode 100644 index 0000000000..9489e40e2a --- /dev/null +++ b/packages/gas-reporter/foundry.toml @@ -0,0 +1,11 @@ +[profile.default] +solc_version = '0.8.13' +ffi = false +fuzz_runs = 256 +optimizer = true +optimizer_runs = 3000 +verbosity = 2 +allow_paths= ["../../node_modules"] +src = "src" +out = "out" +bytecode_hash = "none" diff --git a/packages/gas-reporter/package.json b/packages/gas-reporter/package.json new file mode 100644 index 0000000000..dcb35cfd21 --- /dev/null +++ b/packages/gas-reporter/package.json @@ -0,0 +1,49 @@ +{ + "name": "@latticexyz/gas-reporter", + "version": "1.42.0", + "description": "Gas Reporter", + "repository": { + "type": "git", + "url": "https://github.com/latticexyz/mud.git", + "directory": "packages/gas-reporter" + }, + "license": "MIT", + "type": "module", + "exports": { + ".": "./dist/index.js" + }, + "typesVersions": { + "*": { + "index": [ + "./ts/index.ts" + ] + } + }, + "bin": { + "mud-gas-report": "./dist/mud-gas-report.js" + }, + "scripts": { + "build": "tsup", + "clean": "rimraf dist", + "dev": "tsup --watch", + "test": "vitest typecheck --run --passWithNoTests && vitest --run --passWithNoTests && forge test" + }, + "dependencies": { + "chalk": "^5.3.0", + "dotenv": "^16.0.3", + "execa": "^7.0.0", + "strip-ansi": "^7.1.0", + "table": "^6.8.1", + "yargs": "^17.7.1" + }, + "devDependencies": { + "@types/node": "^18.15.11", + "@types/yargs": "^17.0.10", + "ds-test": "https://github.com/dapphub/ds-test.git#c9ce3f25bde29fc5eb9901842bf02850dfd2d084", + "forge-std": "https://github.com/foundry-rs/forge-std.git#b4f121555729b3afb3c5ffccb62ff4b6e2818fd3", + "rimraf": "^3.0.2", + "tsup": "^6.7.0", + "vitest": "0.31.4" + }, + "gitHead": "914a1e0ae4a573d685841ca2ea921435057deb8f" +} diff --git a/packages/gas-reporter/remappings.txt b/packages/gas-reporter/remappings.txt new file mode 100644 index 0000000000..fff7781446 --- /dev/null +++ b/packages/gas-reporter/remappings.txt @@ -0,0 +1,2 @@ +ds-test/=node_modules/ds-test/src/ +forge-std/=node_modules/forge-std/src/ diff --git a/packages/std-contracts/src/test/GasReporter.sol b/packages/gas-reporter/src/GasReporter.sol similarity index 100% rename from packages/std-contracts/src/test/GasReporter.sol rename to packages/gas-reporter/src/GasReporter.sol diff --git a/packages/std-contracts/test/GasReporter.t.sol b/packages/gas-reporter/test/GasReporter.t.sol similarity index 88% rename from packages/std-contracts/test/GasReporter.t.sol rename to packages/gas-reporter/test/GasReporter.t.sol index 993dd63536..0780642d12 100644 --- a/packages/std-contracts/test/GasReporter.t.sol +++ b/packages/gas-reporter/test/GasReporter.t.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.0; import { Test } from "forge-std/Test.sol"; -import { GasReporter } from "../src/test/GasReporter.sol"; +import { GasReporter } from "../src/GasReporter.sol"; contract GasReporterTest is Test, GasReporter { function testGasReporterGas() public { diff --git a/packages/cli/src/commands/gas-report.ts b/packages/gas-reporter/ts/index.ts similarity index 100% rename from packages/cli/src/commands/gas-report.ts rename to packages/gas-reporter/ts/index.ts diff --git a/packages/gas-reporter/ts/mud-gas-report.ts b/packages/gas-reporter/ts/mud-gas-report.ts new file mode 100755 index 0000000000..9205beb5f9 --- /dev/null +++ b/packages/gas-reporter/ts/mud-gas-report.ts @@ -0,0 +1,31 @@ +#!/usr/bin/env node + +import yargs from "yargs"; +import { hideBin } from "yargs/helpers"; +import gasReport from "."; + +// Load .env file into process.env +import * as dotenv from "dotenv"; +import chalk from "chalk"; +dotenv.config(); + +yargs(hideBin(process.argv)) + .scriptName("gas-report") + // Use the commands directory to scaffold + // eslint-disable-next-line @typescript-eslint/no-explicit-any -- command array overload isn't typed, see https://github.com/yargs/yargs/blob/main/docs/advanced.md#esm-hierarchy + .command(gasReport as any) + // Enable strict mode. + .strict() + // Custom error handler + .fail((msg, err) => { + console.error(chalk.red(msg)); + if (msg.includes("Missing required argument")) { + console.log( + chalk.yellow(`Run 'pnpm mud ${process.argv[2]} --help' for a list of available and required arguments.`) + ); + } + + process.exit(1); + }) + // Useful aliases. + .alias({ h: "help" }).argv; diff --git a/packages/gas-reporter/tsconfig.json b/packages/gas-reporter/tsconfig.json new file mode 100644 index 0000000000..5e655de9b7 --- /dev/null +++ b/packages/gas-reporter/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + /* Visit https://aka.ms/tsconfig.json to read more about this file */ + "target": "es2021", + "types": ["node"], + "module": "esnext", + "moduleResolution": "node", + "declaration": true, + "sourceMap": true, + "rootDir": ".", + "outDir": "dist", + "isolatedModules": true, + "allowSyntheticDefaultImports": true, + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "strict": true, + "skipLibCheck": true + }, + "include": ["ts"] +} diff --git a/packages/gas-reporter/tsup.config.ts b/packages/gas-reporter/tsup.config.ts new file mode 100644 index 0000000000..1f0444cc6e --- /dev/null +++ b/packages/gas-reporter/tsup.config.ts @@ -0,0 +1,11 @@ +import { defineConfig } from "tsup"; + +export default defineConfig({ + entry: ["ts/index.ts", "ts/mud-gas-report.ts"], + target: "esnext", + format: ["esm"], + dts: false, + sourcemap: true, + clean: true, + minify: true, +}); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e129aa01e7..49028d2717 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,4 +1,4 @@ -lockfileVersion: '6.1' +lockfileVersion: '6.0' settings: autoInstallPeers: true @@ -102,6 +102,9 @@ importers: '@latticexyz/config': specifier: workspace:* version: link:../config + '@latticexyz/gas-reporter': + specifier: workspace:* + version: link:../gas-reporter '@latticexyz/schema-type': specifier: workspace:* version: link:../schema-type @@ -156,12 +159,6 @@ importers: path: specifier: ^0.12.7 version: 0.12.7 - strip-ansi: - specifier: ^7.1.0 - version: 7.1.0 - table: - specifier: ^6.8.1 - version: 6.8.1 throttle-debounce: specifier: ^5.0.0 version: 5.0.0 @@ -412,6 +409,49 @@ importers: specifier: ^6.7.0 version: 6.7.0(typescript@4.9.5) + packages/gas-reporter: + dependencies: + chalk: + specifier: ^5.3.0 + version: 5.3.0 + dotenv: + specifier: ^16.0.3 + version: 16.0.3 + execa: + specifier: ^7.0.0 + version: 7.0.0 + strip-ansi: + specifier: ^7.1.0 + version: 7.1.0 + table: + specifier: ^6.8.1 + version: 6.8.1 + yargs: + specifier: ^17.7.1 + version: 17.7.1 + devDependencies: + '@types/node': + specifier: ^18.15.11 + version: 18.15.11 + '@types/yargs': + specifier: ^17.0.10 + version: 17.0.24 + ds-test: + specifier: https://github.com/dapphub/ds-test.git#c9ce3f25bde29fc5eb9901842bf02850dfd2d084 + version: github.com/dapphub/ds-test/c9ce3f25bde29fc5eb9901842bf02850dfd2d084 + forge-std: + specifier: https://github.com/foundry-rs/forge-std.git#b4f121555729b3afb3c5ffccb62ff4b6e2818fd3 + version: github.com/foundry-rs/forge-std/b4f121555729b3afb3c5ffccb62ff4b6e2818fd3 + rimraf: + specifier: ^3.0.2 + version: 3.0.2 + tsup: + specifier: ^6.7.0 + version: 6.7.0(typescript@4.9.5) + vitest: + specifier: 0.31.4 + version: 0.31.4 + packages/network: dependencies: '@ethersproject/abi': @@ -1236,13 +1276,6 @@ packages: '@jridgewell/trace-mapping': 0.3.18 dev: true - /@babel/code-frame@7.18.6: - resolution: {integrity: sha512-TDCmlK5eOvH+eH7cdAFlNXeVJqWIQ7gW9tY1GJIpUtFb6CmjVyq2VM3u71bOyR8CRihcCgMUYoDNyLXao3+70Q==} - engines: {node: '>=6.9.0'} - dependencies: - '@babel/highlight': 7.18.6 - dev: true - /@babel/code-frame@7.21.4: resolution: {integrity: sha512-LYvhNKfwWSPpocw8GI7gpK2nq3HSDuEPC/uSYaALSJu9xjsalaaYFOq0Pwt5KmVqwEbZlDu81aLXwBOmD/Fv9g==} engines: {node: '>=6.9.0'} @@ -4592,6 +4625,11 @@ packages: resolution: {integrity: sha512-ree3Gqw/nazQAPuJJEy+avdl7QfZMcUvmHIKgEZkGL+xOBzRvup5Hxo6LHuMceSxOabuJLJm5Yp/92R9eMmMvA==} engines: {node: ^12.17.0 || ^14.13 || >=16.0.0} + /chalk@5.3.0: + resolution: {integrity: sha512-dLitG79d+GV1Nb/VYcCDFivJeK1hiukt9QjRNVOsUtTy1rR1YJsmpGGTZ3qJos+uw7WmWF4wUwBd9jxjocFC2w==} + engines: {node: ^12.17.0 || ^14.13 || >=16.0.0} + dev: false + /char-regex@1.0.2: resolution: {integrity: sha512-kWWXztvZ5SBQV+eRgKFeh8q5sLuZY2+8WUIzlxWVTg+oGwY14qylx1KbKzHd8P6ZYkAg0xyIDU9JMHhyJMZ1jw==} engines: {node: '>=10'} @@ -5542,7 +5580,7 @@ packages: engines: {node: ^6.14.0 || ^8.10.0 || >=9.10.0} hasBin: true dependencies: - '@babel/code-frame': 7.18.6 + '@babel/code-frame': 7.21.4 ajv: 6.12.6 chalk: 2.4.2 cross-spawn: 6.0.5 From 41f8ae115f37eec27f85a0dd6d5d7988903c942b Mon Sep 17 00:00:00 2001 From: dk1a Date: Tue, 11 Jul 2023 17:30:17 +0300 Subject: [PATCH 02/11] make gas-report a default command for mud-gas-report --- packages/gas-reporter/ts/mud-gas-report.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/gas-reporter/ts/mud-gas-report.ts b/packages/gas-reporter/ts/mud-gas-report.ts index 9205beb5f9..a65e95a086 100755 --- a/packages/gas-reporter/ts/mud-gas-report.ts +++ b/packages/gas-reporter/ts/mud-gas-report.ts @@ -9,8 +9,12 @@ import * as dotenv from "dotenv"; import chalk from "chalk"; dotenv.config(); +// $0 makes this a default command (as opposed to a sub-command), +// which replaces `mud-gas-report gas-report` with just `mud-gas-report` +gasReport.command = "$0"; + yargs(hideBin(process.argv)) - .scriptName("gas-report") + .scriptName("mud-gas-report") // Use the commands directory to scaffold // eslint-disable-next-line @typescript-eslint/no-explicit-any -- command array overload isn't typed, see https://github.com/yargs/yargs/blob/main/docs/advanced.md#esm-hierarchy .command(gasReport as any) From 6bd903eb8a0e838a002b7e37e870cb043a1ea416 Mon Sep 17 00:00:00 2001 From: dk1a Date: Tue, 11 Jul 2023 17:31:04 +0300 Subject: [PATCH 03/11] refactor(store): use gas-reporter --- packages/store/package.json | 3 ++- packages/store/test/Bytes.t.sol | 2 +- packages/store/test/Gas.t.sol | 2 +- packages/store/test/KeyEncoding.t.sol | 2 +- packages/store/test/Mixed.t.sol | 2 +- packages/store/test/PackedCounter.t.sol | 2 +- packages/store/test/Schema.t.sol | 2 +- packages/store/test/Slice.t.sol | 2 +- packages/store/test/Storage.t.sol | 2 +- packages/store/test/StoreCoreDynamic.t.sol | 2 +- packages/store/test/StoreCoreGas.t.sol | 2 +- packages/store/test/StoreMetadata.t.sol | 2 +- packages/store/test/StoreSwitch.t.sol | 2 +- packages/store/test/Vector2.t.sol | 2 +- packages/store/test/tables/Callbacks.t.sol | 2 +- packages/store/test/tables/Hooks.t.sol | 2 +- packages/store/test/tightcoder/DecodeSlice.t.sol | 2 +- packages/store/test/tightcoder/EncodeArray.t.sol | 2 +- packages/store/test/tightcoder/TightCoder.t.sol | 2 +- pnpm-lock.yaml | 3 +++ 20 files changed, 23 insertions(+), 19 deletions(-) diff --git a/packages/store/package.json b/packages/store/package.json index bab6b295ee..68affb2a04 100644 --- a/packages/store/package.json +++ b/packages/store/package.json @@ -46,7 +46,7 @@ "clean:typechain": "rimraf types", "dev": "tsup --watch", "docs": "rimraf API && hardhat docgen", - "gas-report": "../cli/dist/mud.js gas-report --save gas-report.json", + "gas-report": "pnpm mud-gas-report --save gas-report.json", "generate-tightcoder": "tsx ./scripts/generate-tightcoder.ts && prettier --write '**/tightcoder/*.sol'", "lint": "solhint --config ./.solhint.json 'src/**/*.sol'", "test": "vitest typecheck --run && vitest --run --passWithNoTests && forge test" @@ -56,6 +56,7 @@ "@ethersproject/providers": "^5.7.2", "@latticexyz/common": "workspace:*", "@latticexyz/config": "workspace:*", + "@latticexyz/gas-reporter": "workspace:*", "@latticexyz/schema-type": "workspace:*", "abitype": "0.8.7", "ethers": "^5.7.2", diff --git a/packages/store/test/Bytes.t.sol b/packages/store/test/Bytes.t.sol index ca81dbb337..c502ff2cec 100644 --- a/packages/store/test/Bytes.t.sol +++ b/packages/store/test/Bytes.t.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.0; import { Test } from "forge-std/Test.sol"; -import { GasReporter } from "@latticexyz/std-contracts/src/test/GasReporter.sol"; +import { GasReporter } from "@latticexyz/gas-reporter/src/GasReporter.sol"; import { Bytes } from "../src/Bytes.sol"; contract BytesTest is Test, GasReporter { diff --git a/packages/store/test/Gas.t.sol b/packages/store/test/Gas.t.sol index e5663afda4..397b90b808 100644 --- a/packages/store/test/Gas.t.sol +++ b/packages/store/test/Gas.t.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.0; import { Test, console } from "forge-std/Test.sol"; -import { GasReporter } from "@latticexyz/std-contracts/src/test/GasReporter.sol"; +import { GasReporter } from "@latticexyz/gas-reporter/src/GasReporter.sol"; import { Bytes } from "../src/Bytes.sol"; import { SliceLib } from "../src/Slice.sol"; import { EncodeArray } from "../src/tightcoder/EncodeArray.sol"; diff --git a/packages/store/test/KeyEncoding.t.sol b/packages/store/test/KeyEncoding.t.sol index 9f6c5f8c03..e4b4a29ba6 100644 --- a/packages/store/test/KeyEncoding.t.sol +++ b/packages/store/test/KeyEncoding.t.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.0; import { Test } from "forge-std/Test.sol"; -import { GasReporter } from "@latticexyz/std-contracts/src/test/GasReporter.sol"; +import { GasReporter } from "@latticexyz/gas-reporter/src/GasReporter.sol"; import { KeyEncoding, KeyEncodingTableId } from "../src/codegen/Tables.sol"; import { ExampleEnum } from "../src/codegen/Types.sol"; import { StoreCore } from "../src/StoreCore.sol"; diff --git a/packages/store/test/Mixed.t.sol b/packages/store/test/Mixed.t.sol index c59375b3a7..0d4ae589c6 100644 --- a/packages/store/test/Mixed.t.sol +++ b/packages/store/test/Mixed.t.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.0; import { Test } from "forge-std/Test.sol"; -import { GasReporter } from "@latticexyz/std-contracts/src/test/GasReporter.sol"; +import { GasReporter } from "@latticexyz/gas-reporter/src/GasReporter.sol"; import { SchemaType } from "@latticexyz/schema-type/src/solidity/SchemaType.sol"; import { Mixed, MixedData, MixedTableId } from "../src/codegen/Tables.sol"; import { StoreCore } from "../src/StoreCore.sol"; diff --git a/packages/store/test/PackedCounter.t.sol b/packages/store/test/PackedCounter.t.sol index 542cc55e01..f599c72183 100644 --- a/packages/store/test/PackedCounter.t.sol +++ b/packages/store/test/PackedCounter.t.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.0; import { Test } from "forge-std/Test.sol"; -import { GasReporter } from "@latticexyz/std-contracts/src/test/GasReporter.sol"; +import { GasReporter } from "@latticexyz/gas-reporter/src/GasReporter.sol"; import { PackedCounter, PackedCounterLib } from "../src/PackedCounter.sol"; contract PackedCounterTest is Test, GasReporter { diff --git a/packages/store/test/Schema.t.sol b/packages/store/test/Schema.t.sol index d197f60116..8c75f7657e 100644 --- a/packages/store/test/Schema.t.sol +++ b/packages/store/test/Schema.t.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.0; import { Test, console } from "forge-std/Test.sol"; -import { GasReporter } from "@latticexyz/std-contracts/src/test/GasReporter.sol"; +import { GasReporter } from "@latticexyz/gas-reporter/src/GasReporter.sol"; import { SchemaType } from "@latticexyz/schema-type/src/solidity/SchemaType.sol"; import { Schema, SchemaLib } from "../src/Schema.sol"; diff --git a/packages/store/test/Slice.t.sol b/packages/store/test/Slice.t.sol index e7cd28c856..8050acdc0b 100644 --- a/packages/store/test/Slice.t.sol +++ b/packages/store/test/Slice.t.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.0; import { Test } from "forge-std/Test.sol"; -import { GasReporter } from "@latticexyz/std-contracts/src/test/GasReporter.sol"; +import { GasReporter } from "@latticexyz/gas-reporter/src/GasReporter.sol"; import { Memory } from "../src/Memory.sol"; import { Slice, SliceLib } from "../src/Slice.sol"; diff --git a/packages/store/test/Storage.t.sol b/packages/store/test/Storage.t.sol index c6bbcd2908..849d81e45e 100644 --- a/packages/store/test/Storage.t.sol +++ b/packages/store/test/Storage.t.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.0; import { Test } from "forge-std/Test.sol"; -import { GasReporter } from "@latticexyz/std-contracts/src/test/GasReporter.sol"; +import { GasReporter } from "@latticexyz/gas-reporter/src/GasReporter.sol"; import { Storage } from "../src/Storage.sol"; import { Utils } from "../src/Utils.sol"; import { Bytes } from "../src/Bytes.sol"; diff --git a/packages/store/test/StoreCoreDynamic.t.sol b/packages/store/test/StoreCoreDynamic.t.sol index b651059ff3..eb78b7d5d7 100644 --- a/packages/store/test/StoreCoreDynamic.t.sol +++ b/packages/store/test/StoreCoreDynamic.t.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.0; import { Test, console } from "forge-std/Test.sol"; -import { GasReporter } from "@latticexyz/std-contracts/src/test/GasReporter.sol"; +import { GasReporter } from "@latticexyz/gas-reporter/src/GasReporter.sol"; import { SchemaType } from "@latticexyz/schema-type/src/solidity/SchemaType.sol"; import { StoreCore } from "../src/StoreCore.sol"; import { SliceLib } from "../src/Slice.sol"; diff --git a/packages/store/test/StoreCoreGas.t.sol b/packages/store/test/StoreCoreGas.t.sol index a05d7257a9..5f4634bb0d 100644 --- a/packages/store/test/StoreCoreGas.t.sol +++ b/packages/store/test/StoreCoreGas.t.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.0; import { Test } from "forge-std/Test.sol"; -import { GasReporter } from "@latticexyz/std-contracts/src/test/GasReporter.sol"; +import { GasReporter } from "@latticexyz/gas-reporter/src/GasReporter.sol"; import { SchemaType } from "@latticexyz/schema-type/src/solidity/SchemaType.sol"; import { StoreCore, StoreCoreInternal } from "../src/StoreCore.sol"; import { Utils } from "../src/Utils.sol"; diff --git a/packages/store/test/StoreMetadata.t.sol b/packages/store/test/StoreMetadata.t.sol index 4d98cc10f1..ef2ef5196d 100644 --- a/packages/store/test/StoreMetadata.t.sol +++ b/packages/store/test/StoreMetadata.t.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.0; import { Test } from "forge-std/Test.sol"; -import { GasReporter } from "@latticexyz/std-contracts/src/test/GasReporter.sol"; +import { GasReporter } from "@latticexyz/gas-reporter/src/GasReporter.sol"; import { StoreMetadata, StoreMetadataData } from "../src/codegen/Tables.sol"; import { StoreCore } from "../src/StoreCore.sol"; import { StoreReadWithStubs } from "../src/StoreReadWithStubs.sol"; diff --git a/packages/store/test/StoreSwitch.t.sol b/packages/store/test/StoreSwitch.t.sol index 1d186136e7..4d81a983f8 100644 --- a/packages/store/test/StoreSwitch.t.sol +++ b/packages/store/test/StoreSwitch.t.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.0; import { Test } from "forge-std/Test.sol"; -import { GasReporter } from "@latticexyz/std-contracts/src/test/GasReporter.sol"; +import { GasReporter } from "@latticexyz/gas-reporter/src/GasReporter.sol"; import { StoreCore } from "../src/StoreCore.sol"; import { StoreReadWithStubs } from "../src/StoreReadWithStubs.sol"; import { StoreSwitch } from "../src/StoreSwitch.sol"; diff --git a/packages/store/test/Vector2.t.sol b/packages/store/test/Vector2.t.sol index 16791ddd8c..1973936e42 100644 --- a/packages/store/test/Vector2.t.sol +++ b/packages/store/test/Vector2.t.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.0; import { Test } from "forge-std/Test.sol"; -import { GasReporter } from "@latticexyz/std-contracts/src/test/GasReporter.sol"; +import { GasReporter } from "@latticexyz/gas-reporter/src/GasReporter.sol"; import { Vector2, Vector2Data, Vector2TableId } from "../src/codegen/Tables.sol"; import { StoreCore } from "../src/StoreCore.sol"; import { StoreReadWithStubs } from "../src/StoreReadWithStubs.sol"; diff --git a/packages/store/test/tables/Callbacks.t.sol b/packages/store/test/tables/Callbacks.t.sol index 609ee6dedc..e7ad3d27fd 100644 --- a/packages/store/test/tables/Callbacks.t.sol +++ b/packages/store/test/tables/Callbacks.t.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.0; import { Test } from "forge-std/Test.sol"; -import { GasReporter } from "@latticexyz/std-contracts/src/test/GasReporter.sol"; +import { GasReporter } from "@latticexyz/gas-reporter/src/GasReporter.sol"; import { StoreReadWithStubs } from "../../src/StoreReadWithStubs.sol"; import { Callbacks } from "../../src/codegen/Tables.sol"; diff --git a/packages/store/test/tables/Hooks.t.sol b/packages/store/test/tables/Hooks.t.sol index 4f93ced1d0..eae7ba04a9 100644 --- a/packages/store/test/tables/Hooks.t.sol +++ b/packages/store/test/tables/Hooks.t.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.0; import { Test } from "forge-std/Test.sol"; -import { GasReporter } from "@latticexyz/std-contracts/src/test/GasReporter.sol"; +import { GasReporter } from "@latticexyz/gas-reporter/src/GasReporter.sol"; import { StoreReadWithStubs } from "../../src/StoreReadWithStubs.sol"; import { Hooks } from "../../src/codegen/Tables.sol"; diff --git a/packages/store/test/tightcoder/DecodeSlice.t.sol b/packages/store/test/tightcoder/DecodeSlice.t.sol index 7bd2f417b1..aaa06de1e7 100644 --- a/packages/store/test/tightcoder/DecodeSlice.t.sol +++ b/packages/store/test/tightcoder/DecodeSlice.t.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.0; import { Test } from "forge-std/Test.sol"; -import { GasReporter } from "@latticexyz/std-contracts/src/test/GasReporter.sol"; +import { GasReporter } from "@latticexyz/gas-reporter/src/GasReporter.sol"; import { SliceLib } from "../../src/Slice.sol"; contract DecodeSliceTest is Test, GasReporter { diff --git a/packages/store/test/tightcoder/EncodeArray.t.sol b/packages/store/test/tightcoder/EncodeArray.t.sol index 79a1fc4010..e3a65cb22f 100644 --- a/packages/store/test/tightcoder/EncodeArray.t.sol +++ b/packages/store/test/tightcoder/EncodeArray.t.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.0; import { Test } from "forge-std/Test.sol"; -import { GasReporter } from "@latticexyz/std-contracts/src/test/GasReporter.sol"; +import { GasReporter } from "@latticexyz/gas-reporter/src/GasReporter.sol"; import { Bytes } from "../../src/Bytes.sol"; import { EncodeArray } from "../../src/tightcoder/EncodeArray.sol"; diff --git a/packages/store/test/tightcoder/TightCoder.t.sol b/packages/store/test/tightcoder/TightCoder.t.sol index a41dbe48c3..946f5cc25b 100644 --- a/packages/store/test/tightcoder/TightCoder.t.sol +++ b/packages/store/test/tightcoder/TightCoder.t.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.0; import { Test } from "forge-std/Test.sol"; -import { GasReporter } from "@latticexyz/std-contracts/src/test/GasReporter.sol"; +import { GasReporter } from "@latticexyz/gas-reporter/src/GasReporter.sol"; import { SchemaType } from "@latticexyz/schema-type/src/solidity/SchemaType.sol"; import { SliceLib } from "../../src/Slice.sol"; import { EncodeArray } from "../../src/tightcoder/EncodeArray.sol"; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 49028d2717..69fc67313c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -999,6 +999,9 @@ importers: '@latticexyz/config': specifier: workspace:* version: link:../config + '@latticexyz/gas-reporter': + specifier: workspace:* + version: link:../gas-reporter '@latticexyz/schema-type': specifier: workspace:* version: link:../schema-type From 3a91b3a565f621f3411a1ee4097718bddd396046 Mon Sep 17 00:00:00 2001 From: dk1a Date: Tue, 11 Jul 2023 17:34:15 +0300 Subject: [PATCH 04/11] refactor(world): use gas-reporter --- packages/store/package.json | 2 +- packages/world/package.json | 3 ++- packages/world/test/KeysInTableModule.t.sol | 2 +- packages/world/test/KeysWithValueModule.t.sol | 2 +- packages/world/test/SnapSyncModule.t.sol | 2 +- packages/world/test/UniqueEntityModule.t.sol | 2 +- packages/world/test/World.t.sol | 2 +- packages/world/test/WorldDynamicUpdate.t.sol | 2 +- packages/world/test/query.t.sol | 2 +- pnpm-lock.yaml | 3 +++ 10 files changed, 13 insertions(+), 9 deletions(-) diff --git a/packages/store/package.json b/packages/store/package.json index 68affb2a04..27d42c0d0d 100644 --- a/packages/store/package.json +++ b/packages/store/package.json @@ -46,7 +46,7 @@ "clean:typechain": "rimraf types", "dev": "tsup --watch", "docs": "rimraf API && hardhat docgen", - "gas-report": "pnpm mud-gas-report --save gas-report.json", + "gas-report": "mud-gas-report --save gas-report.json", "generate-tightcoder": "tsx ./scripts/generate-tightcoder.ts && prettier --write '**/tightcoder/*.sol'", "lint": "solhint --config ./.solhint.json 'src/**/*.sol'", "test": "vitest typecheck --run && vitest --run --passWithNoTests && forge test" diff --git a/packages/world/package.json b/packages/world/package.json index e53e005648..ef46443aff 100644 --- a/packages/world/package.json +++ b/packages/world/package.json @@ -47,7 +47,7 @@ "clean:typechain": "rimraf types", "dev": "tsup --watch", "docs": "rimraf API && hardhat docgen", - "gas-report": "../cli/dist/mud.js gas-report --save gas-report.json", + "gas-report": "mud-gas-report --save gas-report.json", "lint": "solhint --config ./.solhint.json 'src/**/*.sol'", "test": "tsc --noEmit && vitest --run && forge test" }, @@ -56,6 +56,7 @@ "@ethersproject/providers": "^5.7.2", "@latticexyz/common": "workspace:*", "@latticexyz/config": "workspace:*", + "@latticexyz/gas-reporter": "workspace:*", "@latticexyz/schema-type": "workspace:*", "@latticexyz/store": "workspace:*", "ethers": "^5.7.2", diff --git a/packages/world/test/KeysInTableModule.t.sol b/packages/world/test/KeysInTableModule.t.sol index 51a7ca8b0e..47527a0c39 100644 --- a/packages/world/test/KeysInTableModule.t.sol +++ b/packages/world/test/KeysInTableModule.t.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.0; import { Test } from "forge-std/Test.sol"; -import { GasReporter } from "@latticexyz/std-contracts/src/test/GasReporter.sol"; +import { GasReporter } from "@latticexyz/gas-reporter/src/GasReporter.sol"; import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; import { SchemaType } from "@latticexyz/schema-type/src/solidity/SchemaType.sol"; diff --git a/packages/world/test/KeysWithValueModule.t.sol b/packages/world/test/KeysWithValueModule.t.sol index 1e0e0f08fc..800f80b4bf 100644 --- a/packages/world/test/KeysWithValueModule.t.sol +++ b/packages/world/test/KeysWithValueModule.t.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.0; import { Test } from "forge-std/Test.sol"; -import { GasReporter } from "@latticexyz/std-contracts/src/test/GasReporter.sol"; +import { GasReporter } from "@latticexyz/gas-reporter/src/GasReporter.sol"; import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; import { SchemaType } from "@latticexyz/schema-type/src/solidity/SchemaType.sol"; diff --git a/packages/world/test/SnapSyncModule.t.sol b/packages/world/test/SnapSyncModule.t.sol index 4209deb0d9..d733876622 100644 --- a/packages/world/test/SnapSyncModule.t.sol +++ b/packages/world/test/SnapSyncModule.t.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.0; import { Test } from "forge-std/Test.sol"; -import { GasReporter } from "@latticexyz/std-contracts/src/test/GasReporter.sol"; +import { GasReporter } from "@latticexyz/gas-reporter/src/GasReporter.sol"; import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; import { SchemaType } from "@latticexyz/schema-type/src/solidity/SchemaType.sol"; diff --git a/packages/world/test/UniqueEntityModule.t.sol b/packages/world/test/UniqueEntityModule.t.sol index 7b8a5dfa73..503842c91a 100644 --- a/packages/world/test/UniqueEntityModule.t.sol +++ b/packages/world/test/UniqueEntityModule.t.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.0; import { Test } from "forge-std/Test.sol"; -import { GasReporter } from "@latticexyz/std-contracts/src/test/GasReporter.sol"; +import { GasReporter } from "@latticexyz/gas-reporter/src/GasReporter.sol"; import { World } from "../src/World.sol"; import { IBaseWorld } from "../src/interfaces/IBaseWorld.sol"; diff --git a/packages/world/test/World.t.sol b/packages/world/test/World.t.sol index be1e3c3349..71ffbb34ea 100644 --- a/packages/world/test/World.t.sol +++ b/packages/world/test/World.t.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.0; import { Test } from "forge-std/Test.sol"; -import { GasReporter } from "@latticexyz/std-contracts/src/test/GasReporter.sol"; +import { GasReporter } from "@latticexyz/gas-reporter/src/GasReporter.sol"; import { SchemaType } from "@latticexyz/schema-type/src/solidity/SchemaType.sol"; diff --git a/packages/world/test/WorldDynamicUpdate.t.sol b/packages/world/test/WorldDynamicUpdate.t.sol index 4e8acb9462..6608720852 100644 --- a/packages/world/test/WorldDynamicUpdate.t.sol +++ b/packages/world/test/WorldDynamicUpdate.t.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.0; import { Test, console } from "forge-std/Test.sol"; -import { GasReporter } from "@latticexyz/std-contracts/src/test/GasReporter.sol"; +import { GasReporter } from "@latticexyz/gas-reporter/src/GasReporter.sol"; import { SchemaType } from "@latticexyz/schema-type/src/solidity/SchemaType.sol"; diff --git a/packages/world/test/query.t.sol b/packages/world/test/query.t.sol index 45c8e79c1e..f513afeefb 100644 --- a/packages/world/test/query.t.sol +++ b/packages/world/test/query.t.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.0; import { Test } from "forge-std/Test.sol"; -import { GasReporter } from "@latticexyz/std-contracts/src/test/GasReporter.sol"; +import { GasReporter } from "@latticexyz/gas-reporter/src/GasReporter.sol"; import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; import { SchemaType } from "@latticexyz/schema-type/src/solidity/SchemaType.sol"; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 69fc67313c..e784321f20 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1186,6 +1186,9 @@ importers: '@latticexyz/config': specifier: workspace:* version: link:../config + '@latticexyz/gas-reporter': + specifier: workspace:* + version: link:../gas-reporter '@latticexyz/schema-type': specifier: workspace:* version: link:../schema-type From 89872ef344965c408cd79092c42afa32ec7d9356 Mon Sep 17 00:00:00 2001 From: dk1a Date: Tue, 11 Jul 2023 17:45:47 +0300 Subject: [PATCH 05/11] rename gas-reporter to gas-report --- packages/cli/package.json | 2 +- packages/cli/src/commands/index.ts | 2 +- packages/{gas-reporter => gas-report}/.gitignore | 0 packages/{gas-reporter => gas-report}/.npmignore | 0 .../{gas-reporter => gas-report}/.solhint.json | 0 .../{gas-reporter => gas-report}/CHANGELOG.md | 0 packages/gas-report/README.md | 1 + .../{gas-reporter => gas-report}/foundry.toml | 0 .../{gas-reporter => gas-report}/package.json | 6 +++--- .../{gas-reporter => gas-report}/remappings.txt | 0 .../src/GasReporter.sol | 0 .../test/GasReporter.t.sol | 0 .../{gas-reporter => gas-report}/ts/index.ts | 0 .../ts/mud-gas-report.ts | 0 .../{gas-reporter => gas-report}/tsconfig.json | 0 .../{gas-reporter => gas-report}/tsup.config.ts | 0 packages/gas-reporter/README.md | 1 - packages/store/package.json | 2 +- packages/store/test/Bytes.t.sol | 2 +- packages/store/test/Gas.t.sol | 2 +- packages/store/test/KeyEncoding.t.sol | 2 +- packages/store/test/Mixed.t.sol | 2 +- packages/store/test/PackedCounter.t.sol | 2 +- packages/store/test/Schema.t.sol | 2 +- packages/store/test/Slice.t.sol | 2 +- packages/store/test/Storage.t.sol | 2 +- packages/store/test/StoreCoreDynamic.t.sol | 2 +- packages/store/test/StoreCoreGas.t.sol | 2 +- packages/store/test/StoreMetadata.t.sol | 2 +- packages/store/test/StoreSwitch.t.sol | 2 +- packages/store/test/Vector2.t.sol | 2 +- packages/store/test/tables/Callbacks.t.sol | 2 +- packages/store/test/tables/Hooks.t.sol | 2 +- packages/store/test/tightcoder/DecodeSlice.t.sol | 2 +- packages/store/test/tightcoder/EncodeArray.t.sol | 2 +- packages/store/test/tightcoder/TightCoder.t.sol | 2 +- packages/world/package.json | 2 +- packages/world/test/KeysInTableModule.t.sol | 2 +- packages/world/test/KeysWithValueModule.t.sol | 2 +- packages/world/test/SnapSyncModule.t.sol | 2 +- packages/world/test/UniqueEntityModule.t.sol | 2 +- packages/world/test/World.t.sol | 2 +- packages/world/test/WorldDynamicUpdate.t.sol | 2 +- packages/world/test/query.t.sol | 2 +- pnpm-lock.yaml | 16 ++++++++-------- 45 files changed, 41 insertions(+), 41 deletions(-) rename packages/{gas-reporter => gas-report}/.gitignore (100%) rename packages/{gas-reporter => gas-report}/.npmignore (100%) rename packages/{gas-reporter => gas-report}/.solhint.json (100%) rename packages/{gas-reporter => gas-report}/CHANGELOG.md (100%) create mode 100644 packages/gas-report/README.md rename packages/{gas-reporter => gas-report}/foundry.toml (100%) rename packages/{gas-reporter => gas-report}/package.json (88%) rename packages/{gas-reporter => gas-report}/remappings.txt (100%) rename packages/{gas-reporter => gas-report}/src/GasReporter.sol (100%) rename packages/{gas-reporter => gas-report}/test/GasReporter.t.sol (100%) rename packages/{gas-reporter => gas-report}/ts/index.ts (100%) rename packages/{gas-reporter => gas-report}/ts/mud-gas-report.ts (100%) rename packages/{gas-reporter => gas-report}/tsconfig.json (100%) rename packages/{gas-reporter => gas-report}/tsup.config.ts (100%) delete mode 100644 packages/gas-reporter/README.md diff --git a/packages/cli/package.json b/packages/cli/package.json index a27a7be1c1..219e316155 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -33,7 +33,7 @@ "@improbable-eng/grpc-web-node-http-transport": "^0.15.0", "@latticexyz/common": "workspace:*", "@latticexyz/config": "workspace:*", - "@latticexyz/gas-reporter": "workspace:*", + "@latticexyz/gas-report": "workspace:*", "@latticexyz/schema-type": "workspace:*", "@latticexyz/services": "workspace:*", "@latticexyz/solecs": "workspace:*", diff --git a/packages/cli/src/commands/index.ts b/packages/cli/src/commands/index.ts index d9c5f3f71e..ef7c853983 100644 --- a/packages/cli/src/commands/index.ts +++ b/packages/cli/src/commands/index.ts @@ -1,6 +1,6 @@ import { CommandModule } from "yargs"; -import gasReport from "@latticexyz/gas-reporter"; +import gasReport from "@latticexyz/gas-report"; import devnode from "./devnode"; import faucet from "./faucet"; diff --git a/packages/gas-reporter/.gitignore b/packages/gas-report/.gitignore similarity index 100% rename from packages/gas-reporter/.gitignore rename to packages/gas-report/.gitignore diff --git a/packages/gas-reporter/.npmignore b/packages/gas-report/.npmignore similarity index 100% rename from packages/gas-reporter/.npmignore rename to packages/gas-report/.npmignore diff --git a/packages/gas-reporter/.solhint.json b/packages/gas-report/.solhint.json similarity index 100% rename from packages/gas-reporter/.solhint.json rename to packages/gas-report/.solhint.json diff --git a/packages/gas-reporter/CHANGELOG.md b/packages/gas-report/CHANGELOG.md similarity index 100% rename from packages/gas-reporter/CHANGELOG.md rename to packages/gas-report/CHANGELOG.md diff --git a/packages/gas-report/README.md b/packages/gas-report/README.md new file mode 100644 index 0000000000..f5a66f6b68 --- /dev/null +++ b/packages/gas-report/README.md @@ -0,0 +1 @@ +# Gas Report diff --git a/packages/gas-reporter/foundry.toml b/packages/gas-report/foundry.toml similarity index 100% rename from packages/gas-reporter/foundry.toml rename to packages/gas-report/foundry.toml diff --git a/packages/gas-reporter/package.json b/packages/gas-report/package.json similarity index 88% rename from packages/gas-reporter/package.json rename to packages/gas-report/package.json index dcb35cfd21..6408ffb513 100644 --- a/packages/gas-reporter/package.json +++ b/packages/gas-report/package.json @@ -1,11 +1,11 @@ { - "name": "@latticexyz/gas-reporter", + "name": "@latticexyz/gas-report", "version": "1.42.0", - "description": "Gas Reporter", + "description": "Gas reporter for specific lines within forge tests", "repository": { "type": "git", "url": "https://github.com/latticexyz/mud.git", - "directory": "packages/gas-reporter" + "directory": "packages/gas-report" }, "license": "MIT", "type": "module", diff --git a/packages/gas-reporter/remappings.txt b/packages/gas-report/remappings.txt similarity index 100% rename from packages/gas-reporter/remappings.txt rename to packages/gas-report/remappings.txt diff --git a/packages/gas-reporter/src/GasReporter.sol b/packages/gas-report/src/GasReporter.sol similarity index 100% rename from packages/gas-reporter/src/GasReporter.sol rename to packages/gas-report/src/GasReporter.sol diff --git a/packages/gas-reporter/test/GasReporter.t.sol b/packages/gas-report/test/GasReporter.t.sol similarity index 100% rename from packages/gas-reporter/test/GasReporter.t.sol rename to packages/gas-report/test/GasReporter.t.sol diff --git a/packages/gas-reporter/ts/index.ts b/packages/gas-report/ts/index.ts similarity index 100% rename from packages/gas-reporter/ts/index.ts rename to packages/gas-report/ts/index.ts diff --git a/packages/gas-reporter/ts/mud-gas-report.ts b/packages/gas-report/ts/mud-gas-report.ts similarity index 100% rename from packages/gas-reporter/ts/mud-gas-report.ts rename to packages/gas-report/ts/mud-gas-report.ts diff --git a/packages/gas-reporter/tsconfig.json b/packages/gas-report/tsconfig.json similarity index 100% rename from packages/gas-reporter/tsconfig.json rename to packages/gas-report/tsconfig.json diff --git a/packages/gas-reporter/tsup.config.ts b/packages/gas-report/tsup.config.ts similarity index 100% rename from packages/gas-reporter/tsup.config.ts rename to packages/gas-report/tsup.config.ts diff --git a/packages/gas-reporter/README.md b/packages/gas-reporter/README.md deleted file mode 100644 index 2411999e66..0000000000 --- a/packages/gas-reporter/README.md +++ /dev/null @@ -1 +0,0 @@ -# Gas Reporter diff --git a/packages/store/package.json b/packages/store/package.json index 27d42c0d0d..59a821c7de 100644 --- a/packages/store/package.json +++ b/packages/store/package.json @@ -56,7 +56,7 @@ "@ethersproject/providers": "^5.7.2", "@latticexyz/common": "workspace:*", "@latticexyz/config": "workspace:*", - "@latticexyz/gas-reporter": "workspace:*", + "@latticexyz/gas-report": "workspace:*", "@latticexyz/schema-type": "workspace:*", "abitype": "0.8.7", "ethers": "^5.7.2", diff --git a/packages/store/test/Bytes.t.sol b/packages/store/test/Bytes.t.sol index c502ff2cec..c89fb3e12d 100644 --- a/packages/store/test/Bytes.t.sol +++ b/packages/store/test/Bytes.t.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.0; import { Test } from "forge-std/Test.sol"; -import { GasReporter } from "@latticexyz/gas-reporter/src/GasReporter.sol"; +import { GasReporter } from "@latticexyz/gas-report/src/GasReporter.sol"; import { Bytes } from "../src/Bytes.sol"; contract BytesTest is Test, GasReporter { diff --git a/packages/store/test/Gas.t.sol b/packages/store/test/Gas.t.sol index 397b90b808..156ced0905 100644 --- a/packages/store/test/Gas.t.sol +++ b/packages/store/test/Gas.t.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.0; import { Test, console } from "forge-std/Test.sol"; -import { GasReporter } from "@latticexyz/gas-reporter/src/GasReporter.sol"; +import { GasReporter } from "@latticexyz/gas-report/src/GasReporter.sol"; import { Bytes } from "../src/Bytes.sol"; import { SliceLib } from "../src/Slice.sol"; import { EncodeArray } from "../src/tightcoder/EncodeArray.sol"; diff --git a/packages/store/test/KeyEncoding.t.sol b/packages/store/test/KeyEncoding.t.sol index e4b4a29ba6..a6cc367fa1 100644 --- a/packages/store/test/KeyEncoding.t.sol +++ b/packages/store/test/KeyEncoding.t.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.0; import { Test } from "forge-std/Test.sol"; -import { GasReporter } from "@latticexyz/gas-reporter/src/GasReporter.sol"; +import { GasReporter } from "@latticexyz/gas-report/src/GasReporter.sol"; import { KeyEncoding, KeyEncodingTableId } from "../src/codegen/Tables.sol"; import { ExampleEnum } from "../src/codegen/Types.sol"; import { StoreCore } from "../src/StoreCore.sol"; diff --git a/packages/store/test/Mixed.t.sol b/packages/store/test/Mixed.t.sol index 0d4ae589c6..bf335cf496 100644 --- a/packages/store/test/Mixed.t.sol +++ b/packages/store/test/Mixed.t.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.0; import { Test } from "forge-std/Test.sol"; -import { GasReporter } from "@latticexyz/gas-reporter/src/GasReporter.sol"; +import { GasReporter } from "@latticexyz/gas-report/src/GasReporter.sol"; import { SchemaType } from "@latticexyz/schema-type/src/solidity/SchemaType.sol"; import { Mixed, MixedData, MixedTableId } from "../src/codegen/Tables.sol"; import { StoreCore } from "../src/StoreCore.sol"; diff --git a/packages/store/test/PackedCounter.t.sol b/packages/store/test/PackedCounter.t.sol index f599c72183..4ad489a756 100644 --- a/packages/store/test/PackedCounter.t.sol +++ b/packages/store/test/PackedCounter.t.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.0; import { Test } from "forge-std/Test.sol"; -import { GasReporter } from "@latticexyz/gas-reporter/src/GasReporter.sol"; +import { GasReporter } from "@latticexyz/gas-report/src/GasReporter.sol"; import { PackedCounter, PackedCounterLib } from "../src/PackedCounter.sol"; contract PackedCounterTest is Test, GasReporter { diff --git a/packages/store/test/Schema.t.sol b/packages/store/test/Schema.t.sol index 8c75f7657e..57de6f5770 100644 --- a/packages/store/test/Schema.t.sol +++ b/packages/store/test/Schema.t.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.0; import { Test, console } from "forge-std/Test.sol"; -import { GasReporter } from "@latticexyz/gas-reporter/src/GasReporter.sol"; +import { GasReporter } from "@latticexyz/gas-report/src/GasReporter.sol"; import { SchemaType } from "@latticexyz/schema-type/src/solidity/SchemaType.sol"; import { Schema, SchemaLib } from "../src/Schema.sol"; diff --git a/packages/store/test/Slice.t.sol b/packages/store/test/Slice.t.sol index 8050acdc0b..02856114f5 100644 --- a/packages/store/test/Slice.t.sol +++ b/packages/store/test/Slice.t.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.0; import { Test } from "forge-std/Test.sol"; -import { GasReporter } from "@latticexyz/gas-reporter/src/GasReporter.sol"; +import { GasReporter } from "@latticexyz/gas-report/src/GasReporter.sol"; import { Memory } from "../src/Memory.sol"; import { Slice, SliceLib } from "../src/Slice.sol"; diff --git a/packages/store/test/Storage.t.sol b/packages/store/test/Storage.t.sol index 849d81e45e..a85d9b98ad 100644 --- a/packages/store/test/Storage.t.sol +++ b/packages/store/test/Storage.t.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.0; import { Test } from "forge-std/Test.sol"; -import { GasReporter } from "@latticexyz/gas-reporter/src/GasReporter.sol"; +import { GasReporter } from "@latticexyz/gas-report/src/GasReporter.sol"; import { Storage } from "../src/Storage.sol"; import { Utils } from "../src/Utils.sol"; import { Bytes } from "../src/Bytes.sol"; diff --git a/packages/store/test/StoreCoreDynamic.t.sol b/packages/store/test/StoreCoreDynamic.t.sol index eb78b7d5d7..10aac65a36 100644 --- a/packages/store/test/StoreCoreDynamic.t.sol +++ b/packages/store/test/StoreCoreDynamic.t.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.0; import { Test, console } from "forge-std/Test.sol"; -import { GasReporter } from "@latticexyz/gas-reporter/src/GasReporter.sol"; +import { GasReporter } from "@latticexyz/gas-report/src/GasReporter.sol"; import { SchemaType } from "@latticexyz/schema-type/src/solidity/SchemaType.sol"; import { StoreCore } from "../src/StoreCore.sol"; import { SliceLib } from "../src/Slice.sol"; diff --git a/packages/store/test/StoreCoreGas.t.sol b/packages/store/test/StoreCoreGas.t.sol index 5f4634bb0d..e7f222d7cc 100644 --- a/packages/store/test/StoreCoreGas.t.sol +++ b/packages/store/test/StoreCoreGas.t.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.0; import { Test } from "forge-std/Test.sol"; -import { GasReporter } from "@latticexyz/gas-reporter/src/GasReporter.sol"; +import { GasReporter } from "@latticexyz/gas-report/src/GasReporter.sol"; import { SchemaType } from "@latticexyz/schema-type/src/solidity/SchemaType.sol"; import { StoreCore, StoreCoreInternal } from "../src/StoreCore.sol"; import { Utils } from "../src/Utils.sol"; diff --git a/packages/store/test/StoreMetadata.t.sol b/packages/store/test/StoreMetadata.t.sol index ef2ef5196d..811cb5d18c 100644 --- a/packages/store/test/StoreMetadata.t.sol +++ b/packages/store/test/StoreMetadata.t.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.0; import { Test } from "forge-std/Test.sol"; -import { GasReporter } from "@latticexyz/gas-reporter/src/GasReporter.sol"; +import { GasReporter } from "@latticexyz/gas-report/src/GasReporter.sol"; import { StoreMetadata, StoreMetadataData } from "../src/codegen/Tables.sol"; import { StoreCore } from "../src/StoreCore.sol"; import { StoreReadWithStubs } from "../src/StoreReadWithStubs.sol"; diff --git a/packages/store/test/StoreSwitch.t.sol b/packages/store/test/StoreSwitch.t.sol index 4d81a983f8..12b25fb931 100644 --- a/packages/store/test/StoreSwitch.t.sol +++ b/packages/store/test/StoreSwitch.t.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.0; import { Test } from "forge-std/Test.sol"; -import { GasReporter } from "@latticexyz/gas-reporter/src/GasReporter.sol"; +import { GasReporter } from "@latticexyz/gas-report/src/GasReporter.sol"; import { StoreCore } from "../src/StoreCore.sol"; import { StoreReadWithStubs } from "../src/StoreReadWithStubs.sol"; import { StoreSwitch } from "../src/StoreSwitch.sol"; diff --git a/packages/store/test/Vector2.t.sol b/packages/store/test/Vector2.t.sol index 1973936e42..53fbd4c2a1 100644 --- a/packages/store/test/Vector2.t.sol +++ b/packages/store/test/Vector2.t.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.0; import { Test } from "forge-std/Test.sol"; -import { GasReporter } from "@latticexyz/gas-reporter/src/GasReporter.sol"; +import { GasReporter } from "@latticexyz/gas-report/src/GasReporter.sol"; import { Vector2, Vector2Data, Vector2TableId } from "../src/codegen/Tables.sol"; import { StoreCore } from "../src/StoreCore.sol"; import { StoreReadWithStubs } from "../src/StoreReadWithStubs.sol"; diff --git a/packages/store/test/tables/Callbacks.t.sol b/packages/store/test/tables/Callbacks.t.sol index e7ad3d27fd..8916fd98c1 100644 --- a/packages/store/test/tables/Callbacks.t.sol +++ b/packages/store/test/tables/Callbacks.t.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.0; import { Test } from "forge-std/Test.sol"; -import { GasReporter } from "@latticexyz/gas-reporter/src/GasReporter.sol"; +import { GasReporter } from "@latticexyz/gas-report/src/GasReporter.sol"; import { StoreReadWithStubs } from "../../src/StoreReadWithStubs.sol"; import { Callbacks } from "../../src/codegen/Tables.sol"; diff --git a/packages/store/test/tables/Hooks.t.sol b/packages/store/test/tables/Hooks.t.sol index eae7ba04a9..5e2a62a237 100644 --- a/packages/store/test/tables/Hooks.t.sol +++ b/packages/store/test/tables/Hooks.t.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.0; import { Test } from "forge-std/Test.sol"; -import { GasReporter } from "@latticexyz/gas-reporter/src/GasReporter.sol"; +import { GasReporter } from "@latticexyz/gas-report/src/GasReporter.sol"; import { StoreReadWithStubs } from "../../src/StoreReadWithStubs.sol"; import { Hooks } from "../../src/codegen/Tables.sol"; diff --git a/packages/store/test/tightcoder/DecodeSlice.t.sol b/packages/store/test/tightcoder/DecodeSlice.t.sol index aaa06de1e7..e3b4989f5d 100644 --- a/packages/store/test/tightcoder/DecodeSlice.t.sol +++ b/packages/store/test/tightcoder/DecodeSlice.t.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.0; import { Test } from "forge-std/Test.sol"; -import { GasReporter } from "@latticexyz/gas-reporter/src/GasReporter.sol"; +import { GasReporter } from "@latticexyz/gas-report/src/GasReporter.sol"; import { SliceLib } from "../../src/Slice.sol"; contract DecodeSliceTest is Test, GasReporter { diff --git a/packages/store/test/tightcoder/EncodeArray.t.sol b/packages/store/test/tightcoder/EncodeArray.t.sol index e3a65cb22f..989cfc0038 100644 --- a/packages/store/test/tightcoder/EncodeArray.t.sol +++ b/packages/store/test/tightcoder/EncodeArray.t.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.0; import { Test } from "forge-std/Test.sol"; -import { GasReporter } from "@latticexyz/gas-reporter/src/GasReporter.sol"; +import { GasReporter } from "@latticexyz/gas-report/src/GasReporter.sol"; import { Bytes } from "../../src/Bytes.sol"; import { EncodeArray } from "../../src/tightcoder/EncodeArray.sol"; diff --git a/packages/store/test/tightcoder/TightCoder.t.sol b/packages/store/test/tightcoder/TightCoder.t.sol index 946f5cc25b..0f1e183769 100644 --- a/packages/store/test/tightcoder/TightCoder.t.sol +++ b/packages/store/test/tightcoder/TightCoder.t.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.0; import { Test } from "forge-std/Test.sol"; -import { GasReporter } from "@latticexyz/gas-reporter/src/GasReporter.sol"; +import { GasReporter } from "@latticexyz/gas-report/src/GasReporter.sol"; import { SchemaType } from "@latticexyz/schema-type/src/solidity/SchemaType.sol"; import { SliceLib } from "../../src/Slice.sol"; import { EncodeArray } from "../../src/tightcoder/EncodeArray.sol"; diff --git a/packages/world/package.json b/packages/world/package.json index ef46443aff..155cfa052f 100644 --- a/packages/world/package.json +++ b/packages/world/package.json @@ -56,7 +56,7 @@ "@ethersproject/providers": "^5.7.2", "@latticexyz/common": "workspace:*", "@latticexyz/config": "workspace:*", - "@latticexyz/gas-reporter": "workspace:*", + "@latticexyz/gas-report": "workspace:*", "@latticexyz/schema-type": "workspace:*", "@latticexyz/store": "workspace:*", "ethers": "^5.7.2", diff --git a/packages/world/test/KeysInTableModule.t.sol b/packages/world/test/KeysInTableModule.t.sol index 47527a0c39..4656a03b6e 100644 --- a/packages/world/test/KeysInTableModule.t.sol +++ b/packages/world/test/KeysInTableModule.t.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.0; import { Test } from "forge-std/Test.sol"; -import { GasReporter } from "@latticexyz/gas-reporter/src/GasReporter.sol"; +import { GasReporter } from "@latticexyz/gas-report/src/GasReporter.sol"; import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; import { SchemaType } from "@latticexyz/schema-type/src/solidity/SchemaType.sol"; diff --git a/packages/world/test/KeysWithValueModule.t.sol b/packages/world/test/KeysWithValueModule.t.sol index 800f80b4bf..4cca1745e2 100644 --- a/packages/world/test/KeysWithValueModule.t.sol +++ b/packages/world/test/KeysWithValueModule.t.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.0; import { Test } from "forge-std/Test.sol"; -import { GasReporter } from "@latticexyz/gas-reporter/src/GasReporter.sol"; +import { GasReporter } from "@latticexyz/gas-report/src/GasReporter.sol"; import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; import { SchemaType } from "@latticexyz/schema-type/src/solidity/SchemaType.sol"; diff --git a/packages/world/test/SnapSyncModule.t.sol b/packages/world/test/SnapSyncModule.t.sol index d733876622..0ad935c0ce 100644 --- a/packages/world/test/SnapSyncModule.t.sol +++ b/packages/world/test/SnapSyncModule.t.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.0; import { Test } from "forge-std/Test.sol"; -import { GasReporter } from "@latticexyz/gas-reporter/src/GasReporter.sol"; +import { GasReporter } from "@latticexyz/gas-report/src/GasReporter.sol"; import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; import { SchemaType } from "@latticexyz/schema-type/src/solidity/SchemaType.sol"; diff --git a/packages/world/test/UniqueEntityModule.t.sol b/packages/world/test/UniqueEntityModule.t.sol index 503842c91a..7d8c18b4f7 100644 --- a/packages/world/test/UniqueEntityModule.t.sol +++ b/packages/world/test/UniqueEntityModule.t.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.0; import { Test } from "forge-std/Test.sol"; -import { GasReporter } from "@latticexyz/gas-reporter/src/GasReporter.sol"; +import { GasReporter } from "@latticexyz/gas-report/src/GasReporter.sol"; import { World } from "../src/World.sol"; import { IBaseWorld } from "../src/interfaces/IBaseWorld.sol"; diff --git a/packages/world/test/World.t.sol b/packages/world/test/World.t.sol index 71ffbb34ea..11d9ed1af1 100644 --- a/packages/world/test/World.t.sol +++ b/packages/world/test/World.t.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.0; import { Test } from "forge-std/Test.sol"; -import { GasReporter } from "@latticexyz/gas-reporter/src/GasReporter.sol"; +import { GasReporter } from "@latticexyz/gas-report/src/GasReporter.sol"; import { SchemaType } from "@latticexyz/schema-type/src/solidity/SchemaType.sol"; diff --git a/packages/world/test/WorldDynamicUpdate.t.sol b/packages/world/test/WorldDynamicUpdate.t.sol index 6608720852..040ec307c1 100644 --- a/packages/world/test/WorldDynamicUpdate.t.sol +++ b/packages/world/test/WorldDynamicUpdate.t.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.0; import { Test, console } from "forge-std/Test.sol"; -import { GasReporter } from "@latticexyz/gas-reporter/src/GasReporter.sol"; +import { GasReporter } from "@latticexyz/gas-report/src/GasReporter.sol"; import { SchemaType } from "@latticexyz/schema-type/src/solidity/SchemaType.sol"; diff --git a/packages/world/test/query.t.sol b/packages/world/test/query.t.sol index f513afeefb..27dd77c2b3 100644 --- a/packages/world/test/query.t.sol +++ b/packages/world/test/query.t.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.0; import { Test } from "forge-std/Test.sol"; -import { GasReporter } from "@latticexyz/gas-reporter/src/GasReporter.sol"; +import { GasReporter } from "@latticexyz/gas-report/src/GasReporter.sol"; import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; import { SchemaType } from "@latticexyz/schema-type/src/solidity/SchemaType.sol"; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e784321f20..c11f505d2c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -102,9 +102,9 @@ importers: '@latticexyz/config': specifier: workspace:* version: link:../config - '@latticexyz/gas-reporter': + '@latticexyz/gas-report': specifier: workspace:* - version: link:../gas-reporter + version: link:../gas-report '@latticexyz/schema-type': specifier: workspace:* version: link:../schema-type @@ -409,7 +409,7 @@ importers: specifier: ^6.7.0 version: 6.7.0(typescript@4.9.5) - packages/gas-reporter: + packages/gas-report: dependencies: chalk: specifier: ^5.3.0 @@ -435,7 +435,7 @@ importers: version: 18.15.11 '@types/yargs': specifier: ^17.0.10 - version: 17.0.24 + version: 17.0.23 ds-test: specifier: https://github.com/dapphub/ds-test.git#c9ce3f25bde29fc5eb9901842bf02850dfd2d084 version: github.com/dapphub/ds-test/c9ce3f25bde29fc5eb9901842bf02850dfd2d084 @@ -999,9 +999,9 @@ importers: '@latticexyz/config': specifier: workspace:* version: link:../config - '@latticexyz/gas-reporter': + '@latticexyz/gas-report': specifier: workspace:* - version: link:../gas-reporter + version: link:../gas-report '@latticexyz/schema-type': specifier: workspace:* version: link:../schema-type @@ -1186,9 +1186,9 @@ importers: '@latticexyz/config': specifier: workspace:* version: link:../config - '@latticexyz/gas-reporter': + '@latticexyz/gas-report': specifier: workspace:* - version: link:../gas-reporter + version: link:../gas-report '@latticexyz/schema-type': specifier: workspace:* version: link:../schema-type From 05b2fa99ad2224be9c78fea4b51c62ca7bb15a3f Mon Sep 17 00:00:00 2001 From: dk1a Date: Tue, 11 Jul 2023 18:41:43 +0300 Subject: [PATCH 06/11] use GasReporter in testEncodeDecodeSchema --- packages/store/gas-report.json | 6 ++++++ packages/store/test/Schema.t.sol | 5 ++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/store/gas-report.json b/packages/store/gas-report.json index 7df41d1e35..96127af650 100644 --- a/packages/store/gas-report.json +++ b/packages/store/gas-report.json @@ -149,6 +149,12 @@ "name": "get total of PackedCounter", "gasUsed": 27 }, + { + "file": "test/Schema.t.sol", + "test": "testEncodeDecodeSchema", + "name": "encode schema with 6 entries [SchemaLib.encode]", + "gasUsed": 6040 + }, { "file": "test/Schema.t.sol", "test": "testEncodeDecodeSchema", diff --git a/packages/store/test/Schema.t.sol b/packages/store/test/Schema.t.sol index 57de6f5770..11af647889 100644 --- a/packages/store/test/Schema.t.sol +++ b/packages/store/test/Schema.t.sol @@ -9,7 +9,7 @@ import { Schema, SchemaLib } from "../src/Schema.sol"; // TODO add tests for all schema types contract SchemaTest is Test, GasReporter { function testEncodeDecodeSchema() public { - uint256 gas = gasleft(); + startGasReport("encode schema with 6 entries [SchemaLib.encode]"); Schema schema = SchemaLib.encode( SchemaType.UINT8, // 1 byte SchemaType.UINT16, // 2 bytes @@ -18,8 +18,7 @@ contract SchemaTest is Test, GasReporter { SchemaType.UINT256, // 32 bytes SchemaType.UINT32_ARRAY // 0 bytes (because it's dynamic) ); - gas = gas - gasleft(); - console.log("GAS REPORT: encode schema with 6 entries [SchemaLib.encode]: %s", gas); + endGasReport(); startGasReport("get schema type at index"); SchemaType schemaType1 = schema.atIndex(0); From 398e6c047a91da0dbbcb57c90a401c44af0f9bcd Mon Sep 17 00:00:00 2001 From: dk1a Date: Tue, 11 Jul 2023 19:22:44 +0300 Subject: [PATCH 07/11] actions: install again after build --- .github/actions/build/action.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/actions/build/action.yml b/.github/actions/build/action.yml index a770021ecb..d9b74edfd9 100644 --- a/.github/actions/build/action.yml +++ b/.github/actions/build/action.yml @@ -17,5 +17,9 @@ runs: shell: bash run: pnpm turbo run build --cache-dir=.turbo --concurrency 10 + - name: Install node dependencies again to update workspace binaries + shell: bash + run: pnpm install --frozen-lockfile + - name: Outdated files, run `pnpm build` and commit them uses: ./.github/actions/require-empty-diff From 2e701f771c5dd35ac4f463a6a468acf9347d76fd Mon Sep 17 00:00:00 2001 From: dk1a Date: Tue, 11 Jul 2023 23:02:40 +0300 Subject: [PATCH 08/11] gas-report readme --- packages/gas-report/README.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/packages/gas-report/README.md b/packages/gas-report/README.md index f5a66f6b68..7e6a41a40d 100644 --- a/packages/gas-report/README.md +++ b/packages/gas-report/README.md @@ -1 +1,26 @@ # Gas Report + +Gas reporter for specific lines within forge tests + +Add some reports to your forge tests + +```solidity +import { Test } from "forge-std/Test.sol"; +import { GasReporter } from "@latticexyz/gas-report/src/GasReporter.sol"; + +contract ExampleTest is Test, GasReporter { + function testGas() public { + startGasReport("Describe what is being gas-reported on"); + // do something here + endGasReport(); + } +} +``` + +Then use the cli command to run tests and save the report: + +```console +pnpm mud-gas-report --save gas-report.json +``` + +Run `pnpm mud-gas-report --help` for more details. From fdea96e530c026a51ef0b1c213949dfb72abde05 Mon Sep 17 00:00:00 2001 From: dk1a Date: Tue, 11 Jul 2023 23:09:08 +0300 Subject: [PATCH 09/11] Create quick-numbers-flash.md --- .changeset/quick-numbers-flash.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .changeset/quick-numbers-flash.md diff --git a/.changeset/quick-numbers-flash.md b/.changeset/quick-numbers-flash.md new file mode 100644 index 0000000000..6dc2200e1a --- /dev/null +++ b/.changeset/quick-numbers-flash.md @@ -0,0 +1,7 @@ +--- +"@latticexyz/cli": minor +"@latticexyz/gas-report": minor +"@latticexyz/store": minor +--- + +Create gas-report package, move gas-report cli command and GasReporter contract to it From c9f0d4b9c6b6411f93c69f3e7002a34a529887d5 Mon Sep 17 00:00:00 2001 From: dk1a Date: Wed, 12 Jul 2023 15:05:42 +0300 Subject: [PATCH 10/11] update playwright --- e2e/packages/sync-test/package.json | 2 +- e2e/pnpm-lock.yaml | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/e2e/packages/sync-test/package.json b/e2e/packages/sync-test/package.json index 89be9b80f5..07bf92bf45 100644 --- a/e2e/packages/sync-test/package.json +++ b/e2e/packages/sync-test/package.json @@ -12,7 +12,7 @@ "@latticexyz/schema-type": "link:../../../packages/schema-type", "@latticexyz/store": "link:../../../packages/store", "@latticexyz/utils": "link:../../../packages/utils", - "@playwright/test": "^1.35.0", + "@playwright/test": "^1.36.0", "chalk": "^5.2.0", "dotenv": "^16.0.3", "ethers": "^5.7.2", diff --git a/e2e/pnpm-lock.yaml b/e2e/pnpm-lock.yaml index f14ab1281f..c8870b0d0a 100644 --- a/e2e/pnpm-lock.yaml +++ b/e2e/pnpm-lock.yaml @@ -162,8 +162,8 @@ importers: specifier: link:../../../packages/utils version: link:../../../packages/utils '@playwright/test': - specifier: ^1.35.0 - version: 1.35.0 + specifier: ^1.36.0 + version: 1.36.0 chalk: specifier: ^5.2.0 version: 5.2.0 @@ -738,13 +738,13 @@ packages: /@noble/hashes@1.3.0: resolution: {integrity: sha512-ilHEACi9DwqJB0pw7kv+Apvh50jiiSyR/cQ3y4W7lOR5mhvn/50FLUfsnfJz0BDZtl/RR16kXvptiv6q1msYZg==} - /@playwright/test@1.35.0: - resolution: {integrity: sha512-6qXdd5edCBynOwsz1YcNfgX8tNWeuS9fxy5o59D0rvHXxRtjXRebB4gE4vFVfEMXl/z8zTnAzfOs7aQDEs8G4Q==} + /@playwright/test@1.36.0: + resolution: {integrity: sha512-yN+fvMYtiyLFDCQos+lWzoX4XW3DNuaxjBu68G0lkgLgC6BP+m/iTxJQoSicz/x2G5EsrqlZTqTIP9sTgLQerg==} engines: {node: '>=16'} hasBin: true dependencies: '@types/node': 20.1.3 - playwright-core: 1.35.0 + playwright-core: 1.36.0 optionalDependencies: fsevents: 2.3.2 dev: true @@ -1846,8 +1846,8 @@ packages: pathe: 1.1.0 dev: true - /playwright-core@1.35.0: - resolution: {integrity: sha512-muMXyPmIx/2DPrCHOD1H1ePT01o7OdKxKj2ebmCAYvqhUy+Y1bpal7B0rdoxros7YrXI294JT/DWw2LqyiqTPA==} + /playwright-core@1.36.0: + resolution: {integrity: sha512-7RTr8P6YJPAqB+8j5ATGHqD6LvLLM39sYVNsslh78g8QeLcBs5750c6+msjrHUwwGt+kEbczBj1XB22WMwn+WA==} engines: {node: '>=16'} hasBin: true dev: true From 8a5f968083e98b2a1c8fe21f588cabc90765e970 Mon Sep 17 00:00:00 2001 From: dk1a Date: Wed, 12 Jul 2023 15:19:08 +0300 Subject: [PATCH 11/11] Revert "update playwright" This reverts commit c9f0d4b9c6b6411f93c69f3e7002a34a529887d5. --- e2e/packages/sync-test/package.json | 2 +- e2e/pnpm-lock.yaml | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/e2e/packages/sync-test/package.json b/e2e/packages/sync-test/package.json index 07bf92bf45..89be9b80f5 100644 --- a/e2e/packages/sync-test/package.json +++ b/e2e/packages/sync-test/package.json @@ -12,7 +12,7 @@ "@latticexyz/schema-type": "link:../../../packages/schema-type", "@latticexyz/store": "link:../../../packages/store", "@latticexyz/utils": "link:../../../packages/utils", - "@playwright/test": "^1.36.0", + "@playwright/test": "^1.35.0", "chalk": "^5.2.0", "dotenv": "^16.0.3", "ethers": "^5.7.2", diff --git a/e2e/pnpm-lock.yaml b/e2e/pnpm-lock.yaml index c8870b0d0a..f14ab1281f 100644 --- a/e2e/pnpm-lock.yaml +++ b/e2e/pnpm-lock.yaml @@ -162,8 +162,8 @@ importers: specifier: link:../../../packages/utils version: link:../../../packages/utils '@playwright/test': - specifier: ^1.36.0 - version: 1.36.0 + specifier: ^1.35.0 + version: 1.35.0 chalk: specifier: ^5.2.0 version: 5.2.0 @@ -738,13 +738,13 @@ packages: /@noble/hashes@1.3.0: resolution: {integrity: sha512-ilHEACi9DwqJB0pw7kv+Apvh50jiiSyR/cQ3y4W7lOR5mhvn/50FLUfsnfJz0BDZtl/RR16kXvptiv6q1msYZg==} - /@playwright/test@1.36.0: - resolution: {integrity: sha512-yN+fvMYtiyLFDCQos+lWzoX4XW3DNuaxjBu68G0lkgLgC6BP+m/iTxJQoSicz/x2G5EsrqlZTqTIP9sTgLQerg==} + /@playwright/test@1.35.0: + resolution: {integrity: sha512-6qXdd5edCBynOwsz1YcNfgX8tNWeuS9fxy5o59D0rvHXxRtjXRebB4gE4vFVfEMXl/z8zTnAzfOs7aQDEs8G4Q==} engines: {node: '>=16'} hasBin: true dependencies: '@types/node': 20.1.3 - playwright-core: 1.36.0 + playwright-core: 1.35.0 optionalDependencies: fsevents: 2.3.2 dev: true @@ -1846,8 +1846,8 @@ packages: pathe: 1.1.0 dev: true - /playwright-core@1.36.0: - resolution: {integrity: sha512-7RTr8P6YJPAqB+8j5ATGHqD6LvLLM39sYVNsslh78g8QeLcBs5750c6+msjrHUwwGt+kEbczBj1XB22WMwn+WA==} + /playwright-core@1.35.0: + resolution: {integrity: sha512-muMXyPmIx/2DPrCHOD1H1ePT01o7OdKxKj2ebmCAYvqhUy+Y1bpal7B0rdoxros7YrXI294JT/DWw2LqyiqTPA==} engines: {node: '>=16'} hasBin: true dev: true