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

Updated the instance tests to support fuzzing of new integrations #1114

Closed

Conversation

jalextowle
Copy link
Contributor

Resolved Issues

Partially resolves: #1108.

Description

This PR makes several functions in the InstanceTest harness public. This makes it possible to leverage this functionality on a mainnet fork to run fuzz tests against new integrations. This is the PR that should bring this system to the MCP (minimum crappy product). Some notable features that are absent are:

  • The ability to fund arbitrary accounts. For now, these integrations will rely upon whale addresses, which also means that the fork block is important.
  • Advance time will increase the time internally as well as accrue interest. This PR doesn't add a separate accrue function, although that will not be hard to add in a later PR.

@coveralls
Copy link
Collaborator

coveralls commented Jul 25, 2024

Pull Request Test Coverage Report for Build 10115614749

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 91.635%

Totals Coverage Status
Change from base Build 10082126926: 0.0%
Covered Lines: 2147
Relevant Lines: 2343

💛 - Coveralls

Copy link
Contributor

@slundqui slundqui left a comment

Choose a reason for hiding this comment

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

Thanks for putting this together! Everything here looks relatively straightforward to use

test/instances/aave/AaveHyperdrive.t.sol Show resolved Hide resolved
Copy link

Hyperdrive Gas Benchmark

Benchmark suite Current: acabdd1 Previous: 4ca3f48 Deviation Status
addLiquidity: min 33893 gas 33893 gas 0% 🟰
addLiquidity: avg 197052 gas 197443 gas -0.1980%
addLiquidity: max 474728 gas 474728 gas 0% 🟰
checkpoint: min 40316 gas 40316 gas 0% 🟰
checkpoint: avg 144561 gas 144499 gas 0.0429% 🚨
checkpoint: max 256108 gas 256108 gas 0% 🟰
closeLong: min 31384 gas 31384 gas 0% 🟰
closeLong: avg 135730 gas 135945 gas -0.1582%
closeLong: max 2539399 gas 2539399 gas 0% 🟰
closeShort: min 31327 gas 31327 gas 0% 🟰
closeShort: avg 131288 gas 131311 gas -0.0175%
closeShort: max 271250 gas 271250 gas 0% 🟰
initialize: min 31305 gas 31305 gas 0% 🟰
initialize: avg 352480 gas 352308 gas 0.0488% 🚨
initialize: max 418715 gas 418715 gas 0% 🟰
openLong: min 33370 gas 33370 gas 0% 🟰
openLong: avg 174167 gas 174213 gas -0.0264%
openLong: max 333715 gas 333715 gas 0% 🟰
openShort: min 33936 gas 33936 gas 0% 🟰
openShort: avg 174178 gas 174136 gas 0.0241% 🚨
openShort: max 415161 gas 412616 gas 0.6168% 🚨
redeemWithdrawalShares: min 31211 gas 31211 gas 0% 🟰
redeemWithdrawalShares: avg 74994 gas 74990 gas 0.0053% 🚨
redeemWithdrawalShares: max 305162 gas 305162 gas 0% 🟰
removeLiquidity: min 31217 gas 31217 gas 0% 🟰
removeLiquidity: avg 215063 gas 214590 gas 0.2204% 🚨
removeLiquidity: max 403554 gas 403554 gas 0% 🟰

This comment was automatically generated by workflow using github-action-benchmark.

@@ -80,14 +80,14 @@ contract AaveHyperdriveTest is InstanceTest {

/// @dev Gets the extra data used to deploy Hyperdrive instances.
/// @return The extra data.
function getExtraData() internal pure override returns (bytes memory) {
function getExtraData() public pure override returns (bytes memory) {
return new bytes(0);
}

/// @dev Converts base amount to the equivalent about in shares.
function convertToShares(
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this reimplemented rather than calling the public method on the hyperdrive instance?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question. That method isn’t available before deployHyperdrive is called, and this is used within deployHyperdrive. We might be able to find a workaround in the future, but for now, we need this.

@@ -1,6 +1,8 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.20;

import { console2 as console } from "forge-std/console2.sol";

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change

@@ -110,12 +110,12 @@ contract AaveHyperdriveTest is InstanceTest {
/// @param _factory The address of the Hyperdrive factory.
function deployCoordinator(
address _factory
) internal override returns (address) {
) public override returns (address) {
vm.startPrank(alice);
Copy link
Contributor

Choose a reason for hiding this comment

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

I seem to be having trouble calling this contract's functions. My best guess is that I'm not using the alice account correctly from this function. Any chance we can either (1) expose the private key of alice, or (2) allow the account as an argument?

@@ -110,12 +110,12 @@ contract AaveHyperdriveTest is InstanceTest {
/// @param _factory The address of the Hyperdrive factory.
function deployCoordinator(
address _factory
) internal override returns (address) {
) public override returns (address) {
vm.startPrank(alice);
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm attempting to deploy this contract, then call this function to deploy the coordinator, but getting execution reverted on this line. Are cheatcodes supported when the contract is deployed?

@jalextowle
Copy link
Contributor Author

Closing this since we found that this wasn't a viable path to fuzzing the instances.

@jalextowle jalextowle closed this Aug 20, 2024
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.

Fuzzing Harness
4 participants