Skip to content

Commit

Permalink
Update proof and rc from memory to calldata
Browse files Browse the repository at this point in the history
  • Loading branch information
leeyikjiun committed Jun 20, 2024
1 parent 9e1b604 commit 8db302b
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 26 deletions.
4 changes: 2 additions & 2 deletions contracts/src/v0.8/vrf/BatchVRFCoordinatorV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ contract BatchVRFCoordinatorV2 {
* @param proofs the randomness proofs generated by the VRF provider.
* @param rcs the request commitments corresponding to the randomness proofs.
*/
function fulfillRandomWords(VRFTypes.Proof[] memory proofs, VRFTypes.RequestCommitment[] memory rcs) external {
function fulfillRandomWords(VRFTypes.Proof[] calldata proofs, VRFTypes.RequestCommitment[] memory rcs) external {
// solhint-disable-next-line gas-custom-errors
require(proofs.length == rcs.length, "input array arg lengths mismatch");
for (uint256 i = 0; i < proofs.length; i++) {
Expand Down Expand Up @@ -62,7 +62,7 @@ contract BatchVRFCoordinatorV2 {
// solhint-disable-next-line interface-starts-with-i
interface VRFCoordinatorV2 {
function fulfillRandomWords(
VRFTypes.Proof memory proof,
VRFTypes.Proof calldata proof,
VRFTypes.RequestCommitment memory rc
) external returns (uint96);
}
2 changes: 1 addition & 1 deletion contracts/src/v0.8/vrf/VRF.sol
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ contract VRF {
* @return output i.e., the random output implied by the proof
* ***************************************************************************
*/
function _randomValueFromVRFProof(Proof memory proof, uint256 seed) internal view returns (uint256 output) {
function _randomValueFromVRFProof(Proof calldata proof, uint256 seed) internal view returns (uint256 output) {
_verifyVRFProof(
proof.pk,
proof.gamma,
Expand Down
4 changes: 2 additions & 2 deletions contracts/src/v0.8/vrf/VRFCoordinatorV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ contract VRFCoordinatorV2 is VRF, ConfirmedOwner, TypeAndVersionInterface, VRFCo
}

function _getRandomnessFromProof(
Proof memory proof,
Proof calldata proof,
RequestCommitment memory rc
) private view returns (bytes32 keyHash, uint256 requestId, uint256 randomness) {
keyHash = hashOfKey(proof.pk);
Expand Down Expand Up @@ -522,7 +522,7 @@ contract VRFCoordinatorV2 is VRF, ConfirmedOwner, TypeAndVersionInterface, VRFCo
* @return payment amount billed to the subscription
* @dev simulated offchain to determine if sufficient balance is present to fulfill the request
*/
function fulfillRandomWords(Proof memory proof, RequestCommitment memory rc) external nonReentrant returns (uint96) {
function fulfillRandomWords(Proof calldata proof, RequestCommitment memory rc) external nonReentrant returns (uint96) {
uint256 startGas = gasleft();
(bytes32 keyHash, uint256 requestId, uint256 randomness) = _getRandomnessFromProof(proof, rc);

Expand Down
4 changes: 2 additions & 2 deletions contracts/src/v0.8/vrf/VRFOwner.sol
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ interface IVRFCoordinatorV2 {
function hashOfKey(uint256[2] memory publicKey) external pure returns (bytes32);

function fulfillRandomWords(
VRFTypes.Proof memory proof,
VRFTypes.Proof calldata proof,
VRFTypes.RequestCommitment memory rc
) external returns (uint96);
}
Expand Down Expand Up @@ -281,7 +281,7 @@ contract VRFOwner is ConfirmedOwner, AuthorizedReceiver {
* @param rc request commitment pre-image, committed to at request time
*/
function fulfillRandomWords(
VRFTypes.Proof memory proof,
VRFTypes.Proof calldata proof,
VRFTypes.RequestCommitment memory rc
) external validateAuthorizedSender {
uint256 requestId = _requestIdFromProof(proof.pk, proof.seed);
Expand Down
6 changes: 3 additions & 3 deletions contracts/src/v0.8/vrf/dev/BatchVRFCoordinatorV2Plus.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ contract BatchVRFCoordinatorV2Plus {
* @param proofs the randomness proofs generated by the VRF provider.
* @param rcs the request commitments corresponding to the randomness proofs.
*/
function fulfillRandomWords(VRFTypes.Proof[] memory proofs, VRFTypes.RequestCommitmentV2Plus[] memory rcs) external {
function fulfillRandomWords(VRFTypes.Proof[] calldata proofs, VRFTypes.RequestCommitmentV2Plus[] calldata rcs) external {
// solhint-disable-next-line gas-custom-errors
require(proofs.length == rcs.length, "input array arg lengths mismatch");
for (uint256 i = 0; i < proofs.length; ++i) {
Expand Down Expand Up @@ -61,8 +61,8 @@ contract BatchVRFCoordinatorV2Plus {

interface IVRFCoordinatorV2PlusFulfill {
function fulfillRandomWords(
VRFTypes.Proof memory proof,
VRFTypes.RequestCommitmentV2Plus memory rc,
VRFTypes.Proof calldata proof,
VRFTypes.RequestCommitmentV2Plus calldata rc,
bool onlyPremium
) external returns (uint96);
}
12 changes: 6 additions & 6 deletions contracts/src/v0.8/vrf/dev/VRFCoordinatorV2_5.sol
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ contract VRFCoordinatorV2_5 is VRF, SubscriptionAPI, IVRFCoordinatorV2Plus {
* @notice Returns the proving key hash key associated with this public key
* @param publicKey the key to return the hash of
*/
function hashOfKey(uint256[2] memory publicKey) public pure returns (bytes32) {
function hashOfKey(uint256[2] calldata publicKey) public pure returns (bytes32) {
return keccak256(abi.encode(publicKey));
}

Expand Down Expand Up @@ -358,8 +358,8 @@ contract VRFCoordinatorV2_5 is VRF, SubscriptionAPI, IVRFCoordinatorV2Plus {
}

function _getRandomnessFromProof(
Proof memory proof,
VRFTypes.RequestCommitmentV2Plus memory rc
Proof calldata proof,
VRFTypes.RequestCommitmentV2Plus calldata rc
) internal view returns (Output memory) {
bytes32 keyHash = hashOfKey(proof.pk);
ProvingKey memory key = s_provingKeys[keyHash];
Expand Down Expand Up @@ -408,7 +408,7 @@ contract VRFCoordinatorV2_5 is VRF, SubscriptionAPI, IVRFCoordinatorV2Plus {

function _deliverRandomness(
uint256 requestId,
VRFTypes.RequestCommitmentV2Plus memory rc,
VRFTypes.RequestCommitmentV2Plus calldata rc,
uint256[] memory randomWords
) internal returns (bool success) {
VRFConsumerBaseV2Plus v;
Expand All @@ -434,8 +434,8 @@ contract VRFCoordinatorV2_5 is VRF, SubscriptionAPI, IVRFCoordinatorV2Plus {
* @dev simulated offchain to determine if sufficient balance is present to fulfill the request
*/
function fulfillRandomWords(
Proof memory proof,
VRFTypes.RequestCommitmentV2Plus memory rc,
Proof calldata proof,
VRFTypes.RequestCommitmentV2Plus calldata rc,
bool onlyPremium
) external nonReentrant returns (uint96 payment) {
uint256 startGas = gasleft();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ interface IVRFCoordinatorV2PlusInternal is IVRFCoordinatorV2Plus {
function s_requestCommitments(uint256 requestID) external view returns (bytes32);

function fulfillRandomWords(
Proof memory proof,
Proof calldata proof,
RequestCommitment memory rc,
bool onlyPremium
) external returns (uint96);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,8 @@ contract VRFCoordinatorV2PlusUpgradedVersion is
}

function _getRandomnessFromProof(
Proof memory proof,
VRFTypes.RequestCommitmentV2Plus memory rc
Proof calldata proof,
VRFTypes.RequestCommitmentV2Plus calldata rc
) internal view returns (Output memory) {
bytes32 keyHash = hashOfKey(proof.pk);
ProvingKey memory key = s_provingKeys[keyHash];
Expand Down Expand Up @@ -414,7 +414,7 @@ contract VRFCoordinatorV2PlusUpgradedVersion is

function _deliverRandomness(
uint256 requestId,
VRFTypes.RequestCommitmentV2Plus memory rc,
VRFTypes.RequestCommitmentV2Plus calldata rc,
uint256[] memory randomWords
) internal returns (bool success) {
VRFConsumerBaseV2Plus v;
Expand All @@ -440,8 +440,8 @@ contract VRFCoordinatorV2PlusUpgradedVersion is
* @dev simulated offchain to determine if sufficient balance is present to fulfill the request
*/
function fulfillRandomWords(
Proof memory proof,
VRFTypes.RequestCommitmentV2Plus memory rc,
Proof calldata proof,
VRFTypes.RequestCommitmentV2Plus calldata rc,
bool onlyPremium
) external nonReentrant returns (uint96 payment) {
uint256 startGas = gasleft();
Expand Down
6 changes: 3 additions & 3 deletions contracts/src/v0.8/vrf/testhelpers/VRFCoordinatorTestV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -465,8 +465,8 @@ contract VRFCoordinatorTestV2 is
}

function getRandomnessFromProof(
Proof memory proof,
RequestCommitment memory rc
Proof calldata proof,
RequestCommitment calldata rc
) private view returns (bytes32 keyHash, uint256 requestId, uint256 randomness) {
keyHash = hashOfKey(proof.pk);
// Only registered proving keys are permitted.
Expand Down Expand Up @@ -527,7 +527,7 @@ contract VRFCoordinatorTestV2 is
* @return payment amount billed to the subscription
* @dev simulated offchain to determine if sufficient balance is present to fulfill the request
*/
function fulfillRandomWords(Proof memory proof, RequestCommitment memory rc) external nonReentrant returns (uint96) {
function fulfillRandomWords(Proof calldata proof, RequestCommitment calldata rc) external nonReentrant returns (uint96) {
uint256 startGas = gasleft();
(bytes32 keyHash, uint256 requestId, uint256 randomness) = getRandomnessFromProof(proof, rc);

Expand Down
2 changes: 1 addition & 1 deletion contracts/src/v0.8/vrf/testhelpers/VRFTestHelper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ contract VRFTestHelper is VRF {
super._verifyVRFProof(pk, gamma, c, s, seed, uWitness, cGammaWitness, sHashWitness, zInv);
}

function randomValueFromVRFProof_(Proof memory proof, uint256 seed) public view returns (uint256 output) {
function randomValueFromVRFProof_(Proof calldata proof, uint256 seed) public view returns (uint256 output) {
return super._randomValueFromVRFProof(proof, seed);
}
}

0 comments on commit 8db302b

Please sign in to comment.