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: Increase namespace size #171

Merged
merged 4 commits into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/lib/tree/Constants.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ library Constants {
bytes1 internal constant NODE_PREFIX = 0x01;

/// @dev Parity share namespace ID
NamespaceID internal constant PARITY_SHARE_NAMESPACE_ID = NamespaceID.wrap(0xFFFFFFFFFFFFFFFF);
NamespaceID internal constant PARITY_SHARE_NAMESPACE_ID =
NamespaceID.wrap(0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
Comment on lines 18 to +20
Copy link
Contributor

Choose a reason for hiding this comment

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

[optional] in a separate PR it may make sense to rename namespace ID to namespace for similar reasons to celestiaorg/nmt#206

Copy link
Member Author

Choose a reason for hiding this comment

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

}
2 changes: 1 addition & 1 deletion src/lib/tree/Types.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.19;

type NamespaceID is bytes8;
type NamespaceID is bytes29;
Copy link
Member

Choose a reason for hiding this comment

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

Hmmm. Should this instead be a struct of a bytes1 and bytes28 https://github.com/celestiaorg/celestia-app/blob/3e6d22cfde678efac4f7c078228e9f294a7a9b8d/specs/src/specs/namespace.md#overview? The actual namespace ID isn't just one field. There isn't any code in the QGB proper that cares, but perhaps downstream contracts might care (e.g. to ensure their data was posted to the correct namespace).

Doing that would increase costs though.

Copy link
Member Author

@rach-id rach-id Aug 10, 2023

Choose a reason for hiding this comment

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

Does it make sense to handle this in a separate PR? I can create an issue for it and then make the change along with this one #172


using {equality as ==} for NamespaceID global;
using {lessthan as <} for NamespaceID global;
Expand Down
68 changes: 34 additions & 34 deletions src/lib/tree/namespace/test/NamespaceMerkleMultiproof.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,37 @@ import "../NamespaceMerkleTree.sol";
* TEST VECTORS
*
* Data blocks: namespace id, data
* 0x0000000000000010 0x01
* 0x0000000000000010 0x02
* 0x0000000000000010 0x03
* 0x0000000000000010 0x04
* 0xffffffffffffffff 0x05
* 0xffffffffffffffff 0x06
* 0xffffffffffffffff 0x07
* 0xffffffffffffffff 0x08
* 0x0000000000000000000000000000000000000000000000000000000010 0x01
* 0x0000000000000000000000000000000000000000000000000000000010 0x02
* 0x0000000000000000000000000000000000000000000000000000000010 0x03
* 0x0000000000000000000000000000000000000000000000000000000010 0x04
* 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0x05
* 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0x06
* 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0x07
* 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0x08
*
* Leaf nodes: min namespace, max namespace, data
* 0x0000000000000010 0x0000000000000010 0x531d57c729081d903721f7584b2fa031c8308918779e47d9ef68991b7a30eadf
* 0x0000000000000010 0x0000000000000010 0x95fd61ffb03e598ac50a5e203026c357595efc47e45d27334269a5e1d68212ed
* 0x0000000000000010 0x0000000000000010 0xf052f0755203a9d6c1714cc99e1d4a06433bb2427ae55a2a213b9b5f9f7b36ff
* 0x0000000000000010 0x0000000000000010 0x47ea271b50de032f8b021550f19350a09dc8d0e2372d1c2d876794487517f16e
* 0xffffffffffffffff 0xffffffffffffffff 0x19628f21c9871b13b730e4f0c3f1eb0a033e5ea36e2d928e5580dce8276f3a1f
* 0xffffffffffffffff 0xffffffffffffffff 0x2041097752c4838ed7649383808636798c3bbd9dcb7c70054a833536eca57509
* 0xffffffffffffffff 0xffffffffffffffff 0x6d9dfdf16675fe8a327bbf048a8496686ceb1444268965477c00a73720ec743a
* 0xffffffffffffffff 0xffffffffffffffff 0x22efe732017c70f7ef831b3c0b841d11fdf2230cfabf178d9560e0e4beb5adcd
* 0x0000000000000000000000000000000000000000000000000000000010 0x0000000000000000000000000000000000000000000000000000000010 0xfdb4e3c872666aa9869a1d46c8a5a0e735becdf17c62b9c3ccf4258449475bda
* 0x0000000000000000000000000000000000000000000000000000000010 0x0000000000000000000000000000000000000000000000000000000010 0x01a346b5c14a1b37e6c019eaff190f7a49718fb3036ec51360ee31de6ef58771
* 0x0000000000000000000000000000000000000000000000000000000010 0x0000000000000000000000000000000000000000000000000000000010 0x80cb31e074d15b09950610d26b9447d82a4c9beb04499fb51be9549c1a67f09f
* 0x0000000000000000000000000000000000000000000000000000000010 0x0000000000000000000000000000000000000000000000000000000010 0xc350aeddd5ada629057034f15d4545065213a7a28f9f9b77bdc71c4225145920
* 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0x1617cc7010feae70f9ff07028da463c65ec19b1d6bafde31c7543718025e5efb
* 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0x671157a4e268f7060abbdc4b48f091589555a0775a2694e6899833ec98fdb296
* 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0x2669e36b48e95bd9903300e50c27c53984fc439f6235fade08e3f14e78a42aac
* 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0x655790e24d376e9556a3cba9908a5d97f27faa050806ecfcb481861a83240bd5
*
* Inner nodes(depth = 2): min namespace, max namespace, data
* 0x0000000000000010 0x0000000000000010 0x0f9f4a39c2b64182463d0f3165d0ab513afcc9cbcb4ac561dffaf4c9ef54170f
* 0x0000000000000010 0x0000000000000010 0xd23ad50046b8fe83a22580c52ffe259d257863196574fd69d3e27968401eb99a
* 0xffffffffffffffff 0xffffffffffffffff 0xf11ca80de48fa801927a8061e234a29b8ab63b8239a9ea1efecf92688999602d
* 0xffffffffffffffff 0xffffffffffffffff 0xca4e971ee703d46a64ff78d8abf98618e79ce7d3c95e08f41806d3fb96c2bf0a
* 0x0000000000000000000000000000000000000000000000000000000010 0x0000000000000000000000000000000000000000000000000000000010 0x0ba8a1c0dcf8798d617eeed351a350d4d68792b6c42e9beaf54dd30136ca7e38
* 0x0000000000000000000000000000000000000000000000000000000010 0x0000000000000000000000000000000000000000000000000000000010 0x6d43651bd68866cb3fc8d00512fa2ab570da16c2c5254a6a7671c0400b96441a
* 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0x055a3ea75c438d752aeabbba94ed8fac93e0b32321256a65fde176dba14f5186
* 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0x1b79ffd74644e8c287fe5f1dd70bc8ea02738697cebf2810ffb2dc5157485c40
*
* Inner nodes(depth = 1): min namespace, max namespace, data
* 0x0000000000000010 0x0000000000000010 0x31cb53b761143d0a1b6b7f096b64c6c0543266fda00654070a2d485d0a66b281
* 0xffffffffffffffff 0xffffffffffffffff 0xb3da10c55a205c40528dd8a65e5be607e8a08d5a02198fdd6407419ae3c373c9
* 0x0000000000000000000000000000000000000000000000000000000010 0x0000000000000000000000000000000000000000000000000000000010 0x23fcbabf97fa3bbef73038559ca480d0de5237762e42cac08090c48713eef910
* 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0x5aa3e7ea31995fdd38f41015275229b290a8ee4810521db766ad457b9a8373d6
*
* Root node: min namespace, max namespace, data
* 0x0000000000000010 0x0000000000000010 0x02f1d195cf45f96f9bf0875cb3a8aedff5df35605fb3f50ce52a272c30822466
* 0x0000000000000000000000000000000000000000000000000000000010 0x0000000000000000000000000000000000000000000000000000000010 0x5b3328b03a538d627db78668034089cb395f63d05b24fdf99558d36fe991d268
*
*/

Expand All @@ -57,27 +57,27 @@ contract NamespaceMerkleMultiproofTest is DSTest {

/// @notice Verify inclusion of leaves 0 and 1.
function testVerifyMulti01() external {
NamespaceID nid = NamespaceID.wrap(0x0000000000000010);
NamespaceID nid = NamespaceID.wrap(0x0000000000000000000000000000000000000000000000000000000010);
NamespaceNode memory root = NamespaceNode(
NamespaceID.wrap(0x0000000000000010),
NamespaceID.wrap(0x0000000000000010),
0x02f1d195cf45f96f9bf0875cb3a8aedff5df35605fb3f50ce52a272c30822466
NamespaceID.wrap(0x0000000000000000000000000000000000000000000000000000000010),
NamespaceID.wrap(0x0000000000000000000000000000000000000000000000000000000010),
0x5b3328b03a538d627db78668034089cb395f63d05b24fdf99558d36fe991d268
);
NamespaceNode[] memory sideNodes = new NamespaceNode[](3);
sideNodes[0] = NamespaceNode(
NamespaceID.wrap(0x0000000000000010),
NamespaceID.wrap(0x0000000000000010),
0x531d57c729081d903721f7584b2fa031c8308918779e47d9ef68991b7a30eadf
NamespaceID.wrap(0x0000000000000000000000000000000000000000000000000000000010),
NamespaceID.wrap(0x0000000000000000000000000000000000000000000000000000000010),
0xfdb4e3c872666aa9869a1d46c8a5a0e735becdf17c62b9c3ccf4258449475bda
);
sideNodes[1] = NamespaceNode(
NamespaceID.wrap(0x0000000000000010),
NamespaceID.wrap(0x0000000000000010),
0x47ea271b50de032f8b021550f19350a09dc8d0e2372d1c2d876794487517f16e
NamespaceID.wrap(0x0000000000000000000000000000000000000000000000000000000010),
NamespaceID.wrap(0x0000000000000000000000000000000000000000000000000000000010),
0xc350aeddd5ada629057034f15d4545065213a7a28f9f9b77bdc71c4225145920
);
sideNodes[2] = NamespaceNode(
Constants.PARITY_SHARE_NAMESPACE_ID,
Constants.PARITY_SHARE_NAMESPACE_ID,
0xb3da10c55a205c40528dd8a65e5be607e8a08d5a02198fdd6407419ae3c373c9
0x5aa3e7ea31995fdd38f41015275229b290a8ee4810521db766ad457b9a8373d6
);

uint256 beginKey = 1;
Expand Down
Loading