Skip to content

Commit

Permalink
[VRFv2+] Change request commitment from calldata to memory (#10176)
Browse files Browse the repository at this point in the history
* Remove extraArgs from v2plus log

* prettier

* update interfaces

* Make requestCommitment memory

* Update tests

* Change request commitment from calldata to memory

* Add wrapper changes

* Remove subId from emit RandomWordsFulfilled Event log

* Revert "Remove subId from emit RandomWordsFulfilled Event log"

This reverts commit 337cfb7.

* Change proof to memory from calldata

* Prettier

---------

Co-authored-by: Sri Kidambi <1702865+kidambisrinivas@users.noreply.github.com>
Co-authored-by: Sri Kidambi <kidambisrinivas@users.noreply.github.com>
  • Loading branch information
3 people authored Aug 14, 2023
1 parent ee80c6d commit abcbc8e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
9 changes: 3 additions & 6 deletions contracts/src/v0.8/dev/vrf/VRFCoordinatorV2Plus.sol
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ contract VRFCoordinatorV2Plus is VRF, SubscriptionAPI {
}

function getRandomnessFromProof(
Proof calldata proof,
Proof memory proof,
RequestCommitment memory rc
) internal view returns (Output memory) {
bytes32 keyHash = hashOfKey(proof.pk);
Expand Down Expand Up @@ -388,10 +388,7 @@ contract VRFCoordinatorV2Plus is VRF, SubscriptionAPI {
* @return payment amount billed to the subscription
* @dev simulated offchain to determine if sufficient balance is present to fulfill the request
*/
function fulfillRandomWords(
Proof calldata proof,
RequestCommitment calldata rc
) external nonReentrant returns (uint96) {
function fulfillRandomWords(Proof memory proof, RequestCommitment memory rc) external nonReentrant returns (uint96) {
uint256 startGas = gasleft();
Output memory output = getRandomnessFromProof(proof, rc);

Expand Down Expand Up @@ -419,7 +416,7 @@ contract VRFCoordinatorV2Plus is VRF, SubscriptionAPI {

// stack too deep error
{
bool nativePayment = _fromBytes(rc.extraArgs).nativePayment;
bool nativePayment = uint8(rc.extraArgs[rc.extraArgs.length - 1]) == 1;
// We want to charge users exactly for how much gas they use in their callback.
// The gasAfterPaymentCalculation is meant to cover these additional operations where we
// decrement the subscription balance and increment the oracles withdrawable balance.
Expand Down
Loading

0 comments on commit abcbc8e

Please sign in to comment.