Skip to content

Conversation

@MarcosNicolau
Copy link
Member

@MarcosNicolau MarcosNicolau commented May 13, 2025

Description

Update merkle tree backend in aggregation mode to be OpenZeppelin compliant. For it, we have to make sure that node pairs are sorted when hashing. That is:

Given node_1 and node_2:

if $node_1$ < $node_2$ $\Rightarrow$ hash($node_1$, $node_2$)
else $\Rightarrow$ hash($node_2$, $node_1$)

See OpenZeppelin reference here.

Consideration
zkvm programs ids have changed, so they must be changed in the proof aggregation contract once merged.

Type of change

  • Bug fix

Checklist

  • “Hotfix” to testnet, everything else to staging
  • Linked to Github Issue
  • This change depends on code or research by an external entity
    • Acknowledgements were updated to give credit
  • Unit tests added
  • This change requires new documentation.
    • Documentation has been added/updated.
  • This change is an Optimization
    • Benchmarks added/run
  • Has a known issue
  • If your PR changes the Operator compatibility (Ex: Upgrade prover versions)
    • This PR adds compatibility for operator for both versions and do not change batcher/docs/examples
    • This PR updates batcher and docs/examples to the newer version. This requires the operator are already updated to be compatible

@MarcosNicolau MarcosNicolau self-assigned this May 13, 2025
@github-actions
Copy link

github-actions bot commented May 13, 2025

Changes to gas cost

Generated at commit: 5ad07f8802284edab3616a93f525480a18e63d41, compared to commit: 837b4fbe4715d1b848b001bf77ce517608ae7d02

🧾 Summary (10% most significant diffs)

Contract Method Avg (+/-) %
RegistryCoordinatorHarness blsApkRegistry
stakeRegistry
+354 ❌
+354 ❌
+57.47%
+51.91%
StakeRegistryHarness delegation +146 ❌ +22.19%

Full diff report 👇
Contract Deployment Cost (+/-) Method Min (+/-) % Avg (+/-) % Median (+/-) % Max (+/-) % # Calls (+/-)
Slasher 728,578 (-870,247) initialize 366 (-556) -60.30% 366 (-556) -60.30% 366 (-556) -60.30% 366 (-556) -60.30% 6 (0)
RegistryCoordinatorHarness 5,528,683 (-4,601,377) blsApkRegistry
initialize
stakeRegistry
970 (+354)
55,078,420 (-1,203,055)
1,036 (+354)
+57.47%
-2.14%
+51.91%
970 (+354)
55,078,420 (-1,203,055)
1,036 (+354)
+57.47%
-2.14%
+51.91%
970 (+354)
55,078,420 (-1,203,055)
1,036 (+354)
+57.47%
-2.14%
+51.91%
970 (+354)
55,078,420 (-1,203,055)
1,036 (+354)
+57.47%
-2.14%
+51.91%
6 (0)
6 (0)
6 (0)
StakeRegistryHarness 2,590,172 (-2,549,338) delegation
initializeQuorum
804 (+146)
144,420 (-1,780)
+22.19%
-1.22%
804 (+146)
164,216 (-1,780)
+22.19%
-1.07%
804 (+146)
164,320 (-1,780)
+22.19%
-1.07%
804 (+146)
164,320 (-1,780)
+22.19%
-1.07%
6 (0)
1,152 (0)
AlignedLayerServiceManager 4,398,072 (-3,921,136) batchesState
createNewTask
disableVerifier
disabledVerifiers
enableVerifier
isVerifierDisabled
receive
setDisabledVerifiers
5,132 (-278)
56,886 (-956)
24,602 (+303)
3,030 (+516)
23,748 (-443)
2,406 (-450)
23,301 (-195)
24,243 (-7)
-5.14%
-1.65%
+1.25%
+20.53%
-1.83%
-15.76%
-0.83%
-0.03%
5,132 (-278)
76,970 (-827)
36,191 (+375)
3,030 (+516)
24,388 (-372)
2,406 (-450)
46,928 (-263)
35,262 (+86)
-5.14%
-1.06%
+1.05%
+20.53%
-1.50%
-15.76%
-0.56%
+0.24%
5,132 (-278)
77,074 (-848)
36,191 (+375)
3,030 (+516)
24,388 (-372)
2,406 (-450)
47,115 (-357)
35,262 (+86)
-5.14%
-1.09%
+1.05%
+20.53%
-1.50%
-15.76%
-0.75%
+0.24%
5,132 (-278)
77,836 (-956)
47,780 (+446)
3,030 (+516)
25,029 (-300)
2,406 (-450)
47,115 (-357)
46,282 (+179)
-5.14%
-1.21%
+0.94%
+20.53%
-1.18%
-15.76%
-0.75%
+0.39%
256 (0)
256 (0)
2 (0)
1 (0)
2 (0)
3 (0)
256 (0)
2 (0)
AVSDirectory 1,485,692 (-1,689,090) initialize 97,570 (-3,067) -3.05% 97,570 (-3,067) -3.05% 97,570 (-3,067) -3.05% 97,570 (-3,067) -3.05% 6 (0)
ServiceManagerMock 1,340,500 (-1,292,283) initialize 71,296 (-2,066) -2.82% 71,296 (-2,066) -2.82% 71,296 (-2,066) -2.82% 71,296 (-2,066) -2.82% 6 (0)
ProxyAdmin 412,495 (-345,151) upgrade
upgradeAndCall
38,758 (-883)
55,403,611 (-1,228,407)
-2.23%
-2.17%
38,767 (-883)
55,403,611 (-1,228,407)
-2.23%
-2.17%
38,770 (-883)
55,403,611 (-1,228,407)
-2.23%
-2.17%
38,770 (-883)
55,403,611 (-1,228,407)
-2.23%
-2.17%
24 (0)
6 (0)
BLSApkRegistryHarness 1,676,697 (-1,447,540) initializeQuorum
setBLSPublicKey
45,382 (-596)
89,551 (-556)
-1.30%
-0.62%
45,382 (-596)
89,551 (-556)
-1.30%
-0.62%
45,382 (-596)
89,551 (-556)
-1.30%
-0.62%
45,382 (-596)
89,551 (-556)
-1.30%
-0.62%
1,152 (0)
6 (0)
TransparentUpgradeableProxy 521,513 (-376,486) fallback 1,634 (+90) +5.83% 47,449 (-617) -1.28% 8,200 (+90) +1.11% 119,180 (-820) -0.68% 30 (0)
StrategyManagerMock 1,146,058 (-1,255,314) setAddresses 88,974 (-768) -0.86% 88,974 (-768) -0.86% 88,974 (-768) -0.86% 88,974 (-768) -0.86% 6 (0)
IndexRegistry 917,389 (-790,168) initializeQuorum 45,244 (-348) -0.76% 45,244 (-348) -0.76% 45,244 (-348) -0.76% 45,244 (-348) -0.76% 1,152 (0)

