diff --git a/contracts/src/v0.8/llo-feeds/v0.5.0/Verifier.sol b/contracts/src/v0.8/llo-feeds/v0.5.0/Verifier.sol index 13dd7980631..55e1c542291 100644 --- a/contracts/src/v0.8/llo-feeds/v0.5.0/Verifier.sol +++ b/contracts/src/v0.8/llo-feeds/v0.5.0/Verifier.sol @@ -52,7 +52,7 @@ contract Verifier is IVerifier, ConfirmedOwner, TypeAndVersionInterface { // The block number of the block the last time the configuration was updated. uint32 latestConfigBlockNumber; // Whether the config is deactivated - bool isDeactivated; + bool isActive; // Fault tolerance uint8 f; // Map of signer addresses to oracles @@ -182,14 +182,14 @@ contract Verifier is IVerifier, ConfirmedOwner, TypeAndVersionInterface { bytes32 rawVs ) = abi.decode(signedReport, (bytes32[3], bytes, bytes32[], bytes32[], bytes32)); - VerifierState storage verifierState = s_verifierStates[reportContext[0]]; - // reportContext consists of: // reportContext[0]: ConfigDigest // reportContext[1]: 27 byte padding, 4-byte epoch and 1-byte round // reportContext[2]: ExtraHash bytes32 configDigest = reportContext[0]; + VerifierState storage verifierState = s_verifierStates[configDigest]; + _validateReport(configDigest, rs, ss, verifierState); bytes32 hashedReport = keccak256(reportData); @@ -213,7 +213,7 @@ contract Verifier is IVerifier, ConfirmedOwner, TypeAndVersionInterface { ) private view { uint8 expectedNumSignatures = config.f + 1; - if (!config.isDeactivated) revert DigestInactive(configDigest); + if (!config.isActive) revert DigestInactive(configDigest); if (rs.length != expectedNumSignatures) revert IncorrectSignatureCount(rs.length, expectedNumSignatures); if (rs.length != ss.length) revert MismatchedSignatures(rs.length, ss.length); } @@ -326,6 +326,7 @@ contract Verifier is IVerifier, ConfirmedOwner, TypeAndVersionInterface { verifierState.latestConfigBlockNumber = uint32(block.number); verifierState.configCount = configCount; verifierState.f = f; + verifierState.isActive = true; for (uint8 i; i < signers.length; ++i) { address signerAddr = signers[i]; @@ -405,8 +406,8 @@ contract Verifier is IVerifier, ConfirmedOwner, TypeAndVersionInterface { ) ); uint256 prefixMask = type(uint256).max << (256 - 16); // 0xFFFF00..00 - // 0x0006 corresponds to ConfigDigestPrefixMercuryV02 in libocr - uint256 prefix = 0x0009 << (256 - 16); // 0x000600..00 + // 0x0009 corresponds to ConfigDigestPrefixMercuryV02 in libocr + uint256 prefix = 0x0009 << (256 - 16); // 0x000900..00 return bytes32((prefix & prefixMask) | (h & ~prefixMask)); } @@ -416,7 +417,7 @@ contract Verifier is IVerifier, ConfirmedOwner, TypeAndVersionInterface { if (configDigest == bytes32("")) revert DigestEmpty(); if (verifierState.f == 0) revert DigestNotSet(configDigest); - verifierState.isDeactivated = false; + verifierState.isActive = true; emit ConfigActivated(configDigest); } @@ -426,7 +427,7 @@ contract Verifier is IVerifier, ConfirmedOwner, TypeAndVersionInterface { if (configDigest == bytes32("")) revert DigestEmpty(); if (verifierState.f == 0) revert DigestNotSet(configDigest); - verifierState.isDeactivated = true; + verifierState.isActive = false; emit ConfigDeactivated(configDigest); } diff --git a/contracts/src/v0.8/llo-feeds/v0.5.0/test/gas/Gas_VerifierTest.t.sol b/contracts/src/v0.8/llo-feeds/v0.5.0/test/gas/Gas_VerifierTest.t.sol index ee8ba4c3e34..a9bd067696a 100644 --- a/contracts/src/v0.8/llo-feeds/v0.5.0/test/gas/Gas_VerifierTest.t.sol +++ b/contracts/src/v0.8/llo-feeds/v0.5.0/test/gas/Gas_VerifierTest.t.sol @@ -19,11 +19,14 @@ contract Verifier_setConfig is BaseTest { function testSetConfigSuccess_gas() public { s_verifier.setConfig( FEED_ID, + SOURCE_CHAIN_ID, + SOURCE_ADDRESS, + 1, s_signerAddrs, s_offchaintransmitters, FAULT_TOLERANCE, bytes(""), - VERIFIER_VERSION, + 1, bytes(""), new Common.AddressAndWeight[](0) ); @@ -44,7 +47,7 @@ contract Verifier_verifyWithFee is BaseTestWithConfiguredVerifierAndFeeManager { //warm the rewardManager link.mint(address(this), DEFAULT_NATIVE_MINT_QUANTITY); _approveLink(address(rewardManager), DEFAULT_REPORT_LINK_FEE, address(this)); - (, , bytes32 latestConfigDigest) = s_verifier.latestConfigDetails(FEED_ID); + bytes32 latestConfigDigest = v1ConfigDigest; //mint some tokens to the user link.mint(USER, DEFAULT_LINK_MINT_QUANTITY); @@ -103,7 +106,7 @@ contract Verifier_bulkVerifyWithFee is BaseTestWithConfiguredVerifierAndFeeManag //warm the rewardManager link.mint(address(this), DEFAULT_NATIVE_MINT_QUANTITY); _approveLink(address(rewardManager), DEFAULT_REPORT_LINK_FEE, address(this)); - (, , bytes32 latestConfigDigest) = s_verifier.latestConfigDetails(FEED_ID); + bytes32 latestConfigDigest = v1ConfigDigest; //mint some tokens to the user link.mint(USER, DEFAULT_LINK_MINT_QUANTITY); @@ -174,7 +177,7 @@ contract Verifier_verify is BaseTestWithConfiguredVerifierAndFeeManager { BLOCKNUMBER_LOWER_BOUND, uint32(block.timestamp) ); - (, , s_configDigest) = s_verifier.latestConfigDetails(FEED_ID); + s_configDigest = v1ConfigDigest; bytes32[3] memory reportContext; reportContext[0] = s_configDigest; reportContext[1] = bytes32(abi.encode(uint32(5), uint8(1))); @@ -213,7 +216,7 @@ contract Verifier_accessControlledVerify is BaseTestWithConfiguredVerifierAndFee BLOCKNUMBER_LOWER_BOUND, uint32(block.timestamp) ); - (, , s_configDigest) = s_verifier.latestConfigDetails(FEED_ID); + s_configDigest = v1ConfigDigest; bytes32[3] memory reportContext; reportContext[0] = s_configDigest; reportContext[1] = bytes32(abi.encode(uint32(5), uint8(1))); diff --git a/contracts/src/v0.8/llo-feeds/v0.5.0/test/mocks/ErroredVerifier.sol b/contracts/src/v0.8/llo-feeds/v0.5.0/test/mocks/ErroredVerifier.sol index e9dcd589e23..da0ad973cb1 100644 --- a/contracts/src/v0.8/llo-feeds/v0.5.0/test/mocks/ErroredVerifier.sol +++ b/contracts/src/v0.8/llo-feeds/v0.5.0/test/mocks/ErroredVerifier.sol @@ -40,20 +40,8 @@ contract ErroredVerifier is IVerifier { revert FailedToVerify(); } - function setConfig( - bytes32, - address[] memory, - bytes32[] memory, - uint8, - bytes memory, - uint64, - bytes memory, - Common.AddressAndWeight[] memory - ) external pure override { - revert FailedToSetConfig(); - } - function setConfigFromSource( + function setConfig( bytes32, uint256, address, @@ -69,27 +57,15 @@ contract ErroredVerifier is IVerifier { revert FailedToSetConfig(); } - function activateConfig(bytes32, bytes32) external pure { + function activateConfig(bytes32) external pure { revert FailedToActivateConfig(); } - function deactivateConfig(bytes32, bytes32) external pure { + function deactivateConfig(bytes32) external pure { revert FailedToDeactivateConfig(); } - function activateFeed(bytes32) external pure { - revert FailedToActivateFeed(); - } - - function deactivateFeed(bytes32) external pure { - revert FailedToDeactivateFeed(); - } - - function latestConfigDigestAndEpoch(bytes32) external pure override returns (bool, bytes32, uint32) { - revert FailedToGetLatestConfigDigestAndEpoch(); - } - - function latestConfigDetails(bytes32) external pure override returns (uint32, uint32, bytes32) { + function latestConfigDetails(bytes32) external pure override returns (uint32, uint32) { revert FailedToGetLatestConfigDetails(); } } diff --git a/contracts/src/v0.8/llo-feeds/v0.5.0/test/verifier/BaseVerifierTest.t.sol b/contracts/src/v0.8/llo-feeds/v0.5.0/test/verifier/BaseVerifierTest.t.sol index 4d65414676e..b1aa872be0f 100644 --- a/contracts/src/v0.8/llo-feeds/v0.5.0/test/verifier/BaseVerifierTest.t.sol +++ b/contracts/src/v0.8/llo-feeds/v0.5.0/test/verifier/BaseVerifierTest.t.sol @@ -28,6 +28,9 @@ contract BaseTest is Test { bytes32 internal constant V2_BITMASK = 0x0002000000000000000000000000000000000000000000000000000000000000; bytes32 internal constant V3_BITMASK = 0x0003000000000000000000000000000000000000000000000000000000000000; + uint256 internal constant SOURCE_CHAIN_ID = 0x1234; + address internal constant SOURCE_ADDRESS = address(0x1234); + //version 0 feeds bytes32 internal constant FEED_ID = (keccak256("ETH-USD") & V_MASK) | V1_BITMASK; bytes32 internal constant FEED_ID_2 = (keccak256("LINK-USD") & V_MASK) | V1_BITMASK; @@ -205,7 +208,7 @@ contract BaseTest is Test { ) ); uint256 prefixMask = type(uint256).max << (256 - 16); // 0xFFFF00..00 - uint256 prefix = 0x0006 << (256 - 16); // 0x000600..00 + uint256 prefix = 0x0009 << (256 - 16); // 0x000900..00 return bytes32((prefix & prefixMask) | (h & ~prefixMask)); } @@ -288,6 +291,9 @@ contract BaseTestWithConfiguredVerifierAndFeeManager is BaseTest { s_verifierProxy.initializeVerifier(address(s_verifier)); s_verifier.setConfig( FEED_ID, + SOURCE_CHAIN_ID, + SOURCE_ADDRESS, + 1, _getSignerAddresses(signers), s_offchaintransmitters, FAULT_TOLERANCE, @@ -296,10 +302,25 @@ contract BaseTestWithConfiguredVerifierAndFeeManager is BaseTest { bytes(""), new Common.AddressAndWeight[](0) ); - (, , v1ConfigDigest) = s_verifier.latestConfigDetails(FEED_ID); + + v1ConfigDigest = _configDigestFromConfigData( + FEED_ID, + SOURCE_CHAIN_ID, + SOURCE_ADDRESS, + 1, + _getSignerAddresses(signers), + s_offchaintransmitters, + FAULT_TOLERANCE, + bytes(""), + VERIFIER_VERSION, + bytes("") + ); s_verifier.setConfig( FEED_ID_V3, + SOURCE_CHAIN_ID, + SOURCE_ADDRESS, + 1, _getSignerAddresses(signers), s_offchaintransmitters, FAULT_TOLERANCE, @@ -308,7 +329,19 @@ contract BaseTestWithConfiguredVerifierAndFeeManager is BaseTest { bytes(""), new Common.AddressAndWeight[](0) ); - (, , v3ConfigDigest) = s_verifier.latestConfigDetails(FEED_ID_V3); + + v3ConfigDigest = _configDigestFromConfigData( + FEED_ID_V3, + SOURCE_CHAIN_ID, + SOURCE_ADDRESS, + 1, + _getSignerAddresses(signers), + s_offchaintransmitters, + FAULT_TOLERANCE, + bytes(""), + VERIFIER_VERSION, + bytes("") + ); link = new ERC20Mock("LINK", "LINK", ADMIN, 0); native = new WERC20Mock(); @@ -442,12 +475,15 @@ contract BaseTestWithMultipleConfiguredDigests is BaseTestWithConfiguredVerifier BaseTestWithConfiguredVerifierAndFeeManager.setUp(); Signer[] memory signers = _getSigners(MAX_ORACLES); - (, , s_configDigestOne) = s_verifier.latestConfigDetails(FEED_ID); + s_configDigestOne = v1ConfigDigest; // Verifier 1, Feed 1, Config 2 Signer[] memory secondSetOfSigners = _getSigners(8); s_verifier.setConfig( FEED_ID, + SOURCE_CHAIN_ID, + SOURCE_ADDRESS, + 2, _getSignerAddresses(secondSetOfSigners), s_offchaintransmitters, FAULT_TOLERANCE_TWO, @@ -456,12 +492,27 @@ contract BaseTestWithMultipleConfiguredDigests is BaseTestWithConfiguredVerifier bytes(""), new Common.AddressAndWeight[](0) ); - (, , s_configDigestTwo) = s_verifier.latestConfigDetails(FEED_ID); + + s_configDigestTwo = _configDigestFromConfigData( + FEED_ID, + SOURCE_CHAIN_ID, + SOURCE_ADDRESS, + 2, + _getSignerAddresses(secondSetOfSigners), + s_offchaintransmitters, + FAULT_TOLERANCE_TWO, + bytes(""), + 2, + bytes("") + ); // Verifier 1, Feed 1, Config 3 Signer[] memory thirdSetOfSigners = _getSigners(5); s_verifier.setConfig( FEED_ID, + SOURCE_CHAIN_ID, + SOURCE_ADDRESS, + 3, _getSignerAddresses(thirdSetOfSigners), s_offchaintransmitters, FAULT_TOLERANCE_THREE, @@ -470,11 +521,25 @@ contract BaseTestWithMultipleConfiguredDigests is BaseTestWithConfiguredVerifier bytes(""), new Common.AddressAndWeight[](0) ); - (s_numConfigsSet, , s_configDigestThree) = s_verifier.latestConfigDetails(FEED_ID); + s_configDigestThree = _configDigestFromConfigData( + FEED_ID, + SOURCE_CHAIN_ID, + SOURCE_ADDRESS, + 3, + _getSignerAddresses(thirdSetOfSigners), + s_offchaintransmitters, + FAULT_TOLERANCE_THREE, + bytes(""), + 3, + bytes("") + ); // Verifier 1, Feed 2, Config 1 s_verifier.setConfig( FEED_ID_2, + SOURCE_CHAIN_ID, + SOURCE_ADDRESS, + 1, _getSignerAddresses(signers), s_offchaintransmitters, FAULT_TOLERANCE, @@ -483,20 +548,45 @@ contract BaseTestWithMultipleConfiguredDigests is BaseTestWithConfiguredVerifier bytes(""), new Common.AddressAndWeight[](0) ); - (, , s_configDigestFour) = s_verifier.latestConfigDetails(FEED_ID_2); + s_configDigestFour = _configDigestFromConfigData( + FEED_ID_2, + SOURCE_CHAIN_ID, + SOURCE_ADDRESS, + 1, + _getSignerAddresses(signers), + s_offchaintransmitters, + FAULT_TOLERANCE, + bytes(""), + 4, + bytes("") + ); // Verifier 2, Feed 3, Config 1 s_verifierProxy.initializeVerifier(address(s_verifier_2)); s_verifier_2.setConfig( FEED_ID_3, + SOURCE_CHAIN_ID, + SOURCE_ADDRESS, + 1, _getSignerAddresses(signers), s_offchaintransmitters, FAULT_TOLERANCE, bytes(""), - VERIFIER_VERSION, + 5, bytes(""), new Common.AddressAndWeight[](0) ); - (, , s_configDigestFive) = s_verifier_2.latestConfigDetails(FEED_ID_3); + s_configDigestFive = _configDigestFromConfigData( + FEED_ID_3, + SOURCE_CHAIN_ID, + SOURCE_ADDRESS, + 1, + _getSignerAddresses(signers), + s_offchaintransmitters, + FAULT_TOLERANCE, + bytes(""), + 5, + bytes("") + ); } } diff --git a/contracts/src/v0.8/llo-feeds/v0.5.0/test/verifier/VerifierActivateConfigTest.t.sol b/contracts/src/v0.8/llo-feeds/v0.5.0/test/verifier/VerifierActivateConfigTest.t.sol index 99daabe206b..b7d0975c143 100644 --- a/contracts/src/v0.8/llo-feeds/v0.5.0/test/verifier/VerifierActivateConfigTest.t.sol +++ b/contracts/src/v0.8/llo-feeds/v0.5.0/test/verifier/VerifierActivateConfigTest.t.sol @@ -2,24 +2,24 @@ pragma solidity 0.8.19; import {BaseTestWithConfiguredVerifierAndFeeManager, BaseTestWithMultipleConfiguredDigests} from "./BaseVerifierTest.t.sol"; -import {Verifier} from "../../../v0.3.0/Verifier.sol"; +import {Verifier} from "../../Verifier.sol"; contract VerifierActivateConfigTest is BaseTestWithConfiguredVerifierAndFeeManager { function test_revertsIfNotOwner() public { vm.expectRevert("Only callable by owner"); changePrank(address(s_verifierProxy)); - s_verifier.activateConfig(FEED_ID, bytes32("mock")); + s_verifier.activateConfig(bytes32("mock")); } function test_revertsIfDigestIsEmpty() public { vm.expectRevert(abi.encodeWithSelector(Verifier.DigestEmpty.selector)); - s_verifier.activateConfig(FEED_ID, bytes32("")); + s_verifier.activateConfig(bytes32("")); } function test_revertsIfDigestNotSet() public { - vm.expectRevert(abi.encodeWithSelector(Verifier.DigestNotSet.selector, FEED_ID, bytes32("non-existent-digest"))); - s_verifier.activateConfig(FEED_ID, bytes32("non-existent-digest")); + vm.expectRevert(abi.encodeWithSelector(Verifier.DigestNotSet.selector, bytes32("non-existent-digest"))); + s_verifier.activateConfig(bytes32("non-existent-digest")); } } @@ -46,11 +46,11 @@ contract VerifierActivateConfigWithDeactivatedConfigTest is BaseTestWithMultiple uint32(block.timestamp) ); - s_verifier.deactivateConfig(FEED_ID, s_configDigestTwo); + s_verifier.deactivateConfig(s_configDigestTwo); } function test_allowsVerification() public { - s_verifier.activateConfig(FEED_ID, s_configDigestTwo); + s_verifier.activateConfig(s_configDigestTwo); changePrank(address(s_verifierProxy)); bytes memory signedReport = _generateV1EncodedBlob( diff --git a/contracts/src/v0.8/llo-feeds/v0.5.0/test/verifier/VerifierDeactivateFeedTest.t.sol b/contracts/src/v0.8/llo-feeds/v0.5.0/test/verifier/VerifierDeactivateFeedTest.t.sol deleted file mode 100644 index fb52c1c93e7..00000000000 --- a/contracts/src/v0.8/llo-feeds/v0.5.0/test/verifier/VerifierDeactivateFeedTest.t.sol +++ /dev/null @@ -1,108 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity 0.8.19; - -import {BaseTestWithConfiguredVerifierAndFeeManager, BaseTestWithMultipleConfiguredDigests} from "./BaseVerifierTest.t.sol"; -import {Verifier} from "../../../v0.3.0/Verifier.sol"; - -contract VerifierActivateFeedTest is BaseTestWithConfiguredVerifierAndFeeManager { - function test_revertsIfNotOwnerActivateFeed() public { - changePrank(address(s_verifierProxy)); - vm.expectRevert("Only callable by owner"); - s_verifier.activateFeed(FEED_ID); - } - - function test_revertsIfNotOwnerDeactivateFeed() public { - changePrank(address(s_verifierProxy)); - vm.expectRevert("Only callable by owner"); - s_verifier.deactivateFeed(FEED_ID); - } - - function test_revertsIfNoFeedExistsActivate() public { - vm.expectRevert(abi.encodeWithSelector(Verifier.InvalidFeed.selector, INVALID_FEED)); - s_verifier.activateFeed(INVALID_FEED); - } - - function test_revertsIfNoFeedExistsDeactivate() public { - vm.expectRevert(abi.encodeWithSelector(Verifier.InvalidFeed.selector, INVALID_FEED)); - s_verifier.deactivateFeed(INVALID_FEED); - } -} - -contract VerifierDeactivateFeedWithVerifyTest is BaseTestWithMultipleConfiguredDigests { - bytes32[3] internal s_reportContext; - - event ConfigActivated(bytes32 configDigest); - - V1Report internal s_testReportOne; - - function setUp() public override { - BaseTestWithMultipleConfiguredDigests.setUp(); - s_reportContext[0] = s_configDigestOne; - s_reportContext[1] = bytes32(abi.encode(uint32(5), uint8(1))); - s_testReportOne = _createV1Report( - FEED_ID, - uint32(block.timestamp), - MEDIAN, - BID, - ASK, - uint64(block.number), - blockhash(block.number + 3), - uint64(block.number + 3), - uint32(block.timestamp) - ); - - s_verifier.deactivateFeed(FEED_ID); - } - - function test_currentReportAllowsVerification() public { - s_verifier.activateFeed(FEED_ID); - changePrank(address(s_verifierProxy)); - - bytes memory signedReport = _generateV1EncodedBlob( - s_testReportOne, - s_reportContext, - _getSigners(FAULT_TOLERANCE + 1) - ); - s_verifier.verify(signedReport, msg.sender); - } - - function test_previousReportAllowsVerification() public { - s_verifier.activateFeed(FEED_ID); - changePrank(address(s_verifierProxy)); - - s_reportContext[0] = s_configDigestTwo; - bytes memory signedReport = _generateV1EncodedBlob( - s_testReportOne, - s_reportContext, - _getSigners(FAULT_TOLERANCE_TWO + 1) - ); - s_verifier.verify(signedReport, msg.sender); - } - - function test_currentReportFailsVerification() public { - changePrank(address(s_verifierProxy)); - - bytes memory signedReport = _generateV1EncodedBlob( - s_testReportOne, - s_reportContext, - _getSigners(FAULT_TOLERANCE + 1) - ); - - vm.expectRevert(abi.encodeWithSelector(Verifier.InactiveFeed.selector, FEED_ID)); - s_verifier.verify(signedReport, msg.sender); - } - - function test_previousReportFailsVerification() public { - changePrank(address(s_verifierProxy)); - - s_reportContext[0] = s_configDigestTwo; - bytes memory signedReport = _generateV1EncodedBlob( - s_testReportOne, - s_reportContext, - _getSigners(FAULT_TOLERANCE_TWO + 1) - ); - - vm.expectRevert(abi.encodeWithSelector(Verifier.InactiveFeed.selector, FEED_ID)); - s_verifier.verify(signedReport, msg.sender); - } -} diff --git a/contracts/src/v0.8/llo-feeds/v0.5.0/test/verifier/VerifierProxyConstructorTest.t.sol b/contracts/src/v0.8/llo-feeds/v0.5.0/test/verifier/VerifierProxyConstructorTest.t.sol index 82efd8907be..811a9b440ee 100644 --- a/contracts/src/v0.8/llo-feeds/v0.5.0/test/verifier/VerifierProxyConstructorTest.t.sol +++ b/contracts/src/v0.8/llo-feeds/v0.5.0/test/verifier/VerifierProxyConstructorTest.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.19; import {BaseTest} from "./BaseVerifierTest.t.sol"; -import {VerifierProxy} from "../../../v0.3.0/VerifierProxy.sol"; +import {VerifierProxy} from "../../VerifierProxy.sol"; import {AccessControllerInterface} from "../../../../shared/interfaces/AccessControllerInterface.sol"; contract VerifierProxyConstructorTest is BaseTest { diff --git a/contracts/src/v0.8/llo-feeds/v0.5.0/test/verifier/VerifierProxyInitializeVerifierTest.t.sol b/contracts/src/v0.8/llo-feeds/v0.5.0/test/verifier/VerifierProxyInitializeVerifierTest.t.sol index 5537d273be9..e02b14fe56e 100644 --- a/contracts/src/v0.8/llo-feeds/v0.5.0/test/verifier/VerifierProxyInitializeVerifierTest.t.sol +++ b/contracts/src/v0.8/llo-feeds/v0.5.0/test/verifier/VerifierProxyInitializeVerifierTest.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.19; import {BaseTest} from "./BaseVerifierTest.t.sol"; -import {VerifierProxy} from "../../../v0.3.0/VerifierProxy.sol"; +import {VerifierProxy} from "../../VerifierProxy.sol"; contract VerifierProxyInitializeVerifierTest is BaseTest { bytes32 latestDigest; diff --git a/contracts/src/v0.8/llo-feeds/v0.5.0/test/verifier/VerifierProxySetVerifierTest.t.sol b/contracts/src/v0.8/llo-feeds/v0.5.0/test/verifier/VerifierProxySetVerifierTest.t.sol index 78e5ff0766f..45f64bf5533 100644 --- a/contracts/src/v0.8/llo-feeds/v0.5.0/test/verifier/VerifierProxySetVerifierTest.t.sol +++ b/contracts/src/v0.8/llo-feeds/v0.5.0/test/verifier/VerifierProxySetVerifierTest.t.sol @@ -3,7 +3,7 @@ pragma solidity 0.8.19; import {BaseTestWithConfiguredVerifierAndFeeManager} from "./BaseVerifierTest.t.sol"; import {IVerifier} from "../../interfaces/IVerifier.sol"; -import {VerifierProxy} from "../../../v0.3.0/VerifierProxy.sol"; +import {VerifierProxy} from "../../VerifierProxy.sol"; import {IERC165} from "../../../../vendor/openzeppelin-solidity/v4.8.3/contracts/interfaces/IERC165.sol"; import {Common} from "../../../libraries/Common.sol"; @@ -14,7 +14,7 @@ contract VerifierProxyInitializeVerifierTest is BaseTestWithConfiguredVerifierAn } function test_revertsIfDigestAlreadySet() public { - (, , bytes32 takenDigest) = s_verifier.latestConfigDetails(FEED_ID); + bytes32 takenDigest = v1ConfigDigest; address maliciousVerifier = address(666); bytes32 maliciousDigest = bytes32("malicious-digest"); @@ -32,7 +32,7 @@ contract VerifierProxyInitializeVerifierTest is BaseTestWithConfiguredVerifierAn } function test_updatesVerifierIfVerifier() public { - (, , bytes32 prevDigest) = s_verifier.latestConfigDetails(FEED_ID); + bytes32 prevDigest = v1ConfigDigest; changePrank(address(s_verifier)); s_verifierProxy.setVerifier(prevDigest, bytes32("new-config"), new Common.AddressAndWeight[](0)); assertEq(s_verifierProxy.getVerifier(bytes32("new-config")), address(s_verifier)); diff --git a/contracts/src/v0.8/llo-feeds/v0.5.0/test/verifier/VerifierProxyUnsetVerifierTest.t.sol b/contracts/src/v0.8/llo-feeds/v0.5.0/test/verifier/VerifierProxyUnsetVerifierTest.t.sol index a51c67e336c..74da281a3cd 100644 --- a/contracts/src/v0.8/llo-feeds/v0.5.0/test/verifier/VerifierProxyUnsetVerifierTest.t.sol +++ b/contracts/src/v0.8/llo-feeds/v0.5.0/test/verifier/VerifierProxyUnsetVerifierTest.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.19; import {BaseTest, BaseTestWithConfiguredVerifierAndFeeManager} from "./BaseVerifierTest.t.sol"; -import {VerifierProxy} from "../../../v0.3.0/VerifierProxy.sol"; +import {VerifierProxy} from "../../VerifierProxy.sol"; contract VerifierProxyUnsetVerifierTest is BaseTest { function test_revertsIfNotAdmin() public { @@ -25,7 +25,7 @@ contract VerifierProxyUnsetVerifierWithPreviouslySetVerifierTest is BaseTestWith function setUp() public override { BaseTestWithConfiguredVerifierAndFeeManager.setUp(); - (, , s_configDigest) = s_verifier.latestConfigDetails(FEED_ID); + s_configDigest = v3ConfigDigest; } function test_correctlyUnsetsVerifier() public { diff --git a/contracts/src/v0.8/llo-feeds/v0.5.0/test/verifier/VerifierSetConfigFromSourceTest.t.sol b/contracts/src/v0.8/llo-feeds/v0.5.0/test/verifier/VerifierSetConfigFromSourceTest.t.sol deleted file mode 100644 index 9ee9b5272a7..00000000000 --- a/contracts/src/v0.8/llo-feeds/v0.5.0/test/verifier/VerifierSetConfigFromSourceTest.t.sol +++ /dev/null @@ -1,134 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity 0.8.19; - -import {BaseTest, BaseTestWithMultipleConfiguredDigests} from "./BaseVerifierTest.t.sol"; -import {Common} from "../../../libraries/Common.sol"; - -contract VerifierSetConfigFromSourceTest is BaseTest { - function setUp() public virtual override { - BaseTest.setUp(); - } - - function test_revertsIfCalledByNonOwner() public { - vm.expectRevert("Only callable by owner"); - Signer[] memory signers = _getSigners(MAX_ORACLES); - - changePrank(USER); - s_verifier.setConfigFromSource( - FEED_ID, - 12345, - address(12345), - 0, - _getSignerAddresses(signers), - s_offchaintransmitters, - FAULT_TOLERANCE, - bytes(""), - VERIFIER_VERSION, - bytes(""), - new Common.AddressAndWeight[](0) - ); - } -} - -contract VerifierSetConfigFromSourceMultipleDigestsTest is BaseTestWithMultipleConfiguredDigests { - function test_correctlyUpdatesTheDigestInTheProxy() public { - Signer[] memory newSigners = _getSigners(15); - - s_verifier.setConfigFromSource( - FEED_ID, - 12345, - address(12345), - 0, - _getSignerAddresses(newSigners), - s_offchaintransmitters, - 4, - bytes(""), - VERIFIER_VERSION, - bytes(""), - new Common.AddressAndWeight[](0) - ); - - (, , bytes32 configDigest) = s_verifier.latestConfigDetails(FEED_ID); - address verifierAddr = s_verifierProxy.getVerifier(configDigest); - assertEq(verifierAddr, address(s_verifier)); - } - - function test_correctlyUpdatesDigestsOnMultipleVerifiersInTheProxy() public { - Signer[] memory newSigners = _getSigners(15); - - s_verifier.setConfigFromSource( - FEED_ID_2, - 12345, - address(12345), - 0, - _getSignerAddresses(newSigners), - s_offchaintransmitters, - 4, - bytes(""), - VERIFIER_VERSION, - bytes(""), - new Common.AddressAndWeight[](0) - ); - - (, , bytes32 configDigest) = s_verifier.latestConfigDetails(FEED_ID_2); - address verifierAddr = s_verifierProxy.getVerifier(configDigest); - assertEq(verifierAddr, address(s_verifier)); - - s_verifier_2.setConfigFromSource( - FEED_ID_3, - 12345, - address(12345), - 0, - _getSignerAddresses(newSigners), - s_offchaintransmitters, - 4, - bytes(""), - VERIFIER_VERSION, - bytes(""), - new Common.AddressAndWeight[](0) - ); - - (, , bytes32 configDigest2) = s_verifier_2.latestConfigDetails(FEED_ID_3); - address verifierAddr2 = s_verifierProxy.getVerifier(configDigest2); - assertEq(verifierAddr2, address(s_verifier_2)); - } - - function test_correctlySetsConfigWhenDigestsAreRemoved() public { - s_verifier.deactivateConfig(FEED_ID, s_configDigestTwo); - - Signer[] memory newSigners = _getSigners(15); - - s_verifier.setConfigFromSource( - FEED_ID, - 12345, - address(s_verifier), - 0, - _getSignerAddresses(newSigners), - s_offchaintransmitters, - 4, - bytes(""), - VERIFIER_VERSION, - bytes(""), - new Common.AddressAndWeight[](0) - ); - - bytes32 expectedConfigDigest = _configDigestFromConfigData( - FEED_ID, - 12345, - address(s_verifier), - s_numConfigsSet + 1, - _getSignerAddresses(newSigners), - s_offchaintransmitters, - 4, - bytes(""), - VERIFIER_VERSION, - bytes("") - ); - - (uint32 configCount, uint32 blockNumber, bytes32 configDigest) = s_verifier.latestConfigDetails(FEED_ID); - - assertEq(configCount, s_numConfigsSet + 1); - assertEq(blockNumber, block.number); - assertEq(configDigest, expectedConfigDigest); - } -} diff --git a/contracts/src/v0.8/llo-feeds/v0.5.0/test/verifier/VerifierSetConfigTest.t.sol b/contracts/src/v0.8/llo-feeds/v0.5.0/test/verifier/VerifierSetConfigTest.t.sol index 972ead81230..02784226863 100644 --- a/contracts/src/v0.8/llo-feeds/v0.5.0/test/verifier/VerifierSetConfigTest.t.sol +++ b/contracts/src/v0.8/llo-feeds/v0.5.0/test/verifier/VerifierSetConfigTest.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.19; import {BaseTest, BaseTestWithMultipleConfiguredDigests} from "./BaseVerifierTest.t.sol"; -import {Verifier} from "../../../v0.3.0/Verifier.sol"; +import {Verifier} from "../../Verifier.sol"; import {Common} from "../../../libraries/Common.sol"; contract VerifierSetConfigTest is BaseTest { @@ -17,6 +17,9 @@ contract VerifierSetConfigTest is BaseTest { changePrank(USER); s_verifier.setConfig( FEED_ID, + SOURCE_CHAIN_ID, + SOURCE_ADDRESS, + 1, _getSignerAddresses(signers), s_offchaintransmitters, FAULT_TOLERANCE, @@ -32,6 +35,9 @@ contract VerifierSetConfigTest is BaseTest { vm.expectRevert(abi.encodeWithSelector(Verifier.ExcessSigners.selector, signers.length, MAX_ORACLES)); s_verifier.setConfig( FEED_ID, + SOURCE_CHAIN_ID, + SOURCE_ADDRESS, + 1, signers, s_offchaintransmitters, FAULT_TOLERANCE, @@ -47,6 +53,9 @@ contract VerifierSetConfigTest is BaseTest { Signer[] memory signers = _getSigners(MAX_ORACLES); s_verifier.setConfig( FEED_ID, + SOURCE_CHAIN_ID, + SOURCE_ADDRESS, + 1, _getSignerAddresses(signers), s_offchaintransmitters, 0, @@ -67,6 +76,9 @@ contract VerifierSetConfigTest is BaseTest { ); s_verifier.setConfig( FEED_ID, + SOURCE_CHAIN_ID, + SOURCE_ADDRESS, + 1, signers, s_offchaintransmitters, FAULT_TOLERANCE, @@ -84,6 +96,9 @@ contract VerifierSetConfigTest is BaseTest { vm.expectRevert(abi.encodeWithSelector(Verifier.NonUniqueSignatures.selector)); s_verifier.setConfig( FEED_ID, + SOURCE_CHAIN_ID, + SOURCE_ADDRESS, + 1, signerAddrs, s_offchaintransmitters, FAULT_TOLERANCE, @@ -101,6 +116,9 @@ contract VerifierSetConfigTest is BaseTest { vm.expectRevert(abi.encodeWithSelector(Verifier.ZeroAddress.selector)); s_verifier.setConfig( FEED_ID, + SOURCE_CHAIN_ID, + SOURCE_ADDRESS, + 1, signerAddrs, s_offchaintransmitters, FAULT_TOLERANCE, @@ -117,6 +135,9 @@ contract VerifierSetConfigTest is BaseTest { s_verifierProxy.initializeVerifier(address(s_verifier)); s_verifier.setConfig( FEED_ID, + SOURCE_CHAIN_ID, + SOURCE_ADDRESS, + 1, _getSignerAddresses(signers), s_offchaintransmitters, FAULT_TOLERANCE, @@ -126,10 +147,10 @@ contract VerifierSetConfigTest is BaseTest { new Common.AddressAndWeight[](0) ); - bytes32 expectedConfigDigest = _configDigestFromConfigData( + bytes32 configDigest = _configDigestFromConfigData( FEED_ID, - block.chainid, - address(s_verifier), + SOURCE_CHAIN_ID, + SOURCE_ADDRESS, 1, _getSignerAddresses(signers), s_offchaintransmitters, @@ -139,15 +160,9 @@ contract VerifierSetConfigTest is BaseTest { bytes("") ); - (uint32 configCount, uint32 blockNumber, bytes32 configDigest) = s_verifier.latestConfigDetails(FEED_ID); + (uint32 configCount, uint32 blockNumber) = s_verifier.latestConfigDetails(configDigest); assertEq(configCount, 1); assertEq(blockNumber, block.number); - assertEq(configDigest, expectedConfigDigest); - - (bool scanLogs, bytes32 configDigestTwo, uint32 epoch) = s_verifier.latestConfigDigestAndEpoch(FEED_ID); - assertEq(scanLogs, false); - assertEq(configDigestTwo, expectedConfigDigest); - assertEq(epoch, 0); } } @@ -157,6 +172,9 @@ contract VerifierSetConfigWhenThereAreMultipleDigestsTest is BaseTestWithMultipl s_verifier.setConfig( FEED_ID, + SOURCE_CHAIN_ID, + SOURCE_ADDRESS, + 1, _getSignerAddresses(newSigners), s_offchaintransmitters, 4, @@ -166,7 +184,19 @@ contract VerifierSetConfigWhenThereAreMultipleDigestsTest is BaseTestWithMultipl new Common.AddressAndWeight[](0) ); - (, , bytes32 configDigest) = s_verifier.latestConfigDetails(FEED_ID); + bytes32 configDigest = _configDigestFromConfigData( + FEED_ID, + SOURCE_CHAIN_ID, + SOURCE_ADDRESS, + 1, + _getSignerAddresses(newSigners), + s_offchaintransmitters, + 4, + bytes(""), + VERIFIER_VERSION, + bytes("") + ); + address verifierAddr = s_verifierProxy.getVerifier(configDigest); assertEq(verifierAddr, address(s_verifier)); } @@ -176,6 +206,9 @@ contract VerifierSetConfigWhenThereAreMultipleDigestsTest is BaseTestWithMultipl s_verifier.setConfig( FEED_ID_2, + SOURCE_CHAIN_ID, + SOURCE_ADDRESS, + 1, _getSignerAddresses(newSigners), s_offchaintransmitters, 4, @@ -185,12 +218,27 @@ contract VerifierSetConfigWhenThereAreMultipleDigestsTest is BaseTestWithMultipl new Common.AddressAndWeight[](0) ); - (, , bytes32 configDigest) = s_verifier.latestConfigDetails(FEED_ID_2); + bytes32 configDigest = _configDigestFromConfigData( + FEED_ID_2, + SOURCE_CHAIN_ID, + SOURCE_ADDRESS, + 1, + _getSignerAddresses(newSigners), + s_offchaintransmitters, + 4, + bytes(""), + VERIFIER_VERSION, + bytes("") + ); + address verifierAddr = s_verifierProxy.getVerifier(configDigest); assertEq(verifierAddr, address(s_verifier)); s_verifier_2.setConfig( FEED_ID_3, + SOURCE_CHAIN_ID, + SOURCE_ADDRESS, + 1, _getSignerAddresses(newSigners), s_offchaintransmitters, 4, @@ -200,18 +248,33 @@ contract VerifierSetConfigWhenThereAreMultipleDigestsTest is BaseTestWithMultipl new Common.AddressAndWeight[](0) ); - (, , bytes32 configDigest2) = s_verifier_2.latestConfigDetails(FEED_ID_3); + bytes32 configDigest2 = _configDigestFromConfigData( + FEED_ID_3, + SOURCE_CHAIN_ID, + SOURCE_ADDRESS, + 1, + _getSignerAddresses(newSigners), + s_offchaintransmitters, + 4, + bytes(""), + VERIFIER_VERSION, + bytes("") + ); + address verifierAddr2 = s_verifierProxy.getVerifier(configDigest2); assertEq(verifierAddr2, address(s_verifier_2)); } function test_correctlySetsConfigWhenDigestsAreRemoved() public { - s_verifier.deactivateConfig(FEED_ID, s_configDigestTwo); + s_verifier.deactivateConfig(s_configDigestTwo); Signer[] memory newSigners = _getSigners(15); s_verifier.setConfig( FEED_ID, + SOURCE_CHAIN_ID, + SOURCE_ADDRESS, + 1, _getSignerAddresses(newSigners), s_offchaintransmitters, 4, @@ -223,9 +286,22 @@ contract VerifierSetConfigWhenThereAreMultipleDigestsTest is BaseTestWithMultipl bytes32 expectedConfigDigest = _configDigestFromConfigData( FEED_ID, - block.chainid, - address(s_verifier), - s_numConfigsSet + 1, + SOURCE_CHAIN_ID, + SOURCE_ADDRESS, + 1, + _getSignerAddresses(newSigners), + s_offchaintransmitters, + 4, + bytes(""), + VERIFIER_VERSION, + bytes("") + ); + + bytes32 configDigest = _configDigestFromConfigData( + FEED_ID, + SOURCE_CHAIN_ID, + SOURCE_ADDRESS, + 1, _getSignerAddresses(newSigners), s_offchaintransmitters, 4, @@ -234,7 +310,7 @@ contract VerifierSetConfigWhenThereAreMultipleDigestsTest is BaseTestWithMultipl bytes("") ); - (uint32 configCount, uint32 blockNumber, bytes32 configDigest) = s_verifier.latestConfigDetails(FEED_ID); + (uint32 configCount, uint32 blockNumber) = s_verifier.latestConfigDetails(configDigest); assertEq(configCount, s_numConfigsSet + 1); assertEq(blockNumber, block.number); diff --git a/contracts/src/v0.8/llo-feeds/v0.5.0/test/verifier/VerifierTest.t.sol b/contracts/src/v0.8/llo-feeds/v0.5.0/test/verifier/VerifierTest.t.sol index 81f65f0c6eb..7f8fc472c35 100644 --- a/contracts/src/v0.8/llo-feeds/v0.5.0/test/verifier/VerifierTest.t.sol +++ b/contracts/src/v0.8/llo-feeds/v0.5.0/test/verifier/VerifierTest.t.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.19; import {BaseTest} from "./BaseVerifierTest.t.sol"; -import {Verifier} from "../../../v0.3.0/Verifier.sol"; +import {Verifier} from "../../Verifier.sol"; contract VerifierConstructorTest is BaseTest { function test_revertsIfInitializedWithEmptyVerifierProxy() public { @@ -14,18 +14,12 @@ contract VerifierConstructorTest is BaseTest { Verifier v = new Verifier(address(s_verifierProxy)); assertEq(v.owner(), ADMIN); - (bool scanLogs, bytes32 configDigest, uint32 epoch) = v.latestConfigDigestAndEpoch(FEED_ID); - assertEq(scanLogs, false); - assertEq(configDigest, EMPTY_BYTES); - assertEq(epoch, 0); - - (uint32 configCount, uint32 blockNumber, bytes32 configDigestTwo) = v.latestConfigDetails(FEED_ID); + (uint32 configCount, uint32 blockNumber) = v.latestConfigDetails(FEED_ID); assertEq(configCount, 0); assertEq(blockNumber, 0); - assertEq(configDigestTwo, EMPTY_BYTES); string memory typeAndVersion = s_verifier.typeAndVersion(); - assertEq(typeAndVersion, "Verifier 1.2.0"); + assertEq(typeAndVersion, "Verifier 2.0.0"); } } diff --git a/contracts/src/v0.8/llo-feeds/v0.5.0/test/verifier/VerifierUnsetConfigTest.t.sol b/contracts/src/v0.8/llo-feeds/v0.5.0/test/verifier/VerifierUnsetConfigTest.t.sol index e192a2e9e08..64c9f77a7e7 100644 --- a/contracts/src/v0.8/llo-feeds/v0.5.0/test/verifier/VerifierUnsetConfigTest.t.sol +++ b/contracts/src/v0.8/llo-feeds/v0.5.0/test/verifier/VerifierUnsetConfigTest.t.sol @@ -2,55 +2,23 @@ pragma solidity 0.8.19; import {BaseTestWithMultipleConfiguredDigests} from "./BaseVerifierTest.t.sol"; -import {Verifier} from "../../../v0.3.0/Verifier.sol"; +import {Verifier} from "../../Verifier.sol"; contract VerificationdeactivateConfigWhenThereAreMultipleDigestsTest is BaseTestWithMultipleConfiguredDigests { function test_revertsIfCalledByNonOwner() public { vm.expectRevert("Only callable by owner"); changePrank(USER); - s_verifier.deactivateConfig(FEED_ID, bytes32("")); + s_verifier.deactivateConfig(bytes32("")); } function test_revertsIfRemovingAnEmptyDigest() public { vm.expectRevert(abi.encodeWithSelector(Verifier.DigestEmpty.selector)); - s_verifier.deactivateConfig(FEED_ID, bytes32("")); + s_verifier.deactivateConfig(bytes32("")); } function test_revertsIfRemovingAnNonExistentDigest() public { - vm.expectRevert(abi.encodeWithSelector(Verifier.DigestNotSet.selector, FEED_ID, bytes32("mock-digest"))); - s_verifier.deactivateConfig(FEED_ID, bytes32("mock-digest")); - } - - function test_correctlyRemovesAMiddleDigest() public { - s_verifier.deactivateConfig(FEED_ID, s_configDigestTwo); - (, , bytes32 lastConfigDigest) = s_verifier.latestConfigDetails(FEED_ID); - assertEq(lastConfigDigest, s_configDigestThree); - } - - function test_correctlyRemovesTheFirstDigest() public { - s_verifier.deactivateConfig(FEED_ID, s_configDigestOne); - (, , bytes32 lastConfigDigest) = s_verifier.latestConfigDetails(FEED_ID); - assertEq(lastConfigDigest, s_configDigestThree); - } - - function test_correctlyUnsetsDigestsInSequence() public { - // Delete config digest 2 - s_verifier.deactivateConfig(FEED_ID, s_configDigestTwo); - (, , bytes32 lastConfigDigest) = s_verifier.latestConfigDetails(FEED_ID); - assertEq(lastConfigDigest, s_configDigestThree); - - // Delete config digest 1 - s_verifier.deactivateConfig(FEED_ID, s_configDigestOne); - (, , lastConfigDigest) = s_verifier.latestConfigDetails(FEED_ID); - assertEq(lastConfigDigest, s_configDigestThree); - - // Delete config digest 3 - vm.expectRevert( - abi.encodeWithSelector(Verifier.CannotDeactivateLatestConfig.selector, FEED_ID, s_configDigestThree) - ); - s_verifier.deactivateConfig(FEED_ID, s_configDigestThree); - (, , lastConfigDigest) = s_verifier.latestConfigDetails(FEED_ID); - assertEq(lastConfigDigest, s_configDigestThree); + vm.expectRevert(abi.encodeWithSelector(Verifier.DigestNotSet.selector, bytes32("mock-digest"))); + s_verifier.deactivateConfig(bytes32("mock-digest")); } } diff --git a/contracts/src/v0.8/llo-feeds/v0.5.0/test/verifier/VerifierVerifyTest.t.sol b/contracts/src/v0.8/llo-feeds/v0.5.0/test/verifier/VerifierVerifyTest.t.sol index 1c14ba974c0..151314df22a 100644 --- a/contracts/src/v0.8/llo-feeds/v0.5.0/test/verifier/VerifierVerifyTest.t.sol +++ b/contracts/src/v0.8/llo-feeds/v0.5.0/test/verifier/VerifierVerifyTest.t.sol @@ -2,8 +2,8 @@ pragma solidity 0.8.19; import {BaseTestWithConfiguredVerifierAndFeeManager} from "./BaseVerifierTest.t.sol"; -import {Verifier} from "../../../v0.3.0/Verifier.sol"; -import {VerifierProxy} from "../../../v0.3.0/VerifierProxy.sol"; +import {Verifier} from "../../Verifier.sol"; +import {VerifierProxy} from "../../VerifierProxy.sol"; import {AccessControllerInterface} from "../../../../shared/interfaces/AccessControllerInterface.sol"; import {Common} from "../../../libraries/Common.sol"; @@ -16,8 +16,7 @@ contract VerifierVerifyTest is BaseTestWithConfiguredVerifierAndFeeManager { function setUp() public virtual override { BaseTestWithConfiguredVerifierAndFeeManager.setUp(); - (, , bytes32 configDigest) = s_verifier.latestConfigDetails(FEED_ID); - s_reportContext[0] = configDigest; + s_reportContext[0] = v1ConfigDigest; s_reportContext[1] = bytes32(abi.encode(uint32(5), uint8(1))); s_testReportOne = _createV1Report( FEED_ID, @@ -160,12 +159,12 @@ contract VerifierVerifySingleConfigDigestTest is VerifierVerifyTest { reportContext, _getSigners(FAULT_TOLERANCE + 1) ); - vm.expectRevert(abi.encodeWithSelector(Verifier.DigestInactive.selector, FEED_ID, reportContext[0])); + vm.expectRevert(abi.encodeWithSelector(Verifier.DigestInactive.selector, reportContext[0])); changePrank(address(s_verifierProxy)); s_verifier.verify(signedReport, msg.sender); } - function test_revertsIfReportHasUnconfiguredFeedID() public { + function test_revertsIfReportHasUnconfiguredConfigDigest() public { V1Report memory report = _createV1Report( FEED_ID_2, OBSERVATIONS_TIMESTAMP, @@ -177,8 +176,9 @@ contract VerifierVerifySingleConfigDigestTest is VerifierVerifyTest { BLOCKNUMBER_LOWER_BOUND, uint32(block.timestamp) ); + s_reportContext[0] = keccak256("unconfigured-digesty"); bytes memory signedReport = _generateV1EncodedBlob(report, s_reportContext, _getSigners(FAULT_TOLERANCE + 1)); - vm.expectRevert(abi.encodeWithSelector(Verifier.DigestInactive.selector, FEED_ID_2, s_reportContext[0])); + vm.expectRevert(abi.encodeWithSelector(Verifier.DigestInactive.selector, s_reportContext[0])); changePrank(address(s_verifierProxy)); s_verifier.verify(signedReport, msg.sender); } @@ -212,20 +212,6 @@ contract VerifierVerifySingleConfigDigestTest is VerifierVerifyTest { assertReportsEqual(response, s_testReportOne); } - function test_setsTheCorrectEpoch() public { - s_reportContext[1] = bytes32(uint256(5 << 8)); - bytes memory signedReport = _generateV1EncodedBlob( - s_testReportOne, - s_reportContext, - _getSigners(FAULT_TOLERANCE + 1) - ); - changePrank(address(s_verifierProxy)); - s_verifier.verify(signedReport, msg.sender); - - (, , uint32 latestEpoch) = s_verifier.latestConfigDigestAndEpoch(FEED_ID); - assertEq(latestEpoch, 5); - } - function test_emitsAnEventIfReportVerified() public { bytes memory signedReport = _generateV1EncodedBlob( s_testReportOne, @@ -247,9 +233,12 @@ contract VerifierVerifyMultipleConfigDigestTest is VerifierVerifyTest { function setUp() public override { VerifierVerifyTest.setUp(); - (, , s_oldConfigDigest) = s_verifier.latestConfigDetails(FEED_ID); + s_oldConfigDigest = v1ConfigDigest; s_verifier.setConfig( FEED_ID, + SOURCE_CHAIN_ID, + SOURCE_ADDRESS, + 2, _getSignerAddresses(_getSigners(20)), s_offchaintransmitters, FAULT_TOLERANCE_TWO, @@ -258,11 +247,22 @@ contract VerifierVerifyMultipleConfigDigestTest is VerifierVerifyTest { bytes(""), new Common.AddressAndWeight[](0) ); - (, , s_newConfigDigest) = s_verifier.latestConfigDetails(FEED_ID); + s_newConfigDigest = _configDigestFromConfigData( + FEED_ID, + SOURCE_CHAIN_ID, + SOURCE_ADDRESS, + 2, + _getSignerAddresses(_getSigners(20)), + s_offchaintransmitters, + FAULT_TOLERANCE_TWO, + bytes(""), + VERIFIER_VERSION, + bytes("") + ); } function test_revertsIfVerifyingWithAnUnsetDigest() public { - s_verifier.deactivateConfig(FEED_ID, (s_oldConfigDigest)); + s_verifier.deactivateConfig(s_oldConfigDigest); bytes memory signedReport = _generateV1EncodedBlob( s_testReportOne, @@ -270,7 +270,7 @@ contract VerifierVerifyMultipleConfigDigestTest is VerifierVerifyTest { _getSigners(FAULT_TOLERANCE + 1) ); changePrank(address(s_verifierProxy)); - vm.expectRevert(abi.encodeWithSelector(Verifier.DigestInactive.selector, FEED_ID, s_reportContext[0])); + vm.expectRevert(abi.encodeWithSelector(Verifier.DigestInactive.selector, s_reportContext[0])); s_verifier.verify(signedReport, msg.sender); }