Gas Report
Measure and report gas usage within forge tests
Add some reports to your forge tests
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("description of behavior to measure gas for");
// do something here
endGasReport();
}
}
Then use the cli command to run tests and save the report:
pnpm gas-report --save gas-report.json
Or, if you have your own test command, you can pipe the output to gas-report --stdin
:
GAS_REPORTER_ENABLED=true forge test -vvv --isolate | pnpm gas-report --stdin
Run pnpm gas-report --help
for more details.
Version 2.0.10
Release date: Tue May 14 2024
Patch changes
fix(cli): function selector lookup during deploy (#2800) (@latticexyz/cli)
The deploy CLI now uses logs to find registered function selectors and their corresponding function signatures.
Previously only function signatures were fetched via logs and then mapped to function selectors via getRecord
calls,
but this approach failed for namespaced function selectors of non-root system,
because the function signature table includes both the namespaced and non-namespaced signature but the function selector table only includes the namespaced selector that is registered on the world.
feat(cli): deploy with external modules (#2803) (@latticexyz/cli, @latticexyz/world)
Worlds can now be deployed with external modules, defined by a module's artifactPath
in your MUD config, resolved with Node's module resolution. This allows for modules to be published to and imported from npm.
defineWorld({
// …
modules: [
{
- name: "KeysWithValueModule",
+ artifactPath: "@latticexyz/world-modules/out/KeysWithValueModule.sol/KeysWithValueModule.json",
root: true,
args: [resolveTableId("Inventory")],
},
],
});
Note that the above assumes @latticexyz/world-modules
is included as a dependency of your project.
chore: upgrade to ejs 3.1.10 (#2786) (@latticexyz/world-modules, @latticexyz/store, @latticexyz/cli)
Removed the unused ejs
dependency.
docs: fix create-mud package name in changeset (#2825) (create-mud)
Templates now use an app
namespace by default, instead of the root namespace. This helps keep the root namespace clear for intentionally root-level things and avoids pitfalls with root systems calling other root systems.
chore: upgrade to ejs 3.1.10 (#2786) (@latticexyz/world)
Upgraded the ejs
dependency to 3.1.10.
fix(store-indexer): fix distance from follow block metric (#2791) (@latticexyz/store-indexer)
Fixed the distance_from_follow_block
gauge to be a positive number if the latest processed block is lagging behind the latest remote block.
fix(common): extend OP contracts, add redstone ones (#2792) (@latticexyz/common)
Added OP predeploy contracts for Redstone and Garnet chain configs and added chain-specific contracts for Redstone chain config.
chore: remove cli faucet command and services package (#2811) (@latticexyz/cli)
Removed broken mud faucet
command.
fix(world): config uses readonly arrays (#2805) (@latticexyz/world)
Updated World config types to use readonly arrays.
docs(store-sync): add changeset for #2808 (#2809) (@latticexyz/store-sync)
Both encodeEntity
and decodeEntity
now use an LRU cache to avoid repeating work during iterations of thousands of entities.
fix(store,world): throw on unexpected config keys (#2797) (@latticexyz/store, @latticexyz/world)
defineStore
and defineWorld
will now throw a type error if an unexpected config option is used.
chore: remove cli faucet command and services package (#2811) (create-mud)
Removed usages of old testnet faucet in templates. The previous testnet faucet is broken, deprecated, and going offline soon. We'll be replacing the burner account pattern with something better very soon!
chore: bump zod (#2804) (@latticexyz/cli, @latticexyz/config, @latticexyz/faucet, @latticexyz/store-indexer, @latticexyz/store-sync, @latticexyz/store, @latticexyz/world-modules, @latticexyz/world)
Bumped zod dependency to comply with abitype peer dependencies.
feat(store,world): usable enum values from config (#2807) (@latticexyz/store, @latticexyz/world)
defineStore
and defineWorld
now maps your enums
to usable, strongly-typed enums on enumValues
.
const config = defineStore({
enums: {
TerrainType: ["Water", "Grass", "Sand"],
},
});
config.enumValues.TerrainType.Water;
// ^? (property) Water: 0
config.enumValues.TerrainType.Grass;
// ^? (property) Grass: 1
This allows for easier referencing of enum values (i.e. uint8
equivalent) in contract calls.
writeContract({
// …
functionName: "setTerrainType",
args: [config.enumValues.TerrainType.Grass],
});