From e209d3ffb219887b886a7cc321d5104241a46706 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Fri, 3 Jan 2025 18:51:25 +0000 Subject: [PATCH 1/4] docs: add handling callback failures section to entropy best practices Co-Authored-By: Jayant Krishnamurthy --- pages/entropy/best-practices.mdx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pages/entropy/best-practices.mdx b/pages/entropy/best-practices.mdx index afced270..72822e8f 100644 --- a/pages/entropy/best-practices.mdx +++ b/pages/entropy/best-practices.mdx @@ -33,6 +33,20 @@ function mapRandomNumber( ``` +## Handling Callback Failures + +While the default entropy provider is highly reliable, in rare cases a callback might not be received. This typically happens when there's an issue with your contract's callback implementation rather than with the provider itself. The most common causes are: + +1. The callback function is using more gas than the allowed limit +2. The callback function contains logic that throws an error + +If you're not receiving a callback, you can manually invoke it to identify the specific issue. This allows you to: +- See if the transaction fails and why +- Check the gas usage against the chain's callback gas limit +- Debug your callback implementation + +For detailed instructions on how to manually invoke and debug callbacks, refer to the [Debug Callback Failures](./debug-callback-failures) guide. + Notice that using the modulo operator can distort the distribution of random numbers if it's not a power of 2. This is negligible for small and medium ranges, but it can be noticeable for large ranges. For example, if you want to generate a random number between 1 and 52, the probability of having value 5 is approximately From 9707e4e0536c453f6bfe9e585a1a8cf33c5f4d92 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Fri, 3 Jan 2025 18:54:34 +0000 Subject: [PATCH 2/4] style: fix prettier formatting Co-Authored-By: Jayant Krishnamurthy --- pages/entropy/best-practices.mdx | 1 + 1 file changed, 1 insertion(+) diff --git a/pages/entropy/best-practices.mdx b/pages/entropy/best-practices.mdx index 72822e8f..d279daf3 100644 --- a/pages/entropy/best-practices.mdx +++ b/pages/entropy/best-practices.mdx @@ -41,6 +41,7 @@ While the default entropy provider is highly reliable, in rare cases a callback 2. The callback function contains logic that throws an error If you're not receiving a callback, you can manually invoke it to identify the specific issue. This allows you to: + - See if the transaction fails and why - Check the gas usage against the chain's callback gas limit - Debug your callback implementation From 40b1d0e194826d075f164dde409416cbdcd94861 Mon Sep 17 00:00:00 2001 From: Jayant Krishnamurthy Date: Fri, 3 Jan 2025 10:56:40 -0800 Subject: [PATCH 3/4] Update best-practices.mdx --- pages/entropy/best-practices.mdx | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/pages/entropy/best-practices.mdx b/pages/entropy/best-practices.mdx index d279daf3..73d241ba 100644 --- a/pages/entropy/best-practices.mdx +++ b/pages/entropy/best-practices.mdx @@ -15,6 +15,21 @@ to submit the necessary transactions. The gas limit for each chain is listed on the [contract addresses](./contract-addresses) page. +## Handling Callback Failures + +While the default entropy provider is highly reliable, in rare cases a callback might not be received. This typically happens when there's an issue with your contract's callback implementation rather than with the provider itself. The most common causes are: + +1. The callback function is using more gas than the allowed limit +2. The callback function contains logic that throws an error + +If you're not receiving a callback, you can manually invoke it to identify the specific issue. This allows you to: + +- See if the transaction fails and why +- Check the gas usage against the chain's callback gas limit +- Debug your callback implementation + +For detailed instructions on how to manually invoke and debug callbacks, refer to the [Debug Callback Failures](./debug-callback-failures) guide. + ## 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). @@ -33,21 +48,6 @@ function mapRandomNumber( ``` -## Handling Callback Failures - -While the default entropy provider is highly reliable, in rare cases a callback might not be received. This typically happens when there's an issue with your contract's callback implementation rather than with the provider itself. The most common causes are: - -1. The callback function is using more gas than the allowed limit -2. The callback function contains logic that throws an error - -If you're not receiving a callback, you can manually invoke it to identify the specific issue. This allows you to: - -- See if the transaction fails and why -- Check the gas usage against the chain's callback gas limit -- Debug your callback implementation - -For detailed instructions on how to manually invoke and debug callbacks, refer to the [Debug Callback Failures](./debug-callback-failures) guide. - Notice that using the modulo operator can distort the distribution of random numbers if it's not a power of 2. This is negligible for small and medium ranges, but it can be noticeable for large ranges. For example, if you want to generate a random number between 1 and 52, the probability of having value 5 is approximately From d938cb5db6b5676f6713ddfa0f82c1d27fad9660 Mon Sep 17 00:00:00 2001 From: Jayant Krishnamurthy Date: Fri, 3 Jan 2025 11:08:43 -0800 Subject: [PATCH 4/4] Update best-practices.mdx --- pages/entropy/best-practices.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/entropy/best-practices.mdx b/pages/entropy/best-practices.mdx index 73d241ba..16fb54eb 100644 --- a/pages/entropy/best-practices.mdx +++ b/pages/entropy/best-practices.mdx @@ -15,7 +15,7 @@ to submit the necessary transactions. The gas limit for each chain is listed on the [contract addresses](./contract-addresses) page. -## Handling Callback Failures +## Handling callback failures While the default entropy provider is highly reliable, in rare cases a callback might not be received. This typically happens when there's an issue with your contract's callback implementation rather than with the provider itself. The most common causes are: