Cyfrin / foundry-smart-contract-lottery-cu

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

**Wrong keyhash** for sepolia network - make the lottery stuck in `CALC` status

worca333 opened this issue · comments

In advance, I'd like to thank @PatrickAlphaC for an fast & productive course!

I found an issue with the keyHash of VRF subscription for the sepolia network.

After successfully deploying Raffle contract, subscribing to a chainlink VRF, and creating a chainlink upkeep timer, it seemed everything was in place and ready to work correctly.
But somehow the lottery didn't award the winner at the last step - choosing the winner by a random number which is provided by VRFCoordinatorV2_5. Why? There was an error occurred within the s_vrfCoordinator.requestRandomWords request.
What is irony though, the request itself came out as a successful one so that the performUpkeep method passed while updating the lottery status to CALC.
Our contract never got a call to fulfillRandomWords which means it stuck with CALC status and all funds entered.

Deep inside, it was the problem with the keyHash (gasLane) of the config.
Since we're using VRF v2.5, it should be 0x787d74caea10b2b357790d5b5247c2f63d1d91572a9846f780606e4d953677ae from https://docs.chain.link/vrf/v2-5/supported-networks#sepolia-testnet
But current codebase had 0x474e34a077df58807dbe9c96d3c009b23b3c6d0cce433e59bbf5b34f823bc56c from https://docs.chain.link/vrf/v2/subscription/supported-networks#sepolia-testnet

Should it be fixed to a correct keyHash, it worked perfect!

Hope this helps.

Hello @worca333, this is pretty interesting. Can you please share the lesson link on the updraft you are referring to? That way, we can add and update the written lesson in that section.

Cheers.

Sorry, @worca333, but the lesson you mention is the beginning of it. Can you point me to the actual lesson video, please?

@cromewar
This is the lesson where Patrick makes up those values in HelperConfig.s.sol. Interestingly, it looks correct in the video while it isn't in the codebase.