Skip to content

feat(agglayer): store block number with each registered GER#2579

Open
mmagician wants to merge 3 commits intoagglayerfrom
mmagician-claude/store-block-num-with-ger
Open

feat(agglayer): store block number with each registered GER#2579
mmagician wants to merge 3 commits intoagglayerfrom
mmagician-claude/store-block-num-with-ger

Conversation

@mmagician
Copy link
Collaborator

Summary

  • Store the transaction's reference block number alongside the GER flag in the bridge's GER map, changing the value from [1, 0, 0, 0] to [1, block_num, 0, 0]
  • Update assert_valid_ger to check only the flag element (instead of full word comparison), since block_num is now variable
  • Update SPEC.md to reflect the new GER map value layout

Test plan

  • BUILD_GENERATED_FILES_IN_SRC=1 make test name=update_ger - all 3 tests pass
  • make lint - clean

Closes #2578

🤖 Generated with Claude Code

Store the transaction's reference block number alongside the GER flag
in the bridge's GER map, changing the value from [1, 0, 0, 0] to
[1, block_num, 0, 0]. This enables recovery scenarios that need to
know when each GER was registered.

The assert_valid_ger procedure now checks only the flag element instead
of comparing the full word, since the block_num element is variable.

Closes #2578

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Address review feedback: reorder stack operations so the flag is pushed
before getting the block number, eliminating the need for a swap.

Also add changelog entry.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the AggLayer bridge GER registry to persist the transaction reference block number alongside the “known” flag, enabling recovery workflows to determine when a GER was registered.

Changes:

  • Store [GER_KNOWN_FLAG, block_num, 0, 0] as the GER map value (instead of a fixed sentinel).
  • Update assert_valid_ger to validate only the flag element, since block_num varies.
  • Update tests and spec/docs to reflect the new GER value layout.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
crates/miden-testing/tests/agglayer/update_ger.rs Updates storage assertion to include the stored reference block number.
crates/miden-agglayer/asm/agglayer/bridge/bridge_config.masm Writes block_num into GER map values and adjusts GER validation logic accordingly.
crates/miden-agglayer/SPEC.md Documents the updated GER map value encoding and meaning.
CHANGELOG.md Notes the new feature in the upcoming release changelog.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mmagician mmagician added agglayer PRs or issues related to AggLayer bridging integration pr-from-maintainers PRs that come from internal contributors or integration partners. They should be given priority labels Mar 11, 2026
@mmagician mmagician force-pushed the mmagician-claude/store-block-num-with-ger branch 3 times, most recently from 4355e05 to 7149c9e Compare March 14, 2026 10:54
Resolve conflicts in update_ger.rs: use the new AggLayerBridge helpers
instead of direct storage access. Update is_ger_registered to check
only the flag element (since the value is now [1, block_num, 0, 0]),
and add get_ger_block_number to retrieve the registration block number.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@mmagician mmagician force-pushed the mmagician-claude/store-block-num-with-ger branch from 7149c9e to 0689bf8 Compare March 14, 2026 10:59
@mmagician mmagician requested a review from Copilot March 15, 2026 09:13
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 175 to +182
pub fn is_ger_registered(
ger: ExitRoot,
bridge_account: Account,
) -> Result<bool, AgglayerBridgeError> {
// check that the provided account is a bridge account
Self::assert_bridge_account(&bridge_account)?;
let stored_value = Self::get_ger_value(ger, &bridge_account)?;
Ok(stored_value[Self::GER_FLAG_INDEX] == Self::REGISTERED_GER_FLAG)
}
Comment on lines +191 to +202
pub fn get_ger_block_number(
ger: ExitRoot,
bridge_account: Account,
) -> Result<Option<BlockNumber>, AgglayerBridgeError> {
Self::assert_bridge_account(&bridge_account)?;
let stored_value = Self::get_ger_value(ger, &bridge_account)?;
if stored_value[Self::GER_FLAG_INDEX] != Self::REGISTERED_GER_FLAG {
return Ok(None);
}
let block_num = stored_value[Self::GER_BLOCK_NUM_INDEX].as_int() as u32;
Ok(Some(BlockNumber::from(block_num)))
}
if stored_value[Self::GER_FLAG_INDEX] != Self::REGISTERED_GER_FLAG {
return Ok(None);
}
let block_num = stored_value[Self::GER_BLOCK_NUM_INDEX].as_int() as u32;
Comment on lines +54 to +58
# prepare VALUE = [0, 0, block_num, GER_KNOWN_FLAG]
push.GER_KNOWN_FLAG
exec.tx::get_block_number
push.0.0
# => [0, 0, block_num, GER_KNOWN_FLAG, GER_HASH, pad(12)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agglayer PRs or issues related to AggLayer bridging integration pr-from-maintainers PRs that come from internal contributors or integration partners. They should be given priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants