-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: RPC limits & standard plans (#16)
* feat: add rpc provider limit * feat: catch rpc provider rate limit on runtime * chore: display rpc and duration usage warnings * tests: new rpc limits * chore: add nodejs v>16 requirement * feat: add task creation link on deploy * chore: update storage wording * chore: bump version * chore: bump sdk version
- Loading branch information
Showing
12 changed files
with
119 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
engine-strict=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { | ||
Web3Function, | ||
Web3FunctionContext, | ||
} from "@gelatonetwork/web3-functions-sdk"; | ||
import ky from "ky"; | ||
import { Contract, ethers } from "ethers"; | ||
const delay = (time: number) => new Promise((res) => setTimeout(res, time)); | ||
|
||
const ORACLE_ABI = [ | ||
"function lastUpdated() external view returns(uint256)", | ||
"function updatePrice(uint256)", | ||
]; | ||
|
||
Web3Function.onRun(async (context: Web3FunctionContext) => { | ||
const { provider } = context; | ||
|
||
// Test soft rate limits | ||
const oracleAddress = "0x6a3c82330164822A8a39C7C0224D20DB35DD030a"; | ||
const oracle = new Contract(oracleAddress, ORACLE_ABI, provider); | ||
try { | ||
const promises: Promise<any>[] = []; | ||
for (let i = 0; i < 20; i++) promises.push(oracle.lastUpdated()); | ||
await Promise.race(promises); | ||
} catch (err) { | ||
console.log("Throttling RPC calls error:", err.message); | ||
} | ||
|
||
await delay(9000); | ||
|
||
return { canExec: false, message: "RPC providers tests ok!" }; | ||
}); |