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); diff --git a/test/unit/middlewareV2/BN254TableCalculatorBaseUnit.t.sol b/test/unit/middlewareV2/BN254TableCalculatorBaseUnit.t.sol index 65c5ee1d..29b83612 100644 --- a/test/unit/middlewareV2/BN254TableCalculatorBaseUnit.t.sol +++ b/test/unit/middlewareV2/BN254TableCalculatorBaseUnit.t.sol @@ -22,6 +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"; // Mock implementation for testing abstract contract contract BN254TableCalculatorBaseHarness is BN254TableCalculatorBase { @@ -61,7 +63,8 @@ contract BN254TableCalculatorBaseHarness is BN254TableCalculatorBase { contract BN254TableCalculatorBaseUnitTests is MockEigenLayerDeployer, IOperatorTableCalculatorTypes, - IKeyRegistrarTypes + IKeyRegistrarTypes, + LeafCalculatorMixin { using BN254 for BN254.G1Point; using OperatorSetLib for OperatorSet; @@ -216,10 +219,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}) ); } }