-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(gas-report): create package, move relevant files to it (#1147)
* feat(gas-reporter): create package, move relevant files to it * make gas-report a default command for mud-gas-report * refactor(store): use gas-reporter * refactor(world): use gas-reporter * rename gas-reporter to gas-report * use GasReporter in testEncodeDecodeSchema * actions: install again after build * gas-report readme * Create quick-numbers-flash.md * update playwright * Revert "update playwright" This reverts commit c9f0d4b.
- Loading branch information
Showing
47 changed files
with
298 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
cache | ||
abi | ||
out | ||
docs | ||
_docs | ||
DOCS.md | ||
artifacts | ||
yarn-error.log | ||
API | ||
dist | ||
types/ethers-contracts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
* | ||
|
||
!abi/** | ||
!src/** | ||
!ts/** | ||
!types/** | ||
!package.json | ||
!README.md | ||
!dist/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"extends": "solhint:recommended", | ||
"rules": { | ||
"compiler-version": ["error", ">=0.8.0"], | ||
"avoid-low-level-calls": "off", | ||
"func-visibility": ["warn", { "ignoreConstructors": true }] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
{ | ||
"name": "@latticexyz/gas-report", | ||
"version": "1.42.0", | ||
"description": "Gas reporter for specific lines within forge tests", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/latticexyz/mud.git", | ||
"directory": "packages/gas-report" | ||
}, | ||
"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" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ds-test/=node_modules/ds-test/src/ | ||
forge-std/=node_modules/forge-std/src/ |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/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(); | ||
|
||
// $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("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) | ||
// 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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.