Polygon链上Chainlink自定义自动化第二个触发器无法触发求助
Chainlink自定义自动化合约第二个触发器无法自动触发排查求助
在Polygon区块链上部署了Chainlink自定义逻辑自动化合约,包含两个触发器逻辑:
- 第一个对应
allParticipantsRegistered分支,运行完全正常,能自动触发并执行drawnumbers() - 第二个对应
randomNumberGenerated分支,无法自动触发,但手动调用manualRunGame()能正常执行runGame()
旧版本合约运行无异常,已将Upkeep的Gas限制设置为2500000,未找到触发失败的错误日志。Upkeep ID:37786756493441211265373049430028170682412354847343002706062893578728763693235
核心Upkeep逻辑代码
// The automaton guiding our celestial course - Chainlink Upkeep function checkUpkeep(bytes calldata checkData) public view override returns (bool upkeepNeeded, bytes memory performData) { // Decisions abound at the helm of our cosmic journey. When our spaceship registers a full complement of intrepid Cosmoonauts, it initiates a wide scan of the cosmos, sending out a request for celestial coordinates of resource-rich planets. Upon receipt of this crucial data, our navigation system leaps into action, divvying up the discovered celestial bodies among the Cosmoonauts who have yet to stake their claim on a new world. upkeepNeeded = randomNumberGenerated || allParticipantsRegistered; // We don't require any specific maintenance data in our cosmic journey. // Therefore, we return our received checkData as performData. performData = checkData; } function performUpkeep(bytes calldata /*performData*/) public override { // We ensure our celestial course still requires an adjustment. require(randomNumberGenerated || allParticipantsRegistered, "No upkeep needed"); //Have the celestial coordinates of resource-rich planets reached us? Ignite the hyperdrives! It's time to launch the exploration mission and distribute the interstellar spoils among the fortunate Cosmoonauts //This one is not triggering if (randomNumberGenerated) { randomNumberGenerated = false; runGame(); } // Is our spaceship teeming with brave Cosmoonauts? Power up the star mapping sequence! We are now setting course to chart the undiscovered galaxies and their bountiful planets. //This one works perfectly launching the vrf and receiving the numbers if (allParticipantsRegistered) { allParticipantsRegistered = false; drawnumbers(); } } // Manual function to test runGame function manualRunGame() external onlyFGCreator { require(randomNumberGenerated, "Random number not generated yet"); randomNumberGenerated = false; runGame();//This one runs smoothly while launched manually } // Manual function to test drawNumbers function manualDrawNumbers() external onlyFGCreator { require(allParticipantsRegistered, "Not all participants registered yet"); allParticipantsRegistered = false; drawnumbers(); }
触发值变更代码(fulfillRandomWords)
function fulfillRandomWords(uint256 requestId, uint256[] calldata motsAleatoires) internal override { require(!requetesTraitees[requestId], "La requete a deja ete traitee."); // Each number in the array is a fresh, new coordinate for our Cosmoonauts! for (uint i = 0; i < motsAleatoires.length; i++) { listeNombresAleatoires.push(motsAleatoires[i]); } // We've processed this batch, so let's not repeat it. requetesTraitees[requestId] = true; requetesRestantes--; // When all the requests have been processed and we've got all our random numbers, we're ready to roll. if (requetesRestantes == 0) { // An event to signal our ground control (aka the front end) that all the coordinates for the mission have been generated. emit TousLesNombresAleatoiresGeneres(); randomNumberGenerated = true; // The random number generation is finished. The stars are now aligned for the launch! } }
希望有人帮忙排查第二个触发器无法自动触发的原因。
内容的提问来源于stack exchange,提问作者Jawhar Aredsgfs
相关产品推荐
相关产品推荐

