Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: rename table to tableId #1484

Merged
merged 20 commits into from
Sep 15, 2023
Merged

feat: rename table to tableId #1484

merged 20 commits into from
Sep 15, 2023

Conversation

alvrs
Copy link
Member

@alvrs alvrs commented Sep 14, 2023

@changeset-bot
Copy link

changeset-bot bot commented Sep 14, 2023

🦋 Changeset detected

Latest commit: 8854d92

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 28 packages
Name Type
@latticexyz/block-logs-stream Patch
@latticexyz/store-sync Patch
@latticexyz/store Patch
@latticexyz/store-indexer Patch
@latticexyz/dev-tools Patch
@latticexyz/cli Patch
@latticexyz/react Patch
@latticexyz/world Patch
@latticexyz/abi-ts Patch
@latticexyz/common Patch
@latticexyz/config Patch
create-mud Patch
@latticexyz/ecs-browser Patch
@latticexyz/gas-report Patch
@latticexyz/network Patch
@latticexyz/noise Patch
@latticexyz/phaserx Patch
@latticexyz/protocol-parser Patch
@latticexyz/recs Patch
@latticexyz/schema-type Patch
@latticexyz/services Patch
@latticexyz/solecs Patch
solhint-config-mud Patch
solhint-plugin-mud Patch
@latticexyz/std-client Patch
@latticexyz/std-contracts Patch
@latticexyz/store-cache Patch
@latticexyz/utils Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@alvrs alvrs changed the base branch from main to alvrs/rename-value-schema September 14, 2023 15:40
@alvrs alvrs force-pushed the alvrs/rename-table-id-key-tuple branch from 58ef87c to 6edf524 Compare September 14, 2023 15:40
@alvrs
Copy link
Member Author

alvrs commented Sep 14, 2023

Current dependencies on/for this PR:

This comment was auto-generated by Graphite.

holic
holic previously approved these changes Sep 14, 2023
dk1a
dk1a previously approved these changes Sep 14, 2023
Comment on lines 11 to 21
* Note: if a tableId with composite keys is used, only the first key is indexed
*/
contract KeysInTableHook is StoreHook {
function handleSet(bytes32 tableId, bytes32[] memory key) internal {
bytes32 keysHash = keccak256(abi.encode(key));

// If the key has not yet been set in the table...
// If the key has not yet been set in the tableId...
if (!UsedKeysIndex.getHas(tableId, keysHash)) {
uint40 length = uint40(KeysInTable.lengthKeys0(tableId));

// Push the key to the list of keys in this table
// Push the key to the list of keys in this tableId
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a bunch of comments here (more below) should retain table

}

function setUp() public {
// Register table's value schema
// Register tableId's value schema
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one too

@dk1a
Copy link
Contributor

dk1a commented Sep 14, 2023

I may have missed some, didn't go through every comment

bytes32 table2 = keccak256("other.table");
StoreCore.registerTable(table, fieldLayout, defaultKeySchema, valueSchema, new string[](1), new string[](4));
bytes32 tableId = keccak256("some.tableId");
bytes32 table2 = keccak256("other.tableId");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
bytes32 table2 = keccak256("other.tableId");
bytes32 tableId2 = keccak256("other.tableId");


startGasReport("Check for existence of table (existent)");
StoreCore.hasTable(table);
startGasReport("Check for existence of tableId (existent)");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
startGasReport("Check for existence of tableId (existent)");
startGasReport("Check for existence of table (existent)");

endGasReport();

startGasReport("check for existence of table (non-existent)");
startGasReport("check for existence of tableId (non-existent)");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
startGasReport("check for existence of tableId (non-existent)");
startGasReport("check for existence of table (non-existent)");

endGasReport();
}

function testSetAndGetStaticDataSpanningWords() public {
// Register table
// Register tableId
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Register tableId
// Register table


// Register table
// Register tableId
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Register tableId
// Register table


// Register table
// Register tableId
Copy link
Member

@holic holic Sep 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Register tableId
// Register table

(there's a bunch more of this shape I didn't comment on)

@@ -634,34 +634,34 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock {

bytes memory data = abi.encodePacked(bytes16(0x0102030405060708090a0b0c0d0e0f10));

startGasReport("set record on table with subscriber");
StoreCore.setRecord(table, key, data, fieldLayout);
startGasReport("set record on tableId with subscriber");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
startGasReport("set record on tableId with subscriber");
startGasReport("set record on table with subscriber");

endGasReport();

data = abi.encodePacked(bytes16(0x1112131415161718191a1b1c1d1e1f20));

startGasReport("set static field on table with subscriber");
StoreCore.setField(table, key, 0, data, fieldLayout);
startGasReport("set static field on tableId with subscriber");
Copy link
Member

@holic holic Sep 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
startGasReport("set static field on tableId with subscriber");
startGasReport("set static field on table with subscriber");

(there's a few more of this shape I didn't comment on)

@@ -8,7 +8,7 @@ import { KeysInTable } from "./tables/KeysInTable.sol";
import { UsedKeysIndex } from "./tables/UsedKeysIndex.sol";

/**
* Note: if a table with composite keys is used, only the first key is indexed
* Note: if a tableId with composite keys is used, only the first key is indexed
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Note: if a tableId with composite keys is used, only the first key is indexed
* Note: if a table with composite keys is used, only the first key is indexed

Base automatically changed from alvrs/rename-value-schema to main September 15, 2023 11:15
@alvrs alvrs dismissed stale reviews from dk1a and holic September 15, 2023 11:15

The base branch was changed.

@alvrs alvrs merged commit 6573e38 into main Sep 15, 2023
9 checks passed
@alvrs alvrs deleted the alvrs/rename-table-id-key-tuple branch September 15, 2023 11:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants