Skip to content

Commit 6ec328a

Browse files
committed
cleanup
1 parent 57d5ae2 commit 6ec328a

File tree

8 files changed

+34
-22
lines changed

8 files changed

+34
-22
lines changed

target_chains/ethereum/contracts/contracts/entropy/Entropy.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ abstract contract Entropy is IEntropy, EntropyState {
317317
requestWithCallbackAndGasLimit(
318318
provider,
319319
userRandomNumber,
320-
_state.providers[provider].defaultGasLimit
320+
0 // Passing 0 will assign the request the provider's default gas limit
321321
);
322322
}
323323

target_chains/ethereum/entropy_sdk/solidity/EntropyErrors.sol

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,4 @@ library EntropyErrors {
4545
error UpdateTooOld();
4646
// Not enough gas was provided to the function to execute the callback with the desired amount of gas.
4747
error InsufficientGas();
48-
// An argument to the function call was invalid or out of the expected range.
49-
error InvalidArgument();
5048
}

target_chains/ethereum/entropy_sdk/solidity/EntropyEvents.sol

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,10 @@ interface EntropyEvents {
5151

5252
event ProviderFeeUpdated(address provider, uint128 oldFee, uint128 newFee);
5353

54-
// TODO: uint32
5554
event ProviderDefaultGasLimitUpdated(
5655
address indexed provider,
57-
uint64 oldDefaultGasLimit,
58-
uint64 newDefaultGasLimit
56+
uint32 oldDefaultGasLimit,
57+
uint32 newDefaultGasLimit
5958
);
6059

6160
event ProviderUriUpdated(address provider, bytes oldUri, bytes newUri);

target_chains/ethereum/entropy_sdk/solidity/EntropyStructs.sol

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,9 @@ contract EntropyStructs {
6363
bool useBlockhash;
6464
// Status flag for requests with callbacks. See EntropyConstants for the possible values of this flag.
6565
uint8 callbackStatus;
66-
// 2 bytes of space left in this struct.
67-
// The gasLimit in units of 10k gas. (i.e., 2 = 20k gas)
66+
// The gasLimit in units of 10k gas. (i.e., 2 = 20k gas). We're using units of 10k in order to fit this
67+
// field into the remaining 2 bytes of this storage slot. The dynamic range here is 10k - ~65M, which should
68+
// cover all real-world use cases.
6869
uint16 gasLimit10k;
6970
}
7071
}

target_chains/ethereum/entropy_sdk/solidity/IEntropy.sol

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,30 @@ interface IEntropy is EntropyEvents {
4848
//
4949
// The address calling this function should be a contract that inherits from the IEntropyConsumer interface.
5050
// The `entropyCallback` method on that interface will receive a callback with the generated random number.
51+
// `entropyCallback` will be run with the provider's default gas limit (see `getProviderInfo(provider).defaultGasLimit`).
52+
// If your callback needs additional gas, please use `requestWithCallbackAndGasLimit`.
5153
//
52-
// This method will revert unless the caller provides a sufficient fee (at least getFee(provider)) as msg.value.
54+
// This method will revert unless the caller provides a sufficient fee (at least `getFee(provider)`) as msg.value.
5355
// Note that excess value is *not* refunded to the caller.
5456
function requestWithCallback(
5557
address provider,
5658
bytes32 userRandomNumber
5759
) external payable returns (uint64 assignedSequenceNumber);
5860

61+
// Request a random number from `provider`, getting a callback with the result.
62+
// The caller must specify a provider to fulfill the request -- `getDefaultProvider()` is a sane default --
63+
// and a `userRandomNumber` to combine into the result. The method returns a sequence number which callers
64+
// should save to correlate the request with the callback.
65+
//
66+
// The address calling this function should be a contract that inherits from the IEntropyConsumer interface.
67+
// The `entropyCallback` method on that interface will receive a callback with the returned sequence number and
68+
// the generated random number. `entropyCallback` will be run with the `gasLimit` provided to this function.
69+
// The `gasLimit` will be rounded up to a multiple of 10k (e.g., 19000 -> 20000), and furthermore is lower bounded
70+
// by the provider's configured default limit.
71+
//
72+
// This method will revert unless the caller provides a sufficient fee (at least `getFeeForGas(provider, gasLimit)`) as msg.value.
73+
// Note that provider fees can change over time. Thus, callers of this method should explictly compute `getFeeForGas(provider, gasLimit)`
74+
// prior to each invocation (as opposed to hardcoding a value). Further note that excess value is *not* refunded to the caller.
5975
function requestWithCallbackAndGasLimit(
6076
address provider,
6177
bytes32 userRandomNumber,
@@ -104,8 +120,11 @@ interface IEntropy is EntropyEvents {
104120
uint64 sequenceNumber
105121
) external view returns (EntropyStructs.Request memory req);
106122

123+
// Get the fee charged by provider for a request with the default gasLimit (`request` or `requestWithCallback`).
124+
// If you are calling `requestWithCallbackAndGasLimit`, please use `getFeeForGas`.
107125
function getFee(address provider) external view returns (uint128 feeAmount);
108126

127+
// Get the fee charged by `provider` for a request with a specific `gasLimit` (`requestWithCallbackAndGasLimit`).
109128
function getFeeForGas(
110129
address provider,
111130
uint32 gasLimit

target_chains/ethereum/entropy_sdk/solidity/abis/EntropyErrors.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@
2424
"name": "InsufficientGas",
2525
"type": "error"
2626
},
27-
{
28-
"inputs": [],
29-
"name": "InvalidArgument",
30-
"type": "error"
31-
},
3227
{
3328
"inputs": [],
3429
"name": "InvalidRevealCall",

target_chains/ethereum/entropy_sdk/solidity/abis/EntropyEvents.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,15 @@
108108
},
109109
{
110110
"indexed": false,
111-
"internalType": "uint64",
111+
"internalType": "uint32",
112112
"name": "oldDefaultGasLimit",
113-
"type": "uint64"
113+
"type": "uint32"
114114
},
115115
{
116116
"indexed": false,
117-
"internalType": "uint64",
117+
"internalType": "uint32",
118118
"name": "newDefaultGasLimit",
119-
"type": "uint64"
119+
"type": "uint32"
120120
}
121121
],
122122
"name": "ProviderDefaultGasLimitUpdated",

target_chains/ethereum/entropy_sdk/solidity/abis/IEntropy.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,15 @@
108108
},
109109
{
110110
"indexed": false,
111-
"internalType": "uint64",
111+
"internalType": "uint32",
112112
"name": "oldDefaultGasLimit",
113-
"type": "uint64"
113+
"type": "uint32"
114114
},
115115
{
116116
"indexed": false,
117-
"internalType": "uint64",
117+
"internalType": "uint32",
118118
"name": "newDefaultGasLimit",
119-
"type": "uint64"
119+
"type": "uint32"
120120
}
121121
],
122122
"name": "ProviderDefaultGasLimitUpdated",

0 commit comments

Comments
 (0)