diff --git a/foundry.toml b/foundry.toml index 2d98e3d27..53eb00bdd 100644 --- a/foundry.toml +++ b/foundry.toml @@ -16,6 +16,9 @@ via_ir = false # Override the Solidity version (this overrides `auto_detect_solc`) solc_version = '0.8.12' +memory_limit = 1073741824 +gas_limit = "18446744073709551615" + [rpc_endpoints] mainnet = "${RPC_MAINNET}" diff --git a/src/test/ffi/BLSPubKeyCompendiumFFI.t.sol b/src/test/ffi/BLSPubKeyCompendiumFFI.t.sol index 357d35557..7c571da00 100644 --- a/src/test/ffi/BLSPubKeyCompendiumFFI.t.sol +++ b/src/test/ffi/BLSPubKeyCompendiumFFI.t.sol @@ -21,7 +21,7 @@ contract BLSPublicKeyCompendiumFFITests is G2Operations { compendium = new BLSPublicKeyCompendium(); } - function testRegisterBLSPublicKey(uint256 _privKey) public { + function xtestRegisterBLSPublicKey(uint256 _privKey) public { _setKeys(_privKey); signedMessageHash = _signMessage(alice); diff --git a/src/test/ffi/BLSSignatureCheckerFFI.t.sol b/src/test/ffi/BLSSignatureCheckerFFI.t.sol index 8d7a931f0..1881f0e6a 100644 --- a/src/test/ffi/BLSSignatureCheckerFFI.t.sol +++ b/src/test/ffi/BLSSignatureCheckerFFI.t.sol @@ -10,17 +10,15 @@ contract BLSSignatureCheckerFFITests is FFIBase { uint256 setQuorumBitmap; function setUp() virtual public { - defaultMaxOperatorCount = type(uint32).max; _deployMockEigenLayerAndAVS(); blsSignatureChecker = new BLSSignatureChecker(registryCoordinator); } - function testSingleBLSSignatureChecker() public { - - uint64 pseudoRandomNumber = 0; - uint64 numOperators = 100; - uint64 numNonSigners = 5; + function xtestSingleBLSSignatureChecker() public { + uint64 pseudoRandomNumber = 1; + uint64 numOperators = 2; + uint64 numNonSigners = 1; uint64 numQuorums = 1; uint256 quorumBitmap = 0; diff --git a/src/test/ffi/FFIBase.sol b/src/test/ffi/FFIBase.sol index 3f47d8109..266567ec6 100644 --- a/src/test/ffi/FFIBase.sol +++ b/src/test/ffi/FFIBase.sol @@ -22,6 +22,7 @@ contract FFIBase is MockAVSDeployer, G2Operations { uint32 referenceBlockNumber, BLSSignatureChecker.NonSignerStakesAndSignature memory nonSignerStakesAndSignature ) { + vm.pauseGasMetering(); nonSignerStakesAndSignature.quorumApks = new BN254.G1Point[](numQuorums); nonSignerStakesAndSignature.nonSignerPubkeys = new BN254.G1Point[](numNonSigners); @@ -49,7 +50,7 @@ contract FFIBase is MockAVSDeployer, G2Operations { if(setQuorumBitmap > 0){ quorumBitmap = setQuorumBitmap; } else { - quorumBitmap = privKey & (1 << numQuorums - 1) | 1; + quorumBitmap = privKey & ((1 << numQuorums) - 1) | 1; if(i < numQuorums) { quorumBitmap = quorumBitmap | (1 << i); } @@ -95,11 +96,13 @@ contract FFIBase is MockAVSDeployer, G2Operations { nonSignerStakesAndSignature.totalStakeIndices = checkSignaturesIndices.totalStakeIndices; nonSignerStakesAndSignature.nonSignerStakeIndices = checkSignaturesIndices.nonSignerStakeIndices; + vm.resumeGasMetering(); return (msgHash, allQuorums, referenceBlockNumber, nonSignerStakesAndSignature); } function _setNonSignerPrivKeys(uint256 numNonSigners, uint256 pseudoRandomNumber) internal { nonSignerPrivateKeys = new uint256[](numNonSigners); + for (uint256 i = 0; i < numNonSigners; i++) { nonSignerPrivateKeys[i] = uint256(keccak256(abi.encodePacked("nonSignerPrivateKey", pseudoRandomNumber, i))) % BN254.FR_MODULUS; uint256 j = 0; diff --git a/src/test/ffi/OperatorCapAnalysisFFI.sol b/src/test/ffi/OperatorCapAnalysisFFI.sol index 843b8e909..ddb3bc64a 100644 --- a/src/test/ffi/OperatorCapAnalysisFFI.sol +++ b/src/test/ffi/OperatorCapAnalysisFFI.sol @@ -4,18 +4,39 @@ pragma solidity =0.8.12; import "./FFIBase.sol"; import "./util/BLSSigCheckerExperimental.sol"; +//memory_limit = 1073741824 +//gas_limit = "18446744073709551615" contract OperatorCapAnalysisFFI is FFIBase { using BN254 for BN254.G1Point; BLSSigCheckerExperimental blsSignatureChecker; - function testOneQuorumLinearNonSigningCost() public { - for(uint64 i = 0; i < 10; i++) { - _deployMockEigenLayerAndAVS(); - defaultMaxOperatorCount = type(uint32).max; - blsSignatureChecker = new BLSSigCheckerExperimental(registryCoordinator); - _compareScalarMuls(i, 10, i, 1, 1); - } + function xtestLoopedScalarMulComparison() public { + for(uint64 i = 1; i < 193; i++) { + _compareScalarMuls( + 1, + 2, + 1, + i, + (1 << i) - 1 + ); + } + } + + function testSingleScalarMulComparison() public { + uint64 pseudoRandomNumber = 1; + uint64 numOperators = 100; + uint64 numNonSigners = 99; + uint64 numQuorums = 2; + uint256 quorumBitmap = (1 << numQuorums) - 1; + + _compareScalarMuls( + pseudoRandomNumber, + numOperators, + numNonSigners, + numQuorums, + quorumBitmap + ); } function _compareScalarMuls( @@ -24,8 +45,13 @@ contract OperatorCapAnalysisFFI is FFIBase { uint64 numNonSigners, uint64 numQuorums, uint256 setQuorumBitmap - ) internal { + ) internal returns (uint256) { + _deployMockEigenLayerAndAVS(); + blsSignatureChecker = new BLSSigCheckerExperimental(registryCoordinator); + + vm.pauseGasMetering(); _setNonSignerPrivKeys(numNonSigners, pseudoRandomNumber); + vm.resumeGasMetering(); ( bytes32 msgHash, @@ -68,8 +94,10 @@ contract OperatorCapAnalysisFFI is FFIBase { if(tinyCost < regCost){ emit log_named_uint("-", regCost - tinyCost); + return(tinyCost); } else { emit log_named_uint("+", tinyCost - regCost); + return(regCost); } } diff --git a/src/test/utils/MockAVSDeployer.sol b/src/test/utils/MockAVSDeployer.sol index 8d06d551c..54ef495ce 100644 --- a/src/test/utils/MockAVSDeployer.sol +++ b/src/test/utils/MockAVSDeployer.sol @@ -82,7 +82,7 @@ contract MockAVSDeployer is Test { uint96 defaultStake = 1 ether; uint8 defaultQuorumNumber = 0; - uint32 defaultMaxOperatorCount = 10; + uint32 defaultMaxOperatorCount = type(uint32).max; uint16 defaultKickBIPsOfOperatorStake = 15000; uint16 defaultKickBIPsOfTotalStake = 150; uint8 numQuorums = 192;