Skip to content

Commit

Permalink
Prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
Fletch153 committed Dec 19, 2024
1 parent 1db7f34 commit 8b0d8da
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 227 deletions.
52 changes: 13 additions & 39 deletions contracts/src/v0.8/llo-feeds/v0.5.0/Verifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,10 @@ contract Verifier is IVerifier, ConfirmedOwner, TypeAndVersionInterface {
event ReportVerified(bytes32 indexed feedId, address requester);

/// @notice This event is emitted whenever a new DON configuration is set.
event ConfigSet(
bytes32 indexed configDigest,
address[] signers,
uint8 f
);
event ConfigSet(bytes32 indexed configDigest, address[] signers, uint8 f);

/// @notice This event is
event ConfigUpdated(
bytes32 indexed configDigest,
address[] prevSigners,
address[] newSigners
);
event ConfigUpdated(bytes32 indexed configDigest, address[] prevSigners, address[] newSigners);

/// @notice This event is emitted whenever a configuration is deactivated
event ConfigDeactivated(bytes32 indexed configDigest);
Expand Down Expand Up @@ -212,7 +204,6 @@ contract Verifier is IVerifier, ConfirmedOwner, TypeAndVersionInterface {
if (rs.length != ss.length) revert MismatchedSignatures(rs.length, ss.length);
}


/// @notice Verifies that a report has been signed by the correct
/// signers and that enough signers have signed the reports.
/// @param hashedReport The keccak256 hash of the raw report's bytes
Expand Down Expand Up @@ -260,13 +251,13 @@ contract Verifier is IVerifier, ConfirmedOwner, TypeAndVersionInterface {
if (config.f == 0) revert DigestNotSet(configDigest);

// We must be removing the number of signers that were originally set
if(config.oracleCount != prevSigners.length){
if (config.oracleCount != prevSigners.length) {
revert NonUniqueSignatures();
}

for (uint256 i; i < prevSigners.length; ++i) {
// Check the signers being removed are not zero address or duplicates
if(config.oracles[prevSigners[i]].role == Role.Unset){
if (config.oracles[prevSigners[i]].role == Role.Unset) {
revert NonUniqueSignatures();
}

Expand All @@ -276,7 +267,6 @@ contract Verifier is IVerifier, ConfirmedOwner, TypeAndVersionInterface {
// Once signers have been cleared we can set the new signers
_setConfig(configDigest, newSigners, f, new Common.AddressAndWeight[](0), true);


emit ConfigUpdated(configDigest, prevSigners, newSigners);
}

Expand All @@ -299,7 +289,7 @@ contract Verifier is IVerifier, ConfirmedOwner, TypeAndVersionInterface {
) internal {
VerifierState storage verifierState = s_verifierStates[configDigest];

if(verifierState.f > 0 && !_updateConfig) {
if (verifierState.f > 0 && !_updateConfig) {
revert ConfigDigestAlreadySet();
}

Expand All @@ -316,27 +306,15 @@ contract Verifier is IVerifier, ConfirmedOwner, TypeAndVersionInterface {
// Here the contract checks to see if a signer's address has already
// been set to ensure that the group of signer addresses that will
// sign reports with the config digest are unique.
bool isSignerAlreadySet = verifierState.oracles[signerAddr].role !=
Role.Unset;
bool isSignerAlreadySet = verifierState.oracles[signerAddr].role != Role.Unset;
if (isSignerAlreadySet) revert NonUniqueSignatures();
verifierState.oracles[signerAddr] = Signer({
role: Role.Signer,
index: i
});
verifierState.oracles[signerAddr] = Signer({role: Role.Signer, index: i});
}

if(!_updateConfig) {
IVerifierProxy(i_verifierProxyAddr).setVerifier(
bytes32(0),
configDigest,
recipientAddressesAndWeights
);

emit ConfigSet(
configDigest,
signers,
f
);
if (!_updateConfig) {
IVerifierProxy(i_verifierProxyAddr).setVerifier(bytes32(0), configDigest, recipientAddressesAndWeights);

emit ConfigSet(configDigest, signers, f);
}
}

Expand All @@ -361,12 +339,8 @@ contract Verifier is IVerifier, ConfirmedOwner, TypeAndVersionInterface {
}

/// @inheritdoc IVerifier
function latestConfigDetails(
bytes32 configDigest
) external view override returns (uint32 blockNumber) {
function latestConfigDetails(bytes32 configDigest) external view override returns (uint32 blockNumber) {
VerifierState storage verifierState = s_verifierStates[configDigest];
return (
verifierState.latestConfigBlockNumber
);
return (verifierState.latestConfigBlockNumber);
}
}
4 changes: 1 addition & 3 deletions contracts/src/v0.8/llo-feeds/v0.5.0/interfaces/IVerifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,5 @@ interface IVerifier is IERC165 {
* @param configDigest Config Digest to fetch data for
* @return blockNumber block at which this config was set
*/
function latestConfigDetails(
bytes32 configDigest
) external view returns (uint32 blockNumber);
function latestConfigDetails(bytes32 configDigest) external view returns (uint32 blockNumber);
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,7 @@ contract Verifier_setConfig is BaseTest {
bytes("")
);

s_verifier.setConfig(
configDigest,
s_signerAddrs,
FAULT_TOLERANCE,
new Common.AddressAndWeight[](0)
);
s_verifier.setConfig(configDigest, s_signerAddrs, FAULT_TOLERANCE, new Common.AddressAndWeight[](0));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,7 @@ contract ErroredVerifier is IVerifier {
revert FailedToUnsetConfig();
}

function setConfig(
bytes32,
address[] calldata,
uint8,
Common.AddressAndWeight[] calldata
) external pure override {
function setConfig(bytes32, address[] calldata, uint8, Common.AddressAndWeight[] calldata) external pure override {
revert FailedToSetConfig();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ contract MockConfigurator {
bytes memory offchainConfig
) external {
ConfigurationState storage configurationState = s_configurationStates[configId];

uint64 newConfigCount = ++configurationState.configCount;

bytes32 configDigest = _configDigestFromConfigData(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,9 @@ contract BaseTest is Test {
uint64 offchainConfigVersion,
bytes memory offchainConfig
) internal pure returns (bytes32) {

// Convert addresses to bytes array to match configurator
bytes[] memory signersAsBytes = new bytes[](signers.length);
for (uint i; i < signers.length; ++i){
for (uint i; i < signers.length; ++i) {
signersAsBytes[i] = abi.encodePacked(signers[i]);
}

Expand Down Expand Up @@ -316,7 +315,7 @@ contract BaseTestWithConfiguredVerifierAndFeeManager is BaseTest {
FAULT_TOLERANCE,
new Common.AddressAndWeight[](0)
);

v3ConfigDigest = _configDigestFromConfigData(
FEED_ID_V3,
SOURCE_CHAIN_ID,
Expand Down
Loading

0 comments on commit 8b0d8da

Please sign in to comment.