-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Investigate gas estimation with large amounts of gas #1997
Comments
As a note, the user reporting this seems to be using base-sepolia-testnet |
The problem does not only happen in Base Sepolia, It also happens in Ethereum Sepolia as well. |
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@api3/airnode-protocol/contracts/rrp/interfaces/IAirnodeRrpV0.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
contract MockedRequester is
Ownable
{
address internal _airnodeRrp;
address internal _airnode;
address internal _sponsorWallet;
bytes32 internal _endpointIdUint256;
event Requested(bytes32 requestId);
constructor() {}
function setSettings(
address airnodeRrp,
address airnode,
address sponsorWallet,
bytes32 endpointIdUint256
) external onlyOwner {
_airnodeRrp = airnodeRrp;
_airnode = airnode;
_sponsorWallet = sponsorWallet;
_endpointIdUint256 = endpointIdUint256;
IAirnodeRrpV0(_airnodeRrp).setSponsorshipStatus(address(this), true);
}
struct Request {
uint256 fromId;
uint256 toId;
uint256 timestamp;
bool hasReferral;
}
struct Response {
uint256 rawSeed;
uint256 timestamp;
bool hasReferral;
}
function requestUint256(uint256 tokenIdCount) external onlyOwner {
bytes32 requestId = IAirnodeRrpV0(
_airnodeRrp
).makeFullRequest(
_airnode,
_endpointIdUint256,
address(this),
_sponsorWallet,
address(this),
this.fulfillUint256.selector,
""
);
_expectedRequests[requestId] = Request(0, tokenIdCount, block.timestamp, false);
emit Requested(requestId);
}
mapping(bytes32 => Request) private _expectedRequests;
mapping(bytes32 => Response) private _requestToResponse;
uint256 private _totalProbability;
function fulfillUint256(bytes32 requestId, bytes calldata data) external {
// validate request
Request memory seedRequest = _expectedRequests[requestId];
if (msg.sender != _airnodeRrp) {
revert();
}
// decode seed
uint256 rawSeed = abi.decode(data, (uint256));
// set request's response
_requestToResponse[requestId] = Response(rawSeed, seedRequest.timestamp, seedRequest.hasReferral);
// iterate over token ids
for (uint256 i = seedRequest.fromId; i < seedRequest.toId; i++) {
_totalProbability += (rawSeed ^ i) % type(uint32).max;
}
delete _expectedRequests[requestId];
}
} You can use this contract to test out the fulfillment as I did. This is the mocked version of how my actual fulfillment is happening. |
@tarik0 - what sorts of values are representative for your |
@bbenligiray / @Siegrift - I spun up a local Airnode and local hardhat network, deployed the contract (with a few slight variations), and tested increasingly large INFO Gas limit is set to 554767 (AirnodeRrp: 41995 + Fulfillment Call: 512772) However, when I tried airnode/packages/airnode-node/src/evm/fulfillments/api-calls.ts Lines 188 to 196 in 228d91d
indicating that there is a timeout occurring when trying to estimate the fulfillment call overhead. Full logs here:
|
@dcroote The amounts you've entered are almost the same as mine. I also had problems with more than 500 token IDs. I bet the simulation gets timed out since the transaction flow gets bigger but I don't know why this suggests a gas limit instead of throwing some error. |
A user on Discord is reporting gas estimation issues when fulfillment uses a large amount of gas:
The text was updated successfully, but these errors were encountered: