From e3fd846a1a45ff83c957faeb0ea1cfb5a4ab44dd Mon Sep 17 00:00:00 2001 From: Amin Moghaddam Date: Wed, 12 Jun 2024 15:07:52 +0200 Subject: [PATCH 1/4] feat(entropy): More best practices --- components/EntropyDeployments.tsx | 2 +- pages/entropy/best-practices.mdx | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/components/EntropyDeployments.tsx b/components/EntropyDeployments.tsx index 2c06f7d5..0627e5cf 100644 --- a/components/EntropyDeployments.tsx +++ b/components/EntropyDeployments.tsx @@ -163,7 +163,7 @@ export const EntropyDeployments: Record = { "berachain-testnet-v2": { rpc: "https://evm-rpc-bera.rhino-apis.com/", network: "testnet", - delay: "", + delay: "https://bartio.beratrail.io/address/$ADDRESS", address: "0x36825bf3Fbdf5a29E2d5148bfe7Dcf7B5639e320", explorer: "", gasLimit: "500K", diff --git a/pages/entropy/best-practices.mdx b/pages/entropy/best-practices.mdx index 8ddf181c..c19f7fba 100644 --- a/pages/entropy/best-practices.mdx +++ b/pages/entropy/best-practices.mdx @@ -1,5 +1,19 @@ # Best Practices +## Limit gas usage on the callback + +Since the entropy providers limit the gas usage on the callbacks, +it is important to keep the callback function as simple as possible +so that the gas usage is predictable and below the limits. +This will ensure consistent performance and avoid potential issues with the callback. + +For example, if you want to use entropy to generate a random number for each player in a round of game, you need to make sure that the callback function works for the maximum number of players that can be in each round. +Otherwise, the callbacks will work for some rounds with fewer players, but will fail for rounds with more players. +Multiple solutions are possible to address this problem. You can store the random number received from the callback and +either ask users to submit more transactions after the callback to continue the flow or run a background crank service to submit the necessary transactions. + +You can see the gas limits for each chain in [this](./contract-addresses) page. + ## Generating random values within a specific range You can map the random number provided by Entropy into a smaller range using the solidity [modulo operator](https://docs.soliditylang.org/en/latest/types.html#modulo). From ffc921643052618add42e53e7568063bd8ddee26 Mon Sep 17 00:00:00 2001 From: Amin Moghaddam Date: Wed, 12 Jun 2024 15:14:37 +0200 Subject: [PATCH 2/4] Better spacing --- pages/entropy/best-practices.mdx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pages/entropy/best-practices.mdx b/pages/entropy/best-practices.mdx index c19f7fba..3ab65b0d 100644 --- a/pages/entropy/best-practices.mdx +++ b/pages/entropy/best-practices.mdx @@ -7,10 +7,13 @@ it is important to keep the callback function as simple as possible so that the gas usage is predictable and below the limits. This will ensure consistent performance and avoid potential issues with the callback. -For example, if you want to use entropy to generate a random number for each player in a round of game, you need to make sure that the callback function works for the maximum number of players that can be in each round. +For example, if you want to use entropy to generate a random number for each player in a round of game, +you need to make sure that the callback function works for the maximum number of players that can be in each round. Otherwise, the callbacks will work for some rounds with fewer players, but will fail for rounds with more players. + Multiple solutions are possible to address this problem. You can store the random number received from the callback and -either ask users to submit more transactions after the callback to continue the flow or run a background crank service to submit the necessary transactions. +either ask users to submit more transactions after the callback to continue the flow or run a background crank service +to submit the necessary transactions. You can see the gas limits for each chain in [this](./contract-addresses) page. From bba5d651e012d9eae0ca68661fdc22afcd2cfe6f Mon Sep 17 00:00:00 2001 From: Amin Moghaddam Date: Thu, 13 Jun 2024 10:05:43 +0200 Subject: [PATCH 3/4] Address comments --- pages/entropy/best-practices.mdx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/pages/entropy/best-practices.mdx b/pages/entropy/best-practices.mdx index 3ab65b0d..37a4fb43 100644 --- a/pages/entropy/best-practices.mdx +++ b/pages/entropy/best-practices.mdx @@ -2,10 +2,8 @@ ## Limit gas usage on the callback -Since the entropy providers limit the gas usage on the callbacks, -it is important to keep the callback function as simple as possible -so that the gas usage is predictable and below the limits. -This will ensure consistent performance and avoid potential issues with the callback. +Keeping the callback function simple is crucial because the entropy providers limit gas usage. +This ensures gas usage is predictable and consistent, avoiding potential issues with the callback. For example, if you want to use entropy to generate a random number for each player in a round of game, you need to make sure that the callback function works for the maximum number of players that can be in each round. @@ -15,7 +13,7 @@ Multiple solutions are possible to address this problem. You can store the rando either ask users to submit more transactions after the callback to continue the flow or run a background crank service to submit the necessary transactions. -You can see the gas limits for each chain in [this](./contract-addresses) page. +The gas limit for each chain is listed on the [contract addresses](./contract-addresses) page. ## Generating random values within a specific range From 9f03689d64cde2f0447062f1f7a143385d9d38d3 Mon Sep 17 00:00:00 2001 From: Amin Moghaddam Date: Thu, 13 Jun 2024 10:10:30 +0200 Subject: [PATCH 4/4] Update etherlink gaslimit --- components/EntropyDeployments.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/EntropyDeployments.tsx b/components/EntropyDeployments.tsx index 0627e5cf..95829621 100644 --- a/components/EntropyDeployments.tsx +++ b/components/EntropyDeployments.tsx @@ -236,7 +236,7 @@ export const EntropyDeployments: Record = { address: "0x23f0e8FAeE7bbb405E7A7C3d60138FCfd43d7509", explorer: "https://testnet-explorer.etherlink.com/address/$ADDRESS", delay: "", - gasLimit: "500K", + gasLimit: "15M", network: "testnet", rpc: "https://node.ghostnet.etherlink.com", },