Security News
Cloudflare Adds Security.txt Setup Wizard
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
@latticexyz/gas-report
Advanced tools
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.0-next.18
Release date: Thu Mar 21 2024
docs: add store/world config changesets (#2497) (@latticexyz/store, @latticexyz/world)
Store and World configs have been rebuilt with strong types. The shape of these configs have also changed slightly for clarity, the biggest change of which is merging of keySchema
and valueSchema
into a single schema
with a separate key
for a table's primary key.
To migrate, first update the imported config method:
-import { mudConfig } from "@latticexyz/world/register";
+import { defineWorld } from "@latticexyz/world";
-export default mudConfig({
+export default defineWorld({
Note that if you are only using Store, you will need to import defineStore
from @latticexyz/store
.
Then migrate the table key by renaming keySchema
to schema
and define the table key
with each field name from your key schema:
export default defineWorld({
tables: {
Position: {
- keySchema: {
+ schema: {
player: "address",
},
valueSchema: {
x: "int32",
y: "int32",
},
+ key: ['player'],
},
},
});
Now we can merge the valueSchema
into schema
.
export default defineWorld({
tables: {
Position: {
schema: {
player: "address",
- },
- valueSchema: {
x: "int32",
y: "int32",
},
key: ['player'],
},
},
});
If you previously used the table config shorthand without the full keySchema
and valueSchema
, some of the defaults have changed. Shorthands now use an id: "bytes32"
field by default rather than key: "bytes32"
and corresponding key: ["id"]
. To keep previous behavior, you may have to manually define your schema
with the previous key
and value
fields.
export default defineWorld({
tables: {
- OwnedBy: "address",
+ OwnedBy: {
+ schema: {
+ key: "bytes32",
+ value: "address",
+ },
+ key: ["key"],
+ },
},
});
Singleton tables are defined similarly, where an empty key
rather than keySchema
is provided:
-keySchema: {}
+key: []
Offchain tables are now defined as a table type
instead an offchainOnly
boolean:
-offchainOnly: true
+type: 'offchainTable'
All codegen options have moved under codegen
:
export default defineWorld({
- codegenDirectory: "…",
+ codegen: {
+ outputDirectory: "…",
+ },
tables: {
Position: {
schema: {
player: "address",
x: "int32",
y: "int32",
},
key: ['player'],
- directory: "…",
- dataStruct: false,
+ codegen: {
+ outputDirectory: "…",
+ dataStruct: false,
+ },
},
},
});
refactor: move table ID and field layout constants into table library (#2327) (create-mud, @latticexyz/cli, @latticexyz/common, @latticexyz/store, @latticexyz/world, @latticexyz/world-modules)
Moved table ID and field layout constants in code-generated table libraries from the file level into the library, for clearer access and cleaner imports.
-import { SomeTable, SomeTableTableId } from "./codegen/tables/SomeTable.sol";
+import { SomeTable } from "./codegen/tables/SomeTable.sol";
-console.log(SomeTableTableId);
+console.log(SomeTable._tableId);
-console.log(SomeTable.getFieldLayout());
+console.log(SomeTable._fieldLayout);
feat(store,world): set protocol version, add tests (#2412) (@latticexyz/store, @latticexyz/world)
Set the protocol version to 2.0.0
for each Store and World.
refactor(schema-type,protocol-parser): explicit internal vs external exports (#2452) (@latticexyz/protocol-parser, @latticexyz/schema-type)
Moved all existing exports to a /internal
import path to indicate that these are now internal-only and deprecated. We'll be replacing these types and functions with new ones that are compatible with our new, strongly-typed config.
feat(store): add field index to Store_SpliceDynamicData event (#2279) (@latticexyz/store, @latticexyz/store-sync)
Added dynamicFieldIndex
to the Store_SpliceDynamicData
event. This enables indexers to store dynamic data as a blob per dynamic field without a schema lookup.
refactor: rename PackedCounter to EncodedLengths (#2490) (@latticexyz/cli, @latticexyz/protocol-parser, @latticexyz/store, @latticexyz/world-modules, @latticexyz/world, create-mud)
Renamed PackedCounter
to EncodedLengths
for consistency.
feat(store-sync): adjust DB schema/table names for consistency (#2379) (@latticexyz/store-indexer, @latticexyz/store-sync)
PostgreSQL sync/indexer now uses {storeAddress}
for its database schema names and {namespace}__{tableName}
for its database table names (or just {tableName}
for root namespace), to be more consistent with the rest of the MUD codebase.
For namespaced tables:
- SELECT * FROM 0xfff__some_ns.some_table
+ SELECT * FROM 0xfff.some_ns__some_table
For root tables:
- SELECT * FROM 0xfff__.some_table
+ SELECT * FROM 0xfff.some_table
SQLite sync/indexer now uses snake case for its table names and column names for easier writing of queries and to better match PostgreSQL sync/indexer naming.
- SELECT * FROM 0xfFf__someNS__someTable
+ SELECT * FROM 0xfff__some_ns__some_table
feat: use new config (#2483) (@latticexyz/cli, @latticexyz/dev-tools, @latticexyz/store-sync, @latticexyz/store, @latticexyz/world-modules, @latticexyz/world, create-mud)
Migrated to new config format.
feat(cli): add a RPC batch option to cli (#2322) (@latticexyz/cli)
Added an --rpcBatch
option to mud deploy
command to batch RPC calls for rate limited RPCs.
feat(store-sync,store-indexer): add followBlockTag option (#2315) (@latticexyz/store-indexer, @latticexyz/store-sync)
Added a followBlockTag
option to configure which block number to follow when running createStoreSync
. It defaults to latest
(current behavior), which is recommended for individual clients so that you always have the latest chain state.
Indexers now default to safe
to avoid issues with reorgs and load-balanced RPCs being out of sync. This means indexers will be slightly behind the latest block number, but clients can quickly catch up. Indexers can override this setting using FOLLOW_BLOCK_TAG
environment variable.
refactor(world): registerRootFunctionSelector takes system signature (#2395) (@latticexyz/world)
registerRootFunctionSelector
now expects a systemFunctionSignature
instead of a systemFunctionSelector
. Internally, we compute the selector from the signature. This allows us to track system function signatures that are registered at the root so we can later generate ABIs for these systems.
feat(common): add viem actions that work the same as the current wrappers (#2347) (@latticexyz/common, create-mud)
Added viem custom client actions that work the same as MUD's now-deprecated getContract
, writeContract
, and sendTransaction
wrappers. Templates have been updated to reflect the new patterns.
You can migrate your own code like this:
-import { createWalletClient } from "viem";
-import { getContract, writeContract, sendTransaction } from "@latticexyz/common";
+import { createWalletClient, getContract } from "viem";
+import { transactionQueue, writeObserver } from "@latticexyz/common/actions";
-const walletClient = createWalletClient(...);
+const walletClient = createWalletClient(...)
+ .extend(transactionQueue())
+ .extend(writeObserver({ onWrite });
const worldContract = getContract({
client: { publicClient, walletClient },
- onWrite,
});
refactor(store): add StoreWrite and Store abstract contracts (#2411) (@latticexyz/store, @latticexyz/world)
Added an abstract
StoreKernel
contract, which includes all Store interfaces except for registration, and implements write methods, protocolVersion
and initializes StoreCore
. Store
extends StoreKernel
with the IStoreRegistration
interface. StoreData
is removed as a separate interface/contract. World
now extends StoreKernel
(since the registration methods are added via the InitModule
).
refactor(store): make static array length a constant (#2410) (@latticexyz/store)
Replaced the static array length getters in table libraries with constants.
feat(gas-report): run gas report with --isolate (#2331) (@latticexyz/gas-report)
Now uses --isolate
flag in forge test
for more accurate gas measurement.
feat(cli): link and deploy public libraries (#1910) (@latticexyz/cli)
mud deploy
now supports public/linked libraries.
This helps with cases where system contracts would exceed the EVM bytecode size limit and logic would need to be split into many smaller systems.
Instead of the overhead and complexity of system-to-system calls, this logic can now be moved into public libraries that will be deployed alongside your systems and automatically delegatecall
ed.
refactor: hardcode key/value schema in table libraries (#2328) (create-mud, @latticexyz/store, @latticexyz/world, @latticexyz/world-modules)
Moved key schema and value schema methods to constants in code-generated table libraries for less bytecode and less gas in register/install methods.
-console.log(SomeTable.getKeySchema());
+console.log(SomeTable._keySchema);
-console.log(SomeTable.getValueSchema());
+console.log(SomeTable._valueSchema);
feat: upgrade viem to v2 (#2284) (@latticexyz/block-logs-stream, @latticexyz/cli, @latticexyz/common, @latticexyz/config, @latticexyz/dev-tools, @latticexyz/faucet, @latticexyz/protocol-parser, @latticexyz/schema-type, @latticexyz/store-indexer, @latticexyz/store-sync, @latticexyz/store, @latticexyz/world, create-mud)
Upgraded all packages and templates to viem v2.7.12 and abitype v1.0.0.
Some viem APIs have changed and we've updated getContract
to reflect those changes and keep it aligned with viem. It's one small code change:
const worldContract = getContract({
address: worldAddress,
abi: IWorldAbi,
- publicClient,
- walletClient,
+ client: { public: publicClient, wallet: walletClient },
});
fix(cli): throw error when deploying overlapping systems (#2325) (@latticexyz/cli, @latticexyz/world)
Attempting to deploy multiple systems where there are overlapping system IDs now throws an error.
fix(common): use setTimeout
as fallback for requestIdleCallback
(#2406) (@latticexyz/common)
waitForIdle
now falls back to setTimeout
for environments without requestIdleCallback
.
refactor: human-readable resource IDs use double underscore (#2310) (@latticexyz/store-sync, @latticexyz/dev-tools, @latticexyz/common, @latticexyz/cli)
Updated all human-readable resource IDs to use {namespace}__{name}
for consistency with world function signatures.
chore: remove some unused files (#2398) (@latticexyz/common, @latticexyz/react)
Removed some unused files, namely curry
in @latticexyz/common
and useDeprecatedComputedValue
from @latticexyz/react
.
fix(world-modules): token modules always register namespace (#2352) (@latticexyz/world-modules)
ERC20 and ERC721 implementations now always register the token namespace, instead of checking if it has already been registered. This prevents issues with registering the namespace beforehand, namely that only the owner of a system can create a puppet for it.
refactor(store): store core imports store events (#2356) (@latticexyz/store)
Refactored StoreCore
to import IStoreEvents
instead of defining the events twice.
feat(world): emit salt in WorldDeployed event (#2301) (@latticexyz/world)
Added salt to the WorldDeployed
event.
chore: upgrade to typescript 5.4.2 (#2397) (@latticexyz/cli, create-mud)
Bumped typescript
to 5.4.2
, eslint
to 8.57.0
, and both @typescript-eslint/eslint-plugin
and @typescript-eslint/parser
to 7.1.1
.
fix(common): remove underscore prefix from root namespace labels (#2400) (@latticexyz/common)
resourceToLabel
now correctly returns just the resource name if its in the root namespace.
chore(noise): remove noise package (#2304) (@latticexyz/noise)
Removed the @latticexyz/noise package.
refactor(store): event interfaces for Store libraries (#2348) (@latticexyz/store)
Added interfaces for all errors that are used by StoreCore
, which includes FieldLayout
, PackedCounter
, Schema
, and Slice
. This interfaces are inherited by IStore
, ensuring that all possible errors are included in the IStore
ABI for proper decoding in the frontend.
docs: add missing changeset (#2374) (@latticexyz/common)
Moved the transaction simulation step to just before sending the transaction in our transaction queue actions (sendTransaction
and writeContract
).
This helps avoid cascading transaction failures for deep queues or when a transaction succeeding depends on the value of the previous.
fix(store): restore bytesN helpers (#2403) (@latticexyz/store)
Restored Bytes.sliceN
helpers that were previously (mistakenly) removed and renamed them to Bytes.getBytesN
.
If you're upgrading an existing MUD project, you can rerun codegen with mud build
to update your table libraries to the new function names.
chore: upgrade prettier to 3.2.5 and prettier-plugin-solidity to 1.3.1 (#2303) (@latticexyz/common)
Upgraded prettier version to 3.2.5 and prettier-plugin-solidity version to 1.3.1.
feat(world): add system signatures to FunctionSignatures (#2392) (@latticexyz/world)
Added system signatures to the FunctionSignatures
table, so they can be used to generate system ABIs and decode system calls made via the world.
fix(gas-report): update filename matcher (#2277) (@latticexyz/gas-report)
Fixed gas report parsing for foundry versions released after 2024-02-15.
feat(create-mud): add additional recommended vscode extensions (#2440) (create-mud)
Added dbaeumer.vscode-eslint
and esbenp.prettier-vscode
to recommended VSCode extensions.
refactor(world): add IWorldEvents with HelloWorld (#2358) (@latticexyz/world)
Created an IWorldEvents
interface with HelloStore
, so all World events are defined in a single interface.
fix(store-sync): track changed records together in zustand (#2387) (@latticexyz/store-sync)
Fixes an issue with Zustand store sync where multiple updates to a record for a key in the same block did not get tracked and applied properly.
refactor(store): hellostore in IStoreEvents (#2357) (@latticexyz/store)
Moved the HelloStore
to IStoreEvents
so all Store events are defined in the same interface.
feat(world): world kernel inherits IModuleErrors
(#2380) (@latticexyz/world)
IWorldKernel
now inherits IModuleErrors
so it can render the correct errors if the World reverts when delegatecalled with Module code.
feat(cli): deterministic deployer fallback (#2261) (@latticexyz/cli)
Added a non-deterministic fallback for deploying to chains that have replay protection on and do not support pre-EIP-155 transactions (no chain ID).
If you're using mud deploy
and there's already a deterministic deployer on your target chain, you can provide the address with --deployerAddress 0x...
to still get some determinism.
refactor(world): rename functionSelector to worldFunctionSelector (#2391) (@latticexyz/world)
Renamed the functionSelector
key in the FunctionSelectors
table to worldFunctionSelector
. This clarifies that FunctionSelectors
is for world function selectors and can be used to generate the world ABI.
FAQs
Gas reporter for specific lines within forge tests
The npm package @latticexyz/gas-report receives a total of 1,974 weekly downloads. As such, @latticexyz/gas-report popularity was classified as popular.
We found that @latticexyz/gas-report demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.
Security News
ENISA’s 2024 report highlights the EU’s top cybersecurity threats, including rising DDoS attacks, ransomware, supply chain vulnerabilities, and weaponized AI.