Skip to content
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

Add AirnodeRrpV0DryRun #1737

Merged
merged 8 commits into from
Apr 14, 2023
Merged

Add AirnodeRrpV0DryRun #1737

merged 8 commits into from
Apr 14, 2023

Conversation

bbenligiray
Copy link
Member

@bbenligiray bbenligiray commented Apr 12, 2023

Closes #1716

See the contract comments. I'll address deployment separately, potentially along with #1734

// the calls from AirnodeRrpV0DryRun.
// Instead, we call an address that we know to not contain any
// bytecode, which means this call will not revert or spend extra gas.
(callSuccess, callData) = ADDRESS_WITH_NO_BYTECODE.call( // solhint-disable-line avoid-low-level-calls
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't want to use address(0) since some chains may have a contract at that address for whatever reason

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering just that 👍🏻
We can also safely assume that airnode and msg.sender are EOAs without bytecode, wouldn't those be an alternative as well?

Copy link
Member Author

@bbenligiray bbenligiray Apr 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can have msg.sender be a contract (if you can get the requester and the Airnode to play along -- and I think doing so would allow one to build trustless sponsor wallets using https://eips.ethereum.org/EIPS/eip-3074 in the future), but I see how airnode is guaranteed to be an EOA. Do you think that we should use that instead?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would allow one to build trustless sponsor wallets using https://eips.ethereum.org/EIPS/eip-3074 in the future

🤯

Do you think that we should use that instead?

I don't have a strong opinion about it. It is very unlikely that ADDRESS_WITH_NO_BYTECODE will collide with a smart contract address anyways so I think it's fine too.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I almost favor calling airnode because it would remove a big line of code

Copy link
Contributor

@acenolaza acenolaza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍🏻

// the calls from AirnodeRrpV0DryRun.
// Instead, we call an address that we know to not contain any
// bytecode, which means this call will not revert or spend extra gas.
(callSuccess, callData) = ADDRESS_WITH_NO_BYTECODE.call( // solhint-disable-line avoid-low-level-calls
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering just that 👍🏻
We can also safely assume that airnode and msg.sender are EOAs without bytecode, wouldn't those be an alternative as well?

Comment on lines +110 to +114
// The estimated gas will be ~40,000. This number can slightly change
// with future forks, and differ greatly between roll-ups and regular
// chains.
expect(estimatedGas.toNumber()).to.greaterThan(30000);
expect(estimatedGas.toNumber()).to.lessThan(50000);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏻
Just being curious, what would the gas more or less be when calling estimateGas on AirnodeRrpV0? I wonder if there is any value in comparing the 2 values in another expect() just to be safe.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's not guaranteed if it would be less or more because

  • AirnodeRrpV0DryRun's fulfill() costs less because it has a minimal external call
  • AirnodeRrpV0's fulfill() costs less because it deletes requestIdToFulfillmentParameters[requestId]

So it would depend on how heavy AirnodeRrpV0's fulfill()'s external call will be, which makes this not a very good test

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I agree. I'm just trying to see if we can find a more future-proof way of testing the estimageGas() response by using a relative comparison instead of hardcoded numbers that may become obsolete on different chains, etc. But I guess we can do that once (and if) this becomes an issue.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was mainly testing that it returns some kind of a number without erroring here. I don't think the value is very important as long as it's something completely wrong like -5 or 10000000000000000000.

/// will be used to execute a fulfillment successfully. Specifically, since
/// `eth_estimateGas` looks for the lowest gas limit that results in the
/// transaction not reverting, and AirnodeRrpV0's `fulfill()` does not revert
/// when its external call reverts (because it runs out of gas),
Copy link
Contributor

@Ashar2shahid Ashar2shahid Apr 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you saying it will always return the gas estimate for when the airnode emits FailedRequest becase of the way estimateGas short-circuits ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. This was originally picked up by e2e tests for #1589 was failing.

@bbenligiray bbenligiray merged commit 8d05fab into master Apr 14, 2023
@bbenligiray bbenligiray deleted the airnode-rrp-dry-run branch April 14, 2023 07:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement AirnodeRrpV0DryRun.sol
3 participants