@@ -369,6 +369,7 @@ abstract contract Entropy is IEntropy, EntropyState {
369369 req.requester,
370370 req.sequenceNumber,
371371 userRandomNumber,
372+ uint32 (req.gasLimit10k) * TEN_THOUSAND,
372373 bytes ("" )
373374 );
374375 return req.sequenceNumber;
@@ -543,16 +544,13 @@ abstract contract Entropy is IEntropy, EntropyState {
543544 revert EntropyErrors.InvalidRevealCall ();
544545 }
545546
546- bytes32 blockHash;
547547 bytes32 randomNumber;
548- (randomNumber, blockHash ) = revealHelper (
548+ (randomNumber, ) = revealHelper (
549549 req,
550550 userRandomNumber,
551551 providerRevelation
552552 );
553553
554- address callAddress = req.requester;
555-
556554 // If the request has an explicit gas limit, then run the new callback failure state flow.
557555 //
558556 // Requests that haven't been invoked yet will be invoked safely (catching reverts), and
@@ -567,7 +565,7 @@ abstract contract Entropy is IEntropy, EntropyState {
567565 bool success;
568566 bytes memory ret;
569567 uint256 startingGas = gasleft ();
570- (success, ret) = callAddress .excessivelySafeCall (
568+ (success, ret) = req.requester .excessivelySafeCall (
571569 // Warning: the provided gas limit below is only an *upper bound* on the gas provided to the call.
572570 // At most 63/64ths of the current context's gas will be provided to a call, which may be less
573571 // than the indicated gas limit. (See CALL opcode docs here https://www.evm.codes/?fork=cancun#f1)
@@ -582,6 +580,7 @@ abstract contract Entropy is IEntropy, EntropyState {
582580 randomNumber
583581 )
584582 );
583+ uint32 gasUsed = SafeCast.toUint32 (startingGas - gasleft ());
585584 // Reset status to not started here in case the transaction reverts.
586585 req.callbackStatus = EntropyStatusConstants.CALLBACK_NOT_STARTED;
587586
@@ -599,6 +598,7 @@ abstract contract Entropy is IEntropy, EntropyState {
599598 randomNumber,
600599 false ,
601600 ret,
601+ SafeCast.toUint32 (gasUsed),
602602 bytes ("" )
603603 );
604604 clearRequest (provider, sequenceNumber);
@@ -628,6 +628,7 @@ abstract contract Entropy is IEntropy, EntropyState {
628628 randomNumber,
629629 true ,
630630 ret,
631+ SafeCast.toUint32 (gasUsed),
631632 bytes ("" )
632633 );
633634 req.callbackStatus = EntropyStatusConstants.CALLBACK_FAILED;
@@ -655,13 +656,15 @@ abstract contract Entropy is IEntropy, EntropyState {
655656 randomNumber,
656657 false ,
657658 bytes ("" ),
659+ 0 , // gas usage not tracked in the old no-gas-limit flow.
658660 bytes ("" )
659661 );
660662
661663 clearRequest (provider, sequenceNumber);
662664
663- // Check if the callAddress is a contract account.
665+ // Check if the requester is a contract account.
664666 uint len;
667+ address callAddress = req.requester;
665668 assembly {
666669 len := extcodesize (callAddress)
667670 }
0 commit comments