-
Notifications
You must be signed in to change notification settings - Fork 4
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: store ciphernode in an incremental merkle tree #44
Conversation
WalkthroughThe updates to the Changes
Sequence Diagram(s)sequenceDiagram
participant Owner
participant CiphernodeRegistry
participant LeanIMTData
Owner->>CiphernodeRegistry: addCiphernode(node)
CiphernodeRegistry->>LeanIMTData: insert(node)
LeanIMTData-->>CiphernodeRegistry: success
CiphernodeRegistry-->>Owner: emit CiphernodeAdded(node, index, numNodes, size)
Owner->>CiphernodeRegistry: removeCiphernode(node, siblingNodes)
CiphernodeRegistry->>LeanIMTData: remove(node, siblingNodes)
LeanIMTData-->>CiphernodeRegistry: success
CiphernodeRegistry-->>Owner: emit CiphernodeRemoved(node, index, numNodes, size)
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- packages/evm/contracts/interfaces/ICiphernodeRegistry.sol (1 hunks)
- packages/evm/contracts/registry/CiphernodeRegistryOwnable.sol (4 hunks)
Additional comments not posted (6)
packages/evm/contracts/registry/CiphernodeRegistryOwnable.sol (6)
9-13
: Refactor: Import and use of new libraries.The new libraries
InternalLeanIMT
,LeanIMTData
, andPoseidonT3
are imported and used to manage the cipher nodes with an incremental Merkle tree. This change aligns with the PR objectives to enhance node management efficiency.
16-16
: Best Practice: Use of library functions on data types.The
using
statement forInternalLeanIMT
onLeanIMTData
is a good practice in Solidity, enabling more readable and maintainable code by attaching library functions directly to the data type.
117-125
: Enhancement: UpdatedaddCiphernode
function.The function now converts the node address to a
uint256
and uses the_insert
method fromInternalLeanIMT
to manage the cipher nodes. This is a significant improvement over the previous boolean tracking mechanism, enhancing both performance and scalability.
128-142
: Refactor: UpdatedremoveCiphernode
function.This function now accepts an additional parameter
siblingNodes
which is necessary for the removal process in the incremental Merkle tree. The function also correctly updates thenumCiphernodes
counter and emits detailed events about the state changes, which improves transparency and traceability.
146-146
: Refactor: Renamed function toisEnabled
.The function
isCiphernodeEligible
has been renamed toisEnabled
to better reflect its functionality, which checks if a node is enabled in theciphernodes
structure. This change improves clarity and consistency in the codebase.
162-164
: Enhancement: Implementation ofisEnabled
function.This new function provides a public interface to check if a ciphernode is present in the Merkle tree, using the
_has
method fromInternalLeanIMT
. This is a straightforward and efficient way to check node status, aligning with the PR's goal to enhance node management.
/// @param node Address of the ciphernode. | ||
/// @param index Index of the ciphernode in the registry. | ||
/// @param numNodes Number of ciphernodes in the registry. | ||
/// @param size Size of the registry. | ||
event CiphernodeAdded( | ||
address indexed node, | ||
uint256 index, | ||
uint256 numNodes, | ||
uint256 size | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Enhanced event parameters for CiphernodeAdded
.
The addition of index
, numNodes
, and size
parameters to the CiphernodeAdded
event is a positive change that aligns with the PR objectives of enhancing node management. These parameters provide valuable context about the registry's state when a node is added, which can be crucial for listeners tracking changes.
Suggestion: Improve parameter documentation.
While the parameters are well-named, adding a brief description in the comments for each parameter could improve clarity and developer experience.
/// @param node Address of the ciphernode. | ||
/// @param index Index of the ciphernode in the registry. | ||
/// @param numNodes Number of ciphernodes in the registry. | ||
/// @param size Size of the registry. | ||
event CiphernodeRemoved( | ||
address indexed node, | ||
uint256 index, | ||
uint256 numNodes, | ||
uint256 size | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Enhanced event parameters for CiphernodeRemoved
.
The addition of index
, numNodes
, and size
parameters to the CiphernodeRemoved
event mirrors the changes made to the CiphernodeAdded
event, maintaining consistency and enhancing the utility of these events. This change allows listeners to better understand the impact of a node's removal on the registry.
Suggestion: Improve parameter documentation.
As with the CiphernodeAdded
event, enhancing the documentation for these new parameters would further improve clarity and usability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- packages/evm/contracts/registry/CiphernodeRegistryOwnable.sol (5 hunks)
Files skipped from review as they are similar to previous changes (1)
- packages/evm/contracts/registry/CiphernodeRegistryOwnable.sol
This PR:
CiphernodeAdded()
andCiphernodeRemoved()
events, to make it simpler for the node software to track the current state of the registry.Summary by CodeRabbit
New Features
Bug Fixes