From 88d4f04a96e929f059f115af3ffe217e639413a8 Mon Sep 17 00:00:00 2001 From: Yash Patil <40046473+ypatil12@users.noreply.github.com> Date: Wed, 6 Aug 2025 11:57:57 -0400 Subject: [PATCH 1/3] feat: add calculator operator info leaf --- lib/eigenlayer-contracts | 2 +- .../tableCalculator/BN254TableCalculatorBase.sol | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/eigenlayer-contracts b/lib/eigenlayer-contracts index 6e423cca..d28a5e4a 160000 --- a/lib/eigenlayer-contracts +++ b/lib/eigenlayer-contracts @@ -1 +1 @@ -Subproject commit 6e423ccaa79fc292e8ed23ba87f2b691923cc31a +Subproject commit d28a5e4aaad1984efc8ecb8021b730e23ad60bb1 diff --git a/src/middlewareV2/tableCalculator/BN254TableCalculatorBase.sol b/src/middlewareV2/tableCalculator/BN254TableCalculatorBase.sol index 72edc802..0d42e58e 100644 --- a/src/middlewareV2/tableCalculator/BN254TableCalculatorBase.sol +++ b/src/middlewareV2/tableCalculator/BN254TableCalculatorBase.sol @@ -7,6 +7,8 @@ import {IOperatorTableCalculator} from import {IKeyRegistrar} from "eigenlayer-contracts/src/contracts/interfaces/IKeyRegistrar.sol"; import {Merkle} from "eigenlayer-contracts/src/contracts/libraries/Merkle.sol"; import {BN254} from "eigenlayer-contracts/src/contracts/libraries/BN254.sol"; +import {LeafCalculatorMixin} from + "eigenlayer-contracts/src/contracts/mixins/LeafCalculatorMixin.sol"; import {IBN254TableCalculator} from "../../interfaces/IBN254TableCalculator.sol"; /** @@ -15,7 +17,7 @@ import {IBN254TableCalculator} from "../../interfaces/IBN254TableCalculator.sol" * @dev This contract contains all the core logic for operator table calculations, * with weight calculation left to be implemented by derived contracts */ -abstract contract BN254TableCalculatorBase is IBN254TableCalculator { +abstract contract BN254TableCalculatorBase is IBN254TableCalculator, LeafCalculatorMixin { using Merkle for bytes32[]; using BN254 for BN254.G1Point; @@ -160,8 +162,10 @@ abstract contract BN254TableCalculatorBase is IBN254TableCalculator { totalWeights[j] += weights[i][j]; } (BN254.G1Point memory g1Point,) = keyRegistrar.getBN254Key(operatorSet, operators[i]); + + // Use `LeafCalculatorMixin` to calculate the leaf hash for the operator info operatorInfoLeaves[operatorCount] = - keccak256(abi.encode(BN254OperatorInfo({pubkey: g1Point, weights: weights[i]}))); + calculateOperatorInfoLeaf(BN254OperatorInfo({pubkey: g1Point, weights: weights[i]})); // Add the operator's G1 point to the aggregate pubkey aggregatePubkey = aggregatePubkey.plus(g1Point); From 6f5caaa68ab0829eca060550a65dc0dfe045c085 Mon Sep 17 00:00:00 2001 From: Yash Patil <40046473+ypatil12@users.noreply.github.com> Date: Wed, 6 Aug 2025 12:39:48 -0400 Subject: [PATCH 2/3] fix: test --- .../middlewareV2/BN254TableCalculatorBaseUnit.t.sol | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/unit/middlewareV2/BN254TableCalculatorBaseUnit.t.sol b/test/unit/middlewareV2/BN254TableCalculatorBaseUnit.t.sol index 65c5ee1d..60a8286a 100644 --- a/test/unit/middlewareV2/BN254TableCalculatorBaseUnit.t.sol +++ b/test/unit/middlewareV2/BN254TableCalculatorBaseUnit.t.sol @@ -22,6 +22,7 @@ import {BN254TableCalculatorBase} from import {MockEigenLayerDeployer} from "./MockDeployer.sol"; import {Random} from "test/utils/Random.sol"; import {Merkle} from "eigenlayer-contracts/src/contracts/libraries/Merkle.sol"; +import {LeafCalculatorMixin} from "eigenlayer-contracts/src/contracts/mixins/LeafCalculatorMixin.sol"; // Mock implementation for testing abstract contract contract BN254TableCalculatorBaseHarness is BN254TableCalculatorBase { @@ -61,7 +62,8 @@ contract BN254TableCalculatorBaseHarness is BN254TableCalculatorBase { contract BN254TableCalculatorBaseUnitTests is MockEigenLayerDeployer, IOperatorTableCalculatorTypes, - IKeyRegistrarTypes + IKeyRegistrarTypes, + LeafCalculatorMixin { using BN254 for BN254.G1Point; using OperatorSetLib for OperatorSet; @@ -216,10 +218,8 @@ contract BN254TableCalculatorBaseUnitTests is BN254.G1Point memory pubkey, uint256[] memory weights ) internal pure returns (bytes32) { - return keccak256( - abi.encode( - IOperatorTableCalculatorTypes.BN254OperatorInfo({pubkey: pubkey, weights: weights}) - ) + return calculateOperatorInfoLeaf( + IOperatorTableCalculatorTypes.BN254OperatorInfo({pubkey: pubkey, weights: weights}) ); } } From ae7ea1be3b30284ab2cd39d8f70f658456a45593 Mon Sep 17 00:00:00 2001 From: Yash Patil <40046473+ypatil12@users.noreply.github.com> Date: Wed, 6 Aug 2025 12:42:22 -0400 Subject: [PATCH 3/3] chore: format --- test/unit/middlewareV2/BN254TableCalculatorBaseUnit.t.sol | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/unit/middlewareV2/BN254TableCalculatorBaseUnit.t.sol b/test/unit/middlewareV2/BN254TableCalculatorBaseUnit.t.sol index 60a8286a..29b83612 100644 --- a/test/unit/middlewareV2/BN254TableCalculatorBaseUnit.t.sol +++ b/test/unit/middlewareV2/BN254TableCalculatorBaseUnit.t.sol @@ -22,7 +22,8 @@ import {BN254TableCalculatorBase} from import {MockEigenLayerDeployer} from "./MockDeployer.sol"; import {Random} from "test/utils/Random.sol"; import {Merkle} from "eigenlayer-contracts/src/contracts/libraries/Merkle.sol"; -import {LeafCalculatorMixin} from "eigenlayer-contracts/src/contracts/mixins/LeafCalculatorMixin.sol"; +import {LeafCalculatorMixin} from + "eigenlayer-contracts/src/contracts/mixins/LeafCalculatorMixin.sol"; // Mock implementation for testing abstract contract contract BN254TableCalculatorBaseHarness is BN254TableCalculatorBase {