Skip to content

Commit

Permalink
remove history in proofs from requests
Browse files Browse the repository at this point in the history
  • Loading branch information
daveroga committed Jan 10, 2025
1 parent ca1f04f commit 188bb13
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 23 deletions.
13 changes: 5 additions & 8 deletions contracts/lib/VerifierLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,14 @@ library VerifierLib {
address sender,
IRequestValidator.ResponseField[] memory responseFields
) public {
Proof[] storage proofs = self._proofs[requestId][sender];
Proof storage proof = self._proofs[requestId][sender];
// We only keep only 1 proof now without history. Prepared for the future if needed.
if (proofs.length == 0) {
proofs.push();
}
for (uint256 i = 0; i < responseFields.length; i++) {
proofs[0].storageFields[responseFields[i].name] = responseFields[i].value;
proof.storageFields[responseFields[i].name] = responseFields[i].value;
}

proofs[0].isVerified = true;
proofs[0].validatorVersion = self._requests[requestId].validator.version();
proofs[0].blockTimestamp = block.timestamp;
proof.isVerified = true;
proof.validatorVersion = self._requests[requestId].validator.version();
proof.blockTimestamp = block.timestamp;
}
}
27 changes: 12 additions & 15 deletions contracts/verifiers/Verifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ abstract contract Verifier is IVerifier, ContextUpgradeable {
struct VerifierStorage {
// Information about requests
// solhint-disable-next-line
mapping(uint256 requestId => mapping(address sender => VerifierLib.Proof[])) _proofs;
mapping(uint256 requestId => mapping(address sender => VerifierLib.Proof)) _proofs;
mapping(uint256 requestId => IVerifier.RequestData) _requests;
uint256[] _requestIds;
IState _state;
Expand Down Expand Up @@ -513,10 +513,7 @@ abstract contract Verifier is IVerifier, ContextUpgradeable {
string memory responseFieldName
) public view checkRequestExistence(requestId, true) returns (uint256) {
VerifierStorage storage s = _getVerifierStorage();
return
s._proofs[requestId][sender][s._proofs[requestId][sender].length - 1].storageFields[
responseFieldName
];
return s._proofs[requestId][sender].storageFields[responseFieldName];
}

function _checkLinkedResponseFields(
Expand Down Expand Up @@ -630,9 +627,9 @@ abstract contract Verifier is IVerifier, ContextUpgradeable {

requestStatus[i] = IVerifier.RequestStatus({
requestId: requestId,
isVerified: s._proofs[requestId][userAddress][0].isVerified,
validatorVersion: s._proofs[requestId][userAddress][0].validatorVersion,
timestamp: s._proofs[requestId][userAddress][0].blockTimestamp
isVerified: s._proofs[requestId][userAddress].isVerified,
validatorVersion: s._proofs[requestId][userAddress].validatorVersion,
timestamp: s._proofs[requestId][userAddress].blockTimestamp
});
}

Expand All @@ -644,9 +641,9 @@ abstract contract Verifier is IVerifier, ContextUpgradeable {

requestStatus[multiRequest.requestIds.length + j] = IVerifier.RequestStatus({
requestId: requestId,
isVerified: s._proofs[requestId][userAddress][0].isVerified,
validatorVersion: s._proofs[requestId][userAddress][0].validatorVersion,
timestamp: s._proofs[requestId][userAddress][0].blockTimestamp
isVerified: s._proofs[requestId][userAddress].isVerified,
validatorVersion: s._proofs[requestId][userAddress].validatorVersion,
timestamp: s._proofs[requestId][userAddress].blockTimestamp
});
}
}
Expand All @@ -664,7 +661,7 @@ abstract contract Verifier is IVerifier, ContextUpgradeable {
for (uint256 i = 0; i < multiRequest.requestIds.length; i++) {
uint256 requestId = multiRequest.requestIds[i];

if (!s._proofs[requestId][userAddress][0].isVerified) {
if (!s._proofs[requestId][userAddress].isVerified) {
return false;
}
}
Expand All @@ -675,7 +672,7 @@ abstract contract Verifier is IVerifier, ContextUpgradeable {
for (uint256 j = 0; j < s._groupedRequests[groupId].length; j++) {
uint256 requestId = s._groupedRequests[groupId][j];

if (!s._proofs[requestId][userAddress][0].isVerified) {
if (!s._proofs[requestId][userAddress].isVerified) {
return false;
}
}
Expand All @@ -695,7 +692,7 @@ abstract contract Verifier is IVerifier, ContextUpgradeable {
uint256 requestId
) public view checkRequestExistence(requestId, true) returns (bool) {
VerifierStorage storage s = _getVerifierStorage();
return s._proofs[requestId][sender][0].isVerified;
return s._proofs[requestId][sender].isVerified;
}

/**
Expand Down Expand Up @@ -725,7 +722,7 @@ abstract contract Verifier is IVerifier, ContextUpgradeable {
uint256 requestId
) public view checkRequestExistence(requestId, true) returns (IVerifier.RequestStatus memory) {
VerifierStorage storage s = _getVerifierStorage();
VerifierLib.Proof storage proof = s._proofs[requestId][sender][0];
VerifierLib.Proof storage proof = s._proofs[requestId][sender];

return
IVerifier.RequestStatus(
Expand Down

0 comments on commit 188bb13

Please sign in to comment.