Create storage helpers for AggLayerBridge#2562
Conversation
partylikeits1983
left a comment
There was a problem hiding this comment.
Looks good! Once all of Marti's comments are addressed I think its good to merge
mmagician
left a comment
There was a problem hiding this comment.
LGTM bar the debug vs. runtime assertion question
| fn slot_names() -> Vec<&'static StorageSlotName> { | ||
| vec![ | ||
| &*GER_MAP_SLOT_NAME, | ||
| &*LET_FRONTIER_SLOT_NAME, | ||
| &*LET_ROOT_LO_SLOT_NAME, | ||
| &*LET_ROOT_HI_SLOT_NAME, | ||
| &*LET_NUM_LEAVES_SLOT_NAME, | ||
| &*FAUCET_REGISTRY_SLOT_NAME, | ||
| &*BRIDGE_ADMIN_SLOT_NAME, | ||
| &*GER_MANAGER_SLOT_NAME, | ||
| ] | ||
| } |
There was a problem hiding this comment.
The approach we've taken in the standard components is a bit different from this one: we have a method that returns AccountComponentMetadata (e.g., see here) and then this method is used to build an account component (e.g., here).
A potential improvement on that is to have another method that returns StorageSchema and then use that method in the method that returns AccountComponentMetadata.
There was a problem hiding this comment.
IIUC, this only applies to how we build AccountComponentMetadata, right? Currently, we construct it manually:
let metadata = AccountComponentMetadata::new("agglayer::bridge")
.with_description("Bridge component for AggLayer")
.with_supports_all_types();And I think your suggestion is to have a helper on AggLayerBridge to return this:
let metadata = AggLayerBridge::component_metadata();Did I get your comment correctly?
There was a problem hiding this comment.
@copilot implement the suggested change branching off agglayer branch, and make a PR there.
| pub fn is_ger_registered( | ||
| ger: ExitRoot, | ||
| bridge_account: Account, | ||
| ) -> Result<bool, AgglayerBridgeError> { |
There was a problem hiding this comment.
As discussed offline, this approach is fine for now - but in production, we'll probably have to re-work this as loading the full account into memory may become prohibitively expensive. The two driving factors of this would be:
- GER storage map. This currently has un-bounded growth. If we do come up with a strategy to cap the growth somehow, then this may not be as big of an issue.
CLAIMnote nullifier map (onceCLAIMnotes are re-oriented toward the bridge account). Here too, if we find a way not to store all note nullifiers in the account, the bridge account size would likely be pretty small.
If the bridge account does grow in size over time, the alternative way to handle these types of methods would be on the client wrapper and to use the StorageReader to read specific information from the database as needed.
There was a problem hiding this comment.
👍🏼 I created 0xMiden/miden-client#1899 to track this
This PR adds helper functions to the
AggLayerBridgestruct to simplify the storage checks and make them more robust.Namely, this PR:
is_ger_registeredhelper method in theAggLayerBridgeto simplify the GER presence in the storage.read_local_exit_rootprocedure from the testing crate to agglayer, making it a method of theAggLayerBridge.Both this methods got an internal check, whether the provided account is in fact an
AggLayerBridgeaccount.Once this PR is merged, we should remove the
is_ger_registeredprocedure from themiden-client's testing utilities (0xMiden/miden-client#1854).Closes: #2548