@JuArce JuArce changed the title fix(agg-mode): merkle-tree backend openzeppelin compliant fix(aggregation_mode): merkle-tree backend openzeppelin compliant May 14, 2025
fix: add missing new line
chore: update program ids
@JuArce JuArce requested a review from Copilot May 14, 2025 19:41
Copy link

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

This PR fixes a bug by updating the merkle tree backend in aggregation mode to be OpenZeppelin compliant. The key changes include updating program IDs across several configuration files and modifying the hash_new_parent implementations to use sorted child nodes in the hash computation.

Reviewed Changes

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

Show a summary per file
File Description
contracts/script/deploy/config/**.json Updated program IDs for consistency with new zkvm program IDs
batcher/aligned-sdk/src/sdk/aggregation.rs Added sorted hash computation documented per OpenZeppelin guidelines
aggregation_mode/src/aggregators/mod.rs Added sorted hash computation as above
aggregation_mode/programs_ids.json Updated program IDs
aggregation_mode/aggregation_programs/sp1/src/lib.rs Added sorted hash computation per OpenZeppelin guidelines
aggregation_mode/aggregation_programs/risc0/src/lib.rs Added sorted hash computation; uses a different Keccak hasher variant
Comments suppressed due to low confidence (1)

aggregation_mode/aggregation_programs/risc0/src/lib.rs:55

  • [nitpick] The Risc0 implementation uses Keccak::v256() while other modules use Keccak256. Consider aligning the hasher usage or adding a comment clarifying the reason for this difference.
let mut hasher = Keccak::v256();

JuArce added 2 commits May 14, 2025 16:44
# Conflicts:
#	contracts/scripts/anvil/state/alignedlayer-deployed-anvil-state.json
@MauroToscano MauroToscano enabled auto-merge May 15, 2025 14:19
@JuArce JuArce disabled auto-merge May 15, 2025 18:34
Copy link
Collaborator

@JuArce JuArce left a comment

Choose a reason for hiding this comment

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

I'm updating the ethereum package contracts

@JuArce JuArce enabled auto-merge May 15, 2025 19:59
@JuArce JuArce added this pull request to the merge queue May 15, 2025
Merged via the queue into staging with commit adc5793 May 15, 2025
5 checks passed
@JuArce JuArce deleted the fix/tree-openzeppelin-compliant branch May 15, 2025 20:22
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.

4 participants