Skip to content

Commit

Permalink
fix(store,world): fix StoreRead.getDynamicFieldLength (#2680)
Browse files Browse the repository at this point in the history
Co-authored-by: alvarius <[email protected]>
  • Loading branch information
yonadaaa and alvrs authored Apr 17, 2024
1 parent c18e93c commit 103db6c
Show file tree
Hide file tree
Showing 18 changed files with 891 additions and 102 deletions.
7 changes: 7 additions & 0 deletions .changeset/gorgeous-seals-smile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@latticexyz/store": patch
---

Patched `StoreRead.getDynamicFieldLength` to properly read `StoreCore.getDynamicFieldLength`.

Previously `StoreRead.getDynamicFieldLength` incorrectly read from `StoreCore.getFieldLength`, which expected a `fieldIndex` instead of a `dynamicFieldIndex`, and thereby returned an invalid result if the table had both static and dynamic fields (in which case `fieldIndex` != `dynamicFieldIndex`). `StoreRead` is used for external reads from the `Store`/`World` contract, so this bug only materialized in external table reads (ie from `Systems` outside the root namespace) of the dynamic length of a field in a table with both static and dynamic fields.
2 changes: 1 addition & 1 deletion docs/pages/store/reference/misc.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2688,5 +2688,5 @@ Contains a constant representing the version of the Store protocol.
_Identifier for the current Store protocol version._

```solidity
bytes32 constant STORE_VERSION = "2.0.0";
bytes32 constant STORE_VERSION = "2.0.1";
```
2 changes: 1 addition & 1 deletion docs/pages/world/reference/misc.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,5 @@ Contains a constant representing the version of the World protocol.
_Identifier for the current World protocol version._

```solidity
bytes32 constant WORLD_VERSION = "2.0.0";
bytes32 constant WORLD_VERSION = "2.0.1";
```
8 changes: 8 additions & 0 deletions e2e/packages/contracts/mud.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,18 @@ export default defineWorld({
},
StaticArray: {
schema: {
num: "uint256",
value: "uint256[3]",
},
key: [],
},
DynamicArray: {
schema: {
num: "uint256",
value: "uint256[]",
},
key: [],
},
},
modules: [
{
Expand Down
3 changes: 2 additions & 1 deletion e2e/packages/contracts/src/codegen/index.sol

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 103db6c

Please sign in to comment.