Cyfrin / foundry-smart-contract-lottery-cu

47 stars 38 forks source link

uint256/uint64 SubscriptionId #52

Closed DS-Coding0 closed 4 months ago

DS-Coding0 commented 4 months ago

Hello i've a problem with the subscriptionId from ChainLink. The new v2.5 subscriptionId's doesn't fit in a uint64.. i tried with this

    uint256 subId =
        111660964082621931635013845681919161914960938769201491057353820779771043574085;
    uint64 subIdToUse = uint64(subId);

    struct NetworkConfig {
        uint256 entranceFee;
        uint256 interval;
        address vrfCoordinator;
        bytes32 gasLane;
        uint64 subscriptionId;
        uint32 callbackGasLimit;
        address link;
        uint256 deployerKey;
    }

But if i ran into test there is a problem with invalid Subscription Heres the testCode

$ forge test --fork-url $SEPOLIA_RPC_URL -vvvvvvv
[⠊] Compiling...
No files changed, compilation skipped

Ran 1 test for test/unit/RaffleTest.t.sol:RaffleTest
[FAIL. Reason: setup failed: InvalidSubscription()] setUp() (gas: 0)
Logs:
  Adding consumer contract: 0x90193C961A926261B756D1E5bb255e67ff9498A1
  Using vrfCoordinator:  0x8103B0A8A00be2DDC778e6e7eaa21791Cd364625
  On ChainID:  11155111

Traces:
  [30877841] RaffleTest::setUp()
    ├─ [21693968] → new DeployRaffle@0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f
    │   └─ ← [Return] 108146 bytes of code
    ├─ [9108667] DeployRaffle::run()
    │   ├─ [2584443] → new HelperConfig@0x104fBc016F4bb334D775a19E8A6510109AC63E00
    │   │   ├─ [0] VM::envUint("PRIVATE_KEY") [staticcall]
    │   │   │   └─ ← [Return] <env var value>
    │   │   └─ ← [Return] 11896 bytes of code
    │   ├─ [1121] HelperConfig::activeNetworkConfig() [staticcall]
    │   │   └─ ← [Return] 10000000000000000 [1e16], 30, 0x8103B0A8A00be2DDC778e6e7eaa21791Cd364625, 0x474e34a077df58807dbe9c96d3c009b23b3c6d0cce433e59bbf5b34f823bc56c, 639138992354554181 [6.391e17], 500000 [5e5], 0x779877A7B0D9E8603169DdbD7836e478b4624789, 93450414746917579586137531141216183331316683098185494399813829077597600090296 [9.345e76]
    │   ├─ [0] VM::startBroadcast()
    │   │   └─ ← [Return] 
    │   ├─ [597620] → new Raffle@0x90193C961A926261B756D1E5bb255e67ff9498A1
    │   │   └─ ← [Return] 2860 bytes of code
    │   ├─ [0] VM::stopBroadcast()
    │   │   └─ ← [Return] 
    │   ├─ [5806185] → new AddConsumer@0x037eDa3aDB1198021A9b2e88C22B464fD38db3f3
    │   │   └─ ← [Return] 28885 bytes of code
    │   ├─ [11094] AddConsumer::addConsumer(Raffle: [0x90193C961A926261B756D1E5bb255e67ff9498A1], 0x8103B0A8A00be2DDC778e6e7eaa21791Cd364625, 639138992354554181 [6.391e17], 93450414746917579586137531141216183331316683098185494399813829077597600090296 [9.345e76])
    │   │   ├─ [0] console::log("Adding consumer contract:", Raffle: [0x90193C961A926261B756D1E5bb255e67ff9498A1]) [staticcall]
    │   │   │   └─ ← [Stop] 
    │   │   ├─ [0] console::log("Using vrfCoordinator: ", 0x8103B0A8A00be2DDC778e6e7eaa21791Cd364625) [staticcall]
    │   │   │   └─ ← [Stop] 
    │   │   ├─ [0] console::log("On ChainID: ", 11155111 [1.115e7]) [staticcall]
    │   │   │   └─ ← [Stop] 
    │   │   ├─ [0] VM::startBroadcast(<pk>)
    │   │   │   └─ ← [Return] 
    │   │   ├─ [2690] 0x8103B0A8A00be2DDC778e6e7eaa21791Cd364625::addConsumer(639138992354554181 [6.391e17], Raffle: [0x90193C961A926261B756D1E5bb255e67ff9498A1])
    │   │   │   └─ ← [Revert] InvalidSubscription()
    │   │   └─ ← [Revert] InvalidSubscription()
    │   └─ ← [Revert] InvalidSubscription()
    └─ ← [Revert] InvalidSubscription()

Suite result: FAILED. 0 passed; 1 failed; 0 skipped; finished in 2.84s (0.00ns CPU time)

Ran 1 test suite in 4.00s (2.84s CPU time): 0 tests passed, 1 failed, 0 skipped (1 total tests)

Failing tests:
Encountered 1 failing test in test/unit/RaffleTest.t.sol:RaffleTest
[FAIL. Reason: setup failed: InvalidSubscription()] setUp() (gas: 0)

I think there's something wrong with the uint64.. anyone have a solution for this??

DS-Coding0 commented 4 months ago

Need to make a complete v2Plus integration.

https://docs.chain.link/vrf/v2-5/migration-from-v2

EngrPips commented 4 months ago

Hello @DS-Coding0, Did you figure this out already?

DS-Coding0 commented 4 months ago

Hello @DS-Coding0, Did you figure this out already?

Yes i done some more research about the Migration.. this problem is been solved..

But i have some more problems but first i'll try to solve it by myself. thank you.

EngrPips commented 4 months ago

Awesome. That's what programmers do. Figure out stuff. If you need help at any point, we are always here to help.